fumadocs-ui 11.3.1 → 12.0.0

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 (54) hide show
  1. package/dist/{chunk-24NYFO7H.js → chunk-2KMKNVSN.js} +2 -4
  2. package/dist/{chunk-C4PI62MH.js → chunk-34Z7WODD.js} +6 -8
  3. package/dist/{chunk-GDRBCN6Q.js → chunk-3F57TIUQ.js} +21 -7
  4. package/dist/{chunk-PXDQVGII.js → chunk-7EMVRXMS.js} +10 -1
  5. package/dist/{chunk-7F2LGCS6.js → chunk-AN2Y6MA2.js} +2 -4
  6. package/dist/{chunk-PW7TBOIJ.js → chunk-CRYPD6UZ.js} +2 -1
  7. package/dist/{chunk-UKE65HV3.js → chunk-IOHAG6BY.js} +1 -1
  8. package/dist/chunk-JQW5DMD2.js +226 -0
  9. package/dist/{chunk-WNKY4RA5.js → chunk-UBVEKNRF.js} +1 -1
  10. package/dist/{chunk-E2VA3Y4S.js → chunk-XXVXIK4M.js} +2 -3
  11. package/dist/components/accordion.js +2 -2
  12. package/dist/components/api.js +5 -8
  13. package/dist/components/callout.js +1 -1
  14. package/dist/components/card.js +1 -1
  15. package/dist/components/codeblock.js +3 -3
  16. package/dist/components/dialog/search-algolia.js +4 -3
  17. package/dist/components/dialog/search-default.js +4 -3
  18. package/dist/components/dialog/search.js +4 -3
  19. package/dist/components/files.js +1 -1
  20. package/dist/components/heading.js +2 -2
  21. package/dist/components/image-zoom.js +4 -6
  22. package/dist/components/inline-toc.js +1 -1
  23. package/dist/components/layout/language-toggle.d.ts +6 -0
  24. package/dist/components/layout/language-toggle.js +58 -0
  25. package/dist/components/layout/root-toggle.d.ts +16 -0
  26. package/dist/components/layout/root-toggle.js +60 -0
  27. package/dist/components/roll-button.js +2 -3
  28. package/dist/components/steps.js +1 -1
  29. package/dist/components/tabs.js +6 -11
  30. package/dist/components/type-table.js +2 -2
  31. package/dist/docs.client.d.ts +13 -0
  32. package/dist/docs.client.js +396 -0
  33. package/dist/{i18n-p5QWhj_3.d.ts → i18n-CE8z-AAs.d.ts} +1 -0
  34. package/dist/i18n.d.ts +3 -6
  35. package/dist/i18n.js +5 -104
  36. package/dist/{layout-vxXAvjoq.d.ts → layout.client-Duq0TTke.d.ts} +23 -15
  37. package/dist/layout.client.d.ts +2 -8
  38. package/dist/layout.client.js +39 -571
  39. package/dist/layout.d.ts +1 -1
  40. package/dist/layout.js +42 -28
  41. package/dist/mdx.client.js +3 -3
  42. package/dist/mdx.js +4 -4
  43. package/dist/page.client.js +7 -8
  44. package/dist/page.js +19 -10
  45. package/dist/provider.d.ts +12 -13
  46. package/dist/provider.js +10 -11
  47. package/dist/style.css +1 -1
  48. package/dist/tailwind-plugin.cjs +34 -43
  49. package/dist/tailwind-plugin.js +35 -44
  50. package/dist/twoslash/popup.js +8 -14
  51. package/dist/twoslash.css +1 -1
  52. package/package.json +4 -5
  53. /package/dist/{chunk-6C3VEZWH.js → chunk-MLKGABMK.js} +0 -0
  54. /package/dist/{tree-cqNEopxM.d.ts → tree-CrKzI9Nz.d.ts} +0 -0
package/dist/layout.js CHANGED
@@ -1,75 +1,89 @@
1
1
  import {
2
- Nav,
2
+ LanguageToggle,
3
+ } from "./components/layout/language-toggle"
4
+ import {
3
5
  TreeContextProvider,
4
6
  DynamicSidebar,
7
+ SubNav,
5
8
  Sidebar,
6
- } from "./layout.client.js"
9
+ ThemeToggle,
10
+ } from "./docs.client"
11
+ import { Nav } from "./layout.client"
7
12
  import {
8
13
  replaceOrDefault
9
- } from "./chunk-7F2LGCS6.js";
14
+ } from "./chunk-AN2Y6MA2.js";
10
15
  import {
11
16
  twMerge
12
17
  } from "./chunk-TK3TM3MR.js";
13
- import "./chunk-6C3VEZWH.js";
18
+ import "./chunk-MLKGABMK.js";
14
19
 
15
20
  // src/layout.tsx
21
+ import Link from "next/link";
16
22
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
17
23
  function Layout({
18
24
  nav = {},
19
25
  links = [],
26
+ githubUrl,
20
27
  children
21
28
  }) {
22
- const finalLinks = getLinks(links, nav.githubUrl);
29
+ const finalLinks = getLinks(links, githubUrl);
23
30
  return /* @__PURE__ */ jsxs(Fragment, { children: [
24
31
  replaceOrDefault(
25
32
  nav,
26
- /* @__PURE__ */ jsx(Nav, { items: finalLinks, enableSidebar: false, ...nav, children: nav.children })
33
+ /* @__PURE__ */ jsx(Nav, { items: finalLinks, ...nav, children: nav.children })
27
34
  ),
28
35
  children
29
36
  ] });
30
37
  }
31
38
  function DocsLayout({
32
- nav = {},
39
+ nav,
40
+ githubUrl,
33
41
  sidebar = {},
34
42
  links = [],
35
43
  containerProps,
36
44
  tree,
45
+ i18n = false,
37
46
  children
38
47
  }) {
39
48
  const sidebarEnabled = sidebar.enabled ?? true;
40
49
  const sidebarCollapsible = sidebarEnabled && (sidebar.collapsible ?? true);
41
- const finalLinks = getLinks(links, nav.githubUrl);
50
+ const finalLinks = getLinks(links, githubUrl);
51
+ const Aside = sidebarCollapsible ? DynamicSidebar : Sidebar;
42
52
  return /* @__PURE__ */ jsxs(TreeContextProvider, { tree, children: [
43
- replaceOrDefault(
44
- nav,
45
- /* @__PURE__ */ jsx(Nav, { items: finalLinks, enableSidebar: sidebarEnabled, ...nav, children: nav.children })
46
- ),
53
+ replaceOrDefault(nav, /* @__PURE__ */ jsx(SubNav, { ...nav })),
47
54
  /* @__PURE__ */ jsxs(
48
55
  "div",
49
56
  {
50
57
  ...containerProps,
51
- className: twMerge(
52
- "mx-auto flex w-full max-w-container flex-row gap-2 xl:gap-6",
53
- containerProps?.className
54
- ),
58
+ className: twMerge("flex flex-1 flex-row", containerProps?.className),
55
59
  children: [
56
60
  replaceOrDefault(
57
61
  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,
62
+ /* @__PURE__ */ jsx(
63
+ Aside,
68
64
  {
69
65
  items: finalLinks,
70
66
  defaultOpenLevel: sidebar.defaultOpenLevel,
71
- banner: sidebar.banner,
72
- footer: sidebar.footer
67
+ banner: /* @__PURE__ */ jsxs(Fragment, { children: [
68
+ /* @__PURE__ */ jsx(
69
+ Link,
70
+ {
71
+ href: nav?.url ?? "/",
72
+ className: "inline-flex items-center gap-2.5 border-b pb-4 font-semibold max-md:hidden",
73
+ children: nav?.title
74
+ }
75
+ ),
76
+ sidebar.banner
77
+ ] }),
78
+ bannerProps: {
79
+ className: twMerge(!sidebar.banner && "max-md:hidden")
80
+ },
81
+ footer: /* @__PURE__ */ jsxs(Fragment, { children: [
82
+ /* @__PURE__ */ jsx(ThemeToggle, { className: "me-auto" }),
83
+ sidebar.footer,
84
+ i18n ? /* @__PURE__ */ jsx(LanguageToggle, {}) : null
85
+ ] }),
86
+ components: sidebar.components
73
87
  }
74
88
  )
75
89
  ),
@@ -2,12 +2,12 @@
2
2
  import {
3
3
  CodeBlock,
4
4
  Pre
5
- } from "./chunk-E2VA3Y4S.js";
5
+ } from "./chunk-XXVXIK4M.js";
6
6
  import "./chunk-VYTHQTZE.js";
7
- import "./chunk-24NYFO7H.js";
7
+ import "./chunk-2KMKNVSN.js";
8
8
  import "./chunk-7GZKFBAP.js";
9
9
  import "./chunk-TK3TM3MR.js";
10
- import "./chunk-6C3VEZWH.js";
10
+ import "./chunk-MLKGABMK.js";
11
11
 
12
12
  // src/mdx.client.tsx
13
13
  import { jsx } from "react/jsx-runtime";
package/dist/mdx.js CHANGED
@@ -1,16 +1,16 @@
1
- import { Pre } from "./mdx.client.js"
1
+ import { Pre } from "./mdx.client"
2
2
  import {
3
3
  defaultImageSizes
4
- } from "./chunk-7F2LGCS6.js";
4
+ } from "./chunk-AN2Y6MA2.js";
5
5
  import {
6
6
  Card,
7
7
  Cards
8
8
  } from "./chunk-N3HFQZRE.js";
9
9
  import {
10
10
  Heading
11
- } from "./chunk-UKE65HV3.js";
11
+ } from "./chunk-IOHAG6BY.js";
12
12
  import "./chunk-TK3TM3MR.js";
13
- import "./chunk-6C3VEZWH.js";
13
+ import "./chunk-MLKGABMK.js";
14
14
 
15
15
  // src/mdx.tsx
16
16
  import Link from "fumadocs-core/link";
@@ -1,19 +1,19 @@
1
1
  "use client";
2
2
  import {
3
3
  useTreeContext
4
- } from "./chunk-C4PI62MH.js";
4
+ } from "./chunk-34Z7WODD.js";
5
5
  import {
6
6
  ScrollArea,
7
7
  ScrollViewport
8
8
  } from "./chunk-VYTHQTZE.js";
9
- import "./chunk-7F2LGCS6.js";
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";
16
- import "./chunk-6C3VEZWH.js";
16
+ import "./chunk-MLKGABMK.js";
17
17
 
18
18
  // src/page.client.tsx
19
19
  import { useEffect as useEffect2, useMemo, useState } from "react";
@@ -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";
@@ -34,8 +34,7 @@ function TOCItems({
34
34
  const markerRef = useRef(null);
35
35
  const setPos = useCallback(([top, height]) => {
36
36
  const element = markerRef.current;
37
- if (!element)
38
- return;
37
+ if (!element) return;
39
38
  element.style.setProperty("top", `${top.toString()}px`);
40
39
  element.style.setProperty("height", `${height.toString()}px`);
41
40
  element.style.setProperty("display", "block");
@@ -144,7 +143,7 @@ function Footer({ items }) {
144
143
  };
145
144
  }, [pathname, tree.navigation]);
146
145
  const footerItem = "flex flex-col gap-2 rounded-lg p-4 text-sm transition-colors hover:bg-accent hover:text-accent-foreground";
147
- 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: [
148
147
  previous ? /* @__PURE__ */ jsxs3(Link2, { href: previous.url, className: footerItem, children: [
149
148
  /* @__PURE__ */ jsxs3("div", { className: "inline-flex items-center gap-0.5 text-muted-foreground", children: [
150
149
  /* @__PURE__ */ jsx3(ChevronLeft, { className: "-ms-1 size-4 shrink-0 rtl:rotate-180" }),
package/dist/page.js CHANGED
@@ -3,14 +3,14 @@ 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
- } from "./chunk-7F2LGCS6.js";
9
+ } from "./chunk-AN2Y6MA2.js";
10
10
  import {
11
11
  twMerge
12
12
  } from "./chunk-TK3TM3MR.js";
13
- import "./chunk-6C3VEZWH.js";
13
+ import "./chunk-MLKGABMK.js";
14
14
 
15
15
  // src/page.tsx
16
16
  import { forwardRef } from "react";
@@ -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-16",
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 py-10 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,9 +1,10 @@
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-p5QWhj_3.js';
6
- export { u as useTreeContext } from './tree-cqNEopxM.js';
6
+ export { u as useI18n } from './i18n-CE8z-AAs.js';
7
+ export { u as useTreeContext } from './tree-CrKzI9Nz.js';
7
8
  import 'fumadocs-core/search/shared';
8
9
  import 'fumadocs-core/server';
9
10
 
@@ -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,20 +1,20 @@
1
1
  "use client";
2
+ import {
3
+ useTreeContext
4
+ } from "./chunk-34Z7WODD.js";
5
+ import "./chunk-AN2Y6MA2.js";
2
6
  import {
3
7
  SidebarProvider,
4
8
  useSidebar
5
- } from "./chunk-GDRBCN6Q.js";
6
- import {
7
- useTreeContext
8
- } from "./chunk-C4PI62MH.js";
9
- import "./chunk-7F2LGCS6.js";
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";
17
- import "./chunk-6C3VEZWH.js";
16
+ } from "./chunk-CRYPD6UZ.js";
17
+ import "./chunk-MLKGABMK.js";
18
18
 
19
19
  // src/provider.tsx
20
20
  import { ThemeProvider } from "next-themes";
@@ -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,