@docusaurus/theme-common 2.0.0-beta.17 → 2.0.0-beta.18

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.
Files changed (254) hide show
  1. package/lib/components/Collapsible/index.d.ts +32 -4
  2. package/lib/components/Collapsible/index.d.ts.map +1 -1
  3. package/lib/components/Collapsible/index.js +12 -3
  4. package/lib/components/Collapsible/index.js.map +1 -1
  5. package/lib/components/Details/index.d.ts +6 -1
  6. package/lib/components/Details/index.d.ts.map +1 -1
  7. package/lib/components/Details/index.js +8 -4
  8. package/lib/components/Details/index.js.map +1 -1
  9. package/lib/{utils/announcementBarUtils.d.ts → contexts/announcementBar.d.ts} +7 -3
  10. package/lib/contexts/announcementBar.d.ts.map +1 -0
  11. package/lib/{utils/announcementBarUtils.js → contexts/announcementBar.js} +11 -11
  12. package/lib/contexts/announcementBar.js.map +1 -0
  13. package/lib/{utils/colorModeUtils.d.ts → contexts/colorMode.d.ts} +12 -3
  14. package/lib/contexts/colorMode.d.ts.map +1 -0
  15. package/lib/contexts/colorMode.js +114 -0
  16. package/lib/contexts/colorMode.js.map +1 -0
  17. package/lib/contexts/docSidebarItemsExpandedState.d.ts +31 -0
  18. package/lib/contexts/docSidebarItemsExpandedState.d.ts.map +1 -0
  19. package/lib/{utils → contexts}/docSidebarItemsExpandedState.js +9 -4
  20. package/lib/contexts/docSidebarItemsExpandedState.js.map +1 -0
  21. package/lib/contexts/docsPreferredVersion.d.ts +28 -0
  22. package/lib/contexts/docsPreferredVersion.d.ts.map +1 -0
  23. package/lib/contexts/docsPreferredVersion.js +125 -0
  24. package/lib/contexts/docsPreferredVersion.js.map +1 -0
  25. package/lib/contexts/docsSidebar.d.ts +20 -0
  26. package/lib/contexts/docsSidebar.d.ts.map +1 -0
  27. package/lib/contexts/docsSidebar.js +29 -0
  28. package/lib/contexts/docsSidebar.js.map +1 -0
  29. package/lib/contexts/docsVersion.d.ts +20 -0
  30. package/lib/contexts/docsVersion.d.ts.map +1 -0
  31. package/lib/contexts/docsVersion.js +26 -0
  32. package/lib/contexts/docsVersion.js.map +1 -0
  33. package/lib/contexts/navbarMobileSidebar.d.ts +31 -0
  34. package/lib/contexts/navbarMobileSidebar.d.ts.map +1 -0
  35. package/lib/contexts/navbarMobileSidebar.js +56 -0
  36. package/lib/contexts/navbarMobileSidebar.js.map +1 -0
  37. package/lib/contexts/navbarSecondaryMenu.d.ts +38 -0
  38. package/lib/contexts/navbarSecondaryMenu.d.ts.map +1 -0
  39. package/lib/contexts/navbarSecondaryMenu.js +93 -0
  40. package/lib/contexts/navbarSecondaryMenu.js.map +1 -0
  41. package/lib/{utils/tabGroupChoiceUtils.d.ts → contexts/tabGroupChoice.d.ts} +5 -3
  42. package/lib/contexts/tabGroupChoice.d.ts.map +1 -0
  43. package/lib/{utils/tabGroupChoiceUtils.js → contexts/tabGroupChoice.js} +14 -20
  44. package/lib/contexts/tabGroupChoice.js.map +1 -0
  45. package/lib/hooks/useHideableNavbar.d.ts +7 -3
  46. package/lib/hooks/useHideableNavbar.d.ts.map +1 -1
  47. package/lib/hooks/useHideableNavbar.js +8 -6
  48. package/lib/hooks/useHideableNavbar.js.map +1 -1
  49. package/lib/hooks/useKeyboardNavigation.d.ts +11 -1
  50. package/lib/hooks/useKeyboardNavigation.d.ts.map +1 -1
  51. package/lib/hooks/useKeyboardNavigation.js +11 -3
  52. package/lib/hooks/useKeyboardNavigation.js.map +1 -1
  53. package/lib/hooks/useLockBodyScroll.d.ts +5 -1
  54. package/lib/hooks/useLockBodyScroll.d.ts.map +1 -1
  55. package/lib/hooks/useLockBodyScroll.js +5 -1
  56. package/lib/hooks/useLockBodyScroll.js.map +1 -1
  57. package/lib/hooks/usePrismTheme.d.ts +5 -1
  58. package/lib/hooks/usePrismTheme.d.ts.map +1 -1
  59. package/lib/hooks/usePrismTheme.js +8 -4
  60. package/lib/hooks/usePrismTheme.js.map +1 -1
  61. package/lib/hooks/useSearchPage.d.ts +15 -4
  62. package/lib/hooks/useSearchPage.d.ts.map +1 -1
  63. package/lib/hooks/useSearchPage.js +3 -2
  64. package/lib/hooks/useSearchPage.js.map +1 -1
  65. package/lib/hooks/useTOCHighlight.d.ts +25 -0
  66. package/lib/hooks/useTOCHighlight.d.ts.map +1 -0
  67. package/lib/{utils → hooks}/useTOCHighlight.js +13 -9
  68. package/lib/hooks/useTOCHighlight.js.map +1 -0
  69. package/lib/hooks/useWindowSize.d.ts +14 -1
  70. package/lib/hooks/useWindowSize.d.ts.map +1 -1
  71. package/lib/hooks/useWindowSize.js +14 -11
  72. package/lib/hooks/useWindowSize.js.map +1 -1
  73. package/lib/index.d.ts +26 -30
  74. package/lib/index.d.ts.map +1 -1
  75. package/lib/index.js +26 -24
  76. package/lib/index.js.map +1 -1
  77. package/lib/utils/ThemeClassNames.d.ts +7 -0
  78. package/lib/utils/ThemeClassNames.d.ts.map +1 -1
  79. package/lib/utils/ThemeClassNames.js +7 -4
  80. package/lib/utils/ThemeClassNames.js.map +1 -1
  81. package/lib/utils/codeBlockUtils.d.ts +25 -2
  82. package/lib/utils/codeBlockUtils.d.ts.map +1 -1
  83. package/lib/utils/codeBlockUtils.js +36 -35
  84. package/lib/utils/codeBlockUtils.js.map +1 -1
  85. package/lib/utils/docsUtils.d.ts +25 -18
  86. package/lib/utils/docsUtils.d.ts.map +1 -1
  87. package/lib/utils/docsUtils.js +38 -56
  88. package/lib/utils/docsUtils.js.map +1 -1
  89. package/lib/utils/footerUtils.d.ts +13 -0
  90. package/lib/utils/footerUtils.d.ts.map +1 -0
  91. package/lib/utils/footerUtils.js +14 -0
  92. package/lib/utils/footerUtils.js.map +1 -0
  93. package/lib/utils/generalUtils.d.ts +4 -1
  94. package/lib/utils/generalUtils.d.ts.map +1 -1
  95. package/lib/utils/generalUtils.js +6 -3
  96. package/lib/utils/generalUtils.js.map +1 -1
  97. package/lib/utils/historyUtils.d.ts +1 -7
  98. package/lib/utils/historyUtils.d.ts.map +1 -1
  99. package/lib/utils/historyUtils.js +10 -13
  100. package/lib/utils/historyUtils.js.map +1 -1
  101. package/lib/utils/jsUtils.d.ts +1 -1
  102. package/lib/utils/jsUtils.js +1 -1
  103. package/lib/utils/metadataUtils.d.ts +38 -0
  104. package/lib/utils/metadataUtils.d.ts.map +1 -0
  105. package/lib/utils/metadataUtils.js +61 -0
  106. package/lib/utils/metadataUtils.js.map +1 -0
  107. package/lib/utils/navbarUtils.d.ts +21 -0
  108. package/lib/utils/navbarUtils.d.ts.map +1 -0
  109. package/lib/utils/navbarUtils.js +30 -0
  110. package/lib/utils/navbarUtils.js.map +1 -0
  111. package/lib/utils/reactUtils.d.ts +16 -5
  112. package/lib/utils/reactUtils.d.ts.map +1 -1
  113. package/lib/utils/reactUtils.js +28 -7
  114. package/lib/utils/reactUtils.js.map +1 -1
  115. package/lib/utils/regexpUtils.d.ts +2 -1
  116. package/lib/utils/regexpUtils.d.ts.map +1 -1
  117. package/lib/utils/regexpUtils.js +2 -1
  118. package/lib/utils/regexpUtils.js.map +1 -1
  119. package/lib/utils/routesUtils.d.ts +14 -2
  120. package/lib/utils/routesUtils.d.ts.map +1 -1
  121. package/lib/utils/routesUtils.js +20 -7
  122. package/lib/utils/routesUtils.js.map +1 -1
  123. package/lib/utils/scrollUtils.d.ts +32 -26
  124. package/lib/utils/scrollUtils.d.ts.map +1 -1
  125. package/lib/utils/scrollUtils.js +30 -17
  126. package/lib/utils/scrollUtils.js.map +1 -1
  127. package/lib/utils/searchUtils.d.ts +12 -0
  128. package/lib/utils/searchUtils.d.ts.map +1 -1
  129. package/lib/utils/searchUtils.js +34 -0
  130. package/lib/utils/searchUtils.js.map +1 -1
  131. package/lib/utils/storageUtils.d.ts +10 -7
  132. package/lib/utils/storageUtils.d.ts.map +1 -1
  133. package/lib/utils/storageUtils.js +20 -12
  134. package/lib/utils/storageUtils.js.map +1 -1
  135. package/lib/utils/tagsUtils.d.ts +5 -2
  136. package/lib/utils/tagsUtils.d.ts.map +1 -1
  137. package/lib/utils/tagsUtils.js +7 -4
  138. package/lib/utils/tagsUtils.js.map +1 -1
  139. package/lib/utils/tocUtils.d.ts +16 -0
  140. package/lib/utils/tocUtils.d.ts.map +1 -1
  141. package/lib/utils/tocUtils.js +17 -6
  142. package/lib/utils/tocUtils.js.map +1 -1
  143. package/lib/utils/useAlternatePageUtils.d.ts +20 -1
  144. package/lib/utils/useAlternatePageUtils.d.ts.map +1 -1
  145. package/lib/utils/useAlternatePageUtils.js +6 -3
  146. package/lib/utils/useAlternatePageUtils.js.map +1 -1
  147. package/lib/utils/useLocalPathname.d.ts +5 -0
  148. package/lib/utils/useLocalPathname.d.ts.map +1 -1
  149. package/lib/utils/useLocalPathname.js +6 -4
  150. package/lib/utils/useLocalPathname.js.map +1 -1
  151. package/lib/utils/useLocationChange.d.ts +7 -5
  152. package/lib/utils/useLocationChange.d.ts.map +1 -1
  153. package/lib/utils/useLocationChange.js +6 -2
  154. package/lib/utils/useLocationChange.js.map +1 -1
  155. package/lib/utils/usePluralForm.d.ts +11 -0
  156. package/lib/utils/usePluralForm.d.ts.map +1 -1
  157. package/lib/utils/usePluralForm.js +19 -24
  158. package/lib/utils/usePluralForm.js.map +1 -1
  159. package/lib/utils/useThemeConfig.d.ts +21 -11
  160. package/lib/utils/useThemeConfig.d.ts.map +1 -1
  161. package/lib/utils/useThemeConfig.js +3 -0
  162. package/lib/utils/useThemeConfig.js.map +1 -1
  163. package/package.json +8 -9
  164. package/src/components/Collapsible/index.tsx +40 -22
  165. package/src/components/Details/index.tsx +11 -6
  166. package/src/{utils/announcementBarUtils.tsx → contexts/announcementBar.tsx} +17 -18
  167. package/src/contexts/colorMode.tsx +176 -0
  168. package/src/contexts/docSidebarItemsExpandedState.tsx +55 -0
  169. package/src/contexts/docsPreferredVersion.tsx +250 -0
  170. package/src/contexts/docsSidebar.tsx +42 -0
  171. package/src/contexts/docsVersion.tsx +36 -0
  172. package/src/contexts/navbarMobileSidebar.tsx +99 -0
  173. package/src/contexts/navbarSecondaryMenu.tsx +170 -0
  174. package/src/{utils/tabGroupChoiceUtils.tsx → contexts/tabGroupChoice.tsx} +21 -28
  175. package/src/hooks/useHideableNavbar.ts +11 -11
  176. package/src/hooks/useKeyboardNavigation.ts +11 -3
  177. package/src/hooks/useLockBodyScroll.ts +5 -2
  178. package/src/hooks/usePrismTheme.ts +8 -4
  179. package/src/hooks/useSearchPage.ts +18 -5
  180. package/src/{utils → hooks}/useTOCHighlight.ts +21 -12
  181. package/src/hooks/useWindowSize.ts +14 -12
  182. package/src/index.ts +68 -56
  183. package/src/utils/ThemeClassNames.ts +10 -6
  184. package/src/utils/codeBlockUtils.ts +49 -47
  185. package/src/utils/docsUtils.tsx +48 -99
  186. package/src/utils/footerUtils.ts +18 -0
  187. package/src/utils/generalUtils.ts +6 -3
  188. package/src/utils/historyUtils.ts +11 -17
  189. package/src/utils/jsUtils.ts +1 -1
  190. package/src/utils/metadataUtils.tsx +115 -0
  191. package/src/utils/navbarUtils.tsx +40 -0
  192. package/src/utils/reactUtils.tsx +31 -8
  193. package/src/utils/regexpUtils.ts +2 -1
  194. package/src/utils/routesUtils.ts +27 -8
  195. package/src/utils/scrollUtils.tsx +44 -45
  196. package/src/utils/searchUtils.ts +49 -0
  197. package/src/utils/storageUtils.ts +21 -13
  198. package/src/utils/tagsUtils.ts +14 -7
  199. package/src/utils/tocUtils.ts +18 -7
  200. package/src/utils/useAlternatePageUtils.ts +17 -5
  201. package/src/utils/useLocalPathname.ts +6 -4
  202. package/src/utils/useLocationChange.ts +12 -10
  203. package/src/utils/usePluralForm.ts +27 -24
  204. package/src/utils/useThemeConfig.ts +16 -11
  205. package/lib/utils/announcementBarUtils.d.ts.map +0 -1
  206. package/lib/utils/announcementBarUtils.js.map +0 -1
  207. package/lib/utils/colorModeUtils.d.ts.map +0 -1
  208. package/lib/utils/colorModeUtils.js +0 -107
  209. package/lib/utils/colorModeUtils.js.map +0 -1
  210. package/lib/utils/docSidebarItemsExpandedState.d.ts +0 -17
  211. package/lib/utils/docSidebarItemsExpandedState.d.ts.map +0 -1
  212. package/lib/utils/docSidebarItemsExpandedState.js.map +0 -1
  213. package/lib/utils/docsPreferredVersion/DocsPreferredVersionProvider.d.ts +0 -22
  214. package/lib/utils/docsPreferredVersion/DocsPreferredVersionProvider.d.ts.map +0 -1
  215. package/lib/utils/docsPreferredVersion/DocsPreferredVersionProvider.js +0 -92
  216. package/lib/utils/docsPreferredVersion/DocsPreferredVersionProvider.js.map +0 -1
  217. package/lib/utils/docsPreferredVersion/DocsPreferredVersionStorage.d.ts +0 -14
  218. package/lib/utils/docsPreferredVersion/DocsPreferredVersionStorage.d.ts.map +0 -1
  219. package/lib/utils/docsPreferredVersion/DocsPreferredVersionStorage.js +0 -19
  220. package/lib/utils/docsPreferredVersion/DocsPreferredVersionStorage.js.map +0 -1
  221. package/lib/utils/docsPreferredVersion/useDocsPreferredVersion.d.ts +0 -14
  222. package/lib/utils/docsPreferredVersion/useDocsPreferredVersion.d.ts.map +0 -1
  223. package/lib/utils/docsPreferredVersion/useDocsPreferredVersion.js +0 -41
  224. package/lib/utils/docsPreferredVersion/useDocsPreferredVersion.js.map +0 -1
  225. package/lib/utils/mobileSecondaryMenu.d.ts +0 -21
  226. package/lib/utils/mobileSecondaryMenu.d.ts.map +0 -1
  227. package/lib/utils/mobileSecondaryMenu.js +0 -51
  228. package/lib/utils/mobileSecondaryMenu.js.map +0 -1
  229. package/lib/utils/pathUtils.d.ts +0 -8
  230. package/lib/utils/pathUtils.d.ts.map +0 -1
  231. package/lib/utils/pathUtils.js +0 -14
  232. package/lib/utils/pathUtils.js.map +0 -1
  233. package/lib/utils/tabGroupChoiceUtils.d.ts.map +0 -1
  234. package/lib/utils/tabGroupChoiceUtils.js.map +0 -1
  235. package/lib/utils/useContextualSearchFilters.d.ts +0 -12
  236. package/lib/utils/useContextualSearchFilters.d.ts.map +0 -1
  237. package/lib/utils/useContextualSearchFilters.js +0 -36
  238. package/lib/utils/useContextualSearchFilters.js.map +0 -1
  239. package/lib/utils/usePrevious.d.ts +0 -8
  240. package/lib/utils/usePrevious.d.ts.map +0 -1
  241. package/lib/utils/usePrevious.js +0 -16
  242. package/lib/utils/usePrevious.js.map +0 -1
  243. package/lib/utils/useTOCHighlight.d.ts +0 -14
  244. package/lib/utils/useTOCHighlight.d.ts.map +0 -1
  245. package/lib/utils/useTOCHighlight.js.map +0 -1
  246. package/src/utils/colorModeUtils.tsx +0 -158
  247. package/src/utils/docSidebarItemsExpandedState.tsx +0 -40
  248. package/src/utils/docsPreferredVersion/DocsPreferredVersionProvider.tsx +0 -166
  249. package/src/utils/docsPreferredVersion/DocsPreferredVersionStorage.ts +0 -33
  250. package/src/utils/docsPreferredVersion/useDocsPreferredVersion.ts +0 -70
  251. package/src/utils/mobileSecondaryMenu.tsx +0 -114
  252. package/src/utils/pathUtils.ts +0 -19
  253. package/src/utils/useContextualSearchFilters.ts +0 -53
  254. package/src/utils/usePrevious.ts +0 -19
@@ -1 +0,0 @@
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,EAAC,MAAM,kBAAkB,CAAC;AAEhD;;;GAGG;AAEH,+EAA+E;AAC/E,0DAA0D;AAC1D,SAAS,4BAA4B,CAAC,OAAoB;IACxD,MAAM,IAAI,GAAG,OAAO,CAAC,qBAAqB,EAAE,CAAC;IAC7C,MAAM,WAAW,GAAG,IAAI,CAAC,GAAG,KAAK,IAAI,CAAC,MAAM,CAAC;IAC7C,IAAI,WAAW,EAAE;QACf,OAAO,4BAA4B,CAAC,OAAO,CAAC,UAAyB,CAAC,CAAC;KACxE;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;GAGG;AACH,SAAS,mBAAmB,CAAC,YAAqB;IAChD,OAAO,YAAY,CAAC,GAAG,GAAG,CAAC,IAAI,YAAY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AQ,CAAC,mBAAmB,CAAC,QAAQ,EAAE,gBAAgB,CAAC,CAAC;QAC3D,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC,CAAC;AACnC,CAAC"}
@@ -1,158 +0,0 @@
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, {
9
- useState,
10
- useCallback,
11
- useEffect,
12
- useContext,
13
- useMemo,
14
- type ReactNode,
15
- } from 'react';
16
- import {ReactContextError} from './reactUtils';
17
-
18
- import ExecutionEnvironment from '@docusaurus/ExecutionEnvironment';
19
- import {createStorageSlot} from './storageUtils';
20
- import {useThemeConfig} from './useThemeConfig';
21
-
22
- type ColorModeContextValue = {
23
- readonly isDarkTheme: boolean;
24
- readonly setLightTheme: () => void;
25
- readonly setDarkTheme: () => void;
26
- };
27
-
28
- const ThemeStorageKey = 'theme';
29
- const ThemeStorage = createStorageSlot(ThemeStorageKey);
30
-
31
- const themes = {
32
- light: 'light',
33
- dark: 'dark',
34
- } as const;
35
-
36
- type Themes = typeof themes[keyof typeof themes];
37
-
38
- // Ensure to always return a valid theme even if input is invalid
39
- const coerceToTheme = (theme?: string | null): Themes =>
40
- theme === themes.dark ? themes.dark : themes.light;
41
-
42
- const getInitialTheme = (defaultMode: Themes | undefined): Themes => {
43
- if (!ExecutionEnvironment.canUseDOM) {
44
- return coerceToTheme(defaultMode);
45
- }
46
- return coerceToTheme(document.documentElement.getAttribute('data-theme'));
47
- };
48
-
49
- const storeTheme = (newTheme: Themes) => {
50
- ThemeStorage.set(coerceToTheme(newTheme));
51
- };
52
-
53
- function useColorModeContextValue(): ColorModeContextValue {
54
- const {
55
- colorMode: {defaultMode, disableSwitch, respectPrefersColorScheme},
56
- } = useThemeConfig();
57
- const [theme, setTheme] = useState(getInitialTheme(defaultMode));
58
-
59
- const setLightTheme = useCallback(() => {
60
- setTheme(themes.light);
61
- storeTheme(themes.light);
62
- }, []);
63
- const setDarkTheme = useCallback(() => {
64
- setTheme(themes.dark);
65
- storeTheme(themes.dark);
66
- }, []);
67
-
68
- useEffect(() => {
69
- document.documentElement.setAttribute('data-theme', coerceToTheme(theme));
70
- }, [theme]);
71
-
72
- useEffect(() => {
73
- if (disableSwitch) {
74
- return undefined;
75
- }
76
- const onChange = (e: StorageEvent) => {
77
- if (e.key !== ThemeStorageKey) {
78
- return;
79
- }
80
- try {
81
- const storedTheme = ThemeStorage.get();
82
- if (storedTheme !== null) {
83
- setTheme(coerceToTheme(storedTheme));
84
- }
85
- } catch (err) {
86
- console.error(err);
87
- }
88
- };
89
- window.addEventListener('storage', onChange);
90
- return () => {
91
- window.removeEventListener('storage', onChange);
92
- };
93
- }, [disableSwitch, setTheme]);
94
-
95
- // PCS is coerced to light mode when printing, which causes the color mode to
96
- // be reset to dark when exiting print mode, disregarding user settings. When
97
- // the listener fires only because of a print/screen switch, we don't change
98
- // color mode. See https://github.com/facebook/docusaurus/pull/6490
99
- const previousMediaIsPrint = React.useRef(false);
100
-
101
- useEffect(() => {
102
- if (disableSwitch && !respectPrefersColorScheme) {
103
- return undefined;
104
- }
105
- const mql = window.matchMedia('(prefers-color-scheme: dark)');
106
- const onChange = ({matches}: MediaQueryListEvent) => {
107
- if (window.matchMedia('print').matches || previousMediaIsPrint.current) {
108
- previousMediaIsPrint.current = window.matchMedia('print').matches;
109
- return;
110
- }
111
- setTheme(matches ? themes.dark : themes.light);
112
- };
113
- mql.addListener(onChange);
114
- return () => {
115
- mql.removeListener(onChange);
116
- };
117
- }, [disableSwitch, respectPrefersColorScheme]);
118
-
119
- return {
120
- isDarkTheme: theme === themes.dark,
121
- setLightTheme,
122
- setDarkTheme,
123
- };
124
- }
125
-
126
- const ColorModeContext = React.createContext<ColorModeContextValue | undefined>(
127
- undefined,
128
- );
129
-
130
- export function ColorModeProvider({
131
- children,
132
- }: {
133
- children: ReactNode;
134
- }): JSX.Element {
135
- const {isDarkTheme, setLightTheme, setDarkTheme} = useColorModeContextValue();
136
- const contextValue = useMemo(
137
- () => ({isDarkTheme, setLightTheme, setDarkTheme}),
138
- [isDarkTheme, setLightTheme, setDarkTheme],
139
- );
140
- return (
141
- <ColorModeContext.Provider value={contextValue}>
142
- {children}
143
- </ColorModeContext.Provider>
144
- );
145
- }
146
-
147
- export function useColorMode(): ColorModeContextValue {
148
- const context = useContext<ColorModeContextValue | undefined>(
149
- ColorModeContext,
150
- );
151
- if (context == null) {
152
- throw new ReactContextError(
153
- 'ColorModeProvider',
154
- 'Please see https://docusaurus.io/docs/api/themes/configuration#use-color-mode.',
155
- );
156
- }
157
- return context;
158
- }
@@ -1,40 +0,0 @@
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 ReactNode, useMemo, useState, useContext} from 'react';
9
- import {ReactContextError} from './reactUtils';
10
-
11
- const EmptyContext: unique symbol = Symbol('EmptyContext');
12
- const Context = React.createContext<
13
- DocSidebarItemsExpandedState | typeof EmptyContext
14
- >(EmptyContext);
15
- type DocSidebarItemsExpandedState = {
16
- expandedItem: number | null;
17
- setExpandedItem: (a: number | null) => void;
18
- };
19
-
20
- export function DocSidebarItemsExpandedStateProvider({
21
- children,
22
- }: {
23
- children: ReactNode;
24
- }): JSX.Element {
25
- const [expandedItem, setExpandedItem] = useState<number | null>(null);
26
- const contextValue = useMemo(
27
- () => ({expandedItem, setExpandedItem}),
28
- [expandedItem],
29
- );
30
-
31
- return <Context.Provider value={contextValue}>{children}</Context.Provider>;
32
- }
33
-
34
- export function useDocSidebarItemsExpandedState(): DocSidebarItemsExpandedState {
35
- const contextValue = useContext(Context);
36
- if (contextValue === EmptyContext) {
37
- throw new ReactContextError('DocSidebarItemsExpandedStateProvider');
38
- }
39
- return contextValue;
40
- }
@@ -1,166 +0,0 @@
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, {
9
- createContext,
10
- type ReactNode,
11
- useContext,
12
- useEffect,
13
- useMemo,
14
- useState,
15
- } from 'react';
16
- import {useThemeConfig, type DocsVersionPersistence} from '../useThemeConfig';
17
- import {isDocsPluginEnabled} from '../docsUtils';
18
- import {ReactContextError} from '../reactUtils';
19
-
20
- import {
21
- useAllDocsData,
22
- type GlobalPluginData,
23
- } from '@docusaurus/plugin-content-docs/client';
24
-
25
- import DocsPreferredVersionStorage from './DocsPreferredVersionStorage';
26
-
27
- type DocsPreferredVersionName = string | null;
28
-
29
- // State for a single docs plugin instance
30
- type DocsPreferredVersionPluginState = {
31
- preferredVersionName: DocsPreferredVersionName;
32
- };
33
-
34
- // We need to store in state/storage globally
35
- // one preferred version per docs plugin instance
36
- // pluginId => pluginState
37
- type DocsPreferredVersionState = Record<
38
- string,
39
- DocsPreferredVersionPluginState
40
- >;
41
-
42
- // Initial state is always null as we can't read local storage from node SSR
43
- function getInitialState(pluginIds: string[]): DocsPreferredVersionState {
44
- const initialState: DocsPreferredVersionState = {};
45
- pluginIds.forEach((pluginId) => {
46
- initialState[pluginId] = {
47
- preferredVersionName: null,
48
- };
49
- });
50
- return initialState;
51
- }
52
-
53
- // Read storage for all docs plugins
54
- // Assign to each doc plugin a preferred version (if found)
55
- function readStorageState({
56
- pluginIds,
57
- versionPersistence,
58
- allDocsData,
59
- }: {
60
- pluginIds: string[];
61
- versionPersistence: DocsVersionPersistence;
62
- allDocsData: Record<string, GlobalPluginData>;
63
- }): DocsPreferredVersionState {
64
- // The storage value we read might be stale,
65
- // and belong to a version that does not exist in the site anymore
66
- // In such case, we remove the storage value to avoid downstream errors
67
- function restorePluginState(
68
- pluginId: string,
69
- ): DocsPreferredVersionPluginState {
70
- const preferredVersionNameUnsafe = DocsPreferredVersionStorage.read(
71
- pluginId,
72
- versionPersistence,
73
- );
74
- const pluginData = allDocsData[pluginId];
75
- const versionExists = pluginData.versions.some(
76
- (version) => version.name === preferredVersionNameUnsafe,
77
- );
78
- if (versionExists) {
79
- return {preferredVersionName: preferredVersionNameUnsafe};
80
- }
81
- DocsPreferredVersionStorage.clear(pluginId, versionPersistence);
82
- return {preferredVersionName: null};
83
- }
84
-
85
- const initialState: DocsPreferredVersionState = {};
86
- pluginIds.forEach((pluginId) => {
87
- initialState[pluginId] = restorePluginState(pluginId);
88
- });
89
- return initialState;
90
- }
91
-
92
- function useVersionPersistence(): DocsVersionPersistence {
93
- return useThemeConfig().docs.versionPersistence;
94
- }
95
-
96
- // Value that will be accessible through context: [state,api]
97
- function useContextValue() {
98
- const allDocsData = useAllDocsData();
99
- const versionPersistence = useVersionPersistence();
100
- const pluginIds = useMemo(() => Object.keys(allDocsData), [allDocsData]);
101
-
102
- // Initial state is empty, as we can't read browser storage in node/SSR
103
- const [state, setState] = useState(() => getInitialState(pluginIds));
104
-
105
- // On mount, we set the state read from browser storage
106
- useEffect(() => {
107
- setState(readStorageState({allDocsData, versionPersistence, pluginIds}));
108
- }, [allDocsData, versionPersistence, pluginIds]);
109
-
110
- // The API that we expose to consumer hooks (memo for constant object)
111
- const api = useMemo(() => {
112
- function savePreferredVersion(pluginId: string, versionName: string) {
113
- DocsPreferredVersionStorage.save(
114
- pluginId,
115
- versionPersistence,
116
- versionName,
117
- );
118
- setState((s) => ({
119
- ...s,
120
- [pluginId]: {preferredVersionName: versionName},
121
- }));
122
- }
123
-
124
- return {
125
- savePreferredVersion,
126
- };
127
- }, [versionPersistence]);
128
-
129
- return [state, api] as const;
130
- }
131
-
132
- type DocsPreferredVersionContextValue = ReturnType<typeof useContextValue>;
133
-
134
- const Context = createContext<DocsPreferredVersionContextValue | null>(null);
135
-
136
- export function DocsPreferredVersionContextProvider({
137
- children,
138
- }: {
139
- children: JSX.Element;
140
- }): JSX.Element {
141
- if (isDocsPluginEnabled) {
142
- return (
143
- <DocsPreferredVersionContextProviderUnsafe>
144
- {children}
145
- </DocsPreferredVersionContextProviderUnsafe>
146
- );
147
- }
148
- return children;
149
- }
150
-
151
- function DocsPreferredVersionContextProviderUnsafe({
152
- children,
153
- }: {
154
- children: ReactNode;
155
- }): JSX.Element {
156
- const contextValue = useContextValue();
157
- return <Context.Provider value={contextValue}>{children}</Context.Provider>;
158
- }
159
-
160
- export function useDocsPreferredVersionContext(): DocsPreferredVersionContextValue {
161
- const value = useContext(Context);
162
- if (!value) {
163
- throw new ReactContextError('DocsPreferredVersionContextProvider');
164
- }
165
- return value;
166
- }
@@ -1,33 +0,0 @@
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 {createStorageSlot} from '../storageUtils';
9
- import type {DocsVersionPersistence} from '../useThemeConfig';
10
-
11
- const storageKey = (pluginId: string) => `docs-preferred-version-${pluginId}`;
12
-
13
- const DocsPreferredVersionStorage = {
14
- save: (
15
- pluginId: string,
16
- persistence: DocsVersionPersistence,
17
- versionName: string,
18
- ): void => {
19
- createStorageSlot(storageKey(pluginId), {persistence}).set(versionName);
20
- },
21
-
22
- read: (
23
- pluginId: string,
24
- persistence: DocsVersionPersistence,
25
- ): string | null =>
26
- createStorageSlot(storageKey(pluginId), {persistence}).get(),
27
-
28
- clear: (pluginId: string, persistence: DocsVersionPersistence): void => {
29
- createStorageSlot(storageKey(pluginId), {persistence}).del();
30
- },
31
- };
32
-
33
- export default DocsPreferredVersionStorage;
@@ -1,70 +0,0 @@
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 {useCallback} from 'react';
9
- import {useDocsPreferredVersionContext} from './DocsPreferredVersionProvider';
10
- import {
11
- useAllDocsData,
12
- useDocsData,
13
- type GlobalVersion,
14
- } from '@docusaurus/plugin-content-docs/client';
15
-
16
- import {DEFAULT_PLUGIN_ID} from '@docusaurus/constants';
17
-
18
- // Note, the preferredVersion attribute will always be null before mount
19
- export function useDocsPreferredVersion(
20
- pluginId: string | undefined = DEFAULT_PLUGIN_ID,
21
- ): {
22
- preferredVersion: GlobalVersion | null | undefined;
23
- savePreferredVersionName: (versionName: string) => void;
24
- } {
25
- const docsData = useDocsData(pluginId);
26
- const [state, api] = useDocsPreferredVersionContext();
27
-
28
- const {preferredVersionName} = state[pluginId];
29
-
30
- const preferredVersion = preferredVersionName
31
- ? docsData.versions.find((version) => version.name === preferredVersionName)
32
- : null;
33
-
34
- const savePreferredVersionName = useCallback(
35
- (versionName: string) => {
36
- api.savePreferredVersion(pluginId, versionName);
37
- },
38
- [api, pluginId],
39
- );
40
-
41
- return {preferredVersion, savePreferredVersionName} as const;
42
- }
43
-
44
- export function useDocsPreferredVersionByPluginId(): Record<
45
- string,
46
- GlobalVersion | null | undefined
47
- > {
48
- const allDocsData = useAllDocsData();
49
- const [state] = useDocsPreferredVersionContext();
50
-
51
- function getPluginIdPreferredVersion(pluginId: string) {
52
- const docsData = allDocsData[pluginId];
53
- const {preferredVersionName} = state[pluginId];
54
-
55
- return preferredVersionName
56
- ? docsData.versions.find(
57
- (version) => version.name === preferredVersionName,
58
- )
59
- : null;
60
- }
61
-
62
- const pluginIds = Object.keys(allDocsData);
63
-
64
- const result: Record<string, GlobalVersion | null | undefined> = {};
65
- pluginIds.forEach((pluginId) => {
66
- result[pluginId] = getPluginIdPreferredVersion(pluginId);
67
- });
68
-
69
- return result;
70
- }
@@ -1,114 +0,0 @@
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, {
9
- useState,
10
- type ReactNode,
11
- useContext,
12
- createContext,
13
- useEffect,
14
- type ComponentType,
15
- useMemo,
16
- } from 'react';
17
- import {ReactContextError} from './reactUtils';
18
-
19
- /*
20
- The idea behind all this is that a specific component must be able to fill a
21
- placeholder in the generic layout. The doc page should be able to fill the
22
- secondary menu of the main mobile navbar. This permits to reduce coupling
23
- between the main layout and the specific page.
24
-
25
- This kind of feature is often called portal/teleport/gateway... various
26
- unmaintained React libs exist. Most up-to-date one: https://github.com/gregberge/react-teleporter
27
- Not sure any of those is safe regarding concurrent mode.
28
- */
29
-
30
- type ExtraProps = {
31
- toggleSidebar: () => void;
32
- };
33
-
34
- export type MobileSecondaryMenuComponent<Props> = ComponentType<
35
- Props & ExtraProps
36
- >;
37
-
38
- type State = {
39
- component: MobileSecondaryMenuComponent<unknown>;
40
- props: unknown;
41
- } | null;
42
-
43
- function useContextValue() {
44
- return useState<State>(null);
45
- }
46
-
47
- type ContextValue = ReturnType<typeof useContextValue>;
48
-
49
- const Context = createContext<ContextValue | null>(null);
50
-
51
- export function MobileSecondaryMenuProvider({
52
- children,
53
- }: {
54
- children: ReactNode;
55
- }): JSX.Element {
56
- return (
57
- <Context.Provider value={useContextValue()}>{children}</Context.Provider>
58
- );
59
- }
60
-
61
- function useMobileSecondaryMenuContext(): ContextValue {
62
- const value = useContext(Context);
63
- if (value === null) {
64
- throw new ReactContextError('MobileSecondaryMenuProvider');
65
- }
66
- return value;
67
- }
68
-
69
- export function useMobileSecondaryMenuRenderer(): (
70
- extraProps: ExtraProps,
71
- ) => ReactNode | undefined {
72
- const [state] = useMobileSecondaryMenuContext();
73
- if (state) {
74
- const Comp = state.component;
75
- return function render(extraProps) {
76
- return <Comp {...state.props} {...extraProps} />;
77
- };
78
- }
79
- return () => undefined;
80
- }
81
-
82
- function useShallowMemoizedObject<O extends Record<string, unknown>>(obj: O) {
83
- return useMemo(
84
- () => obj,
85
- // Is this safe?
86
- // eslint-disable-next-line react-hooks/exhaustive-deps
87
- [...Object.keys(obj), ...Object.values(obj)],
88
- );
89
- }
90
-
91
- // Fill the secondary menu placeholder with some real content
92
- export function MobileSecondaryMenuFiller<
93
- Props extends Record<string, unknown>,
94
- >({
95
- component,
96
- props,
97
- }: {
98
- component: MobileSecondaryMenuComponent<Props & ExtraProps>;
99
- props: Props;
100
- }): JSX.Element | null {
101
- const [, setState] = useMobileSecondaryMenuContext();
102
-
103
- // To avoid useless context re-renders, props are memoized shallowly
104
- const memoizedProps = useShallowMemoizedObject(props);
105
-
106
- useEffect(() => {
107
- // @ts-expect-error: context is not 100% type-safe but it's ok
108
- setState({component, props: memoizedProps});
109
- }, [setState, component, memoizedProps]);
110
-
111
- useEffect(() => () => setState(null), [setState]);
112
-
113
- return null;
114
- }
@@ -1,19 +0,0 @@
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
- // Compare the 2 paths, case insensitive and ignoring trailing slash
9
- export const isSamePath = (
10
- path1: string | undefined,
11
- path2: string | undefined,
12
- ): boolean => {
13
- const normalize = (pathname: string | undefined) =>
14
- (!pathname || pathname?.endsWith('/')
15
- ? pathname
16
- : `${pathname}/`
17
- )?.toLowerCase();
18
- return normalize(path1) === normalize(path2);
19
- };
@@ -1,53 +0,0 @@
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 {
9
- useAllDocsData,
10
- useActivePluginAndVersion,
11
- } from '@docusaurus/plugin-content-docs/client';
12
- import {useDocsPreferredVersionByPluginId} from './docsPreferredVersion/useDocsPreferredVersion';
13
- import {docVersionSearchTag, DEFAULT_SEARCH_TAG} from './searchUtils';
14
- import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
15
-
16
- export type useContextualSearchFiltersReturns = {
17
- locale: string;
18
- tags: string[];
19
- };
20
-
21
- // We may want to support multiple search engines, don't couple that to
22
- // Algolia/DocSearch. Maybe users want to use their own search engine solution
23
- export function useContextualSearchFilters(): useContextualSearchFiltersReturns {
24
- const {i18n} = useDocusaurusContext();
25
- const allDocsData = useAllDocsData();
26
- const activePluginAndVersion = useActivePluginAndVersion();
27
- const docsPreferredVersionByPluginId = useDocsPreferredVersionByPluginId();
28
-
29
- function getDocPluginTags(pluginId: string) {
30
- const activeVersion =
31
- activePluginAndVersion?.activePlugin?.pluginId === pluginId
32
- ? activePluginAndVersion.activeVersion
33
- : undefined;
34
-
35
- const preferredVersion = docsPreferredVersionByPluginId[pluginId];
36
-
37
- const latestVersion = allDocsData[pluginId].versions.find((v) => v.isLast)!;
38
-
39
- const version = activeVersion ?? preferredVersion ?? latestVersion;
40
-
41
- return docVersionSearchTag(pluginId, version.name);
42
- }
43
-
44
- const tags = [
45
- DEFAULT_SEARCH_TAG,
46
- ...Object.keys(allDocsData).map(getDocPluginTags),
47
- ];
48
-
49
- return {
50
- locale: i18n.currentLocale,
51
- tags,
52
- };
53
- }
@@ -1,19 +0,0 @@
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 {useRef} from 'react';
9
- import {useIsomorphicLayoutEffect} from './reactUtils';
10
-
11
- export function usePrevious<T>(value: T): T | undefined {
12
- const ref = useRef<T>();
13
-
14
- useIsomorphicLayoutEffect(() => {
15
- ref.current = value;
16
- });
17
-
18
- return ref.current;
19
- }