@docusaurus/theme-common 2.0.0-beta.ff31de0ff → 2.0.0-rc.1

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 (269) hide show
  1. package/lib/components/Collapsible/index.d.ts +64 -0
  2. package/lib/components/Collapsible/index.d.ts.map +1 -0
  3. package/lib/components/Collapsible/index.js +150 -0
  4. package/lib/components/Collapsible/index.js.map +1 -0
  5. package/lib/components/Details/index.d.ts +17 -0
  6. package/lib/components/Details/index.d.ts.map +1 -0
  7. package/lib/components/Details/index.js +76 -0
  8. package/lib/components/Details/index.js.map +1 -0
  9. package/lib/components/Details/styles.module.css +62 -0
  10. package/lib/contexts/announcementBar.d.ts +22 -0
  11. package/lib/contexts/announcementBar.d.ts.map +1 -0
  12. package/lib/contexts/announcementBar.js +72 -0
  13. package/lib/contexts/announcementBar.js.map +1 -0
  14. package/lib/contexts/blogPost.d.ts +33 -0
  15. package/lib/contexts/blogPost.d.ts.map +1 -0
  16. package/lib/contexts/blogPost.js +46 -0
  17. package/lib/contexts/blogPost.js.map +1 -0
  18. package/lib/contexts/colorMode.d.ts +27 -0
  19. package/lib/contexts/colorMode.d.ts.map +1 -0
  20. package/lib/contexts/colorMode.js +132 -0
  21. package/lib/contexts/colorMode.js.map +1 -0
  22. package/lib/contexts/doc.d.ts +30 -0
  23. package/lib/contexts/doc.d.ts.map +1 -0
  24. package/lib/contexts/doc.js +48 -0
  25. package/lib/contexts/doc.js.map +1 -0
  26. package/lib/contexts/docSidebarItemsExpandedState.d.ts +31 -0
  27. package/lib/contexts/docSidebarItemsExpandedState.d.ts.map +1 -0
  28. package/lib/contexts/docSidebarItemsExpandedState.js +28 -0
  29. package/lib/contexts/docSidebarItemsExpandedState.js.map +1 -0
  30. package/lib/contexts/docsPreferredVersion.d.ts +30 -0
  31. package/lib/contexts/docsPreferredVersion.d.ts.map +1 -0
  32. package/lib/contexts/docsPreferredVersion.js +130 -0
  33. package/lib/contexts/docsPreferredVersion.js.map +1 -0
  34. package/lib/contexts/docsSidebar.d.ts +26 -0
  35. package/lib/contexts/docsSidebar.d.ts.map +1 -0
  36. package/lib/contexts/docsSidebar.js +30 -0
  37. package/lib/contexts/docsSidebar.js.map +1 -0
  38. package/lib/contexts/docsVersion.d.ts +20 -0
  39. package/lib/contexts/docsVersion.d.ts.map +1 -0
  40. package/lib/contexts/docsVersion.js +26 -0
  41. package/lib/contexts/docsVersion.js.map +1 -0
  42. package/lib/contexts/navbarMobileSidebar.d.ts +31 -0
  43. package/lib/contexts/navbarMobileSidebar.d.ts.map +1 -0
  44. package/lib/contexts/navbarMobileSidebar.js +56 -0
  45. package/lib/contexts/navbarMobileSidebar.js.map +1 -0
  46. package/lib/contexts/navbarSecondaryMenu/content.d.ts +37 -0
  47. package/lib/contexts/navbarSecondaryMenu/content.d.ts.map +1 -0
  48. package/lib/contexts/navbarSecondaryMenu/content.js +50 -0
  49. package/lib/contexts/navbarSecondaryMenu/content.js.map +1 -0
  50. package/lib/contexts/navbarSecondaryMenu/display.d.ts +24 -0
  51. package/lib/contexts/navbarSecondaryMenu/display.d.ts.map +1 -0
  52. package/lib/contexts/navbarSecondaryMenu/display.js +62 -0
  53. package/lib/contexts/navbarSecondaryMenu/display.js.map +1 -0
  54. package/lib/contexts/tabGroupChoice.d.ts +21 -0
  55. package/lib/contexts/tabGroupChoice.d.ts.map +1 -0
  56. package/lib/contexts/tabGroupChoice.js +49 -0
  57. package/lib/contexts/tabGroupChoice.js.map +1 -0
  58. package/lib/{utils/useChangeRoute.d.ts → hooks/styles.css} +4 -1
  59. package/lib/hooks/useBackToTopButton.d.ts +27 -0
  60. package/lib/hooks/useBackToTopButton.d.ts.map +1 -0
  61. package/lib/hooks/useBackToTopButton.js +50 -0
  62. package/lib/hooks/useBackToTopButton.js.map +1 -0
  63. package/lib/hooks/useCodeWordWrap.d.ts +14 -0
  64. package/lib/hooks/useCodeWordWrap.d.ts.map +1 -0
  65. package/lib/hooks/useCodeWordWrap.js +67 -0
  66. package/lib/hooks/useCodeWordWrap.js.map +1 -0
  67. package/lib/hooks/useHideableNavbar.d.ts +17 -0
  68. package/lib/hooks/useHideableNavbar.d.ts.map +1 -0
  69. package/lib/hooks/useHideableNavbar.js +60 -0
  70. package/lib/hooks/useHideableNavbar.js.map +1 -0
  71. package/lib/hooks/useKeyboardNavigation.d.ts +20 -0
  72. package/lib/hooks/useKeyboardNavigation.d.ts.map +1 -0
  73. package/lib/hooks/useKeyboardNavigation.js +39 -0
  74. package/lib/hooks/useKeyboardNavigation.js.map +1 -0
  75. package/lib/hooks/useLockBodyScroll.d.ts +12 -0
  76. package/lib/hooks/useLockBodyScroll.d.ts.map +1 -0
  77. package/lib/hooks/useLockBodyScroll.js +20 -0
  78. package/lib/hooks/useLockBodyScroll.js.map +1 -0
  79. package/lib/hooks/useMutationObserver.d.ts +4 -0
  80. package/lib/hooks/useMutationObserver.d.ts.map +1 -0
  81. package/lib/hooks/useMutationObserver.js +29 -0
  82. package/lib/hooks/useMutationObserver.js.map +1 -0
  83. package/lib/hooks/usePrismTheme.d.ts +13 -0
  84. package/lib/hooks/usePrismTheme.d.ts.map +1 -0
  85. package/lib/hooks/usePrismTheme.js +21 -0
  86. package/lib/hooks/usePrismTheme.js.map +1 -0
  87. package/lib/hooks/useSearchPage.d.ts +25 -0
  88. package/lib/hooks/useSearchPage.d.ts.map +1 -0
  89. package/lib/hooks/useSearchPage.js +43 -0
  90. package/lib/hooks/useSearchPage.js.map +1 -0
  91. package/lib/hooks/useSkipToContent.d.ts +25 -0
  92. package/lib/hooks/useSkipToContent.d.ts.map +1 -0
  93. package/lib/hooks/useSkipToContent.js +35 -0
  94. package/lib/hooks/useSkipToContent.js.map +1 -0
  95. package/lib/hooks/useTOCHighlight.d.ts +25 -0
  96. package/lib/hooks/useTOCHighlight.d.ts.map +1 -0
  97. package/lib/hooks/useTOCHighlight.js +130 -0
  98. package/lib/hooks/useTOCHighlight.js.map +1 -0
  99. package/lib/hooks/useWindowSize.d.ts +28 -0
  100. package/lib/hooks/useWindowSize.d.ts.map +1 -0
  101. package/lib/hooks/useWindowSize.js +59 -0
  102. package/lib/hooks/useWindowSize.js.map +1 -0
  103. package/lib/index.d.ts +16 -11
  104. package/lib/index.d.ts.map +1 -0
  105. package/lib/index.js +23 -10
  106. package/lib/index.js.map +1 -0
  107. package/lib/internal.d.ts +41 -0
  108. package/lib/internal.d.ts.map +1 -0
  109. package/lib/internal.js +52 -0
  110. package/lib/internal.js.map +1 -0
  111. package/lib/utils/ThemeClassNames.d.ts +49 -12
  112. package/lib/utils/ThemeClassNames.d.ts.map +1 -0
  113. package/lib/utils/ThemeClassNames.js +47 -4
  114. package/lib/utils/ThemeClassNames.js.map +1 -0
  115. package/lib/utils/codeBlockUtils.d.ts +63 -0
  116. package/lib/utils/codeBlockUtils.d.ts.map +1 -0
  117. package/lib/utils/codeBlockUtils.js +159 -3
  118. package/lib/utils/codeBlockUtils.js.map +1 -0
  119. package/lib/utils/docsUtils.d.ts +91 -0
  120. package/lib/utils/docsUtils.d.ts.map +1 -0
  121. package/lib/utils/docsUtils.js +217 -1
  122. package/lib/utils/docsUtils.js.map +1 -0
  123. package/lib/utils/footerUtils.d.ts +13 -0
  124. package/lib/utils/footerUtils.d.ts.map +1 -0
  125. package/lib/utils/footerUtils.js +14 -0
  126. package/lib/utils/footerUtils.js.map +1 -0
  127. package/lib/utils/generalUtils.d.ts +11 -1
  128. package/lib/utils/generalUtils.d.ts.map +1 -0
  129. package/lib/utils/generalUtils.js +9 -5
  130. package/lib/utils/generalUtils.js.map +1 -0
  131. package/lib/utils/historyUtils.d.ts +17 -0
  132. package/lib/utils/historyUtils.d.ts.map +1 -0
  133. package/lib/utils/historyUtils.js +38 -0
  134. package/lib/utils/historyUtils.js.map +1 -0
  135. package/lib/utils/jsUtils.d.ts +23 -0
  136. package/lib/utils/jsUtils.d.ts.map +1 -0
  137. package/lib/utils/jsUtils.js +29 -0
  138. package/lib/utils/jsUtils.js.map +1 -0
  139. package/lib/utils/metadataUtils.d.ts +38 -0
  140. package/lib/utils/metadataUtils.d.ts.map +1 -0
  141. package/lib/utils/metadataUtils.js +70 -0
  142. package/lib/utils/metadataUtils.js.map +1 -0
  143. package/lib/utils/navbarUtils.d.ts +21 -0
  144. package/lib/utils/navbarUtils.d.ts.map +1 -0
  145. package/lib/utils/navbarUtils.js +36 -0
  146. package/lib/utils/navbarUtils.js.map +1 -0
  147. package/lib/utils/reactUtils.d.ts +69 -0
  148. package/lib/utils/reactUtils.d.ts.map +1 -0
  149. package/lib/utils/reactUtils.js +98 -0
  150. package/lib/utils/reactUtils.js.map +1 -0
  151. package/lib/utils/regexpUtils.d.ts +12 -0
  152. package/lib/utils/regexpUtils.d.ts.map +1 -0
  153. package/lib/utils/regexpUtils.js +18 -0
  154. package/lib/utils/regexpUtils.js.map +1 -0
  155. package/lib/utils/routesUtils.d.ts +26 -0
  156. package/lib/utils/routesUtils.d.ts.map +1 -0
  157. package/lib/utils/routesUtils.js +54 -0
  158. package/lib/utils/routesUtils.js.map +1 -0
  159. package/lib/utils/scrollUtils.d.ts +83 -0
  160. package/lib/utils/scrollUtils.d.ts.map +1 -0
  161. package/lib/utils/scrollUtils.js +200 -0
  162. package/lib/utils/scrollUtils.js.map +1 -0
  163. package/lib/utils/searchUtils.d.ts +13 -0
  164. package/lib/utils/searchUtils.d.ts.map +1 -0
  165. package/lib/utils/searchUtils.js +37 -0
  166. package/lib/utils/searchUtils.js.map +1 -0
  167. package/lib/utils/storageUtils.d.ts +15 -7
  168. package/lib/utils/storageUtils.d.ts.map +1 -0
  169. package/lib/utils/storageUtils.js +58 -25
  170. package/lib/utils/storageUtils.js.map +1 -0
  171. package/lib/utils/tagsUtils.d.ts +18 -0
  172. package/lib/utils/tagsUtils.d.ts.map +1 -0
  173. package/lib/utils/tagsUtils.js +36 -0
  174. package/lib/utils/tagsUtils.js.map +1 -0
  175. package/lib/utils/tocUtils.d.ts +36 -0
  176. package/lib/utils/tocUtils.d.ts.map +1 -0
  177. package/lib/utils/tocUtils.js +84 -0
  178. package/lib/utils/tocUtils.js.map +1 -0
  179. package/lib/utils/useAlternatePageUtils.d.ts +21 -1
  180. package/lib/utils/useAlternatePageUtils.d.ts.map +1 -0
  181. package/lib/utils/useAlternatePageUtils.js +9 -4
  182. package/lib/utils/useAlternatePageUtils.js.map +1 -0
  183. package/lib/utils/useLocalPathname.d.ts +13 -0
  184. package/lib/utils/useLocalPathname.d.ts.map +1 -0
  185. package/lib/utils/useLocalPathname.js +19 -0
  186. package/lib/utils/useLocalPathname.js.map +1 -0
  187. package/lib/utils/useLocationChange.d.ts +17 -0
  188. package/lib/utils/useLocationChange.d.ts.map +1 -0
  189. package/lib/utils/useLocationChange.js +31 -0
  190. package/lib/utils/useLocationChange.js.map +1 -0
  191. package/lib/utils/usePluralForm.d.ts +12 -0
  192. package/lib/utils/usePluralForm.d.ts.map +1 -0
  193. package/lib/utils/usePluralForm.js +36 -37
  194. package/lib/utils/usePluralForm.js.map +1 -0
  195. package/lib/utils/useThemeConfig.d.ts +56 -27
  196. package/lib/utils/useThemeConfig.d.ts.map +1 -0
  197. package/lib/utils/useThemeConfig.js +4 -0
  198. package/lib/utils/useThemeConfig.js.map +1 -0
  199. package/package.json +35 -13
  200. package/src/components/Collapsible/index.tsx +263 -0
  201. package/src/components/Details/index.tsx +109 -0
  202. package/src/components/Details/styles.module.css +62 -0
  203. package/src/contexts/announcementBar.tsx +119 -0
  204. package/src/contexts/blogPost.tsx +80 -0
  205. package/src/contexts/colorMode.tsx +198 -0
  206. package/src/contexts/doc.tsx +71 -0
  207. package/src/contexts/docSidebarItemsExpandedState.tsx +55 -0
  208. package/src/contexts/docsPreferredVersion.tsx +251 -0
  209. package/src/contexts/docsSidebar.tsx +50 -0
  210. package/src/contexts/docsVersion.tsx +36 -0
  211. package/src/contexts/navbarMobileSidebar.tsx +99 -0
  212. package/src/contexts/navbarSecondaryMenu/content.tsx +100 -0
  213. package/src/contexts/navbarSecondaryMenu/display.tsx +102 -0
  214. package/src/contexts/tabGroupChoice.tsx +85 -0
  215. package/{lib/utils/pathUtils.d.ts → src/hooks/styles.css} +4 -1
  216. package/src/hooks/useBackToTopButton.ts +73 -0
  217. package/src/hooks/useCodeWordWrap.ts +105 -0
  218. package/src/hooks/useHideableNavbar.ts +75 -0
  219. package/src/hooks/useKeyboardNavigation.ts +45 -0
  220. package/src/hooks/useLockBodyScroll.ts +21 -0
  221. package/src/hooks/useMutationObserver.ts +38 -0
  222. package/src/hooks/usePrismTheme.ts +24 -0
  223. package/src/hooks/useSearchPage.ts +79 -0
  224. package/src/hooks/useSkipToContent.ts +58 -0
  225. package/src/hooks/useTOCHighlight.ts +189 -0
  226. package/src/hooks/useWindowSize.ts +72 -0
  227. package/src/index.ts +55 -23
  228. package/src/internal.ts +122 -0
  229. package/src/types.d.ts +0 -2
  230. package/src/utils/ThemeClassNames.ts +54 -5
  231. package/src/utils/codeBlockUtils.ts +241 -2
  232. package/src/utils/docsUtils.tsx +334 -0
  233. package/src/utils/footerUtils.ts +18 -0
  234. package/src/utils/generalUtils.ts +9 -5
  235. package/src/utils/historyUtils.ts +45 -0
  236. package/src/utils/jsUtils.ts +36 -0
  237. package/src/utils/metadataUtils.tsx +115 -0
  238. package/src/utils/navbarUtils.tsx +45 -0
  239. package/src/utils/reactUtils.tsx +129 -0
  240. package/src/utils/regexpUtils.ts +24 -0
  241. package/src/utils/routesUtils.ts +75 -0
  242. package/src/utils/scrollUtils.tsx +304 -0
  243. package/src/utils/searchUtils.ts +51 -0
  244. package/src/utils/storageUtils.ts +59 -26
  245. package/src/utils/tagsUtils.ts +50 -0
  246. package/src/utils/tocUtils.ts +119 -0
  247. package/src/utils/useAlternatePageUtils.ts +28 -7
  248. package/src/utils/useLocalPathname.ts +22 -0
  249. package/src/utils/useLocationChange.ts +41 -0
  250. package/src/utils/usePluralForm.ts +53 -39
  251. package/src/utils/useThemeConfig.ts +55 -29
  252. package/lib/.tsbuildinfo +0 -4115
  253. package/lib/utils/docsPreferredVersion/DocsPreferredVersionProvider.d.ts +0 -21
  254. package/lib/utils/docsPreferredVersion/DocsPreferredVersionProvider.js +0 -94
  255. package/lib/utils/docsPreferredVersion/DocsPreferredVersionStorage.d.ts +0 -13
  256. package/lib/utils/docsPreferredVersion/DocsPreferredVersionStorage.js +0 -20
  257. package/lib/utils/docsPreferredVersion/useDocsPreferredVersion.d.ts +0 -5
  258. package/lib/utils/docsPreferredVersion/useDocsPreferredVersion.js +0 -41
  259. package/lib/utils/pathUtils.js +0 -13
  260. package/lib/utils/useChangeRoute.js +0 -18
  261. package/src/utils/__tests__/codeBlockUtils.test.ts +0 -54
  262. package/src/utils/__tests__/pathUtils.test.ts +0 -32
  263. package/src/utils/docsPreferredVersion/DocsPreferredVersionProvider.tsx +0 -165
  264. package/src/utils/docsPreferredVersion/DocsPreferredVersionStorage.ts +0 -34
  265. package/src/utils/docsPreferredVersion/useDocsPreferredVersion.ts +0 -66
  266. package/src/utils/docsUtils.ts +0 -11
  267. package/src/utils/pathUtils.ts +0 -17
  268. package/src/utils/useChangeRoute.ts +0 -21
  269. package/tsconfig.json +0 -10
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Copyright (c) Facebook, Inc. and its affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import React, { useCallback, useEffect, useState, useMemo, } from 'react';
8
+ import { useNavbarSecondaryMenuContent } from './navbarSecondaryMenu/content';
9
+ import { useWindowSize } from '../hooks/useWindowSize';
10
+ import { useHistoryPopHandler } from '../utils/historyUtils';
11
+ import { useThemeConfig } from '../utils/useThemeConfig';
12
+ import { ReactContextError } from '../utils/reactUtils';
13
+ const Context = React.createContext(undefined);
14
+ function useIsNavbarMobileSidebarDisabled() {
15
+ const secondaryMenuContent = useNavbarSecondaryMenuContent();
16
+ const { items } = useThemeConfig().navbar;
17
+ return items.length === 0 && !secondaryMenuContent.component;
18
+ }
19
+ function useContextValue() {
20
+ const disabled = useIsNavbarMobileSidebarDisabled();
21
+ const windowSize = useWindowSize();
22
+ const shouldRender = !disabled && windowSize === 'mobile';
23
+ const [shown, setShown] = useState(false);
24
+ // Close mobile sidebar on navigation pop
25
+ // Most likely firing when using the Android back button (but not only)
26
+ useHistoryPopHandler(() => {
27
+ if (shown) {
28
+ setShown(false);
29
+ // Prevent pop navigation; seems desirable enough
30
+ // See https://github.com/facebook/docusaurus/pull/5462#issuecomment-911699846
31
+ return false;
32
+ }
33
+ return undefined;
34
+ });
35
+ const toggle = useCallback(() => {
36
+ setShown((s) => !s);
37
+ }, []);
38
+ useEffect(() => {
39
+ if (windowSize === 'desktop') {
40
+ setShown(false);
41
+ }
42
+ }, [windowSize]);
43
+ return useMemo(() => ({ disabled, shouldRender, toggle, shown }), [disabled, shouldRender, toggle, shown]);
44
+ }
45
+ export function NavbarMobileSidebarProvider({ children, }) {
46
+ const value = useContextValue();
47
+ return <Context.Provider value={value}>{children}</Context.Provider>;
48
+ }
49
+ export function useNavbarMobileSidebar() {
50
+ const context = React.useContext(Context);
51
+ if (context === undefined) {
52
+ throw new ReactContextError('NavbarMobileSidebarProvider');
53
+ }
54
+ return context;
55
+ }
56
+ //# sourceMappingURL=navbarMobileSidebar.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"navbarMobileSidebar.js","sourceRoot":"","sources":["../../src/contexts/navbarMobileSidebar.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,EACZ,WAAW,EACX,SAAS,EACT,QAAQ,EACR,OAAO,GAER,MAAM,OAAO,CAAC;AACf,OAAO,EAAC,6BAA6B,EAAC,MAAM,+BAA+B,CAAC;AAC5E,OAAO,EAAC,aAAa,EAAC,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAC,oBAAoB,EAAC,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAC,cAAc,EAAC,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAC,iBAAiB,EAAC,M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C/C,CAAC,QAAQ,EAAE,YAAY,EAAE,MAAM,EAAE,KAAK,CAAC,CACxC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,2BAA2B,CAAC,EAC1C,QAAQ,GAGT;IACC,MAAM,KAAK,GAAG,eAAe,EAAE,CAAC;IAChC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;AACvE,CAAC;AAED,MAAM,UAAU,sBAAsB;IACpC,MAAM,OAAO,GAAG,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;IAC1C,IAAI,OAAO,KAAK,SAAS,EAAE;QACzB,MAAM,IAAI,iBAAiB,CAAC,6BAA6B,CAAC,CAAC;KAC5D;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Copyright (c) Facebook, Inc. and its affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import { type ReactNode, type ComponentType } from 'react';
8
+ export declare type NavbarSecondaryMenuComponent<Props> = ComponentType<Props>;
9
+ /** @internal */
10
+ export declare type Content = {
11
+ component: NavbarSecondaryMenuComponent<object>;
12
+ props: object;
13
+ } | {
14
+ component: null;
15
+ props: null;
16
+ };
17
+ /** @internal */
18
+ export declare function NavbarSecondaryMenuContentProvider({ children, }: {
19
+ children: ReactNode;
20
+ }): JSX.Element;
21
+ /** @internal */
22
+ export declare function useNavbarSecondaryMenuContent(): Content;
23
+ /**
24
+ * This component renders nothing by itself, but it fills the placeholder in the
25
+ * generic secondary menu layout. This reduces coupling between the main layout
26
+ * and the specific page.
27
+ *
28
+ * This kind of feature is often called portal/teleport/gateway/outlet...
29
+ * Various unmaintained React libs exist. Most up-to-date one:
30
+ * https://github.com/gregberge/react-teleporter
31
+ * Not sure any of those is safe regarding concurrent mode.
32
+ */
33
+ export declare function NavbarSecondaryMenuFiller<P extends object>({ component, props, }: {
34
+ component: NavbarSecondaryMenuComponent<P>;
35
+ props: P;
36
+ }): JSX.Element | null;
37
+ //# sourceMappingURL=content.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content.d.ts","sourceRoot":"","sources":["../../../src/contexts/navbarSecondaryMenu/content.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAc,EAIZ,KAAK,SAAS,EACd,KAAK,aAAa,EACnB,MAAM,OAAO,CAAC;AAUf,oBAAY,4BAA4B,CAAC,KAAK,IAAI,aAAa,CAAC,KAAK,CAAC,CAAC;AAEvE,gBAAgB;AAChB,oBAAY,OAAO,GACf;IACE,SAAS,EAAE,4BAA4B,CAAC,MAAM,CAAC,CAAC;IAChD,KAAK,EAAE,MAAM,CAAC;CACf,GACD;IAAC,SAAS,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,IAAI,CAAA;CAAC,CAAC;AASnC,gBAAgB;AAChB,wBAAgB,kCAAkC,CAAC,EACjD,QAAQ,GACT,EAAE;IACD,QAAQ,EAAE,SAAS,CAAC;CACrB,GAAG,GAAG,CAAC,OAAO,CAMd;AAED,gBAAgB;AAChB,wBAAgB,6BAA6B,IAAI,OAAO,CAMvD;AAED;;;;;;;;;GASG;AACH,wBAAgB,yBAAyB,CAAC,CAAC,SAAS,MAAM,EAAE,EAC1D,SAAS,EACT,KAAK,GACN,EAAE;IACD,SAAS,EAAE,4BAA4B,CAAC,CAAC,CAAC,CAAC;IAC3C,KAAK,EAAE,CAAC,CAAC;CACV,GAAG,GAAG,CAAC,OAAO,GAAG,IAAI,CAqBrB"}
@@ -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, useEffect, } from 'react';
8
+ import { ReactContextError, useShallowMemoObject } from '../../utils/reactUtils';
9
+ const Context = React.createContext(null);
10
+ /** @internal */
11
+ export function NavbarSecondaryMenuContentProvider({ children, }) {
12
+ const value = useState({ component: null, props: null });
13
+ return (
14
+ // @ts-expect-error: this context is hard to type
15
+ <Context.Provider value={value}>{children}</Context.Provider>);
16
+ }
17
+ /** @internal */
18
+ export function useNavbarSecondaryMenuContent() {
19
+ const value = useContext(Context);
20
+ if (!value) {
21
+ throw new ReactContextError('NavbarSecondaryMenuContentProvider');
22
+ }
23
+ return value[0];
24
+ }
25
+ /**
26
+ * This component renders nothing by itself, but it fills the placeholder in the
27
+ * generic secondary menu layout. This reduces coupling between the main layout
28
+ * and the specific page.
29
+ *
30
+ * This kind of feature is often called portal/teleport/gateway/outlet...
31
+ * Various unmaintained React libs exist. Most up-to-date one:
32
+ * https://github.com/gregberge/react-teleporter
33
+ * Not sure any of those is safe regarding concurrent mode.
34
+ */
35
+ export function NavbarSecondaryMenuFiller({ component, props, }) {
36
+ const context = useContext(Context);
37
+ if (!context) {
38
+ throw new ReactContextError('NavbarSecondaryMenuContentProvider');
39
+ }
40
+ const [, setContent] = context;
41
+ // To avoid useless context re-renders, props are memoized shallowly
42
+ const memoizedProps = useShallowMemoObject(props);
43
+ useEffect(() => {
44
+ // @ts-expect-error: this context is hard to type
45
+ setContent({ component, props: memoizedProps });
46
+ }, [setContent, component, memoizedProps]);
47
+ useEffect(() => () => setContent({ component: null, props: null }), [setContent]);
48
+ return null;
49
+ }
50
+ //# sourceMappingURL=content.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content.js","sourceRoot":"","sources":["../../../src/contexts/navbarSecondaryMenu/content.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,EACZ,QAAQ,EACR,UAAU,EACV,SAAS,GAGV,MAAM,OAAO,CAAC;AACf,OAAO,EAAC,iBAAiB,EAAE,oBAAoB,EAAC,MAAM,wBAAwB,CAAC;AAwB/E,MAAM,OAAO,GAAG,KAAK,CAAC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,IAAI,EAAE,KAAK,EAAE,IAAI,EAAC,CAAC,EACtD,CAAC,UAAU,CAAC,CACb,CAAC;IAEF,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,24 @@
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 } from 'react';
8
+ /** @internal */
9
+ export declare function NavbarSecondaryMenuDisplayProvider({ children, }: {
10
+ children: ReactNode;
11
+ }): JSX.Element;
12
+ /** Wires the logic for rendering the mobile navbar secondary menu. */
13
+ export declare function useNavbarSecondaryMenu(): {
14
+ /** Whether secondary menu is displayed. */
15
+ shown: boolean;
16
+ /**
17
+ * Hide the secondary menu; fired either when hiding the entire sidebar, or
18
+ * when going back to the primary menu.
19
+ */
20
+ hide: () => void;
21
+ /** The content returned from the current secondary menu filler. */
22
+ content: JSX.Element | undefined;
23
+ };
24
+ //# sourceMappingURL=display.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"display.d.ts","sourceRoot":"","sources":["../../../src/contexts/navbarSecondaryMenu/display.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAc,EAMZ,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AA6Cf,gBAAgB;AAChB,wBAAgB,kCAAkC,CAAC,EACjD,QAAQ,GACT,EAAE;IACD,QAAQ,EAAE,SAAS,CAAC;CACrB,GAAG,GAAG,CAAC,OAAO,CAGd;AAUD,sEAAsE;AACtE,wBAAgB,sBAAsB,IAAI;IACxC,2CAA2C;IAC3C,KAAK,EAAE,OAAO,CAAC;IACf;;;OAGG;IACH,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB,mEAAmE;IACnE,OAAO,EAAE,GAAG,CAAC,OAAO,GAAG,SAAS,CAAC;CAClC,CAaA"}
@@ -0,0 +1,62 @@
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, useEffect, useMemo, useCallback, } from 'react';
8
+ import { ReactContextError, usePrevious } from '../../utils/reactUtils';
9
+ import { useNavbarMobileSidebar } from '../navbarMobileSidebar';
10
+ import { useNavbarSecondaryMenuContent } from './content';
11
+ const Context = React.createContext(null);
12
+ function useContextValue() {
13
+ const mobileSidebar = useNavbarMobileSidebar();
14
+ const content = useNavbarSecondaryMenuContent();
15
+ const [shown, setShown] = useState(false);
16
+ const hasContent = content.component !== null;
17
+ const previousHasContent = usePrevious(hasContent);
18
+ // When content is become available for the first time (set in useEffect)
19
+ // we set this content to be shown!
20
+ useEffect(() => {
21
+ const contentBecameAvailable = hasContent && !previousHasContent;
22
+ if (contentBecameAvailable) {
23
+ setShown(true);
24
+ }
25
+ }, [hasContent, previousHasContent]);
26
+ // On sidebar close, secondary menu is set to be shown on next re-opening
27
+ // (if any secondary menu content available)
28
+ useEffect(() => {
29
+ if (!hasContent) {
30
+ setShown(false);
31
+ return;
32
+ }
33
+ if (!mobileSidebar.shown) {
34
+ setShown(true);
35
+ }
36
+ }, [mobileSidebar.shown, hasContent]);
37
+ return useMemo(() => [shown, setShown], [shown]);
38
+ }
39
+ /** @internal */
40
+ export function NavbarSecondaryMenuDisplayProvider({ children, }) {
41
+ const value = useContextValue();
42
+ return <Context.Provider value={value}>{children}</Context.Provider>;
43
+ }
44
+ function renderElement(content) {
45
+ if (content.component) {
46
+ const Comp = content.component;
47
+ return <Comp {...content.props}/>;
48
+ }
49
+ return undefined;
50
+ }
51
+ /** Wires the logic for rendering the mobile navbar secondary menu. */
52
+ export function useNavbarSecondaryMenu() {
53
+ const value = useContext(Context);
54
+ if (!value) {
55
+ throw new ReactContextError('NavbarSecondaryMenuDisplayProvider');
56
+ }
57
+ const [shown, setShown] = value;
58
+ const hide = useCallback(() => setShown(false), [setShown]);
59
+ const content = useNavbarSecondaryMenuContent();
60
+ return useMemo(() => ({ shown, hide, content: renderElement(content) }), [hide, content, shown]);
61
+ }
62
+ //# sourceMappingURL=display.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"display.js","sourceRoot":"","sources":["../../../src/contexts/navbarSecondaryMenu/display.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,EACZ,QAAQ,EACR,UAAU,EACV,SAAS,EACT,OAAO,EACP,WAAW,GAEZ,MAAM,OAAO,CAAC;AACf,OAAO,EAAC,iBAAiB,EAAE,WAAW,EAAC,MAAM,wBAAwB,CAAC;AACtE,OAAO,EAAC,sBAAsB,EAAC,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAC,6BAA6B,EAAe,MAAM,WAAW,CAAC;AAOtE,MAAM,OAAO,GAAG,KAAK,CAAC,aAAa,CAAsB,IAAI,CAAC,CAAC;AAE/D,SAAS,eAAe;IACtB,MAAM,aAAa,GAAG,sBAAsB,EAAE,CAAC;IAC/C,MAAM,OAAO,GAAG,6BAA6B,EAAE,CAAC;IAEhD,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAE1C,MAAM,UAAU,GAAG,OAAO,CAAC,SAAS,KAAK,IAAI,CAAC;IAC9C,MAAM,kBAAkB,GAAG,WAAW,CAAC,UAAU,CAAC,CAAC;IAEnD,yEAAyE;IACzE,mCAAmC;IACnC,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,sBAAsB,GAAG,UAAU,IAAI,CAAC,kBAAkB,CAAC;QACjE,IAAI,sBAAsB,EAAE;YAC1B,QAAQ,CAAC,IAAI,CAAC,CAAC;SAChB;IACH,CAAC,EAAE,CAAC,UAAU,EAAE,kBAAkB,CAAC,CAAC,CAAC;IAErC,yEAAyE;IACzE,4CAA4C;IAC5C,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,CAAC,UAAU,EAAE;YACf,QAAQ,CAAC,KAAK,CAAC,CAAC;YA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AC,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,aAAa,CAAC,OAAO,CAAC,EAAC,CAAC,EACtD,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,CACvB,CAAC;AACJ,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 } from 'react';
8
+ declare type ContextValue = {
9
+ /** A map from `groupId` to the `value` of the saved choice. */
10
+ readonly tabGroupChoices: {
11
+ readonly [groupId: string]: string;
12
+ };
13
+ /** Set the new choice value of a group. */
14
+ readonly setTabGroupChoices: (groupId: string, newChoice: string) => void;
15
+ };
16
+ export declare function TabGroupChoiceProvider({ children, }: {
17
+ children: ReactNode;
18
+ }): JSX.Element;
19
+ export declare function useTabGroupChoice(): ContextValue;
20
+ export {};
21
+ //# sourceMappingURL=tabGroupChoice.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tabGroupChoice.d.ts","sourceRoot":"","sources":["../../src/contexts/tabGroupChoice.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAc,EAMZ,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAMf,aAAK,YAAY,GAAG;IAClB,+DAA+D;IAC/D,QAAQ,CAAC,eAAe,EAAE;QAAC,QAAQ,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAAA;KAAC,CAAC;IAC/D,2CAA2C;IAC3C,QAAQ,CAAC,kBAAkB,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;CAC3E,CAAC;AA4CF,wBAAgB,sBAAsB,CAAC,EACrC,QAAQ,GACT,EAAE;IACD,QAAQ,EAAE,SAAS,CAAC;CACrB,GAAG,GAAG,CAAC,OAAO,CAGd;AAED,wBAAgB,iBAAiB,IAAI,YAAY,CAMhD"}
@@ -0,0 +1,49 @@
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, useCallback, useEffect, useMemo, useContext, } from 'react';
8
+ import { createStorageSlot, listStorageKeys } from '../utils/storageUtils';
9
+ import { ReactContextError } from '../utils/reactUtils';
10
+ const TAB_CHOICE_PREFIX = 'docusaurus.tab.';
11
+ const Context = React.createContext(undefined);
12
+ function useContextValue() {
13
+ const [tabGroupChoices, setChoices] = useState({});
14
+ const setChoiceSyncWithLocalStorage = useCallback((groupId, newChoice) => {
15
+ createStorageSlot(`${TAB_CHOICE_PREFIX}${groupId}`).set(newChoice);
16
+ }, []);
17
+ useEffect(() => {
18
+ try {
19
+ const localStorageChoices = {};
20
+ listStorageKeys().forEach((storageKey) => {
21
+ if (storageKey.startsWith(TAB_CHOICE_PREFIX)) {
22
+ const groupId = storageKey.substring(TAB_CHOICE_PREFIX.length);
23
+ localStorageChoices[groupId] = createStorageSlot(storageKey).get();
24
+ }
25
+ });
26
+ setChoices(localStorageChoices);
27
+ }
28
+ catch (err) {
29
+ console.error(err);
30
+ }
31
+ }, []);
32
+ const setTabGroupChoices = useCallback((groupId, newChoice) => {
33
+ setChoices((oldChoices) => ({ ...oldChoices, [groupId]: newChoice }));
34
+ setChoiceSyncWithLocalStorage(groupId, newChoice);
35
+ }, [setChoiceSyncWithLocalStorage]);
36
+ return useMemo(() => ({ tabGroupChoices, setTabGroupChoices }), [tabGroupChoices, setTabGroupChoices]);
37
+ }
38
+ export function TabGroupChoiceProvider({ children, }) {
39
+ const value = useContextValue();
40
+ return <Context.Provider value={value}>{children}</Context.Provider>;
41
+ }
42
+ export function useTabGroupChoice() {
43
+ const context = useContext(Context);
44
+ if (context == null) {
45
+ throw new ReactContextError('TabGroupChoiceProvider');
46
+ }
47
+ return context;
48
+ }
49
+ //# sourceMappingURL=tabGroupChoice.js.map
@@ -0,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AAC,KAAK,CAAC,GAAG,CAAC,CAAC;SACpB;IACH,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,MAAM,kBAAkB,GAAG,WAAW,CACpC,CAAC,OAAe,EAAE,SAAiB,EAAE,EAAE;QACrC,UAAU,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC,EAAC,GAAG,UAAU,EAAE,CAAC,OAAO,CAAC,EAAE,SAAS,EAAC,CAAC,CAAC,CAAC;QACpE,6BAA6B,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;IACpD,CAAC,EACD,CAAC,6BAA6B,CAAC,CAChC,CAAC;IAEF,OAAO,OAAO,CACZ,GAAG,EAAE,CAAC,CAAC,EAAC,eAAe,EAAE,kBAAkB,EAAC,CAAC,EAC7C,CAAC,eAAe,EAAE,kBAAkB,CAAC,CACtC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,EACrC,QAAQ,GAGT;IACC,MAAM,KAAK,GAAG,eAAe,EAAE,CAAC;IAChC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;AACvE,CAAC;AAED,MAAM,UAAU,iBAAiB;IAC/B,MAAM,OAAO,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC;IACpC,IAAI,OAAO,IAAI,IAAI,EAAE;QACnB,MAAM,IAAI,iBAAiB,CAAC,wBAAwB,CAAC,CAAC;KACvD;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -4,4 +4,7 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
- export declare function useChangeRoute(onRouteChange: () => void): void;
7
+
8
+ body:not(.navigation-with-keyboard) *:not(input):focus {
9
+ outline: none;
10
+ }
@@ -0,0 +1,27 @@
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
+ /** Wires the logic for the back to top button. */
8
+ export declare function useBackToTopButton({ threshold, }: {
9
+ /**
10
+ * The minimum vertical scroll position, above which a scroll-up would not
11
+ * cause `shown` to become `true`. This is because BTT is only useful if the
12
+ * user is far down the page.
13
+ */
14
+ threshold: number;
15
+ }): {
16
+ /**
17
+ * Whether the button should be displayed. We only show if the user has
18
+ * scrolled up and is on a vertical position greater than `threshold`.
19
+ */
20
+ shown: boolean;
21
+ /**
22
+ * A (memoized) handle for starting the scroll, which you can directly plug
23
+ * into the props.
24
+ */
25
+ scrollToTop: () => void;
26
+ };
27
+ //# sourceMappingURL=useBackToTopButton.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useBackToTopButton.d.ts","sourceRoot":"","sources":["../../src/hooks/useBackToTopButton.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,kDAAkD;AAClD,wBAAgB,kBAAkB,CAAC,EACjC,SAAS,GACV,EAAE;IACD;;;;OAIG;IACH,SAAS,EAAE,MAAM,CAAC;CACnB,GAAG;IACF;;;OAGG;IACH,KAAK,EAAE,OAAO,CAAC;IACf;;;OAGG;IACH,WAAW,EAAE,MAAM,IAAI,CAAC;CACzB,CAwCA"}
@@ -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 { useRef, useState } from 'react';
8
+ import { useScrollPosition, useSmoothScrollTo } from '../utils/scrollUtils';
9
+ import { useLocationChange } from '../utils/useLocationChange';
10
+ /** Wires the logic for the back to top button. */
11
+ export function useBackToTopButton({ threshold, }) {
12
+ const [shown, setShown] = useState(false);
13
+ const isFocusedAnchor = useRef(false);
14
+ const { startScroll, cancelScroll } = useSmoothScrollTo();
15
+ useScrollPosition(({ scrollY: scrollTop }, lastPosition) => {
16
+ const lastScrollTop = lastPosition?.scrollY;
17
+ // Component is just being mounted. Not really a scroll event from the user.
18
+ // Ignore it.
19
+ if (!lastScrollTop) {
20
+ return;
21
+ }
22
+ if (isFocusedAnchor.current) {
23
+ // This scroll position change is triggered by navigating to an anchor.
24
+ // Ignore it.
25
+ isFocusedAnchor.current = false;
26
+ }
27
+ else if (scrollTop >= lastScrollTop) {
28
+ // The user has scrolled down to "fight against" the animation. Cancel any
29
+ // animation under progress.
30
+ cancelScroll();
31
+ setShown(false);
32
+ }
33
+ else if (scrollTop < threshold) {
34
+ // Scrolled to the minimum position; hide the button.
35
+ setShown(false);
36
+ }
37
+ else if (scrollTop + window.innerHeight <
38
+ document.documentElement.scrollHeight) {
39
+ setShown(true);
40
+ }
41
+ });
42
+ useLocationChange((locationChangeEvent) => {
43
+ if (locationChangeEvent.location.hash) {
44
+ isFocusedAnchor.current = true;
45
+ setShown(false);
46
+ }
47
+ });
48
+ return { shown, scrollToTop: () => startScroll(0) };
49
+ }
50
+ //# sourceMappingURL=useBackToTopButton.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useBackToTopButton.js","sourceRoot":"","sources":["../../src/hooks/useBackToTopButton.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAC,MAAM,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAC;AACvC,OAAO,EAAC,iBAAiB,EAAE,iBAAiB,EAAC,MAAM,sBAAsB,CAAC;AAC1E,OAAO,EAAC,iBAAiB,EAAC,MAAM,4BAA4B,CAAC;AAE7D,kDAAkD;AAClD,MAAM,UAAU,kBAAkB,CAAC,EACjC,SAAS,GAQV;IAYC,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC1C,MAAM,eAAe,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IACtC,MAAM,EAAC,WAAW,EAAE,YAAY,EAAC,GAAG,iBAAiB,EAAE,CAAC;IAExD,iBAAiB,CAAC,CAAC,EAAC,OAAO,EAAE,SAAS,EAAC,EAAE,YAAY,EAAE,EAAE;QACvD,MAAM,aAAa,GAAG,YAAY,EAAE,OAAO,CAAC;QAC5C,4EAA4E;QAC5E,aAAa;QACb,IAAI,CAAC,aAAa,EAAE;YAClB,OAAO;SACR;QACD,IAAI,eAAe,CAAC,OAAO,EAAE;YAC3B,uEAAuE;YACvE,aAAa;YACb,eAAe,CAAC,OAAO,GAAG,KAAK,CAAC;SACjC;aAAM,IAAI,SAAS,IAAI,aAAa,EAAE;YACrC,0EAA0E;YAC1E,4BAA4B;YAC5B,YAAY,EAAE,CAAC;YACf,QAAQ,CAAC,KAAK,CAAC,CAAC;SACjB;aAAM,IAAI,SAAS,GAAG,SAAS,EAAE;YAChC,qDAAqD;YACrD,QAAQ,CAAC,KAAK,CAAC,CAAC;SACjB;aAAM,IACL,SAAS,GAAG,MAAM,CAAC,WAAW;YAC9B,QAAQ,CAAC,eAAe,CAAC,YAAY,EACrC;YACA,QAAQ,CAAC,IAAI,CAAC,CAAC;SAChB;IACH,CAAC,CAAC,CAAC;IAEH,iBAAiB,CAAC,CAAC,mBAAmB,EAAE,EAAE;QACxC,IAAI,mBAAmB,CAAC,QAAQ,CAAC,IAAI,EAAE;YACrC,eAAe,CAAC,OAAO,GAAG,IAAI,CAAC;YAC/B,QAAQ,CAAC,KAAK,CAAC,CAAC;SACjB;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,EAAC,KAAK,EAAE,WAAW,EAAE,GAAG,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC,EAAC,CAAC;AACpD,CAAC"}
@@ -0,0 +1,14 @@
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 { RefObject } from 'react';
8
+ export declare function useCodeWordWrap(): {
9
+ readonly codeBlockRef: RefObject<HTMLPreElement>;
10
+ readonly isEnabled: boolean;
11
+ readonly isCodeScrollable: boolean;
12
+ readonly toggle: () => void;
13
+ };
14
+ //# sourceMappingURL=useCodeWordWrap.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useCodeWordWrap.d.ts","sourceRoot":"","sources":["../../src/hooks/useCodeWordWrap.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,OAAO,CAAC;AAgDrC,wBAAgB,eAAe,IAAI;IACjC,QAAQ,CAAC,YAAY,EAAE,SAAS,CAAC,cAAc,CAAC,CAAC;IACjD,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,gBAAgB,EAAE,OAAO,CAAC;IACnC,QAAQ,CAAC,MAAM,EAAE,MAAM,IAAI,CAAC;CAC7B,CA6CA"}
@@ -0,0 +1,67 @@
1
+ import { useState, useCallback, useEffect, useRef } from 'react';
2
+ import { useMutationObserver } from './useMutationObserver';
3
+ // Callback fires when the "hidden" attribute of a tabpanel changes
4
+ // See https://github.com/facebook/docusaurus/pull/7485
5
+ function useTabBecameVisibleCallback(codeBlockRef, callback) {
6
+ const [hiddenTabElement, setHiddenTabElement] = useState();
7
+ const updateHiddenTabElement = useCallback(() => {
8
+ // No need to observe non-hidden tabs
9
+ // + we want to force a re-render when a tab becomes visible
10
+ setHiddenTabElement(codeBlockRef.current?.closest('[role=tabpanel][hidden]'));
11
+ }, [codeBlockRef, setHiddenTabElement]);
12
+ useEffect(() => {
13
+ updateHiddenTabElement();
14
+ }, [updateHiddenTabElement]);
15
+ useMutationObserver(hiddenTabElement, (mutations) => {
16
+ mutations.forEach((mutation) => {
17
+ if (mutation.type === 'attributes' &&
18
+ mutation.attributeName === 'hidden') {
19
+ callback();
20
+ updateHiddenTabElement();
21
+ }
22
+ });
23
+ }, {
24
+ attributes: true,
25
+ characterData: false,
26
+ childList: false,
27
+ subtree: false,
28
+ });
29
+ }
30
+ export function useCodeWordWrap() {
31
+ const [isEnabled, setIsEnabled] = useState(false);
32
+ const [isCodeScrollable, setIsCodeScrollable] = useState(false);
33
+ const codeBlockRef = useRef(null);
34
+ const toggle = useCallback(() => {
35
+ const codeElement = codeBlockRef.current.querySelector('code');
36
+ if (isEnabled) {
37
+ codeElement.removeAttribute('style');
38
+ }
39
+ else {
40
+ codeElement.style.whiteSpace = 'pre-wrap';
41
+ // When code wrap is enabled, we want to avoid a scrollbar in any case
42
+ // Ensure that very very long words/strings/tokens still wrap
43
+ codeElement.style.overflowWrap = 'anywhere';
44
+ }
45
+ setIsEnabled((value) => !value);
46
+ }, [codeBlockRef, isEnabled]);
47
+ const updateCodeIsScrollable = useCallback(() => {
48
+ const { scrollWidth, clientWidth } = codeBlockRef.current;
49
+ const isScrollable = scrollWidth > clientWidth ||
50
+ codeBlockRef.current.querySelector('code').hasAttribute('style');
51
+ setIsCodeScrollable(isScrollable);
52
+ }, [codeBlockRef]);
53
+ useTabBecameVisibleCallback(codeBlockRef, updateCodeIsScrollable);
54
+ useEffect(() => {
55
+ updateCodeIsScrollable();
56
+ }, [isEnabled, updateCodeIsScrollable]);
57
+ useEffect(() => {
58
+ window.addEventListener('resize', updateCodeIsScrollable, {
59
+ passive: true,
60
+ });
61
+ return () => {
62
+ window.removeEventListener('resize', updateCodeIsScrollable);
63
+ };
64
+ }, [updateCodeIsScrollable]);
65
+ return { codeBlockRef, isEnabled, isCodeScrollable, toggle };
66
+ }
67
+ //# sourceMappingURL=useCodeWordWrap.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useCodeWordWrap.js","sourceRoot":"","sources":["../../src/hooks/useCodeWordWrap.ts"],"names":[],"mappings":"AAOA,OAAO,EAAC,QAAQ,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAC,MAAM,OAAO,CAAC;AAC/D,OAAO,EAAC,mBAAmB,EAAC,MAAM,uBAAuB,CAAC;AAE1D,mEAAmE;AACnE,uDAAuD;AACvD,SAAS,2BAA2B,CAClC,YAAuC,EACv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AAC7D,CAAC"}
@@ -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
+ * Wires the imperative logic of a hideable navbar.
9
+ * @param hideOnScroll If `false`, this hook is basically a no-op.
10
+ */
11
+ export declare function useHideableNavbar(hideOnScroll: boolean): {
12
+ /** A ref to the navbar component. Plug this into the actual element. */
13
+ readonly navbarRef: (node: HTMLElement | null) => void;
14
+ /** If `false`, the navbar component should not be rendered. */
15
+ readonly isNavbarVisible: boolean;
16
+ };
17
+ //# sourceMappingURL=useHideableNavbar.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useHideableNavbar.d.ts","sourceRoot":"","sources":["../../src/hooks/useHideableNavbar.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,YAAY,EAAE,OAAO,GAAG;IACxD,wEAAwE;IACxE,QAAQ,CAAC,SAAS,EAAE,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI,KAAK,IAAI,CAAC;IACvD,+DAA+D;IAC/D,QAAQ,CAAC,eAAe,EAAE,OAAO,CAAC;CACnC,CAsDA"}
@@ -0,0 +1,60 @@
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 { useState, useCallback, useRef } from 'react';
8
+ import { useLocationChange } from '../utils/useLocationChange';
9
+ import { useScrollPosition } from '../utils/scrollUtils';
10
+ /**
11
+ * Wires the imperative logic of a hideable navbar.
12
+ * @param hideOnScroll If `false`, this hook is basically a no-op.
13
+ */
14
+ export function useHideableNavbar(hideOnScroll) {
15
+ const [isNavbarVisible, setIsNavbarVisible] = useState(hideOnScroll);
16
+ const isFocusedAnchor = useRef(false);
17
+ const navbarHeight = useRef(0);
18
+ const navbarRef = useCallback((node) => {
19
+ if (node !== null) {
20
+ navbarHeight.current = node.getBoundingClientRect().height;
21
+ }
22
+ }, []);
23
+ useScrollPosition(({ scrollY: scrollTop }, lastPosition) => {
24
+ if (!hideOnScroll) {
25
+ return;
26
+ }
27
+ // Needed mostly for handling rubber band scrolling.
28
+ // See https://github.com/facebook/docusaurus/pull/5721
29
+ if (scrollTop < navbarHeight.current) {
30
+ setIsNavbarVisible(true);
31
+ return;
32
+ }
33
+ if (isFocusedAnchor.current) {
34
+ isFocusedAnchor.current = false;
35
+ return;
36
+ }
37
+ const lastScrollTop = lastPosition?.scrollY;
38
+ const documentHeight = document.documentElement.scrollHeight - navbarHeight.current;
39
+ const windowHeight = window.innerHeight;
40
+ if (lastScrollTop && scrollTop >= lastScrollTop) {
41
+ setIsNavbarVisible(false);
42
+ }
43
+ else if (scrollTop + windowHeight < documentHeight) {
44
+ setIsNavbarVisible(true);
45
+ }
46
+ });
47
+ useLocationChange((locationChangeEvent) => {
48
+ if (!hideOnScroll) {
49
+ return;
50
+ }
51
+ if (locationChangeEvent.location.hash) {
52
+ isFocusedAnchor.current = true;
53
+ setIsNavbarVisible(false);
54
+ return;
55
+ }
56
+ setIsNavbarVisible(true);
57
+ });
58
+ return { navbarRef, isNavbarVisible };
59
+ }
60
+ //# sourceMappingURL=useHideableNavbar.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useHideableNavbar.js","sourceRoot":"","sources":["../../src/hooks/useHideableNavbar.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAC,QAAQ,EAAE,WAAW,EAAE,MAAM,EAAC,MAAM,OAAO,CAAC;AACpD,OAAO,EAAC,iBAAiB,EAAC,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAC,iBAAiB,EAAC,MAAM,sBAAsB,CAAC;AAEvD;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAAC,YAAqB;IAMrD,MAAM,CAAC,eAAe,EAAE,kBAAkB,C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,QAAQ,CAAC,IAAI,EAAE;YACrC,eAAe,CAAC,OAAO,GAAG,IAAI,CAAC;YAC/B,kBAAkB,CAAC,KAAK,CAAC,CAAC;YAC1B,OAAO;SACR;QAED,kBAAkB,CAAC,IAAI,CAAC,CAAC;IAC3B,CAAC,CAAC,CAAC;IAEH,OAAO,EAAC,SAAS,EAAE,eAAe,EAAC,CAAC;AACtC,CAAC"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Copyright (c) Facebook, Inc. and its affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import './styles.css';
8
+ export declare const keyboardFocusedClassName = "navigation-with-keyboard";
9
+ /**
10
+ * Side-effect that adds the `keyboardFocusedClassName` to the body element when
11
+ * the keyboard has been pressed, or removes it when the mouse is clicked.
12
+ *
13
+ * The presence of this class name signals that the user may be using keyboard
14
+ * for navigation, and the theme **must** add focus outline when this class name
15
+ * is present. (And optionally not if it's absent, for design purposes)
16
+ *
17
+ * Inspired by https://hackernoon.com/removing-that-ugly-focus-ring-and-keeping-it-too-6c8727fefcd2
18
+ */
19
+ export declare function useKeyboardNavigation(): void;
20
+ //# sourceMappingURL=useKeyboardNavigation.d.ts.map