fumadocs-ui 11.3.2 → 12.0.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 (46) hide show
  1. package/dist/chunk-2BHQGWSJ.js +261 -0
  2. package/dist/{chunk-TDTHXDET.js → chunk-34Z7WODD.js} +2 -1
  3. package/dist/{chunk-IN5NHEZV.js → chunk-3F57TIUQ.js} +20 -5
  4. package/dist/{chunk-UKE65HV3.js → chunk-5CZEA2KX.js} +2 -2
  5. package/dist/{chunk-PXDQVGII.js → chunk-7EMVRXMS.js} +10 -1
  6. package/dist/{chunk-PW7TBOIJ.js → chunk-CRYPD6UZ.js} +2 -1
  7. package/dist/{chunk-XXVXIK4M.js → chunk-E5OQ6FBQ.js} +1 -1
  8. package/dist/{chunk-WNKY4RA5.js → chunk-UBVEKNRF.js} +1 -1
  9. package/dist/components/accordion.js +2 -2
  10. package/dist/components/api.js +2 -2
  11. package/dist/components/callout.d.ts +1 -1
  12. package/dist/components/codeblock.js +1 -1
  13. package/dist/components/dialog/search-algolia.js +3 -2
  14. package/dist/components/dialog/search-default.js +3 -2
  15. package/dist/components/dialog/search.js +3 -2
  16. package/dist/components/files.js +1 -1
  17. package/dist/components/heading.js +1 -1
  18. package/dist/components/layout/language-toggle.d.ts +6 -0
  19. package/dist/components/layout/language-toggle.js +58 -0
  20. package/dist/components/layout/root-toggle.d.ts +16 -0
  21. package/dist/components/layout/root-toggle.js +60 -0
  22. package/dist/components/roll-button.d.ts +1 -1
  23. package/dist/components/roll-button.js +22 -9
  24. package/dist/components/type-table.js +1 -1
  25. package/dist/docs.client.d.ts +19 -0
  26. package/dist/docs.client.js +406 -0
  27. package/dist/{i18n-K879Pt9h.d.ts → i18n-CE8z-AAs.d.ts} +1 -0
  28. package/dist/i18n.d.ts +3 -6
  29. package/dist/i18n.js +4 -102
  30. package/dist/{layout-WuS8Ab4e.d.ts → layout.client-Duq0TTke.d.ts} +23 -15
  31. package/dist/layout.client.d.ts +2 -8
  32. package/dist/layout.client.js +37 -590
  33. package/dist/layout.d.ts +1 -1
  34. package/dist/layout.js +45 -26
  35. package/dist/mdx.client.js +1 -1
  36. package/dist/mdx.js +2 -2
  37. package/dist/page.client.js +7 -7
  38. package/dist/page.js +17 -8
  39. package/dist/provider.d.ts +11 -12
  40. package/dist/provider.js +9 -10
  41. package/dist/style.css +1 -1
  42. package/dist/tailwind-plugin.cjs +21 -22
  43. package/dist/tailwind-plugin.js +21 -22
  44. package/dist/twoslash/popup.js +1 -1
  45. package/dist/twoslash.css +1 -1
  46. package/package.json +4 -5
package/dist/layout.js CHANGED
@@ -1,9 +1,15 @@
1
1
  import {
2
- Nav,
2
+ LanguageToggle,
3
+ } from "./components/layout/language-toggle"
4
+ import {
3
5
  TreeContextProvider,
4
6
  DynamicSidebar,
7
+ SubNav,
8
+ LinksMenu,
5
9
  Sidebar,
6
- } from "./layout.client.js"
10
+ ThemeToggle,
11
+ } from "./docs.client"
12
+ import { Nav } from "./layout.client"
7
13
  import {
8
14
  replaceOrDefault
9
15
  } from "./chunk-AN2Y6MA2.js";
@@ -13,63 +19,76 @@ import {
13
19
  import "./chunk-MLKGABMK.js";
14
20
 
15
21
  // src/layout.tsx
22
+ import Link from "next/link";
23
+ import { MoreHorizontal } from "lucide-react";
16
24
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
17
25
  function Layout({
18
26
  nav = {},
19
27
  links = [],
28
+ githubUrl,
20
29
  children
21
30
  }) {
22
- const finalLinks = getLinks(links, nav.githubUrl);
31
+ const finalLinks = getLinks(links, githubUrl);
23
32
  return /* @__PURE__ */ jsxs(Fragment, { children: [
24
33
  replaceOrDefault(
25
34
  nav,
26
- /* @__PURE__ */ jsx(Nav, { items: finalLinks, enableSidebar: false, ...nav, children: nav.children })
35
+ /* @__PURE__ */ jsx(Nav, { items: finalLinks, ...nav, children: nav.children })
27
36
  ),
28
37
  children
29
38
  ] });
30
39
  }
31
40
  function DocsLayout({
32
- nav = {},
41
+ nav,
42
+ githubUrl,
33
43
  sidebar = {},
34
44
  links = [],
35
45
  containerProps,
36
46
  tree,
47
+ i18n = false,
37
48
  children
38
49
  }) {
39
50
  const sidebarEnabled = sidebar.enabled ?? true;
40
51
  const sidebarCollapsible = sidebarEnabled && (sidebar.collapsible ?? true);
41
- const finalLinks = getLinks(links, nav.githubUrl);
52
+ const finalLinks = getLinks(links, githubUrl);
53
+ const Aside = sidebarCollapsible ? DynamicSidebar : Sidebar;
42
54
  return /* @__PURE__ */ jsxs(TreeContextProvider, { tree, children: [
43
- replaceOrDefault(
44
- nav,
45
- /* @__PURE__ */ jsx(Nav, { items: finalLinks, enableSidebar: sidebarEnabled, ...nav, children: nav.children })
46
- ),
55
+ replaceOrDefault(nav, /* @__PURE__ */ jsx(SubNav, { ...nav })),
47
56
  /* @__PURE__ */ jsxs(
48
57
  "div",
49
58
  {
50
59
  ...containerProps,
51
- className: twMerge(
52
- "mx-auto flex w-full max-w-container flex-row gap-2 xl:gap-6",
53
- containerProps?.className
54
- ),
60
+ className: twMerge("flex flex-1 flex-row", containerProps?.className),
55
61
  children: [
56
62
  replaceOrDefault(
57
63
  sidebar,
58
- sidebarCollapsible ? /* @__PURE__ */ jsx(
59
- DynamicSidebar,
60
- {
61
- items: finalLinks,
62
- defaultOpenLevel: sidebar.defaultOpenLevel,
63
- banner: sidebar.banner,
64
- footer: sidebar.footer
65
- }
66
- ) : /* @__PURE__ */ jsx(
67
- Sidebar,
64
+ /* @__PURE__ */ jsx(
65
+ Aside,
68
66
  {
69
67
  items: finalLinks,
70
68
  defaultOpenLevel: sidebar.defaultOpenLevel,
71
- banner: sidebar.banner,
72
- footer: sidebar.footer
69
+ banner: /* @__PURE__ */ jsxs(Fragment, { children: [
70
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-row items-center justify-between border-b pb-2 max-md:hidden", children: [
71
+ /* @__PURE__ */ jsx(
72
+ Link,
73
+ {
74
+ href: nav?.url ?? "/",
75
+ className: "inline-flex items-center gap-2.5 font-medium",
76
+ children: nav?.title
77
+ }
78
+ ),
79
+ /* @__PURE__ */ jsx(LinksMenu, { items: finalLinks, children: /* @__PURE__ */ jsx(MoreHorizontal, {}) })
80
+ ] }),
81
+ sidebar.banner
82
+ ] }),
83
+ bannerProps: {
84
+ className: twMerge(!sidebar.banner && "max-md:hidden")
85
+ },
86
+ footer: /* @__PURE__ */ jsxs(Fragment, { children: [
87
+ /* @__PURE__ */ jsx(ThemeToggle, { className: "me-auto" }),
88
+ sidebar.footer,
89
+ i18n ? /* @__PURE__ */ jsx(LanguageToggle, {}) : null
90
+ ] }),
91
+ components: sidebar.components
73
92
  }
74
93
  )
75
94
  ),
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  CodeBlock,
4
4
  Pre
5
- } from "./chunk-XXVXIK4M.js";
5
+ } from "./chunk-E5OQ6FBQ.js";
6
6
  import "./chunk-VYTHQTZE.js";
7
7
  import "./chunk-2KMKNVSN.js";
8
8
  import "./chunk-7GZKFBAP.js";
package/dist/mdx.js CHANGED
@@ -1,4 +1,4 @@
1
- import { Pre } from "./mdx.client.js"
1
+ import { Pre } from "./mdx.client"
2
2
  import {
3
3
  defaultImageSizes
4
4
  } from "./chunk-AN2Y6MA2.js";
@@ -8,7 +8,7 @@ import {
8
8
  } from "./chunk-N3HFQZRE.js";
9
9
  import {
10
10
  Heading
11
- } from "./chunk-UKE65HV3.js";
11
+ } from "./chunk-5CZEA2KX.js";
12
12
  import "./chunk-TK3TM3MR.js";
13
13
  import "./chunk-MLKGABMK.js";
14
14
 
@@ -1,15 +1,15 @@
1
1
  "use client";
2
- import {
3
- useTreeContext
4
- } from "./chunk-TDTHXDET.js";
5
2
  import {
6
3
  ScrollArea,
7
4
  ScrollViewport
8
5
  } from "./chunk-VYTHQTZE.js";
6
+ import {
7
+ useTreeContext
8
+ } from "./chunk-34Z7WODD.js";
9
9
  import "./chunk-AN2Y6MA2.js";
10
10
  import {
11
11
  useI18n
12
- } from "./chunk-PW7TBOIJ.js";
12
+ } from "./chunk-CRYPD6UZ.js";
13
13
  import {
14
14
  twMerge
15
15
  } from "./chunk-TK3TM3MR.js";
@@ -21,7 +21,7 @@ import { ChevronLeft, ChevronRight as ChevronRight2 } from "lucide-react";
21
21
  import Link2 from "next/link";
22
22
  import { usePathname as usePathname2 } from "next/navigation";
23
23
 
24
- // src/components/toc.tsx
24
+ // src/components/layout/toc.tsx
25
25
  import { TextIcon } from "lucide-react";
26
26
  import * as Primitive from "fumadocs-core/toc";
27
27
  import { useCallback, useEffect, useRef } from "react";
@@ -82,7 +82,7 @@ function TOCItem2({
82
82
  );
83
83
  }
84
84
 
85
- // src/components/breadcrumb.tsx
85
+ // src/components/layout/breadcrumb.tsx
86
86
  import { ChevronRight } from "lucide-react";
87
87
  import { useBreadcrumb } from "fumadocs-core/breadcrumb";
88
88
  import Link from "next/link";
@@ -143,7 +143,7 @@ function Footer({ items }) {
143
143
  };
144
144
  }, [pathname, tree.navigation]);
145
145
  const footerItem = "flex flex-col gap-2 rounded-lg p-4 text-sm transition-colors hover:bg-accent hover:text-accent-foreground";
146
- return /* @__PURE__ */ jsxs3("div", { className: "mt-4 flex flex-row flex-wrap gap-1 border-t py-4", children: [
146
+ return /* @__PURE__ */ jsxs3("div", { className: "mt-auto flex flex-row flex-wrap gap-1 border-t py-4", children: [
147
147
  previous ? /* @__PURE__ */ jsxs3(Link2, { href: previous.url, className: footerItem, children: [
148
148
  /* @__PURE__ */ jsxs3("div", { className: "inline-flex items-center gap-0.5 text-muted-foreground", children: [
149
149
  /* @__PURE__ */ jsx3(ChevronLeft, { className: "-ms-1 size-4 shrink-0 rtl:rotate-180" }),
package/dist/page.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  Breadcrumb,
4
4
  Footer,
5
5
  LastUpdate,
6
- } from "./page.client.js"
6
+ } from "./page.client"
7
7
  import {
8
8
  replaceOrDefault
9
9
  } from "./chunk-AN2Y6MA2.js";
@@ -22,12 +22,21 @@ function DocsPage({
22
22
  ...props
23
23
  }) {
24
24
  return /* @__PURE__ */ jsxs(Fragment, { children: [
25
- /* @__PURE__ */ jsxs("article", { className: "flex w-0 flex-1 flex-col gap-6 px-4 py-10", children: [
26
- replaceOrDefault(breadcrumb, /* @__PURE__ */ jsx(Breadcrumb, {})),
27
- props.children,
28
- props.lastUpdate ? /* @__PURE__ */ jsx(LastUpdate, { date: new Date(props.lastUpdate) }) : null,
29
- replaceOrDefault(footer, /* @__PURE__ */ jsx(Footer, { items: footer.items }))
30
- ] }),
25
+ /* @__PURE__ */ jsxs(
26
+ "article",
27
+ {
28
+ className: twMerge(
29
+ "mx-auto flex w-0 max-w-[800px] flex-1 flex-col gap-6 px-4 py-10 md:px-6 md:pt-12",
30
+ tableOfContent.enabled === false && "max-w-[1200px]"
31
+ ),
32
+ children: [
33
+ replaceOrDefault(breadcrumb, /* @__PURE__ */ jsx(Breadcrumb, {})),
34
+ props.children,
35
+ props.lastUpdate ? /* @__PURE__ */ jsx(LastUpdate, { date: new Date(props.lastUpdate) }) : null,
36
+ replaceOrDefault(footer, /* @__PURE__ */ jsx(Footer, { items: footer.items }))
37
+ ]
38
+ }
39
+ ),
31
40
  replaceOrDefault(
32
41
  tableOfContent,
33
42
  /* @__PURE__ */ jsx(
@@ -42,7 +51,7 @@ function DocsPage({
42
51
  ] });
43
52
  }
44
53
  function Toc(props) {
45
- return /* @__PURE__ */ jsxs("div", { className: "sticky top-16 flex h-body w-[220px] flex-col gap-4 divide-y py-10 max-lg:hidden xl:w-[260px]", children: [
54
+ return /* @__PURE__ */ jsxs("div", { className: "sticky top-0 flex h-dvh w-[220px] flex-col gap-4 divide-y pt-12 max-lg:hidden xl:w-[260px]", children: [
46
55
  props.header,
47
56
  props.items.length > 0 && /* @__PURE__ */ jsx(TOCItems, { items: props.items }),
48
57
  props.footer ? /* @__PURE__ */ jsx("div", { className: "pt-4 first:pt-0", children: props.footer }) : null
@@ -1,8 +1,9 @@
1
- import { ReactNode } from 'react';
1
+ import * as React$1 from 'react';
2
+ import { MutableRefObject, ReactNode } from 'react';
2
3
  import { ThemeProviderProps } from 'next-themes/dist/types';
3
4
  import { DefaultSearchDialogProps } from './components/dialog/search-default.js';
4
5
  import { SearchLink, SharedProps } from './components/dialog/search.js';
5
- export { u as useI18n } from './i18n-K879Pt9h.js';
6
+ export { u as useI18n } from './i18n-CE8z-AAs.js';
6
7
  export { u as useTreeContext } from './tree-CrKzI9Nz.js';
7
8
  import 'fumadocs-core/search/shared';
8
9
  import 'fumadocs-core/server';
@@ -50,13 +51,18 @@ interface SearchContextType {
50
51
  }
51
52
  declare function useSearchContext(): SearchContextType;
52
53
 
53
- interface SidebarCollapseContext {
54
+ interface SidebarContext {
54
55
  open: boolean;
55
56
  setOpen: (v: boolean) => void;
56
57
  collapsed: boolean;
57
58
  setCollapsed: (v: boolean) => void;
59
+ /**
60
+ * When set to true, close the sidebar on redirection
61
+ */
62
+ closeOnRedirect: MutableRefObject<boolean>;
58
63
  }
59
- declare function useSidebar(): SidebarCollapseContext;
64
+ declare const SidebarContext: React$1.Context<SidebarContext | undefined>;
65
+ declare function useSidebar(): SidebarContext;
60
66
 
61
67
  interface SearchOptions extends Omit<SearchProviderProps, 'options' | 'children'> {
62
68
  options?: Partial<DefaultSearchDialogProps> | SearchProviderProps['options'];
@@ -76,13 +82,6 @@ interface RootProviderProps {
76
82
  * @remarks `SearchProviderProps`
77
83
  */
78
84
  search?: Partial<SearchOptions>;
79
- /**
80
- * Wrap the body in `ThemeProvider` (next-themes)
81
- *
82
- * @defaultValue true
83
- * @deprecated Use `theme.enable` instead
84
- */
85
- enableThemeProvider?: boolean;
86
85
  /**
87
86
  * Customise options of `next-themes`
88
87
  */
@@ -96,6 +95,6 @@ interface RootProviderProps {
96
95
  };
97
96
  children: ReactNode;
98
97
  }
99
- declare function RootProvider({ children, dir, enableThemeProvider, theme: { enabled, ...theme }, search, }: RootProviderProps): React.ReactElement;
98
+ declare function RootProvider({ children, dir, theme: { enabled, ...theme }, search, }: RootProviderProps): React.ReactElement;
100
99
 
101
100
  export { RootProvider, type RootProviderProps, useSearchContext, useSidebar };
package/dist/provider.js CHANGED
@@ -1,19 +1,19 @@
1
1
  "use client";
2
- import {
3
- SidebarProvider,
4
- useSidebar
5
- } from "./chunk-IN5NHEZV.js";
6
2
  import {
7
3
  useTreeContext
8
- } from "./chunk-TDTHXDET.js";
4
+ } from "./chunk-34Z7WODD.js";
9
5
  import "./chunk-AN2Y6MA2.js";
6
+ import {
7
+ SidebarProvider,
8
+ useSidebar
9
+ } from "./chunk-3F57TIUQ.js";
10
10
  import {
11
11
  SearchProvider,
12
12
  useSearchContext
13
13
  } from "./chunk-FSPYEOFC.js";
14
14
  import {
15
15
  useI18n
16
- } from "./chunk-PW7TBOIJ.js";
16
+ } from "./chunk-CRYPD6UZ.js";
17
17
  import "./chunk-MLKGABMK.js";
18
18
 
19
19
  // src/provider.tsx
@@ -28,14 +28,13 @@ var DefaultSearchDialog = dynamic(
28
28
  function RootProvider({
29
29
  children,
30
30
  dir,
31
- enableThemeProvider = true,
32
31
  theme: { enabled = true, ...theme } = {},
33
32
  search
34
33
  }) {
35
- let body = /* @__PURE__ */ jsx(DirectionProvider, { dir: dir ?? "ltr", children: /* @__PURE__ */ jsx(SidebarProvider, { children }) });
34
+ let body = children;
36
35
  if (search?.enabled !== false)
37
36
  body = /* @__PURE__ */ jsx(SearchProvider, { SearchDialog: DefaultSearchDialog, ...search, children: body });
38
- if (enabled && enableThemeProvider)
37
+ if (enabled)
39
38
  body = /* @__PURE__ */ jsx(
40
39
  ThemeProvider,
41
40
  {
@@ -47,7 +46,7 @@ function RootProvider({
47
46
  children: body
48
47
  }
49
48
  );
50
- return body;
49
+ return /* @__PURE__ */ jsx(DirectionProvider, { dir: dir ?? "ltr", children: /* @__PURE__ */ jsx(SidebarProvider, { children: body }) });
51
50
  }
52
51
  export {
53
52
  RootProvider,