@redocly/theme 0.9.15 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { PropsWithChildren } from 'react';
|
|
2
|
+
type Child = {
|
|
3
|
+
props: {
|
|
4
|
+
label: string;
|
|
5
|
+
} & TabsProps;
|
|
6
|
+
};
|
|
2
7
|
type TabsProps = PropsWithChildren<{
|
|
3
|
-
children:
|
|
4
|
-
props: {
|
|
5
|
-
label: string;
|
|
6
|
-
} & TabsProps;
|
|
7
|
-
}[];
|
|
8
|
+
children: Child[];
|
|
8
9
|
}>;
|
|
9
|
-
export declare function Tabs(
|
|
10
|
+
export declare function Tabs(props: TabsProps): JSX.Element;
|
|
10
11
|
export {};
|
|
@@ -30,8 +30,10 @@ exports.Tabs = void 0;
|
|
|
30
30
|
const react_1 = __importStar(require("react"));
|
|
31
31
|
const styled_components_1 = __importDefault(require("styled-components"));
|
|
32
32
|
const Tab_1 = require("../../Markdown/Tabs/Tab");
|
|
33
|
-
function Tabs(
|
|
34
|
-
|
|
33
|
+
function Tabs(props) {
|
|
34
|
+
var _a;
|
|
35
|
+
const children = react_1.default.Children.toArray(props.children);
|
|
36
|
+
const [activeTab, setActiveTab] = (0, react_1.useState)((_a = children[0]) === null || _a === void 0 ? void 0 : _a.props.label);
|
|
35
37
|
const onTabSelect = (label) => setActiveTab(label);
|
|
36
38
|
return (react_1.default.createElement(TabsContainer, { "data-component-name": "Markdown/Tabs/Tabs" },
|
|
37
39
|
react_1.default.createElement(TabList, null, children.map((child) => {
|
package/package.json
CHANGED
|
@@ -5,10 +5,12 @@ import type { PropsWithChildren } from 'react';
|
|
|
5
5
|
|
|
6
6
|
import { Tab } from '@theme/Markdown/Tabs/Tab';
|
|
7
7
|
|
|
8
|
-
type
|
|
8
|
+
type Child = { props: { label: string } & TabsProps };
|
|
9
|
+
type TabsProps = PropsWithChildren<{ children: Child[] }>;
|
|
9
10
|
|
|
10
|
-
export function Tabs(
|
|
11
|
-
const
|
|
11
|
+
export function Tabs(props: TabsProps): JSX.Element {
|
|
12
|
+
const children = React.Children.toArray(props.children) as Child[];
|
|
13
|
+
const [activeTab, setActiveTab] = useState(children[0]?.props.label);
|
|
12
14
|
const onTabSelect = (label: string) => setActiveTab(label);
|
|
13
15
|
|
|
14
16
|
return (
|