fumadocs-ui 13.4.9 → 14.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 (93) hide show
  1. package/dist/{chunk-774JT2B6.js → chunk-5KVEK5A7.js} +11 -8
  2. package/dist/chunk-5QPVK7QM.js +542 -0
  3. package/dist/chunk-BN7HGCQ4.js +212 -0
  4. package/dist/chunk-CDPVENXR.js +8 -0
  5. package/dist/{chunk-KWZZNVSY.js → chunk-CPGKWLLV.js} +7 -3
  6. package/dist/chunk-DN6Z5VW6.js +61 -0
  7. package/dist/chunk-GHOAONNQ.js +48 -0
  8. package/dist/{chunk-ERUVE5R6.js → chunk-IHIFNFRB.js} +4 -2
  9. package/dist/{chunk-CP67AHDD.js → chunk-IVBHRX3O.js} +1 -1
  10. package/dist/{chunk-NSEJBI4V.js → chunk-KZTWSBYY.js} +28 -16
  11. package/dist/chunk-MCX7E6ZW.js +57 -0
  12. package/dist/chunk-PZTQPB4U.js +125 -0
  13. package/dist/{chunk-EDNTYBXS.js → chunk-QKOA6KEZ.js} +2 -17
  14. package/dist/{chunk-YIOV4KEY.js → chunk-TYZZJ335.js} +26 -16
  15. package/dist/{chunk-HOIRMHZT.js → chunk-UQIRU7MP.js} +8 -2
  16. package/dist/chunk-V6RONFCQ.js +69 -0
  17. package/dist/chunk-WRBUXI2A.js +82 -0
  18. package/dist/chunk-YL3MZH7N.js +66 -0
  19. package/dist/components/accordion.js +7 -3
  20. package/dist/components/api.d.ts +2 -5
  21. package/dist/components/api.js +2 -4
  22. package/dist/components/banner.js +5 -6
  23. package/dist/components/callout.d.ts +1 -1
  24. package/dist/components/callout.js +2 -1
  25. package/dist/components/card.d.ts +6 -5
  26. package/dist/components/card.js +1 -1
  27. package/dist/components/codeblock.js +4 -3
  28. package/dist/components/dialog/search-algolia.d.ts +10 -4
  29. package/dist/components/dialog/search-algolia.js +25 -15
  30. package/dist/components/dialog/search-default.d.ts +10 -6
  31. package/dist/components/dialog/search-default.js +27 -5
  32. package/dist/components/dialog/search.d.ts +7 -7
  33. package/dist/components/dialog/search.js +4 -3
  34. package/dist/components/files.js +15 -11
  35. package/dist/components/heading.js +2 -1
  36. package/dist/components/image-zoom.d.ts +6 -1
  37. package/dist/components/image-zoom.js +10 -5
  38. package/dist/components/inline-toc.js +3 -1
  39. package/dist/components/layout/language-toggle.d.ts +4 -3
  40. package/dist/components/layout/language-toggle.js +8 -6
  41. package/dist/components/layout/root-toggle.d.ts +3 -3
  42. package/dist/components/layout/root-toggle.js +7 -73
  43. package/dist/components/tabs.js +30 -13
  44. package/dist/components/type-table.d.ts +7 -5
  45. package/dist/components/type-table.js +11 -11
  46. package/dist/dynamic-sidebar-QWGMOUMS.js +129 -0
  47. package/dist/{edit-on-github-YFVYCMB7.js → edit-on-github-PCTRDRD6.js} +10 -8
  48. package/dist/layouts/docs.client.d.ts +26 -0
  49. package/dist/layouts/docs.client.js +200 -0
  50. package/dist/layouts/docs.d.ts +29 -0
  51. package/dist/layouts/docs.js +187 -0
  52. package/dist/layouts/home.client.d.ts +11 -0
  53. package/dist/layouts/home.client.js +274 -0
  54. package/dist/layouts/home.d.ts +7 -0
  55. package/dist/layouts/home.js +55 -0
  56. package/dist/layouts/shared.d.ts +2 -0
  57. package/dist/layouts/shared.js +9 -0
  58. package/dist/mdx.client.js +4 -3
  59. package/dist/mdx.d.ts +0 -1
  60. package/dist/mdx.js +8 -10
  61. package/dist/og.d.ts +1 -7
  62. package/dist/og.js +5 -15
  63. package/dist/page.client.d.ts +2 -1
  64. package/dist/page.client.js +91 -63
  65. package/dist/page.d.ts +6 -5
  66. package/dist/page.js +63 -51
  67. package/dist/provider.d.ts +1 -2
  68. package/dist/provider.js +3 -4
  69. package/dist/shared-ElIzX-sQ.d.ts +152 -0
  70. package/dist/{sidebar-DwBSl7jC.d.ts → sidebar-HwpSmOKR.d.ts} +7 -9
  71. package/dist/style.css +1 -1
  72. package/dist/tailwind-plugin.js +86 -39
  73. package/dist/{toc-clerk-CAID2WGC.js → toc-clerk-SKE4LBT7.js} +40 -50
  74. package/dist/{tree-CrKzI9Nz.d.ts → tree-06ley65N.d.ts} +9 -3
  75. package/package.json +31 -68
  76. package/dist/chunk-KCZRDPB4.js +0 -308
  77. package/dist/chunk-LSTPTAZ5.js +0 -58
  78. package/dist/chunk-P4HLRHHV.js +0 -36
  79. package/dist/chunk-UOD2T27N.js +0 -27
  80. package/dist/chunk-WLTWFYQA.js +0 -44
  81. package/dist/docs-layout.client.d.ts +0 -18
  82. package/dist/docs-layout.client.js +0 -406
  83. package/dist/home-layout.client.d.ts +0 -9
  84. package/dist/home-layout.client.js +0 -88
  85. package/dist/home-layout.d.ts +0 -7
  86. package/dist/home-layout.js +0 -30
  87. package/dist/layout.d.ts +0 -19
  88. package/dist/layout.js +0 -127
  89. package/dist/layout.shared-DEQFTB9M.d.ts +0 -117
  90. package/dist/twoslash/popup.d.ts +0 -11
  91. package/dist/twoslash/popup.js +0 -97
  92. package/dist/twoslash.css +0 -1
  93. /package/dist/{image-zoom.css → components/image-zoom.css} +0 -0
@@ -0,0 +1,129 @@
1
+ "use client";
2
+ import {
3
+ Sidebar
4
+ } from "./chunk-BN7HGCQ4.js";
5
+ import "./chunk-V6RONFCQ.js";
6
+ import "./chunk-CDPVENXR.js";
7
+ import "./chunk-TQJ6YPJ3.js";
8
+ import {
9
+ buttonVariants
10
+ } from "./chunk-QKOA6KEZ.js";
11
+ import "./chunk-2FLZOPQN.js";
12
+ import {
13
+ PanelLeft
14
+ } from "./chunk-5QPVK7QM.js";
15
+ import {
16
+ twMerge
17
+ } from "./chunk-TK3TM3MR.js";
18
+ import "./chunk-ET4TW6M5.js";
19
+ import "./chunk-YL3MZH7N.js";
20
+ import {
21
+ useSidebar
22
+ } from "./chunk-27HFSL7N.js";
23
+ import "./chunk-EFMHXXHW.js";
24
+ import "./chunk-MLKGABMK.js";
25
+
26
+ // src/components/layout/dynamic-sidebar.tsx
27
+ import {
28
+ useCallback,
29
+ useMemo,
30
+ useRef,
31
+ useState
32
+ } from "react";
33
+ import { useOnChange } from "fumadocs-core/utils/use-on-change";
34
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
35
+ function DynamicSidebar(props) {
36
+ const { collapsed, setCollapsed } = useSidebar();
37
+ const [hover, setHover] = useState(false);
38
+ const timerRef = useRef(0);
39
+ const closeTimeRef = useRef(0);
40
+ useOnChange(collapsed, () => {
41
+ setHover(false);
42
+ closeTimeRef.current = Date.now() + 150;
43
+ });
44
+ const onEnter = useCallback((e) => {
45
+ if (e.pointerType === "touch" || closeTimeRef.current > Date.now()) return;
46
+ window.clearTimeout(timerRef.current);
47
+ setHover(true);
48
+ }, []);
49
+ const onLeave = useCallback((e) => {
50
+ if (e.pointerType === "touch") return;
51
+ window.clearTimeout(timerRef.current);
52
+ timerRef.current = window.setTimeout(
53
+ () => {
54
+ setHover(false);
55
+ closeTimeRef.current = Date.now() + 150;
56
+ },
57
+ Math.min(e.clientX, document.body.clientWidth - e.clientX) > 100 ? 0 : 500
58
+ );
59
+ }, []);
60
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
61
+ collapsed ? /* @__PURE__ */ jsxs(Fragment, { children: [
62
+ /* @__PURE__ */ jsx(
63
+ "div",
64
+ {
65
+ className: "fixed inset-y-0 start-0 w-6 max-md:hidden",
66
+ onPointerEnter: onEnter,
67
+ onPointerLeave: onLeave
68
+ }
69
+ ),
70
+ /* @__PURE__ */ jsx(
71
+ "button",
72
+ {
73
+ type: "button",
74
+ "aria-label": "Collapse Sidebar",
75
+ className: twMerge(
76
+ buttonVariants({
77
+ color: "secondary",
78
+ size: "icon",
79
+ className: "fixed start-4 bottom-2 z-10 max-md:hidden"
80
+ })
81
+ ),
82
+ onClick: () => {
83
+ setCollapsed((v) => !v);
84
+ },
85
+ children: /* @__PURE__ */ jsx(PanelLeft, {})
86
+ }
87
+ ),
88
+ /* @__PURE__ */ jsx("style", { children: `#nd-page { --fd-sidebar-width: 0px; }` })
89
+ ] }) : null,
90
+ /* @__PURE__ */ jsx(
91
+ Sidebar,
92
+ {
93
+ ...props,
94
+ aside: useMemo(
95
+ () => ({
96
+ "data-collapse": collapsed,
97
+ "data-hover": hover,
98
+ onPointerEnter: collapsed ? onEnter : void 0,
99
+ onPointerLeave: collapsed ? onLeave : void 0,
100
+ "aria-hidden": Boolean(collapsed && !hover),
101
+ style: {
102
+ // the offset given to docs content when the sidebar is collapsed
103
+ "--fd-content-offset": "calc(var(--fd-sidebar-width) * -1)"
104
+ },
105
+ className: twMerge(
106
+ "md:transition-[transform,margin,flex]",
107
+ collapsed && [
108
+ "md:me-[var(--fd-content-offset)] md:grow-0 md:shadow-md",
109
+ hover ? "md:translate-x-0" : "md:translate-x-[calc(var(--fd-sidebar-width)*-1)] rtl:md:translate-x-[var(--fd-sidebar-width)]"
110
+ ],
111
+ ``
112
+ )
113
+ }),
114
+ [collapsed, hover, onEnter, onLeave]
115
+ )
116
+ }
117
+ ),
118
+ /* @__PURE__ */ jsx(
119
+ "div",
120
+ {
121
+ role: "none",
122
+ className: twMerge("transition-all max-md:hidden", collapsed && "flex-1")
123
+ }
124
+ )
125
+ ] });
126
+ }
127
+ export {
128
+ DynamicSidebar as default
129
+ };
@@ -1,18 +1,20 @@
1
1
  "use client";
2
- import {
3
- useI18n
4
- } from "./chunk-EFMHXXHW.js";
5
2
  import {
6
3
  buttonVariants
7
- } from "./chunk-EDNTYBXS.js";
4
+ } from "./chunk-QKOA6KEZ.js";
5
+ import {
6
+ SquarePen
7
+ } from "./chunk-5QPVK7QM.js";
8
8
  import {
9
9
  twMerge
10
10
  } from "./chunk-TK3TM3MR.js";
11
+ import {
12
+ useI18n
13
+ } from "./chunk-EFMHXXHW.js";
11
14
  import "./chunk-MLKGABMK.js";
12
15
 
13
16
  // src/components/layout/edit-on-github.tsx
14
17
  import { forwardRef } from "react";
15
- import { Edit } from "lucide-react";
16
18
  import { jsx, jsxs } from "react/jsx-runtime";
17
19
  var EditOnGitHub = forwardRef(
18
20
  ({ owner, repo, sha = "main", path, ...props }, ref) => {
@@ -27,13 +29,13 @@ var EditOnGitHub = forwardRef(
27
29
  ...props,
28
30
  className: twMerge(
29
31
  buttonVariants({
30
- color: "outline",
31
- className: "text-fd-muted-foreground text-xs p-1.5 gap-2"
32
+ color: "secondary",
33
+ className: "gap-1.5 py-1 text-fd-muted-foreground"
32
34
  }),
33
35
  props.className
34
36
  ),
35
37
  children: [
36
- /* @__PURE__ */ jsx(Edit, { className: "size-3.5" }),
38
+ /* @__PURE__ */ jsx(SquarePen, { className: "size-3.5" }),
37
39
  text.editOnGithub
38
40
  ]
39
41
  }
@@ -0,0 +1,26 @@
1
+ import { ReactNode, ButtonHTMLAttributes } from 'react';
2
+ import { L as LinkItemType, S as SharedNavProps } from '../shared-ElIzX-sQ.js';
3
+ export { I as IconItem, N as NavProvider } from '../shared-ElIzX-sQ.js';
4
+ export { RootToggle } from '../components/layout/root-toggle.js';
5
+ export { a as Sidebar } from '../sidebar-HwpSmOKR.js';
6
+ export { T as TreeContextProvider } from '../tree-06ley65N.js';
7
+ export { LanguageToggle, LanguageToggleText } from '../components/layout/language-toggle.js';
8
+ import 'fumadocs-core/server';
9
+
10
+ interface MenuItemProps extends React.HTMLAttributes<HTMLElement> {
11
+ item: LinkItemType;
12
+ }
13
+ declare function MenuItem({ item, ...props }: MenuItemProps): ReactNode;
14
+
15
+ declare function ThemeToggle({ className, ...props }: ButtonHTMLAttributes<HTMLButtonElement>): React.ReactElement;
16
+
17
+ declare function SubNav({ title, url, enableSearch, ...props }: Omit<SharedNavProps, 'transparentMode'> & {
18
+ className?: string;
19
+ }): React.ReactElement;
20
+ declare function SidebarCollapseTrigger(props: ButtonHTMLAttributes<HTMLButtonElement>): React.ReactElement;
21
+ interface LinksMenuProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
22
+ items?: ReactNode;
23
+ }
24
+ declare function LinksMenu({ items, ...props }: LinksMenuProps): ReactNode;
25
+
26
+ export { LinksMenu, MenuItem, SidebarCollapseTrigger, SubNav, ThemeToggle };
@@ -0,0 +1,200 @@
1
+ "use client";
2
+ import {
3
+ Sidebar,
4
+ itemVariants
5
+ } from "../chunk-BN7HGCQ4.js";
6
+ import {
7
+ BaseLinkItem,
8
+ ButtonItem,
9
+ IconItem,
10
+ ThemeToggle
11
+ } from "../chunk-PZTQPB4U.js";
12
+ import {
13
+ SearchToggle
14
+ } from "../chunk-V6RONFCQ.js";
15
+ import {
16
+ LanguageToggle,
17
+ LanguageToggleText
18
+ } from "../chunk-KZTWSBYY.js";
19
+ import {
20
+ RootToggle
21
+ } from "../chunk-WRBUXI2A.js";
22
+ import "../chunk-CDPVENXR.js";
23
+ import {
24
+ Collapsible,
25
+ CollapsibleContent,
26
+ CollapsibleTrigger
27
+ } from "../chunk-TQJ6YPJ3.js";
28
+ import {
29
+ buttonVariants
30
+ } from "../chunk-QKOA6KEZ.js";
31
+ import {
32
+ NavContext,
33
+ NavProvider,
34
+ Title
35
+ } from "../chunk-MCX7E6ZW.js";
36
+ import {
37
+ Popover,
38
+ PopoverContent,
39
+ PopoverTrigger
40
+ } from "../chunk-IVBHRX3O.js";
41
+ import "../chunk-2FLZOPQN.js";
42
+ import {
43
+ ChevronDown,
44
+ Menu,
45
+ PanelLeft,
46
+ X
47
+ } from "../chunk-5QPVK7QM.js";
48
+ import {
49
+ twMerge
50
+ } from "../chunk-TK3TM3MR.js";
51
+ import {
52
+ useSearchContext
53
+ } from "../chunk-ET4TW6M5.js";
54
+ import {
55
+ TreeContextProvider
56
+ } from "../chunk-YL3MZH7N.js";
57
+ import {
58
+ useSidebar
59
+ } from "../chunk-27HFSL7N.js";
60
+ import "../chunk-EFMHXXHW.js";
61
+ import "../chunk-MLKGABMK.js";
62
+
63
+ // src/layouts/docs.client.tsx
64
+ import { SidebarTrigger } from "fumadocs-core/sidebar";
65
+ import {
66
+ useContext,
67
+ useState
68
+ } from "react";
69
+ import { usePathname } from "next/navigation";
70
+ import { useOnChange } from "fumadocs-core/utils/use-on-change";
71
+
72
+ // src/layouts/menu-item.tsx
73
+ import { jsx, jsxs } from "react/jsx-runtime";
74
+ function MenuItem({ item, ...props }) {
75
+ if (item.type === "custom")
76
+ return /* @__PURE__ */ jsx("div", { ...props, className: twMerge("grid", props.className), children: item.children });
77
+ if (item.type === "menu") {
78
+ return /* @__PURE__ */ jsxs(Collapsible, { className: "flex flex-col", children: [
79
+ /* @__PURE__ */ jsxs(
80
+ CollapsibleTrigger,
81
+ {
82
+ ...props,
83
+ "data-active": false,
84
+ className: twMerge(itemVariants(), "group/link", props.className),
85
+ children: [
86
+ item.icon,
87
+ item.text,
88
+ /* @__PURE__ */ jsx(ChevronDown, { className: "ms-auto transition-transform group-data-[state=closed]/link:-rotate-90" })
89
+ ]
90
+ }
91
+ ),
92
+ /* @__PURE__ */ jsx(CollapsibleContent, { children: /* @__PURE__ */ jsx("div", { className: "ms-2 flex flex-col border-s py-2 ps-2", children: item.items.map((child, i) => /* @__PURE__ */ jsx(MenuItem, { item: child }, i)) }) })
93
+ ] });
94
+ }
95
+ if (item.type === "button") {
96
+ return /* @__PURE__ */ jsx(ButtonItem, { item, ...props });
97
+ }
98
+ return /* @__PURE__ */ jsxs(
99
+ BaseLinkItem,
100
+ {
101
+ item,
102
+ ...props,
103
+ className: twMerge(itemVariants(), props.className),
104
+ children: [
105
+ item.icon,
106
+ item.text
107
+ ]
108
+ }
109
+ );
110
+ }
111
+
112
+ // src/layouts/docs.client.tsx
113
+ import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
114
+ function SubNav({
115
+ title,
116
+ url,
117
+ enableSearch = true,
118
+ ...props
119
+ }) {
120
+ const { open } = useSidebar();
121
+ const { isTransparent } = useContext(NavContext);
122
+ const search = useSearchContext();
123
+ return /* @__PURE__ */ jsxs2(
124
+ "header",
125
+ {
126
+ id: "nd-subnav",
127
+ ...props,
128
+ className: twMerge(
129
+ "sticky top-[var(--fd-banner-height)] z-40 flex flex-row items-center border-b border-fd-foreground/10 px-4 transition-colors",
130
+ (!isTransparent || open) && "bg-fd-background/80 backdrop-blur-lg",
131
+ props.className
132
+ ),
133
+ children: [
134
+ /* @__PURE__ */ jsx2(Title, { url, title }),
135
+ /* @__PURE__ */ jsx2("div", { className: "flex flex-1 flex-row items-center gap-1", children: props.children }),
136
+ search.enabled && enableSearch ? /* @__PURE__ */ jsx2(SearchToggle, {}) : null,
137
+ /* @__PURE__ */ jsx2(
138
+ SidebarTrigger,
139
+ {
140
+ className: twMerge(
141
+ buttonVariants({
142
+ color: "ghost",
143
+ size: "icon",
144
+ className: "-me-2 md:hidden"
145
+ })
146
+ ),
147
+ children: open ? /* @__PURE__ */ jsx2(X, {}) : /* @__PURE__ */ jsx2(Menu, {})
148
+ }
149
+ )
150
+ ]
151
+ }
152
+ );
153
+ }
154
+ function SidebarCollapseTrigger(props) {
155
+ const { setCollapsed } = useSidebar();
156
+ return /* @__PURE__ */ jsx2(
157
+ "button",
158
+ {
159
+ type: "button",
160
+ "aria-label": "Collapse Sidebar",
161
+ ...props,
162
+ className: twMerge(
163
+ buttonVariants({
164
+ color: "ghost",
165
+ size: "icon"
166
+ }),
167
+ props.className
168
+ ),
169
+ onClick: () => {
170
+ setCollapsed((prev) => !prev);
171
+ },
172
+ children: /* @__PURE__ */ jsx2(PanelLeft, {})
173
+ }
174
+ );
175
+ }
176
+ function LinksMenu({ items, ...props }) {
177
+ const [open, setOpen] = useState(false);
178
+ const pathname = usePathname();
179
+ useOnChange(pathname, () => {
180
+ setOpen(false);
181
+ });
182
+ return /* @__PURE__ */ jsxs2(Popover, { open, onOpenChange: setOpen, children: [
183
+ /* @__PURE__ */ jsx2(PopoverTrigger, { ...props }),
184
+ /* @__PURE__ */ jsx2(PopoverContent, { className: "flex flex-col p-1", children: items })
185
+ ] });
186
+ }
187
+ export {
188
+ IconItem,
189
+ LanguageToggle,
190
+ LanguageToggleText,
191
+ LinksMenu,
192
+ MenuItem,
193
+ NavProvider,
194
+ RootToggle,
195
+ Sidebar,
196
+ SidebarCollapseTrigger,
197
+ SubNav,
198
+ ThemeToggle,
199
+ TreeContextProvider
200
+ };
@@ -0,0 +1,29 @@
1
+ import { PageTree } from 'fumadocs-core/server';
2
+ import { HTMLAttributes, ReactNode } from 'react';
3
+ import { S as SidebarProps } from '../sidebar-HwpSmOKR.js';
4
+ import { B as BaseLayoutProps } from '../shared-ElIzX-sQ.js';
5
+ export { L as LinkItemType } from '../shared-ElIzX-sQ.js';
6
+ import { Option } from '../components/layout/root-toggle.js';
7
+
8
+ interface TabOptions {
9
+ transform?: (option: Option, node: PageTree.Folder) => Option | null;
10
+ }
11
+ declare function getSidebarTabs(pageTree: PageTree.Root, { transform }?: TabOptions): Option[];
12
+
13
+ interface SidebarOptions extends Omit<SidebarProps, 'children'> {
14
+ enabled: boolean;
15
+ component: ReactNode;
16
+ collapsible: boolean;
17
+ /**
18
+ * Root Toggle options
19
+ */
20
+ tabs?: Option[] | TabOptions | false;
21
+ }
22
+ interface DocsLayoutProps extends BaseLayoutProps {
23
+ tree: PageTree.Root;
24
+ sidebar?: Partial<SidebarOptions>;
25
+ containerProps?: HTMLAttributes<HTMLDivElement>;
26
+ }
27
+ declare function DocsLayout({ nav: { transparentMode, ...nav }, sidebar: { enabled: sidebarEnabled, collapsible, component: sidebarReplace, tabs: tabOptions, ...sidebar }, i18n, ...props }: DocsLayoutProps): ReactNode;
28
+
29
+ export { DocsLayout, type DocsLayoutProps, type TabOptions, getSidebarTabs };
@@ -0,0 +1,187 @@
1
+ import {
2
+ TreeContextProvider,
3
+ SidebarCollapseTrigger,
4
+ ThemeToggle,
5
+ SubNav,
6
+ LanguageToggle,
7
+ LanguageToggleText,
8
+ LinksMenu,
9
+ RootToggle,
10
+ Sidebar,
11
+ IconItem,
12
+ MenuItem,
13
+ NavProvider,
14
+ } from "./docs.client"
15
+ import {
16
+ buttonVariants
17
+ } from "../chunk-QKOA6KEZ.js";
18
+ import {
19
+ Ellipsis,
20
+ Languages
21
+ } from "../chunk-5QPVK7QM.js";
22
+ import {
23
+ getLinks,
24
+ replaceOrDefault
25
+ } from "../chunk-UQIRU7MP.js";
26
+ import {
27
+ twMerge
28
+ } from "../chunk-TK3TM3MR.js";
29
+ import "../chunk-MLKGABMK.js";
30
+
31
+ // src/layouts/docs.tsx
32
+ import { Fragment } from "react";
33
+ import Link from "next/link";
34
+ import { notFound } from "next/navigation";
35
+ import dynamic from "next/dynamic";
36
+
37
+ // src/utils/get-sidebar-tabs.tsx
38
+ function getSidebarTabs(pageTree, { transform } = {}) {
39
+ const options = [];
40
+ function traverse(node) {
41
+ if (node.type === "folder" && node.root && node.index) {
42
+ const option = {
43
+ url: node.index.url,
44
+ title: node.name,
45
+ icon: node.icon,
46
+ description: node.description
47
+ };
48
+ const mapped = transform ? transform(option, node) : option;
49
+ if (mapped) options.push(mapped);
50
+ }
51
+ if (node.type === "folder") node.children.forEach(traverse);
52
+ }
53
+ pageTree.children.forEach(traverse);
54
+ return options;
55
+ }
56
+
57
+ // src/layouts/docs.tsx
58
+ import { Fragment as Fragment2, jsx, jsxs } from "react/jsx-runtime";
59
+ var DynamicSidebar = dynamic(
60
+ () => import("../dynamic-sidebar-QWGMOUMS.js")
61
+ );
62
+ function DocsLayout({
63
+ nav: { transparentMode, ...nav } = {},
64
+ sidebar: {
65
+ enabled: sidebarEnabled = true,
66
+ collapsible = true,
67
+ component: sidebarReplace,
68
+ tabs: tabOptions,
69
+ ...sidebar
70
+ } = {},
71
+ i18n = false,
72
+ ...props
73
+ }) {
74
+ const links = getLinks(props.links ?? [], props.githubUrl);
75
+ const Aside = collapsible ? DynamicSidebar : Sidebar;
76
+ if (props.tree === void 0) notFound();
77
+ const header = [];
78
+ const footer = [];
79
+ if (nav.title)
80
+ header.push(
81
+ /* @__PURE__ */ jsx(
82
+ Link,
83
+ {
84
+ href: nav.url ?? "/",
85
+ className: "inline-flex items-center gap-2.5 py-1 font-medium",
86
+ children: nav.title
87
+ },
88
+ "title"
89
+ )
90
+ );
91
+ if (nav.children)
92
+ header.push(/* @__PURE__ */ jsx(Fragment, { children: nav.children }, "children"));
93
+ if (links.length > 0)
94
+ header.push(
95
+ /* @__PURE__ */ jsx(
96
+ LinksMenu,
97
+ {
98
+ items: links.map((item, i) => /* @__PURE__ */ jsx(MenuItem, { item }, i)),
99
+ className: twMerge(
100
+ buttonVariants({
101
+ size: "icon",
102
+ color: "ghost",
103
+ className: "ms-auto"
104
+ })
105
+ ),
106
+ children: /* @__PURE__ */ jsx(Ellipsis, {})
107
+ },
108
+ "links"
109
+ )
110
+ );
111
+ const iconLinks = links.filter((v) => v.type === "icon");
112
+ if (iconLinks.length > 0) {
113
+ footer.push(
114
+ /* @__PURE__ */ jsx("div", { className: "flex flex-row items-center md:hidden", children: iconLinks.map((item, i) => /* @__PURE__ */ jsx(IconItem, { item, className: "text-fd-muted-foreground" }, i)) }, "links")
115
+ );
116
+ }
117
+ if (!props.disableThemeSwitch) {
118
+ footer.push(
119
+ /* @__PURE__ */ jsx(
120
+ ThemeToggle,
121
+ {
122
+ className: twMerge("md:me-auto", !i18n && "max-md:ms-auto")
123
+ },
124
+ "theme"
125
+ )
126
+ );
127
+ }
128
+ if (i18n) {
129
+ footer.push(
130
+ /* @__PURE__ */ jsxs(LanguageToggle, { className: "max-md:order-first max-md:me-auto", children: [
131
+ /* @__PURE__ */ jsx(Languages, { className: "size-5" }),
132
+ /* @__PURE__ */ jsx(LanguageToggleText, { className: "md:hidden" })
133
+ ] }, "i18n")
134
+ );
135
+ }
136
+ if (collapsible) {
137
+ footer.push(
138
+ /* @__PURE__ */ jsx(SidebarCollapseTrigger, { className: "max-md:hidden" }, "sidebar")
139
+ );
140
+ }
141
+ let tabs = [];
142
+ if (Array.isArray(tabOptions)) tabs = tabOptions;
143
+ else if (typeof tabOptions === "object")
144
+ tabs = getSidebarTabs(props.tree, tabOptions);
145
+ else if (tabOptions !== false) tabs = getSidebarTabs(props.tree);
146
+ return /* @__PURE__ */ jsx(TreeContextProvider, { tree: props.tree, children: /* @__PURE__ */ jsxs(NavProvider, { transparentMode, children: [
147
+ replaceOrDefault(nav, /* @__PURE__ */ jsx(SubNav, { className: "h-14 md:hidden", ...nav })),
148
+ /* @__PURE__ */ jsxs(
149
+ "main",
150
+ {
151
+ id: "nd-docs-layout",
152
+ ...props.containerProps,
153
+ className: twMerge(
154
+ "flex flex-1 flex-row",
155
+ !nav.component && nav.enabled !== false && "[--fd-nav-height:3.5rem] md:[--fd-nav-height:0px]",
156
+ props.containerProps?.className
157
+ ),
158
+ children: [
159
+ replaceOrDefault(
160
+ { enabled: sidebarEnabled, component: sidebarReplace },
161
+ /* @__PURE__ */ jsx(
162
+ Aside,
163
+ {
164
+ ...sidebar,
165
+ banner: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1 px-4 empty:hidden md:px-3 md:pb-2", children: [
166
+ header.length > 0 ? /* @__PURE__ */ jsx("div", { className: "flex flex-row items-center border-b pb-2 max-md:hidden", children: header }) : null,
167
+ tabs.length > 0 ? /* @__PURE__ */ jsx(RootToggle, { className: "-mx-1", options: tabs }) : null,
168
+ sidebar.banner
169
+ ] }),
170
+ footer: /* @__PURE__ */ jsxs(Fragment2, { children: [
171
+ /* @__PURE__ */ jsx("div", { className: "flex flex-row items-center border-t py-1 empty:hidden max-md:gap-1.5 max-md:px-3 md:mx-3", children: footer }),
172
+ sidebar.footer
173
+ ] }),
174
+ children: /* @__PURE__ */ jsx("div", { className: "flex flex-col px-2 pt-4 empty:hidden md:hidden", children: links.filter((v) => v.type !== "icon").map((item, i) => /* @__PURE__ */ jsx(MenuItem, { item }, i)) })
175
+ }
176
+ )
177
+ ),
178
+ props.children
179
+ ]
180
+ }
181
+ )
182
+ ] }) });
183
+ }
184
+ export {
185
+ DocsLayout,
186
+ getSidebarTabs
187
+ };
@@ -0,0 +1,11 @@
1
+ import { ReactNode } from 'react';
2
+ import { S as SharedNavProps, L as LinkItemType } from '../shared-ElIzX-sQ.js';
3
+ export { N as NavProvider } from '../shared-ElIzX-sQ.js';
4
+
5
+ declare function Nav({ items, enableSearch, ...props }: Omit<SharedNavProps, 'transparentMode'> & {
6
+ disableThemeSwitch?: boolean;
7
+ i18n?: boolean;
8
+ items: LinkItemType[];
9
+ }): ReactNode;
10
+
11
+ export { Nav };