@docusaurus/theme-common 2.0.0-beta.16 → 2.0.0-beta.19

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 (279) hide show
  1. package/Details.d.ts +14 -0
  2. package/lib/components/Collapsible/index.d.ts +32 -4
  3. package/lib/components/Collapsible/index.d.ts.map +1 -1
  4. package/lib/components/Collapsible/index.js +18 -10
  5. package/lib/components/Collapsible/index.js.map +1 -1
  6. package/lib/components/Details/index.d.ts +6 -1
  7. package/lib/components/Details/index.d.ts.map +1 -1
  8. package/lib/components/Details/index.js +11 -6
  9. package/lib/components/Details/index.js.map +1 -1
  10. package/lib/components/Details/styles.module.css +4 -0
  11. package/lib/{utils/announcementBarUtils.d.ts → contexts/announcementBar.d.ts} +7 -3
  12. package/lib/contexts/announcementBar.d.ts.map +1 -0
  13. package/lib/{utils/announcementBarUtils.js → contexts/announcementBar.js} +15 -14
  14. package/lib/contexts/announcementBar.js.map +1 -0
  15. package/lib/contexts/colorMode.d.ts +27 -0
  16. package/lib/contexts/colorMode.d.ts.map +1 -0
  17. package/lib/contexts/colorMode.js +132 -0
  18. package/lib/contexts/colorMode.js.map +1 -0
  19. package/lib/contexts/docSidebarItemsExpandedState.d.ts +31 -0
  20. package/lib/contexts/docSidebarItemsExpandedState.d.ts.map +1 -0
  21. package/lib/{utils → contexts}/docSidebarItemsExpandedState.js +10 -4
  22. package/lib/contexts/docSidebarItemsExpandedState.js.map +1 -0
  23. package/lib/contexts/docsPreferredVersion.d.ts +31 -0
  24. package/lib/contexts/docsPreferredVersion.d.ts.map +1 -0
  25. package/lib/contexts/docsPreferredVersion.js +128 -0
  26. package/lib/contexts/docsPreferredVersion.js.map +1 -0
  27. package/lib/contexts/docsSidebar.d.ts +26 -0
  28. package/lib/contexts/docsSidebar.d.ts.map +1 -0
  29. package/lib/contexts/docsSidebar.js +30 -0
  30. package/lib/contexts/docsSidebar.js.map +1 -0
  31. package/lib/contexts/docsVersion.d.ts +20 -0
  32. package/lib/contexts/docsVersion.d.ts.map +1 -0
  33. package/lib/contexts/docsVersion.js +26 -0
  34. package/lib/contexts/docsVersion.js.map +1 -0
  35. package/lib/contexts/navbarMobileSidebar.d.ts +31 -0
  36. package/lib/contexts/navbarMobileSidebar.d.ts.map +1 -0
  37. package/lib/contexts/navbarMobileSidebar.js +56 -0
  38. package/lib/contexts/navbarMobileSidebar.js.map +1 -0
  39. package/lib/contexts/navbarSecondaryMenu/content.d.ts +37 -0
  40. package/lib/contexts/navbarSecondaryMenu/content.d.ts.map +1 -0
  41. package/lib/contexts/navbarSecondaryMenu/content.js +56 -0
  42. package/lib/contexts/navbarSecondaryMenu/content.js.map +1 -0
  43. package/lib/contexts/navbarSecondaryMenu/display.d.ts +24 -0
  44. package/lib/contexts/navbarSecondaryMenu/display.d.ts.map +1 -0
  45. package/lib/contexts/navbarSecondaryMenu/display.js +62 -0
  46. package/lib/contexts/navbarSecondaryMenu/display.js.map +1 -0
  47. package/lib/{utils/tabGroupChoiceUtils.d.ts → contexts/tabGroupChoice.d.ts} +5 -3
  48. package/lib/contexts/tabGroupChoice.d.ts.map +1 -0
  49. package/lib/{utils/tabGroupChoiceUtils.js → contexts/tabGroupChoice.js} +15 -20
  50. package/lib/contexts/tabGroupChoice.js.map +1 -0
  51. package/lib/hooks/useBackToTopButton.d.ts +27 -0
  52. package/lib/hooks/useBackToTopButton.d.ts.map +1 -0
  53. package/lib/hooks/useBackToTopButton.js +50 -0
  54. package/lib/hooks/useBackToTopButton.js.map +1 -0
  55. package/lib/hooks/useCodeWordWrap.d.ts +14 -0
  56. package/lib/hooks/useCodeWordWrap.d.ts.map +1 -0
  57. package/lib/hooks/useCodeWordWrap.js +41 -0
  58. package/lib/hooks/useCodeWordWrap.js.map +1 -0
  59. package/lib/hooks/useHideableNavbar.d.ts +7 -3
  60. package/lib/hooks/useHideableNavbar.d.ts.map +1 -1
  61. package/lib/hooks/useHideableNavbar.js +10 -9
  62. package/lib/hooks/useHideableNavbar.js.map +1 -1
  63. package/lib/hooks/useKeyboardNavigation.d.ts +11 -1
  64. package/lib/hooks/useKeyboardNavigation.d.ts.map +1 -1
  65. package/lib/hooks/useKeyboardNavigation.js +11 -3
  66. package/lib/hooks/useKeyboardNavigation.js.map +1 -1
  67. package/lib/hooks/useLockBodyScroll.d.ts +5 -1
  68. package/lib/hooks/useLockBodyScroll.d.ts.map +1 -1
  69. package/lib/hooks/useLockBodyScroll.js +5 -1
  70. package/lib/hooks/useLockBodyScroll.js.map +1 -1
  71. package/lib/hooks/usePrismTheme.d.ts +6 -2
  72. package/lib/hooks/usePrismTheme.d.ts.map +1 -1
  73. package/lib/hooks/usePrismTheme.js +9 -6
  74. package/lib/hooks/usePrismTheme.js.map +1 -1
  75. package/lib/hooks/useSearchPage.d.ts +15 -4
  76. package/lib/hooks/useSearchPage.d.ts.map +1 -1
  77. package/lib/hooks/useSearchPage.js +4 -4
  78. package/lib/hooks/useSearchPage.js.map +1 -1
  79. package/lib/hooks/useSkipToContent.d.ts +25 -0
  80. package/lib/hooks/useSkipToContent.d.ts.map +1 -0
  81. package/lib/hooks/useSkipToContent.js +35 -0
  82. package/lib/hooks/useSkipToContent.js.map +1 -0
  83. package/lib/hooks/useTOCHighlight.d.ts +25 -0
  84. package/lib/hooks/useTOCHighlight.d.ts.map +1 -0
  85. package/lib/{utils → hooks}/useTOCHighlight.js +18 -16
  86. package/lib/hooks/useTOCHighlight.js.map +1 -0
  87. package/lib/hooks/useWindowSize.d.ts +14 -1
  88. package/lib/hooks/useWindowSize.d.ts.map +1 -1
  89. package/lib/hooks/useWindowSize.js +14 -11
  90. package/lib/hooks/useWindowSize.js.map +1 -1
  91. package/lib/index.d.ts +31 -32
  92. package/lib/index.d.ts.map +1 -1
  93. package/lib/index.js +31 -26
  94. package/lib/index.js.map +1 -1
  95. package/lib/utils/ThemeClassNames.d.ts +7 -0
  96. package/lib/utils/ThemeClassNames.d.ts.map +1 -1
  97. package/lib/utils/ThemeClassNames.js +7 -4
  98. package/lib/utils/ThemeClassNames.js.map +1 -1
  99. package/lib/utils/codeBlockUtils.d.ts +57 -4
  100. package/lib/utils/codeBlockUtils.d.ts.map +1 -1
  101. package/lib/utils/codeBlockUtils.js +111 -80
  102. package/lib/utils/codeBlockUtils.js.map +1 -1
  103. package/lib/utils/docsUtils.d.ts +83 -18
  104. package/lib/utils/docsUtils.d.ts.map +1 -1
  105. package/lib/utils/docsUtils.js +143 -62
  106. package/lib/utils/docsUtils.js.map +1 -1
  107. package/lib/utils/footerUtils.d.ts +13 -0
  108. package/lib/utils/footerUtils.d.ts.map +1 -0
  109. package/lib/utils/footerUtils.js +14 -0
  110. package/lib/utils/footerUtils.js.map +1 -0
  111. package/lib/utils/generalUtils.d.ts +4 -1
  112. package/lib/utils/generalUtils.d.ts.map +1 -1
  113. package/lib/utils/generalUtils.js +6 -3
  114. package/lib/utils/generalUtils.js.map +1 -1
  115. package/lib/utils/historyUtils.d.ts +1 -7
  116. package/lib/utils/historyUtils.d.ts.map +1 -1
  117. package/lib/utils/historyUtils.js +10 -13
  118. package/lib/utils/historyUtils.js.map +1 -1
  119. package/lib/utils/jsUtils.d.ts +1 -1
  120. package/lib/utils/jsUtils.js +1 -1
  121. package/lib/utils/metadataUtils.d.ts +38 -0
  122. package/lib/utils/metadataUtils.d.ts.map +1 -0
  123. package/lib/utils/metadataUtils.js +61 -0
  124. package/lib/utils/metadataUtils.js.map +1 -0
  125. package/lib/utils/navbarUtils.d.ts +21 -0
  126. package/lib/utils/navbarUtils.d.ts.map +1 -0
  127. package/lib/utils/navbarUtils.js +32 -0
  128. package/lib/utils/navbarUtils.js.map +1 -0
  129. package/lib/utils/reactUtils.d.ts +21 -7
  130. package/lib/utils/reactUtils.d.ts.map +1 -1
  131. package/lib/utils/reactUtils.js +34 -6
  132. package/lib/utils/reactUtils.js.map +1 -1
  133. package/lib/utils/regexpUtils.d.ts +2 -1
  134. package/lib/utils/regexpUtils.d.ts.map +1 -1
  135. package/lib/utils/regexpUtils.js +2 -1
  136. package/lib/utils/regexpUtils.js.map +1 -1
  137. package/lib/utils/routesUtils.d.ts +19 -4
  138. package/lib/utils/routesUtils.d.ts.map +1 -1
  139. package/lib/utils/routesUtils.js +40 -19
  140. package/lib/utils/routesUtils.js.map +1 -1
  141. package/lib/utils/scrollUtils.d.ts +55 -25
  142. package/lib/utils/scrollUtils.d.ts.map +1 -1
  143. package/lib/utils/scrollUtils.js +85 -21
  144. package/lib/utils/scrollUtils.js.map +1 -1
  145. package/lib/utils/searchUtils.d.ts +12 -0
  146. package/lib/utils/searchUtils.d.ts.map +1 -1
  147. package/lib/utils/searchUtils.js +36 -0
  148. package/lib/utils/searchUtils.js.map +1 -1
  149. package/lib/utils/storageUtils.d.ts +12 -9
  150. package/lib/utils/storageUtils.d.ts.map +1 -1
  151. package/lib/utils/storageUtils.js +21 -13
  152. package/lib/utils/storageUtils.js.map +1 -1
  153. package/lib/utils/tagsUtils.d.ts +7 -8
  154. package/lib/utils/tagsUtils.d.ts.map +1 -1
  155. package/lib/utils/tagsUtils.js +8 -6
  156. package/lib/utils/tagsUtils.js.map +1 -1
  157. package/lib/utils/tocUtils.d.ts +17 -1
  158. package/lib/utils/tocUtils.d.ts.map +1 -1
  159. package/lib/utils/tocUtils.js +20 -9
  160. package/lib/utils/tocUtils.js.map +1 -1
  161. package/lib/utils/useAlternatePageUtils.d.ts +20 -1
  162. package/lib/utils/useAlternatePageUtils.d.ts.map +1 -1
  163. package/lib/utils/useAlternatePageUtils.js +6 -3
  164. package/lib/utils/useAlternatePageUtils.js.map +1 -1
  165. package/lib/utils/useLocalPathname.d.ts +5 -0
  166. package/lib/utils/useLocalPathname.d.ts.map +1 -1
  167. package/lib/utils/useLocalPathname.js +6 -4
  168. package/lib/utils/useLocalPathname.js.map +1 -1
  169. package/lib/utils/useLocationChange.d.ts +7 -5
  170. package/lib/utils/useLocationChange.d.ts.map +1 -1
  171. package/lib/utils/useLocationChange.js +6 -2
  172. package/lib/utils/useLocationChange.js.map +1 -1
  173. package/lib/utils/usePluralForm.d.ts +11 -0
  174. package/lib/utils/usePluralForm.d.ts.map +1 -1
  175. package/lib/utils/usePluralForm.js +19 -24
  176. package/lib/utils/usePluralForm.js.map +1 -1
  177. package/lib/utils/useThemeConfig.d.ts +28 -22
  178. package/lib/utils/useThemeConfig.d.ts.map +1 -1
  179. package/lib/utils/useThemeConfig.js +3 -0
  180. package/lib/utils/useThemeConfig.js.map +1 -1
  181. package/package.json +18 -11
  182. package/src/components/Collapsible/index.tsx +42 -24
  183. package/src/components/Details/index.tsx +15 -8
  184. package/src/components/Details/styles.module.css +4 -0
  185. package/src/{utils/announcementBarUtils.tsx → contexts/announcementBar.tsx} +20 -22
  186. package/src/contexts/colorMode.tsx +199 -0
  187. package/src/contexts/docSidebarItemsExpandedState.tsx +55 -0
  188. package/src/contexts/docsPreferredVersion.tsx +253 -0
  189. package/src/contexts/docsSidebar.tsx +50 -0
  190. package/src/contexts/docsVersion.tsx +36 -0
  191. package/src/contexts/navbarMobileSidebar.tsx +99 -0
  192. package/src/contexts/navbarSecondaryMenu/content.tsx +110 -0
  193. package/src/contexts/navbarSecondaryMenu/display.tsx +102 -0
  194. package/src/{utils/tabGroupChoiceUtils.tsx → contexts/tabGroupChoice.tsx} +28 -33
  195. package/src/hooks/useBackToTopButton.ts +73 -0
  196. package/src/hooks/useCodeWordWrap.ts +56 -0
  197. package/src/hooks/useHideableNavbar.ts +12 -14
  198. package/src/hooks/useKeyboardNavigation.ts +11 -3
  199. package/src/hooks/useLockBodyScroll.ts +5 -2
  200. package/src/hooks/usePrismTheme.ts +10 -6
  201. package/src/hooks/useSearchPage.ts +18 -5
  202. package/src/hooks/useSkipToContent.ts +58 -0
  203. package/src/{utils → hooks}/useTOCHighlight.ts +24 -15
  204. package/src/hooks/useWindowSize.ts +14 -12
  205. package/src/index.ts +77 -57
  206. package/src/utils/ThemeClassNames.ts +10 -6
  207. package/src/utils/codeBlockUtils.ts +178 -92
  208. package/src/utils/docsUtils.tsx +205 -101
  209. package/src/utils/footerUtils.ts +18 -0
  210. package/src/utils/generalUtils.ts +6 -3
  211. package/src/utils/historyUtils.ts +11 -17
  212. package/src/utils/jsUtils.ts +1 -1
  213. package/src/utils/metadataUtils.tsx +115 -0
  214. package/src/utils/navbarUtils.tsx +45 -0
  215. package/src/utils/reactUtils.tsx +40 -7
  216. package/src/utils/regexpUtils.ts +2 -1
  217. package/src/utils/routesUtils.ts +58 -22
  218. package/src/utils/scrollUtils.tsx +120 -49
  219. package/src/utils/searchUtils.ts +51 -0
  220. package/src/utils/storageUtils.ts +23 -15
  221. package/src/utils/tagsUtils.ts +12 -10
  222. package/src/utils/tocUtils.ts +22 -11
  223. package/src/utils/useAlternatePageUtils.ts +17 -5
  224. package/src/utils/useLocalPathname.ts +6 -4
  225. package/src/utils/useLocationChange.ts +12 -10
  226. package/src/utils/usePluralForm.ts +27 -24
  227. package/src/utils/useThemeConfig.ts +23 -22
  228. package/yarn-error.log +20199 -0
  229. package/lib/utils/announcementBarUtils.d.ts.map +0 -1
  230. package/lib/utils/announcementBarUtils.js.map +0 -1
  231. package/lib/utils/colorModeUtils.d.ts +0 -18
  232. package/lib/utils/colorModeUtils.d.ts.map +0 -1
  233. package/lib/utils/colorModeUtils.js +0 -106
  234. package/lib/utils/colorModeUtils.js.map +0 -1
  235. package/lib/utils/docSidebarItemsExpandedState.d.ts +0 -17
  236. package/lib/utils/docSidebarItemsExpandedState.d.ts.map +0 -1
  237. package/lib/utils/docSidebarItemsExpandedState.js.map +0 -1
  238. package/lib/utils/docsPreferredVersion/DocsPreferredVersionProvider.d.ts +0 -22
  239. package/lib/utils/docsPreferredVersion/DocsPreferredVersionProvider.d.ts.map +0 -1
  240. package/lib/utils/docsPreferredVersion/DocsPreferredVersionProvider.js +0 -91
  241. package/lib/utils/docsPreferredVersion/DocsPreferredVersionProvider.js.map +0 -1
  242. package/lib/utils/docsPreferredVersion/DocsPreferredVersionStorage.d.ts +0 -14
  243. package/lib/utils/docsPreferredVersion/DocsPreferredVersionStorage.d.ts.map +0 -1
  244. package/lib/utils/docsPreferredVersion/DocsPreferredVersionStorage.js +0 -19
  245. package/lib/utils/docsPreferredVersion/DocsPreferredVersionStorage.js.map +0 -1
  246. package/lib/utils/docsPreferredVersion/useDocsPreferredVersion.d.ts +0 -14
  247. package/lib/utils/docsPreferredVersion/useDocsPreferredVersion.d.ts.map +0 -1
  248. package/lib/utils/docsPreferredVersion/useDocsPreferredVersion.js +0 -41
  249. package/lib/utils/docsPreferredVersion/useDocsPreferredVersion.js.map +0 -1
  250. package/lib/utils/mobileSecondaryMenu.d.ts +0 -21
  251. package/lib/utils/mobileSecondaryMenu.d.ts.map +0 -1
  252. package/lib/utils/mobileSecondaryMenu.js +0 -50
  253. package/lib/utils/mobileSecondaryMenu.js.map +0 -1
  254. package/lib/utils/pathUtils.d.ts +0 -8
  255. package/lib/utils/pathUtils.d.ts.map +0 -1
  256. package/lib/utils/pathUtils.js +0 -17
  257. package/lib/utils/pathUtils.js.map +0 -1
  258. package/lib/utils/tabGroupChoiceUtils.d.ts.map +0 -1
  259. package/lib/utils/tabGroupChoiceUtils.js.map +0 -1
  260. package/lib/utils/useContextualSearchFilters.d.ts +0 -12
  261. package/lib/utils/useContextualSearchFilters.d.ts.map +0 -1
  262. package/lib/utils/useContextualSearchFilters.js +0 -37
  263. package/lib/utils/useContextualSearchFilters.js.map +0 -1
  264. package/lib/utils/usePrevious.d.ts +0 -8
  265. package/lib/utils/usePrevious.d.ts.map +0 -1
  266. package/lib/utils/usePrevious.js +0 -16
  267. package/lib/utils/usePrevious.js.map +0 -1
  268. package/lib/utils/useTOCHighlight.d.ts +0 -14
  269. package/lib/utils/useTOCHighlight.d.ts.map +0 -1
  270. package/lib/utils/useTOCHighlight.js.map +0 -1
  271. package/src/utils/colorModeUtils.tsx +0 -156
  272. package/src/utils/docSidebarItemsExpandedState.tsx +0 -41
  273. package/src/utils/docsPreferredVersion/DocsPreferredVersionProvider.tsx +0 -167
  274. package/src/utils/docsPreferredVersion/DocsPreferredVersionStorage.ts +0 -33
  275. package/src/utils/docsPreferredVersion/useDocsPreferredVersion.ts +0 -70
  276. package/src/utils/mobileSecondaryMenu.tsx +0 -115
  277. package/src/utils/pathUtils.ts +0 -19
  278. package/src/utils/useContextualSearchFilters.ts +0 -53
  279. package/src/utils/usePrevious.ts +0 -19
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Copyright (c) Facebook, Inc. and its affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import React from 'react';
8
+ import { NavbarMobileSidebarProvider } from '../contexts/navbarMobileSidebar';
9
+ import { NavbarSecondaryMenuContentProvider } from '../contexts/navbarSecondaryMenu/content';
10
+ import { NavbarSecondaryMenuDisplayProvider } from '../contexts/navbarSecondaryMenu/display';
11
+ const DefaultNavItemPosition = 'right';
12
+ /**
13
+ * Split links by left/right. If position is unspecified, fallback to right.
14
+ */
15
+ export function splitNavbarItems(items) {
16
+ function isLeft(item) {
17
+ return (item.position ?? DefaultNavItemPosition) === 'left';
18
+ }
19
+ const leftItems = items.filter(isLeft);
20
+ const rightItems = items.filter((item) => !isLeft(item));
21
+ return [leftItems, rightItems];
22
+ }
23
+ /**
24
+ * Composes multiple navbar state providers that are mutually dependent and
25
+ * hence can't be re-ordered.
26
+ */
27
+ export function NavbarProvider({ children }) {
28
+ return (React.createElement(NavbarSecondaryMenuContentProvider, null,
29
+ React.createElement(NavbarMobileSidebarProvider, null,
30
+ React.createElement(NavbarSecondaryMenuDisplayProvider, null, children))));
31
+ }
32
+ //# sourceMappingURL=navbarUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"navbarUtils.js","sourceRoot":"","sources":["../../src/utils/navbarUtils.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAuB,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAC,2BAA2B,EAAC,MAAM,iCAAiC,CAAC;AAC5E,OAAO,EAAC,kCAAkC,EAAC,MAAM,yCAAyC,CAAC;AAC3F,OAAO,EAAC,kCAAkC,EAAC,MAAM,yCAAyC,CAAC;AAE3F,MAAM,sBAAsB,GAAG,OAAO,CAAC;AAEvC;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAC9B,KAAU;IAEV,SAAS,MAAM,CAAC,IAAO;QACrB,OAAO,CAAC,IAAI,CAAC,QAAQ,IAAI,sBAAsB,CAAC,KAAK,MAAM,CAAC;IAC9D,CAAC;IAED,MAAM,SAAS,GAAG,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACvC,MAAM,UAAU,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;IAEzD,OAAO,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;AACjC,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,EAAC,QAAQ,EAAwB;IAC9D,OAAO,CACL,oBAAC,kCAAkC;QACjC,oBAAC,2BAA2B;YAC1B,oBAAC,kCAAkC,QAChC,QAAQ,CAC0B,CACT,CACK,CACtC,CAAC;AACJ,CAAC"}
@@ -4,25 +4,39 @@
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 { useEffect } from 'react';
7
+ import { useLayoutEffect } from 'react';
8
8
  /**
9
- * This hook is like useLayoutEffect, but without the SSR warning
10
- * It seems hacky but it's used in many React libs (Redux, Formik...)
9
+ * This hook is like `useLayoutEffect`, but without the SSR warning.
10
+ * It seems hacky but it's used in many React libs (Redux, Formik...).
11
11
  * Also mentioned here: https://github.com/facebook/react/issues/16956
12
+ *
12
13
  * It is useful when you need to update a ref as soon as possible after a React
13
- * render (before `useEffect`)
14
+ * render (before `useEffect`).
14
15
  */
15
- export declare const useIsomorphicLayoutEffect: typeof useEffect;
16
+ export declare const useIsomorphicLayoutEffect: typeof useLayoutEffect;
16
17
  /**
17
18
  * Permits to transform an unstable callback (like an arrow function provided as
18
- * props) to a "stable" callback that is safe to use in a useEffect dependency
19
+ * props) to a "stable" callback that is safe to use in a `useEffect` dependency
19
20
  * array. Useful to avoid React stale closure problems + avoid useless effect
20
- * re-executions
21
+ * re-executions.
21
22
  *
22
23
  * Workaround until the React team recommends a good solution, see
23
24
  * https://github.com/facebook/react/issues/16956
25
+ *
24
26
  * This generally works but has some potential drawbacks, such as
25
27
  * https://github.com/facebook/react/issues/16956#issuecomment-536636418
26
28
  */
27
29
  export declare function useDynamicCallback<T extends (...args: never[]) => unknown>(callback: T): T;
30
+ /**
31
+ * Gets `value` from the last render.
32
+ */
33
+ export declare function usePrevious<T>(value: T): T | undefined;
34
+ /**
35
+ * This error is thrown when a context is consumed outside its provider. Allows
36
+ * reusing a generic error message format and reduces bundle size. The hook's
37
+ * name will be extracted from its stack, so only the provider's name is needed.
38
+ */
39
+ export declare class ReactContextError extends Error {
40
+ constructor(providerName: string, additionalInfo?: string);
41
+ }
28
42
  //# sourceMappingURL=reactUtils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"reactUtils.d.ts","sourceRoot":"","sources":["../../src/utils/reactUtils.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAc,SAAS,EAA0B,MAAM,OAAO,CAAC;AAEtE;;;;;;GAMG;AACH,eAAO,MAAM,yBAAyB,kBACuB,CAAC;AAE9D;;;;;;;;;;GAUG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,KAAK,EAAE,KAAK,OAAO,EACxE,QAAQ,EAAE,CAAC,GACV,CAAC,CAUH"}
1
+ {"version":3,"file":"reactUtils.d.ts","sourceRoot":"","sources":["../../src/utils/reactUtils.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAyB,eAAe,EAAS,MAAM,OAAO,CAAC;AAGtE;;;;;;;GAOG;AACH,eAAO,MAAM,yBAAyB,wBAEzB,CAAC;AAEd;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,KAAK,EAAE,KAAK,OAAO,EACxE,QAAQ,EAAE,CAAC,GACV,CAAC,CAUH;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,GAAG,SAAS,CAQtD;AAED;;;;GAIG;AACH,qBAAa,iBAAkB,SAAQ,KAAK;gBAC9B,YAAY,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,MAAM;CAQ1D"}
@@ -5,22 +5,27 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import { useCallback, useEffect, useLayoutEffect, useRef } from 'react';
8
+ import ExecutionEnvironment from '@docusaurus/ExecutionEnvironment';
8
9
  /**
9
- * This hook is like useLayoutEffect, but without the SSR warning
10
- * It seems hacky but it's used in many React libs (Redux, Formik...)
10
+ * This hook is like `useLayoutEffect`, but without the SSR warning.
11
+ * It seems hacky but it's used in many React libs (Redux, Formik...).
11
12
  * Also mentioned here: https://github.com/facebook/react/issues/16956
13
+ *
12
14
  * It is useful when you need to update a ref as soon as possible after a React
13
- * render (before `useEffect`)
15
+ * render (before `useEffect`).
14
16
  */
15
- export const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect;
17
+ export const useIsomorphicLayoutEffect = ExecutionEnvironment.canUseDOM
18
+ ? useLayoutEffect
19
+ : useEffect;
16
20
  /**
17
21
  * Permits to transform an unstable callback (like an arrow function provided as
18
- * props) to a "stable" callback that is safe to use in a useEffect dependency
22
+ * props) to a "stable" callback that is safe to use in a `useEffect` dependency
19
23
  * array. Useful to avoid React stale closure problems + avoid useless effect
20
- * re-executions
24
+ * re-executions.
21
25
  *
22
26
  * Workaround until the React team recommends a good solution, see
23
27
  * https://github.com/facebook/react/issues/16956
28
+ *
24
29
  * This generally works but has some potential drawbacks, such as
25
30
  * https://github.com/facebook/react/issues/16956#issuecomment-536636418
26
31
  */
@@ -33,4 +38,27 @@ export function useDynamicCallback(callback) {
33
38
  // but good enough for our use
34
39
  return useCallback((...args) => ref.current(...args), []);
35
40
  }
41
+ /**
42
+ * Gets `value` from the last render.
43
+ */
44
+ export function usePrevious(value) {
45
+ const ref = useRef();
46
+ useIsomorphicLayoutEffect(() => {
47
+ ref.current = value;
48
+ });
49
+ return ref.current;
50
+ }
51
+ /**
52
+ * This error is thrown when a context is consumed outside its provider. Allows
53
+ * reusing a generic error message format and reduces bundle size. The hook's
54
+ * name will be extracted from its stack, so only the provider's name is needed.
55
+ */
56
+ export class ReactContextError extends Error {
57
+ constructor(providerName, additionalInfo) {
58
+ super();
59
+ this.name = 'ReactContextError';
60
+ this.message = `Hook ${this.stack?.split('\n')[1]?.match(/at (?:\w+\.)?(?<name>\w+)/)?.groups
61
+ .name} is called outside the <${providerName}>. ${additionalInfo || ''}`;
62
+ }
63
+ }
36
64
  //# sourceMappingURL=reactUtils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"reactUtils.js","sourceRoot":"","sources":["../../src/utils/reactUtils.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAC,WAAW,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,EAAC,MAAM,OAAO,CAAC;AAEtE;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,yBAAyB,GACpC,OAAO,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,SAAS,CAAC;AAE9D;;;;;;;;;;GAUG;AACH,MAAM,UAAU,kBAAkB,CAChC,QAAW;IAEX,MAAM,GAAG,GAAG,MAAM,CAAI,QAAQ,CAAC,CAAC;IAEhC,yBAAyB,CAAC,GAAG,EAAE;QAC7B,GAAG,CAAC,OAAO,GAAG,QAAQ,CAAC;IACzB,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;IAEf,4EAA4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YAAoB,EAAE,cAAuB;QACvD,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC;QAChC,IAAI,CAAC,OAAO,GAAG,QACb,IAAI,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,2BAA2B,CAAC,EAAE,MAAO;aACpE,IACL,2BAA2B,YAAY,MAAM,cAAc,IAAI,EAAE,EAAE,CAAC;IACtE,CAAC;CACF"}
@@ -5,7 +5,8 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  /**
8
- * Converts an optional string into a Regex case insensitive and global
8
+ * Matches a string regex (as provided from the config) against a target in a
9
+ * null-safe fashion, case insensitive and global.
9
10
  */
10
11
  export declare function isRegexpStringMatch(regexAsString?: string, valueToTest?: string): boolean;
11
12
  //# sourceMappingURL=regexpUtils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"regexpUtils.d.ts","sourceRoot":"","sources":["../../src/utils/regexpUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,aAAa,CAAC,EAAE,MAAM,EACtB,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAST"}
1
+ {"version":3,"file":"regexpUtils.d.ts","sourceRoot":"","sources":["../../src/utils/regexpUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,aAAa,CAAC,EAAE,MAAM,EACtB,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAST"}
@@ -5,7 +5,8 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  /**
8
- * Converts an optional string into a Regex case insensitive and global
8
+ * Matches a string regex (as provided from the config) against a target in a
9
+ * null-safe fashion, case insensitive and global.
9
10
  */
10
11
  export function isRegexpStringMatch(regexAsString, valueToTest) {
11
12
  if (typeof regexAsString === 'undefined' ||
@@ -1 +1 @@
1
- {"version":3,"file":"regexpUtils.js","sourceRoot":"","sources":["../../src/utils/regexpUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;GAEG;AACH,MAAM,UAAU,mBAAmB,CACjC,aAAsB,EACtB,WAAoB;IAEpB,IACE,OAAO,aAAa,KAAK,WAAW;QACpC,OAAO,WAAW,KAAK,WAAW,EAClC;QACA,OAAO,KAAK,CAAC;KACd;IAED,OAAO,IAAI,MAAM,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;AAC3D,CAAC"}
1
+ {"version":3,"file":"regexpUtils.js","sourceRoot":"","sources":["../../src/utils/regexpUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CACjC,aAAsB,EACtB,WAAoB;IAEpB,IACE,OAAO,aAAa,KAAK,WAAW;QACpC,OAAO,WAAW,KAAK,WAAW,EAClC;QACA,OAAO,KAAK,CAAC;KACd;IAED,OAAO,IAAI,MAAM,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;AAC3D,CAAC"}
@@ -4,8 +4,23 @@
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
- /// <reference types="@docusaurus/module-type-aliases" />
8
- import { type Route } from '@generated/routes';
9
- export declare function findHomePageRoute(routes?: Route[]): Route | undefined;
10
- export declare function useHomePageRoute(): Route | undefined;
7
+ import type { RouteConfig } from 'react-router-config';
8
+ /**
9
+ * Compare the 2 paths, case insensitive and ignoring trailing slash
10
+ */
11
+ export declare function isSamePath(path1: string | undefined, path2: string | undefined): boolean;
12
+ /**
13
+ * Note that sites don't always have a homepage in practice, so we can't assume
14
+ * that linking to '/' is always safe.
15
+ * @see https://github.com/facebook/docusaurus/pull/6517#issuecomment-1048709116
16
+ */
17
+ export declare function findHomePageRoute({ baseUrl, routes: initialRoutes, }: {
18
+ routes: RouteConfig[];
19
+ baseUrl: string;
20
+ }): RouteConfig | undefined;
21
+ /**
22
+ * Fetches the route that points to "/". Use this instead of the naive "/",
23
+ * because the homepage may not exist.
24
+ */
25
+ export declare function useHomePageRoute(): RouteConfig | undefined;
11
26
  //# sourceMappingURL=routesUtils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"routesUtils.d.ts","sourceRoot":"","sources":["../../src/utils/routesUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;;AAEH,OAAwB,EAAC,KAAK,KAAK,EAAC,MAAM,mBAAmB,CAAC;AAa9D,wBAAgB,iBAAiB,CAC/B,MAAM,GAAE,KAAK,EAAoB,GAChC,KAAK,GAAG,SAAS,CAYnB;AAED,wBAAgB,gBAAgB,IAAI,KAAK,GAAG,SAAS,CAEpD"}
1
+ {"version":3,"file":"routesUtils.d.ts","sourceRoot":"","sources":["../../src/utils/routesUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,qBAAqB,CAAC;AAErD;;GAEG;AACH,wBAAgB,UAAU,CACxB,KAAK,EAAE,MAAM,GAAG,SAAS,EACzB,KAAK,EAAE,MAAM,GAAG,SAAS,GACxB,OAAO,CAOT;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,EAChC,OAAO,EACP,MAAM,EAAE,aAAa,GACtB,EAAE;IACD,MAAM,EAAE,WAAW,EAAE,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;CACjB,GAAG,WAAW,GAAG,SAAS,CAwB1B;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,IAAI,WAAW,GAAG,SAAS,CAM1D"}
@@ -4,30 +4,51 @@
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 GeneratedRoutes from '@generated/routes';
8
7
  import { useMemo } from 'react';
9
- function isHomePageRoute(route) {
10
- return route.path === '/' && route.exact === true;
11
- }
12
- function isHomeParentRoute(route) {
13
- return route.path === '/' && route.exact === false;
8
+ import generatedRoutes from '@generated/routes';
9
+ import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
10
+ /**
11
+ * Compare the 2 paths, case insensitive and ignoring trailing slash
12
+ */
13
+ export function isSamePath(path1, path2) {
14
+ const normalize = (pathname) => (!pathname || pathname?.endsWith('/')
15
+ ? pathname
16
+ : `${pathname}/`)?.toLowerCase();
17
+ return normalize(path1) === normalize(path2);
14
18
  }
15
- // Note that all sites don't always have a homepage in practice
16
- // See https://github.com/facebook/docusaurus/pull/6517#issuecomment-1048709116
17
- export function findHomePageRoute(routes = GeneratedRoutes) {
18
- if (routes.length === 0) {
19
- return undefined;
19
+ /**
20
+ * Note that sites don't always have a homepage in practice, so we can't assume
21
+ * that linking to '/' is always safe.
22
+ * @see https://github.com/facebook/docusaurus/pull/6517#issuecomment-1048709116
23
+ */
24
+ export function findHomePageRoute({ baseUrl, routes: initialRoutes, }) {
25
+ function isHomePageRoute(route) {
26
+ return route.path === baseUrl && route.exact === true;
27
+ }
28
+ function isHomeParentRoute(route) {
29
+ return route.path === baseUrl && !route.exact;
20
30
  }
21
- const homePage = routes.find(isHomePageRoute);
22
- if (homePage) {
23
- return homePage;
31
+ function doFindHomePageRoute(routes) {
32
+ if (routes.length === 0) {
33
+ return undefined;
34
+ }
35
+ const homePage = routes.find(isHomePageRoute);
36
+ if (homePage) {
37
+ return homePage;
38
+ }
39
+ const indexSubRoutes = routes
40
+ .filter(isHomeParentRoute)
41
+ .flatMap((route) => route.routes ?? []);
42
+ return doFindHomePageRoute(indexSubRoutes);
24
43
  }
25
- const indexSubRoutes = routes
26
- .filter(isHomeParentRoute)
27
- .flatMap((route) => { var _a; return (_a = route.routes) !== null && _a !== void 0 ? _a : []; });
28
- return findHomePageRoute(indexSubRoutes);
44
+ return doFindHomePageRoute(initialRoutes);
29
45
  }
46
+ /**
47
+ * Fetches the route that points to "/". Use this instead of the naive "/",
48
+ * because the homepage may not exist.
49
+ */
30
50
  export function useHomePageRoute() {
31
- return useMemo(() => findHomePageRoute(), []);
51
+ const { baseUrl } = useDocusaurusContext().siteConfig;
52
+ return useMemo(() => findHomePageRoute({ routes: generatedRoutes, baseUrl }), [baseUrl]);
32
53
  }
33
54
  //# sourceMappingURL=routesUtils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"routesUtils.js","sourceRoot":"","sources":["../../src/utils/routesUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,eAA6B,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAC,OAAO,EAAC,MAAM,OAAO,CAAC;AAE9B,SAAS,eAAe,CAAC,KAAY;IACnC,OAAO,KAAK,CAAC,IAAI,KAAK,GAAG,IAAI,KAAK,CAAC,KAAK,KAAK,IAAI,CAAC;AACpD,CAAC;AAED,SAAS,iBAAiB,CAAC,KAAY;IACrC,OAAO,KAAK,CAAC,IAAI,KAAK,GAAG,IAAI,KAAK,CAAC,KAAK,KAAK,KAAK,CAAC;AACrD,CAAC;AAED,+DAA+D;AAC/D,+EAA+E;AAC/E,MAAM,UAAU,iBAAiB,CAC/B,SAAkB,eAAe;IAEjC,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE;QACvB,OAAO,SAAS,CAAC;KAClB;IACD,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;IAC9C,IAAI,QAAQ,EAAE;QACZ,OAAO,QAAQ,CAAC;KACjB;IACD,MAAM,cAAc,GAAG,MAAM;SAC1B,MAAM,CAAC,iBAAiB,CAAC;SACzB,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,WAAC,OAAA,MAAA,KAAK,CAAC,MAAM,mCAAI,EAAE,CAAA,EAAA,CAAC,CAAC;IAC1C,OAAO,iBAAiB,CAAC,cAAc,CAAC,CAAC;AAC3C,CAAC;AAED,MAAM,UAAU,gBAAgB;IAC9B,OAAO,OAAO,CAAC,GAAG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AAc,GAAG,MAAM;aAC1B,MAAM,CAAC,iBAAiB,CAAC;aACzB,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC;QAC1C,OAAO,mBAAmB,CAAC,cAAc,CAAC,CAAC;IAC7C,CAAC;IAED,OAAO,mBAAmB,CAAC,aAAa,CAAC,CAAC;AAC5C,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,gBAAgB;IAC9B,MAAM,EAAC,OAAO,EAAC,GAAG,oBAAoB,EAAE,CAAC,UAAU,CAAC;IACpD,OAAO,OAAO,CACZ,GAAG,EAAE,CAAC,iBAAiB,CAAC,EAAC,MAAM,EAAE,eAAe,EAAE,OAAO,EAAC,CAAC,EAC3D,CAAC,OAAO,CAAC,CACV,CAAC;AACJ,CAAC"}
@@ -5,49 +5,79 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import React, { type ReactNode } from 'react';
8
- /**
9
- * We need a way to update the scroll position while ignoring scroll events
10
- * without affecting Navbar/BackToTop visibility
11
- *
12
- * This API permits to temporarily disable/ignore scroll events
13
- * Motivated by https://github.com/facebook/docusaurus/pull/5618
14
- */
15
8
  declare type ScrollController = {
16
- /**
17
- * A boolean ref tracking whether scroll events are enabled
18
- */
9
+ /** A boolean ref tracking whether scroll events are enabled. */
19
10
  scrollEventsEnabledRef: React.MutableRefObject<boolean>;
20
- /**
21
- * Enables scroll events in `useScrollPosition`
22
- */
11
+ /** Enable scroll events in `useScrollPosition`. */
23
12
  enableScrollEvents: () => void;
24
- /**
25
- * Disables scroll events in `useScrollPosition`
26
- */
13
+ /** Disable scroll events in `useScrollPosition`. */
27
14
  disableScrollEvents: () => void;
28
15
  };
29
16
  export declare function ScrollControllerProvider({ children, }: {
30
17
  children: ReactNode;
31
18
  }): JSX.Element;
19
+ /**
20
+ * We need a way to update the scroll position while ignoring scroll events
21
+ * so as not to toggle Navbar/BackToTop visibility.
22
+ *
23
+ * This API permits to temporarily disable/ignore scroll events. Motivated by
24
+ * https://github.com/facebook/docusaurus/pull/5618
25
+ */
32
26
  export declare function useScrollController(): ScrollController;
33
27
  declare type ScrollPosition = {
34
28
  scrollX: number;
35
29
  scrollY: number;
36
30
  };
31
+ /**
32
+ * This hook fires an effect when the scroll position changes. The effect will
33
+ * be provided with the before/after scroll positions. Note that the effect may
34
+ * not be always run: if scrolling is disabled through `useScrollController`, it
35
+ * will be a no-op.
36
+ *
37
+ * @see {@link useScrollController}
38
+ */
37
39
  export declare function useScrollPosition(effect: (position: ScrollPosition, lastPosition: ScrollPosition | null) => void, deps?: unknown[]): void;
38
- declare type UseScrollPositionBlockerReturn = {
40
+ /**
41
+ * This hook permits to "block" the scroll position of a DOM element.
42
+ * The idea is that we should be able to update DOM content above this element
43
+ * but the screen position of this element should not change.
44
+ *
45
+ * Feature motivated by the Tabs groups: clicking on a tab may affect tabs of
46
+ * the same group upper in the tree, yet to avoid a bad UX, the clicked tab must
47
+ * remain under the user mouse.
48
+ *
49
+ * @see https://github.com/facebook/docusaurus/pull/5618
50
+ */
51
+ export declare function useScrollPositionBlocker(): {
52
+ /**
53
+ * Takes an element, and keeps its screen position no matter what's getting
54
+ * rendered above it, until the next render.
55
+ */
39
56
  blockElementScrollPositionUntilNextRender: (el: HTMLElement) => void;
40
57
  };
58
+ declare type CancelScrollTop = () => void;
41
59
  /**
42
- * This hook permits to "block" the scroll position of a dom element
43
- * The idea is that we should be able to update DOM content above this element
44
- * but the screen position of this element should not change
60
+ * A "smart polyfill" of `window.scrollTo({ top, behavior: "smooth" })`.
61
+ * This currently always uses a polyfilled implementation unless
62
+ * `scroll-behavior: smooth` has been set in CSS, because native support
63
+ * detection for scroll behavior seems unreliable.
45
64
  *
46
- * Feature motivated by the Tabs groups:
47
- * clicking on a tab may affect tabs of the same group upper in the tree
48
- * Yet to avoid a bad UX, the clicked tab must remain under the user mouse!
49
- * See GIF here: https://github.com/facebook/docusaurus/pull/5618
65
+ * This hook does not do anything by itself: it returns a start and a stop
66
+ * handle. You can execute either handle at any time.
50
67
  */
51
- export declare function useScrollPositionBlocker(): UseScrollPositionBlockerReturn;
68
+ export declare function useSmoothScrollTo(): {
69
+ /**
70
+ * Start the scroll.
71
+ *
72
+ * @param top The final scroll top position.
73
+ */
74
+ startScroll: (top: number) => void;
75
+ /**
76
+ * A cancel function, because the non-native smooth scroll-top
77
+ * implementation must be interrupted if user scrolls down. If there's no
78
+ * existing animation or the scroll is using native behavior, this is a no-op.
79
+ */
80
+ cancelScroll: CancelScrollTop;
81
+ };
52
82
  export {};
53
83
  //# sourceMappingURL=scrollUtils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"scrollUtils.d.ts","sourceRoot":"","sources":["../../src/utils/scrollUtils.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,EAEZ,KAAK,SAAS,EAOf,MAAM,OAAO,CAAC;AAIf;;;;;;GAMG;AACH,aAAK,gBAAgB,GAAG;IACtB;;OAEG;IACH,sBAAsB,EAAE,KAAK,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;IACxD;;OAEG;IACH,kBAAkB,EAAE,MAAM,IAAI,CAAC;IAC/B;;OAEG;IACH,mBAAmB,EAAE,MAAM,IAAI,CAAC;CACjC,CAAC;AAuBF,wBAAgB,wBAAwB,CAAC,EACvC,QAAQ,GACT,EAAE;IACD,QAAQ,EAAE,SAAS,CAAC;CACrB,GAAG,GAAG,CAAC,OAAO,CAMd;AAED,wBAAgB,mBAAmB,IAAI,gBAAgB,CAQtD;AAUD,aAAK,cAAc,GAAG;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAC,CAAC;AAEzD,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,CACN,QAAQ,EAAE,cAAc,EACxB,YAAY,EAAE,cAAc,GAAG,IAAI,KAChC,IAAI,EACT,IAAI,GAAE,OAAO,EAAO,GACnB,IAAI,CAkCN;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AgB,iBAAiB,IAAI;IACnC;;;;OAIG;IACH,WAAW,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC;;;;OAIG;IACH,YAAY,EAAE,eAAe,CAAC;CAC/B,CAoBA"}
@@ -4,9 +4,10 @@
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, { createContext, useCallback, useContext, useEffect, useLayoutEffect, useMemo, useRef, } from 'react';
8
- import { useDynamicCallback } from './reactUtils';
7
+ import React, { useCallback, useContext, useEffect, useLayoutEffect, useMemo, useRef, } from 'react';
8
+ import { useDynamicCallback, ReactContextError } from './reactUtils';
9
9
  import ExecutionEnvironment from '@docusaurus/ExecutionEnvironment';
10
+ import useIsBrowser from '@docusaurus/useIsBrowser';
10
11
  function useScrollControllerContextValue() {
11
12
  const scrollEventsEnabledRef = useRef(true);
12
13
  return useMemo(() => ({
@@ -19,14 +20,22 @@ function useScrollControllerContextValue() {
19
20
  },
20
21
  }), []);
21
22
  }
22
- const ScrollMonitorContext = createContext(undefined);
23
+ const ScrollMonitorContext = React.createContext(undefined);
23
24
  export function ScrollControllerProvider({ children, }) {
24
- return (React.createElement(ScrollMonitorContext.Provider, { value: useScrollControllerContextValue() }, children));
25
+ const value = useScrollControllerContextValue();
26
+ return (React.createElement(ScrollMonitorContext.Provider, { value: value }, children));
25
27
  }
28
+ /**
29
+ * We need a way to update the scroll position while ignoring scroll events
30
+ * so as not to toggle Navbar/BackToTop visibility.
31
+ *
32
+ * This API permits to temporarily disable/ignore scroll events. Motivated by
33
+ * https://github.com/facebook/docusaurus/pull/5618
34
+ */
26
35
  export function useScrollController() {
27
36
  const context = useContext(ScrollMonitorContext);
28
37
  if (context == null) {
29
- throw new Error('"useScrollController" is used but no context provider was found in the React tree.');
38
+ throw new ReactContextError('ScrollControllerProvider');
30
39
  }
31
40
  return context;
32
41
  }
@@ -36,6 +45,14 @@ const getScrollPosition = () => ExecutionEnvironment.canUseDOM
36
45
  scrollY: window.pageYOffset,
37
46
  }
38
47
  : null;
48
+ /**
49
+ * This hook fires an effect when the scroll position changes. The effect will
50
+ * be provided with the before/after scroll positions. Note that the effect may
51
+ * not be always run: if scrolling is disabled through `useScrollController`, it
52
+ * will be a no-op.
53
+ *
54
+ * @see {@link useScrollController}
55
+ */
39
56
  export function useScrollPosition(effect, deps = []) {
40
57
  const { scrollEventsEnabledRef } = useScrollController();
41
58
  const lastPositionRef = useRef(getScrollPosition());
@@ -57,12 +74,8 @@ export function useScrollPosition(effect, deps = []) {
57
74
  handleScroll();
58
75
  window.addEventListener('scroll', handleScroll, opts);
59
76
  return () => window.removeEventListener('scroll', handleScroll, opts);
60
- }, [
61
- dynamicEffect,
62
- scrollEventsEnabledRef,
63
77
  // eslint-disable-next-line react-hooks/exhaustive-deps
64
- ...deps,
65
- ]);
78
+ }, [dynamicEffect, scrollEventsEnabledRef, ...deps]);
66
79
  }
67
80
  function useScrollPositionSaver() {
68
81
  const lastElementRef = useRef({
@@ -91,14 +104,15 @@ function useScrollPositionSaver() {
91
104
  return useMemo(() => ({ save, restore }), [restore, save]);
92
105
  }
93
106
  /**
94
- * This hook permits to "block" the scroll position of a dom element
107
+ * This hook permits to "block" the scroll position of a DOM element.
95
108
  * The idea is that we should be able to update DOM content above this element
96
- * but the screen position of this element should not change
109
+ * but the screen position of this element should not change.
110
+ *
111
+ * Feature motivated by the Tabs groups: clicking on a tab may affect tabs of
112
+ * the same group upper in the tree, yet to avoid a bad UX, the clicked tab must
113
+ * remain under the user mouse.
97
114
  *
98
- * Feature motivated by the Tabs groups:
99
- * clicking on a tab may affect tabs of the same group upper in the tree
100
- * Yet to avoid a bad UX, the clicked tab must remain under the user mouse!
101
- * See GIF here: https://github.com/facebook/docusaurus/pull/5618
115
+ * @see https://github.com/facebook/docusaurus/pull/5618
102
116
  */
103
117
  export function useScrollPositionBlocker() {
104
118
  const scrollController = useScrollController();
@@ -110,9 +124,9 @@ export function useScrollPositionBlocker() {
110
124
  nextLayoutEffectCallbackRef.current = () => {
111
125
  const { restored } = scrollPositionSaver.restore();
112
126
  nextLayoutEffectCallbackRef.current = undefined;
113
- // Restoring the former scroll position will trigger a scroll event
114
- // We need to wait for next scroll event to happen
115
- // before enabling again the scrollController events
127
+ // Restoring the former scroll position will trigger a scroll event. We
128
+ // need to wait for next scroll event to happen before enabling the
129
+ // scrollController events again.
116
130
  if (restored) {
117
131
  const handleScrollRestoreEvent = () => {
118
132
  scrollController.enableScrollEvents();
@@ -126,11 +140,61 @@ export function useScrollPositionBlocker() {
126
140
  };
127
141
  }, [scrollController, scrollPositionSaver]);
128
142
  useLayoutEffect(() => {
129
- var _a;
130
- (_a = nextLayoutEffectCallbackRef.current) === null || _a === void 0 ? void 0 : _a.call(nextLayoutEffectCallbackRef);
143
+ nextLayoutEffectCallbackRef.current?.();
131
144
  });
132
145
  return {
133
146
  blockElementScrollPositionUntilNextRender,
134
147
  };
135
148
  }
149
+ function smoothScrollNative(top) {
150
+ window.scrollTo({ top, behavior: 'smooth' });
151
+ return () => {
152
+ // Nothing to cancel, it's natively cancelled if user tries to scroll down
153
+ };
154
+ }
155
+ function smoothScrollPolyfill(top) {
156
+ let raf = null;
157
+ const isUpScroll = document.documentElement.scrollTop > top;
158
+ function rafRecursion() {
159
+ const currentScroll = document.documentElement.scrollTop;
160
+ if ((isUpScroll && currentScroll > top) ||
161
+ (!isUpScroll && currentScroll < top)) {
162
+ raf = requestAnimationFrame(rafRecursion);
163
+ window.scrollTo(0, Math.floor((currentScroll - top) * 0.85) + top);
164
+ }
165
+ }
166
+ rafRecursion();
167
+ // Break the recursion. Prevents the user from "fighting" against that
168
+ // recursion producing a weird UX
169
+ return () => raf && cancelAnimationFrame(raf);
170
+ }
171
+ /**
172
+ * A "smart polyfill" of `window.scrollTo({ top, behavior: "smooth" })`.
173
+ * This currently always uses a polyfilled implementation unless
174
+ * `scroll-behavior: smooth` has been set in CSS, because native support
175
+ * detection for scroll behavior seems unreliable.
176
+ *
177
+ * This hook does not do anything by itself: it returns a start and a stop
178
+ * handle. You can execute either handle at any time.
179
+ */
180
+ export function useSmoothScrollTo() {
181
+ const cancelRef = useRef(null);
182
+ const isBrowser = useIsBrowser();
183
+ // Not all have support for smooth scrolling (particularly Safari mobile iOS)
184
+ // TODO proper detection is currently unreliable!
185
+ // see https://github.com/wessberg/scroll-behavior-polyfill/issues/16
186
+ // For now, we only use native scroll behavior if smooth is already set,
187
+ // because otherwise the polyfill produces a weird UX when both CSS and JS try
188
+ // to scroll a page, and they cancel each other.
189
+ const supportsNativeSmoothScrolling = isBrowser &&
190
+ getComputedStyle(document.documentElement).scrollBehavior === 'smooth';
191
+ return {
192
+ startScroll: (top) => {
193
+ cancelRef.current = supportsNativeSmoothScrolling
194
+ ? smoothScrollNative(top)
195
+ : smoothScrollPolyfill(top);
196
+ },
197
+ cancelScroll: () => cancelRef.current?.(),
198
+ };
199
+ }
136
200
  //# sourceMappingURL=scrollUtils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"scrollUtils.js","sourceRoot":"","sources":["../../src/utils/scrollUtils.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,EACZ,aAAa,EAEb,WAAW,EACX,UAAU,EACV,SAAS,EACT,eAAe,EACf,OAAO,EACP,MAAM,GACP,MAAM,OAAO,CAAC;AACf,OAAO,EAAC,kBAAkB,EAAC,MAAM,cAAc,CAAC;AAChD,OAAO,oBAAoB,MAAM,kCAAkC,CAAC;AAwBpE,SAAS,+BAA+B;IACtC,MAAM,sBAAsB,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;IAE5C,OAAO,OAAO,CACZ,GAAG,EAAE,CAAC,CAAC;QACL,sBAAsB;QACtB,kBAAkB,EAAE,GAAG,EAAE;YACvB,sBAAsB,CAAC,OAAO,GAAG,IAAI,CAAC;QACxC,CAAC;QACD,mBAAmB,EAAE,GAAG,EAAE;YACxB,sBAAsB,CAAC,OAAO,GAAG,KAAK,CAAC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G,CAAC,CAAC;QAChC,CAAC;QACD,YAAY,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,OAAO,EAAE,EAAE;KAC1C,CAAC;AACJ,CAAC"}
@@ -5,5 +5,17 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  export declare const DEFAULT_SEARCH_TAG = "default";
8
+ /** The search tag to append as each doc's metadata. */
8
9
  export declare function docVersionSearchTag(pluginId: string, versionName: string): string;
10
+ /**
11
+ * Gets the relevant context information for contextual search.
12
+ *
13
+ * The value is generic and not coupled to Algolia/DocSearch, since we may want
14
+ * to support multiple search engines, or allowing users to use their own search
15
+ * engine solution.
16
+ */
17
+ export declare function useContextualSearchFilters(): {
18
+ locale: string;
19
+ tags: string[];
20
+ };
9
21
  //# sourceMappingURL=searchUtils.d.ts.map