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
|
@@ -0,0 +1,396 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
LargeSearchToggle,
|
|
4
|
+
LinkItem,
|
|
5
|
+
SearchToggle,
|
|
6
|
+
ThemeToggle
|
|
7
|
+
} from "./chunk-JQW5DMD2.js";
|
|
8
|
+
import {
|
|
9
|
+
TreeContextProvider,
|
|
10
|
+
useTreeContext
|
|
11
|
+
} from "./chunk-34Z7WODD.js";
|
|
12
|
+
import {
|
|
13
|
+
ScrollArea,
|
|
14
|
+
ScrollViewport
|
|
15
|
+
} from "./chunk-VYTHQTZE.js";
|
|
16
|
+
import "./chunk-UBVEKNRF.js";
|
|
17
|
+
import {
|
|
18
|
+
hasActive,
|
|
19
|
+
isActive
|
|
20
|
+
} from "./chunk-AN2Y6MA2.js";
|
|
21
|
+
import {
|
|
22
|
+
useSidebar
|
|
23
|
+
} from "./chunk-3F57TIUQ.js";
|
|
24
|
+
import {
|
|
25
|
+
useSearchContext
|
|
26
|
+
} from "./chunk-FSPYEOFC.js";
|
|
27
|
+
import "./chunk-CRYPD6UZ.js";
|
|
28
|
+
import {
|
|
29
|
+
Collapsible,
|
|
30
|
+
CollapsibleContent,
|
|
31
|
+
CollapsibleTrigger
|
|
32
|
+
} from "./chunk-7XPZOMJ2.js";
|
|
33
|
+
import {
|
|
34
|
+
buttonVariants
|
|
35
|
+
} from "./chunk-7GZKFBAP.js";
|
|
36
|
+
import {
|
|
37
|
+
twMerge
|
|
38
|
+
} from "./chunk-TK3TM3MR.js";
|
|
39
|
+
import "./chunk-MLKGABMK.js";
|
|
40
|
+
|
|
41
|
+
// src/docs.client.tsx
|
|
42
|
+
import Link2 from "next/link";
|
|
43
|
+
import { SidebarTrigger } from "fumadocs-core/sidebar";
|
|
44
|
+
import { Menu, X } from "lucide-react";
|
|
45
|
+
|
|
46
|
+
// src/components/layout/sidebar.tsx
|
|
47
|
+
import { cva } from "class-variance-authority";
|
|
48
|
+
import { ChevronDown, ExternalLinkIcon } from "lucide-react";
|
|
49
|
+
import * as Base from "fumadocs-core/sidebar";
|
|
50
|
+
import { usePathname } from "next/navigation";
|
|
51
|
+
import {
|
|
52
|
+
createContext,
|
|
53
|
+
useCallback,
|
|
54
|
+
useContext,
|
|
55
|
+
useEffect,
|
|
56
|
+
useMemo,
|
|
57
|
+
useState
|
|
58
|
+
} from "react";
|
|
59
|
+
import Link from "fumadocs-core/link";
|
|
60
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
61
|
+
var itemVariants = cva(
|
|
62
|
+
"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",
|
|
63
|
+
{
|
|
64
|
+
variants: {
|
|
65
|
+
active: {
|
|
66
|
+
true: "bg-primary/10 font-medium text-primary",
|
|
67
|
+
false: "hover:bg-accent/50 hover:text-accent-foreground/80 hover:transition-none"
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
);
|
|
72
|
+
var defaultComponents = {
|
|
73
|
+
Folder: FolderNode,
|
|
74
|
+
Separator: SeparatorNode,
|
|
75
|
+
Item: PageNode
|
|
76
|
+
};
|
|
77
|
+
var Context = createContext({
|
|
78
|
+
defaultOpenLevel: 1,
|
|
79
|
+
components: defaultComponents
|
|
80
|
+
});
|
|
81
|
+
function Sidebar({
|
|
82
|
+
footer,
|
|
83
|
+
components,
|
|
84
|
+
defaultOpenLevel = 1,
|
|
85
|
+
banner,
|
|
86
|
+
items,
|
|
87
|
+
aside,
|
|
88
|
+
bannerProps,
|
|
89
|
+
footerProps
|
|
90
|
+
}) {
|
|
91
|
+
const context = useMemo(
|
|
92
|
+
() => ({
|
|
93
|
+
defaultOpenLevel,
|
|
94
|
+
components: { ...defaultComponents, ...components }
|
|
95
|
+
}),
|
|
96
|
+
[components, defaultOpenLevel]
|
|
97
|
+
);
|
|
98
|
+
return /* @__PURE__ */ jsx(Context.Provider, { value: context, children: /* @__PURE__ */ jsxs(
|
|
99
|
+
Base.SidebarList,
|
|
100
|
+
{
|
|
101
|
+
id: "nd-sidebar",
|
|
102
|
+
blockScrollingWidth: 768,
|
|
103
|
+
...aside,
|
|
104
|
+
className: twMerge(
|
|
105
|
+
"z-30 flex w-full flex-col text-[15px] md:sticky md:top-0 md:h-dvh md:w-[240px] md:border-e md:bg-card md:text-sm xl:w-[260px]",
|
|
106
|
+
"max-md:fixed max-md:inset-0 max-md:bg-background/80 max-md:pt-16 max-md:backdrop-blur-md max-md:data-[open=false]:hidden",
|
|
107
|
+
aside?.className
|
|
108
|
+
),
|
|
109
|
+
children: [
|
|
110
|
+
/* @__PURE__ */ jsxs(
|
|
111
|
+
"div",
|
|
112
|
+
{
|
|
113
|
+
...bannerProps,
|
|
114
|
+
className: twMerge(
|
|
115
|
+
"flex flex-col gap-2 border-b px-4 py-2 md:p-3 md:pt-10",
|
|
116
|
+
bannerProps?.className
|
|
117
|
+
),
|
|
118
|
+
children: [
|
|
119
|
+
banner,
|
|
120
|
+
/* @__PURE__ */ jsx(LargeSearchToggle, { className: "rounded-lg max-md:hidden" })
|
|
121
|
+
]
|
|
122
|
+
}
|
|
123
|
+
),
|
|
124
|
+
/* @__PURE__ */ jsx(ViewportContent, { children: items.length > 0 && /* @__PURE__ */ jsx("div", { className: "flex flex-col", children: items.map((item, i) => /* @__PURE__ */ jsx(LinkItem, { item, on: "menu" }, i)) }) }),
|
|
125
|
+
/* @__PURE__ */ jsx(
|
|
126
|
+
"div",
|
|
127
|
+
{
|
|
128
|
+
...footerProps,
|
|
129
|
+
className: twMerge(
|
|
130
|
+
"flex flex-row items-center border-t px-4 py-2 md:px-3",
|
|
131
|
+
footerProps?.className
|
|
132
|
+
),
|
|
133
|
+
children: footer
|
|
134
|
+
}
|
|
135
|
+
)
|
|
136
|
+
]
|
|
137
|
+
}
|
|
138
|
+
) });
|
|
139
|
+
}
|
|
140
|
+
function ViewportContent({
|
|
141
|
+
children
|
|
142
|
+
}) {
|
|
143
|
+
const { root } = useTreeContext();
|
|
144
|
+
return /* @__PURE__ */ jsx(ScrollArea, { className: "flex-1", children: /* @__PURE__ */ jsx(ScrollViewport, { children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-8 p-4 pb-10 md:px-3", children: [
|
|
145
|
+
children,
|
|
146
|
+
/* @__PURE__ */ jsx(NodeList, { items: root.children })
|
|
147
|
+
] }) }) });
|
|
148
|
+
}
|
|
149
|
+
function NodeList({
|
|
150
|
+
items,
|
|
151
|
+
level = 0,
|
|
152
|
+
...props
|
|
153
|
+
}) {
|
|
154
|
+
const { components } = useContext(Context);
|
|
155
|
+
return /* @__PURE__ */ jsx("div", { ...props, children: items.map((item) => {
|
|
156
|
+
const id = `${item.type}_${item.name}`;
|
|
157
|
+
switch (item.type) {
|
|
158
|
+
case "separator":
|
|
159
|
+
return /* @__PURE__ */ jsx(components.Separator, { item }, id);
|
|
160
|
+
case "folder":
|
|
161
|
+
return /* @__PURE__ */ jsx(components.Folder, { item, level: level + 1 }, id);
|
|
162
|
+
default:
|
|
163
|
+
return /* @__PURE__ */ jsx(components.Item, { item }, item.url);
|
|
164
|
+
}
|
|
165
|
+
}) });
|
|
166
|
+
}
|
|
167
|
+
function PageNode({
|
|
168
|
+
item: { icon, external = false, url, name }
|
|
169
|
+
}) {
|
|
170
|
+
const pathname = usePathname();
|
|
171
|
+
const { closeOnRedirect } = useSidebar();
|
|
172
|
+
const active = isActive(url, pathname, false);
|
|
173
|
+
return /* @__PURE__ */ jsxs(
|
|
174
|
+
Link,
|
|
175
|
+
{
|
|
176
|
+
href: url,
|
|
177
|
+
external,
|
|
178
|
+
className: twMerge(itemVariants({ active })),
|
|
179
|
+
onClick: useCallback(() => {
|
|
180
|
+
closeOnRedirect.current = !active;
|
|
181
|
+
}, [closeOnRedirect, active]),
|
|
182
|
+
children: [
|
|
183
|
+
icon ?? (external ? /* @__PURE__ */ jsx(ExternalLinkIcon, {}) : null),
|
|
184
|
+
name
|
|
185
|
+
]
|
|
186
|
+
}
|
|
187
|
+
);
|
|
188
|
+
}
|
|
189
|
+
function FolderNode({
|
|
190
|
+
item: { name, children, index, icon, defaultOpen = false },
|
|
191
|
+
level
|
|
192
|
+
}) {
|
|
193
|
+
const { defaultOpenLevel } = useContext(Context);
|
|
194
|
+
const { closeOnRedirect } = useSidebar();
|
|
195
|
+
const pathname = usePathname();
|
|
196
|
+
const active = index !== void 0 && isActive(index.url, pathname, false);
|
|
197
|
+
const childActive = useMemo(
|
|
198
|
+
() => hasActive(children, pathname),
|
|
199
|
+
[children, pathname]
|
|
200
|
+
);
|
|
201
|
+
const shouldExtend = active || childActive || defaultOpenLevel >= level || defaultOpen;
|
|
202
|
+
const [extend, setExtend] = useState(shouldExtend);
|
|
203
|
+
useEffect(() => {
|
|
204
|
+
if (shouldExtend) setExtend(true);
|
|
205
|
+
}, [shouldExtend]);
|
|
206
|
+
const onClick = useCallback(
|
|
207
|
+
(e) => {
|
|
208
|
+
if (e.target !== e.currentTarget || active) {
|
|
209
|
+
setExtend((prev) => !prev);
|
|
210
|
+
e.preventDefault();
|
|
211
|
+
} else {
|
|
212
|
+
closeOnRedirect.current = !active;
|
|
213
|
+
}
|
|
214
|
+
},
|
|
215
|
+
[closeOnRedirect, active]
|
|
216
|
+
);
|
|
217
|
+
return /* @__PURE__ */ jsxs(Collapsible, { open: extend, onOpenChange: setExtend, children: [
|
|
218
|
+
index ? /* @__PURE__ */ jsxs(
|
|
219
|
+
Link,
|
|
220
|
+
{
|
|
221
|
+
className: twMerge(itemVariants({ active })),
|
|
222
|
+
href: index.url,
|
|
223
|
+
onClick,
|
|
224
|
+
children: [
|
|
225
|
+
icon,
|
|
226
|
+
name,
|
|
227
|
+
/* @__PURE__ */ jsx(
|
|
228
|
+
ChevronDown,
|
|
229
|
+
{
|
|
230
|
+
className: twMerge(
|
|
231
|
+
"ms-auto transition-transform",
|
|
232
|
+
!extend && "-rotate-90"
|
|
233
|
+
)
|
|
234
|
+
}
|
|
235
|
+
)
|
|
236
|
+
]
|
|
237
|
+
}
|
|
238
|
+
) : /* @__PURE__ */ jsxs(CollapsibleTrigger, { className: twMerge(itemVariants({ active })), children: [
|
|
239
|
+
icon,
|
|
240
|
+
name,
|
|
241
|
+
/* @__PURE__ */ jsx(
|
|
242
|
+
ChevronDown,
|
|
243
|
+
{
|
|
244
|
+
className: twMerge(
|
|
245
|
+
"ms-auto transition-transform",
|
|
246
|
+
!extend && "-rotate-90"
|
|
247
|
+
)
|
|
248
|
+
}
|
|
249
|
+
)
|
|
250
|
+
] }),
|
|
251
|
+
/* @__PURE__ */ jsx(CollapsibleContent, { children: /* @__PURE__ */ jsx(
|
|
252
|
+
NodeList,
|
|
253
|
+
{
|
|
254
|
+
className: "ms-2 flex flex-col border-s py-2 ps-2",
|
|
255
|
+
items: children,
|
|
256
|
+
level
|
|
257
|
+
}
|
|
258
|
+
) })
|
|
259
|
+
] });
|
|
260
|
+
}
|
|
261
|
+
function SeparatorNode({
|
|
262
|
+
item
|
|
263
|
+
}) {
|
|
264
|
+
return /* @__PURE__ */ jsx("p", { className: "mb-2 mt-8 px-2 font-medium first:mt-0", children: item.name });
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
// src/components/layout/dynamic-sidebar.tsx
|
|
268
|
+
import { useCallback as useCallback2, useRef, useState as useState2 } from "react";
|
|
269
|
+
import { SidebarIcon } from "lucide-react";
|
|
270
|
+
import { Fragment, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
271
|
+
function DynamicSidebar(props) {
|
|
272
|
+
const { collapsed, setCollapsed } = useSidebar();
|
|
273
|
+
const [hover, setHover] = useState2(false);
|
|
274
|
+
const timerRef = useRef(0);
|
|
275
|
+
const onCollapse = useCallback2(() => {
|
|
276
|
+
setCollapsed(!collapsed);
|
|
277
|
+
}, [collapsed, setCollapsed]);
|
|
278
|
+
const onHover = useCallback2((e) => {
|
|
279
|
+
if (e.pointerType === "touch") return;
|
|
280
|
+
window.clearTimeout(timerRef.current);
|
|
281
|
+
setHover(true);
|
|
282
|
+
}, []);
|
|
283
|
+
const onLeave = useCallback2((e) => {
|
|
284
|
+
if (e.pointerType === "touch") return;
|
|
285
|
+
window.clearTimeout(timerRef.current);
|
|
286
|
+
timerRef.current = window.setTimeout(() => {
|
|
287
|
+
setHover(false);
|
|
288
|
+
}, 300);
|
|
289
|
+
}, []);
|
|
290
|
+
return /* @__PURE__ */ jsxs2(Fragment, { children: [
|
|
291
|
+
collapsed ? /* @__PURE__ */ jsx2(
|
|
292
|
+
"div",
|
|
293
|
+
{
|
|
294
|
+
className: "fixed inset-y-0 start-0 w-4 max-md:hidden xl:static xl:w-[260px]",
|
|
295
|
+
onPointerEnter: onHover,
|
|
296
|
+
onPointerLeave: onLeave
|
|
297
|
+
}
|
|
298
|
+
) : null,
|
|
299
|
+
collapsed ? /* @__PURE__ */ jsx2(
|
|
300
|
+
"button",
|
|
301
|
+
{
|
|
302
|
+
type: "button",
|
|
303
|
+
"aria-label": "Collapse Sidebar",
|
|
304
|
+
className: twMerge(
|
|
305
|
+
buttonVariants({
|
|
306
|
+
color: "secondary",
|
|
307
|
+
size: "icon",
|
|
308
|
+
className: "fixed start-4 bottom-4 z-10 max-md:hidden"
|
|
309
|
+
})
|
|
310
|
+
),
|
|
311
|
+
onClick: onCollapse,
|
|
312
|
+
children: /* @__PURE__ */ jsx2(SidebarIcon, {})
|
|
313
|
+
}
|
|
314
|
+
) : null,
|
|
315
|
+
/* @__PURE__ */ jsx2(
|
|
316
|
+
Sidebar,
|
|
317
|
+
{
|
|
318
|
+
...props,
|
|
319
|
+
aside: {
|
|
320
|
+
"data-collapse": collapsed,
|
|
321
|
+
"data-hover": hover,
|
|
322
|
+
onPointerEnter: onHover,
|
|
323
|
+
onPointerLeave: onLeave,
|
|
324
|
+
"aria-hidden": Boolean(collapsed && !hover),
|
|
325
|
+
className: twMerge(
|
|
326
|
+
"overflow-hidden md:transition-transform",
|
|
327
|
+
collapsed && "md:fixed md:inset-y-2 md:start-2 md:h-auto md:rounded-xl md:border md:shadow-md"
|
|
328
|
+
)
|
|
329
|
+
},
|
|
330
|
+
footer: /* @__PURE__ */ jsxs2(Fragment, { children: [
|
|
331
|
+
props.footer,
|
|
332
|
+
/* @__PURE__ */ jsx2(
|
|
333
|
+
"button",
|
|
334
|
+
{
|
|
335
|
+
type: "button",
|
|
336
|
+
"aria-label": "Collapse Sidebar",
|
|
337
|
+
className: twMerge(
|
|
338
|
+
buttonVariants({
|
|
339
|
+
color: "ghost",
|
|
340
|
+
size: "icon",
|
|
341
|
+
className: "max-md:hidden"
|
|
342
|
+
})
|
|
343
|
+
),
|
|
344
|
+
onClick: onCollapse,
|
|
345
|
+
children: /* @__PURE__ */ jsx2(SidebarIcon, {})
|
|
346
|
+
}
|
|
347
|
+
)
|
|
348
|
+
] })
|
|
349
|
+
}
|
|
350
|
+
)
|
|
351
|
+
] });
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
// src/docs.client.tsx
|
|
355
|
+
import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
356
|
+
function SubNav({
|
|
357
|
+
title,
|
|
358
|
+
url = "/",
|
|
359
|
+
children,
|
|
360
|
+
enableSearch = true
|
|
361
|
+
}) {
|
|
362
|
+
const { open } = useSidebar();
|
|
363
|
+
const { enabled } = useSearchContext();
|
|
364
|
+
return /* @__PURE__ */ jsxs3(
|
|
365
|
+
"nav",
|
|
366
|
+
{
|
|
367
|
+
id: "nd-subnav",
|
|
368
|
+
className: "sticky top-0 z-40 flex h-16 w-full flex-row items-center border-b bg-background/50 px-4 backdrop-blur-md md:hidden [&_svg]:size-5",
|
|
369
|
+
children: [
|
|
370
|
+
/* @__PURE__ */ jsx3(Link2, { href: url, className: "inline-flex items-center gap-3 font-semibold", children: title }),
|
|
371
|
+
children,
|
|
372
|
+
enabled && enableSearch ? /* @__PURE__ */ jsx3(SearchToggle, { className: "ml-auto" }) : null,
|
|
373
|
+
/* @__PURE__ */ jsx3(
|
|
374
|
+
SidebarTrigger,
|
|
375
|
+
{
|
|
376
|
+
className: twMerge(
|
|
377
|
+
buttonVariants({
|
|
378
|
+
color: "ghost",
|
|
379
|
+
size: "icon",
|
|
380
|
+
className: (!enabled || !enableSearch) && "ml-auto"
|
|
381
|
+
})
|
|
382
|
+
),
|
|
383
|
+
children: open ? /* @__PURE__ */ jsx3(X, {}) : /* @__PURE__ */ jsx3(Menu, {})
|
|
384
|
+
}
|
|
385
|
+
)
|
|
386
|
+
]
|
|
387
|
+
}
|
|
388
|
+
);
|
|
389
|
+
}
|
|
390
|
+
export {
|
|
391
|
+
DynamicSidebar,
|
|
392
|
+
Sidebar,
|
|
393
|
+
SubNav,
|
|
394
|
+
ThemeToggle,
|
|
395
|
+
TreeContextProvider
|
|
396
|
+
};
|
package/dist/i18n.d.ts
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
import { SelectProps } from '@radix-ui/react-select';
|
|
2
1
|
import { ReactNode } from 'react';
|
|
3
|
-
import { N as NamedTranslation } from './i18n-
|
|
4
|
-
export { T as Translations } from './i18n-
|
|
2
|
+
import { N as NamedTranslation } from './i18n-CE8z-AAs.js';
|
|
3
|
+
export { T as Translations } from './i18n-CE8z-AAs.js';
|
|
5
4
|
|
|
6
|
-
type LanguageSelectProps = Omit<SelectProps, 'value' | 'onValueChange'>;
|
|
7
|
-
declare function LanguageSelect({ ...props }: LanguageSelectProps): React.ReactElement;
|
|
8
5
|
interface I18nProviderProps {
|
|
9
6
|
/**
|
|
10
7
|
* Force a locale
|
|
@@ -18,4 +15,4 @@ interface I18nProviderProps {
|
|
|
18
15
|
}
|
|
19
16
|
declare function I18nProvider({ translations, locale: forceLocale, children, }: I18nProviderProps): React.ReactElement;
|
|
20
17
|
|
|
21
|
-
export { I18nProvider
|
|
18
|
+
export { I18nProvider };
|
package/dist/i18n.js
CHANGED
|
@@ -2,110 +2,13 @@
|
|
|
2
2
|
import {
|
|
3
3
|
I18nContext,
|
|
4
4
|
useI18n
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import {
|
|
7
|
-
twMerge
|
|
8
|
-
} from "./chunk-TK3TM3MR.js";
|
|
5
|
+
} from "./chunk-CRYPD6UZ.js";
|
|
9
6
|
import "./chunk-MLKGABMK.js";
|
|
10
7
|
|
|
11
8
|
// src/i18n.tsx
|
|
12
9
|
import { useCallback } from "react";
|
|
13
10
|
import { useRouter, usePathname } from "next/navigation";
|
|
14
|
-
|
|
15
|
-
// src/components/ui/select.tsx
|
|
16
|
-
import * as SelectPrimitive from "@radix-ui/react-select";
|
|
17
|
-
import { Check, ChevronDown } from "lucide-react";
|
|
18
|
-
import * as React from "react";
|
|
19
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
20
|
-
var Select = SelectPrimitive.Root;
|
|
21
|
-
var SelectValue = SelectPrimitive.Value;
|
|
22
|
-
var SelectTrigger = React.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxs(
|
|
23
|
-
SelectPrimitive.Trigger,
|
|
24
|
-
{
|
|
25
|
-
ref,
|
|
26
|
-
className: twMerge(
|
|
27
|
-
"flex h-10 w-full items-center justify-between rounded-lg border px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-[placeholder]:text-muted-foreground",
|
|
28
|
-
className
|
|
29
|
-
),
|
|
30
|
-
...props,
|
|
31
|
-
children: [
|
|
32
|
-
children,
|
|
33
|
-
/* @__PURE__ */ jsx(SelectPrimitive.Icon, { asChild: true, children: /* @__PURE__ */ jsx(ChevronDown, { className: "size-4 opacity-50" }) })
|
|
34
|
-
]
|
|
35
|
-
}
|
|
36
|
-
));
|
|
37
|
-
SelectTrigger.displayName = SelectPrimitive.Trigger.displayName;
|
|
38
|
-
var SelectContent = React.forwardRef(({ className, children, position = "popper", ...props }, ref) => /* @__PURE__ */ jsx(SelectPrimitive.Portal, { children: /* @__PURE__ */ jsx(
|
|
39
|
-
SelectPrimitive.Content,
|
|
40
|
-
{
|
|
41
|
-
ref,
|
|
42
|
-
className: twMerge(
|
|
43
|
-
"relative z-50 min-w-32 overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=closed]:animate-popover-out data-[state=open]:animate-popover-in",
|
|
44
|
-
className
|
|
45
|
-
),
|
|
46
|
-
position,
|
|
47
|
-
...props,
|
|
48
|
-
children: /* @__PURE__ */ jsx(
|
|
49
|
-
SelectPrimitive.Viewport,
|
|
50
|
-
{
|
|
51
|
-
className: twMerge(
|
|
52
|
-
"p-1",
|
|
53
|
-
position === "popper" && "h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"
|
|
54
|
-
),
|
|
55
|
-
children
|
|
56
|
-
}
|
|
57
|
-
)
|
|
58
|
-
}
|
|
59
|
-
) }));
|
|
60
|
-
SelectContent.displayName = SelectPrimitive.Content.displayName;
|
|
61
|
-
var SelectLabel = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
62
|
-
SelectPrimitive.Label,
|
|
63
|
-
{
|
|
64
|
-
ref,
|
|
65
|
-
className: twMerge("py-1.5 pl-8 pr-2 text-sm font-semibold", className),
|
|
66
|
-
...props
|
|
67
|
-
}
|
|
68
|
-
));
|
|
69
|
-
SelectLabel.displayName = SelectPrimitive.Label.displayName;
|
|
70
|
-
var SelectItem = React.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxs(
|
|
71
|
-
SelectPrimitive.Item,
|
|
72
|
-
{
|
|
73
|
-
ref,
|
|
74
|
-
className: twMerge(
|
|
75
|
-
"relative flex w-full select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
76
|
-
className
|
|
77
|
-
),
|
|
78
|
-
...props,
|
|
79
|
-
children: [
|
|
80
|
-
/* @__PURE__ */ jsx("span", { className: "absolute left-2 flex size-3.5 items-center justify-center", children: /* @__PURE__ */ jsx(SelectPrimitive.ItemIndicator, { children: /* @__PURE__ */ jsx(Check, { className: "size-4" }) }) }),
|
|
81
|
-
/* @__PURE__ */ jsx(SelectPrimitive.ItemText, { children })
|
|
82
|
-
]
|
|
83
|
-
}
|
|
84
|
-
));
|
|
85
|
-
SelectItem.displayName = SelectPrimitive.Item.displayName;
|
|
86
|
-
var SelectSeparator = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
87
|
-
SelectPrimitive.Separator,
|
|
88
|
-
{
|
|
89
|
-
ref,
|
|
90
|
-
className: twMerge("-mx-1 my-1 h-px bg-muted", className),
|
|
91
|
-
...props
|
|
92
|
-
}
|
|
93
|
-
));
|
|
94
|
-
SelectSeparator.displayName = SelectPrimitive.Separator.displayName;
|
|
95
|
-
|
|
96
|
-
// src/i18n.tsx
|
|
97
|
-
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
98
|
-
function LanguageSelect({
|
|
99
|
-
...props
|
|
100
|
-
}) {
|
|
101
|
-
const context = useI18n();
|
|
102
|
-
if (!context.translations) throw new Error("Missing prop `translations`");
|
|
103
|
-
const languages = Object.entries(context.translations);
|
|
104
|
-
return /* @__PURE__ */ jsxs2(Select, { value: context.locale, onValueChange: context.onChange, ...props, children: [
|
|
105
|
-
/* @__PURE__ */ jsx2(SelectTrigger, { children: /* @__PURE__ */ jsx2(SelectValue, { placeholder: context.text.chooseLanguage }) }),
|
|
106
|
-
/* @__PURE__ */ jsx2(SelectContent, { children: languages.map(([lang, { name }]) => /* @__PURE__ */ jsx2(SelectItem, { value: lang, children: name }, lang)) })
|
|
107
|
-
] });
|
|
108
|
-
}
|
|
11
|
+
import { jsx } from "react/jsx-runtime";
|
|
109
12
|
function I18nProvider({
|
|
110
13
|
translations = {},
|
|
111
14
|
locale: forceLocale,
|
|
@@ -124,7 +27,7 @@ function I18nProvider({
|
|
|
124
27
|
},
|
|
125
28
|
[segments, router]
|
|
126
29
|
);
|
|
127
|
-
return /* @__PURE__ */
|
|
30
|
+
return /* @__PURE__ */ jsx(
|
|
128
31
|
I18nContext.Provider,
|
|
129
32
|
{
|
|
130
33
|
value: {
|
|
@@ -141,6 +44,5 @@ function I18nProvider({
|
|
|
141
44
|
);
|
|
142
45
|
}
|
|
143
46
|
export {
|
|
144
|
-
I18nProvider
|
|
145
|
-
LanguageSelect
|
|
47
|
+
I18nProvider
|
|
146
48
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { PageTree } from 'fumadocs-core/server';
|
|
2
1
|
import { ReactNode, HTMLAttributes } from 'react';
|
|
2
|
+
import { PageTree } from 'fumadocs-core/server';
|
|
3
3
|
|
|
4
4
|
interface NavProps {
|
|
5
5
|
title?: ReactNode;
|
|
@@ -8,8 +8,6 @@ interface NavProps {
|
|
|
8
8
|
* @defaultValue '/'
|
|
9
9
|
*/
|
|
10
10
|
url?: string;
|
|
11
|
-
items: LinkItemType[];
|
|
12
|
-
enableSidebar: boolean;
|
|
13
11
|
/**
|
|
14
12
|
* Show/hide search toggle
|
|
15
13
|
*
|
|
@@ -23,7 +21,9 @@ interface NavProps {
|
|
|
23
21
|
transparentMode?: 'always' | 'top' | 'none';
|
|
24
22
|
children?: ReactNode;
|
|
25
23
|
}
|
|
26
|
-
declare function Nav({ title, url, items, transparentMode,
|
|
24
|
+
declare function Nav({ title, url, items, transparentMode, enableSearch, children, }: NavProps & {
|
|
25
|
+
items: LinkItemType[];
|
|
26
|
+
}): React.ReactElement;
|
|
27
27
|
|
|
28
28
|
interface SidebarProps {
|
|
29
29
|
items: LinkItemType[];
|
|
@@ -36,7 +36,9 @@ interface SidebarProps {
|
|
|
36
36
|
defaultOpenLevel?: number;
|
|
37
37
|
components?: Partial<Components>;
|
|
38
38
|
banner?: React.ReactNode;
|
|
39
|
+
bannerProps?: HTMLAttributes<HTMLDivElement>;
|
|
39
40
|
footer?: React.ReactNode;
|
|
41
|
+
footerProps?: HTMLAttributes<HTMLDivElement>;
|
|
40
42
|
}
|
|
41
43
|
interface Components {
|
|
42
44
|
Item: React.FC<{
|
|
@@ -50,8 +52,8 @@ interface Components {
|
|
|
50
52
|
item: PageTree.Separator;
|
|
51
53
|
}>;
|
|
52
54
|
}
|
|
53
|
-
declare function Sidebar({ footer, components, defaultOpenLevel, banner, items,
|
|
54
|
-
|
|
55
|
+
declare function Sidebar({ footer, components, defaultOpenLevel, banner, items, aside, bannerProps, footerProps, }: SidebarProps & {
|
|
56
|
+
aside?: HTMLAttributes<HTMLElement> & Record<string, unknown>;
|
|
55
57
|
}): React.ReactElement;
|
|
56
58
|
|
|
57
59
|
type ActiveType = 'none' | 'url' | 'nested-url';
|
|
@@ -85,13 +87,9 @@ type LinkItemType = {
|
|
|
85
87
|
text: string;
|
|
86
88
|
external?: boolean;
|
|
87
89
|
};
|
|
88
|
-
interface NavOptions extends Omit<NavProps, '
|
|
90
|
+
interface NavOptions extends Omit<NavProps, 'items'> {
|
|
89
91
|
enabled: boolean;
|
|
90
92
|
component: ReactNode;
|
|
91
|
-
/**
|
|
92
|
-
* GitHub url displayed on the navbar
|
|
93
|
-
*/
|
|
94
|
-
githubUrl: string;
|
|
95
93
|
}
|
|
96
94
|
interface SidebarOptions extends Omit<SidebarProps, 'items'> {
|
|
97
95
|
enabled: boolean;
|
|
@@ -99,19 +97,29 @@ interface SidebarOptions extends Omit<SidebarProps, 'items'> {
|
|
|
99
97
|
collapsible: boolean;
|
|
100
98
|
}
|
|
101
99
|
interface BaseLayoutProps {
|
|
100
|
+
/**
|
|
101
|
+
* GitHub url
|
|
102
|
+
*/
|
|
103
|
+
githubUrl?: string;
|
|
102
104
|
links?: LinkItemType[];
|
|
103
105
|
/**
|
|
104
106
|
* Replace or disable navbar
|
|
105
107
|
*/
|
|
106
108
|
nav?: Partial<NavOptions>;
|
|
107
|
-
children
|
|
109
|
+
children?: ReactNode;
|
|
108
110
|
}
|
|
109
111
|
interface DocsLayoutProps extends BaseLayoutProps {
|
|
110
112
|
tree: PageTree.Root;
|
|
111
113
|
sidebar?: Partial<SidebarOptions>;
|
|
112
114
|
containerProps?: HTMLAttributes<HTMLDivElement>;
|
|
115
|
+
/**
|
|
116
|
+
* Enable Language Switch
|
|
117
|
+
*
|
|
118
|
+
* @defaultValue false
|
|
119
|
+
*/
|
|
120
|
+
i18n?: boolean;
|
|
113
121
|
}
|
|
114
|
-
declare function Layout({ nav, links, children, }: BaseLayoutProps): React.ReactElement;
|
|
115
|
-
declare function DocsLayout({ nav, sidebar, links, containerProps, tree, children, }: DocsLayoutProps): React.ReactElement;
|
|
122
|
+
declare function Layout({ nav, links, githubUrl, children, }: BaseLayoutProps): React.ReactElement;
|
|
123
|
+
declare function DocsLayout({ nav, githubUrl, sidebar, links, containerProps, tree, i18n, children, }: DocsLayoutProps): React.ReactElement;
|
|
116
124
|
|
|
117
|
-
export { type BaseLayoutProps as B, type DocsLayoutProps as D, type LinkItemType as L,
|
|
125
|
+
export { type BaseLayoutProps as B, type DocsLayoutProps as D, type LinkItemType as L, type NavProps as N, type SidebarProps as S, Sidebar as a, Layout as b, DocsLayout as c, Nav as d };
|
package/dist/layout.client.d.ts
CHANGED
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
export {
|
|
2
|
-
import { S as SidebarProps } from './layout-WuS8Ab4e.js';
|
|
3
|
-
export { N as Nav, a as Sidebar } from './layout-WuS8Ab4e.js';
|
|
4
|
-
import 'fumadocs-core/server';
|
|
1
|
+
export { d as Nav } from './layout.client-Duq0TTke.js';
|
|
5
2
|
import 'react';
|
|
6
|
-
|
|
7
|
-
declare function DynamicSidebar(props: SidebarProps): React.ReactElement;
|
|
8
|
-
|
|
9
|
-
export { DynamicSidebar };
|
|
3
|
+
import 'fumadocs-core/server';
|