@docusaurus/theme-common 2.0.0-beta.2 → 2.0.0-beta.20
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/Details.d.ts +14 -0
- package/lib/components/Collapsible/index.d.ts +64 -0
- package/lib/components/Collapsible/index.d.ts.map +1 -0
- package/lib/components/Collapsible/index.js +152 -0
- package/lib/components/Collapsible/index.js.map +1 -0
- package/lib/components/Details/index.d.ts +17 -0
- package/lib/components/Details/index.d.ts.map +1 -0
- package/lib/components/Details/index.js +71 -0
- package/lib/components/Details/index.js.map +1 -0
- package/lib/components/Details/styles.module.css +62 -0
- package/lib/contexts/announcementBar.d.ts +22 -0
- package/lib/contexts/announcementBar.d.ts.map +1 -0
- package/lib/{utils/announcementBarUtils.js → contexts/announcementBar.js} +30 -31
- package/lib/contexts/announcementBar.js.map +1 -0
- package/lib/contexts/colorMode.d.ts +27 -0
- package/lib/contexts/colorMode.d.ts.map +1 -0
- package/lib/contexts/colorMode.js +132 -0
- package/lib/contexts/colorMode.js.map +1 -0
- package/lib/contexts/docSidebarItemsExpandedState.d.ts +31 -0
- package/lib/contexts/docSidebarItemsExpandedState.d.ts.map +1 -0
- package/lib/contexts/docSidebarItemsExpandedState.js +28 -0
- package/lib/contexts/docSidebarItemsExpandedState.js.map +1 -0
- package/lib/contexts/docsPreferredVersion.d.ts +31 -0
- package/lib/contexts/docsPreferredVersion.d.ts.map +1 -0
- package/lib/contexts/docsPreferredVersion.js +128 -0
- package/lib/contexts/docsPreferredVersion.js.map +1 -0
- package/lib/contexts/docsSidebar.d.ts +26 -0
- package/lib/contexts/docsSidebar.d.ts.map +1 -0
- package/lib/contexts/docsSidebar.js +30 -0
- package/lib/contexts/docsSidebar.js.map +1 -0
- package/lib/contexts/docsVersion.d.ts +20 -0
- package/lib/contexts/docsVersion.d.ts.map +1 -0
- package/lib/contexts/docsVersion.js +26 -0
- package/lib/contexts/docsVersion.js.map +1 -0
- package/lib/contexts/navbarMobileSidebar.d.ts +31 -0
- package/lib/contexts/navbarMobileSidebar.d.ts.map +1 -0
- package/lib/contexts/navbarMobileSidebar.js +56 -0
- package/lib/contexts/navbarMobileSidebar.js.map +1 -0
- package/lib/contexts/navbarSecondaryMenu/content.d.ts +37 -0
- package/lib/contexts/navbarSecondaryMenu/content.d.ts.map +1 -0
- package/lib/contexts/navbarSecondaryMenu/content.js +56 -0
- package/lib/contexts/navbarSecondaryMenu/content.js.map +1 -0
- package/lib/contexts/navbarSecondaryMenu/display.d.ts +24 -0
- package/lib/contexts/navbarSecondaryMenu/display.d.ts.map +1 -0
- package/lib/contexts/navbarSecondaryMenu/display.js +62 -0
- package/lib/contexts/navbarSecondaryMenu/display.js.map +1 -0
- package/lib/contexts/tabGroupChoice.d.ts +21 -0
- package/lib/contexts/tabGroupChoice.d.ts.map +1 -0
- package/lib/contexts/tabGroupChoice.js +49 -0
- package/lib/contexts/tabGroupChoice.js.map +1 -0
- package/lib/{utils/usePrevious.d.ts → hooks/styles.css} +4 -1
- package/lib/hooks/useBackToTopButton.d.ts +27 -0
- package/lib/hooks/useBackToTopButton.d.ts.map +1 -0
- package/lib/hooks/useBackToTopButton.js +50 -0
- package/lib/hooks/useBackToTopButton.js.map +1 -0
- package/lib/hooks/useCodeWordWrap.d.ts +14 -0
- package/lib/hooks/useCodeWordWrap.d.ts.map +1 -0
- package/lib/hooks/useCodeWordWrap.js +41 -0
- package/lib/hooks/useCodeWordWrap.js.map +1 -0
- package/lib/hooks/useHideableNavbar.d.ts +17 -0
- package/lib/hooks/useHideableNavbar.d.ts.map +1 -0
- package/lib/hooks/useHideableNavbar.js +60 -0
- package/lib/hooks/useHideableNavbar.js.map +1 -0
- package/lib/hooks/useKeyboardNavigation.d.ts +20 -0
- package/lib/hooks/useKeyboardNavigation.d.ts.map +1 -0
- package/lib/hooks/useKeyboardNavigation.js +39 -0
- package/lib/hooks/useKeyboardNavigation.js.map +1 -0
- package/lib/hooks/useLockBodyScroll.d.ts +12 -0
- package/lib/hooks/useLockBodyScroll.d.ts.map +1 -0
- package/lib/hooks/useLockBodyScroll.js +20 -0
- package/lib/hooks/useLockBodyScroll.js.map +1 -0
- package/lib/hooks/usePrismTheme.d.ts +13 -0
- package/lib/hooks/usePrismTheme.d.ts.map +1 -0
- package/lib/hooks/usePrismTheme.js +21 -0
- package/lib/hooks/usePrismTheme.js.map +1 -0
- package/lib/hooks/useSearchPage.d.ts +25 -0
- package/lib/hooks/useSearchPage.d.ts.map +1 -0
- package/lib/hooks/useSearchPage.js +43 -0
- package/lib/hooks/useSearchPage.js.map +1 -0
- package/lib/hooks/useSkipToContent.d.ts +25 -0
- package/lib/hooks/useSkipToContent.d.ts.map +1 -0
- package/lib/hooks/useSkipToContent.js +35 -0
- package/lib/hooks/useSkipToContent.js.map +1 -0
- package/lib/hooks/useTOCHighlight.d.ts +25 -0
- package/lib/hooks/useTOCHighlight.d.ts.map +1 -0
- package/lib/hooks/useTOCHighlight.js +130 -0
- package/lib/hooks/useTOCHighlight.js.map +1 -0
- package/lib/hooks/useWindowSize.d.ts +28 -0
- package/lib/hooks/useWindowSize.d.ts.map +1 -0
- package/lib/hooks/useWindowSize.js +59 -0
- package/lib/hooks/useWindowSize.js.map +1 -0
- package/lib/index.d.ts +38 -10
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +38 -9
- package/lib/index.js.map +1 -0
- package/lib/utils/ThemeClassNames.d.ts +47 -12
- package/lib/utils/ThemeClassNames.d.ts.map +1 -0
- package/lib/utils/ThemeClassNames.js +45 -4
- package/lib/utils/ThemeClassNames.js.map +1 -0
- package/lib/utils/codeBlockUtils.d.ts +63 -0
- package/lib/utils/codeBlockUtils.d.ts.map +1 -0
- package/lib/utils/codeBlockUtils.js +157 -3
- package/lib/utils/codeBlockUtils.js.map +1 -0
- package/lib/utils/docsUtils.d.ts +91 -0
- package/lib/utils/docsUtils.d.ts.map +1 -0
- package/lib/utils/docsUtils.js +217 -1
- package/lib/utils/docsUtils.js.map +1 -0
- package/lib/utils/footerUtils.d.ts +13 -0
- package/lib/utils/footerUtils.d.ts.map +1 -0
- package/lib/utils/footerUtils.js +14 -0
- package/lib/utils/footerUtils.js.map +1 -0
- package/lib/utils/generalUtils.d.ts +11 -1
- package/lib/utils/generalUtils.d.ts.map +1 -0
- package/lib/utils/generalUtils.js +9 -5
- package/lib/utils/generalUtils.js.map +1 -0
- package/lib/utils/historyUtils.d.ts +17 -0
- package/lib/utils/historyUtils.d.ts.map +1 -0
- package/lib/utils/historyUtils.js +38 -0
- package/lib/utils/historyUtils.js.map +1 -0
- package/lib/utils/jsUtils.d.ts +23 -0
- package/lib/utils/jsUtils.d.ts.map +1 -0
- package/lib/utils/jsUtils.js +29 -0
- package/lib/utils/jsUtils.js.map +1 -0
- package/lib/utils/metadataUtils.d.ts +38 -0
- package/lib/utils/metadataUtils.d.ts.map +1 -0
- package/lib/utils/metadataUtils.js +61 -0
- package/lib/utils/metadataUtils.js.map +1 -0
- package/lib/utils/navbarUtils.d.ts +21 -0
- package/lib/utils/navbarUtils.d.ts.map +1 -0
- package/lib/utils/navbarUtils.js +32 -0
- package/lib/utils/navbarUtils.js.map +1 -0
- package/lib/utils/reactUtils.d.ts +42 -0
- package/lib/utils/reactUtils.d.ts.map +1 -0
- package/lib/utils/reactUtils.js +64 -0
- package/lib/utils/reactUtils.js.map +1 -0
- package/lib/utils/regexpUtils.d.ts +12 -0
- package/lib/utils/regexpUtils.d.ts.map +1 -0
- package/lib/utils/regexpUtils.js +18 -0
- package/lib/utils/regexpUtils.js.map +1 -0
- package/lib/utils/routesUtils.d.ts +26 -0
- package/lib/utils/routesUtils.d.ts.map +1 -0
- package/lib/utils/routesUtils.js +54 -0
- package/lib/utils/routesUtils.js.map +1 -0
- package/lib/utils/scrollUtils.d.ts +83 -0
- package/lib/utils/scrollUtils.d.ts.map +1 -0
- package/lib/utils/scrollUtils.js +200 -0
- package/lib/utils/scrollUtils.js.map +1 -0
- package/lib/utils/searchUtils.d.ts +13 -0
- package/lib/utils/searchUtils.d.ts.map +1 -0
- package/lib/utils/searchUtils.js +37 -0
- package/lib/utils/searchUtils.js.map +1 -0
- package/lib/utils/storageUtils.d.ts +15 -7
- package/lib/utils/storageUtils.d.ts.map +1 -0
- package/lib/utils/storageUtils.js +55 -22
- package/lib/utils/storageUtils.js.map +1 -0
- package/lib/utils/tagsUtils.d.ts +18 -0
- package/lib/utils/tagsUtils.d.ts.map +1 -0
- package/lib/utils/tagsUtils.js +36 -0
- package/lib/utils/tagsUtils.js.map +1 -0
- package/lib/utils/tocUtils.d.ts +36 -0
- package/lib/utils/tocUtils.d.ts.map +1 -0
- package/lib/utils/tocUtils.js +84 -0
- package/lib/utils/tocUtils.js.map +1 -0
- package/lib/utils/useAlternatePageUtils.d.ts +21 -1
- package/lib/utils/useAlternatePageUtils.d.ts.map +1 -0
- package/lib/utils/useAlternatePageUtils.js +9 -4
- package/lib/utils/useAlternatePageUtils.js.map +1 -0
- package/lib/utils/useLocalPathname.d.ts +13 -0
- package/lib/utils/useLocalPathname.d.ts.map +1 -0
- package/lib/utils/useLocalPathname.js +19 -0
- package/lib/utils/useLocalPathname.js.map +1 -0
- package/lib/utils/useLocationChange.d.ts +9 -6
- package/lib/utils/useLocationChange.d.ts.map +1 -0
- package/lib/utils/useLocationChange.js +17 -11
- package/lib/utils/useLocationChange.js.map +1 -0
- package/lib/utils/usePluralForm.d.ts +12 -0
- package/lib/utils/usePluralForm.d.ts.map +1 -0
- package/lib/utils/usePluralForm.js +36 -37
- package/lib/utils/usePluralForm.js.map +1 -0
- package/lib/utils/useThemeConfig.d.ts +55 -24
- package/lib/utils/useThemeConfig.d.ts.map +1 -0
- package/lib/utils/useThemeConfig.js +4 -0
- package/lib/utils/useThemeConfig.js.map +1 -0
- package/package.json +26 -13
- package/src/components/Collapsible/index.tsx +265 -0
- package/src/components/Details/index.tsx +109 -0
- package/src/components/Details/styles.module.css +62 -0
- package/src/{utils/announcementBarUtils.tsx → contexts/announcementBar.tsx} +43 -39
- package/src/contexts/colorMode.tsx +199 -0
- package/src/contexts/docSidebarItemsExpandedState.tsx +55 -0
- package/src/contexts/docsPreferredVersion.tsx +253 -0
- package/src/contexts/docsSidebar.tsx +50 -0
- package/src/contexts/docsVersion.tsx +36 -0
- package/src/contexts/navbarMobileSidebar.tsx +99 -0
- package/src/contexts/navbarSecondaryMenu/content.tsx +110 -0
- package/src/contexts/navbarSecondaryMenu/display.tsx +102 -0
- package/src/contexts/tabGroupChoice.tsx +85 -0
- package/{lib/utils/pathUtils.d.ts → src/hooks/styles.css} +4 -1
- package/src/hooks/useBackToTopButton.ts +73 -0
- package/src/hooks/useCodeWordWrap.ts +56 -0
- package/src/hooks/useHideableNavbar.ts +75 -0
- package/src/hooks/useKeyboardNavigation.ts +45 -0
- package/src/hooks/useLockBodyScroll.ts +21 -0
- package/src/hooks/usePrismTheme.ts +24 -0
- package/src/hooks/useSearchPage.ts +79 -0
- package/src/hooks/useSkipToContent.ts +58 -0
- package/src/hooks/useTOCHighlight.ts +192 -0
- package/src/hooks/useWindowSize.ts +72 -0
- package/src/index.ts +130 -19
- package/src/types.d.ts +0 -2
- package/src/utils/ThemeClassNames.ts +51 -5
- package/src/utils/codeBlockUtils.ts +239 -2
- package/src/utils/docsUtils.tsx +334 -0
- package/src/utils/footerUtils.ts +18 -0
- package/src/utils/generalUtils.ts +9 -5
- package/src/utils/historyUtils.ts +45 -0
- package/src/utils/jsUtils.ts +36 -0
- package/src/utils/metadataUtils.tsx +115 -0
- package/src/utils/navbarUtils.tsx +45 -0
- package/src/utils/reactUtils.tsx +76 -0
- package/src/utils/regexpUtils.ts +24 -0
- package/src/utils/routesUtils.ts +75 -0
- package/src/utils/scrollUtils.tsx +308 -0
- package/src/utils/searchUtils.ts +51 -0
- package/src/utils/storageUtils.ts +56 -23
- package/src/utils/tagsUtils.ts +50 -0
- package/src/utils/tocUtils.ts +119 -0
- package/src/utils/useAlternatePageUtils.ts +19 -6
- package/src/utils/useLocalPathname.ts +22 -0
- package/src/utils/useLocationChange.ts +24 -20
- package/src/utils/usePluralForm.ts +46 -38
- package/src/utils/useThemeConfig.ts +54 -26
- package/lib/.tsbuildinfo +0 -1
- package/lib/utils/announcementBarInlineJavaScript.d.ts +0 -0
- package/lib/utils/announcementBarInlineJavaScript.js +0 -1
- package/lib/utils/announcementBarUtils.d.ts +0 -17
- package/lib/utils/docsPreferredVersion/DocsPreferredVersionProvider.d.ts +0 -21
- package/lib/utils/docsPreferredVersion/DocsPreferredVersionProvider.js +0 -94
- package/lib/utils/docsPreferredVersion/DocsPreferredVersionStorage.d.ts +0 -13
- package/lib/utils/docsPreferredVersion/DocsPreferredVersionStorage.js +0 -20
- package/lib/utils/docsPreferredVersion/useDocsPreferredVersion.d.ts +0 -5
- package/lib/utils/docsPreferredVersion/useDocsPreferredVersion.js +0 -41
- package/lib/utils/pathUtils.js +0 -13
- package/lib/utils/usePrevious.js +0 -14
- package/src/utils/__tests__/codeBlockUtils.test.ts +0 -54
- package/src/utils/__tests__/pathUtils.test.ts +0 -32
- package/src/utils/docsPreferredVersion/DocsPreferredVersionProvider.tsx +0 -165
- package/src/utils/docsPreferredVersion/DocsPreferredVersionStorage.ts +0 -34
- package/src/utils/docsPreferredVersion/useDocsPreferredVersion.ts +0 -66
- package/src/utils/docsUtils.ts +0 -11
- package/src/utils/pathUtils.ts +0 -17
- package/src/utils/usePrevious.ts +0 -18
- package/tsconfig.json +0 -10
package/Details.d.ts
ADDED
|
@@ -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
|
+
// `Details` is a separate export entry because of side-effects messing with CSS
|
|
9
|
+
// insertion order. See https://github.com/facebook/docusaurus/pull/7085.
|
|
10
|
+
// However, because TS doesn't recognize `exports` (also a problem in
|
|
11
|
+
// `content-docs`), we have to manually create a stub.
|
|
12
|
+
|
|
13
|
+
// eslint-disable-next-line import/named
|
|
14
|
+
export {Details, type DetailsProps} from './lib/components/Details';
|
|
@@ -0,0 +1,64 @@
|
|
|
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, { type Dispatch, type SetStateAction, type ReactNode } from 'react';
|
|
8
|
+
/**
|
|
9
|
+
* This hook is a very thin wrapper around a `useState`.
|
|
10
|
+
*/
|
|
11
|
+
export declare function useCollapsible({ initialState, }: {
|
|
12
|
+
/** The initial state. Will be non-collapsed by default. */
|
|
13
|
+
initialState: boolean | (() => boolean);
|
|
14
|
+
}): {
|
|
15
|
+
collapsed: boolean;
|
|
16
|
+
setCollapsed: Dispatch<SetStateAction<boolean>>;
|
|
17
|
+
toggleCollapsed: () => void;
|
|
18
|
+
};
|
|
19
|
+
declare type CollapsibleAnimationConfig = {
|
|
20
|
+
duration?: number;
|
|
21
|
+
easing?: string;
|
|
22
|
+
};
|
|
23
|
+
declare type CollapsibleElementType = React.ElementType<Pick<React.HTMLAttributes<unknown>, 'className' | 'onTransitionEnd' | 'style'>>;
|
|
24
|
+
declare type CollapsibleBaseProps = {
|
|
25
|
+
/** The actual DOM element to be used in the markup. */
|
|
26
|
+
as?: CollapsibleElementType;
|
|
27
|
+
/** Initial collapsed state. */
|
|
28
|
+
collapsed: boolean;
|
|
29
|
+
children: ReactNode;
|
|
30
|
+
/** Configuration of animation, like `duration` and `easing` */
|
|
31
|
+
animation?: CollapsibleAnimationConfig;
|
|
32
|
+
/**
|
|
33
|
+
* A callback fired when the collapse transition animation ends. Receives
|
|
34
|
+
* the **new** collapsed state: e.g. when
|
|
35
|
+
* expanding, `collapsed` will be `false`. You can use this for some "cleanup"
|
|
36
|
+
* like applying new styles when the container is fully expanded.
|
|
37
|
+
*/
|
|
38
|
+
onCollapseTransitionEnd?: (collapsed: boolean) => void;
|
|
39
|
+
/** Class name for the underlying DOM element. */
|
|
40
|
+
className?: string;
|
|
41
|
+
/**
|
|
42
|
+
* This is mostly useful for details/summary component where ssrStyle is not
|
|
43
|
+
* needed (as details are hidden natively) and can mess up with the browser's
|
|
44
|
+
* native behavior when JS fails to load or is disabled
|
|
45
|
+
*/
|
|
46
|
+
disableSSRStyle?: boolean;
|
|
47
|
+
};
|
|
48
|
+
declare type CollapsibleProps = CollapsibleBaseProps & {
|
|
49
|
+
/**
|
|
50
|
+
* Delay rendering of the content till first expansion. Marked as required to
|
|
51
|
+
* force us to think if content should be server-rendered or not. This has
|
|
52
|
+
* perf impact since it reduces html file sizes, but could undermine SEO.
|
|
53
|
+
* @see https://github.com/facebook/docusaurus/issues/4753
|
|
54
|
+
*/
|
|
55
|
+
lazy: boolean;
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* A headless component providing smooth and uniform collapsing behavior. The
|
|
59
|
+
* component will be invisible (zero height) when collapsed. Doesn't provide
|
|
60
|
+
* interactivity by itself: collapse state is toggled through props.
|
|
61
|
+
*/
|
|
62
|
+
export declare function Collapsible({ lazy, ...props }: CollapsibleProps): JSX.Element;
|
|
63
|
+
export {};
|
|
64
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Collapsible/index.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,EAOZ,KAAK,QAAQ,EACb,KAAK,cAAc,EACnB,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAIf;;GAEG;AACH,wBAAgB,cAAc,CAAC,EAC7B,YAAY,GACb,EAAE;IACD,2DAA2D;IAC3D,YAAY,EAAE,OAAO,GAAG,CAAC,MAAM,OAAO,CAAC,CAAC;CACzC,GAAG;IACF,SAAS,EAAE,OAAO,CAAC;IACnB,YAAY,EAAE,QAAQ,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC;IAChD,eAAe,EAAE,MAAM,IAAI,CAAC;CAC7B,CAYA;AAgCD,aAAK,0BAA0B,GAAG;IAChC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAoEF,aAAK,sBAAsB,GAAG,KAAK,CAAC,WAAW,CAC7C,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC,EAAE,WAAW,GAAG,iBAAiB,GAAG,OAAO,CAAC,CAC/E,CAAC;AAaF,aAAK,oBAAoB,GAAG;IAC1B,uDAAuD;IACvD,EAAE,CAAC,EAAE,sBAAsB,CAAC;IAC5B,+BAA+B;IAC/B,SAAS,EAAE,OAAO,CAAC;IACnB,QAAQ,EAAE,SAAS,CAAC;IACpB,+DAA+D;IAC/D,SAAS,CAAC,EAAE,0BAA0B,CAAC;IACvC;;;;;OAKG;IACH,uBAAuB,CAAC,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;IACvD,iDAAiD;IACjD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B,CAAC;AA2DF,aAAK,gBAAgB,GAAG,oBAAoB,GAAG;IAC7C;;;;;OAKG;IACH,IAAI,EAAE,OAAO,CAAC;CACf,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,EAAC,IAAI,EAAE,GAAG,KAAK,EAAC,EAAE,gBAAgB,GAAG,GAAG,CAAC,OAAO,CAG3E"}
|
|
@@ -0,0 +1,152 @@
|
|
|
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 ExecutionEnvironment from '@docusaurus/ExecutionEnvironment';
|
|
8
|
+
import React, { useState, useEffect, useRef, useCallback, useLayoutEffect, } from 'react';
|
|
9
|
+
const DefaultAnimationEasing = 'ease-in-out';
|
|
10
|
+
/**
|
|
11
|
+
* This hook is a very thin wrapper around a `useState`.
|
|
12
|
+
*/
|
|
13
|
+
export function useCollapsible({ initialState, }) {
|
|
14
|
+
const [collapsed, setCollapsed] = useState(initialState ?? false);
|
|
15
|
+
const toggleCollapsed = useCallback(() => {
|
|
16
|
+
setCollapsed((expanded) => !expanded);
|
|
17
|
+
}, []);
|
|
18
|
+
return {
|
|
19
|
+
collapsed,
|
|
20
|
+
setCollapsed,
|
|
21
|
+
toggleCollapsed,
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
const CollapsedStyles = {
|
|
25
|
+
display: 'none',
|
|
26
|
+
overflow: 'hidden',
|
|
27
|
+
height: '0px',
|
|
28
|
+
};
|
|
29
|
+
const ExpandedStyles = {
|
|
30
|
+
display: 'block',
|
|
31
|
+
overflow: 'visible',
|
|
32
|
+
height: 'auto',
|
|
33
|
+
};
|
|
34
|
+
function applyCollapsedStyle(el, collapsed) {
|
|
35
|
+
const collapsedStyles = collapsed ? CollapsedStyles : ExpandedStyles;
|
|
36
|
+
el.style.display = collapsedStyles.display;
|
|
37
|
+
el.style.overflow = collapsedStyles.overflow;
|
|
38
|
+
el.style.height = collapsedStyles.height;
|
|
39
|
+
}
|
|
40
|
+
/*
|
|
41
|
+
Lex111: Dynamic transition duration is used in Material design, this technique
|
|
42
|
+
is good for a large number of items.
|
|
43
|
+
https://material.io/archive/guidelines/motion/duration-easing.html#duration-easing-dynamic-durations
|
|
44
|
+
https://github.com/mui-org/material-ui/blob/e724d98eba018e55e1a684236a2037e24bcf050c/packages/material-ui/src/styles/createTransitions.js#L40-L43
|
|
45
|
+
*/
|
|
46
|
+
function getAutoHeightDuration(height) {
|
|
47
|
+
const constant = height / 36;
|
|
48
|
+
return Math.round((4 + 15 * constant ** 0.25 + constant / 5) * 10);
|
|
49
|
+
}
|
|
50
|
+
function useCollapseAnimation({ collapsibleRef, collapsed, animation, }) {
|
|
51
|
+
const mounted = useRef(false);
|
|
52
|
+
useEffect(() => {
|
|
53
|
+
const el = collapsibleRef.current;
|
|
54
|
+
function getTransitionStyles() {
|
|
55
|
+
const height = el.scrollHeight;
|
|
56
|
+
const duration = animation?.duration ?? getAutoHeightDuration(height);
|
|
57
|
+
const easing = animation?.easing ?? DefaultAnimationEasing;
|
|
58
|
+
return {
|
|
59
|
+
transition: `height ${duration}ms ${easing}`,
|
|
60
|
+
height: `${height}px`,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
function applyTransitionStyles() {
|
|
64
|
+
const transitionStyles = getTransitionStyles();
|
|
65
|
+
el.style.transition = transitionStyles.transition;
|
|
66
|
+
el.style.height = transitionStyles.height;
|
|
67
|
+
}
|
|
68
|
+
// On mount, we just apply styles, no animated transition
|
|
69
|
+
if (!mounted.current) {
|
|
70
|
+
applyCollapsedStyle(el, collapsed);
|
|
71
|
+
mounted.current = true;
|
|
72
|
+
return undefined;
|
|
73
|
+
}
|
|
74
|
+
el.style.willChange = 'height';
|
|
75
|
+
function startAnimation() {
|
|
76
|
+
const animationFrame = requestAnimationFrame(() => {
|
|
77
|
+
// When collapsing
|
|
78
|
+
if (collapsed) {
|
|
79
|
+
applyTransitionStyles();
|
|
80
|
+
requestAnimationFrame(() => {
|
|
81
|
+
el.style.height = CollapsedStyles.height;
|
|
82
|
+
el.style.overflow = CollapsedStyles.overflow;
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
// When expanding
|
|
86
|
+
else {
|
|
87
|
+
el.style.display = 'block';
|
|
88
|
+
requestAnimationFrame(() => {
|
|
89
|
+
applyTransitionStyles();
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
return () => cancelAnimationFrame(animationFrame);
|
|
94
|
+
}
|
|
95
|
+
return startAnimation();
|
|
96
|
+
}, [collapsibleRef, collapsed, animation]);
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Prevent hydration layout shift before animations are handled imperatively
|
|
100
|
+
* with JS
|
|
101
|
+
*/
|
|
102
|
+
function getSSRStyle(collapsed) {
|
|
103
|
+
if (ExecutionEnvironment.canUseDOM) {
|
|
104
|
+
return undefined;
|
|
105
|
+
}
|
|
106
|
+
return collapsed ? CollapsedStyles : ExpandedStyles;
|
|
107
|
+
}
|
|
108
|
+
function CollapsibleBase({ as: As = 'div', collapsed, children, animation, onCollapseTransitionEnd, className, disableSSRStyle, }) {
|
|
109
|
+
// any because TS is a pain for HTML element refs, see https://twitter.com/sebastienlorber/status/1412784677795110914
|
|
110
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
111
|
+
const collapsibleRef = useRef(null);
|
|
112
|
+
useCollapseAnimation({ collapsibleRef, collapsed, animation });
|
|
113
|
+
return (React.createElement(As
|
|
114
|
+
// @ts-expect-error: the "too complicated type" is produced from
|
|
115
|
+
// "CollapsibleElementType" being a huge union
|
|
116
|
+
, {
|
|
117
|
+
// @ts-expect-error: the "too complicated type" is produced from
|
|
118
|
+
// "CollapsibleElementType" being a huge union
|
|
119
|
+
ref: collapsibleRef, style: disableSSRStyle ? undefined : getSSRStyle(collapsed), onTransitionEnd: (e) => {
|
|
120
|
+
if (e.propertyName !== 'height') {
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
applyCollapsedStyle(collapsibleRef.current, collapsed);
|
|
124
|
+
onCollapseTransitionEnd?.(collapsed);
|
|
125
|
+
}, className: className }, children));
|
|
126
|
+
}
|
|
127
|
+
function CollapsibleLazy({ collapsed, ...props }) {
|
|
128
|
+
const [mounted, setMounted] = useState(!collapsed);
|
|
129
|
+
// Updated in effect so that first expansion transition can work
|
|
130
|
+
const [lazyCollapsed, setLazyCollapsed] = useState(collapsed);
|
|
131
|
+
useLayoutEffect(() => {
|
|
132
|
+
if (!collapsed) {
|
|
133
|
+
setMounted(true);
|
|
134
|
+
}
|
|
135
|
+
}, [collapsed]);
|
|
136
|
+
useLayoutEffect(() => {
|
|
137
|
+
if (mounted) {
|
|
138
|
+
setLazyCollapsed(collapsed);
|
|
139
|
+
}
|
|
140
|
+
}, [mounted, collapsed]);
|
|
141
|
+
return mounted ? (React.createElement(CollapsibleBase, { ...props, collapsed: lazyCollapsed })) : null;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* A headless component providing smooth and uniform collapsing behavior. The
|
|
145
|
+
* component will be invisible (zero height) when collapsed. Doesn't provide
|
|
146
|
+
* interactivity by itself: collapse state is toggled through props.
|
|
147
|
+
*/
|
|
148
|
+
export function Collapsible({ lazy, ...props }) {
|
|
149
|
+
const Comp = lazy ? CollapsibleLazy : CollapsibleBase;
|
|
150
|
+
return React.createElement(Comp, { ...props });
|
|
151
|
+
}
|
|
152
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/Collapsible/index.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,oBAAoB,MAAM,kCAAkC,CAAC;AACpE,OAAO,KAAK,EAAE,EACZ,QAAQ,EACR,SAAS,EACT,MAAM,EACN,WAAW,EACX,eAAe,GAKhB,MAAM,OAAO,CAAC;AAEf,MAAM,sBAAsB,GAAG,aAAa,CAAC;AAE7C;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,EAC7B,YAAY,GAIb;IAKC,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAC,YAAY,IAAI,KAAK,CAAC,CAAC;IAElE,MAAM,eAAe,GAAG,WAAW,CAAC,GAAG,EAAE;QACvC,YAAY,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC;IACxC,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO;QACL,SAAS;QACT,YAA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SAAS,CAAC,CAAC;IACnD,gEAAgE;IAChE,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC;IAE9D,eAAe,CAAC,GAAG,EAAE;QACnB,IAAI,CAAC,SAAS,EAAE;YACd,UAAU,CAAC,IAAI,CAAC,CAAC;SAClB;IACH,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC;IAEhB,eAAe,CAAC,GAAG,EAAE;QACnB,IAAI,OAAO,EAAE;YACX,gBAAgB,CAAC,SAAS,CAAC,CAAC;SAC7B;IACH,CAAC,EAAE,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC;IAEzB,OAAO,OAAO,CAAC,CAAC,CAAC,CACf,oBAAC,eAAe,OAAK,KAAK,EAAE,SAAS,EAAE,aAAa,GAAI,CACzD,CAAC,CAAC,CAAC,IAAI,CAAC;AACX,CAAC;AAYD;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,EAAC,IAAI,EAAE,GAAG,KAAK,EAAmB;IAC5D,MAAM,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,eAAe,CAAC;IACtD,OAAO,oBAAC,IAAI,OAAK,KAAK,GAAI,CAAC;AAC7B,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
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 { type ComponentProps, type ReactElement } from 'react';
|
|
8
|
+
export declare type DetailsProps = {
|
|
9
|
+
/** Summary is provided as props, including the wrapping `<summary>` tag */
|
|
10
|
+
summary?: ReactElement;
|
|
11
|
+
} & ComponentProps<'details'>;
|
|
12
|
+
/**
|
|
13
|
+
* A mostly un-styled `<details>` element with smooth collapsing. Provides some
|
|
14
|
+
* very lightweight styles, but you should bring your UI.
|
|
15
|
+
*/
|
|
16
|
+
export declare function Details({ summary, children, ...props }: DetailsProps): JSX.Element;
|
|
17
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Details/index.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAc,EAGZ,KAAK,cAAc,EACnB,KAAK,YAAY,EAClB,MAAM,OAAO,CAAC;AAoBf,oBAAY,YAAY,GAAG;IACzB,2EAA2E;IAC3E,OAAO,CAAC,EAAE,YAAY,CAAC;CACxB,GAAG,cAAc,CAAC,SAAS,CAAC,CAAC;AAE9B;;;GAGG;AACH,wBAAgB,OAAO,CAAC,EACtB,OAAO,EACP,QAAQ,EACR,GAAG,KAAK,EACT,EAAE,YAAY,GAAG,GAAG,CAAC,OAAO,CA+D5B"}
|
|
@@ -0,0 +1,71 @@
|
|
|
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, { useRef, useState, } from 'react';
|
|
8
|
+
import useIsBrowser from '@docusaurus/useIsBrowser';
|
|
9
|
+
import clsx from 'clsx';
|
|
10
|
+
import { useCollapsible, Collapsible } from '../Collapsible';
|
|
11
|
+
import styles from './styles.module.css';
|
|
12
|
+
function isInSummary(node) {
|
|
13
|
+
if (!node) {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
return node.tagName === 'SUMMARY' || isInSummary(node.parentElement);
|
|
17
|
+
}
|
|
18
|
+
function hasParent(node, parent) {
|
|
19
|
+
if (!node) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
return node === parent || hasParent(node.parentElement, parent);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* A mostly un-styled `<details>` element with smooth collapsing. Provides some
|
|
26
|
+
* very lightweight styles, but you should bring your UI.
|
|
27
|
+
*/
|
|
28
|
+
export function Details({ summary, children, ...props }) {
|
|
29
|
+
const isBrowser = useIsBrowser();
|
|
30
|
+
const detailsRef = useRef(null);
|
|
31
|
+
const { collapsed, setCollapsed } = useCollapsible({
|
|
32
|
+
initialState: !props.open,
|
|
33
|
+
});
|
|
34
|
+
// Use a separate state for the actual details prop, because it must be set
|
|
35
|
+
// only after animation completes, otherwise close animations won't work
|
|
36
|
+
const [open, setOpen] = useState(props.open);
|
|
37
|
+
return (
|
|
38
|
+
// eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-noninteractive-element-interactions
|
|
39
|
+
React.createElement("details", { ...props, ref: detailsRef, open: open, "data-collapsed": collapsed, className: clsx(styles.details, isBrowser && styles.isBrowser, props.className), onMouseDown: (e) => {
|
|
40
|
+
const target = e.target;
|
|
41
|
+
// Prevent a double-click to highlight summary text
|
|
42
|
+
if (isInSummary(target) && e.detail > 1) {
|
|
43
|
+
e.preventDefault();
|
|
44
|
+
}
|
|
45
|
+
}, onClick: (e) => {
|
|
46
|
+
e.stopPropagation(); // For isolation of multiple nested details/summary
|
|
47
|
+
const target = e.target;
|
|
48
|
+
const shouldToggle = isInSummary(target) && hasParent(target, detailsRef.current);
|
|
49
|
+
if (!shouldToggle) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
e.preventDefault();
|
|
53
|
+
if (collapsed) {
|
|
54
|
+
setCollapsed(false);
|
|
55
|
+
setOpen(true);
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
setCollapsed(true);
|
|
59
|
+
// Don't do this, it breaks close animation!
|
|
60
|
+
// setOpen(false);
|
|
61
|
+
}
|
|
62
|
+
} },
|
|
63
|
+
summary || React.createElement("summary", null, "Details"),
|
|
64
|
+
React.createElement(Collapsible, { lazy: false, collapsed: collapsed, disableSSRStyle // Allows component to work fine even with JS disabled!
|
|
65
|
+
: true, onCollapseTransitionEnd: (newCollapsed) => {
|
|
66
|
+
setCollapsed(newCollapsed);
|
|
67
|
+
setOpen(!newCollapsed);
|
|
68
|
+
} },
|
|
69
|
+
React.createElement("div", { className: styles.collapsibleContent }, children))));
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/Details/index.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,EACZ,MAAM,EACN,QAAQ,GAGT,MAAM,OAAO,CAAC;AACf,OAAO,YAAY,MAAM,0BAA0B,CAAC;AACpD,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAC,cAAc,EAAE,WAAW,EAAC,MAAM,gBAAgB,CAAC;AAC3D,OAAO,MAAM,MAAM,qBAAqB,CAAC;AAEzC,SAAS,WAAW,CAAC,IAAwB;IAC3C,IAAI,CAAC,IAAI,EAAE;QACT,OAAO,KAAK,CAAC;KACd;IACD,OAAO,IAAI,CAAC,OAAO,KAAK,SAAS,IAAI,WAAW,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;AACvE,CAAC;AAED,SAAS,SAAS,CAAC,IAAwB,EAAE,MAAmB;IAC9D,IAAI,CAAC,IAAI,EAAE;QACT,OAAO,KAAK,CAAC;KACd;IACD,OAAO,IAAI,KAAK,MAAM,IAAI,SAAS,CAAC,IAAI,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC;AAClE,CAAC;AAOD;;;GAGG;AACH,MAAM,UAAU,OAAO,CAAC,EACtB,OAAO,EACP,QAAQ,EACR,GAAG,KAAK,EACK;IACb,MAAM,SAAS,GAAG,YAAY,EAAE,CAAC;IACjC,MAAM,UAAU,GAAG,MAAM,CAAqB,IAAI,CAAC,CAAC;IAEpD,MAAM,EAAC,SAAS,EAAE,YAAY,EAAC,GAAG,cAAc,CAAC;QAC/C,YAAY,EA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,SAAS,EACpB,eAAe,CAAC,uDAAuD;oBACvE,uBAAuB,EAAE,CAAC,YAAY,EAAE,EAAE;gBACxC,YAAY,CAAC,YAAY,CAAC,CAAC;gBAC3B,OAAO,CAAC,CAAC,YAAY,CAAC,CAAC;YACzB,CAAC;YACD,6BAAK,SAAS,EAAE,MAAM,CAAC,kBAAkB,IAAG,QAAQ,CAAO,CAC/C,CACN,CACX,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
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
|
+
/*
|
|
9
|
+
CSS variables, meant to be overridden by final theme
|
|
10
|
+
*/
|
|
11
|
+
.details {
|
|
12
|
+
--docusaurus-details-summary-arrow-size: 0.38rem;
|
|
13
|
+
--docusaurus-details-transition: transform 200ms ease;
|
|
14
|
+
--docusaurus-details-decoration-color: grey;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.details > summary {
|
|
18
|
+
position: relative;
|
|
19
|
+
cursor: pointer;
|
|
20
|
+
list-style: none;
|
|
21
|
+
padding-left: 1rem;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/* TODO: deprecation, need to remove this after Safari will support `::marker` */
|
|
25
|
+
.details > summary::-webkit-details-marker {
|
|
26
|
+
display: none;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.details > summary::before {
|
|
30
|
+
position: absolute;
|
|
31
|
+
top: 0.45rem;
|
|
32
|
+
left: 0;
|
|
33
|
+
|
|
34
|
+
/* CSS-only Arrow */
|
|
35
|
+
content: '';
|
|
36
|
+
border-width: var(--docusaurus-details-summary-arrow-size);
|
|
37
|
+
border-style: solid;
|
|
38
|
+
border-color: transparent transparent transparent
|
|
39
|
+
var(--docusaurus-details-decoration-color);
|
|
40
|
+
|
|
41
|
+
/* Arrow rotation anim */
|
|
42
|
+
transform: rotate(0deg);
|
|
43
|
+
transition: var(--docusaurus-details-transition);
|
|
44
|
+
transform-origin: calc(var(--docusaurus-details-summary-arrow-size) / 2) 50%;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/* When JS disabled/failed to load: we use the open property for arrow animation: */
|
|
48
|
+
.details[open]:not(.isBrowser) > summary::before,
|
|
49
|
+
/* When JS works: we use the data-attribute for arrow animation */
|
|
50
|
+
.details[data-collapsed='false'].isBrowser > summary::before {
|
|
51
|
+
transform: rotate(90deg);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.collapsibleContent {
|
|
55
|
+
margin-top: 1rem;
|
|
56
|
+
border-top: 1px solid var(--docusaurus-details-decoration-color);
|
|
57
|
+
padding-top: 1rem;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.collapsibleContent > *:last-child {
|
|
61
|
+
margin-bottom: 0;
|
|
62
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
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 { type ReactNode } from 'react';
|
|
8
|
+
export declare const AnnouncementBarDismissStorageKey = "docusaurus.announcement.dismiss";
|
|
9
|
+
declare type ContextValue = {
|
|
10
|
+
/** Whether the announcement bar should be displayed. */
|
|
11
|
+
readonly isActive: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Callback fired when the user closes the announcement. Will be saved.
|
|
14
|
+
*/
|
|
15
|
+
readonly close: () => void;
|
|
16
|
+
};
|
|
17
|
+
export declare function AnnouncementBarProvider({ children, }: {
|
|
18
|
+
children: ReactNode;
|
|
19
|
+
}): JSX.Element;
|
|
20
|
+
export declare function useAnnouncementBar(): ContextValue;
|
|
21
|
+
export {};
|
|
22
|
+
//# sourceMappingURL=announcementBar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"announcementBar.d.ts","sourceRoot":"","sources":["../../src/contexts/announcementBar.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAc,EAMZ,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAMf,eAAO,MAAM,gCAAgC,oCACV,CAAC;AAapC,aAAK,YAAY,GAAG;IAClB,wDAAwD;IACxD,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,IAAI,CAAC;CAC5B,CAAC;AA8DF,wBAAgB,uBAAuB,CAAC,EACtC,QAAQ,GACT,EAAE;IACD,QAAQ,EAAE,SAAS,CAAC;CACrB,GAAG,GAAG,CAAC,OAAO,CAGd;AAED,wBAAgB,kBAAkB,IAAI,YAAY,CAMjD"}
|
|
@@ -4,26 +4,26 @@
|
|
|
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, { useState, useEffect, useCallback, useMemo, useContext,
|
|
8
|
-
import
|
|
9
|
-
import { createStorageSlot } from '
|
|
10
|
-
import {
|
|
7
|
+
import React, { useState, useEffect, useCallback, useMemo, useContext, } from 'react';
|
|
8
|
+
import useIsBrowser from '@docusaurus/useIsBrowser';
|
|
9
|
+
import { createStorageSlot } from '../utils/storageUtils';
|
|
10
|
+
import { ReactContextError } from '../utils/reactUtils';
|
|
11
|
+
import { useThemeConfig } from '../utils/useThemeConfig';
|
|
11
12
|
export const AnnouncementBarDismissStorageKey = 'docusaurus.announcement.dismiss';
|
|
12
13
|
const AnnouncementBarIdStorageKey = 'docusaurus.announcement.id';
|
|
13
14
|
const AnnouncementBarDismissStorage = createStorageSlot(AnnouncementBarDismissStorageKey);
|
|
14
15
|
const IdStorage = createStorageSlot(AnnouncementBarIdStorageKey);
|
|
15
16
|
const isDismissedInStorage = () => AnnouncementBarDismissStorage.get() === 'true';
|
|
16
17
|
const setDismissedInStorage = (bool) => AnnouncementBarDismissStorage.set(String(bool));
|
|
17
|
-
const
|
|
18
|
+
const Context = React.createContext(null);
|
|
19
|
+
function useContextValue() {
|
|
18
20
|
const { announcementBar } = useThemeConfig();
|
|
19
|
-
const
|
|
20
|
-
const [isClosed, setClosed] = useState(() =>
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
false;
|
|
26
|
-
});
|
|
21
|
+
const isBrowser = useIsBrowser();
|
|
22
|
+
const [isClosed, setClosed] = useState(() => isBrowser
|
|
23
|
+
? // On client navigation: init with local storage value
|
|
24
|
+
isDismissedInStorage()
|
|
25
|
+
: // On server/hydration: always visible to prevent layout shifts (will be hidden with css if needed)
|
|
26
|
+
false);
|
|
27
27
|
// Update state after hydration
|
|
28
28
|
useEffect(() => {
|
|
29
29
|
setClosed(isDismissedInStorage());
|
|
@@ -38,8 +38,9 @@ const useAnnouncementBarContextValue = () => {
|
|
|
38
38
|
}
|
|
39
39
|
const { id } = announcementBar;
|
|
40
40
|
let viewedId = IdStorage.get();
|
|
41
|
-
//
|
|
41
|
+
// Retrocompatibility due to spelling mistake of default id
|
|
42
42
|
// see https://github.com/facebook/docusaurus/issues/3338
|
|
43
|
+
// cSpell:ignore annoucement
|
|
43
44
|
if (viewedId === 'annoucement-bar') {
|
|
44
45
|
viewedId = 'announcement-bar';
|
|
45
46
|
}
|
|
@@ -51,23 +52,21 @@ const useAnnouncementBarContextValue = () => {
|
|
|
51
52
|
if (isNewAnnouncement || !isDismissedInStorage()) {
|
|
52
53
|
setClosed(false);
|
|
53
54
|
}
|
|
54
|
-
}, []);
|
|
55
|
-
return useMemo(() => {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
};
|
|
67
|
-
export const useAnnouncementBar = () => {
|
|
68
|
-
const api = useContext(AnnouncementBarContext);
|
|
55
|
+
}, [announcementBar]);
|
|
56
|
+
return useMemo(() => ({
|
|
57
|
+
isActive: !!announcementBar && !isClosed,
|
|
58
|
+
close: handleClose,
|
|
59
|
+
}), [announcementBar, isClosed, handleClose]);
|
|
60
|
+
}
|
|
61
|
+
export function AnnouncementBarProvider({ children, }) {
|
|
62
|
+
const value = useContextValue();
|
|
63
|
+
return React.createElement(Context.Provider, { value: value }, children);
|
|
64
|
+
}
|
|
65
|
+
export function useAnnouncementBar() {
|
|
66
|
+
const api = useContext(Context);
|
|
69
67
|
if (!api) {
|
|
70
|
-
throw new
|
|
68
|
+
throw new ReactContextError('AnnouncementBarProvider');
|
|
71
69
|
}
|
|
72
70
|
return api;
|
|
73
|
-
}
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=announcementBar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"announcementBar.js","sourceRoot":"","sources":["../../src/contexts/announcementBar.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,EACZ,QAAQ,EACR,SAAS,EACT,WAAW,EACX,OAAO,EACP,UAAU,GAEX,MAAM,OAAO,CAAC;AACf,OAAO,YAAY,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAC,iBAAiB,EAAC,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAC,iBAAiB,EAAC,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAC,cAAc,EAAC,MAAM,yBAAyB,CAAC;AAEvD,MAAM,CAAC,MAAM,gCAAgC,GAC3C,iCAAiC,CAAC;AACpC,MAAM,2BAA2B,GAAG,4BAA4B,CAAC;AAEjE,MAAM,6BAA6B,GAAG,iBAAiB,CACrD,gCAAgC,CACjC,CAAC;AACF,MAAM,SAAS,GAAG,iBAAiB,CAAC,2BAA2B,CAAC,CAAC;AAEjE,MAAM,oBAAoB,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AAE,CAAC,CAAC;QAElB,IAAI,iBAAiB,EAAE;YACrB,qBAAqB,CAAC,KAAK,CAAC,CAAC;SAC9B;QAED,IAAI,iBAAiB,IAAI,CAAC,oBAAoB,EAAE,EAAE;YAChD,SAAS,CAAC,KAAK,CAAC,CAAC;SAClB;IACH,CAAC,EAAE,CAAC,eAAe,CAAC,CAAC,CAAC;IAEtB,OAAO,OAAO,CACZ,GAAG,EAAE,CAAC,CAAC;QACL,QAAQ,EAAE,CAAC,CAAC,eAAe,IAAI,CAAC,QAAQ;QACxC,KAAK,EAAE,WAAW;KACnB,CAAC,EACF,CAAC,eAAe,EAAE,QAAQ,EAAE,WAAW,CAAC,CACzC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,uBAAuB,CAAC,EACtC,QAAQ,GAGT;IACC,MAAM,KAAK,GAAG,eAAe,EAAE,CAAC;IAChC,OAAO,oBAAC,OAAO,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,IAAG,QAAQ,CAAoB,CAAC;AACvE,CAAC;AAED,MAAM,UAAU,kBAAkB;IAChC,MAAM,GAAG,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC;IAChC,IAAI,CAAC,GAAG,EAAE;QACR,MAAM,IAAI,iBAAiB,CAAC,yBAAyB,CAAC,CAAC;KACxD;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
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 { type ReactNode } from 'react';
|
|
8
|
+
declare type ContextValue = {
|
|
9
|
+
/** Current color mode. */
|
|
10
|
+
readonly colorMode: ColorMode;
|
|
11
|
+
/** Set new color mode. */
|
|
12
|
+
readonly setColorMode: (colorMode: ColorMode) => void;
|
|
13
|
+
readonly isDarkTheme: boolean;
|
|
14
|
+
readonly setLightTheme: () => void;
|
|
15
|
+
readonly setDarkTheme: () => void;
|
|
16
|
+
};
|
|
17
|
+
declare const ColorModes: {
|
|
18
|
+
readonly light: "light";
|
|
19
|
+
readonly dark: "dark";
|
|
20
|
+
};
|
|
21
|
+
export declare type ColorMode = typeof ColorModes[keyof typeof ColorModes];
|
|
22
|
+
export declare function ColorModeProvider({ children, }: {
|
|
23
|
+
children: ReactNode;
|
|
24
|
+
}): JSX.Element;
|
|
25
|
+
export declare function useColorMode(): ContextValue;
|
|
26
|
+
export {};
|
|
27
|
+
//# sourceMappingURL=colorMode.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"colorMode.d.ts","sourceRoot":"","sources":["../../src/contexts/colorMode.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAc,EAOZ,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAOf,aAAK,YAAY,GAAG;IAClB,0BAA0B;IAC1B,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B,0BAA0B;IAC1B,QAAQ,CAAC,YAAY,EAAE,CAAC,SAAS,EAAE,SAAS,KAAK,IAAI,CAAC;IAGtD,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC;IAC9B,QAAQ,CAAC,aAAa,EAAE,MAAM,IAAI,CAAC;IACnC,QAAQ,CAAC,YAAY,EAAE,MAAM,IAAI,CAAC;CACnC,CAAC;AAOF,QAAA,MAAM,UAAU;;;CAGN,CAAC;AAEX,oBAAY,SAAS,GAAG,OAAO,UAAU,CAAC,MAAM,OAAO,UAAU,CAAC,CAAC;AAwInE,wBAAgB,iBAAiB,CAAC,EAChC,QAAQ,GACT,EAAE;IACD,QAAQ,EAAE,SAAS,CAAC;CACrB,GAAG,GAAG,CAAC,OAAO,CAGd;AAED,wBAAgB,YAAY,IAAI,YAAY,CAS3C"}
|