@docusaurus/theme-classic 2.2.0 → 2.3.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.
- package/lib/getSwizzleConfig.js +35 -1
- package/lib/theme/DocBreadcrumbs/Items/Home/index.d.ts +8 -0
- package/lib/theme/DocBreadcrumbs/Items/Home/index.js +29 -0
- package/lib/theme/DocBreadcrumbs/Items/Home/styles.module.css +14 -0
- package/lib/theme/DocBreadcrumbs/index.js +1 -19
- package/lib/theme/DocBreadcrumbs/styles.module.css +0 -8
- package/lib/theme/DocPage/Layout/Sidebar/ExpandButton/styles.module.css +3 -2
- package/lib/theme/DocPage/Layout/Sidebar/index.js +13 -8
- package/lib/theme/DocPage/Layout/Sidebar/styles.module.css +7 -0
- package/lib/theme/DocPage/Layout/styles.module.css +1 -0
- package/lib/theme/DocSidebar/Desktop/CollapseButton/styles.module.css +1 -0
- package/lib/theme/DocSidebar/Desktop/Content/index.js +6 -0
- package/lib/theme/DocSidebar/Desktop/styles.module.css +0 -6
- package/lib/theme/Heading/index.js +17 -8
- package/lib/theme/Layout/Provider/index.js +0 -2
- package/lib/theme/Layout/styles.module.css +2 -0
- package/lib/theme/Navbar/Layout/index.js +6 -0
- package/lib/theme/Tabs/index.js +63 -130
- package/package.json +14 -14
- package/src/getSwizzleConfig.ts +39 -1
- package/src/theme/DocBreadcrumbs/Items/Home/index.tsx +33 -0
- package/src/theme/DocBreadcrumbs/Items/Home/styles.module.css +14 -0
- package/src/theme/DocBreadcrumbs/index.tsx +1 -20
- package/src/theme/DocBreadcrumbs/styles.module.css +0 -8
- package/src/theme/DocPage/Layout/Sidebar/ExpandButton/styles.module.css +3 -2
- package/src/theme/DocPage/Layout/Sidebar/index.tsx +13 -8
- package/src/theme/DocPage/Layout/Sidebar/styles.module.css +7 -0
- package/src/theme/DocPage/Layout/styles.module.css +1 -0
- package/src/theme/DocSidebar/Desktop/CollapseButton/styles.module.css +1 -0
- package/src/theme/DocSidebar/Desktop/Content/index.tsx +6 -0
- package/src/theme/DocSidebar/Desktop/styles.module.css +0 -6
- package/src/theme/Heading/index.tsx +18 -8
- package/src/theme/Layout/Provider/index.tsx +0 -2
- package/src/theme/Layout/styles.module.css +2 -0
- package/src/theme/Navbar/Layout/index.tsx +6 -0
- package/src/theme/Tabs/index.tsx +79 -142
- package/src/theme-classic.d.ts +8 -25
package/lib/getSwizzleConfig.js
CHANGED
|
@@ -17,6 +17,13 @@ function getSwizzleConfig() {
|
|
|
17
17
|
},
|
|
18
18
|
description: 'The component used to render multi-line code blocks, generally used in Markdown files.',
|
|
19
19
|
},
|
|
20
|
+
'CodeBlock/Content': {
|
|
21
|
+
actions: {
|
|
22
|
+
eject: 'unsafe',
|
|
23
|
+
wrap: 'forbidden',
|
|
24
|
+
},
|
|
25
|
+
description: 'The folder containing components responsible for rendering different types of CodeBlock content.',
|
|
26
|
+
},
|
|
20
27
|
ColorModeToggle: {
|
|
21
28
|
actions: {
|
|
22
29
|
eject: 'safe',
|
|
@@ -24,6 +31,13 @@ function getSwizzleConfig() {
|
|
|
24
31
|
},
|
|
25
32
|
description: 'The color mode toggle to switch between light and dark mode.',
|
|
26
33
|
},
|
|
34
|
+
'DocBreadcrumbs/Items': {
|
|
35
|
+
actions: {
|
|
36
|
+
eject: 'unsafe',
|
|
37
|
+
wrap: 'forbidden', // Can't wrap a folder
|
|
38
|
+
},
|
|
39
|
+
description: 'The components responsible for rendering the breadcrumb items',
|
|
40
|
+
},
|
|
27
41
|
DocCardList: {
|
|
28
42
|
actions: {
|
|
29
43
|
eject: 'safe',
|
|
@@ -31,6 +45,16 @@ function getSwizzleConfig() {
|
|
|
31
45
|
},
|
|
32
46
|
description: 'The component responsible for rendering a list of sidebar items cards.\nNotable used on the category generated-index pages.',
|
|
33
47
|
},
|
|
48
|
+
'DocItem/TOC': {
|
|
49
|
+
actions: {
|
|
50
|
+
// Forbidden because it's a parent folder, makes the CLI crash atm
|
|
51
|
+
// TODO the CLI should rather support --eject
|
|
52
|
+
// Subfolders can be swizzled
|
|
53
|
+
eject: 'forbidden',
|
|
54
|
+
wrap: 'forbidden',
|
|
55
|
+
},
|
|
56
|
+
description: 'The DocItem TOC is not directly swizzle-able, but you can swizzle its sub-components.',
|
|
57
|
+
},
|
|
34
58
|
DocSidebar: {
|
|
35
59
|
actions: {
|
|
36
60
|
eject: 'unsafe',
|
|
@@ -94,6 +118,16 @@ function getSwizzleConfig() {
|
|
|
94
118
|
},
|
|
95
119
|
description: 'The footer logo',
|
|
96
120
|
},
|
|
121
|
+
Icon: {
|
|
122
|
+
actions: {
|
|
123
|
+
// Forbidden because it's a parent folder, makes the CLI crash atm
|
|
124
|
+
// TODO the CLI should rather support --eject
|
|
125
|
+
// Subfolders can be swizzled
|
|
126
|
+
eject: 'forbidden',
|
|
127
|
+
wrap: 'forbidden',
|
|
128
|
+
},
|
|
129
|
+
description: 'The Icon folder is not directly swizzle-able, but you can swizzle its sub-components.',
|
|
130
|
+
},
|
|
97
131
|
'Icon/Arrow': {
|
|
98
132
|
actions: {
|
|
99
133
|
eject: 'safe',
|
|
@@ -204,7 +238,7 @@ function getSwizzleConfig() {
|
|
|
204
238
|
eject: 'safe',
|
|
205
239
|
wrap: 'forbidden',
|
|
206
240
|
},
|
|
207
|
-
description: 'The Navbar item components mapping. Can be ejected to add custom navbar item types
|
|
241
|
+
description: 'The Navbar item components mapping. Can be ejected to add custom navbar item types.\nSee https://github.com/facebook/docusaurus/issues/7227.',
|
|
208
242
|
},
|
|
209
243
|
NotFound: {
|
|
210
244
|
actions: {
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
/// <reference types="react" />
|
|
8
|
+
export default function HomeBreadcrumbItem(): JSX.Element;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import Link from '@docusaurus/Link';
|
|
9
|
+
import useBaseUrl from '@docusaurus/useBaseUrl';
|
|
10
|
+
import {translate} from '@docusaurus/Translate';
|
|
11
|
+
import IconHome from '@theme/Icon/Home';
|
|
12
|
+
import styles from './styles.module.css';
|
|
13
|
+
export default function HomeBreadcrumbItem() {
|
|
14
|
+
const homeHref = useBaseUrl('/');
|
|
15
|
+
return (
|
|
16
|
+
<li className="breadcrumbs__item">
|
|
17
|
+
<Link
|
|
18
|
+
aria-label={translate({
|
|
19
|
+
id: 'theme.docs.breadcrumbs.home',
|
|
20
|
+
message: 'Home page',
|
|
21
|
+
description: 'The ARIA label for the home page in the breadcrumbs',
|
|
22
|
+
})}
|
|
23
|
+
className="breadcrumbs__link"
|
|
24
|
+
href={homeHref}>
|
|
25
|
+
<IconHome className={styles.breadcrumbHomeIcon} />
|
|
26
|
+
</Link>
|
|
27
|
+
</li>
|
|
28
|
+
);
|
|
29
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
.breadcrumbHomeIcon {
|
|
9
|
+
position: relative;
|
|
10
|
+
top: 1px;
|
|
11
|
+
vertical-align: top;
|
|
12
|
+
height: 1.1rem;
|
|
13
|
+
width: 1.1rem;
|
|
14
|
+
}
|
|
@@ -12,9 +12,8 @@ import {
|
|
|
12
12
|
useHomePageRoute,
|
|
13
13
|
} from '@docusaurus/theme-common/internal';
|
|
14
14
|
import Link from '@docusaurus/Link';
|
|
15
|
-
import useBaseUrl from '@docusaurus/useBaseUrl';
|
|
16
15
|
import {translate} from '@docusaurus/Translate';
|
|
17
|
-
import
|
|
16
|
+
import HomeBreadcrumbItem from '@theme/DocBreadcrumbs/Items/Home';
|
|
18
17
|
import styles from './styles.module.css';
|
|
19
18
|
// TODO move to design system folder
|
|
20
19
|
function BreadcrumbsItemLink({children, href, isLast}) {
|
|
@@ -56,23 +55,6 @@ function BreadcrumbsItem({children, active, index, addMicrodata}) {
|
|
|
56
55
|
</li>
|
|
57
56
|
);
|
|
58
57
|
}
|
|
59
|
-
function HomeBreadcrumbItem() {
|
|
60
|
-
const homeHref = useBaseUrl('/');
|
|
61
|
-
return (
|
|
62
|
-
<li className="breadcrumbs__item">
|
|
63
|
-
<Link
|
|
64
|
-
aria-label={translate({
|
|
65
|
-
id: 'theme.docs.breadcrumbs.home',
|
|
66
|
-
message: 'Home page',
|
|
67
|
-
description: 'The ARIA label for the home page in the breadcrumbs',
|
|
68
|
-
})}
|
|
69
|
-
className={clsx('breadcrumbs__link', styles.breadcrumbsItemLink)}
|
|
70
|
-
href={homeHref}>
|
|
71
|
-
<IconHome className={styles.breadcrumbHomeIcon} />
|
|
72
|
-
</Link>
|
|
73
|
-
</li>
|
|
74
|
-
);
|
|
75
|
-
}
|
|
76
58
|
export default function DocBreadcrumbs() {
|
|
77
59
|
const breadcrumbs = useSidebarBreadcrumbs();
|
|
78
60
|
const homePageRoute = useHomePageRoute();
|
|
@@ -52,15 +52,20 @@ export default function DocPageLayoutSidebar({
|
|
|
52
52
|
}
|
|
53
53
|
}}>
|
|
54
54
|
<ResetOnSidebarChange>
|
|
55
|
-
<
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
55
|
+
<div
|
|
56
|
+
className={clsx(
|
|
57
|
+
styles.sidebarViewport,
|
|
58
|
+
hiddenSidebar && styles.sidebarViewportHidden,
|
|
59
|
+
)}>
|
|
60
|
+
<DocSidebar
|
|
61
|
+
sidebar={sidebar}
|
|
62
|
+
path={pathname}
|
|
63
|
+
onCollapse={toggleSidebar}
|
|
64
|
+
isHidden={hiddenSidebar}
|
|
65
|
+
/>
|
|
66
|
+
{hiddenSidebar && <ExpandButton toggleSidebar={toggleSidebar} />}
|
|
67
|
+
</div>
|
|
61
68
|
</ResetOnSidebarChange>
|
|
62
|
-
|
|
63
|
-
{hiddenSidebar && <ExpandButton toggleSidebar={toggleSidebar} />}
|
|
64
69
|
</aside>
|
|
65
70
|
);
|
|
66
71
|
}
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
useAnnouncementBar,
|
|
12
12
|
useScrollPosition,
|
|
13
13
|
} from '@docusaurus/theme-common/internal';
|
|
14
|
+
import {translate} from '@docusaurus/Translate';
|
|
14
15
|
import DocSidebarItems from '@theme/DocSidebarItems';
|
|
15
16
|
import styles from './styles.module.css';
|
|
16
17
|
function useShowAnnouncementBar() {
|
|
@@ -30,6 +31,11 @@ export default function DocSidebarDesktopContent({path, sidebar, className}) {
|
|
|
30
31
|
const showAnnouncementBar = useShowAnnouncementBar();
|
|
31
32
|
return (
|
|
32
33
|
<nav
|
|
34
|
+
aria-label={translate({
|
|
35
|
+
id: 'theme.docs.sidebar.navAriaLabel',
|
|
36
|
+
message: 'Docs sidebar',
|
|
37
|
+
description: 'The ARIA label for the sidebar navigation',
|
|
38
|
+
})}
|
|
33
39
|
className={clsx(
|
|
34
40
|
'menu thin-scrollbar',
|
|
35
41
|
styles.menu,
|
|
@@ -9,13 +9,9 @@
|
|
|
9
9
|
.sidebar {
|
|
10
10
|
display: flex;
|
|
11
11
|
flex-direction: column;
|
|
12
|
-
max-height: 100vh;
|
|
13
12
|
height: 100%;
|
|
14
|
-
position: sticky;
|
|
15
|
-
top: 0;
|
|
16
13
|
padding-top: var(--ifm-navbar-height);
|
|
17
14
|
width: var(--doc-sidebar-width);
|
|
18
|
-
transition: opacity 50ms ease;
|
|
19
15
|
}
|
|
20
16
|
|
|
21
17
|
.sidebarWithHideableNavbar {
|
|
@@ -24,8 +20,6 @@
|
|
|
24
20
|
|
|
25
21
|
.sidebarHidden {
|
|
26
22
|
opacity: 0;
|
|
27
|
-
height: 0;
|
|
28
|
-
overflow: hidden;
|
|
29
23
|
visibility: hidden;
|
|
30
24
|
}
|
|
31
25
|
|
|
@@ -8,6 +8,7 @@ import React from 'react';
|
|
|
8
8
|
import clsx from 'clsx';
|
|
9
9
|
import {translate} from '@docusaurus/Translate';
|
|
10
10
|
import {useThemeConfig} from '@docusaurus/theme-common';
|
|
11
|
+
import Link from '@docusaurus/Link';
|
|
11
12
|
import styles from './styles.module.css';
|
|
12
13
|
export default function Heading({as: As, id, ...props}) {
|
|
13
14
|
const {
|
|
@@ -17,6 +18,16 @@ export default function Heading({as: As, id, ...props}) {
|
|
|
17
18
|
if (As === 'h1' || !id) {
|
|
18
19
|
return <As {...props} id={undefined} />;
|
|
19
20
|
}
|
|
21
|
+
const anchorTitle = translate(
|
|
22
|
+
{
|
|
23
|
+
id: 'theme.common.headingLinkTitle',
|
|
24
|
+
message: 'Direct link to {heading}',
|
|
25
|
+
description: 'Title for link to heading',
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
heading: typeof props.children === 'string' ? props.children : id,
|
|
29
|
+
},
|
|
30
|
+
);
|
|
20
31
|
return (
|
|
21
32
|
<As
|
|
22
33
|
{...props}
|
|
@@ -25,19 +36,17 @@ export default function Heading({as: As, id, ...props}) {
|
|
|
25
36
|
hideOnScroll
|
|
26
37
|
? styles.anchorWithHideOnScrollNavbar
|
|
27
38
|
: styles.anchorWithStickyNavbar,
|
|
39
|
+
props.className,
|
|
28
40
|
)}
|
|
29
41
|
id={id}>
|
|
30
42
|
{props.children}
|
|
31
|
-
<
|
|
43
|
+
<Link
|
|
32
44
|
className="hash-link"
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
message: 'Direct link to heading',
|
|
37
|
-
description: 'Title for link to heading',
|
|
38
|
-
})}>
|
|
45
|
+
to={`#${id}`}
|
|
46
|
+
aria-label={anchorTitle}
|
|
47
|
+
title={anchorTitle}>
|
|
39
48
|
​
|
|
40
|
-
</
|
|
49
|
+
</Link>
|
|
41
50
|
</As>
|
|
42
51
|
);
|
|
43
52
|
}
|
|
@@ -8,7 +8,6 @@ import React from 'react';
|
|
|
8
8
|
import {composeProviders} from '@docusaurus/theme-common';
|
|
9
9
|
import {
|
|
10
10
|
ColorModeProvider,
|
|
11
|
-
TabGroupChoiceProvider,
|
|
12
11
|
AnnouncementBarProvider,
|
|
13
12
|
DocsPreferredVersionContextProvider,
|
|
14
13
|
ScrollControllerProvider,
|
|
@@ -18,7 +17,6 @@ import {
|
|
|
18
17
|
const Provider = composeProviders([
|
|
19
18
|
ColorModeProvider,
|
|
20
19
|
AnnouncementBarProvider,
|
|
21
|
-
TabGroupChoiceProvider,
|
|
22
20
|
ScrollControllerProvider,
|
|
23
21
|
DocsPreferredVersionContextProvider,
|
|
24
22
|
PluginHtmlClassNameProvider,
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
useHideableNavbar,
|
|
12
12
|
useNavbarMobileSidebar,
|
|
13
13
|
} from '@docusaurus/theme-common/internal';
|
|
14
|
+
import {translate} from '@docusaurus/Translate';
|
|
14
15
|
import NavbarMobileSidebar from '@theme/Navbar/MobileSidebar';
|
|
15
16
|
import styles from './styles.module.css';
|
|
16
17
|
function NavbarBackdrop(props) {
|
|
@@ -31,6 +32,11 @@ export default function NavbarLayout({children}) {
|
|
|
31
32
|
return (
|
|
32
33
|
<nav
|
|
33
34
|
ref={navbarRef}
|
|
35
|
+
aria-label={translate({
|
|
36
|
+
id: 'theme.NavBar.navAriaLabel',
|
|
37
|
+
message: 'Main',
|
|
38
|
+
description: 'The ARIA label for the main navigation',
|
|
39
|
+
})}
|
|
34
40
|
className={clsx(
|
|
35
41
|
'navbar',
|
|
36
42
|
'navbar--fixed-top',
|
package/lib/theme/Tabs/index.js
CHANGED
|
@@ -4,99 +4,25 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
import React, {
|
|
7
|
+
import React, {cloneElement} from 'react';
|
|
8
8
|
import clsx from 'clsx';
|
|
9
|
-
import useIsBrowser from '@docusaurus/useIsBrowser';
|
|
10
|
-
import {duplicates} from '@docusaurus/theme-common';
|
|
11
9
|
import {
|
|
12
10
|
useScrollPositionBlocker,
|
|
13
|
-
|
|
11
|
+
useTabs,
|
|
14
12
|
} from '@docusaurus/theme-common/internal';
|
|
13
|
+
import useIsBrowser from '@docusaurus/useIsBrowser';
|
|
15
14
|
import styles from './styles.module.css';
|
|
16
|
-
|
|
17
|
-
// allowing customization
|
|
18
|
-
function isTabItem(comp) {
|
|
19
|
-
return 'value' in comp.props;
|
|
20
|
-
}
|
|
21
|
-
function TabsComponent(props) {
|
|
22
|
-
const {
|
|
23
|
-
lazy,
|
|
24
|
-
block,
|
|
25
|
-
defaultValue: defaultValueProp,
|
|
26
|
-
values: valuesProp,
|
|
27
|
-
groupId,
|
|
28
|
-
className,
|
|
29
|
-
} = props;
|
|
30
|
-
const children = React.Children.map(props.children, (child) => {
|
|
31
|
-
if (isValidElement(child) && isTabItem(child)) {
|
|
32
|
-
return child;
|
|
33
|
-
}
|
|
34
|
-
// child.type.name will give non-sensical values in prod because of
|
|
35
|
-
// minification, but we assume it won't throw in prod.
|
|
36
|
-
throw new Error(
|
|
37
|
-
`Docusaurus error: Bad <Tabs> child <${
|
|
38
|
-
// @ts-expect-error: guarding against unexpected cases
|
|
39
|
-
typeof child.type === 'string' ? child.type : child.type.name
|
|
40
|
-
}>: all children of the <Tabs> component should be <TabItem>, and every <TabItem> should have a unique "value" prop.`,
|
|
41
|
-
);
|
|
42
|
-
});
|
|
43
|
-
const values =
|
|
44
|
-
valuesProp ??
|
|
45
|
-
// Only pick keys that we recognize. MDX would inject some keys by default
|
|
46
|
-
children.map(({props: {value, label, attributes}}) => ({
|
|
47
|
-
value,
|
|
48
|
-
label,
|
|
49
|
-
attributes,
|
|
50
|
-
}));
|
|
51
|
-
const dup = duplicates(values, (a, b) => a.value === b.value);
|
|
52
|
-
if (dup.length > 0) {
|
|
53
|
-
throw new Error(
|
|
54
|
-
`Docusaurus error: Duplicate values "${dup
|
|
55
|
-
.map((a) => a.value)
|
|
56
|
-
.join(', ')}" found in <Tabs>. Every value needs to be unique.`,
|
|
57
|
-
);
|
|
58
|
-
}
|
|
59
|
-
// When defaultValueProp is null, don't show a default tab
|
|
60
|
-
const defaultValue =
|
|
61
|
-
defaultValueProp === null
|
|
62
|
-
? defaultValueProp
|
|
63
|
-
: defaultValueProp ??
|
|
64
|
-
children.find((child) => child.props.default)?.props.value ??
|
|
65
|
-
children[0].props.value;
|
|
66
|
-
if (defaultValue !== null && !values.some((a) => a.value === defaultValue)) {
|
|
67
|
-
throw new Error(
|
|
68
|
-
`Docusaurus error: The <Tabs> has a defaultValue "${defaultValue}" but none of its children has the corresponding value. Available values are: ${values
|
|
69
|
-
.map((a) => a.value)
|
|
70
|
-
.join(
|
|
71
|
-
', ',
|
|
72
|
-
)}. If you intend to show no default tab, use defaultValue={null} instead.`,
|
|
73
|
-
);
|
|
74
|
-
}
|
|
75
|
-
const {tabGroupChoices, setTabGroupChoices} = useTabGroupChoice();
|
|
76
|
-
const [selectedValue, setSelectedValue] = useState(defaultValue);
|
|
15
|
+
function TabList({className, block, selectedValue, selectValue, tabValues}) {
|
|
77
16
|
const tabRefs = [];
|
|
78
17
|
const {blockElementScrollPositionUntilNextRender} =
|
|
79
18
|
useScrollPositionBlocker();
|
|
80
|
-
if (groupId != null) {
|
|
81
|
-
const relevantTabGroupChoice = tabGroupChoices[groupId];
|
|
82
|
-
if (
|
|
83
|
-
relevantTabGroupChoice != null &&
|
|
84
|
-
relevantTabGroupChoice !== selectedValue &&
|
|
85
|
-
values.some((value) => value.value === relevantTabGroupChoice)
|
|
86
|
-
) {
|
|
87
|
-
setSelectedValue(relevantTabGroupChoice);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
19
|
const handleTabChange = (event) => {
|
|
91
20
|
const newTab = event.currentTarget;
|
|
92
21
|
const newTabIndex = tabRefs.indexOf(newTab);
|
|
93
|
-
const newTabValue =
|
|
22
|
+
const newTabValue = tabValues[newTabIndex].value;
|
|
94
23
|
if (newTabValue !== selectedValue) {
|
|
95
24
|
blockElementScrollPositionUntilNextRender(newTab);
|
|
96
|
-
|
|
97
|
-
if (groupId != null) {
|
|
98
|
-
setTabGroupChoices(groupId, String(newTabValue));
|
|
99
|
-
}
|
|
25
|
+
selectValue(newTabValue);
|
|
100
26
|
}
|
|
101
27
|
};
|
|
102
28
|
const handleKeydown = (event) => {
|
|
@@ -122,60 +48,67 @@ function TabsComponent(props) {
|
|
|
122
48
|
focusElement?.focus();
|
|
123
49
|
};
|
|
124
50
|
return (
|
|
125
|
-
<
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
)}
|
|
174
|
-
</div>
|
|
51
|
+
<ul
|
|
52
|
+
role="tablist"
|
|
53
|
+
aria-orientation="horizontal"
|
|
54
|
+
className={clsx(
|
|
55
|
+
'tabs',
|
|
56
|
+
{
|
|
57
|
+
'tabs--block': block,
|
|
58
|
+
},
|
|
59
|
+
className,
|
|
60
|
+
)}>
|
|
61
|
+
{tabValues.map(({value, label, attributes}) => (
|
|
62
|
+
<li
|
|
63
|
+
// TODO extract TabListItem
|
|
64
|
+
role="tab"
|
|
65
|
+
tabIndex={selectedValue === value ? 0 : -1}
|
|
66
|
+
aria-selected={selectedValue === value}
|
|
67
|
+
key={value}
|
|
68
|
+
ref={(tabControl) => tabRefs.push(tabControl)}
|
|
69
|
+
onKeyDown={handleKeydown}
|
|
70
|
+
onClick={handleTabChange}
|
|
71
|
+
{...attributes}
|
|
72
|
+
className={clsx('tabs__item', styles.tabItem, attributes?.className, {
|
|
73
|
+
'tabs__item--active': selectedValue === value,
|
|
74
|
+
})}>
|
|
75
|
+
{label ?? value}
|
|
76
|
+
</li>
|
|
77
|
+
))}
|
|
78
|
+
</ul>
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
function TabContent({lazy, children, selectedValue}) {
|
|
82
|
+
if (lazy) {
|
|
83
|
+
const selectedTabItem = children.find(
|
|
84
|
+
(tabItem) => tabItem.props.value === selectedValue,
|
|
85
|
+
);
|
|
86
|
+
if (!selectedTabItem) {
|
|
87
|
+
// fail-safe or fail-fast? not sure what's best here
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
return cloneElement(selectedTabItem, {className: 'margin-top--md'});
|
|
91
|
+
}
|
|
92
|
+
return (
|
|
93
|
+
<div className="margin-top--md">
|
|
94
|
+
{children.map((tabItem, i) =>
|
|
95
|
+
cloneElement(tabItem, {
|
|
96
|
+
key: i,
|
|
97
|
+
hidden: tabItem.props.value !== selectedValue,
|
|
98
|
+
}),
|
|
175
99
|
)}
|
|
176
100
|
</div>
|
|
177
101
|
);
|
|
178
102
|
}
|
|
103
|
+
function TabsComponent(props) {
|
|
104
|
+
const tabs = useTabs(props);
|
|
105
|
+
return (
|
|
106
|
+
<div className={clsx('tabs-container', styles.tabList)}>
|
|
107
|
+
<TabList {...props} {...tabs} />
|
|
108
|
+
<TabContent {...props} {...tabs} />
|
|
109
|
+
</div>
|
|
110
|
+
);
|
|
111
|
+
}
|
|
179
112
|
export default function Tabs(props) {
|
|
180
113
|
const isBrowser = useIsBrowser();
|
|
181
114
|
return (
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/theme-classic",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"description": "Classic theme for Docusaurus",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "src/theme-classic.d.ts",
|
|
@@ -20,18 +20,18 @@
|
|
|
20
20
|
"copy:watch": "node ../../admin/scripts/copyUntypedFiles.js --watch"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@docusaurus/core": "2.
|
|
24
|
-
"@docusaurus/mdx-loader": "2.
|
|
25
|
-
"@docusaurus/module-type-aliases": "2.
|
|
26
|
-
"@docusaurus/plugin-content-blog": "2.
|
|
27
|
-
"@docusaurus/plugin-content-docs": "2.
|
|
28
|
-
"@docusaurus/plugin-content-pages": "2.
|
|
29
|
-
"@docusaurus/theme-common": "2.
|
|
30
|
-
"@docusaurus/theme-translations": "2.
|
|
31
|
-
"@docusaurus/types": "2.
|
|
32
|
-
"@docusaurus/utils": "2.
|
|
33
|
-
"@docusaurus/utils-common": "2.
|
|
34
|
-
"@docusaurus/utils-validation": "2.
|
|
23
|
+
"@docusaurus/core": "2.3.0",
|
|
24
|
+
"@docusaurus/mdx-loader": "2.3.0",
|
|
25
|
+
"@docusaurus/module-type-aliases": "2.3.0",
|
|
26
|
+
"@docusaurus/plugin-content-blog": "2.3.0",
|
|
27
|
+
"@docusaurus/plugin-content-docs": "2.3.0",
|
|
28
|
+
"@docusaurus/plugin-content-pages": "2.3.0",
|
|
29
|
+
"@docusaurus/theme-common": "2.3.0",
|
|
30
|
+
"@docusaurus/theme-translations": "2.3.0",
|
|
31
|
+
"@docusaurus/types": "2.3.0",
|
|
32
|
+
"@docusaurus/utils": "2.3.0",
|
|
33
|
+
"@docusaurus/utils-common": "2.3.0",
|
|
34
|
+
"@docusaurus/utils-validation": "2.3.0",
|
|
35
35
|
"@mdx-js/react": "^1.6.22",
|
|
36
36
|
"clsx": "^1.2.1",
|
|
37
37
|
"copy-text-to-clipboard": "^3.0.1",
|
|
@@ -62,5 +62,5 @@
|
|
|
62
62
|
"engines": {
|
|
63
63
|
"node": ">=16.14"
|
|
64
64
|
},
|
|
65
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "ad477781bdca6a11fa9c6daef5048bdcec0ee37e"
|
|
66
66
|
}
|