@docusaurus/theme-common 2.3.0 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/components/Collapsible/index.d.ts.map +1 -1
- package/lib/components/Collapsible/index.js +6 -0
- package/lib/components/Collapsible/index.js.map +1 -1
- package/lib/components/Details/index.d.ts +5 -2
- package/lib/components/Details/index.d.ts.map +1 -1
- package/lib/components/Details/index.js +2 -2
- package/lib/components/Details/index.js.map +1 -1
- package/lib/hooks/useSearchPage.d.ts +8 -18
- package/lib/hooks/useSearchPage.d.ts.map +1 -1
- package/lib/hooks/useSearchPage.js +14 -31
- package/lib/hooks/useSearchPage.js.map +1 -1
- package/lib/index.d.ts +2 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -0
- package/lib/index.js.map +1 -1
- package/lib/internal.d.ts +0 -1
- package/lib/internal.d.ts.map +1 -1
- package/lib/internal.js +0 -1
- package/lib/internal.js.map +1 -1
- package/lib/utils/docsUtils.js +3 -3
- package/lib/utils/docsUtils.js.map +1 -1
- package/lib/utils/errorBoundaryUtils.d.ts +29 -0
- package/lib/utils/errorBoundaryUtils.d.ts.map +1 -0
- package/lib/utils/errorBoundaryUtils.js +41 -0
- package/lib/utils/errorBoundaryUtils.js.map +1 -0
- package/lib/utils/errorBoundaryUtils.module.css +11 -0
- package/lib/utils/historyUtils.d.ts +6 -0
- package/lib/utils/historyUtils.d.ts.map +1 -1
- package/lib/utils/historyUtils.js +28 -2
- package/lib/utils/historyUtils.js.map +1 -1
- package/lib/utils/scrollUtils.d.ts.map +1 -1
- package/lib/utils/scrollUtils.js +4 -1
- package/lib/utils/scrollUtils.js.map +1 -1
- package/lib/utils/storageUtils.d.ts.map +1 -1
- package/lib/utils/storageUtils.js +7 -0
- package/lib/utils/storageUtils.js.map +1 -1
- package/lib/utils/tabsUtils.d.ts +3 -1
- package/lib/utils/tabsUtils.d.ts.map +1 -1
- package/lib/utils/tabsUtils.js +10 -6
- package/lib/utils/tabsUtils.js.map +1 -1
- package/package.json +11 -10
- package/src/components/Collapsible/index.tsx +7 -0
- package/src/components/Details/index.tsx +12 -4
- package/src/hooks/useSearchPage.ts +16 -58
- package/src/index.ts +11 -0
- package/src/internal.ts +0 -1
- package/src/utils/docsUtils.tsx +4 -4
- package/src/utils/errorBoundaryUtils.module.css +11 -0
- package/src/utils/errorBoundaryUtils.tsx +56 -0
- package/src/utils/historyUtils.ts +45 -2
- package/src/utils/scrollUtils.tsx +4 -1
- package/src/utils/storageUtils.ts +7 -0
- package/src/utils/tabsUtils.tsx +14 -8
|
@@ -15,6 +15,13 @@ const DefaultStorageType = 'localStorage';
|
|
|
15
15
|
// see https://stackoverflow.com/a/71177640/82609
|
|
16
16
|
// see https://stackoverflow.com/questions/26974084/listen-for-changes-with-localstorage-on-the-same-window
|
|
17
17
|
function dispatchChangeEvent({ key, oldValue, newValue, storage, }) {
|
|
18
|
+
// If we set multiple times the same storage value, events should not be fired
|
|
19
|
+
// The native events behave this way, so our manual event dispatch should
|
|
20
|
+
// rather behave exactly the same. Not doing so might create infinite loops.
|
|
21
|
+
// See https://github.com/facebook/docusaurus/issues/8594
|
|
22
|
+
if (oldValue === newValue) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
18
25
|
const event = document.createEvent('StorageEvent');
|
|
19
26
|
event.initStorageEvent('storage', false, false, key, oldValue, newValue, window.location.href, storage);
|
|
20
27
|
window.dispatchEvent(event);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storageUtils.js","sourceRoot":"","sources":["../../src/utils/storageUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAC,WAAW,EAAE,MAAM,EAAC,MAAM,OAAO,CAAC;AAC1C,2DAA2D;AAC3D,OAAO,EAAC,oBAAoB,EAAC,MAAM,8BAA8B,CAAC;AAElE,MAAM,YAAY,GAAG,CAAC,cAAc,EAAE,gBAAgB,EAAE,MAAM,CAAU,CAAC;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AAC;IAC1B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,cAAc,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE;QACjD,MAAM,GAAG,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAClC,IAAI,GAAG,KAAK,IAAI,EAAE;YAChB,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;SAChB;KACF;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/lib/utils/tabsUtils.d.ts
CHANGED
|
@@ -17,10 +17,11 @@ export interface TabValue {
|
|
|
17
17
|
};
|
|
18
18
|
readonly default?: boolean;
|
|
19
19
|
}
|
|
20
|
+
declare type TabItem = ReactElement<TabItemProps> | null | false | undefined;
|
|
20
21
|
export interface TabsProps {
|
|
21
22
|
readonly lazy?: boolean;
|
|
22
23
|
readonly block?: boolean;
|
|
23
|
-
readonly children:
|
|
24
|
+
readonly children: TabItem[] | TabItem;
|
|
24
25
|
readonly defaultValue?: string | null;
|
|
25
26
|
readonly values?: readonly TabValue[];
|
|
26
27
|
readonly groupId?: string;
|
|
@@ -43,4 +44,5 @@ export declare function useTabs(props: TabsProps): {
|
|
|
43
44
|
selectValue: (value: string) => void;
|
|
44
45
|
tabValues: readonly TabValue[];
|
|
45
46
|
};
|
|
47
|
+
export {};
|
|
46
48
|
//# sourceMappingURL=tabsUtils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tabsUtils.d.ts","sourceRoot":"","sources":["../../src/utils/tabsUtils.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAc,
|
|
1
|
+
{"version":3,"file":"tabsUtils.d.ts","sourceRoot":"","sources":["../../src/utils/tabsUtils.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAc,EAKZ,KAAK,SAAS,EACd,KAAK,YAAY,EAElB,MAAM,OAAO,CAAC;AAKf;;;GAGG;AACH,MAAM,WAAW,QAA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ChD;AAyKD,wBAAgB,OAAO,CAAC,KAAK,EAAE,SAAS,GAAG;IACzC,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACrC,SAAS,EAAE,SAAS,QAAQ,EAAE,CAAC;CAChC,CA8CA"}
|
package/lib/utils/tabsUtils.js
CHANGED
|
@@ -4,18 +4,20 @@
|
|
|
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, { isValidElement, useCallback,
|
|
7
|
+
import React, { isValidElement, useCallback, useState, useMemo, useLayoutEffect, } from 'react';
|
|
8
8
|
import { useHistory } from '@docusaurus/router';
|
|
9
9
|
import { useQueryStringValue } from '@docusaurus/theme-common/internal';
|
|
10
10
|
import { duplicates, useStorageSlot } from '../index';
|
|
11
11
|
// A very rough duck type, but good enough to guard against mistakes while
|
|
12
12
|
// allowing customization
|
|
13
13
|
function isTabItem(comp) {
|
|
14
|
-
|
|
14
|
+
const { props } = comp;
|
|
15
|
+
return !!props && typeof props === 'object' && 'value' in props;
|
|
15
16
|
}
|
|
16
17
|
function ensureValidChildren(children) {
|
|
17
|
-
return React.Children.map(children, (child) => {
|
|
18
|
-
|
|
18
|
+
return (React.Children.map(children, (child) => {
|
|
19
|
+
// Pass falsy values through: allow conditionally not rendering a tab
|
|
20
|
+
if (!child || (isValidElement(child) && isTabItem(child))) {
|
|
19
21
|
return child;
|
|
20
22
|
}
|
|
21
23
|
// child.type.name will give non-sensical values in prod because of
|
|
@@ -23,7 +25,7 @@ function ensureValidChildren(children) {
|
|
|
23
25
|
throw new Error(`Docusaurus error: Bad <Tabs> child <${
|
|
24
26
|
// @ts-expect-error: guarding against unexpected cases
|
|
25
27
|
typeof child.type === 'string' ? child.type : child.type.name}>: all children of the <Tabs> component should be <TabItem>, and every <TabItem> should have a unique "value" prop.`);
|
|
26
|
-
});
|
|
28
|
+
})?.filter(Boolean) ?? []);
|
|
27
29
|
}
|
|
28
30
|
function extractChildrenTabValues(children) {
|
|
29
31
|
return ensureValidChildren(children).map(({ props: { value, label, attributes, default: isDefault } }) => ({
|
|
@@ -133,7 +135,9 @@ export function useTabs(props) {
|
|
|
133
135
|
}
|
|
134
136
|
return value;
|
|
135
137
|
})();
|
|
136
|
-
|
|
138
|
+
// Sync in a layout/sync effect is important, for useScrollPositionBlocker
|
|
139
|
+
// See https://github.com/facebook/docusaurus/issues/8625
|
|
140
|
+
useLayoutEffect(() => {
|
|
137
141
|
if (valueToSync) {
|
|
138
142
|
setSelectedValue(valueToSync);
|
|
139
143
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tabsUtils.js","sourceRoot":"","sources":["../../src/utils/tabsUtils.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,EACZ,cAAc,EACd,WAAW,EACX,
|
|
1
|
+
{"version":3,"file":"tabsUtils.js","sourceRoot":"","sources":["../../src/utils/tabsUtils.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,EACZ,cAAc,EACd,WAAW,EACX,QAAQ,EACR,OAAO,EAGP,eAAe,GAChB,MAAM,OAAO,CAAC;AACf,OAAO,EAAC,UAAU,EAAC,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAC,mBAAmB,EAAC,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAAC,UAAU,EAAE,cAAc,EAAC,MAAM,UAAU,CAAC;AAoCpD,0EAA0E;AAC1E,yBAAyB;AACzB,SAAS,SAAS,CAChB,IAA2B;IAE3B,MAAM,EAAC,KAAK,EAAC,GAAG,IAAI,CAAC;IACrB,OAAO,CAAC,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,IAAI,KAAK,CAAC;AAClE,CAAC;AAED,SAAS,mBAAmB,CAAC,QAA+B;IAC1D,OAAO,CAAC,KAAK,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AC,KAAK,EAAE,SAAS,EAAC,CAAC,EAAE;YACrC,OAAO,IAAI,CAAC;SACb;QACD,OAAO,KAAK,CAAC;IACf,CAAC,CAAC,EAAE,CAAC;IACL,0EAA0E;IAC1E,yDAAyD;IACzD,eAAe,CAAC,GAAG,EAAE;QACnB,IAAI,WAAW,EAAE;YACf,gBAAgB,CAAC,WAAW,CAAC,CAAC;SAC/B;IACH,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC;IAElB,MAAM,WAAW,GAAG,WAAW,CAC7B,CAAC,QAAgB,EAAE,EAAE;QACnB,IAAI,CAAC,YAAY,CAAC,EAAC,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAC,CAAC,EAAE;YAC/C,MAAM,IAAI,KAAK,CAAC,kCAAkC,QAAQ,EAAE,CAAC,CAAC;SAC/D;QACD,gBAAgB,CAAC,QAAQ,CAAC,CAAC;QAC3B,cAAc,CAAC,QAAQ,CAAC,CAAC;QACzB,eAAe,CAAC,QAAQ,CAAC,CAAC;IAC5B,CAAC,EACD,CAAC,cAAc,EAAE,eAAe,EAAE,SAAS,CAAC,CAC7C,CAAC;IAEF,OAAO,EAAC,aAAa,EAAE,WAAW,EAAE,SAAS,EAAC,CAAC;AACjD,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/theme-common",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.0",
|
|
4
4
|
"description": "Common code for Docusaurus themes.",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"types": "./lib/index.d.ts",
|
|
@@ -30,12 +30,13 @@
|
|
|
30
30
|
},
|
|
31
31
|
"license": "MIT",
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@docusaurus/mdx-loader": "2.
|
|
34
|
-
"@docusaurus/module-type-aliases": "2.
|
|
35
|
-
"@docusaurus/plugin-content-blog": "2.
|
|
36
|
-
"@docusaurus/plugin-content-docs": "2.
|
|
37
|
-
"@docusaurus/plugin-content-pages": "2.
|
|
38
|
-
"@docusaurus/utils": "2.
|
|
33
|
+
"@docusaurus/mdx-loader": "2.4.0",
|
|
34
|
+
"@docusaurus/module-type-aliases": "2.4.0",
|
|
35
|
+
"@docusaurus/plugin-content-blog": "2.4.0",
|
|
36
|
+
"@docusaurus/plugin-content-docs": "2.4.0",
|
|
37
|
+
"@docusaurus/plugin-content-pages": "2.4.0",
|
|
38
|
+
"@docusaurus/utils": "2.4.0",
|
|
39
|
+
"@docusaurus/utils-common": "2.4.0",
|
|
39
40
|
"@types/history": "^4.7.11",
|
|
40
41
|
"@types/react": "*",
|
|
41
42
|
"@types/react-router-config": "*",
|
|
@@ -47,8 +48,8 @@
|
|
|
47
48
|
"utility-types": "^3.10.0"
|
|
48
49
|
},
|
|
49
50
|
"devDependencies": {
|
|
50
|
-
"@docusaurus/core": "2.
|
|
51
|
-
"@docusaurus/types": "2.
|
|
51
|
+
"@docusaurus/core": "2.4.0",
|
|
52
|
+
"@docusaurus/types": "2.4.0",
|
|
52
53
|
"fs-extra": "^10.1.0",
|
|
53
54
|
"lodash": "^4.17.21"
|
|
54
55
|
},
|
|
@@ -59,5 +60,5 @@
|
|
|
59
60
|
"engines": {
|
|
60
61
|
"node": ">=16.14"
|
|
61
62
|
},
|
|
62
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "898b85ef134cc43bf3b1209aad0ca8cdcfb214c5"
|
|
63
64
|
}
|
|
@@ -65,6 +65,10 @@ function applyCollapsedStyle(el: HTMLElement, collapsed: boolean) {
|
|
|
65
65
|
el.style.height = collapsedStyles.height;
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
+
function userPrefersReducedMotion(): boolean {
|
|
69
|
+
return window.matchMedia('(prefers-reduced-motion: reduce)').matches;
|
|
70
|
+
}
|
|
71
|
+
|
|
68
72
|
/*
|
|
69
73
|
Lex111: Dynamic transition duration is used in Material design, this technique
|
|
70
74
|
is good for a large number of items.
|
|
@@ -72,6 +76,9 @@ https://material.io/archive/guidelines/motion/duration-easing.html#duration-easi
|
|
|
72
76
|
https://github.com/mui-org/material-ui/blob/e724d98eba018e55e1a684236a2037e24bcf050c/packages/material-ui/src/styles/createTransitions.js#L40-L43
|
|
73
77
|
*/
|
|
74
78
|
function getAutoHeightDuration(height: number) {
|
|
79
|
+
if (userPrefersReducedMotion()) {
|
|
80
|
+
return 0;
|
|
81
|
+
}
|
|
75
82
|
const constant = height / 36;
|
|
76
83
|
return Math.round((4 + 15 * constant ** 0.25 + constant / 5) * 10);
|
|
77
84
|
}
|
|
@@ -31,8 +31,11 @@ function hasParent(node: HTMLElement | null, parent: HTMLElement): boolean {
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
export type DetailsProps = {
|
|
34
|
-
/**
|
|
35
|
-
|
|
34
|
+
/**
|
|
35
|
+
* Summary is provided as props, optionally including the wrapping
|
|
36
|
+
* `<summary>` tag
|
|
37
|
+
*/
|
|
38
|
+
summary?: ReactElement | string;
|
|
36
39
|
} & ComponentProps<'details'>;
|
|
37
40
|
|
|
38
41
|
/**
|
|
@@ -54,6 +57,12 @@ export function Details({
|
|
|
54
57
|
// only after animation completes, otherwise close animations won't work
|
|
55
58
|
const [open, setOpen] = useState(props.open);
|
|
56
59
|
|
|
60
|
+
const summaryElement = React.isValidElement(summary) ? (
|
|
61
|
+
summary
|
|
62
|
+
) : (
|
|
63
|
+
<summary>{summary ?? 'Details'}</summary>
|
|
64
|
+
);
|
|
65
|
+
|
|
57
66
|
return (
|
|
58
67
|
// eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-noninteractive-element-interactions
|
|
59
68
|
<details
|
|
@@ -91,8 +100,7 @@ export function Details({
|
|
|
91
100
|
// setOpen(false);
|
|
92
101
|
}
|
|
93
102
|
}}>
|
|
94
|
-
{
|
|
95
|
-
{summary ?? <summary>Details</summary>}
|
|
103
|
+
{summaryElement}
|
|
96
104
|
|
|
97
105
|
<Collapsible
|
|
98
106
|
lazy={false} // Content might matter for SEO in this case
|
|
@@ -5,32 +5,24 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import {useCallback
|
|
9
|
-
import {useHistory} from '@docusaurus/router';
|
|
8
|
+
import {useCallback} from 'react';
|
|
10
9
|
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
|
|
10
|
+
import {useQueryString} from '../utils/historyUtils';
|
|
11
11
|
import type {ThemeConfig as AlgoliaThemeConfig} from '@docusaurus/theme-search-algolia';
|
|
12
12
|
|
|
13
13
|
const SEARCH_PARAM_QUERY = 'q';
|
|
14
14
|
|
|
15
|
-
/**
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
setSearchQuery: (newSearchQuery: string) => void;
|
|
27
|
-
/**
|
|
28
|
-
* Given a query, this handle generates the corresponding search page link,
|
|
29
|
-
* with base URL prepended.
|
|
30
|
-
*/
|
|
31
|
-
generateSearchPageLink: (targetSearchQuery: string) => string;
|
|
32
|
-
} {
|
|
33
|
-
const history = useHistory();
|
|
15
|
+
/**
|
|
16
|
+
* Permits to read/write the current search query string
|
|
17
|
+
*/
|
|
18
|
+
export function useSearchQueryString(): [string, (newValue: string) => void] {
|
|
19
|
+
return useQueryString(SEARCH_PARAM_QUERY);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Permits to create links to the search page with the appropriate query string
|
|
24
|
+
*/
|
|
25
|
+
export function useSearchLinkCreator(): (searchValue: string) => string {
|
|
34
26
|
const {
|
|
35
27
|
siteConfig: {baseUrl, themeConfig},
|
|
36
28
|
} = useDocusaurusContext();
|
|
@@ -38,47 +30,13 @@ export function useSearchPage(): {
|
|
|
38
30
|
algolia: {searchPagePath},
|
|
39
31
|
} = themeConfig as AlgoliaThemeConfig;
|
|
40
32
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
// Init search query just after React hydration
|
|
44
|
-
useEffect(() => {
|
|
45
|
-
const searchQueryStringValue =
|
|
46
|
-
new URLSearchParams(window.location.search).get(SEARCH_PARAM_QUERY) ?? '';
|
|
47
|
-
|
|
48
|
-
setSearchQueryState(searchQueryStringValue);
|
|
49
|
-
}, []);
|
|
50
|
-
|
|
51
|
-
const setSearchQuery = useCallback(
|
|
52
|
-
(newSearchQuery: string) => {
|
|
53
|
-
const searchParams = new URLSearchParams(window.location.search);
|
|
54
|
-
|
|
55
|
-
if (newSearchQuery) {
|
|
56
|
-
searchParams.set(SEARCH_PARAM_QUERY, newSearchQuery);
|
|
57
|
-
} else {
|
|
58
|
-
searchParams.delete(SEARCH_PARAM_QUERY);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
history.replace({
|
|
62
|
-
search: searchParams.toString(),
|
|
63
|
-
});
|
|
64
|
-
setSearchQueryState(newSearchQuery);
|
|
65
|
-
},
|
|
66
|
-
[history],
|
|
67
|
-
);
|
|
68
|
-
|
|
69
|
-
const generateSearchPageLink = useCallback(
|
|
70
|
-
(targetSearchQuery: string) =>
|
|
33
|
+
return useCallback(
|
|
34
|
+
(searchValue: string) =>
|
|
71
35
|
// Refer to https://github.com/facebook/docusaurus/pull/2838
|
|
72
36
|
// Note: if searchPagePath is falsy, useSearchPage() will not be called
|
|
73
37
|
`${baseUrl}${
|
|
74
38
|
searchPagePath as string
|
|
75
|
-
}?${SEARCH_PARAM_QUERY}=${encodeURIComponent(
|
|
39
|
+
}?${SEARCH_PARAM_QUERY}=${encodeURIComponent(searchValue)}`,
|
|
76
40
|
[baseUrl, searchPagePath],
|
|
77
41
|
);
|
|
78
|
-
|
|
79
|
-
return {
|
|
80
|
-
searchQuery,
|
|
81
|
-
setSearchQuery,
|
|
82
|
-
generateSearchPageLink,
|
|
83
|
-
};
|
|
84
42
|
}
|
package/src/index.ts
CHANGED
|
@@ -73,6 +73,11 @@ export {
|
|
|
73
73
|
type TagLetterEntry,
|
|
74
74
|
} from './utils/tagsUtils';
|
|
75
75
|
|
|
76
|
+
export {
|
|
77
|
+
useSearchQueryString,
|
|
78
|
+
useSearchLinkCreator,
|
|
79
|
+
} from './hooks/useSearchPage';
|
|
80
|
+
|
|
76
81
|
export {isMultiColumnFooterLinks} from './utils/footerUtils';
|
|
77
82
|
|
|
78
83
|
export {isRegexpStringMatch} from './utils/regexpUtils';
|
|
@@ -89,3 +94,9 @@ export {
|
|
|
89
94
|
SkipToContentFallbackId,
|
|
90
95
|
SkipToContentLink,
|
|
91
96
|
} from './utils/skipToContentUtils';
|
|
97
|
+
|
|
98
|
+
export {
|
|
99
|
+
ErrorBoundaryTryAgainButton,
|
|
100
|
+
ErrorBoundaryError,
|
|
101
|
+
ErrorCauseBoundary,
|
|
102
|
+
} from './utils/errorBoundaryUtils';
|
package/src/internal.ts
CHANGED
|
@@ -117,7 +117,6 @@ export {
|
|
|
117
117
|
keyboardFocusedClassName,
|
|
118
118
|
} from './hooks/useKeyboardNavigation';
|
|
119
119
|
export {useLockBodyScroll} from './hooks/useLockBodyScroll';
|
|
120
|
-
export {useSearchPage} from './hooks/useSearchPage';
|
|
121
120
|
export {useCodeWordWrap} from './hooks/useCodeWordWrap';
|
|
122
121
|
export {getPrismCssVariables} from './utils/codeBlockUtils';
|
|
123
122
|
export {useBackToTopButton} from './hooks/useBackToTopButton';
|
package/src/utils/docsUtils.tsx
CHANGED
|
@@ -271,8 +271,8 @@ export function useLayoutDocsSidebar(
|
|
|
271
271
|
`Can't find any sidebar with id "${sidebarId}" in version${
|
|
272
272
|
versions.length > 1 ? 's' : ''
|
|
273
273
|
} ${versions.map((version) => version.name).join(', ')}".
|
|
274
|
-
|
|
275
|
-
|
|
274
|
+
Available sidebar ids are:
|
|
275
|
+
- ${Object.keys(allSidebars).join('\n- ')}`,
|
|
276
276
|
);
|
|
277
277
|
}
|
|
278
278
|
return sidebarEntry[1];
|
|
@@ -304,9 +304,9 @@ export function useLayoutDoc(
|
|
|
304
304
|
return null;
|
|
305
305
|
}
|
|
306
306
|
throw new Error(
|
|
307
|
-
`
|
|
307
|
+
`Couldn't find any doc with id "${docId}" in version${
|
|
308
308
|
versions.length > 1 ? 's' : ''
|
|
309
|
-
} ${versions.map((version) => version.name).join(', ')}".
|
|
309
|
+
} "${versions.map((version) => version.name).join(', ')}".
|
|
310
310
|
Available doc ids are:
|
|
311
311
|
- ${uniq(allDocs.map((versionDoc) => versionDoc.id)).join('\n- ')}`,
|
|
312
312
|
);
|
|
@@ -0,0 +1,11 @@
|
|
|
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
|
+
.errorBoundaryError {
|
|
9
|
+
white-space: pre-wrap;
|
|
10
|
+
color: red;
|
|
11
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
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 React, {type ComponentProps} from 'react';
|
|
9
|
+
import Translate from '@docusaurus/Translate';
|
|
10
|
+
import {getErrorCausalChain} from '@docusaurus/utils-common';
|
|
11
|
+
import styles from './errorBoundaryUtils.module.css';
|
|
12
|
+
|
|
13
|
+
export function ErrorBoundaryTryAgainButton(
|
|
14
|
+
props: ComponentProps<'button'>,
|
|
15
|
+
): JSX.Element {
|
|
16
|
+
return (
|
|
17
|
+
<button type="button" {...props}>
|
|
18
|
+
<Translate
|
|
19
|
+
id="theme.ErrorPageContent.tryAgain"
|
|
20
|
+
description="The label of the button to try again rendering when the React error boundary captures an error">
|
|
21
|
+
Try again
|
|
22
|
+
</Translate>
|
|
23
|
+
</button>
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
export function ErrorBoundaryError({error}: {error: Error}): JSX.Element {
|
|
27
|
+
const causalChain = getErrorCausalChain(error);
|
|
28
|
+
const fullMessage = causalChain.map((e) => e.message).join('\n\nCause:\n');
|
|
29
|
+
return <p className={styles.errorBoundaryError}>{fullMessage}</p>;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* This component is useful to wrap a low-level error into a more meaningful
|
|
34
|
+
* error with extra context, using the ES error-cause feature.
|
|
35
|
+
*
|
|
36
|
+
* <ErrorCauseBoundary
|
|
37
|
+
* onError={(error) => new Error("extra context message",{cause: error})}
|
|
38
|
+
* >
|
|
39
|
+
* <RiskyComponent>
|
|
40
|
+
* </ErrorCauseBoundary>
|
|
41
|
+
*/
|
|
42
|
+
export class ErrorCauseBoundary extends React.Component<
|
|
43
|
+
{
|
|
44
|
+
children: React.ReactNode;
|
|
45
|
+
onError: (error: Error, errorInfo: React.ErrorInfo) => Error;
|
|
46
|
+
},
|
|
47
|
+
unknown
|
|
48
|
+
> {
|
|
49
|
+
override componentDidCatch(error: Error, errorInfo: React.ErrorInfo): never {
|
|
50
|
+
throw this.props.onError(error, errorInfo);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
override render(): React.ReactNode {
|
|
54
|
+
return this.props.children;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import {useEffect} from 'react';
|
|
8
|
+
import {useCallback, useEffect} from 'react';
|
|
9
9
|
import {useHistory} from '@docusaurus/router';
|
|
10
10
|
// @ts-expect-error: TODO temporary until React 18 upgrade
|
|
11
11
|
import {useSyncExternalStore} from 'use-sync-external-store/shim';
|
|
@@ -56,7 +56,11 @@ export function useHistorySelector<Value>(
|
|
|
56
56
|
selector: (history: History<unknown>) => Value,
|
|
57
57
|
): Value {
|
|
58
58
|
const history = useHistory();
|
|
59
|
-
return useSyncExternalStore(
|
|
59
|
+
return useSyncExternalStore(
|
|
60
|
+
history.listen,
|
|
61
|
+
() => selector(history),
|
|
62
|
+
() => selector(history),
|
|
63
|
+
);
|
|
60
64
|
}
|
|
61
65
|
|
|
62
66
|
/**
|
|
@@ -71,3 +75,42 @@ export function useQueryStringValue(key: string | null): string | null {
|
|
|
71
75
|
return new URLSearchParams(history.location.search).get(key);
|
|
72
76
|
});
|
|
73
77
|
}
|
|
78
|
+
|
|
79
|
+
export function useQueryStringKeySetter(): (
|
|
80
|
+
key: string,
|
|
81
|
+
newValue: string | null,
|
|
82
|
+
options?: {push: boolean},
|
|
83
|
+
) => void {
|
|
84
|
+
const history = useHistory();
|
|
85
|
+
return useCallback(
|
|
86
|
+
(key, newValue, options) => {
|
|
87
|
+
const searchParams = new URLSearchParams(history.location.search);
|
|
88
|
+
if (newValue) {
|
|
89
|
+
searchParams.set(key, newValue);
|
|
90
|
+
} else {
|
|
91
|
+
searchParams.delete(key);
|
|
92
|
+
}
|
|
93
|
+
const updaterFn = options?.push ? history.push : history.replace;
|
|
94
|
+
updaterFn({
|
|
95
|
+
search: searchParams.toString(),
|
|
96
|
+
});
|
|
97
|
+
},
|
|
98
|
+
[history],
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export function useQueryString(
|
|
103
|
+
key: string,
|
|
104
|
+
): [string, (newValue: string, options?: {push: boolean}) => void] {
|
|
105
|
+
const value = useQueryStringValue(key) ?? '';
|
|
106
|
+
const setQueryString = useQueryStringKeySetter();
|
|
107
|
+
return [
|
|
108
|
+
value,
|
|
109
|
+
useCallback(
|
|
110
|
+
(newValue: string, options) => {
|
|
111
|
+
setQueryString(key, newValue, options);
|
|
112
|
+
},
|
|
113
|
+
[setQueryString, key],
|
|
114
|
+
),
|
|
115
|
+
];
|
|
116
|
+
}
|
|
@@ -222,7 +222,10 @@ export function useScrollPositionBlocker(): {
|
|
|
222
222
|
);
|
|
223
223
|
|
|
224
224
|
useLayoutEffect(() => {
|
|
225
|
-
|
|
225
|
+
// Queuing permits to restore scroll position after all useLayoutEffect
|
|
226
|
+
// have run, and yet preserve the sync nature of the scroll restoration
|
|
227
|
+
// See https://github.com/facebook/docusaurus/issues/8625
|
|
228
|
+
queueMicrotask(() => nextLayoutEffectCallbackRef.current?.());
|
|
226
229
|
});
|
|
227
230
|
|
|
228
231
|
return {
|
|
@@ -31,6 +31,13 @@ function dispatchChangeEvent({
|
|
|
31
31
|
newValue: string | null;
|
|
32
32
|
storage: Storage;
|
|
33
33
|
}) {
|
|
34
|
+
// If we set multiple times the same storage value, events should not be fired
|
|
35
|
+
// The native events behave this way, so our manual event dispatch should
|
|
36
|
+
// rather behave exactly the same. Not doing so might create infinite loops.
|
|
37
|
+
// See https://github.com/facebook/docusaurus/issues/8594
|
|
38
|
+
if (oldValue === newValue) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
34
41
|
const event = document.createEvent('StorageEvent');
|
|
35
42
|
event.initStorageEvent(
|
|
36
43
|
'storage',
|
package/src/utils/tabsUtils.tsx
CHANGED
|
@@ -8,11 +8,11 @@
|
|
|
8
8
|
import React, {
|
|
9
9
|
isValidElement,
|
|
10
10
|
useCallback,
|
|
11
|
-
useEffect,
|
|
12
11
|
useState,
|
|
13
12
|
useMemo,
|
|
14
13
|
type ReactNode,
|
|
15
14
|
type ReactElement,
|
|
15
|
+
useLayoutEffect,
|
|
16
16
|
} from 'react';
|
|
17
17
|
import {useHistory} from '@docusaurus/router';
|
|
18
18
|
import {useQueryStringValue} from '@docusaurus/theme-common/internal';
|
|
@@ -29,10 +29,12 @@ export interface TabValue {
|
|
|
29
29
|
readonly default?: boolean;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
+
type TabItem = ReactElement<TabItemProps> | null | false | undefined;
|
|
33
|
+
|
|
32
34
|
export interface TabsProps {
|
|
33
35
|
readonly lazy?: boolean;
|
|
34
36
|
readonly block?: boolean;
|
|
35
|
-
readonly children:
|
|
37
|
+
readonly children: TabItem[] | TabItem;
|
|
36
38
|
readonly defaultValue?: string | null;
|
|
37
39
|
readonly values?: readonly TabValue[];
|
|
38
40
|
readonly groupId?: string;
|
|
@@ -53,14 +55,16 @@ export interface TabItemProps {
|
|
|
53
55
|
// A very rough duck type, but good enough to guard against mistakes while
|
|
54
56
|
// allowing customization
|
|
55
57
|
function isTabItem(
|
|
56
|
-
comp: ReactElement<
|
|
58
|
+
comp: ReactElement<unknown>,
|
|
57
59
|
): comp is ReactElement<TabItemProps> {
|
|
58
|
-
|
|
60
|
+
const {props} = comp;
|
|
61
|
+
return !!props && typeof props === 'object' && 'value' in props;
|
|
59
62
|
}
|
|
60
63
|
|
|
61
64
|
function ensureValidChildren(children: TabsProps['children']) {
|
|
62
|
-
return React.Children.map(children, (child) => {
|
|
63
|
-
|
|
65
|
+
return (React.Children.map(children, (child) => {
|
|
66
|
+
// Pass falsy values through: allow conditionally not rendering a tab
|
|
67
|
+
if (!child || (isValidElement(child) && isTabItem(child))) {
|
|
64
68
|
return child;
|
|
65
69
|
}
|
|
66
70
|
// child.type.name will give non-sensical values in prod because of
|
|
@@ -71,7 +75,7 @@ function ensureValidChildren(children: TabsProps['children']) {
|
|
|
71
75
|
typeof child.type === 'string' ? child.type : child.type.name
|
|
72
76
|
}>: all children of the <Tabs> component should be <TabItem>, and every <TabItem> should have a unique "value" prop.`,
|
|
73
77
|
);
|
|
74
|
-
});
|
|
78
|
+
})?.filter(Boolean) ?? []) as ReactElement<TabItemProps>[];
|
|
75
79
|
}
|
|
76
80
|
|
|
77
81
|
function extractChildrenTabValues(children: TabsProps['children']): TabValue[] {
|
|
@@ -244,7 +248,9 @@ export function useTabs(props: TabsProps): {
|
|
|
244
248
|
}
|
|
245
249
|
return value;
|
|
246
250
|
})();
|
|
247
|
-
|
|
251
|
+
// Sync in a layout/sync effect is important, for useScrollPositionBlocker
|
|
252
|
+
// See https://github.com/facebook/docusaurus/issues/8625
|
|
253
|
+
useLayoutEffect(() => {
|
|
248
254
|
if (valueToSync) {
|
|
249
255
|
setSelectedValue(valueToSync);
|
|
250
256
|
}
|