Skip to content

Commit

Permalink
Merge branch 'main' into fix-light
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeldking authored Jan 23, 2024
2 parents b9f9ed2 + 9b59376 commit 118abff
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 8 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/release-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 12
node-version: 20
- run: npm ci
- run: npm test

Expand All @@ -22,7 +22,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 12
node-version: 20
registry-url: https://npm.pkg.github.com/
- run: npm ci
- run: npm publish
Expand Down
23 changes: 23 additions & 0 deletions .github/workflows/release-please.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: release-please

on:
push:
branches: [main]

permissions:
contents: write
pull-requests: write

jobs:
release-please:
runs-on: ubuntu-latest
steps:
- uses: google-github-actions/release-please-action@v4
with:
# this assumes that you have created a personal access token
# (PAT) and configured it as a GitHub action secret named
# `RELEASE_PLEASE_TOKEN` (this secret name is not important).
token: ${{ secrets.RELEASE_PLEASE_TOKEN }}
# this is a built-in strategy in release-please, see "Action Inputs"
# for more options
release-type: node
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "1.0.7",
"version": "1.0.8",
"license": "MIT",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
Expand Down
18 changes: 13 additions & 5 deletions src/tabs/Tabs.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React, {
useState,
Children,
cloneElement,
ReactNode,
isValidElement,
ReactElement,
HtmlHTMLAttributes,
} from 'react';
import { useControlledState } from '@react-stately/utils';
import { Text } from '../content';
import { css } from '@emotion/react';
import { Orientation } from '../types/orientation';
Expand Down Expand Up @@ -112,6 +112,10 @@ function parseTabList(children: ReactNode): Tab[] {
export type TabsProps = {
children: ReactNode[];
className?: string;
/**
* If specified, the index of the selected tab is controlled by the parent component rather than the internal state.
*/
index?: number;
onChange?: (index: number) => void;
/**
* The orientation of the tabs. Defaults to horizontal
Expand All @@ -127,16 +131,21 @@ export type TabsProps = {
export function Tabs({
children,
className,
index,
onChange,
orientation = 'horizontal',
extra,
}: TabsProps) {
// Filter out the nulls from the children so that tabs can be mounted conditionally
children = Children.toArray(children).filter(child => child);
const tabs = parseTabList(children);
// Initialize the selected tab to the first non-hidden tab
const [selectedIndex, setSelectedIndex] = useState<number>(
tabs.findIndex(tab => !tab.hidden)

// Initialize the selected tab to the first non-hidden tab if there is no controlled value provided
const defaultValue = tabs.findIndex(tab => !tab.hidden);
const [selectedIndex, setSelectedIndex] = useControlledState(
index,
defaultValue,
onChange
);
return (
<div
Expand All @@ -159,7 +168,6 @@ export function Tabs({
onClick={e => {
e.preventDefault();
setSelectedIndex(index);
onChange && onChange(index);
}}
{...tab?.tabListItemProps}
>
Expand Down

0 comments on commit 118abff

Please sign in to comment.