fumadocs-ui 11.3.2 → 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.
- package/dist/{chunk-TDTHXDET.js → chunk-34Z7WODD.js} +2 -1
- package/dist/{chunk-IN5NHEZV.js → chunk-3F57TIUQ.js} +20 -5
- package/dist/{chunk-PXDQVGII.js → chunk-7EMVRXMS.js} +10 -1
- package/dist/{chunk-PW7TBOIJ.js → chunk-CRYPD6UZ.js} +2 -1
- package/dist/{chunk-UKE65HV3.js → chunk-IOHAG6BY.js} +1 -1
- package/dist/chunk-JQW5DMD2.js +226 -0
- package/dist/{chunk-WNKY4RA5.js → chunk-UBVEKNRF.js} +1 -1
- package/dist/components/api.js +1 -1
- package/dist/components/dialog/search-algolia.js +3 -2
- package/dist/components/dialog/search-default.js +3 -2
- package/dist/components/dialog/search.js +3 -2
- package/dist/components/heading.js +1 -1
- package/dist/components/layout/language-toggle.d.ts +6 -0
- package/dist/components/layout/language-toggle.js +58 -0
- package/dist/components/layout/root-toggle.d.ts +16 -0
- package/dist/components/layout/root-toggle.js +60 -0
- package/dist/components/type-table.js +1 -1
- package/dist/docs.client.d.ts +13 -0
- package/dist/docs.client.js +396 -0
- package/dist/{i18n-K879Pt9h.d.ts → i18n-CE8z-AAs.d.ts} +1 -0
- package/dist/i18n.d.ts +3 -6
- package/dist/i18n.js +4 -102
- package/dist/{layout-WuS8Ab4e.d.ts → layout.client-Duq0TTke.d.ts} +23 -15
- package/dist/layout.client.d.ts +2 -8
- package/dist/layout.client.js +37 -565
- package/dist/layout.d.ts +1 -1
- package/dist/layout.js +40 -26
- package/dist/mdx.js +2 -2
- package/dist/page.client.js +4 -4
- package/dist/page.js +17 -8
- package/dist/provider.d.ts +11 -12
- package/dist/provider.js +9 -10
- package/dist/style.css +1 -1
- package/dist/tailwind-plugin.cjs +17 -22
- package/dist/tailwind-plugin.js +17 -22
- package/dist/twoslash/popup.js +1 -1
- package/dist/twoslash.css +1 -1
- package/package.json +4 -5
package/dist/layout.client.js
CHANGED
|
@@ -1,35 +1,23 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
} from "./chunk-TDTHXDET.js";
|
|
9
|
-
import {
|
|
10
|
-
ScrollArea,
|
|
11
|
-
ScrollViewport
|
|
12
|
-
} from "./chunk-VYTHQTZE.js";
|
|
3
|
+
LargeSearchToggle,
|
|
4
|
+
LinkItem,
|
|
5
|
+
SearchToggle,
|
|
6
|
+
ThemeToggle
|
|
7
|
+
} from "./chunk-JQW5DMD2.js";
|
|
13
8
|
import {
|
|
14
9
|
Popover,
|
|
15
10
|
PopoverContent,
|
|
16
11
|
PopoverTrigger
|
|
17
|
-
} from "./chunk-
|
|
18
|
-
import
|
|
19
|
-
hasActive,
|
|
20
|
-
isActive
|
|
21
|
-
} from "./chunk-AN2Y6MA2.js";
|
|
12
|
+
} from "./chunk-UBVEKNRF.js";
|
|
13
|
+
import "./chunk-AN2Y6MA2.js";
|
|
22
14
|
import {
|
|
23
15
|
useSearchContext
|
|
24
16
|
} from "./chunk-FSPYEOFC.js";
|
|
25
17
|
import {
|
|
26
18
|
useI18n
|
|
27
|
-
} from "./chunk-
|
|
28
|
-
import
|
|
29
|
-
Collapsible,
|
|
30
|
-
CollapsibleContent,
|
|
31
|
-
CollapsibleTrigger
|
|
32
|
-
} from "./chunk-7XPZOMJ2.js";
|
|
19
|
+
} from "./chunk-CRYPD6UZ.js";
|
|
20
|
+
import "./chunk-7XPZOMJ2.js";
|
|
33
21
|
import {
|
|
34
22
|
buttonVariants
|
|
35
23
|
} from "./chunk-7GZKFBAP.js";
|
|
@@ -38,166 +26,17 @@ import {
|
|
|
38
26
|
} from "./chunk-TK3TM3MR.js";
|
|
39
27
|
import "./chunk-MLKGABMK.js";
|
|
40
28
|
|
|
41
|
-
// src/components/nav.tsx
|
|
42
|
-
import {
|
|
43
|
-
import Link2 from "fumadocs-core/link";
|
|
44
|
-
import { SidebarTrigger } from "fumadocs-core/sidebar";
|
|
45
|
-
import { useCallback as useCallback2, useEffect, useState } from "react";
|
|
46
|
-
import { usePathname as usePathname2 } from "next/navigation";
|
|
47
|
-
|
|
48
|
-
// src/components/theme-toggle.tsx
|
|
49
|
-
import { cva } from "class-variance-authority";
|
|
50
|
-
import { Moon, Sun } from "lucide-react";
|
|
51
|
-
import { useTheme } from "next-themes";
|
|
52
|
-
import { useCallback } from "react";
|
|
53
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
54
|
-
var buttonVariants2 = cva("size-7 rounded-full p-1.5 text-muted-foreground", {
|
|
55
|
-
variants: {
|
|
56
|
-
dark: {
|
|
57
|
-
true: "dark:bg-accent dark:text-accent-foreground",
|
|
58
|
-
false: "bg-accent text-accent-foreground dark:bg-transparent dark:text-muted-foreground"
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
function ThemeToggle({
|
|
63
|
-
className,
|
|
64
|
-
...props
|
|
65
|
-
}) {
|
|
66
|
-
const { setTheme, resolvedTheme } = useTheme();
|
|
67
|
-
const onToggle = useCallback(() => {
|
|
68
|
-
setTheme(resolvedTheme === "dark" ? "light" : "dark");
|
|
69
|
-
}, [setTheme, resolvedTheme]);
|
|
70
|
-
return /* @__PURE__ */ jsxs(
|
|
71
|
-
"button",
|
|
72
|
-
{
|
|
73
|
-
type: "button",
|
|
74
|
-
className: twMerge(
|
|
75
|
-
"inline-flex items-center rounded-full border p-0.5",
|
|
76
|
-
className
|
|
77
|
-
),
|
|
78
|
-
"aria-label": "Toggle Theme",
|
|
79
|
-
onClick: onToggle,
|
|
80
|
-
...props,
|
|
81
|
-
children: [
|
|
82
|
-
/* @__PURE__ */ jsx(Sun, { className: twMerge(buttonVariants2({ dark: false })) }),
|
|
83
|
-
/* @__PURE__ */ jsx(Moon, { className: twMerge(buttonVariants2({ dark: true })) })
|
|
84
|
-
]
|
|
85
|
-
}
|
|
86
|
-
);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
// src/components/link-item.tsx
|
|
29
|
+
// src/components/layout/nav.tsx
|
|
30
|
+
import { MoreVertical } from "lucide-react";
|
|
90
31
|
import Link from "fumadocs-core/link";
|
|
91
|
-
import {
|
|
32
|
+
import { useEffect, useState } from "react";
|
|
92
33
|
import { usePathname } from "next/navigation";
|
|
93
|
-
import {
|
|
94
|
-
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
95
|
-
var linkItemVariants = cva2(
|
|
96
|
-
"inline-flex items-center gap-1.5 rounded-lg p-2 text-[15px] text-muted-foreground transition-colors [&_svg]:size-4",
|
|
97
|
-
{
|
|
98
|
-
variants: {
|
|
99
|
-
active: {
|
|
100
|
-
true: "bg-accent text-accent-foreground",
|
|
101
|
-
false: "hover:bg-accent"
|
|
102
|
-
}
|
|
103
|
-
},
|
|
104
|
-
defaultVariants: {
|
|
105
|
-
active: false
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
);
|
|
109
|
-
function LinkItem({
|
|
110
|
-
item,
|
|
111
|
-
on = "nav",
|
|
112
|
-
className,
|
|
113
|
-
...props
|
|
114
|
-
}) {
|
|
115
|
-
const pathname = usePathname();
|
|
116
|
-
if (item.type === "menu" && on === "nav") {
|
|
117
|
-
return /* @__PURE__ */ jsxs2(Popover, { children: [
|
|
118
|
-
/* @__PURE__ */ jsxs2(
|
|
119
|
-
PopoverTrigger,
|
|
120
|
-
{
|
|
121
|
-
className: twMerge(
|
|
122
|
-
linkItemVariants({ className }),
|
|
123
|
-
"data-[state=open]:bg-accent"
|
|
124
|
-
),
|
|
125
|
-
...props,
|
|
126
|
-
children: [
|
|
127
|
-
item.text,
|
|
128
|
-
/* @__PURE__ */ jsx2(ChevronDown, { className: "ml-auto size-4" })
|
|
129
|
-
]
|
|
130
|
-
}
|
|
131
|
-
),
|
|
132
|
-
/* @__PURE__ */ jsx2(PopoverContent, { className: "flex flex-col", children: item.items.map((child, i) => /* @__PURE__ */ jsx2(LinkItem, { item: child, on: "menu" }, i)) })
|
|
133
|
-
] });
|
|
134
|
-
}
|
|
135
|
-
if (item.type === "menu") {
|
|
136
|
-
return /* @__PURE__ */ jsxs2(Collapsible, { className: "flex flex-col", children: [
|
|
137
|
-
/* @__PURE__ */ jsxs2(
|
|
138
|
-
CollapsibleTrigger,
|
|
139
|
-
{
|
|
140
|
-
className: twMerge(linkItemVariants({ className }), "group/link"),
|
|
141
|
-
...props,
|
|
142
|
-
children: [
|
|
143
|
-
item.icon,
|
|
144
|
-
item.text,
|
|
145
|
-
/* @__PURE__ */ jsx2(ChevronDown, { className: "ml-auto size-4 group-data-[state=closed]/link:-rotate-90" })
|
|
146
|
-
]
|
|
147
|
-
}
|
|
148
|
-
),
|
|
149
|
-
/* @__PURE__ */ jsx2(CollapsibleContent, { children: /* @__PURE__ */ jsx2("div", { className: "flex flex-col py-1 ps-4", children: item.items.map((child, i) => /* @__PURE__ */ jsx2(LinkItem, { item: child, on: "menu" }, i)) }) })
|
|
150
|
-
] });
|
|
151
|
-
}
|
|
152
|
-
const activeType = item.active ?? "url";
|
|
153
|
-
const active = activeType !== "none" ? isActive(item.url, pathname, activeType === "nested-url") : false;
|
|
154
|
-
if (item.type === "secondary" && on === "nav") {
|
|
155
|
-
return /* @__PURE__ */ jsx2(
|
|
156
|
-
Link,
|
|
157
|
-
{
|
|
158
|
-
"aria-label": item.text,
|
|
159
|
-
href: item.url,
|
|
160
|
-
external: item.external,
|
|
161
|
-
className: twMerge(
|
|
162
|
-
buttonVariants({
|
|
163
|
-
size: "icon",
|
|
164
|
-
color: "ghost",
|
|
165
|
-
className
|
|
166
|
-
})
|
|
167
|
-
),
|
|
168
|
-
...props,
|
|
169
|
-
children: item.icon
|
|
170
|
-
}
|
|
171
|
-
);
|
|
172
|
-
}
|
|
173
|
-
return /* @__PURE__ */ jsxs2(
|
|
174
|
-
Link,
|
|
175
|
-
{
|
|
176
|
-
href: item.url,
|
|
177
|
-
external: item.external,
|
|
178
|
-
className: twMerge(
|
|
179
|
-
linkItemVariants({
|
|
180
|
-
active,
|
|
181
|
-
className
|
|
182
|
-
})
|
|
183
|
-
),
|
|
184
|
-
...props,
|
|
185
|
-
children: [
|
|
186
|
-
on === "menu" ? item.icon : null,
|
|
187
|
-
item.text
|
|
188
|
-
]
|
|
189
|
-
}
|
|
190
|
-
);
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
// src/components/nav.tsx
|
|
194
|
-
import { Fragment, jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
34
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
195
35
|
function Nav({
|
|
196
36
|
title = "My App",
|
|
197
37
|
url = "/",
|
|
198
38
|
items,
|
|
199
39
|
transparentMode = "none",
|
|
200
|
-
enableSidebar,
|
|
201
40
|
enableSearch = true,
|
|
202
41
|
children
|
|
203
42
|
}) {
|
|
@@ -214,16 +53,16 @@ function Nav({
|
|
|
214
53
|
window.removeEventListener("scroll", listener);
|
|
215
54
|
};
|
|
216
55
|
}, [transparentMode]);
|
|
217
|
-
return /* @__PURE__ */
|
|
56
|
+
return /* @__PURE__ */ jsx(
|
|
218
57
|
"header",
|
|
219
58
|
{
|
|
220
59
|
className: twMerge(
|
|
221
60
|
"sticky top-0 z-50 h-16 border-b transition-colors",
|
|
222
61
|
transparent ? "border-transparent" : "border-foreground/10 bg-background/50 backdrop-blur-md"
|
|
223
62
|
),
|
|
224
|
-
children: /* @__PURE__ */
|
|
225
|
-
/* @__PURE__ */
|
|
226
|
-
|
|
63
|
+
children: /* @__PURE__ */ jsxs("nav", { className: "mx-auto flex size-full max-w-container flex-row items-center gap-6 px-4", children: [
|
|
64
|
+
/* @__PURE__ */ jsx(
|
|
65
|
+
Link,
|
|
227
66
|
{
|
|
228
67
|
href: url,
|
|
229
68
|
className: "inline-flex items-center gap-3 font-semibold",
|
|
@@ -231,7 +70,7 @@ function Nav({
|
|
|
231
70
|
}
|
|
232
71
|
),
|
|
233
72
|
children,
|
|
234
|
-
items.filter((item) => item.type !== "secondary").map((item, i) => /* @__PURE__ */
|
|
73
|
+
items.filter((item) => item.type !== "secondary").map((item, i) => /* @__PURE__ */ jsx(
|
|
235
74
|
LinkItem,
|
|
236
75
|
{
|
|
237
76
|
item,
|
|
@@ -239,34 +78,14 @@ function Nav({
|
|
|
239
78
|
},
|
|
240
79
|
i
|
|
241
80
|
)),
|
|
242
|
-
/* @__PURE__ */
|
|
243
|
-
enableSearch && search.enabled ? /* @__PURE__ */
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
buttonVariants({
|
|
251
|
-
size: "icon",
|
|
252
|
-
color: "ghost",
|
|
253
|
-
className: "group md:hidden"
|
|
254
|
-
})
|
|
255
|
-
),
|
|
256
|
-
children: [
|
|
257
|
-
/* @__PURE__ */ jsx3(MenuIcon, { className: "group-data-[open=true]:hidden" }),
|
|
258
|
-
/* @__PURE__ */ jsx3(X, { className: "hidden group-data-[open=true]:block" })
|
|
259
|
-
]
|
|
260
|
-
}
|
|
261
|
-
) : null,
|
|
262
|
-
/* @__PURE__ */ jsx3(
|
|
263
|
-
LinksMenu,
|
|
264
|
-
{
|
|
265
|
-
items,
|
|
266
|
-
className: twMerge("lg:hidden", enableSidebar && "max-md:hidden")
|
|
267
|
-
}
|
|
268
|
-
),
|
|
269
|
-
items.filter((item) => item.type === "secondary").map((item, i) => /* @__PURE__ */ jsx3(LinkItem, { item, className: "max-lg:hidden" }, i))
|
|
81
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-1 flex-row items-center justify-end md:gap-2", children: [
|
|
82
|
+
enableSearch && search.enabled ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
83
|
+
/* @__PURE__ */ jsx(SearchToggle, { className: "md:hidden" }),
|
|
84
|
+
/* @__PURE__ */ jsx(LargeSearchToggle, { className: "w-full max-w-[240px] max-md:hidden" })
|
|
85
|
+
] }) : null,
|
|
86
|
+
/* @__PURE__ */ jsx(ThemeToggle, { className: "max-lg:hidden" }),
|
|
87
|
+
/* @__PURE__ */ jsx(LinksMenu, { items, className: "lg:hidden" }),
|
|
88
|
+
items.filter((item) => item.type === "secondary").map((item, i) => /* @__PURE__ */ jsx(LinkItem, { item, className: "max-lg:hidden" }, i))
|
|
270
89
|
] })
|
|
271
90
|
] })
|
|
272
91
|
}
|
|
@@ -274,12 +93,13 @@ function Nav({
|
|
|
274
93
|
}
|
|
275
94
|
function LinksMenu({ items, ...props }) {
|
|
276
95
|
const [open, setOpen] = useState(false);
|
|
277
|
-
const
|
|
96
|
+
const { text } = useI18n();
|
|
97
|
+
const pathname = usePathname();
|
|
278
98
|
useEffect(() => {
|
|
279
99
|
setOpen(false);
|
|
280
100
|
}, [pathname]);
|
|
281
|
-
return /* @__PURE__ */
|
|
282
|
-
/* @__PURE__ */
|
|
101
|
+
return /* @__PURE__ */ jsxs(Popover, { open, onOpenChange: setOpen, children: [
|
|
102
|
+
/* @__PURE__ */ jsx(
|
|
283
103
|
PopoverTrigger,
|
|
284
104
|
{
|
|
285
105
|
...props,
|
|
@@ -290,366 +110,18 @@ function LinksMenu({ items, ...props }) {
|
|
|
290
110
|
className: props.className
|
|
291
111
|
})
|
|
292
112
|
),
|
|
293
|
-
children: /* @__PURE__ */
|
|
113
|
+
children: /* @__PURE__ */ jsx(MoreVertical, {})
|
|
294
114
|
}
|
|
295
115
|
),
|
|
296
|
-
/* @__PURE__ */
|
|
297
|
-
items.map((item, i) => /* @__PURE__ */
|
|
298
|
-
/* @__PURE__ */
|
|
299
|
-
/* @__PURE__ */
|
|
300
|
-
/* @__PURE__ */
|
|
116
|
+
/* @__PURE__ */ jsxs(PopoverContent, { className: "flex flex-col", children: [
|
|
117
|
+
items.map((item, i) => /* @__PURE__ */ jsx(LinkItem, { item, on: "menu" }, i)),
|
|
118
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-row items-center justify-between px-2 py-1", children: [
|
|
119
|
+
/* @__PURE__ */ jsx("p", { className: "font-medium text-muted-foreground", children: text.chooseTheme }),
|
|
120
|
+
/* @__PURE__ */ jsx(ThemeToggle, {})
|
|
301
121
|
] })
|
|
302
122
|
] })
|
|
303
123
|
] });
|
|
304
124
|
}
|
|
305
|
-
function SearchToggle() {
|
|
306
|
-
const { hotKey, setOpenSearch } = useSearchContext();
|
|
307
|
-
const { text } = useI18n();
|
|
308
|
-
const onClick = useCallback2(() => {
|
|
309
|
-
setOpenSearch(true);
|
|
310
|
-
}, [setOpenSearch]);
|
|
311
|
-
return /* @__PURE__ */ jsxs3(Fragment, { children: [
|
|
312
|
-
/* @__PURE__ */ jsx3(
|
|
313
|
-
"button",
|
|
314
|
-
{
|
|
315
|
-
type: "button",
|
|
316
|
-
className: twMerge(
|
|
317
|
-
buttonVariants({
|
|
318
|
-
size: "icon",
|
|
319
|
-
color: "ghost",
|
|
320
|
-
className: "md:hidden"
|
|
321
|
-
})
|
|
322
|
-
),
|
|
323
|
-
"aria-label": "Open Search",
|
|
324
|
-
onClick,
|
|
325
|
-
children: /* @__PURE__ */ jsx3(SearchIcon, {})
|
|
326
|
-
}
|
|
327
|
-
),
|
|
328
|
-
/* @__PURE__ */ jsxs3(
|
|
329
|
-
"button",
|
|
330
|
-
{
|
|
331
|
-
type: "button",
|
|
332
|
-
className: "inline-flex w-full max-w-[240px] items-center gap-2 rounded-full border bg-secondary/50 p-1.5 text-sm text-muted-foreground transition-colors hover:bg-accent hover:text-accent-foreground max-md:hidden",
|
|
333
|
-
onClick,
|
|
334
|
-
children: [
|
|
335
|
-
/* @__PURE__ */ jsx3(SearchIcon, { className: "ms-1 size-4" }),
|
|
336
|
-
text.search,
|
|
337
|
-
/* @__PURE__ */ jsx3("div", { className: "ms-auto inline-flex gap-0.5 text-xs", children: hotKey.map((k, i) => /* @__PURE__ */ jsx3("kbd", { className: "rounded-md border bg-background px-1.5", children: k.display }, i)) })
|
|
338
|
-
]
|
|
339
|
-
}
|
|
340
|
-
)
|
|
341
|
-
] });
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
// src/components/sidebar.tsx
|
|
345
|
-
import { cva as cva3 } from "class-variance-authority";
|
|
346
|
-
import { ChevronDown as ChevronDown2, ExternalLinkIcon } from "lucide-react";
|
|
347
|
-
import * as Base from "fumadocs-core/sidebar";
|
|
348
|
-
import { usePathname as usePathname3 } from "next/navigation";
|
|
349
|
-
import {
|
|
350
|
-
createContext,
|
|
351
|
-
useCallback as useCallback3,
|
|
352
|
-
useContext,
|
|
353
|
-
useEffect as useEffect2,
|
|
354
|
-
useMemo,
|
|
355
|
-
useState as useState2
|
|
356
|
-
} from "react";
|
|
357
|
-
import Link3 from "fumadocs-core/link";
|
|
358
|
-
import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
359
|
-
var itemVariants = cva3(
|
|
360
|
-
"flex w-full flex-row items-center gap-2 rounded-md px-2 py-1.5 text-muted-foreground transition-colors duration-100 [&_svg]:size-4",
|
|
361
|
-
{
|
|
362
|
-
variants: {
|
|
363
|
-
active: {
|
|
364
|
-
true: "bg-primary/10 font-medium text-primary",
|
|
365
|
-
false: "hover:bg-accent/50 hover:text-accent-foreground/80 hover:transition-none"
|
|
366
|
-
}
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
);
|
|
370
|
-
var defaultComponents = {
|
|
371
|
-
Folder: FolderNode,
|
|
372
|
-
Separator: SeparatorNode,
|
|
373
|
-
Item: PageNode
|
|
374
|
-
};
|
|
375
|
-
var SidebarContext = createContext({
|
|
376
|
-
defaultOpenLevel: 1,
|
|
377
|
-
components: defaultComponents
|
|
378
|
-
});
|
|
379
|
-
function Sidebar({
|
|
380
|
-
footer,
|
|
381
|
-
components,
|
|
382
|
-
defaultOpenLevel = 1,
|
|
383
|
-
banner,
|
|
384
|
-
items,
|
|
385
|
-
...props
|
|
386
|
-
}) {
|
|
387
|
-
const alwaysShowFooter = Boolean(footer);
|
|
388
|
-
const context = useMemo(
|
|
389
|
-
() => ({
|
|
390
|
-
defaultOpenLevel,
|
|
391
|
-
components: { ...defaultComponents, ...components }
|
|
392
|
-
}),
|
|
393
|
-
[components, defaultOpenLevel]
|
|
394
|
-
);
|
|
395
|
-
return /* @__PURE__ */ jsx4(SidebarContext.Provider, { value: context, children: /* @__PURE__ */ jsxs4(
|
|
396
|
-
Base.SidebarList,
|
|
397
|
-
{
|
|
398
|
-
blockScrollingWidth: 768,
|
|
399
|
-
className: twMerge(
|
|
400
|
-
"flex w-full flex-col text-[15px] md:sticky md:top-16 md:h-body md:w-[240px] md:text-sm xl:w-[260px]",
|
|
401
|
-
"max-md:fixed max-md:inset-0 max-md:z-40 max-md:pt-16 max-md:data-[open=false]:hidden",
|
|
402
|
-
props.className
|
|
403
|
-
),
|
|
404
|
-
children: [
|
|
405
|
-
/* @__PURE__ */ jsx4(
|
|
406
|
-
"div",
|
|
407
|
-
{
|
|
408
|
-
id: "sidebar-background",
|
|
409
|
-
className: "absolute z-[-1] size-full max-md:bg-background/80 max-md:backdrop-blur-md"
|
|
410
|
-
}
|
|
411
|
-
),
|
|
412
|
-
/* @__PURE__ */ jsxs4(ViewportContent, { children: [
|
|
413
|
-
banner,
|
|
414
|
-
items.length > 0 && /* @__PURE__ */ jsx4("div", { className: "flex flex-col md:hidden", children: items.map((item, i) => /* @__PURE__ */ jsx4(LinkItem, { item, on: "menu" }, i)) })
|
|
415
|
-
] }),
|
|
416
|
-
/* @__PURE__ */ jsxs4(
|
|
417
|
-
"div",
|
|
418
|
-
{
|
|
419
|
-
className: twMerge(
|
|
420
|
-
"flex flex-row items-center gap-2 border-t p-3 md:p-2",
|
|
421
|
-
!alwaysShowFooter && "md:hidden"
|
|
422
|
-
),
|
|
423
|
-
children: [
|
|
424
|
-
footer,
|
|
425
|
-
/* @__PURE__ */ jsx4(ThemeToggle, { className: "md:hidden" })
|
|
426
|
-
]
|
|
427
|
-
}
|
|
428
|
-
)
|
|
429
|
-
]
|
|
430
|
-
}
|
|
431
|
-
) });
|
|
432
|
-
}
|
|
433
|
-
function ViewportContent({
|
|
434
|
-
children
|
|
435
|
-
}) {
|
|
436
|
-
const { root } = useTreeContext();
|
|
437
|
-
return /* @__PURE__ */ jsx4(ScrollArea, { className: "flex-1", children: /* @__PURE__ */ jsx4(ScrollViewport, { children: /* @__PURE__ */ jsxs4("div", { className: "flex flex-col gap-8 p-4 pb-10 md:px-3 md:pt-10", children: [
|
|
438
|
-
children,
|
|
439
|
-
/* @__PURE__ */ jsx4(NodeList, { items: root.children })
|
|
440
|
-
] }) }) });
|
|
441
|
-
}
|
|
442
|
-
function NodeList({
|
|
443
|
-
items,
|
|
444
|
-
level = 0,
|
|
445
|
-
...props
|
|
446
|
-
}) {
|
|
447
|
-
const { components } = useContext(SidebarContext);
|
|
448
|
-
return /* @__PURE__ */ jsx4("div", { ...props, children: items.map((item) => {
|
|
449
|
-
const id = `${item.type}_${item.name}`;
|
|
450
|
-
switch (item.type) {
|
|
451
|
-
case "separator":
|
|
452
|
-
return /* @__PURE__ */ jsx4(components.Separator, { item }, id);
|
|
453
|
-
case "folder":
|
|
454
|
-
return /* @__PURE__ */ jsx4(components.Folder, { item, level: level + 1 }, id);
|
|
455
|
-
default:
|
|
456
|
-
return /* @__PURE__ */ jsx4(components.Item, { item }, item.url);
|
|
457
|
-
}
|
|
458
|
-
}) });
|
|
459
|
-
}
|
|
460
|
-
function PageNode({
|
|
461
|
-
item: { icon, external = false, url, name },
|
|
462
|
-
nested = false
|
|
463
|
-
}) {
|
|
464
|
-
const pathname = usePathname3();
|
|
465
|
-
const active = isActive(url, pathname, nested);
|
|
466
|
-
return /* @__PURE__ */ jsxs4(
|
|
467
|
-
Link3,
|
|
468
|
-
{
|
|
469
|
-
href: url,
|
|
470
|
-
external,
|
|
471
|
-
className: twMerge(itemVariants({ active })),
|
|
472
|
-
children: [
|
|
473
|
-
icon ?? (external ? /* @__PURE__ */ jsx4(ExternalLinkIcon, {}) : null),
|
|
474
|
-
name
|
|
475
|
-
]
|
|
476
|
-
}
|
|
477
|
-
);
|
|
478
|
-
}
|
|
479
|
-
function FolderNode({
|
|
480
|
-
item: { name, children, index, icon, defaultOpen = false },
|
|
481
|
-
level
|
|
482
|
-
}) {
|
|
483
|
-
const { defaultOpenLevel } = useContext(SidebarContext);
|
|
484
|
-
const pathname = usePathname3();
|
|
485
|
-
const active = index !== void 0 && isActive(index.url, pathname, false);
|
|
486
|
-
const childActive = useMemo(
|
|
487
|
-
() => hasActive(children, pathname),
|
|
488
|
-
[children, pathname]
|
|
489
|
-
);
|
|
490
|
-
const shouldExtend = active || childActive || defaultOpenLevel >= level || defaultOpen;
|
|
491
|
-
const [extend, setExtend] = useState2(shouldExtend);
|
|
492
|
-
useEffect2(() => {
|
|
493
|
-
if (shouldExtend) setExtend(true);
|
|
494
|
-
}, [shouldExtend]);
|
|
495
|
-
const onClick = useCallback3(
|
|
496
|
-
(e) => {
|
|
497
|
-
if (e.target !== e.currentTarget || active) {
|
|
498
|
-
setExtend((prev) => !prev);
|
|
499
|
-
e.preventDefault();
|
|
500
|
-
}
|
|
501
|
-
},
|
|
502
|
-
[active]
|
|
503
|
-
);
|
|
504
|
-
return /* @__PURE__ */ jsxs4(Collapsible, { open: extend, onOpenChange: setExtend, children: [
|
|
505
|
-
index ? /* @__PURE__ */ jsxs4(
|
|
506
|
-
Link3,
|
|
507
|
-
{
|
|
508
|
-
className: twMerge(itemVariants({ active })),
|
|
509
|
-
href: index.url,
|
|
510
|
-
onClick,
|
|
511
|
-
children: [
|
|
512
|
-
icon,
|
|
513
|
-
name,
|
|
514
|
-
/* @__PURE__ */ jsx4(
|
|
515
|
-
ChevronDown2,
|
|
516
|
-
{
|
|
517
|
-
className: twMerge(
|
|
518
|
-
"ms-auto transition-transform",
|
|
519
|
-
!extend && "-rotate-90"
|
|
520
|
-
)
|
|
521
|
-
}
|
|
522
|
-
)
|
|
523
|
-
]
|
|
524
|
-
}
|
|
525
|
-
) : /* @__PURE__ */ jsxs4(CollapsibleTrigger, { className: twMerge(itemVariants({ active })), children: [
|
|
526
|
-
icon,
|
|
527
|
-
name,
|
|
528
|
-
/* @__PURE__ */ jsx4(
|
|
529
|
-
ChevronDown2,
|
|
530
|
-
{
|
|
531
|
-
className: twMerge(
|
|
532
|
-
"ms-auto transition-transform",
|
|
533
|
-
!extend && "-rotate-90"
|
|
534
|
-
)
|
|
535
|
-
}
|
|
536
|
-
)
|
|
537
|
-
] }),
|
|
538
|
-
/* @__PURE__ */ jsx4(CollapsibleContent, { children: /* @__PURE__ */ jsx4(
|
|
539
|
-
NodeList,
|
|
540
|
-
{
|
|
541
|
-
className: "ms-2 flex flex-col border-s py-2 ps-2",
|
|
542
|
-
items: children,
|
|
543
|
-
level
|
|
544
|
-
}
|
|
545
|
-
) })
|
|
546
|
-
] });
|
|
547
|
-
}
|
|
548
|
-
function SeparatorNode({
|
|
549
|
-
item
|
|
550
|
-
}) {
|
|
551
|
-
return /* @__PURE__ */ jsx4("p", { className: "mb-2 mt-8 px-2 font-medium first:mt-0", children: item.name });
|
|
552
|
-
}
|
|
553
|
-
|
|
554
|
-
// src/components/dynamic-sidebar.tsx
|
|
555
|
-
import { useCallback as useCallback4, useRef, useState as useState3 } from "react";
|
|
556
|
-
import { SidebarIcon } from "lucide-react";
|
|
557
|
-
import { Fragment as Fragment2, jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
558
|
-
function DynamicSidebar(props) {
|
|
559
|
-
const { collapsed, setCollapsed } = useSidebar();
|
|
560
|
-
const [hover, setHover] = useState3(false);
|
|
561
|
-
const timerRef = useRef(0);
|
|
562
|
-
const onCollapse = useCallback4(() => {
|
|
563
|
-
setCollapsed(!collapsed);
|
|
564
|
-
}, [collapsed, setCollapsed]);
|
|
565
|
-
const onHover = useCallback4((e) => {
|
|
566
|
-
if (e.pointerType === "touch") return;
|
|
567
|
-
window.clearTimeout(timerRef.current);
|
|
568
|
-
setHover(true);
|
|
569
|
-
}, []);
|
|
570
|
-
const onLeave = useCallback4((e) => {
|
|
571
|
-
if (e.pointerType === "touch") return;
|
|
572
|
-
window.clearTimeout(timerRef.current);
|
|
573
|
-
timerRef.current = window.setTimeout(() => {
|
|
574
|
-
setHover(false);
|
|
575
|
-
}, 300);
|
|
576
|
-
}, []);
|
|
577
|
-
return /* @__PURE__ */ jsxs5(Fragment2, { children: [
|
|
578
|
-
collapsed ? /* @__PURE__ */ jsx5(
|
|
579
|
-
"div",
|
|
580
|
-
{
|
|
581
|
-
className: "fixed bottom-0 start-0 top-16 max-md:hidden",
|
|
582
|
-
onPointerEnter: onHover,
|
|
583
|
-
onPointerLeave: onLeave,
|
|
584
|
-
style: {
|
|
585
|
-
maxWidth: "240px",
|
|
586
|
-
width: "calc(max(0px, 100vw - 1400px)/2)",
|
|
587
|
-
minWidth: "1rem"
|
|
588
|
-
}
|
|
589
|
-
}
|
|
590
|
-
) : null,
|
|
591
|
-
collapsed ? /* @__PURE__ */ jsx5(
|
|
592
|
-
"button",
|
|
593
|
-
{
|
|
594
|
-
type: "button",
|
|
595
|
-
"aria-label": "Collapse Sidebar",
|
|
596
|
-
className: twMerge(
|
|
597
|
-
buttonVariants({
|
|
598
|
-
color: "secondary",
|
|
599
|
-
size: "icon",
|
|
600
|
-
className: "fixed start-4 bottom-4 z-10 max-md:hidden"
|
|
601
|
-
})
|
|
602
|
-
),
|
|
603
|
-
onClick: onCollapse,
|
|
604
|
-
children: /* @__PURE__ */ jsx5(SidebarIcon, {})
|
|
605
|
-
}
|
|
606
|
-
) : null,
|
|
607
|
-
/* @__PURE__ */ jsx5(
|
|
608
|
-
"div",
|
|
609
|
-
{
|
|
610
|
-
id: "dynamic-sidebar",
|
|
611
|
-
"data-open": !collapsed,
|
|
612
|
-
"data-hover": hover,
|
|
613
|
-
onPointerEnter: onHover,
|
|
614
|
-
onPointerLeave: onLeave,
|
|
615
|
-
"aria-hidden": Boolean(collapsed && !hover),
|
|
616
|
-
className: twMerge(
|
|
617
|
-
"z-40 transition-transform max-md:absolute",
|
|
618
|
-
collapsed && "md:fixed md:bottom-2 md:start-2 md:top-16 md:overflow-hidden md:rounded-xl md:border md:bg-background md:shadow-md"
|
|
619
|
-
),
|
|
620
|
-
children: /* @__PURE__ */ jsx5(
|
|
621
|
-
Sidebar,
|
|
622
|
-
{
|
|
623
|
-
...props,
|
|
624
|
-
className: twMerge(collapsed && "md:h-full"),
|
|
625
|
-
footer: /* @__PURE__ */ jsxs5(Fragment2, { children: [
|
|
626
|
-
props.footer,
|
|
627
|
-
/* @__PURE__ */ jsx5(
|
|
628
|
-
"button",
|
|
629
|
-
{
|
|
630
|
-
type: "button",
|
|
631
|
-
"aria-label": "Collapse Sidebar",
|
|
632
|
-
className: twMerge(
|
|
633
|
-
buttonVariants({
|
|
634
|
-
color: "ghost",
|
|
635
|
-
size: "icon",
|
|
636
|
-
className: "max-md:hidden ms-auto"
|
|
637
|
-
})
|
|
638
|
-
),
|
|
639
|
-
onClick: onCollapse,
|
|
640
|
-
children: /* @__PURE__ */ jsx5(SidebarIcon, {})
|
|
641
|
-
}
|
|
642
|
-
)
|
|
643
|
-
] })
|
|
644
|
-
}
|
|
645
|
-
)
|
|
646
|
-
}
|
|
647
|
-
)
|
|
648
|
-
] });
|
|
649
|
-
}
|
|
650
125
|
export {
|
|
651
|
-
|
|
652
|
-
Nav,
|
|
653
|
-
Sidebar,
|
|
654
|
-
TreeContextProvider
|
|
126
|
+
Nav
|
|
655
127
|
};
|
package/dist/layout.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import 'fumadocs-core/server';
|
|
2
2
|
import 'react';
|
|
3
|
-
export { B as BaseLayoutProps, c as DocsLayout, D as DocsLayoutProps, b as Layout, L as LinkItemType } from './layout-
|
|
3
|
+
export { B as BaseLayoutProps, c as DocsLayout, D as DocsLayoutProps, b as Layout, L as LinkItemType } from './layout.client-Duq0TTke.js';
|