@docusaurus/theme-common 2.0.0-beta.15d451942 → 2.0.0-beta.16

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 (211) hide show
  1. package/lib/components/Collapsible/index.d.ts +36 -0
  2. package/lib/components/Collapsible/index.d.ts.map +1 -0
  3. package/lib/components/Collapsible/index.js +144 -0
  4. package/lib/components/Collapsible/index.js.map +1 -0
  5. package/lib/components/Details/index.d.ts +12 -0
  6. package/lib/components/Details/index.d.ts.map +1 -0
  7. package/lib/components/Details/index.js +66 -0
  8. package/lib/components/Details/index.js.map +1 -0
  9. package/lib/components/Details/styles.module.css +58 -0
  10. package/lib/{utils/useChangeRoute.d.ts → hooks/styles.css} +4 -1
  11. package/lib/hooks/useHideableNavbar.d.ts +13 -0
  12. package/lib/hooks/useHideableNavbar.d.ts.map +1 -0
  13. package/lib/hooks/useHideableNavbar.js +59 -0
  14. package/lib/hooks/useHideableNavbar.js.map +1 -0
  15. package/lib/hooks/useKeyboardNavigation.d.ts +10 -0
  16. package/lib/hooks/useKeyboardNavigation.d.ts.map +1 -0
  17. package/lib/hooks/useKeyboardNavigation.js +31 -0
  18. package/lib/hooks/useKeyboardNavigation.js.map +1 -0
  19. package/{src/utils/docsUtils.ts → lib/hooks/useLockBodyScroll.d.ts} +2 -5
  20. package/lib/hooks/useLockBodyScroll.d.ts.map +1 -0
  21. package/lib/hooks/useLockBodyScroll.js +16 -0
  22. package/lib/hooks/useLockBodyScroll.js.map +1 -0
  23. package/lib/hooks/usePrismTheme.d.ts +9 -0
  24. package/lib/hooks/usePrismTheme.d.ts.map +1 -0
  25. package/lib/hooks/usePrismTheme.js +18 -0
  26. package/lib/hooks/usePrismTheme.js.map +1 -0
  27. package/lib/hooks/useSearchPage.d.ts +14 -0
  28. package/lib/hooks/useSearchPage.d.ts.map +1 -0
  29. package/lib/hooks/useSearchPage.js +43 -0
  30. package/lib/hooks/useSearchPage.js.map +1 -0
  31. package/lib/hooks/useWindowSize.d.ts +15 -0
  32. package/lib/hooks/useWindowSize.d.ts.map +1 -0
  33. package/lib/hooks/useWindowSize.js +56 -0
  34. package/lib/hooks/useWindowSize.js.map +1 -0
  35. package/lib/index.d.ts +35 -4
  36. package/lib/index.d.ts.map +1 -0
  37. package/lib/index.js +29 -3
  38. package/lib/index.js.map +1 -0
  39. package/lib/utils/ThemeClassNames.d.ts +40 -12
  40. package/lib/utils/ThemeClassNames.d.ts.map +1 -0
  41. package/lib/utils/ThemeClassNames.js +41 -3
  42. package/lib/utils/ThemeClassNames.js.map +1 -0
  43. package/lib/utils/announcementBarUtils.d.ts +18 -0
  44. package/lib/utils/announcementBarUtils.d.ts.map +1 -0
  45. package/lib/utils/announcementBarUtils.js +71 -0
  46. package/lib/utils/announcementBarUtils.js.map +1 -0
  47. package/lib/utils/codeBlockUtils.d.ts +10 -0
  48. package/lib/utils/codeBlockUtils.d.ts.map +1 -0
  49. package/lib/utils/codeBlockUtils.js +125 -2
  50. package/lib/utils/codeBlockUtils.js.map +1 -0
  51. package/lib/utils/colorModeUtils.d.ts +18 -0
  52. package/lib/utils/colorModeUtils.d.ts.map +1 -0
  53. package/lib/utils/colorModeUtils.js +106 -0
  54. package/lib/utils/colorModeUtils.js.map +1 -0
  55. package/lib/utils/docSidebarItemsExpandedState.d.ts +17 -0
  56. package/lib/utils/docSidebarItemsExpandedState.d.ts.map +1 -0
  57. package/lib/utils/docSidebarItemsExpandedState.js +22 -0
  58. package/lib/utils/docSidebarItemsExpandedState.js.map +1 -0
  59. package/lib/utils/docsPreferredVersion/DocsPreferredVersionProvider.d.ts +3 -2
  60. package/lib/utils/docsPreferredVersion/DocsPreferredVersionProvider.d.ts.map +1 -0
  61. package/lib/utils/docsPreferredVersion/DocsPreferredVersionProvider.js +8 -11
  62. package/lib/utils/docsPreferredVersion/DocsPreferredVersionProvider.js.map +1 -0
  63. package/lib/utils/docsPreferredVersion/DocsPreferredVersionStorage.d.ts +2 -1
  64. package/lib/utils/docsPreferredVersion/DocsPreferredVersionStorage.d.ts.map +1 -0
  65. package/lib/utils/docsPreferredVersion/DocsPreferredVersionStorage.js +2 -3
  66. package/lib/utils/docsPreferredVersion/DocsPreferredVersionStorage.js.map +1 -0
  67. package/lib/utils/docsPreferredVersion/useDocsPreferredVersion.d.ts +12 -3
  68. package/lib/utils/docsPreferredVersion/useDocsPreferredVersion.d.ts.map +1 -0
  69. package/lib/utils/docsPreferredVersion/useDocsPreferredVersion.js +3 -3
  70. package/lib/utils/docsPreferredVersion/useDocsPreferredVersion.js.map +1 -0
  71. package/lib/utils/docsUtils.d.ts +26 -0
  72. package/lib/utils/docsUtils.d.ts.map +1 -0
  73. package/lib/utils/docsUtils.js +136 -1
  74. package/lib/utils/docsUtils.js.map +1 -0
  75. package/lib/utils/generalUtils.d.ts +7 -0
  76. package/lib/utils/generalUtils.d.ts.map +1 -0
  77. package/lib/utils/generalUtils.js +3 -2
  78. package/lib/utils/generalUtils.js.map +1 -0
  79. package/lib/utils/historyUtils.d.ts +23 -0
  80. package/lib/utils/historyUtils.d.ts.map +1 -0
  81. package/lib/utils/historyUtils.js +41 -0
  82. package/lib/utils/historyUtils.js.map +1 -0
  83. package/lib/utils/jsUtils.d.ts +23 -0
  84. package/lib/utils/jsUtils.d.ts.map +1 -0
  85. package/lib/utils/jsUtils.js +29 -0
  86. package/lib/utils/jsUtils.js.map +1 -0
  87. package/lib/utils/mobileSecondaryMenu.d.ts +21 -0
  88. package/lib/utils/mobileSecondaryMenu.d.ts.map +1 -0
  89. package/lib/utils/mobileSecondaryMenu.js +50 -0
  90. package/lib/utils/mobileSecondaryMenu.js.map +1 -0
  91. package/lib/utils/pathUtils.d.ts +1 -0
  92. package/lib/utils/pathUtils.d.ts.map +1 -0
  93. package/lib/utils/pathUtils.js +6 -2
  94. package/lib/utils/pathUtils.js.map +1 -0
  95. package/lib/utils/reactUtils.d.ts +28 -0
  96. package/lib/utils/reactUtils.d.ts.map +1 -0
  97. package/lib/utils/reactUtils.js +36 -0
  98. package/lib/utils/reactUtils.js.map +1 -0
  99. package/lib/utils/regexpUtils.d.ts +11 -0
  100. package/lib/utils/regexpUtils.d.ts.map +1 -0
  101. package/lib/utils/regexpUtils.js +17 -0
  102. package/lib/utils/regexpUtils.js.map +1 -0
  103. package/lib/utils/routesUtils.d.ts +11 -0
  104. package/lib/utils/routesUtils.d.ts.map +1 -0
  105. package/lib/utils/routesUtils.js +33 -0
  106. package/lib/utils/routesUtils.js.map +1 -0
  107. package/lib/utils/scrollUtils.d.ts +53 -0
  108. package/lib/utils/scrollUtils.d.ts.map +1 -0
  109. package/lib/utils/scrollUtils.js +136 -0
  110. package/lib/utils/scrollUtils.js.map +1 -0
  111. package/lib/utils/searchUtils.d.ts +1 -0
  112. package/lib/utils/searchUtils.d.ts.map +1 -0
  113. package/lib/utils/searchUtils.js +1 -0
  114. package/lib/utils/searchUtils.js.map +1 -0
  115. package/lib/utils/storageUtils.d.ts +5 -0
  116. package/lib/utils/storageUtils.d.ts.map +1 -0
  117. package/lib/utils/storageUtils.js +41 -16
  118. package/lib/utils/storageUtils.js.map +1 -0
  119. package/lib/utils/tabGroupChoiceUtils.d.ts +19 -0
  120. package/lib/utils/tabGroupChoiceUtils.d.ts.map +1 -0
  121. package/lib/utils/tabGroupChoiceUtils.js +54 -0
  122. package/lib/utils/tabGroupChoiceUtils.js.map +1 -0
  123. package/lib/utils/tagsUtils.d.ts +19 -0
  124. package/lib/utils/tagsUtils.d.ts.map +1 -0
  125. package/lib/utils/tagsUtils.js +34 -0
  126. package/lib/utils/tagsUtils.js.map +1 -0
  127. package/lib/utils/tocUtils.d.ts +20 -0
  128. package/lib/utils/tocUtils.d.ts.map +1 -0
  129. package/lib/utils/tocUtils.js +73 -0
  130. package/lib/utils/tocUtils.js.map +1 -0
  131. package/lib/utils/useAlternatePageUtils.d.ts +1 -0
  132. package/lib/utils/useAlternatePageUtils.d.ts.map +1 -0
  133. package/lib/utils/useAlternatePageUtils.js +3 -1
  134. package/lib/utils/useAlternatePageUtils.js.map +1 -0
  135. package/lib/utils/useContextualSearchFilters.d.ts +12 -0
  136. package/lib/utils/useContextualSearchFilters.d.ts.map +1 -0
  137. package/lib/utils/useContextualSearchFilters.js +37 -0
  138. package/lib/utils/useContextualSearchFilters.js.map +1 -0
  139. package/lib/utils/useLocalPathname.d.ts +8 -0
  140. package/lib/utils/useLocalPathname.d.ts.map +1 -0
  141. package/lib/utils/useLocalPathname.js +17 -0
  142. package/lib/utils/useLocalPathname.js.map +1 -0
  143. package/lib/utils/useLocationChange.d.ts +15 -0
  144. package/lib/utils/useLocationChange.d.ts.map +1 -0
  145. package/lib/utils/useLocationChange.js +27 -0
  146. package/lib/utils/useLocationChange.js.map +1 -0
  147. package/lib/utils/usePluralForm.d.ts +1 -0
  148. package/lib/utils/usePluralForm.d.ts.map +1 -0
  149. package/lib/utils/usePluralForm.js +29 -25
  150. package/lib/utils/usePluralForm.js.map +1 -0
  151. package/lib/utils/usePrevious.d.ts +8 -0
  152. package/lib/utils/usePrevious.d.ts.map +1 -0
  153. package/lib/utils/usePrevious.js +16 -0
  154. package/lib/utils/usePrevious.js.map +1 -0
  155. package/lib/utils/useTOCHighlight.d.ts +14 -0
  156. package/lib/utils/useTOCHighlight.d.ts.map +1 -0
  157. package/lib/utils/useTOCHighlight.js +128 -0
  158. package/lib/utils/useTOCHighlight.js.map +1 -0
  159. package/lib/utils/useThemeConfig.d.ts +36 -11
  160. package/lib/utils/useThemeConfig.d.ts.map +1 -0
  161. package/lib/utils/useThemeConfig.js +1 -0
  162. package/lib/utils/useThemeConfig.js.map +1 -0
  163. package/package.json +19 -13
  164. package/src/components/Collapsible/index.tsx +247 -0
  165. package/src/components/Details/index.tsx +102 -0
  166. package/src/components/Details/styles.module.css +58 -0
  167. package/src/hooks/styles.css +10 -0
  168. package/src/hooks/useHideableNavbar.ts +77 -0
  169. package/src/hooks/useKeyboardNavigation.ts +37 -0
  170. package/src/hooks/useLockBodyScroll.ts +18 -0
  171. package/src/hooks/usePrismTheme.ts +20 -0
  172. package/src/hooks/useSearchPage.ts +66 -0
  173. package/src/hooks/useWindowSize.ts +70 -0
  174. package/src/index.ts +102 -4
  175. package/src/types.d.ts +0 -2
  176. package/src/utils/ThemeClassNames.ts +46 -4
  177. package/src/utils/announcementBarUtils.tsx +121 -0
  178. package/src/utils/codeBlockUtils.ts +153 -2
  179. package/src/utils/colorModeUtils.tsx +156 -0
  180. package/src/utils/docSidebarItemsExpandedState.tsx +41 -0
  181. package/src/utils/docsPreferredVersion/DocsPreferredVersionProvider.tsx +16 -14
  182. package/src/utils/docsPreferredVersion/DocsPreferredVersionStorage.ts +3 -4
  183. package/src/utils/docsPreferredVersion/useDocsPreferredVersion.ts +18 -14
  184. package/src/utils/docsUtils.tsx +230 -0
  185. package/src/utils/generalUtils.ts +3 -2
  186. package/src/utils/historyUtils.ts +51 -0
  187. package/src/utils/jsUtils.ts +36 -0
  188. package/src/utils/mobileSecondaryMenu.tsx +115 -0
  189. package/src/utils/pathUtils.ts +6 -4
  190. package/src/utils/reactUtils.tsx +43 -0
  191. package/src/utils/regexpUtils.ts +23 -0
  192. package/src/utils/routesUtils.ts +39 -0
  193. package/src/utils/scrollUtils.tsx +237 -0
  194. package/src/utils/storageUtils.ts +40 -15
  195. package/src/utils/tabGroupChoiceUtils.tsx +90 -0
  196. package/src/utils/tagsUtils.ts +48 -0
  197. package/src/utils/tocUtils.ts +108 -0
  198. package/src/utils/useAlternatePageUtils.ts +13 -4
  199. package/src/utils/useContextualSearchFilters.ts +53 -0
  200. package/src/utils/useLocalPathname.ts +20 -0
  201. package/src/utils/useLocationChange.ts +39 -0
  202. package/src/utils/usePluralForm.ts +35 -28
  203. package/src/utils/usePrevious.ts +19 -0
  204. package/src/utils/useTOCHighlight.ts +183 -0
  205. package/src/utils/useThemeConfig.ts +38 -11
  206. package/lib/.tsbuildinfo +0 -4159
  207. package/lib/utils/useChangeRoute.js +0 -18
  208. package/src/utils/__tests__/codeBlockUtils.test.ts +0 -54
  209. package/src/utils/__tests__/pathUtils.test.ts +0 -32
  210. package/src/utils/useChangeRoute.ts +0 -21
  211. package/tsconfig.json +0 -10
@@ -0,0 +1 @@
1
+ {"version":3,"file":"historyUtils.js","sourceRoot":"","sources":["../../src/utils/historyUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAC,SAAS,EAAE,MAAM,EAAC,MAAM,OAAO,CAAC;AACxC,OAAO,EAAC,UAAU,EAAC,MAAM,oBAAoB,CAAC;AAK9C;;;;GAIG;AACH,MAAM,UAAU,uBAAuB,CAAC,OAA4B;IAClE,MAAM,EAAC,KAAK,EAAC,GAAG,UAAU,EAAE,CAAC;IAE7B,mEAAmE;IACnE,MAAM,cAAc,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC;IACvC,SAAS,CAAC,GAAG,EAAE;QACb,cAAc,CAAC,OAAO,GAAG,OAAO,CAAC;IACnC,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IAEd,SAAS,CACP,GAAG,EAAE;IACH,kFAAkF;IAClF,KAAK,CAAC,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,CAAC,cAAc,CAAC,OAAO,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,EACvE,CAAC,KAAK,EAAE,cAAc,CAAC,CACxB,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAAC,OAA4B;IAC/D,uBAAuB,CAAC,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE;QAC3C,IAAI,MAAM,KAAK,KAAK,EAAE;YACpB,uDAAuD;YACvD,OAAO,OAAO,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;SAClC;QACD,uCAAuC;QACvC,OAAO,SAAS,CAAC;IACnB,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,23 @@
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
+ * Gets the duplicate values in an array.
9
+ * @param arr The array.
10
+ * @param comparator Compares two values and returns `true` if they are equal
11
+ * (duplicated).
12
+ * @returns Value of the elements `v` that have a preceding element `u` where
13
+ * `comparator(u, v) === true`. Values within the returned array are not
14
+ * guaranteed to be unique.
15
+ */
16
+ export declare function duplicates<T>(arr: readonly T[], comparator?: (a: T, b: T) => boolean): T[];
17
+ /**
18
+ * Remove duplicate array items (similar to _.uniq)
19
+ * @param arr The array.
20
+ * @returns An array with duplicate elements removed by reference comparison.
21
+ */
22
+ export declare function uniq<T>(arr: T[]): T[];
23
+ //# sourceMappingURL=jsUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsUtils.d.ts","sourceRoot":"","sources":["../../src/utils/jsUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAC1B,GAAG,EAAE,SAAS,CAAC,EAAE,EACjB,UAAU,GAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,OAA2B,GACtD,CAAC,EAAE,CAIL;AAED;;;;GAIG;AACH,wBAAgB,IAAI,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,CAGrC"}
@@ -0,0 +1,29 @@
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
+ // A replacement of lodash in client code
8
+ /**
9
+ * Gets the duplicate values in an array.
10
+ * @param arr The array.
11
+ * @param comparator Compares two values and returns `true` if they are equal
12
+ * (duplicated).
13
+ * @returns Value of the elements `v` that have a preceding element `u` where
14
+ * `comparator(u, v) === true`. Values within the returned array are not
15
+ * guaranteed to be unique.
16
+ */
17
+ export function duplicates(arr, comparator = (a, b) => a === b) {
18
+ return arr.filter((v, vIndex) => arr.findIndex((u) => comparator(u, v)) !== vIndex);
19
+ }
20
+ /**
21
+ * Remove duplicate array items (similar to _.uniq)
22
+ * @param arr The array.
23
+ * @returns An array with duplicate elements removed by reference comparison.
24
+ */
25
+ export function uniq(arr) {
26
+ // Note: had problems with [...new Set()]: https://github.com/facebook/docusaurus/issues/4972#issuecomment-863895061
27
+ return Array.from(new Set(arr));
28
+ }
29
+ //# sourceMappingURL=jsUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsUtils.js","sourceRoot":"","sources":["../../src/utils/jsUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,yCAAyC;AAEzC;;;;;;;;GAQG;AACH,MAAM,UAAU,UAAU,CACxB,GAAiB,EACjB,aAAsC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC;IAEvD,OAAO,GAAG,CAAC,MAAM,CACf,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,MAAM,CACjE,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,IAAI,CAAI,GAAQ;IAC9B,oHAAoH;IACpH,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;AAClC,CAAC"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Copyright (c) Facebook, Inc. and its affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import { type ReactNode, type ComponentType } from 'react';
8
+ declare type ExtraProps = {
9
+ toggleSidebar: () => void;
10
+ };
11
+ export declare type MobileSecondaryMenuComponent<Props> = ComponentType<Props & ExtraProps>;
12
+ export declare function MobileSecondaryMenuProvider({ children, }: {
13
+ children: ReactNode;
14
+ }): JSX.Element;
15
+ export declare function useMobileSecondaryMenuRenderer(): (extraProps: ExtraProps) => ReactNode | undefined;
16
+ export declare function MobileSecondaryMenuFiller<Props extends Record<string, unknown>>({ component, props, }: {
17
+ component: MobileSecondaryMenuComponent<Props & ExtraProps>;
18
+ props: Props;
19
+ }): JSX.Element | null;
20
+ export {};
21
+ //# sourceMappingURL=mobileSecondaryMenu.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mobileSecondaryMenu.d.ts","sourceRoot":"","sources":["../../src/utils/mobileSecondaryMenu.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAc,EAEZ,KAAK,SAAS,EAId,KAAK,aAAa,EAEnB,MAAM,OAAO,CAAC;AAaf,aAAK,UAAU,GAAG;IAChB,aAAa,EAAE,MAAM,IAAI,CAAC;CAC3B,CAAC;AAEF,oBAAY,4BAA4B,CAAC,KAAK,IAAI,aAAa,CAC7D,KAAK,GAAG,UAAU,CACnB,CAAC;AAeF,wBAAgB,2BAA2B,CAAC,EAC1C,QAAQ,GACT,EAAE;IACD,QAAQ,EAAE,SAAS,CAAC;CACrB,GAAG,GAAG,CAAC,OAAO,CAId;AAYD,wBAAgB,8BAA8B,IAAI,CAChD,UAAU,EAAE,UAAU,KACnB,SAAS,GAAG,SAAS,CASzB;AAYD,wBAAgB,yBAAyB,CACvC,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACrC,EACA,SAAS,EACT,KAAK,GACN,EAAE;IACD,SAAS,EAAE,4BAA4B,CAAC,KAAK,GAAG,UAAU,CAAC,CAAC;IAC5D,KAAK,EAAE,KAAK,CAAC;CACd,GAAG,GAAG,CAAC,OAAO,GAAG,IAAI,CAcrB"}
@@ -0,0 +1,50 @@
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, { useState, useContext, createContext, useEffect, useMemo, } from 'react';
8
+ function useContextValue() {
9
+ return useState(null);
10
+ }
11
+ const Context = createContext(null);
12
+ export function MobileSecondaryMenuProvider({ children, }) {
13
+ return (React.createElement(Context.Provider, { value: useContextValue() }, children));
14
+ }
15
+ function useMobileSecondaryMenuContext() {
16
+ const value = useContext(Context);
17
+ if (value === null) {
18
+ throw new Error('MobileSecondaryMenuProvider was not used correctly, context value is null');
19
+ }
20
+ return value;
21
+ }
22
+ export function useMobileSecondaryMenuRenderer() {
23
+ const [state] = useMobileSecondaryMenuContext();
24
+ if (state) {
25
+ const Comp = state.component;
26
+ return function render(extraProps) {
27
+ return React.createElement(Comp, { ...state.props, ...extraProps });
28
+ };
29
+ }
30
+ return () => undefined;
31
+ }
32
+ function useShallowMemoizedObject(obj) {
33
+ return useMemo(() => obj,
34
+ // Is this safe?
35
+ // eslint-disable-next-line react-hooks/exhaustive-deps
36
+ [...Object.keys(obj), ...Object.values(obj)]);
37
+ }
38
+ // Fill the secondary menu placeholder with some real content
39
+ export function MobileSecondaryMenuFiller({ component, props, }) {
40
+ const [, setState] = useMobileSecondaryMenuContext();
41
+ // To avoid useless context re-renders, props are memoized shallowly
42
+ const memoizedProps = useShallowMemoizedObject(props);
43
+ useEffect(() => {
44
+ // @ts-expect-error: context is not 100% type-safe but it's ok
45
+ setState({ component, props: memoizedProps });
46
+ }, [setState, component, memoizedProps]);
47
+ useEffect(() => () => setState(null), [setState]);
48
+ return null;
49
+ }
50
+ //# sourceMappingURL=mobileSecondaryMenu.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mobileSecondaryMenu.js","sourceRoot":"","sources":["../../src/utils/mobileSecondaryMenu.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,EACZ,QAAQ,EAER,UAAU,EACV,aAAa,EACb,SAAS,EAET,OAAO,GACR,MAAM,OAAO,CAAC;AA0Bf,SAAS,eAAe;IACtB,OAAO,QAAQ,CAAQ,IAAI,CAAC,CAAC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IAEtD,SAAS,CAAC,GAAG,EAAE;QACb,8DAA8D;QAC9D,QAAQ,CAAC,EAAC,SAAS,EAAE,KAAK,EAAE,aAAa,EAAC,CAAC,CAAC;IAC9C,CAAC,EAAE,CAAC,QAAQ,EAAE,SAAS,EAAE,aAAa,CAAC,CAAC,CAAC;IAEzC,SAAS,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;IAElD,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -5,3 +5,4 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  export declare const isSamePath: (path1: string | undefined, path2: string | undefined) => boolean;
8
+ //# sourceMappingURL=pathUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pathUtils.d.ts","sourceRoot":"","sources":["../../src/utils/pathUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,eAAO,MAAM,UAAU,UACd,MAAM,GAAG,SAAS,SAClB,MAAM,GAAG,SAAS,KACxB,OAOF,CAAC"}
@@ -4,10 +4,14 @@
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
- // Compare the 2 paths, ignoring trailing /
7
+ // Compare the 2 paths, case insensitive and ignoring trailing slash
8
8
  export const isSamePath = (path1, path2) => {
9
9
  const normalize = (pathname) => {
10
- return !pathname || (pathname === null || pathname === void 0 ? void 0 : pathname.endsWith('/')) ? pathname : `${pathname}/`;
10
+ var _a;
11
+ return (_a = (!pathname || (pathname === null || pathname === void 0 ? void 0 : pathname.endsWith('/'))
12
+ ? pathname
13
+ : `${pathname}/`)) === null || _a === void 0 ? void 0 : _a.toLowerCase();
11
14
  };
12
15
  return normalize(path1) === normalize(path2);
13
16
  };
17
+ //# sourceMappingURL=pathUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pathUtils.js","sourceRoot":"","sources":["../../src/utils/pathUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,oEAAoE;AACpE,MAAM,CAAC,MAAM,UAAU,GAAG,CACxB,KAAyB,EACzB,KAAyB,EAChB,EAAE;IACX,MAAM,SAAS,GAAG,CAAC,QAA4B,EAAE,EAAE;;QACjD,OAAA,MAAA,CAAC,CAAC,QAAQ,KAAI,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,QAAQ,CAAC,GAAG,CAAC,CAAA;YACnC,CAAC,CAAC,QAAQ;YACV,CAAC,CAAC,GAAG,QAAQ,GAAG,CACjB,0CAAE,WAAW,EAAE,CAAA;KAAA,CAAC;IACnB,OAAO,SAAS,CAAC,KAAK,CAAC,KAAK,SAAS,CAAC,KAAK,CAAC,CAAC;AAC/C,CAAC,CAAC"}
@@ -0,0 +1,28 @@
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 { useEffect } from 'react';
8
+ /**
9
+ * This hook is like useLayoutEffect, but without the SSR warning
10
+ * It seems hacky but it's used in many React libs (Redux, Formik...)
11
+ * Also mentioned here: https://github.com/facebook/react/issues/16956
12
+ * It is useful when you need to update a ref as soon as possible after a React
13
+ * render (before `useEffect`)
14
+ */
15
+ export declare const useIsomorphicLayoutEffect: typeof useEffect;
16
+ /**
17
+ * 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
+ * array. Useful to avoid React stale closure problems + avoid useless effect
20
+ * re-executions
21
+ *
22
+ * Workaround until the React team recommends a good solution, see
23
+ * https://github.com/facebook/react/issues/16956
24
+ * This generally works but has some potential drawbacks, such as
25
+ * https://github.com/facebook/react/issues/16956#issuecomment-536636418
26
+ */
27
+ export declare function useDynamicCallback<T extends (...args: never[]) => unknown>(callback: T): T;
28
+ //# sourceMappingURL=reactUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reactUtils.d.ts","sourceRoot":"","sources":["../../src/utils/reactUtils.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,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"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Copyright (c) Facebook, Inc. and its affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import { useCallback, useEffect, useLayoutEffect, useRef } from 'react';
8
+ /**
9
+ * This hook is like useLayoutEffect, but without the SSR warning
10
+ * It seems hacky but it's used in many React libs (Redux, Formik...)
11
+ * Also mentioned here: https://github.com/facebook/react/issues/16956
12
+ * It is useful when you need to update a ref as soon as possible after a React
13
+ * render (before `useEffect`)
14
+ */
15
+ export const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect;
16
+ /**
17
+ * 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
+ * array. Useful to avoid React stale closure problems + avoid useless effect
20
+ * re-executions
21
+ *
22
+ * Workaround until the React team recommends a good solution, see
23
+ * https://github.com/facebook/react/issues/16956
24
+ * This generally works but has some potential drawbacks, such as
25
+ * https://github.com/facebook/react/issues/16956#issuecomment-536636418
26
+ */
27
+ export function useDynamicCallback(callback) {
28
+ const ref = useRef(callback);
29
+ useIsomorphicLayoutEffect(() => {
30
+ ref.current = callback;
31
+ }, [callback]);
32
+ // @ts-expect-error: TS is right that this callback may be a supertype of T,
33
+ // but good enough for our use
34
+ return useCallback((...args) => ref.current(...args), []);
35
+ }
36
+ //# sourceMappingURL=reactUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reactUtils.js","sourceRoot":"","sources":["../../src/utils/reactUtils.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,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,4EAA4E;IAC5E,8BAA8B;IAC9B,OAAO,WAAW,CAAI,CAAC,GAAG,IAAI,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC;AAC/D,CAAC"}
@@ -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
+ * Converts an optional string into a Regex case insensitive and global
9
+ */
10
+ export declare function isRegexpStringMatch(regexAsString?: string, valueToTest?: string): boolean;
11
+ //# sourceMappingURL=regexpUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"regexpUtils.d.ts","sourceRoot":"","sources":["../../src/utils/regexpUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,aAAa,CAAC,EAAE,MAAM,EACtB,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAST"}
@@ -0,0 +1,17 @@
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
+ * Converts an optional string into a Regex case insensitive and global
9
+ */
10
+ export function isRegexpStringMatch(regexAsString, valueToTest) {
11
+ if (typeof regexAsString === 'undefined' ||
12
+ typeof valueToTest === 'undefined') {
13
+ return false;
14
+ }
15
+ return new RegExp(regexAsString, 'gi').test(valueToTest);
16
+ }
17
+ //# sourceMappingURL=regexpUtils.js.map
@@ -0,0 +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"}
@@ -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
+ /// <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;
11
+ //# sourceMappingURL=routesUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"routesUtils.d.ts","sourceRoot":"","sources":["../../src/utils/routesUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;;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"}
@@ -0,0 +1,33 @@
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 GeneratedRoutes from '@generated/routes';
8
+ 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;
14
+ }
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;
20
+ }
21
+ const homePage = routes.find(isHomePageRoute);
22
+ if (homePage) {
23
+ return homePage;
24
+ }
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);
29
+ }
30
+ export function useHomePageRoute() {
31
+ return useMemo(() => findHomePageRoute(), []);
32
+ }
33
+ //# sourceMappingURL=routesUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"routesUtils.js","sourceRoot":"","sources":["../../src/utils/routesUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,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,EAAE,CAAC,iBAAiB,EAAE,EAAE,EAAE,CAAC,CAAC;AAChD,CAAC"}
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Copyright (c) Facebook, Inc. and its affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import React, { type ReactNode } from 'react';
8
+ /**
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
+ declare type ScrollController = {
16
+ /**
17
+ * A boolean ref tracking whether scroll events are enabled
18
+ */
19
+ scrollEventsEnabledRef: React.MutableRefObject<boolean>;
20
+ /**
21
+ * Enables scroll events in `useScrollPosition`
22
+ */
23
+ enableScrollEvents: () => void;
24
+ /**
25
+ * Disables scroll events in `useScrollPosition`
26
+ */
27
+ disableScrollEvents: () => void;
28
+ };
29
+ export declare function ScrollControllerProvider({ children, }: {
30
+ children: ReactNode;
31
+ }): JSX.Element;
32
+ export declare function useScrollController(): ScrollController;
33
+ declare type ScrollPosition = {
34
+ scrollX: number;
35
+ scrollY: number;
36
+ };
37
+ export declare function useScrollPosition(effect: (position: ScrollPosition, lastPosition: ScrollPosition | null) => void, deps?: unknown[]): void;
38
+ declare type UseScrollPositionBlockerReturn = {
39
+ blockElementScrollPositionUntilNextRender: (el: HTMLElement) => void;
40
+ };
41
+ /**
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
45
+ *
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
50
+ */
51
+ export declare function useScrollPositionBlocker(): UseScrollPositionBlockerReturn;
52
+ export {};
53
+ //# sourceMappingURL=scrollUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scrollUtils.d.ts","sourceRoot":"","sources":["../../src/utils/scrollUtils.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,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;AA+CD,aAAK,8BAA8B,GAAG;IACpC,yCAAyC,EAAE,CAAC,EAAE,EAAE,WAAW,KAAK,IAAI,CAAC;CACtE,CAAC;AAEF;;;;;;;;;GASG;AACH,wBAAgB,wBAAwB,IAAI,8BAA8B,CAwCzE"}
@@ -0,0 +1,136 @@
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, { createContext, useCallback, useContext, useEffect, useLayoutEffect, useMemo, useRef, } from 'react';
8
+ import { useDynamicCallback } from './reactUtils';
9
+ import ExecutionEnvironment from '@docusaurus/ExecutionEnvironment';
10
+ function useScrollControllerContextValue() {
11
+ const scrollEventsEnabledRef = useRef(true);
12
+ return useMemo(() => ({
13
+ scrollEventsEnabledRef,
14
+ enableScrollEvents: () => {
15
+ scrollEventsEnabledRef.current = true;
16
+ },
17
+ disableScrollEvents: () => {
18
+ scrollEventsEnabledRef.current = false;
19
+ },
20
+ }), []);
21
+ }
22
+ const ScrollMonitorContext = createContext(undefined);
23
+ export function ScrollControllerProvider({ children, }) {
24
+ return (React.createElement(ScrollMonitorContext.Provider, { value: useScrollControllerContextValue() }, children));
25
+ }
26
+ export function useScrollController() {
27
+ const context = useContext(ScrollMonitorContext);
28
+ if (context == null) {
29
+ throw new Error('"useScrollController" is used but no context provider was found in the React tree.');
30
+ }
31
+ return context;
32
+ }
33
+ const getScrollPosition = () => ExecutionEnvironment.canUseDOM
34
+ ? {
35
+ scrollX: window.pageXOffset,
36
+ scrollY: window.pageYOffset,
37
+ }
38
+ : null;
39
+ export function useScrollPosition(effect, deps = []) {
40
+ const { scrollEventsEnabledRef } = useScrollController();
41
+ const lastPositionRef = useRef(getScrollPosition());
42
+ const dynamicEffect = useDynamicCallback(effect);
43
+ useEffect(() => {
44
+ const handleScroll = () => {
45
+ if (!scrollEventsEnabledRef.current) {
46
+ return;
47
+ }
48
+ const currentPosition = getScrollPosition();
49
+ if (dynamicEffect) {
50
+ dynamicEffect(currentPosition, lastPositionRef.current);
51
+ }
52
+ lastPositionRef.current = currentPosition;
53
+ };
54
+ const opts = {
55
+ passive: true,
56
+ };
57
+ handleScroll();
58
+ window.addEventListener('scroll', handleScroll, opts);
59
+ return () => window.removeEventListener('scroll', handleScroll, opts);
60
+ }, [
61
+ dynamicEffect,
62
+ scrollEventsEnabledRef,
63
+ // eslint-disable-next-line react-hooks/exhaustive-deps
64
+ ...deps,
65
+ ]);
66
+ }
67
+ function useScrollPositionSaver() {
68
+ const lastElementRef = useRef({
69
+ elem: null,
70
+ top: 0,
71
+ });
72
+ const save = useCallback((elem) => {
73
+ lastElementRef.current = {
74
+ elem,
75
+ top: elem.getBoundingClientRect().top,
76
+ };
77
+ }, []);
78
+ const restore = useCallback(() => {
79
+ const { current: { elem, top }, } = lastElementRef;
80
+ if (!elem) {
81
+ return { restored: false };
82
+ }
83
+ const newTop = elem.getBoundingClientRect().top;
84
+ const heightDiff = newTop - top;
85
+ if (heightDiff) {
86
+ window.scrollBy({ left: 0, top: heightDiff });
87
+ }
88
+ lastElementRef.current = { elem: null, top: 0 };
89
+ return { restored: heightDiff !== 0 };
90
+ }, []);
91
+ return useMemo(() => ({ save, restore }), [restore, save]);
92
+ }
93
+ /**
94
+ * This hook permits to "block" the scroll position of a dom element
95
+ * 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
97
+ *
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
102
+ */
103
+ export function useScrollPositionBlocker() {
104
+ const scrollController = useScrollController();
105
+ const scrollPositionSaver = useScrollPositionSaver();
106
+ const nextLayoutEffectCallbackRef = useRef(undefined);
107
+ const blockElementScrollPositionUntilNextRender = useCallback((el) => {
108
+ scrollPositionSaver.save(el);
109
+ scrollController.disableScrollEvents();
110
+ nextLayoutEffectCallbackRef.current = () => {
111
+ const { restored } = scrollPositionSaver.restore();
112
+ 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
116
+ if (restored) {
117
+ const handleScrollRestoreEvent = () => {
118
+ scrollController.enableScrollEvents();
119
+ window.removeEventListener('scroll', handleScrollRestoreEvent);
120
+ };
121
+ window.addEventListener('scroll', handleScrollRestoreEvent);
122
+ }
123
+ else {
124
+ scrollController.enableScrollEvents();
125
+ }
126
+ };
127
+ }, [scrollController, scrollPositionSaver]);
128
+ useLayoutEffect(() => {
129
+ var _a;
130
+ (_a = nextLayoutEffectCallbackRef.current) === null || _a === void 0 ? void 0 : _a.call(nextLayoutEffectCallbackRef);
131
+ });
132
+ return {
133
+ blockElementScrollPositionUntilNextRender,
134
+ };
135
+ }
136
+ //# sourceMappingURL=scrollUtils.js.map
@@ -0,0 +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;AAwB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CAAC;oBACtC,MAAM,CAAC,mBAAmB,CAAC,QAAQ,EAAE,wBAAwB,CAAC,CAAC;gBACjE,CAAC,CAAC;gBACF,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,wBAAwB,CAAC,CAAC;aAC7D;iBAAM;gBACL,gBAAgB,CAAC,kBAAkB,EAAE,CAAC;aACvC;QACH,CAAC,CAAC;IACJ,CAAC,EACD,CAAC,gBAAgB,EAAE,mBAAmB,CAAC,CACxC,CAAC;IAEF,eAAe,CAAC,GAAG,EAAE;;QACnB,MAAA,2BAA2B,CAAC,OAAO,+CAAnC,2BAA2B,CAAY,CAAC;IAC1C,CAAC,CAAC,CAAC;IAEH,OAAO;QACL,yCAAyC;KAC1C,CAAC;AACJ,CAAC"}
@@ -6,3 +6,4 @@
6
6
  */
7
7
  export declare const DEFAULT_SEARCH_TAG = "default";
8
8
  export declare function docVersionSearchTag(pluginId: string, versionName: string): string;
9
+ //# sourceMappingURL=searchUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"searchUtils.d.ts","sourceRoot":"","sources":["../../src/utils/searchUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,kBAAkB,YAAY,CAAC;AAE5C,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,MAAM,GAClB,MAAM,CAER"}
@@ -8,3 +8,4 @@ export const DEFAULT_SEARCH_TAG = 'default';
8
8
  export function docVersionSearchTag(pluginId, versionName) {
9
9
  return `docs-${pluginId}-${versionName}`;
10
10
  }
11
+ //# sourceMappingURL=searchUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"searchUtils.js","sourceRoot":"","sources":["../../src/utils/searchUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,kBAAkB,GAAG,SAAS,CAAC;AAE5C,MAAM,UAAU,mBAAmB,CACjC,QAAgB,EAChB,WAAmB;IAEnB,OAAO,QAAQ,QAAQ,IAAI,WAAW,EAAE,CAAC;AAC3C,CAAC"}
@@ -13,6 +13,10 @@ export interface StorageSlot {
13
13
  }
14
14
  /**
15
15
  * Creates an object for accessing a particular key in localStorage.
16
+ * The API is fail-safe, and usage of browser storage should be considered
17
+ * unreliable. Local storage might simply be unavailable (iframe + browser
18
+ * security) or operations might fail individually. Please assume that using
19
+ * this API can be a NO-OP. See also https://github.com/facebook/docusaurus/issues/6036
16
20
  */
17
21
  export declare const createStorageSlot: (key: string, options?: {
18
22
  persistence?: "localStorage" | "none" | "sessionStorage" | undefined;
@@ -23,3 +27,4 @@ export declare const createStorageSlot: (key: string, options?: {
23
27
  */
24
28
  export declare function listStorageKeys(storageType?: StorageType): string[];
25
29
  export {};
30
+ //# sourceMappingURL=storageUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storageUtils.d.ts","sourceRoot":"","sources":["../../src/utils/storageUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,QAAA,MAAM,YAAY,qDAAsD,CAAC;AAEzE,oBAAY,WAAW,GAAG,OAAO,YAAY,CAAC,MAAM,CAAC,CAAC;AA0CtD,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE,MAAM,MAAM,GAAG,IAAI,CAAC;IACzB,GAAG,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7B,GAAG,EAAE,MAAM,IAAI,CAAC;CACjB;AAuBD;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,QACvB,MAAM;;kBAEV,WAmCF,CAAC;AAEF;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,WAAW,GAAE,WAAgC,GAC5C,MAAM,EAAE,CAcV"}