@docusaurus/theme-classic 2.0.0-beta.14 → 2.0.0-beta.15

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 (152) hide show
  1. package/README.md +1 -1
  2. package/lib/index.js +7 -16
  3. package/lib/theme-classic.d.ts +89 -182
  4. package/lib/validateThemeConfig.js +13 -1
  5. package/lib-next/theme/BackToTopButton/styles.module.css +1 -1
  6. package/lib-next/theme/BlogListPaginator/index.js +12 -12
  7. package/lib-next/theme/BlogPostAuthor/index.js +1 -1
  8. package/lib-next/theme/BlogPostAuthors/index.js +12 -2
  9. package/lib-next/theme/BlogPostAuthors/styles.module.css +10 -0
  10. package/lib-next/theme/BlogPostItem/index.js +12 -15
  11. package/lib-next/theme/BlogPostPage/index.js +10 -7
  12. package/lib-next/theme/BlogPostPaginator/index.js +11 -15
  13. package/lib-next/theme/BlogSidebar/styles.module.css +2 -0
  14. package/lib-next/theme/CodeBlock/index.js +44 -9
  15. package/lib-next/theme/CodeBlock/styles.module.css +12 -7
  16. package/lib-next/theme/DocCard/styles.module.css +3 -3
  17. package/lib-next/theme/DocCategoryGeneratedIndexPage/index.js +6 -3
  18. package/lib-next/theme/DocItem/index.js +9 -6
  19. package/lib-next/theme/DocItem/styles.module.css +2 -2
  20. package/lib-next/theme/DocPage/index.js +7 -3
  21. package/lib-next/theme/DocPage/styles.module.css +1 -0
  22. package/lib-next/theme/DocPaginator/index.js +26 -4
  23. package/lib-next/theme/DocSidebar/index.js +2 -2
  24. package/lib-next/theme/DocSidebar/styles.module.css +1 -0
  25. package/lib-next/theme/DocSidebarItem/index.js +43 -21
  26. package/lib-next/theme/DocSidebarItem/styles.module.css +1 -0
  27. package/lib-next/theme/DocSidebarItems/index.js +28 -0
  28. package/{src/theme/hooks/styles.css → lib-next/theme/DocSidebarItems/styles.module.css} +12 -2
  29. package/lib-next/theme/DocVersionBanner/index.js +4 -1
  30. package/lib-next/theme/Footer/styles.module.css +2 -1
  31. package/lib-next/theme/Heading/index.js +39 -42
  32. package/lib-next/theme/Heading/styles.css +1 -1
  33. package/lib-next/theme/Layout/index.js +1 -2
  34. package/lib-next/theme/LayoutHead/index.js +5 -9
  35. package/lib-next/theme/LayoutProviders/index.js +6 -6
  36. package/lib-next/theme/MDXComponents/index.js +18 -31
  37. package/lib-next/theme/MDXComponents/styles.css +4 -0
  38. package/lib-next/theme/MDXPage/index.js +3 -10
  39. package/lib-next/theme/Navbar/index.js +6 -6
  40. package/lib-next/theme/NavbarItem/DefaultNavbarItem.js +4 -66
  41. package/lib-next/theme/NavbarItem/DocNavbarItem.js +5 -2
  42. package/lib-next/theme/NavbarItem/DocSidebarNavbarItem.js +73 -0
  43. package/lib-next/theme/NavbarItem/DocsVersionDropdownNavbarItem.js +5 -3
  44. package/lib-next/theme/NavbarItem/DocsVersionNavbarItem.js +4 -1
  45. package/lib-next/theme/NavbarItem/DropdownNavbarItem.js +5 -5
  46. package/lib-next/theme/NavbarItem/NavbarNavLink.js +70 -0
  47. package/lib-next/theme/NavbarItem/index.js +1 -2
  48. package/lib-next/theme/{hooks/styles.css → NavbarItem/utils.js} +3 -4
  49. package/lib-next/theme/PaginatorNavLink/index.js +20 -0
  50. package/lib-next/theme/SkipToContent/index.js +1 -1
  51. package/lib-next/theme/SkipToContent/styles.module.css +7 -0
  52. package/lib-next/theme/TOCCollapsible/styles.module.css +2 -2
  53. package/lib-next/theme/Tabs/__tests__/index.test.js +8 -6
  54. package/lib-next/theme/Tabs/index.js +6 -3
  55. package/lib-next/theme/Tag/styles.module.css +4 -4
  56. package/lib-next/theme/ThemedImage/index.js +2 -2
  57. package/lib-next/theme/Toggle/styles.module.css +16 -15
  58. package/lib-next/theme/prism-include-languages.js +10 -3
  59. package/package.json +16 -17
  60. package/src/index.ts +10 -21
  61. package/src/theme/Admonition/index.tsx +1 -1
  62. package/src/theme/BackToTopButton/styles.module.css +1 -1
  63. package/src/theme/BlogListPaginator/index.tsx +12 -12
  64. package/src/theme/BlogPostAuthor/index.tsx +1 -1
  65. package/src/theme/BlogPostAuthors/index.tsx +12 -2
  66. package/src/theme/BlogPostAuthors/styles.module.css +10 -0
  67. package/src/theme/BlogPostItem/index.tsx +13 -15
  68. package/src/theme/BlogPostPage/index.tsx +10 -7
  69. package/src/theme/BlogPostPaginator/index.tsx +11 -15
  70. package/src/theme/BlogSidebar/styles.module.css +2 -0
  71. package/src/theme/CodeBlock/index.tsx +45 -10
  72. package/src/theme/CodeBlock/styles.module.css +12 -7
  73. package/src/theme/DocCard/index.tsx +2 -2
  74. package/src/theme/DocCard/styles.module.css +3 -3
  75. package/src/theme/DocCardList/index.tsx +1 -1
  76. package/src/theme/DocCategoryGeneratedIndexPage/index.tsx +7 -3
  77. package/src/theme/DocItem/index.tsx +9 -6
  78. package/src/theme/DocItem/styles.module.css +2 -2
  79. package/src/theme/DocItemFooter/index.tsx +1 -1
  80. package/src/theme/DocPage/index.tsx +8 -4
  81. package/src/theme/DocPage/styles.module.css +1 -0
  82. package/src/theme/DocPaginator/index.tsx +26 -4
  83. package/src/theme/DocSidebar/index.tsx +3 -3
  84. package/src/theme/DocSidebar/styles.module.css +1 -0
  85. package/src/theme/DocSidebarItem/index.tsx +34 -23
  86. package/src/theme/DocSidebarItem/styles.module.css +1 -0
  87. package/src/theme/DocSidebarItems/index.tsx +32 -0
  88. package/src/theme/{UserPreferencesContext.ts → DocSidebarItems/styles.module.css} +11 -3
  89. package/src/theme/DocVersionBanner/index.tsx +3 -3
  90. package/src/theme/Footer/index.tsx +4 -4
  91. package/src/theme/Footer/styles.module.css +2 -1
  92. package/src/theme/Heading/index.tsx +39 -46
  93. package/src/theme/Heading/styles.css +1 -1
  94. package/src/theme/Layout/index.tsx +1 -2
  95. package/src/theme/LayoutHead/index.tsx +4 -8
  96. package/src/theme/LayoutProviders/index.tsx +6 -6
  97. package/src/theme/MDXComponents/index.tsx +26 -37
  98. package/src/theme/MDXComponents/styles.css +4 -0
  99. package/src/theme/MDXPage/index.tsx +3 -11
  100. package/src/theme/Navbar/index.tsx +7 -7
  101. package/src/theme/NavbarItem/DefaultNavbarItem.tsx +6 -62
  102. package/src/theme/NavbarItem/DocNavbarItem.tsx +8 -5
  103. package/src/theme/NavbarItem/DocSidebarNavbarItem.tsx +84 -0
  104. package/src/theme/NavbarItem/DocsVersionDropdownNavbarItem.tsx +9 -6
  105. package/src/theme/NavbarItem/DocsVersionNavbarItem.tsx +2 -2
  106. package/src/theme/NavbarItem/DropdownNavbarItem.tsx +5 -5
  107. package/src/theme/NavbarItem/NavbarNavLink.tsx +68 -0
  108. package/src/theme/NavbarItem/index.tsx +3 -5
  109. package/{lib-next/theme/UserPreferencesContext.js → src/theme/NavbarItem/utils.ts} +4 -3
  110. package/src/theme/PaginatorNavLink/index.tsx +22 -0
  111. package/src/theme/SkipToContent/index.tsx +1 -1
  112. package/src/theme/SkipToContent/styles.module.css +7 -0
  113. package/src/theme/TOCCollapsible/styles.module.css +2 -2
  114. package/src/theme/TOCItems/index.tsx +2 -2
  115. package/src/theme/Tabs/index.tsx +7 -4
  116. package/src/theme/Tag/styles.module.css +4 -4
  117. package/src/theme/TagsListByLetter/index.tsx +1 -1
  118. package/src/theme/ThemedImage/index.tsx +2 -2
  119. package/src/theme/Toggle/index.tsx +1 -1
  120. package/src/theme/Toggle/styles.module.css +16 -15
  121. package/src/theme/prism-include-languages.ts +10 -3
  122. package/src/theme-classic.d.ts +89 -182
  123. package/src/translations.ts +2 -2
  124. package/src/validateThemeConfig.ts +16 -0
  125. package/lib-next/theme/DocPaginatorNavLink/index.js +0 -36
  126. package/lib-next/theme/ThemeContext.js +0 -9
  127. package/lib-next/theme/ThemeProvider/index.js +0 -28
  128. package/lib-next/theme/UserPreferencesProvider/index.js +0 -27
  129. package/lib-next/theme/hooks/useDocs.js +0 -10
  130. package/lib-next/theme/hooks/useHideableNavbar.js +0 -66
  131. package/lib-next/theme/hooks/useKeyboardNavigation.js +0 -35
  132. package/lib-next/theme/hooks/useLockBodyScroll.js +0 -18
  133. package/lib-next/theme/hooks/usePrismTheme.js +0 -20
  134. package/lib-next/theme/hooks/useTabGroupChoice.js +0 -39
  135. package/lib-next/theme/hooks/useTheme.js +0 -81
  136. package/lib-next/theme/hooks/useThemeContext.js +0 -22
  137. package/lib-next/theme/hooks/useUserPreferencesContext.js +0 -22
  138. package/lib-next/theme/hooks/useWindowSize.js +0 -59
  139. package/src/theme/DocPaginatorNavLink/index.tsx +0 -38
  140. package/src/theme/ThemeContext.ts +0 -15
  141. package/src/theme/ThemeProvider/index.tsx +0 -28
  142. package/src/theme/UserPreferencesProvider/index.tsx +0 -30
  143. package/src/theme/hooks/useDocs.ts +0 -11
  144. package/src/theme/hooks/useHideableNavbar.ts +0 -72
  145. package/src/theme/hooks/useKeyboardNavigation.ts +0 -39
  146. package/src/theme/hooks/useLockBodyScroll.ts +0 -20
  147. package/src/theme/hooks/usePrismTheme.ts +0 -22
  148. package/src/theme/hooks/useTabGroupChoice.ts +0 -46
  149. package/src/theme/hooks/useTheme.ts +0 -91
  150. package/src/theme/hooks/useThemeContext.ts +0 -23
  151. package/src/theme/hooks/useUserPreferencesContext.ts +0 -25
  152. package/src/theme/hooks/useWindowSize.ts +0 -69
@@ -12,14 +12,21 @@ import type * as PrismNamespace from 'prismjs';
12
12
  const prismIncludeLanguages = (PrismObject: typeof PrismNamespace): void => {
13
13
  if (ExecutionEnvironment.canUseDOM) {
14
14
  const {
15
- themeConfig: {prism = {}},
15
+ themeConfig: {prism},
16
16
  } = siteConfig;
17
- const {additionalLanguages = []} = prism as {additionalLanguages: string[]};
17
+ const {additionalLanguages} = prism as {additionalLanguages: string[]};
18
18
 
19
+ // Prism components work on the Prism instance on the window, while
20
+ // prism-react-renderer uses its own Prism instance. We temporarily mount
21
+ // the instance onto window, import components to enhance it, then remove it
22
+ // to avoid polluting global namespace.
23
+ // You can mutate this object: registering plugins, deleting languages... As
24
+ // long as you don't re-assign it
19
25
  window.Prism = PrismObject;
20
26
 
21
27
  additionalLanguages.forEach((lang) => {
22
- require(`prismjs/components/prism-${lang}`); // eslint-disable-line
28
+ // eslint-disable-next-line global-require, import/no-dynamic-require
29
+ require(`prismjs/components/prism-${lang}`);
23
30
  });
24
31
 
25
32
  delete (window as Window & {Prism?: typeof PrismNamespace}).Prism;
@@ -44,7 +44,8 @@ declare module '@theme/BlogListPaginator' {
44
44
  }
45
45
 
46
46
  declare module '@theme/BlogPostItem' {
47
- import type {FrontMatter, Assets, Metadata} from '@theme/BlogPostPage';
47
+ import type {FrontMatter, Metadata} from '@theme/BlogPostPage';
48
+ import type {Assets} from '@docusaurus/plugin-content-blog';
48
49
 
49
50
  export interface Props {
50
51
  readonly frontMatter: FrontMatter;
@@ -70,7 +71,8 @@ declare module '@theme/BlogPostAuthor' {
70
71
  }
71
72
 
72
73
  declare module '@theme/BlogPostAuthors' {
73
- import type {Metadata, Assets} from '@theme/BlogPostPage';
74
+ import type {Metadata} from '@theme/BlogPostPage';
75
+ import type {Assets} from '@docusaurus/plugin-content-blog';
74
76
 
75
77
  export interface Props {
76
78
  readonly authors: Metadata['authors'];
@@ -107,13 +109,14 @@ declare module '@theme/BlogLayout' {
107
109
  }
108
110
 
109
111
  declare module '@theme/CodeBlock' {
110
- import {ReactElement} from 'react';
112
+ import type {ReactElement} from 'react';
111
113
 
112
114
  export interface Props {
113
115
  readonly children: string | ReactElement;
114
116
  readonly className?: string;
115
117
  readonly metastring?: string;
116
118
  readonly title?: string;
119
+ readonly language?: string;
117
120
  }
118
121
 
119
122
  const CodeBlock: (props: Props) => JSX.Element;
@@ -129,18 +132,6 @@ declare module '@theme/DocPaginator' {
129
132
  export default function DocPaginator(props: Props): JSX.Element;
130
133
  }
131
134
 
132
- declare module '@theme/DocPaginatorNavLink' {
133
- import type {PropNavigationLink} from '@docusaurus/plugin-content-docs';
134
-
135
- // May be simpler to provide a {navigation: PropNavigation} prop?
136
- export interface Props {
137
- navLink: PropNavigationLink;
138
- next?: boolean;
139
- }
140
-
141
- export default function DocPaginatorNavLink(props: Props): JSX.Element;
142
- }
143
-
144
135
  declare module '@theme/DocSidebar' {
145
136
  import type {PropSidebarItem} from '@docusaurus/plugin-content-docs';
146
137
 
@@ -160,23 +151,27 @@ declare module '@theme/DocSidebar' {
160
151
  declare module '@theme/DocSidebarItem' {
161
152
  import type {PropSidebarItem} from '@docusaurus/plugin-content-docs';
162
153
 
163
- type DocSidebarPropsBase = {
154
+ export interface Props {
164
155
  readonly activePath: string;
165
156
  readonly onItemClick?: (item: PropSidebarItem) => void;
166
157
  readonly level: number;
167
158
  readonly tabIndex?: number;
168
- };
169
-
170
- export interface Props extends DocSidebarPropsBase {
171
159
  readonly item: PropSidebarItem;
160
+ readonly index: number;
172
161
  }
173
- const DocSidebarItem: (props: Props) => JSX.Element;
174
- export default DocSidebarItem;
175
162
 
176
- export type DocSidebarItemsProps = DocSidebarPropsBase & {
163
+ export default function DocSidebarItem(props: Props): JSX.Element;
164
+ }
165
+
166
+ declare module '@theme/DocSidebarItems' {
167
+ import type {Props as DocSidebarItemProps} from '@theme/DocSidebarItem';
168
+ import type {PropSidebarItem} from '@docusaurus/plugin-content-docs';
169
+
170
+ export type Props = Omit<DocSidebarItemProps, 'item' | 'index'> & {
177
171
  readonly items: readonly PropSidebarItem[];
178
172
  };
179
- export const DocSidebarItems: (props: DocSidebarItemsProps) => JSX.Element;
173
+
174
+ export default function DocSidebarItems(props: Props): JSX.Element;
180
175
  }
181
176
 
182
177
  declare module '@theme/DocVersionSuggestions' {
@@ -193,7 +188,7 @@ declare module '@theme/EditThisPage' {
193
188
  }
194
189
 
195
190
  declare module '@theme/ErrorPageContent' {
196
- import ErrorComponent from '@theme/Error';
191
+ import type ErrorComponent from '@theme/Error';
197
192
 
198
193
  const ErrorPageContent: typeof ErrorComponent;
199
194
  export default ErrorPageContent;
@@ -207,99 +202,20 @@ declare module '@theme/Footer' {
207
202
  declare module '@theme/Heading' {
208
203
  import type {ComponentProps} from 'react';
209
204
 
210
- export type HeadingType = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
211
- export interface Props extends ComponentProps<HeadingType> {}
212
-
213
- const Heading: (Tag: HeadingType) => (props: Props) => JSX.Element;
214
- export default Heading;
215
- export const MainHeading: (props: Props) => JSX.Element;
216
- }
217
-
218
- declare module '@theme/hooks/useHideableNavbar' {
219
- export type useHideableNavbarReturns = {
220
- readonly navbarRef: (node: HTMLElement | null) => void;
221
- readonly isNavbarVisible: boolean;
222
- };
223
-
224
- const useHideableNavbar: (hideOnScroll: boolean) => useHideableNavbarReturns;
225
- export default useHideableNavbar;
226
- }
227
-
228
- declare module '@theme/hooks/useLockBodyScroll' {
229
- const useLockBodyScroll: (lock?: boolean) => void;
230
- export default useLockBodyScroll;
231
- }
232
-
233
- declare module '@theme/hooks/usePrismTheme' {
234
- import defaultTheme from 'prism-react-renderer/themes/palenight';
235
-
236
- const usePrismTheme: () => typeof defaultTheme;
237
- export default usePrismTheme;
238
- }
239
-
240
- declare module '@theme/hooks/useTabGroupChoice' {
241
- export type useTabGroupChoiceReturns = {
242
- readonly tabGroupChoices: {readonly [groupId: string]: string};
243
- readonly setTabGroupChoices: (groupId: string, newChoice: string) => void;
244
- };
245
-
246
- const useTabGroupChoice: () => useTabGroupChoiceReturns;
247
- export default useTabGroupChoice;
248
- }
205
+ type HeadingType = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
249
206
 
250
- declare module '@theme/hooks/useTheme' {
251
- export type useThemeReturns = {
252
- readonly isDarkTheme: boolean;
253
- readonly setLightTheme: () => void;
254
- readonly setDarkTheme: () => void;
255
- };
256
-
257
- const useTheme: () => useThemeReturns;
258
- export default useTheme;
259
- }
260
-
261
- declare module '@theme/hooks/useThemeContext' {
262
- export type ThemeContextProps = {
263
- isDarkTheme: boolean;
264
- setLightTheme: () => void;
265
- setDarkTheme: () => void;
266
- };
267
-
268
- export default function useThemeContext(): ThemeContextProps;
269
- }
270
-
271
- declare module '@theme/hooks/useUserPreferencesContext' {
272
- export type UserPreferencesContextProps = {
273
- tabGroupChoices: {readonly [groupId: string]: string};
274
- setTabGroupChoices: (groupId: string, newChoice: string) => void;
275
- };
276
-
277
- export default function useUserPreferencesContext(): UserPreferencesContextProps;
278
- }
279
-
280
- declare module '@theme/hooks/useWindowSize' {
281
- export const windowSizes: {
282
- desktop: 'desktop';
283
- mobile: 'mobile';
284
- ssr: 'ssr';
285
- };
286
-
287
- export type WindowSize = keyof typeof windowSizes;
288
-
289
- export default function useWindowSize(): WindowSize;
290
- }
291
-
292
- declare module '@theme/hooks/useKeyboardNavigation' {
293
- const useKeyboardNavigation: () => void;
207
+ export interface Props extends ComponentProps<HeadingType> {
208
+ as: HeadingType;
209
+ }
294
210
 
295
- export default useKeyboardNavigation;
211
+ export default function Heading(props: Props): JSX.Element;
296
212
  }
297
213
 
298
214
  declare module '@theme/Layout' {
299
215
  import type {ReactNode} from 'react';
300
216
 
301
217
  export interface Props {
302
- readonly children: ReactNode;
218
+ readonly children?: ReactNode;
303
219
  readonly title?: string;
304
220
  readonly noFooter?: boolean;
305
221
  readonly description?: string;
@@ -314,8 +230,7 @@ declare module '@theme/Layout' {
314
230
  };
315
231
  }
316
232
 
317
- const Layout: (props: Props) => JSX.Element;
318
- export default Layout;
233
+ export default function Layout(props: Props): JSX.Element;
319
234
  }
320
235
 
321
236
  declare module '@theme/LayoutHead' {
@@ -323,8 +238,17 @@ declare module '@theme/LayoutHead' {
323
238
 
324
239
  export interface Props extends Omit<LayoutProps, 'children'> {}
325
240
 
326
- const LayoutHead: (props: Props) => JSX.Element;
327
- export default LayoutHead;
241
+ export default function LayoutHead(props: Props): JSX.Element;
242
+ }
243
+
244
+ declare module '@theme/LayoutProviders' {
245
+ import type {ReactNode} from 'react';
246
+
247
+ export interface Props {
248
+ readonly children: ReactNode;
249
+ }
250
+
251
+ export default function LayoutProviders(props: Props): JSX.Element;
328
252
  }
329
253
 
330
254
  declare module '@theme/SearchMetadata' {
@@ -383,18 +307,9 @@ declare module '@theme/Navbar' {
383
307
  }
384
308
 
385
309
  declare module '@theme/NavbarItem/DefaultNavbarItem' {
386
- import type {ReactNode} from 'react';
387
- import type {LinkProps} from '@docusaurus/Link';
388
-
389
- export type NavLinkProps = LinkProps & {
390
- readonly activeBasePath?: string;
391
- readonly activeBaseRegex?: string;
392
- readonly exact?: boolean;
393
- readonly label?: ReactNode;
394
- readonly prependBaseUrlToHref?: string;
395
- };
310
+ import type {Props as NavbarNavLinkProps} from '@theme/NavbarItem/NavbarNavLink';
396
311
 
397
- export type DesktopOrMobileNavBarItemProps = NavLinkProps & {
312
+ export type DesktopOrMobileNavBarItemProps = NavbarNavLinkProps & {
398
313
  readonly isDropdownItem?: boolean;
399
314
  readonly className?: string;
400
315
  readonly position?: 'left' | 'right';
@@ -404,17 +319,30 @@ declare module '@theme/NavbarItem/DefaultNavbarItem' {
404
319
  readonly mobile?: boolean;
405
320
  }
406
321
 
407
- export const NavLink: (props: NavLinkProps) => JSX.Element;
322
+ export default function DefaultNavbarItem(props: Props): JSX.Element;
323
+ }
324
+
325
+ declare module '@theme/NavbarItem/NavbarNavLink' {
326
+ import type {ReactNode} from 'react';
327
+ import type {LinkProps} from '@docusaurus/Link';
408
328
 
409
- const DefaultNavbarItem: (props: Props) => JSX.Element;
410
- export default DefaultNavbarItem;
329
+ export type Props = LinkProps & {
330
+ readonly activeBasePath?: string;
331
+ readonly activeBaseRegex?: string;
332
+ readonly exact?: boolean;
333
+ readonly label?: ReactNode;
334
+ readonly prependBaseUrlToHref?: string;
335
+ };
336
+
337
+ export default function NavbarNavLink(props: Props): JSX.Element;
411
338
  }
412
339
 
413
340
  declare module '@theme/NavbarItem/DropdownNavbarItem' {
414
- import type {NavLinkProps} from '@theme/NavbarItem/DefaultNavbarItem';
341
+ import type {Props as NavbarNavLinkProps} from '@theme/NavbarItem/NavbarNavLink';
342
+
415
343
  import type {LinkLikeNavbarItemProps} from '@theme/NavbarItem';
416
344
 
417
- export type DesktopOrMobileNavBarItemProps = NavLinkProps & {
345
+ export type DesktopOrMobileNavBarItemProps = NavbarNavLinkProps & {
418
346
  readonly position?: 'left' | 'right';
419
347
  readonly items: readonly LinkLikeNavbarItemProps[];
420
348
  readonly className?: string;
@@ -488,10 +416,23 @@ declare module '@theme/NavbarItem/DocNavbarItem' {
488
416
  export default DocsSidebarNavbarItem;
489
417
  }
490
418
 
419
+ declare module '@theme/NavbarItem/DocSidebarNavbarItem' {
420
+ import type {Props as DefaultNavbarItemProps} from '@theme/NavbarItem/DefaultNavbarItem';
421
+
422
+ export interface Props extends DefaultNavbarItemProps {
423
+ readonly sidebarId: string;
424
+ readonly docsPluginId?: string;
425
+ }
426
+
427
+ const DocSidebarNavbarItem: (props: Props) => JSX.Element;
428
+ export default DocSidebarNavbarItem;
429
+ }
430
+
491
431
  declare module '@theme/NavbarItem' {
492
432
  import type {ComponentProps} from 'react';
493
433
  import type {Props as DefaultNavbarItemProps} from '@theme/NavbarItem/DefaultNavbarItem';
494
434
  import type {Props as DocNavbarItemProps} from '@theme/NavbarItem/DocNavbarItem';
435
+ import type {Props as DocSidebarNavbarItemProps} from '@theme/NavbarItem/DocSidebarNavbarItem';
495
436
  import type {Props as DocsVersionNavbarItemProps} from '@theme/NavbarItem/DocsVersionNavbarItem';
496
437
  import type {Props as DropdownNavbarItemProps} from '@theme/NavbarItem/DropdownNavbarItem';
497
438
  import type {Props as DocsVersionDropdownNavbarItemProps} from '@theme/NavbarItem/DocsVersionDropdownNavbarItem';
@@ -501,7 +442,8 @@ declare module '@theme/NavbarItem' {
501
442
  export type LinkLikeNavbarItemProps =
502
443
  | ({readonly type?: 'default'} & DefaultNavbarItemProps)
503
444
  | ({readonly type: 'doc'} & DocNavbarItemProps)
504
- | ({readonly type: 'docsVersion'} & DocsVersionNavbarItemProps);
445
+ | ({readonly type: 'docsVersion'} & DocsVersionNavbarItemProps)
446
+ | ({readonly type: 'docSidebar'} & DocSidebarNavbarItemProps);
505
447
 
506
448
  export type Props = ComponentProps<'a'> & {
507
449
  readonly position?: 'left' | 'right';
@@ -523,6 +465,22 @@ declare module '@theme/NavbarItem' {
523
465
  export default NavbarItem;
524
466
  }
525
467
 
468
+ declare module '@theme/NavbarItem/utils' {
469
+ export function getInfimaActiveClassName(mobile?: boolean): string;
470
+ }
471
+
472
+ declare module '@theme/PaginatorNavLink' {
473
+ import type {ReactNode} from 'react';
474
+ import type {PropNavigationLink} from '@docusaurus/plugin-content-docs';
475
+
476
+ export interface Props extends Omit<PropNavigationLink, 'title'> {
477
+ readonly title: ReactNode;
478
+ readonly subLabel?: JSX.Element;
479
+ }
480
+
481
+ export default function PaginatorNavLink(props: Props): JSX.Element;
482
+ }
483
+
526
484
  declare module '@theme/SearchBar' {
527
485
  export default function SearchBar(): JSX.Element;
528
486
  }
@@ -581,23 +539,12 @@ declare module '@theme/ThemedImage' {
581
539
  }
582
540
 
583
541
  declare module '@theme/Details' {
584
- import {Details, DetailsProps} from '@docusaurus/theme-common';
542
+ import {Details, type DetailsProps} from '@docusaurus/theme-common';
585
543
 
586
544
  export interface Props extends DetailsProps {}
587
545
  export default Details;
588
546
  }
589
547
 
590
- declare module '@theme/ThemeProvider' {
591
- import type {ReactNode} from 'react';
592
-
593
- export interface Props {
594
- readonly children: ReactNode;
595
- }
596
-
597
- const ThemeProvider: (props: Props) => JSX.Element;
598
- export default ThemeProvider;
599
- }
600
-
601
548
  declare module '@theme/TOCItems' {
602
549
  import type {TOCItem} from '@docusaurus/types';
603
550
 
@@ -678,46 +625,6 @@ declare module '@theme/Toggle' {
678
625
  export default Toggle;
679
626
  }
680
627
 
681
- declare module '@theme/UserPreferencesProvider' {
682
- import type {ReactNode} from 'react';
683
-
684
- export interface Props {
685
- readonly children: ReactNode;
686
- }
687
-
688
- const UserPreferencesProvider: (props: Props) => JSX.Element;
689
- export default UserPreferencesProvider;
690
- }
691
-
692
- declare module '@theme/LayoutProviders' {
693
- import type {ReactNode} from 'react';
694
-
695
- export interface Props {
696
- readonly children: ReactNode;
697
- }
698
-
699
- const LayoutProviders: (props: Props) => JSX.Element;
700
- export default LayoutProviders;
701
- }
702
-
703
- declare module '@theme/ThemeContext' {
704
- import type {Context} from 'react';
705
- import type {ThemeContextProps} from '@theme/hooks/useThemeContext';
706
-
707
- const ThemeContext: Context<ThemeContextProps | undefined>;
708
- export default ThemeContext;
709
- }
710
-
711
- declare module '@theme/UserPreferencesContext' {
712
- import type {Context} from 'react';
713
- import type {UserPreferencesContextProps} from '@theme/hooks/useUserPreferencesContext';
714
-
715
- const UserPreferencesContext: Context<
716
- UserPreferencesContextProps | undefined
717
- >;
718
- export default UserPreferencesContext;
719
- }
720
-
721
628
  declare module '@theme/Logo' {
722
629
  import type {ComponentProps} from 'react';
723
630
 
@@ -5,8 +5,8 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- import {TranslationFile, TranslationFileContent} from '@docusaurus/types';
9
- import {
8
+ import type {TranslationFile, TranslationFileContent} from '@docusaurus/types';
9
+ import type {
10
10
  ThemeConfig,
11
11
  Navbar,
12
12
  NavbarItem,
@@ -41,6 +41,7 @@ const DEFAULT_CONFIG = {
41
41
  items: [],
42
42
  },
43
43
  hideableSidebar: false,
44
+ autoCollapseSidebarCategories: false,
44
45
  tableOfContents: {
45
46
  minHeadingLevel: 2,
46
47
  maxHeadingLevel: 3,
@@ -85,6 +86,12 @@ const DocItemSchema = NavbarItemBaseSchema.append({
85
86
  docsPluginId: Joi.string(),
86
87
  });
87
88
 
89
+ const DocSidebarItemSchema = NavbarItemBaseSchema.append({
90
+ type: Joi.string().equal('docSidebar').required(),
91
+ sidebarId: Joi.string().required(),
92
+ docsPluginId: Joi.string(),
93
+ });
94
+
88
95
  const itemWithType = (type: string | undefined) => {
89
96
  // because equal(undefined) is not supported :/
90
97
  const typeSchema = type
@@ -172,6 +179,10 @@ const NavbarItemSchema = Joi.object({
172
179
  is: itemWithType('doc'),
173
180
  then: DocItemSchema,
174
181
  },
182
+ {
183
+ is: itemWithType('docSidebar'),
184
+ then: DocSidebarItemSchema,
185
+ },
175
186
  {
176
187
  is: itemWithType('localeDropdown'),
177
188
  then: LocaleDropdownNavbarItemSchema,
@@ -266,8 +277,10 @@ const ThemeConfigSchema = Joi.object({
266
277
  metadata: Joi.array()
267
278
  .items(HtmlMetadataSchema)
268
279
  .default(DEFAULT_CONFIG.metadata),
280
+ // cSpell:ignore metadatas
269
281
  metadatas: Joi.any().forbidden().messages({
270
282
  'any.unknown':
283
+ // cSpell:ignore metadatas
271
284
  'themeConfig.metadatas has been renamed as themeConfig.metadata. See https://github.com/facebook/docusaurus/pull/5871',
272
285
  }),
273
286
  announcementBar: Joi.object({
@@ -342,6 +355,9 @@ const ThemeConfigSchema = Joi.object({
342
355
  .default(DEFAULT_CONFIG.prism)
343
356
  .unknown(),
344
357
  hideableSidebar: Joi.bool().default(DEFAULT_CONFIG.hideableSidebar),
358
+ autoCollapseSidebarCategories: Joi.bool().default(
359
+ DEFAULT_CONFIG.autoCollapseSidebarCategories,
360
+ ),
345
361
  sidebarCollapsible: Joi.forbidden().messages({
346
362
  'any.unknown':
347
363
  'The themeConfig.sidebarCollapsible has been moved to docs plugin options. See: https://docusaurus.io/docs/api/plugins/@docusaurus/plugin-content-docs',
@@ -1,36 +0,0 @@
1
- /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- */
7
- import React from 'react';
8
- import clsx from 'clsx';
9
- import Link from '@docusaurus/Link';
10
- import Translate from '@docusaurus/Translate';
11
-
12
- function DocPaginatorNavLink(props) {
13
- const {navLink, next} = props;
14
- return (
15
- <Link className={clsx('pagination-nav__link')} to={navLink.permalink}>
16
- <div className="pagination-nav__sublabel">
17
- {next ? (
18
- <Translate
19
- id="theme.docs.paginator.next"
20
- description="The label used to navigate to the next doc">
21
- Next
22
- </Translate>
23
- ) : (
24
- <Translate
25
- id="theme.docs.paginator.previous"
26
- description="The label used to navigate to the previous doc">
27
- Previous
28
- </Translate>
29
- )}
30
- </div>
31
- <div className="pagination-nav__label">{navLink.title}</div>
32
- </Link>
33
- );
34
- }
35
-
36
- export default DocPaginatorNavLink;
@@ -1,9 +0,0 @@
1
- /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- */
7
- import React from 'react';
8
- const ThemeContext = React.createContext(undefined);
9
- export default ThemeContext;
@@ -1,28 +0,0 @@
1
- /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- */
7
- import React, {useMemo} from 'react';
8
- import useTheme from '@theme/hooks/useTheme';
9
- import ThemeContext from '@theme/ThemeContext';
10
-
11
- function ThemeProvider(props) {
12
- const {isDarkTheme, setLightTheme, setDarkTheme} = useTheme();
13
- const contextValue = useMemo(
14
- () => ({
15
- isDarkTheme,
16
- setLightTheme,
17
- setDarkTheme,
18
- }),
19
- [isDarkTheme, setLightTheme, setDarkTheme],
20
- );
21
- return (
22
- <ThemeContext.Provider value={contextValue}>
23
- {props.children}
24
- </ThemeContext.Provider>
25
- );
26
- }
27
-
28
- export default ThemeProvider;
@@ -1,27 +0,0 @@
1
- /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- */
7
- import React, {useMemo} from 'react';
8
- import useTabGroupChoice from '@theme/hooks/useTabGroupChoice';
9
- import UserPreferencesContext from '@theme/UserPreferencesContext';
10
-
11
- function UserPreferencesProvider(props) {
12
- const {tabGroupChoices, setTabGroupChoices} = useTabGroupChoice();
13
- const contextValue = useMemo(
14
- () => ({
15
- tabGroupChoices,
16
- setTabGroupChoices,
17
- }),
18
- [tabGroupChoices, setTabGroupChoices],
19
- );
20
- return (
21
- <UserPreferencesContext.Provider value={contextValue}>
22
- {props.children}
23
- </UserPreferencesContext.Provider>
24
- );
25
- }
26
-
27
- export default UserPreferencesProvider;
@@ -1,10 +0,0 @@
1
- /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- */
7
- // Re-expose useDocs
8
- // Ensure it's always statically available even if user is not using the docs plugin
9
- // Problem reported for the blog-only mode: https://github.com/facebook/docusaurus/issues/3360
10
- export * from '@docusaurus/plugin-content-docs/lib/theme/hooks/useDocs';
@@ -1,66 +0,0 @@
1
- /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- */
7
- import {useState, useCallback, useRef} from 'react';
8
- import {useLocationChange, useScrollPosition} from '@docusaurus/theme-common';
9
-
10
- const useHideableNavbar = (hideOnScroll) => {
11
- const [isNavbarVisible, setIsNavbarVisible] = useState(hideOnScroll);
12
- const isFocusedAnchor = useRef(false);
13
- const navbarHeight = useRef(0);
14
- const navbarRef = useCallback((node) => {
15
- if (node !== null) {
16
- navbarHeight.current = node.getBoundingClientRect().height;
17
- }
18
- }, []);
19
- useScrollPosition((currentPosition, lastPosition) => {
20
- if (!hideOnScroll) {
21
- return;
22
- }
23
-
24
- const scrollTop = currentPosition.scrollY; // It needed for mostly to handle rubber band scrolling
25
-
26
- if (scrollTop < navbarHeight.current) {
27
- setIsNavbarVisible(true);
28
- return;
29
- }
30
-
31
- if (isFocusedAnchor.current) {
32
- isFocusedAnchor.current = false;
33
- return;
34
- }
35
-
36
- const lastScrollTop = lastPosition?.scrollY;
37
- const documentHeight =
38
- document.documentElement.scrollHeight - navbarHeight.current;
39
- const windowHeight = window.innerHeight;
40
-
41
- if (lastScrollTop && scrollTop >= lastScrollTop) {
42
- setIsNavbarVisible(false);
43
- } else if (scrollTop + windowHeight < documentHeight) {
44
- setIsNavbarVisible(true);
45
- }
46
- });
47
- useLocationChange((locationChangeEvent) => {
48
- if (!hideOnScroll) {
49
- return;
50
- }
51
-
52
- if (locationChangeEvent.location.hash) {
53
- isFocusedAnchor.current = true;
54
- setIsNavbarVisible(false);
55
- return;
56
- }
57
-
58
- setIsNavbarVisible(true);
59
- });
60
- return {
61
- navbarRef,
62
- isNavbarVisible,
63
- };
64
- };
65
-
66
- export default useHideableNavbar;