@docusaurus/theme-common 2.0.0-beta.14 → 2.0.0-beta.15
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 +1 -1
- package/lib/components/Collapsible/index.d.ts.map +1 -1
- package/lib/components/Collapsible/index.js +1 -1
- package/lib/components/Collapsible/index.js.map +1 -1
- package/lib/components/Details/index.d.ts +1 -1
- package/lib/components/Details/index.d.ts.map +1 -1
- package/lib/components/Details/index.js +1 -1
- package/lib/components/Details/index.js.map +1 -1
- package/lib/components/Details/styles.module.css +4 -4
- package/lib/hooks/styles.css +10 -0
- package/lib/hooks/useHideableNavbar.d.ts +13 -0
- package/lib/hooks/useHideableNavbar.d.ts.map +1 -0
- package/lib/hooks/useHideableNavbar.js +59 -0
- package/lib/hooks/useHideableNavbar.js.map +1 -0
- package/lib/hooks/useKeyboardNavigation.d.ts +9 -0
- package/lib/hooks/useKeyboardNavigation.d.ts.map +1 -0
- package/lib/hooks/useKeyboardNavigation.js +31 -0
- package/lib/hooks/useKeyboardNavigation.js.map +1 -0
- package/lib/hooks/useLockBodyScroll.d.ts +8 -0
- package/lib/hooks/useLockBodyScroll.d.ts.map +1 -0
- package/lib/hooks/useLockBodyScroll.js +16 -0
- package/lib/hooks/useLockBodyScroll.js.map +1 -0
- package/lib/hooks/usePrismTheme.d.ts +9 -0
- package/lib/hooks/usePrismTheme.d.ts.map +1 -0
- package/lib/hooks/usePrismTheme.js +18 -0
- package/lib/hooks/usePrismTheme.js.map +1 -0
- package/lib/hooks/useSearchPage.d.ts +14 -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/useWindowSize.d.ts +15 -0
- package/lib/hooks/useWindowSize.d.ts.map +1 -0
- package/lib/hooks/useWindowSize.js +54 -0
- package/lib/hooks/useWindowSize.js.map +1 -0
- package/lib/index.d.ts +9 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +9 -0
- package/lib/index.js.map +1 -1
- package/lib/utils/ThemeClassNames.d.ts +1 -0
- package/lib/utils/ThemeClassNames.d.ts.map +1 -1
- package/lib/utils/ThemeClassNames.js +1 -0
- package/lib/utils/ThemeClassNames.js.map +1 -1
- package/lib/utils/announcementBarUtils.d.ts +1 -1
- package/lib/utils/announcementBarUtils.d.ts.map +1 -1
- package/lib/utils/announcementBarUtils.js +2 -1
- package/lib/utils/announcementBarUtils.js.map +1 -1
- package/lib/utils/codeBlockUtils.d.ts +2 -3
- package/lib/utils/codeBlockUtils.d.ts.map +1 -1
- package/lib/utils/codeBlockUtils.js +3 -1
- package/lib/utils/codeBlockUtils.js.map +1 -1
- package/lib/utils/colorModeUtils.d.ts +18 -0
- package/lib/utils/colorModeUtils.d.ts.map +1 -0
- package/lib/utils/colorModeUtils.js +84 -0
- package/lib/utils/colorModeUtils.js.map +1 -0
- package/lib/utils/docSidebarItemsExpandedState.d.ts +17 -0
- package/lib/utils/docSidebarItemsExpandedState.d.ts.map +1 -0
- package/lib/utils/docSidebarItemsExpandedState.js +22 -0
- package/lib/utils/docSidebarItemsExpandedState.js.map +1 -0
- package/lib/utils/docsPreferredVersion/DocsPreferredVersionProvider.d.ts.map +1 -1
- package/lib/utils/docsPreferredVersion/DocsPreferredVersionProvider.js +2 -2
- package/lib/utils/docsPreferredVersion/DocsPreferredVersionProvider.js.map +1 -1
- package/lib/utils/docsPreferredVersion/DocsPreferredVersionStorage.d.ts +1 -1
- package/lib/utils/docsPreferredVersion/DocsPreferredVersionStorage.d.ts.map +1 -1
- package/lib/utils/docsPreferredVersion/useDocsPreferredVersion.d.ts +1 -1
- package/lib/utils/docsPreferredVersion/useDocsPreferredVersion.d.ts.map +1 -1
- package/lib/utils/docsPreferredVersion/useDocsPreferredVersion.js +1 -1
- package/lib/utils/docsPreferredVersion/useDocsPreferredVersion.js.map +1 -1
- package/lib/utils/docsUtils.d.ts +2 -2
- package/lib/utils/docsUtils.d.ts.map +1 -1
- package/lib/utils/docsUtils.js +1 -1
- package/lib/utils/docsUtils.js.map +1 -1
- package/lib/utils/mobileSecondaryMenu.d.ts +1 -1
- package/lib/utils/mobileSecondaryMenu.d.ts.map +1 -1
- package/lib/utils/mobileSecondaryMenu.js +1 -1
- package/lib/utils/mobileSecondaryMenu.js.map +1 -1
- package/lib/utils/regexpUtils.d.ts +1 -1
- package/lib/utils/regexpUtils.js +1 -1
- package/lib/utils/scrollUtils.d.ts +1 -1
- package/lib/utils/scrollUtils.d.ts.map +1 -1
- package/lib/utils/tabGroupChoiceUtils.d.ts +19 -0
- package/lib/utils/tabGroupChoiceUtils.d.ts.map +1 -0
- package/lib/utils/tabGroupChoiceUtils.js +54 -0
- package/lib/utils/tabGroupChoiceUtils.js.map +1 -0
- package/lib/utils/tocUtils.d.ts +1 -1
- package/lib/utils/tocUtils.d.ts.map +1 -1
- package/lib/utils/useContextualSearchFilters.d.ts.map +1 -1
- package/lib/utils/useContextualSearchFilters.js +1 -1
- package/lib/utils/useContextualSearchFilters.js.map +1 -1
- package/lib/utils/useLocationChange.d.ts +1 -1
- package/lib/utils/useLocationChange.d.ts.map +1 -1
- package/lib/utils/useTOCHighlight.d.ts.map +1 -1
- package/lib/utils/useTOCHighlight.js +1 -0
- package/lib/utils/useTOCHighlight.js.map +1 -1
- package/lib/utils/useThemeConfig.d.ts +4 -3
- package/lib/utils/useThemeConfig.d.ts.map +1 -1
- package/lib/utils/useThemeConfig.js.map +1 -1
- package/package.json +11 -11
- package/src/components/Collapsible/index.tsx +5 -5
- package/src/components/Details/index.tsx +6 -1
- package/src/components/Details/styles.module.css +4 -4
- package/src/hooks/styles.css +10 -0
- package/src/hooks/useHideableNavbar.ts +77 -0
- package/src/hooks/useKeyboardNavigation.ts +37 -0
- package/src/hooks/useLockBodyScroll.ts +18 -0
- package/src/hooks/usePrismTheme.ts +20 -0
- package/src/hooks/useSearchPage.ts +66 -0
- package/src/hooks/useWindowSize.ts +68 -0
- package/src/index.ts +17 -0
- package/src/utils/ThemeClassNames.ts +1 -0
- package/src/utils/announcementBarUtils.tsx +3 -2
- package/src/utils/codeBlockUtils.ts +4 -5
- package/src/utils/colorModeUtils.tsx +135 -0
- package/src/utils/docSidebarItemsExpandedState.tsx +41 -0
- package/src/utils/docsPreferredVersion/DocsPreferredVersionProvider.tsx +7 -4
- package/src/utils/docsPreferredVersion/DocsPreferredVersionStorage.ts +1 -1
- package/src/utils/docsPreferredVersion/useDocsPreferredVersion.ts +5 -1
- package/src/utils/docsUtils.tsx +3 -3
- package/src/utils/mobileSecondaryMenu.tsx +3 -3
- package/src/utils/regexpUtils.ts +1 -1
- package/src/utils/scrollUtils.tsx +1 -1
- package/src/utils/tabGroupChoiceUtils.tsx +90 -0
- package/src/utils/tocUtils.ts +1 -1
- package/src/utils/useContextualSearchFilters.ts +4 -1
- package/src/utils/useLocationChange.ts +1 -1
- package/src/utils/useTOCHighlight.ts +1 -0
- package/src/utils/useThemeConfig.ts +4 -3
|
@@ -4,7 +4,7 @@
|
|
|
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 { Location } from '@docusaurus/history';
|
|
7
|
+
import type { Location } from '@docusaurus/history';
|
|
8
8
|
declare type LocationChangeEvent = {
|
|
9
9
|
location: Location;
|
|
10
10
|
previousLocation: Location | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLocationChange.d.ts","sourceRoot":"","sources":["../../src/utils/useLocationChange.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAC,QAAQ,EAAC,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"useLocationChange.d.ts","sourceRoot":"","sources":["../../src/utils/useLocationChange.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,qBAAqB,CAAC;AAIlD,aAAK,mBAAmB,GAAG;IACzB,QAAQ,EAAE,QAAQ,CAAC;IACnB,gBAAgB,EAAE,QAAQ,GAAG,SAAS,CAAC;CACxC,CAAC;AAEF,aAAK,gBAAgB,GAAG,CAAC,mBAAmB,EAAE,mBAAmB,KAAK,IAAI,CAAC;AAE3E,wBAAgB,iBAAiB,CAAC,gBAAgB,EAAE,gBAAgB,GAAG,IAAI,CAc1E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTOCHighlight.d.ts","sourceRoot":"","sources":["../../src/utils/useTOCHighlight.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AA6GH,oBAAY,kBAAkB,GAAG;IAC/B,aAAa,EAAE,MAAM,CAAC;IACtB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,eAAe,EAAE,MAAM,CAAC;IACxB,eAAe,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,iBAAS,eAAe,CAAC,MAAM,EAAE,kBAAkB,GAAG,SAAS,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"useTOCHighlight.d.ts","sourceRoot":"","sources":["../../src/utils/useTOCHighlight.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AA6GH,oBAAY,kBAAkB,GAAG;IAC/B,aAAa,EAAE,MAAM,CAAC;IACtB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,eAAe,EAAE,MAAM,CAAC;IACxB,eAAe,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,iBAAS,eAAe,CAAC,MAAM,EAAE,kBAAkB,GAAG,SAAS,GAAG,IAAI,CAwDrE;AAED,eAAe,eAAe,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTOCHighlight.js","sourceRoot":"","sources":["../../src/utils/useTOCHighlight.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAC,SAAS,EAAE,MAAM,EAAC,MAAM,OAAO,CAAC;AACxC,OAAO,EAAC,cAAc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AAE,gBAAgB,CAAC,CAAC;QAEtD,gBAAgB,EAAE,CAAC;QAEnB,OAAO,GAAG,EAAE;YACV,QAAQ,CAAC,mBAAmB,CAAC,QAAQ,EAAE,gBAAgB,CAAC,CAAC;YACzD,QAAQ,CAAC,mBAAmB,CAAC,QAAQ,EAAE,gBAAgB,CAAC,CAAC;QAC3D,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC,CAAC;AACnC,CAAC;AAED,eAAe,eAAe,CAAC"}
|
|
@@ -4,9 +4,9 @@
|
|
|
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 { PrismTheme } from 'prism-react-renderer';
|
|
8
|
-
import { CSSProperties } from 'react';
|
|
9
|
-
import { DeepPartial } from 'utility-types';
|
|
7
|
+
import type { PrismTheme } from 'prism-react-renderer';
|
|
8
|
+
import type { CSSProperties } from 'react';
|
|
9
|
+
import type { DeepPartial } from 'utility-types';
|
|
10
10
|
export declare type DocsVersionPersistence = 'localStorage' | 'none';
|
|
11
11
|
export declare type NavbarItem = {
|
|
12
12
|
type?: string | undefined;
|
|
@@ -97,6 +97,7 @@ export declare type ThemeConfig = {
|
|
|
97
97
|
prism: PrismConfig;
|
|
98
98
|
footer?: Footer;
|
|
99
99
|
hideableSidebar: boolean;
|
|
100
|
+
autoCollapseSidebarCategories: boolean;
|
|
100
101
|
image?: string;
|
|
101
102
|
metadata: Array<Record<string, string>>;
|
|
102
103
|
sidebarCollapsible: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useThemeConfig.d.ts","sourceRoot":"","sources":["../../src/utils/useThemeConfig.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAC,UAAU,EAAC,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"useThemeConfig.d.ts","sourceRoot":"","sources":["../../src/utils/useThem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CAAC;KACzB,CAAC,CAAC;CACJ,CAAC;AAEF,oBAAY,YAAY,GAAG,UAAU,GAAG;IACtC,KAAK,EAAE,cAAc,EAAE,CAAC;CACzB,CAAC;AAEF,oBAAY,MAAM,GAAG,iBAAiB,GAAG,YAAY,CAAC;AAEtD,oBAAY,eAAe,GAAG;IAC5B,eAAe,EAAE,MAAM,CAAC;IACxB,eAAe,EAAE,MAAM,CAAC;CACzB,CAAC;AAGF,oBAAY,WAAW,GAAG;IACxB,IAAI,EAAE;QACJ,kBAAkB,EAAE,sBAAsB,CAAC;KAC5C,CAAC;IAOF,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,eAAe,CAAC;IAC3B,eAAe,CAAC,EAAE,qBAAqB,CAAC;IACxC,KAAK,EAAE,WAAW,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE,OAAO,CAAC;IACzB,6BAA6B,EAAE,OAAO,CAAC;IACvC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACxC,kBAAkB,EAAE,OAAO,CAAC;IAC5B,eAAe,EAAE,eAAe,CAAC;CAClC,CAAC;AAGF,oBAAY,eAAe,GAAG,WAAW,CAAC,WAAW,CAAC,CAAC;AAEvD,wBAAgB,cAAc,IAAI,WAAW,CAE5C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useThemeConfig.js","sourceRoot":"","sources":["../../src/utils/useThemeConfig.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,oBAAoB,MAAM,kCAAkC,CAAC;
|
|
1
|
+
{"version":3,"file":"useThemeConfig.js","sourceRoot":"","sources":["../../src/utils/useThemeConfig.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,oBAAoB,MAAM,kCAAkC,CAAC;AA+HpE,MAAM,UAAU,cAAc;IAC5B,OAAO,oBAAoB,EAAE,CAAC,UAAU,CAAC,WAA0B,CAAC;AACtE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/theme-common",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.15",
|
|
4
4
|
"description": "Common code for Docusaurus themes.",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"types": "./lib/index.d.ts",
|
|
7
7
|
"scripts": {
|
|
8
|
-
"build": "node copyUntypedFiles.
|
|
9
|
-
"watch": "node copyUntypedFiles.
|
|
8
|
+
"build": "node copyUntypedFiles.mjs && tsc",
|
|
9
|
+
"watch": "node copyUntypedFiles.mjs && tsc --watch"
|
|
10
10
|
},
|
|
11
11
|
"publishConfig": {
|
|
12
12
|
"access": "public"
|
|
@@ -18,20 +18,20 @@
|
|
|
18
18
|
},
|
|
19
19
|
"license": "MIT",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@docusaurus/plugin-content-blog": "2.0.0-beta.
|
|
22
|
-
"@docusaurus/plugin-content-docs": "2.0.0-beta.
|
|
23
|
-
"@docusaurus/plugin-content-pages": "2.0.0-beta.
|
|
21
|
+
"@docusaurus/plugin-content-blog": "2.0.0-beta.15",
|
|
22
|
+
"@docusaurus/plugin-content-docs": "2.0.0-beta.15",
|
|
23
|
+
"@docusaurus/plugin-content-pages": "2.0.0-beta.15",
|
|
24
24
|
"clsx": "^1.1.1",
|
|
25
|
-
"fs-extra": "^10.0.0",
|
|
26
25
|
"parse-numeric-range": "^1.3.0",
|
|
27
26
|
"tslib": "^2.3.1",
|
|
28
27
|
"utility-types": "^3.10.0"
|
|
29
28
|
},
|
|
30
29
|
"devDependencies": {
|
|
31
|
-
"@docusaurus/core": "2.0.0-beta.
|
|
32
|
-
"@docusaurus/module-type-aliases": "2.0.0-beta.
|
|
33
|
-
"@docusaurus/types": "2.0.0-beta.
|
|
30
|
+
"@docusaurus/core": "2.0.0-beta.15",
|
|
31
|
+
"@docusaurus/module-type-aliases": "2.0.0-beta.15",
|
|
32
|
+
"@docusaurus/types": "2.0.0-beta.15",
|
|
34
33
|
"@testing-library/react-hooks": "^7.0.2",
|
|
34
|
+
"fs-extra": "^10.0.0",
|
|
35
35
|
"lodash": "^4.17.20"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
@@ -42,5 +42,5 @@
|
|
|
42
42
|
"engines": {
|
|
43
43
|
"node": ">=14"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "6cfad16436c07d8d11e5c2e1486dc59afd483e33"
|
|
46
46
|
}
|
|
@@ -11,10 +11,10 @@ import React, {
|
|
|
11
11
|
useEffect,
|
|
12
12
|
useRef,
|
|
13
13
|
useCallback,
|
|
14
|
-
RefObject,
|
|
15
|
-
Dispatch,
|
|
16
|
-
SetStateAction,
|
|
17
|
-
ReactNode,
|
|
14
|
+
type RefObject,
|
|
15
|
+
type Dispatch,
|
|
16
|
+
type SetStateAction,
|
|
17
|
+
type ReactNode,
|
|
18
18
|
useLayoutEffect,
|
|
19
19
|
} from 'react';
|
|
20
20
|
|
|
@@ -151,7 +151,7 @@ type CollapsibleElementType = React.ElementType<
|
|
|
151
151
|
Pick<React.HTMLAttributes<unknown>, 'className' | 'onTransitionEnd' | 'style'>
|
|
152
152
|
>;
|
|
153
153
|
|
|
154
|
-
// Prevent hydration layout shift before
|
|
154
|
+
// Prevent hydration layout shift before animations are handled imperatively with JS
|
|
155
155
|
function getSSRStyle(collapsed: boolean) {
|
|
156
156
|
if (ExecutionEnvironment.canUseDOM) {
|
|
157
157
|
return undefined;
|
|
@@ -5,7 +5,12 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import React, {
|
|
8
|
+
import React, {
|
|
9
|
+
type ComponentProps,
|
|
10
|
+
type ReactElement,
|
|
11
|
+
useRef,
|
|
12
|
+
useState,
|
|
13
|
+
} from 'react';
|
|
9
14
|
import useIsBrowser from '@docusaurus/useIsBrowser';
|
|
10
15
|
import clsx from 'clsx';
|
|
11
16
|
import {useCollapsible, Collapsible} from '../Collapsible';
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
/*
|
|
9
|
-
CSS variables, meant to be
|
|
9
|
+
CSS variables, meant to be overridden by final theme
|
|
10
10
|
*/
|
|
11
11
|
.details {
|
|
12
12
|
--docusaurus-details-summary-arrow-size: 0.38rem;
|
|
@@ -26,7 +26,7 @@ CSS variables, meant to be overriden by final theme
|
|
|
26
26
|
display: none;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
.details > summary
|
|
29
|
+
.details > summary::before {
|
|
30
30
|
position: absolute;
|
|
31
31
|
top: 0.45rem;
|
|
32
32
|
left: 0;
|
|
@@ -45,9 +45,9 @@ CSS variables, meant to be overriden by final theme
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
/* When JS disabled/failed to load: we use the open property for arrow animation: */
|
|
48
|
-
.details[open]:not(.isBrowser) > summary
|
|
48
|
+
.details[open]:not(.isBrowser) > summary::before,
|
|
49
49
|
/* When JS works: we use the data-attribute for arrow animation */
|
|
50
|
-
.details[data-collapsed='false'].isBrowser > summary
|
|
50
|
+
.details[data-collapsed='false'].isBrowser > summary::before {
|
|
51
51
|
transform: rotate(90deg);
|
|
52
52
|
}
|
|
53
53
|
|
|
@@ -0,0 +1,10 @@
|
|
|
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
|
+
body:not(.navigation-with-keyboard) *:not(input):focus {
|
|
9
|
+
outline: none;
|
|
10
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
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
|
+
import {useState, useCallback, useRef} from 'react';
|
|
9
|
+
import {useLocationChange} from '../utils/useLocationChange';
|
|
10
|
+
import {useScrollPosition} from '../utils/scrollUtils';
|
|
11
|
+
|
|
12
|
+
type UseHideableNavbarReturns = {
|
|
13
|
+
readonly navbarRef: (node: HTMLElement | null) => void;
|
|
14
|
+
readonly isNavbarVisible: boolean;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export default function useHideableNavbar(
|
|
18
|
+
hideOnScroll: boolean,
|
|
19
|
+
): UseHideableNavbarReturns {
|
|
20
|
+
const [isNavbarVisible, setIsNavbarVisible] = useState(hideOnScroll);
|
|
21
|
+
const isFocusedAnchor = useRef(false);
|
|
22
|
+
const navbarHeight = useRef(0);
|
|
23
|
+
const navbarRef = useCallback((node: HTMLElement | null) => {
|
|
24
|
+
if (node !== null) {
|
|
25
|
+
navbarHeight.current = node.getBoundingClientRect().height;
|
|
26
|
+
}
|
|
27
|
+
}, []);
|
|
28
|
+
|
|
29
|
+
useScrollPosition((currentPosition, lastPosition) => {
|
|
30
|
+
if (!hideOnScroll) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const scrollTop = currentPosition.scrollY;
|
|
35
|
+
|
|
36
|
+
// It needed for mostly to handle rubber band scrolling
|
|
37
|
+
if (scrollTop < navbarHeight.current) {
|
|
38
|
+
setIsNavbarVisible(true);
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (isFocusedAnchor.current) {
|
|
43
|
+
isFocusedAnchor.current = false;
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const lastScrollTop = lastPosition?.scrollY;
|
|
48
|
+
const documentHeight =
|
|
49
|
+
document.documentElement.scrollHeight - navbarHeight.current;
|
|
50
|
+
const windowHeight = window.innerHeight;
|
|
51
|
+
|
|
52
|
+
if (lastScrollTop && scrollTop >= lastScrollTop) {
|
|
53
|
+
setIsNavbarVisible(false);
|
|
54
|
+
} else if (scrollTop + windowHeight < documentHeight) {
|
|
55
|
+
setIsNavbarVisible(true);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
useLocationChange((locationChangeEvent) => {
|
|
60
|
+
if (!hideOnScroll) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (locationChangeEvent.location.hash) {
|
|
65
|
+
isFocusedAnchor.current = true;
|
|
66
|
+
setIsNavbarVisible(false);
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
setIsNavbarVisible(true);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
return {
|
|
74
|
+
navbarRef,
|
|
75
|
+
isNavbarVisible,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
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
|
+
import {useEffect} from 'react';
|
|
9
|
+
|
|
10
|
+
import './styles.css';
|
|
11
|
+
|
|
12
|
+
// This hook detect keyboard focus indicator to not show outline for mouse users
|
|
13
|
+
// Inspired by https://hackernoon.com/removing-that-ugly-focus-ring-and-keeping-it-too-6c8727fefcd2
|
|
14
|
+
export default function useKeyboardNavigation(): void {
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
const keyboardFocusedClassName = 'navigation-with-keyboard';
|
|
17
|
+
|
|
18
|
+
function handleOutlineStyles(e: MouseEvent | KeyboardEvent) {
|
|
19
|
+
if (e.type === 'keydown' && (e as KeyboardEvent).key === 'Tab') {
|
|
20
|
+
document.body.classList.add(keyboardFocusedClassName);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if (e.type === 'mousedown') {
|
|
24
|
+
document.body.classList.remove(keyboardFocusedClassName);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
document.addEventListener('keydown', handleOutlineStyles);
|
|
29
|
+
document.addEventListener('mousedown', handleOutlineStyles);
|
|
30
|
+
|
|
31
|
+
return () => {
|
|
32
|
+
document.body.classList.remove(keyboardFocusedClassName);
|
|
33
|
+
document.removeEventListener('keydown', handleOutlineStyles);
|
|
34
|
+
document.removeEventListener('mousedown', handleOutlineStyles);
|
|
35
|
+
};
|
|
36
|
+
}, []);
|
|
37
|
+
}
|
|
@@ -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
|
+
import {useEffect} from 'react';
|
|
9
|
+
|
|
10
|
+
export default function useLockBodyScroll(lock: boolean = true): void {
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
document.body.style.overflow = lock ? 'hidden' : 'visible';
|
|
13
|
+
|
|
14
|
+
return () => {
|
|
15
|
+
document.body.style.overflow = 'visible';
|
|
16
|
+
};
|
|
17
|
+
}, [lock]);
|
|
18
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
import defaultTheme from 'prism-react-renderer/themes/palenight';
|
|
9
|
+
import {useColorMode} from '../utils/colorModeUtils';
|
|
10
|
+
import {useThemeConfig} from '../utils/useThemeConfig';
|
|
11
|
+
|
|
12
|
+
export default function usePrismTheme(): typeof defaultTheme {
|
|
13
|
+
const {prism} = useThemeConfig();
|
|
14
|
+
const {isDarkTheme} = useColorMode();
|
|
15
|
+
const lightModeTheme = prism.theme || defaultTheme;
|
|
16
|
+
const darkModeTheme = prism.darkTheme || lightModeTheme;
|
|
17
|
+
const prismTheme = isDarkTheme ? darkModeTheme : lightModeTheme;
|
|
18
|
+
|
|
19
|
+
return prismTheme;
|
|
20
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
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
|
+
import {useHistory} from '@docusaurus/router';
|
|
9
|
+
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
|
|
10
|
+
import {useCallback, useEffect, useState} from 'react';
|
|
11
|
+
|
|
12
|
+
const SEARCH_PARAM_QUERY = 'q';
|
|
13
|
+
|
|
14
|
+
interface UseSearchPageReturn {
|
|
15
|
+
searchQuery: string;
|
|
16
|
+
setSearchQuery: (newSearchQuery: string) => void;
|
|
17
|
+
generateSearchPageLink: (targetSearchQuery: string) => string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export default function useSearchPage(): UseSearchPageReturn {
|
|
21
|
+
const history = useHistory();
|
|
22
|
+
const {
|
|
23
|
+
siteConfig: {baseUrl},
|
|
24
|
+
} = useDocusaurusContext();
|
|
25
|
+
|
|
26
|
+
const [searchQuery, setSearchQueryState] = useState('');
|
|
27
|
+
|
|
28
|
+
// Init search query just after React hydration
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
const searchQueryStringValue =
|
|
31
|
+
new URLSearchParams(window.location.search).get(SEARCH_PARAM_QUERY) ?? '';
|
|
32
|
+
|
|
33
|
+
setSearchQueryState(searchQueryStringValue);
|
|
34
|
+
}, []);
|
|
35
|
+
|
|
36
|
+
const setSearchQuery = useCallback(
|
|
37
|
+
(newSearchQuery: string) => {
|
|
38
|
+
const searchParams = new URLSearchParams(window.location.search);
|
|
39
|
+
|
|
40
|
+
if (newSearchQuery) {
|
|
41
|
+
searchParams.set(SEARCH_PARAM_QUERY, newSearchQuery);
|
|
42
|
+
} else {
|
|
43
|
+
searchParams.delete(SEARCH_PARAM_QUERY);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
history.replace({
|
|
47
|
+
search: searchParams.toString(),
|
|
48
|
+
});
|
|
49
|
+
setSearchQueryState(newSearchQuery);
|
|
50
|
+
},
|
|
51
|
+
[history],
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
const generateSearchPageLink = useCallback(
|
|
55
|
+
(targetSearchQuery: string) =>
|
|
56
|
+
// Refer to https://github.com/facebook/docusaurus/pull/2838
|
|
57
|
+
`${baseUrl}search?q=${encodeURIComponent(targetSearchQuery)}`,
|
|
58
|
+
[baseUrl],
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
return {
|
|
62
|
+
searchQuery,
|
|
63
|
+
setSearchQuery,
|
|
64
|
+
generateSearchPageLink,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
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
|
+
import {useEffect, useState} from 'react';
|
|
9
|
+
|
|
10
|
+
import ExecutionEnvironment from '@docusaurus/ExecutionEnvironment';
|
|
11
|
+
|
|
12
|
+
const windowSizes = {
|
|
13
|
+
desktop: 'desktop',
|
|
14
|
+
mobile: 'mobile',
|
|
15
|
+
|
|
16
|
+
// This "ssr" value is very important to handle hydration FOUC / layout shifts
|
|
17
|
+
// You have to handle server-rendering explicitly on the call-site
|
|
18
|
+
// On the server, you may need to render BOTH the mobile/desktop elements (and hide one of them with mediaquery)
|
|
19
|
+
// We don't return "undefined" on purpose, to make it more explicit
|
|
20
|
+
ssr: 'ssr',
|
|
21
|
+
} as const;
|
|
22
|
+
|
|
23
|
+
type WindowSize = keyof typeof windowSizes;
|
|
24
|
+
|
|
25
|
+
const DesktopThresholdWidth = 996;
|
|
26
|
+
|
|
27
|
+
function getWindowSize() {
|
|
28
|
+
if (!ExecutionEnvironment.canUseDOM) {
|
|
29
|
+
return windowSizes.ssr;
|
|
30
|
+
}
|
|
31
|
+
return window.innerWidth > DesktopThresholdWidth
|
|
32
|
+
? windowSizes.desktop
|
|
33
|
+
: windowSizes.mobile;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Simulate the SSR window size in dev, so that potential hydration FOUC/layout shift problems can be seen in dev too!
|
|
37
|
+
const DevSimulateSSR = process.env.NODE_ENV === 'development' && true;
|
|
38
|
+
|
|
39
|
+
// This hook returns an enum value on purpose!
|
|
40
|
+
// We don't want it to return the actual width value, for resize perf reasons
|
|
41
|
+
// We only want to re-render once a breakpoint is crossed
|
|
42
|
+
export default function useWindowSize(): WindowSize {
|
|
43
|
+
const [windowSize, setWindowSize] = useState<WindowSize>(() => {
|
|
44
|
+
if (DevSimulateSSR) {
|
|
45
|
+
return 'ssr';
|
|
46
|
+
}
|
|
47
|
+
return getWindowSize();
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
useEffect(() => {
|
|
51
|
+
function updateWindowSize() {
|
|
52
|
+
setWindowSize(getWindowSize());
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const timeout = DevSimulateSSR
|
|
56
|
+
? window.setTimeout(updateWindowSize, 1000)
|
|
57
|
+
: undefined;
|
|
58
|
+
|
|
59
|
+
window.addEventListener('resize', updateWindowSize);
|
|
60
|
+
|
|
61
|
+
return () => {
|
|
62
|
+
window.removeEventListener('resize', updateWindowSize);
|
|
63
|
+
clearTimeout(timeout);
|
|
64
|
+
};
|
|
65
|
+
}, []);
|
|
66
|
+
|
|
67
|
+
return windowSize;
|
|
68
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -6,6 +6,10 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
export {useThemeConfig} from './utils/useThemeConfig';
|
|
9
|
+
export {
|
|
10
|
+
DocSidebarItemsExpandedStateProvider,
|
|
11
|
+
useDocSidebarItemsExpandedState,
|
|
12
|
+
} from './utils/docSidebarItemsExpandedState';
|
|
9
13
|
|
|
10
14
|
export type {
|
|
11
15
|
ThemeConfig,
|
|
@@ -114,3 +118,16 @@ export {
|
|
|
114
118
|
} from './utils/reactUtils';
|
|
115
119
|
|
|
116
120
|
export {isRegexpStringMatch} from './utils/regexpUtils';
|
|
121
|
+
|
|
122
|
+
export {useColorMode, ColorModeProvider} from './utils/colorModeUtils';
|
|
123
|
+
export {
|
|
124
|
+
useTabGroupChoice,
|
|
125
|
+
TabGroupChoiceProvider,
|
|
126
|
+
} from './utils/tabGroupChoiceUtils';
|
|
127
|
+
|
|
128
|
+
export {default as useHideableNavbar} from './hooks/useHideableNavbar';
|
|
129
|
+
export {default as useKeyboardNavigation} from './hooks/useKeyboardNavigation';
|
|
130
|
+
export {default as usePrismTheme} from './hooks/usePrismTheme';
|
|
131
|
+
export {default as useLockBodyScroll} from './hooks/useLockBodyScroll';
|
|
132
|
+
export {default as useWindowSize} from './hooks/useWindowSize';
|
|
133
|
+
export {default as useSearchPage} from './hooks/useSearchPage';
|
|
@@ -48,6 +48,7 @@ export const ThemeClassNames = {
|
|
|
48
48
|
docFooter: 'theme-doc-footer',
|
|
49
49
|
docFooterTagsRow: 'theme-doc-footer-tags-row',
|
|
50
50
|
docFooterEditMetaRow: 'theme-doc-footer-edit-meta-row',
|
|
51
|
+
docSidebarContainer: 'theme-doc-sidebar-container',
|
|
51
52
|
docSidebarMenu: 'theme-doc-sidebar-menu',
|
|
52
53
|
docSidebarItemCategory: 'theme-doc-sidebar-item-category',
|
|
53
54
|
docSidebarItemLink: 'theme-doc-sidebar-item-link',
|
|
@@ -10,7 +10,7 @@ import React, {
|
|
|
10
10
|
useEffect,
|
|
11
11
|
useCallback,
|
|
12
12
|
useMemo,
|
|
13
|
-
ReactNode,
|
|
13
|
+
type ReactNode,
|
|
14
14
|
useContext,
|
|
15
15
|
createContext,
|
|
16
16
|
} from 'react';
|
|
@@ -43,7 +43,7 @@ const useAnnouncementBarContextValue = (): AnnouncementBarAPI => {
|
|
|
43
43
|
|
|
44
44
|
const [isClosed, setClosed] = useState(() =>
|
|
45
45
|
isBrowser
|
|
46
|
-
? // On client navigation: init with
|
|
46
|
+
? // On client navigation: init with local storage value
|
|
47
47
|
isDismissedInStorage()
|
|
48
48
|
: // On server/hydration: always visible to prevent layout shifts (will be hidden with css if needed)
|
|
49
49
|
false,
|
|
@@ -68,6 +68,7 @@ const useAnnouncementBarContextValue = (): AnnouncementBarAPI => {
|
|
|
68
68
|
|
|
69
69
|
// retrocompatibility due to spelling mistake of default id
|
|
70
70
|
// see https://github.com/facebook/docusaurus/issues/3338
|
|
71
|
+
// cSpell:ignore annoucement
|
|
71
72
|
if (viewedId === 'annoucement-bar') {
|
|
72
73
|
viewedId = 'announcement-bar';
|
|
73
74
|
}
|
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import rangeParser from 'parse-numeric-range';
|
|
9
|
-
import type {Language} from 'prism-react-renderer';
|
|
10
9
|
|
|
11
10
|
const codeBlockTitleRegex = /title=(["'])(.*?)\1/;
|
|
12
11
|
const highlightLinesRangeRegex = /{([\d,-]+)}/;
|
|
@@ -93,11 +92,11 @@ export function parseCodeBlockTitle(metastring?: string): string {
|
|
|
93
92
|
return metastring?.match(codeBlockTitleRegex)?.[2] ?? '';
|
|
94
93
|
}
|
|
95
94
|
|
|
96
|
-
export function parseLanguage(className
|
|
95
|
+
export function parseLanguage(className: string): string | undefined {
|
|
97
96
|
const languageClassName = className
|
|
98
|
-
|
|
97
|
+
.split(' ')
|
|
99
98
|
.find((str) => str.startsWith('language-'));
|
|
100
|
-
return languageClassName?.replace(/language-/, '')
|
|
99
|
+
return languageClassName?.replace(/language-/, '');
|
|
101
100
|
}
|
|
102
101
|
|
|
103
102
|
/**
|
|
@@ -107,7 +106,7 @@ export function parseLanguage(className?: string): Language | undefined {
|
|
|
107
106
|
export function parseLines(
|
|
108
107
|
content: string,
|
|
109
108
|
metastring?: string,
|
|
110
|
-
language?:
|
|
109
|
+
language?: string,
|
|
111
110
|
): {
|
|
112
111
|
highlightLines: number[];
|
|
113
112
|
code: string;
|