@docusaurus/theme-common 2.0.0-beta.fbdeefcac → 2.0.0-rc.1
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/components/Collapsible/index.d.ts +64 -0
- package/lib/components/Collapsible/index.d.ts.map +1 -0
- package/lib/components/Collapsible/index.js +150 -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 +76 -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/blogPost.d.ts +33 -0
- package/lib/contexts/blogPost.d.ts.map +1 -0
- package/lib/contexts/blogPost.js +46 -0
- package/lib/contexts/blogPost.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/doc.d.ts +30 -0
- package/lib/contexts/doc.d.ts.map +1 -0
- package/lib/contexts/doc.js +48 -0
- package/lib/contexts/doc.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 +30 -0
- package/lib/contexts/docsPreferredVersion.d.ts.map +1 -0
- package/lib/contexts/docsPreferredVersion.js +130 -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 +50 -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 +67 -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/useMutationObserver.d.ts +4 -0
- package/lib/hooks/useMutationObserver.d.ts.map +1 -0
- package/lib/hooks/useMutationObserver.js +29 -0
- package/lib/hooks/useMutationObserver.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 +16 -13
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +23 -12
- package/lib/index.js.map +1 -0
- package/lib/internal.d.ts +41 -0
- package/lib/internal.d.ts.map +1 -0
- package/lib/internal.js +52 -0
- package/lib/internal.js.map +1 -0
- package/lib/utils/ThemeClassNames.d.ts +49 -12
- package/lib/utils/ThemeClassNames.d.ts.map +1 -0
- package/lib/utils/ThemeClassNames.js +47 -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 +159 -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 +70 -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 +36 -0
- package/lib/utils/navbarUtils.js.map +1 -0
- package/lib/utils/reactUtils.d.ts +69 -0
- package/lib/utils/reactUtils.d.ts.map +1 -0
- package/lib/utils/reactUtils.js +98 -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 +56 -28
- 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 +35 -13
- package/src/components/Collapsible/index.tsx +263 -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/blogPost.tsx +80 -0
- package/src/contexts/colorMode.tsx +198 -0
- package/src/contexts/doc.tsx +71 -0
- package/src/contexts/docSidebarItemsExpandedState.tsx +55 -0
- package/src/contexts/docsPreferredVersion.tsx +251 -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 +100 -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 +105 -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/useMutationObserver.ts +38 -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 +189 -0
- package/src/hooks/useWindowSize.ts +72 -0
- package/src/index.ts +53 -28
- package/src/internal.ts +122 -0
- package/src/types.d.ts +0 -2
- package/src/utils/ThemeClassNames.ts +54 -5
- package/src/utils/codeBlockUtils.ts +241 -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 +129 -0
- package/src/utils/regexpUtils.ts +24 -0
- package/src/utils/routesUtils.ts +75 -0
- package/src/utils/scrollUtils.tsx +304 -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 +50 -38
- package/src/utils/useThemeConfig.ts +55 -30
- package/lib/.tsbuildinfo +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
|
@@ -0,0 +1,70 @@
|
|
|
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 clsx from 'clsx';
|
|
9
|
+
import Head from '@docusaurus/Head';
|
|
10
|
+
import useRouteContext from '@docusaurus/useRouteContext';
|
|
11
|
+
import { useBaseUrlUtils } from '@docusaurus/useBaseUrl';
|
|
12
|
+
import { useTitleFormatter } from './generalUtils';
|
|
13
|
+
/**
|
|
14
|
+
* Helper component to manipulate page metadata and override site defaults.
|
|
15
|
+
* Works in the same way as Helmet.
|
|
16
|
+
*/
|
|
17
|
+
export function PageMetadata({ title, description, keywords, image, children, }) {
|
|
18
|
+
const pageTitle = useTitleFormatter(title);
|
|
19
|
+
const { withBaseUrl } = useBaseUrlUtils();
|
|
20
|
+
const pageImage = image ? withBaseUrl(image, { absolute: true }) : undefined;
|
|
21
|
+
return (<Head>
|
|
22
|
+
{title && <title>{pageTitle}</title>}
|
|
23
|
+
{title && <meta property="og:title" content={pageTitle}/>}
|
|
24
|
+
|
|
25
|
+
{description && <meta name="description" content={description}/>}
|
|
26
|
+
{description && <meta property="og:description" content={description}/>}
|
|
27
|
+
|
|
28
|
+
{keywords && (<meta name="keywords" content={
|
|
29
|
+
// https://github.com/microsoft/TypeScript/issues/17002
|
|
30
|
+
(Array.isArray(keywords) ? keywords.join(',') : keywords)}/>)}
|
|
31
|
+
|
|
32
|
+
{pageImage && <meta property="og:image" content={pageImage}/>}
|
|
33
|
+
{pageImage && <meta name="twitter:image" content={pageImage}/>}
|
|
34
|
+
|
|
35
|
+
{children}
|
|
36
|
+
</Head>);
|
|
37
|
+
}
|
|
38
|
+
const HtmlClassNameContext = React.createContext(undefined);
|
|
39
|
+
/**
|
|
40
|
+
* Every layer of this provider will append a class name to the HTML element.
|
|
41
|
+
* There's no consumer for this hook: it's side-effect-only. This wrapper is
|
|
42
|
+
* necessary because Helmet does not "merge" classes.
|
|
43
|
+
* @see https://github.com/staylor/react-helmet-async/issues/161
|
|
44
|
+
*/
|
|
45
|
+
export function HtmlClassNameProvider({ className: classNameProp, children, }) {
|
|
46
|
+
const classNameContext = React.useContext(HtmlClassNameContext);
|
|
47
|
+
const className = clsx(classNameContext, classNameProp);
|
|
48
|
+
return (<HtmlClassNameContext.Provider value={className}>
|
|
49
|
+
<Head>
|
|
50
|
+
<html className={className}/>
|
|
51
|
+
</Head>
|
|
52
|
+
{children}
|
|
53
|
+
</HtmlClassNameContext.Provider>);
|
|
54
|
+
}
|
|
55
|
+
function pluginNameToClassName(pluginName) {
|
|
56
|
+
return `plugin-${pluginName.replace(/docusaurus-(?:plugin|theme)-(?:content-)?/gi, '')}`;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* A very thin wrapper around `HtmlClassNameProvider` that adds the plugin ID +
|
|
60
|
+
* name to the HTML class name.
|
|
61
|
+
*/
|
|
62
|
+
export function PluginHtmlClassNameProvider({ children, }) {
|
|
63
|
+
const routeContext = useRouteContext();
|
|
64
|
+
const nameClass = pluginNameToClassName(routeContext.plugin.name);
|
|
65
|
+
const idClass = `plugin-id-${routeContext.plugin.id}`;
|
|
66
|
+
return (<HtmlClassNameProvider className={clsx(nameClass, idClass)}>
|
|
67
|
+
{children}
|
|
68
|
+
</HtmlClassNameProvider>);
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=metadataUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metadataUtils.js","sourceRoot":"","sources":["../../src/utils/metadataUtils.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAuB,MAAM,OAAO,CAA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C,CAAC;IAClE,MAAM,OAAO,GAAG,aAAa,YAAY,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC;IACtD,OAAO,CACL,CAAC,qBAAqB,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC,CACzD;MAAA,CAAC,QAAQ,CACX;IAAA,EAAE,qBAAqB,CAAC,CACzB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
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
|
+
/**
|
|
9
|
+
* Split links by left/right. If position is unspecified, fallback to right.
|
|
10
|
+
*/
|
|
11
|
+
export declare function splitNavbarItems<T extends {
|
|
12
|
+
position?: 'left' | 'right';
|
|
13
|
+
}>(items: T[]): [leftItems: T[], rightItems: T[]];
|
|
14
|
+
/**
|
|
15
|
+
* Composes multiple navbar state providers that are mutually dependent and
|
|
16
|
+
* hence can't be re-ordered.
|
|
17
|
+
*/
|
|
18
|
+
export declare function NavbarProvider({ children }: {
|
|
19
|
+
children: ReactNode;
|
|
20
|
+
}): JSX.Element;
|
|
21
|
+
//# sourceMappingURL=navbarUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"navbarUtils.d.ts","sourceRoot":"","sources":["../../src/utils/navbarUtils.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAc,EAAC,KAAK,SAAS,EAAC,MAAM,OAAO,CAAC;AAO5C;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,SAAS;IAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;CAAC,EACtE,KAAK,EAAE,CAAC,EAAE,GACT,CAAC,SAAS,EAAE,CAAC,EAAE,EAAE,UAAU,EAAE,CAAC,EAAE,CAAC,CASnC;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,EAAC,QAAQ,EAAC,EAAE;IAAC,QAAQ,EAAE,SAAS,CAAA;CAAC,GAAG,GAAG,CAAC,OAAO,CAU7E"}
|
|
@@ -0,0 +1,36 @@
|
|
|
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 { NavbarMobileSidebarProvider } from '../contexts/navbarMobileSidebar';
|
|
9
|
+
import { NavbarSecondaryMenuContentProvider } from '../contexts/navbarSecondaryMenu/content';
|
|
10
|
+
import { NavbarSecondaryMenuDisplayProvider } from '../contexts/navbarSecondaryMenu/display';
|
|
11
|
+
const DefaultNavItemPosition = 'right';
|
|
12
|
+
/**
|
|
13
|
+
* Split links by left/right. If position is unspecified, fallback to right.
|
|
14
|
+
*/
|
|
15
|
+
export function splitNavbarItems(items) {
|
|
16
|
+
function isLeft(item) {
|
|
17
|
+
return (item.position ?? DefaultNavItemPosition) === 'left';
|
|
18
|
+
}
|
|
19
|
+
const leftItems = items.filter(isLeft);
|
|
20
|
+
const rightItems = items.filter((item) => !isLeft(item));
|
|
21
|
+
return [leftItems, rightItems];
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Composes multiple navbar state providers that are mutually dependent and
|
|
25
|
+
* hence can't be re-ordered.
|
|
26
|
+
*/
|
|
27
|
+
export function NavbarProvider({ children }) {
|
|
28
|
+
return (<NavbarSecondaryMenuContentProvider>
|
|
29
|
+
<NavbarMobileSidebarProvider>
|
|
30
|
+
<NavbarSecondaryMenuDisplayProvider>
|
|
31
|
+
{children}
|
|
32
|
+
</NavbarSecondaryMenuDisplayProvider>
|
|
33
|
+
</NavbarMobileSidebarProvider>
|
|
34
|
+
</NavbarSecondaryMenuContentProvider>);
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=navbarUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"navbarUtils.js","sourceRoot":"","sources":["../../src/utils/navbarUtils.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAuB,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAC,2BAA2B,EAAC,MAAM,iCAAiC,CAAC;AAC5E,OAAO,EAAC,kCAAkC,EAAC,MAAM,yCAAyC,CAAC;AAC3F,OAAO,EAAC,kCAAkC,EAAC,MAAM,yCAAyC,CAAC;AAE3F,MAAM,sBAAsB,GAAG,OAAO,CAAC;AAEvC;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAC9B,KAAU;IAEV,SAAS,MAAM,CAAC,IAAO;QACrB,OAAO,CAAC,IAAI,CAAC,QAAQ,IAAI,sBAAsB,CAAC,KAAK,MAAM,CAAC;IAC9D,CAAC;IAED,MAAM,SAAS,GAAG,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACvC,MAAM,UAAU,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;IAEzD,OAAO,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;AACjC,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,EAAC,QAAQ,EAAwB;IAC9D,OAAO,CACL,CAAC,kCAAkC,CACjC;MAAA,CAAC,2BAA2B,CAC1B;QAAA,CAAC,kCAAkC,CACjC;UAAA,CAAC,QAAQ,CACX;QAAA,EAAE,kCAAkC,CACtC;MAAA,EAAE,2BAA2B,CAC/B;IAAA,EAAE,kCAAkC,CAAC,CACtC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
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 ComponentType, type ReactNode } from 'react';
|
|
8
|
+
/**
|
|
9
|
+
* This hook is like `useLayoutEffect`, but without the SSR warning.
|
|
10
|
+
* It seems hacky but it's used in many React libs (Redux, Formik...).
|
|
11
|
+
* Also mentioned here: https://github.com/facebook/react/issues/16956
|
|
12
|
+
*
|
|
13
|
+
* It is useful when you need to update a ref as soon as possible after a React
|
|
14
|
+
* render (before `useEffect`).
|
|
15
|
+
*/
|
|
16
|
+
export declare const useIsomorphicLayoutEffect: typeof React.useLayoutEffect;
|
|
17
|
+
/**
|
|
18
|
+
* Temporary userland implementation until an official hook is implemented
|
|
19
|
+
* See RFC: https://github.com/reactjs/rfcs/pull/220
|
|
20
|
+
*
|
|
21
|
+
* Permits to transform an unstable callback (like an arrow function provided as
|
|
22
|
+
* props) to a "stable" callback that is safe to use in a `useEffect` dependency
|
|
23
|
+
* array. Useful to avoid React stale closure problems + avoid useless effect
|
|
24
|
+
* re-executions.
|
|
25
|
+
*
|
|
26
|
+
* This generally works but has some potential drawbacks, such as
|
|
27
|
+
* https://github.com/facebook/react/issues/16956#issuecomment-536636418
|
|
28
|
+
*/
|
|
29
|
+
export declare function useEvent<T extends (...args: never[]) => unknown>(callback: T): T;
|
|
30
|
+
/**
|
|
31
|
+
* Gets `value` from the last render.
|
|
32
|
+
*/
|
|
33
|
+
export declare function usePrevious<T>(value: T): T | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* This error is thrown when a context is consumed outside its provider. Allows
|
|
36
|
+
* reusing a generic error message format and reduces bundle size. The hook's
|
|
37
|
+
* name will be extracted from its stack, so only the provider's name is needed.
|
|
38
|
+
*/
|
|
39
|
+
export declare class ReactContextError extends Error {
|
|
40
|
+
constructor(providerName: string, additionalInfo?: string);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Shallow-memoize an object. This means the returned object will be the same as
|
|
44
|
+
* the previous render if the property keys and values did not change. This
|
|
45
|
+
* works for simple cases: when property values are primitives or stable
|
|
46
|
+
* objects.
|
|
47
|
+
*
|
|
48
|
+
* @param obj
|
|
49
|
+
*/
|
|
50
|
+
export declare function useShallowMemoObject<O extends object>(obj: O): O;
|
|
51
|
+
declare type SimpleProvider = ComponentType<{
|
|
52
|
+
children: ReactNode;
|
|
53
|
+
}>;
|
|
54
|
+
/**
|
|
55
|
+
* Creates a single React provider from an array of existing providers
|
|
56
|
+
* assuming providers only take "children" as props.
|
|
57
|
+
*
|
|
58
|
+
* Prevents the annoying React element nesting
|
|
59
|
+
* Example here: https://getfrontend.tips/compose-multiple-react-providers/
|
|
60
|
+
*
|
|
61
|
+
* The order matters:
|
|
62
|
+
* - The first provider is at the top of the tree.
|
|
63
|
+
* - The last provider is the most nested one
|
|
64
|
+
*
|
|
65
|
+
* @param providers array of providers to compose
|
|
66
|
+
*/
|
|
67
|
+
export declare function composeProviders(providers: SimpleProvider[]): SimpleProvider;
|
|
68
|
+
export {};
|
|
69
|
+
//# sourceMappingURL=reactUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reactUtils.d.ts","sourceRoot":"","sources":["../../src/utils/reactUtils.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,EAMZ,KAAK,aAAa,EAClB,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAGf;;;;;;;GAOG;AACH,eAAO,MAAM,yBAAyB,8BAEzB,CAAC;AAEd;;;;;;;;;;;GAWG;AACH,wBAAgB,QAAQ,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,KAAK,EAAE,KAAK,OAAO,EAC9D,QAAQ,EAAE,CAAC,GACV,CAAC,CAUH;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,GAAG,SAAS,CAQtD;AAED;;;;GAIG;AACH,qBAAa,iBAAkB,SAAQ,KAAK;gBAC9B,YAAY,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,MAAM;CAQ1D;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,SAAS,MAAM,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAMhE;AAED,aAAK,cAAc,GAAG,aAAa,CAAC;IAAC,QAAQ,EAAE,SAAS,CAAA;CAAC,CAAC,CAAC;AAE3D;;;;;;;;;;;;GAYG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,cAAc,EAAE,GAAG,cAAc,CAY5E"}
|
|
@@ -0,0 +1,98 @@
|
|
|
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, { useCallback, useEffect, useLayoutEffect, useMemo, useRef, } from 'react';
|
|
8
|
+
import ExecutionEnvironment from '@docusaurus/ExecutionEnvironment';
|
|
9
|
+
/**
|
|
10
|
+
* This hook is like `useLayoutEffect`, but without the SSR warning.
|
|
11
|
+
* It seems hacky but it's used in many React libs (Redux, Formik...).
|
|
12
|
+
* Also mentioned here: https://github.com/facebook/react/issues/16956
|
|
13
|
+
*
|
|
14
|
+
* It is useful when you need to update a ref as soon as possible after a React
|
|
15
|
+
* render (before `useEffect`).
|
|
16
|
+
*/
|
|
17
|
+
export const useIsomorphicLayoutEffect = ExecutionEnvironment.canUseDOM
|
|
18
|
+
? useLayoutEffect
|
|
19
|
+
: useEffect;
|
|
20
|
+
/**
|
|
21
|
+
* Temporary userland implementation until an official hook is implemented
|
|
22
|
+
* See RFC: https://github.com/reactjs/rfcs/pull/220
|
|
23
|
+
*
|
|
24
|
+
* Permits to transform an unstable callback (like an arrow function provided as
|
|
25
|
+
* props) to a "stable" callback that is safe to use in a `useEffect` dependency
|
|
26
|
+
* array. Useful to avoid React stale closure problems + avoid useless effect
|
|
27
|
+
* re-executions.
|
|
28
|
+
*
|
|
29
|
+
* This generally works but has some potential drawbacks, such as
|
|
30
|
+
* https://github.com/facebook/react/issues/16956#issuecomment-536636418
|
|
31
|
+
*/
|
|
32
|
+
export function useEvent(callback) {
|
|
33
|
+
const ref = useRef(callback);
|
|
34
|
+
useIsomorphicLayoutEffect(() => {
|
|
35
|
+
ref.current = callback;
|
|
36
|
+
}, [callback]);
|
|
37
|
+
// @ts-expect-error: TS is right that this callback may be a supertype of T,
|
|
38
|
+
// but good enough for our use
|
|
39
|
+
return useCallback((...args) => ref.current(...args), []);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Gets `value` from the last render.
|
|
43
|
+
*/
|
|
44
|
+
export function usePrevious(value) {
|
|
45
|
+
const ref = useRef();
|
|
46
|
+
useIsomorphicLayoutEffect(() => {
|
|
47
|
+
ref.current = value;
|
|
48
|
+
});
|
|
49
|
+
return ref.current;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* This error is thrown when a context is consumed outside its provider. Allows
|
|
53
|
+
* reusing a generic error message format and reduces bundle size. The hook's
|
|
54
|
+
* name will be extracted from its stack, so only the provider's name is needed.
|
|
55
|
+
*/
|
|
56
|
+
export class ReactContextError extends Error {
|
|
57
|
+
constructor(providerName, additionalInfo) {
|
|
58
|
+
super();
|
|
59
|
+
this.name = 'ReactContextError';
|
|
60
|
+
this.message = `Hook ${this.stack?.split('\n')[1]?.match(/at (?:\w+\.)?(?<name>\w+)/)?.groups
|
|
61
|
+
.name ?? ''} is called outside the <${providerName}>. ${additionalInfo ?? ''}`;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Shallow-memoize an object. This means the returned object will be the same as
|
|
66
|
+
* the previous render if the property keys and values did not change. This
|
|
67
|
+
* works for simple cases: when property values are primitives or stable
|
|
68
|
+
* objects.
|
|
69
|
+
*
|
|
70
|
+
* @param obj
|
|
71
|
+
*/
|
|
72
|
+
export function useShallowMemoObject(obj) {
|
|
73
|
+
const deps = Object.entries(obj);
|
|
74
|
+
// Sort by keys to make it order-insensitive
|
|
75
|
+
deps.sort((a, b) => a[0].localeCompare(b[0]));
|
|
76
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
77
|
+
return useMemo(() => obj, deps.flat());
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Creates a single React provider from an array of existing providers
|
|
81
|
+
* assuming providers only take "children" as props.
|
|
82
|
+
*
|
|
83
|
+
* Prevents the annoying React element nesting
|
|
84
|
+
* Example here: https://getfrontend.tips/compose-multiple-react-providers/
|
|
85
|
+
*
|
|
86
|
+
* The order matters:
|
|
87
|
+
* - The first provider is at the top of the tree.
|
|
88
|
+
* - The last provider is the most nested one
|
|
89
|
+
*
|
|
90
|
+
* @param providers array of providers to compose
|
|
91
|
+
*/
|
|
92
|
+
export function composeProviders(providers) {
|
|
93
|
+
// Creates a single React component: it's cheaper to compose JSX elements
|
|
94
|
+
return ({ children }) => (<>
|
|
95
|
+
{providers.reduceRight((element, CurrentProvider) => (<CurrentProvider>{element}</CurrentProvider>), children)}
|
|
96
|
+
</>);
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=reactUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reactUtils.js","sourceRoot":"","sources":["../../src/utils/reactUtils.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,EACZ,WAAW,EACX,SAAS,EACT,eAAe,EACf,OAAO,EACP,MAAM,GAGP,MAAM,OAAO,CAAC;AACf,OAAO,oBAAoB,MAAM,kCAAkC,CAAC;AAEpE;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,oBAAoB,CAAC,SAAS;IACrE,CAAC,CAAC,eAAe;IACjB,CAAC,CAAC,SAAS,C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E,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9C,uDAAuD;IACvD,OAAO,OAAO,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;AACzC,CAAC;AAID;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,gBAAgB,CAAC,SAA2B;IAC1D,yEAAyE;IACzE,OAAO,CAAC,EAAC,QAAQ,EAAC,EAAE,EAAE,CAAC,CACrB,EACE;MAAA,CAAC,SAAS,CAAC,WAAW,CACpB,CAAC,OAAO,EAAE,eAAe,EAAE,EAAE,CAAC,CAC5B,CAAC,eAAe,CAAC,CAAC,OAAO,CAAC,EAAE,eAAe,CAAC,CAC7C,EACD,QAAQ,CACT,CACH;IAAA,GAAG,CACJ,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
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
|
+
* Matches a string regex (as provided from the config) against a target in a
|
|
9
|
+
* null-safe fashion, case insensitive and global.
|
|
10
|
+
*/
|
|
11
|
+
export declare function isRegexpStringMatch(regexAsString?: string, valueToTest?: string): boolean;
|
|
12
|
+
//# sourceMappingURL=regexpUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"regexpUtils.d.ts","sourceRoot":"","sources":["../../src/utils/regexpUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,aAAa,CAAC,EAAE,MAAM,EACtB,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAST"}
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
* Matches a string regex (as provided from the config) against a target in a
|
|
9
|
+
* null-safe fashion, case insensitive and global.
|
|
10
|
+
*/
|
|
11
|
+
export function isRegexpStringMatch(regexAsString, valueToTest) {
|
|
12
|
+
if (typeof regexAsString === 'undefined' ||
|
|
13
|
+
typeof valueToTest === 'undefined') {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
return new RegExp(regexAsString, 'gi').test(valueToTest);
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=regexpUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"regexpUtils.js","sourceRoot":"","sources":["../../src/utils/regexpUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CACjC,aAAsB,EACtB,WAAoB;IAEpB,IACE,OAAO,aAAa,KAAK,WAAW;QACpC,OAAO,WAAW,KAAK,WAAW,EAClC;QACA,OAAO,KAAK,CAAC;KACd;IAED,OAAO,IAAI,MAAM,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;AAC3D,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
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 { RouteConfig } from 'react-router-config';
|
|
8
|
+
/**
|
|
9
|
+
* Compare the 2 paths, case insensitive and ignoring trailing slash
|
|
10
|
+
*/
|
|
11
|
+
export declare function isSamePath(path1: string | undefined, path2: string | undefined): boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Note that sites don't always have a homepage in practice, so we can't assume
|
|
14
|
+
* that linking to '/' is always safe.
|
|
15
|
+
* @see https://github.com/facebook/docusaurus/pull/6517#issuecomment-1048709116
|
|
16
|
+
*/
|
|
17
|
+
export declare function findHomePageRoute({ baseUrl, routes: initialRoutes, }: {
|
|
18
|
+
routes: RouteConfig[];
|
|
19
|
+
baseUrl: string;
|
|
20
|
+
}): RouteConfig | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* Fetches the route that points to "/". Use this instead of the naive "/",
|
|
23
|
+
* because the homepage may not exist.
|
|
24
|
+
*/
|
|
25
|
+
export declare function useHomePageRoute(): RouteConfig | undefined;
|
|
26
|
+
//# sourceMappingURL=routesUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routesUtils.d.ts","sourceRoot":"","sources":["../../src/utils/routesUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,qBAAqB,CAAC;AAErD;;GAEG;AACH,wBAAgB,UAAU,CACxB,KAAK,EAAE,MAAM,GAAG,SAAS,EACzB,KAAK,EAAE,MAAM,GAAG,SAAS,GACxB,OAAO,CAOT;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,EAChC,OAAO,EACP,MAAM,EAAE,aAAa,GACtB,EAAE;IACD,MAAM,EAAE,WAAW,EAAE,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;CACjB,GAAG,WAAW,GAAG,SAAS,CAwB1B;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,IAAI,WAAW,GAAG,SAAS,CAM1D"}
|
|
@@ -0,0 +1,54 @@
|
|
|
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 { useMemo } from 'react';
|
|
8
|
+
import generatedRoutes from '@generated/routes';
|
|
9
|
+
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
|
|
10
|
+
/**
|
|
11
|
+
* Compare the 2 paths, case insensitive and ignoring trailing slash
|
|
12
|
+
*/
|
|
13
|
+
export function isSamePath(path1, path2) {
|
|
14
|
+
const normalize = (pathname) => (!pathname || pathname.endsWith('/')
|
|
15
|
+
? pathname
|
|
16
|
+
: `${pathname}/`)?.toLowerCase();
|
|
17
|
+
return normalize(path1) === normalize(path2);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Note that sites don't always have a homepage in practice, so we can't assume
|
|
21
|
+
* that linking to '/' is always safe.
|
|
22
|
+
* @see https://github.com/facebook/docusaurus/pull/6517#issuecomment-1048709116
|
|
23
|
+
*/
|
|
24
|
+
export function findHomePageRoute({ baseUrl, routes: initialRoutes, }) {
|
|
25
|
+
function isHomePageRoute(route) {
|
|
26
|
+
return route.path === baseUrl && route.exact === true;
|
|
27
|
+
}
|
|
28
|
+
function isHomeParentRoute(route) {
|
|
29
|
+
return route.path === baseUrl && !route.exact;
|
|
30
|
+
}
|
|
31
|
+
function doFindHomePageRoute(routes) {
|
|
32
|
+
if (routes.length === 0) {
|
|
33
|
+
return undefined;
|
|
34
|
+
}
|
|
35
|
+
const homePage = routes.find(isHomePageRoute);
|
|
36
|
+
if (homePage) {
|
|
37
|
+
return homePage;
|
|
38
|
+
}
|
|
39
|
+
const indexSubRoutes = routes
|
|
40
|
+
.filter(isHomeParentRoute)
|
|
41
|
+
.flatMap((route) => route.routes ?? []);
|
|
42
|
+
return doFindHomePageRoute(indexSubRoutes);
|
|
43
|
+
}
|
|
44
|
+
return doFindHomePageRoute(initialRoutes);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Fetches the route that points to "/". Use this instead of the naive "/",
|
|
48
|
+
* because the homepage may not exist.
|
|
49
|
+
*/
|
|
50
|
+
export function useHomePageRoute() {
|
|
51
|
+
const { baseUrl } = useDocusaurusContext().siteConfig;
|
|
52
|
+
return useMemo(() => findHomePageRoute({ routes: generatedRoutes, baseUrl }), [baseUrl]);
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=routesUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routesUtils.js","sourceRoot":"","sources":["../../src/utils/routesUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAC,OAAO,EAAC,MAAM,OAAO,CAAC;AAC9B,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAChD,OAAO,oBAAoB,MAAM,kCAAkC,CAAC;AAGpE;;GAEG;AACH,MAAM,UAAU,UAAU,CACxB,KAAyB,EACzB,KAAyB;IAEzB,MAAM,SAAS,GAAG,CAAC,QAA4B,EAAE,EAAE,CACjD,CAAC,CAAC,QAAQ,IAAI,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC;QAClC,CAAC,CAAC,QAAQ;QACV,CAAC,CAAC,GAAG,QAAQ,GAAG,CACjB,EAAE,WAAW,EAAE,CAAC;IACnB,OAAO,SAAS,CAAC,KAAK,CAAC,KAAK,SAAS,CAAC,KAAK,CAAC,CAAC;AAC/C,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAC,EAChC,OAAO,EACP,MAAM,EAAE,aAAa,GAItB;IACC,SAAS,eAAe,CAAC,KAAkB;QACzC,OAAO,KAAK,CAAC,IAAI,KAAK,OAAO,IAAI,KAAK,CAAC,KAAK,KAAK,IAAI,CAAC;IACxD,CAAC;IAED,SAAS,iBAAiB,CAAC,KAAkB;QAC3C,OAAO,KAAK,CAAC,IAAI,KAAK,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC;IAChD,CAAC;IAED,SAAS,mBAAmB,CAAC,MAAqB;QAChD,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE;YACvB,OAAO,SAAS,CAAC;SAClB;QACD,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;QAC9C,IAAI,QAAQ,EAAE;YACZ,OAAO,QAAQ,CAAC;SACjB;QACD,MAAM,cAAc,GAAG,MAAM;aAC1B,MAAM,CAAC,iBAAiB,CAAC;aACzB,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC;QAC1C,OAAO,mBAAmB,CAAC,cAAc,CAAC,CAAC;IAC7C,CAAC;IAED,OAAO,mBAAmB,CAAC,aAAa,CAAC,CAAC;AAC5C,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,gBAAgB;IAC9B,MAAM,EAAC,OAAO,EAAC,GAAG,oBAAoB,EAAE,CAAC,UAAU,CAAC;IACpD,OAAO,OAAO,CACZ,GAAG,EAAE,CAAC,iBAAiB,CAAC,EAAC,MAAM,EAAE,eAAe,EAAE,OAAO,EAAC,CAAC,EAC3D,CAAC,OAAO,CAAC,CACV,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,83 @@
|
|
|
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 ReactNode } from 'react';
|
|
8
|
+
declare type ScrollController = {
|
|
9
|
+
/** A boolean ref tracking whether scroll events are enabled. */
|
|
10
|
+
scrollEventsEnabledRef: React.MutableRefObject<boolean>;
|
|
11
|
+
/** Enable scroll events in `useScrollPosition`. */
|
|
12
|
+
enableScrollEvents: () => void;
|
|
13
|
+
/** Disable scroll events in `useScrollPosition`. */
|
|
14
|
+
disableScrollEvents: () => void;
|
|
15
|
+
};
|
|
16
|
+
export declare function ScrollControllerProvider({ children, }: {
|
|
17
|
+
children: ReactNode;
|
|
18
|
+
}): JSX.Element;
|
|
19
|
+
/**
|
|
20
|
+
* We need a way to update the scroll position while ignoring scroll events
|
|
21
|
+
* so as not to toggle Navbar/BackToTop visibility.
|
|
22
|
+
*
|
|
23
|
+
* This API permits to temporarily disable/ignore scroll events. Motivated by
|
|
24
|
+
* https://github.com/facebook/docusaurus/pull/5618
|
|
25
|
+
*/
|
|
26
|
+
export declare function useScrollController(): ScrollController;
|
|
27
|
+
declare type ScrollPosition = {
|
|
28
|
+
scrollX: number;
|
|
29
|
+
scrollY: number;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* This hook fires an effect when the scroll position changes. The effect will
|
|
33
|
+
* be provided with the before/after scroll positions. Note that the effect may
|
|
34
|
+
* not be always run: if scrolling is disabled through `useScrollController`, it
|
|
35
|
+
* will be a no-op.
|
|
36
|
+
*
|
|
37
|
+
* @see {@link useScrollController}
|
|
38
|
+
*/
|
|
39
|
+
export declare function useScrollPosition(effect: (position: ScrollPosition, lastPosition: ScrollPosition | null) => void, deps?: unknown[]): void;
|
|
40
|
+
/**
|
|
41
|
+
* This hook permits to "block" the scroll position of a DOM element.
|
|
42
|
+
* The idea is that we should be able to update DOM content above this element
|
|
43
|
+
* but the screen position of this element should not change.
|
|
44
|
+
*
|
|
45
|
+
* Feature motivated by the Tabs groups: clicking on a tab may affect tabs of
|
|
46
|
+
* the same group upper in the tree, yet to avoid a bad UX, the clicked tab must
|
|
47
|
+
* remain under the user mouse.
|
|
48
|
+
*
|
|
49
|
+
* @see https://github.com/facebook/docusaurus/pull/5618
|
|
50
|
+
*/
|
|
51
|
+
export declare function useScrollPositionBlocker(): {
|
|
52
|
+
/**
|
|
53
|
+
* Takes an element, and keeps its screen position no matter what's getting
|
|
54
|
+
* rendered above it, until the next render.
|
|
55
|
+
*/
|
|
56
|
+
blockElementScrollPositionUntilNextRender: (el: HTMLElement) => void;
|
|
57
|
+
};
|
|
58
|
+
declare type CancelScrollTop = () => void;
|
|
59
|
+
/**
|
|
60
|
+
* A "smart polyfill" of `window.scrollTo({ top, behavior: "smooth" })`.
|
|
61
|
+
* This currently always uses a polyfilled implementation unless
|
|
62
|
+
* `scroll-behavior: smooth` has been set in CSS, because native support
|
|
63
|
+
* detection for scroll behavior seems unreliable.
|
|
64
|
+
*
|
|
65
|
+
* This hook does not do anything by itself: it returns a start and a stop
|
|
66
|
+
* handle. You can execute either handle at any time.
|
|
67
|
+
*/
|
|
68
|
+
export declare function useSmoothScrollTo(): {
|
|
69
|
+
/**
|
|
70
|
+
* Start the scroll.
|
|
71
|
+
*
|
|
72
|
+
* @param top The final scroll top position.
|
|
73
|
+
*/
|
|
74
|
+
startScroll: (top: number) => void;
|
|
75
|
+
/**
|
|
76
|
+
* A cancel function, because the non-native smooth scroll-top
|
|
77
|
+
* implementation must be interrupted if user scrolls down. If there's no
|
|
78
|
+
* existing animation or the scroll is using native behavior, this is a no-op.
|
|
79
|
+
*/
|
|
80
|
+
cancelScroll: CancelScrollTop;
|
|
81
|
+
};
|
|
82
|
+
export {};
|
|
83
|
+
//# sourceMappingURL=scrollUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scrollUtils.d.ts","sourceRoot":"","sources":["../../src/utils/scrollUtils.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,EAOZ,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAKf,aAAK,gBAAgB,GAAG;IACtB,gEAAgE;IAChE,sBAAsB,EAAE,KAAK,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;IACxD,mDAAmD;IACnD,kBAAkB,EAAE,MAAM,IAAI,CAAC;IAC/B,oDAAoD;IACpD,mBAAmB,EAAE,MAAM,IAAI,CAAC;CACjC,CAAC;AAuBF,wBAAgB,wBAAwB,CAAC,EACvC,QAAQ,GACT,EAAE;IACD,QAAQ,EAAE,SAAS,CAAC;CACrB,GAAG,GAAG,CAAC,OAAO,CAOd;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB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