fumadocs-ui 12.1.2 → 12.2.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-MXPAPA74.js → chunk-3WVIP3N5.js} +1 -1
- package/dist/{chunk-H5USAX5W.js → chunk-CPOVVDVF.js} +0 -1
- package/dist/{chunk-45QF3XKA.js → chunk-G7WCPUM7.js} +2 -2
- package/dist/{chunk-U4G4ZLRB.js → chunk-Q3FSJZ3E.js} +1 -1
- package/dist/{chunk-YJDZJ4BG.js → chunk-XVCWFZ3A.js} +69 -23
- package/dist/components/accordion.js +2 -2
- package/dist/components/api.d.ts +3 -1
- package/dist/components/api.js +27 -39
- package/dist/components/callout.d.ts +1 -1
- package/dist/components/codeblock.js +2 -2
- package/dist/components/dialog/search-algolia.js +3 -3
- package/dist/components/dialog/search-default.js +3 -3
- package/dist/components/dialog/search.js +3 -3
- package/dist/components/layout/language-toggle.js +1 -1
- package/dist/components/layout/root-toggle.js +1 -1
- package/dist/components/roll-button.js +2 -2
- package/dist/docs.client.d.ts +3 -3
- package/dist/docs.client.js +38 -26
- package/dist/{layout.client-BzAmSQXB.d.ts → layout-C2Cxe6NB.d.ts} +24 -19
- package/dist/layout.client.d.ts +8 -2
- package/dist/layout.client.js +43 -74
- package/dist/layout.d.ts +1 -1
- package/dist/layout.js +5 -4
- package/dist/mdx.client.js +2 -2
- package/dist/page.client.d.ts +3 -3
- package/dist/page.client.js +63 -50
- package/dist/page.d.ts +7 -1
- package/dist/page.js +42 -22
- package/dist/provider.d.ts +1 -1
- package/dist/provider.js +1 -1
- package/dist/style.css +1 -1
- package/dist/tailwind-plugin.cjs +10 -12
- package/dist/tailwind-plugin.js +10 -12
- package/dist/twoslash.css +1 -1
- package/package.json +2 -2
- package/dist/{chunk-FSPYEOFC.js → chunk-ET4TW6M5.js} +4 -4
package/dist/page.client.js
CHANGED
|
@@ -15,9 +15,6 @@ import "./chunk-AN2Y6MA2.js";
|
|
|
15
15
|
import {
|
|
16
16
|
useI18n
|
|
17
17
|
} from "./chunk-HLGNIWUN.js";
|
|
18
|
-
import {
|
|
19
|
-
buttonVariants
|
|
20
|
-
} from "./chunk-H5USAX5W.js";
|
|
21
18
|
import {
|
|
22
19
|
twMerge
|
|
23
20
|
} from "./chunk-TK3TM3MR.js";
|
|
@@ -28,54 +25,53 @@ import { useEffect, useMemo, useState } from "react";
|
|
|
28
25
|
import { ChevronLeft, ChevronRight as ChevronRight2 } from "lucide-react";
|
|
29
26
|
import Link2 from "next/link";
|
|
30
27
|
import { usePathname as usePathname2 } from "next/navigation";
|
|
28
|
+
import { cva } from "class-variance-authority";
|
|
31
29
|
|
|
32
30
|
// src/components/layout/toc.tsx
|
|
33
|
-
import {
|
|
31
|
+
import { ChevronDown, Text } from "lucide-react";
|
|
34
32
|
import * as Primitive from "fumadocs-core/toc-internal";
|
|
35
|
-
import {
|
|
33
|
+
import {
|
|
34
|
+
useCallback,
|
|
35
|
+
useRef
|
|
36
|
+
} from "react";
|
|
36
37
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
37
38
|
var TocProvider = Primitive.AnchorProvider;
|
|
38
39
|
function Toc({ items, header, footer }) {
|
|
39
40
|
const { text } = useI18n();
|
|
40
|
-
return /* @__PURE__ */ jsxs("div", { className: "sticky top-0 flex h-dvh w-[220px] flex-col gap-4 pe-2 pt-12 max-lg:hidden xl:w-[260px]", children: [
|
|
41
|
+
return /* @__PURE__ */ jsxs("div", { className: "sticky top-0 flex h-dvh w-[220px] shrink-0 flex-col gap-4 pe-2 pt-12 max-lg:hidden xl:w-[260px]", children: [
|
|
41
42
|
header,
|
|
42
43
|
/* @__PURE__ */ jsxs("h3", { className: "-mb-1 -ms-0.5 inline-flex items-center gap-1.5 text-sm text-muted-foreground", children: [
|
|
43
|
-
/* @__PURE__ */ jsx(
|
|
44
|
+
/* @__PURE__ */ jsx(Text, { className: "size-4" }),
|
|
44
45
|
text.toc
|
|
45
46
|
] }),
|
|
46
47
|
/* @__PURE__ */ jsx(TOCItems, { items }),
|
|
47
48
|
footer
|
|
48
49
|
] });
|
|
49
50
|
}
|
|
50
|
-
function
|
|
51
|
+
function TocPopover({
|
|
52
|
+
items,
|
|
53
|
+
header,
|
|
54
|
+
footer,
|
|
55
|
+
...props
|
|
56
|
+
}) {
|
|
51
57
|
const { text } = useI18n();
|
|
52
58
|
return /* @__PURE__ */ jsxs(Popover, { children: [
|
|
53
|
-
/* @__PURE__ */ jsxs(
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
className: "sticky ms-auto bottom-4 gap-2 shadow-lg shadow-background z-10 lg:hidden",
|
|
59
|
-
color: "secondary"
|
|
60
|
-
})
|
|
61
|
-
),
|
|
62
|
-
children: [
|
|
63
|
-
/* @__PURE__ */ jsx(TextIcon, { className: "size-4" }),
|
|
64
|
-
text.toc
|
|
65
|
-
]
|
|
66
|
-
}
|
|
67
|
-
),
|
|
59
|
+
/* @__PURE__ */ jsxs(PopoverTrigger, { ...props, children: [
|
|
60
|
+
/* @__PURE__ */ jsx(Text, { className: "size-4" }),
|
|
61
|
+
text.toc,
|
|
62
|
+
/* @__PURE__ */ jsx(ChevronDown, { className: "ms-auto size-4 text-muted-foreground" })
|
|
63
|
+
] }),
|
|
68
64
|
/* @__PURE__ */ jsxs(
|
|
69
65
|
PopoverContent,
|
|
70
66
|
{
|
|
71
67
|
hideWhenDetached: true,
|
|
72
|
-
|
|
73
|
-
align: "
|
|
74
|
-
|
|
68
|
+
alignOffset: 16,
|
|
69
|
+
align: "start",
|
|
70
|
+
side: "bottom",
|
|
75
71
|
className: "flex max-h-[80vh] w-[260px] flex-col gap-4 p-3",
|
|
76
72
|
children: [
|
|
77
73
|
header,
|
|
78
|
-
/* @__PURE__ */ jsx(TOCItems, {
|
|
74
|
+
/* @__PURE__ */ jsx(TOCItems, { items, isMenu: true }),
|
|
79
75
|
footer
|
|
80
76
|
]
|
|
81
77
|
}
|
|
@@ -84,7 +80,7 @@ function SubToc({ items, header, footer }) {
|
|
|
84
80
|
}
|
|
85
81
|
function TOCItems({
|
|
86
82
|
items,
|
|
87
|
-
|
|
83
|
+
isMenu = false
|
|
88
84
|
}) {
|
|
89
85
|
const { text } = useI18n();
|
|
90
86
|
const containerRef = useRef(null);
|
|
@@ -98,7 +94,7 @@ function TOCItems({
|
|
|
98
94
|
}, []);
|
|
99
95
|
if (items.length === 0)
|
|
100
96
|
return /* @__PURE__ */ jsx("div", { className: "rounded-lg border bg-card p-3 text-xs text-muted-foreground", children: text.tocNoHeadings });
|
|
101
|
-
return /* @__PURE__ */ jsx(ScrollArea, { className: twMerge("flex flex-col",
|
|
97
|
+
return /* @__PURE__ */ jsx(ScrollArea, { className: twMerge("flex flex-col", isMenu && "-mx-3"), children: /* @__PURE__ */ jsxs(
|
|
102
98
|
ScrollViewport,
|
|
103
99
|
{
|
|
104
100
|
className: "relative h-0 flex-1 text-sm",
|
|
@@ -112,7 +108,16 @@ function TOCItems({
|
|
|
112
108
|
className: "absolute start-0 hidden w-0.5 bg-primary transition-all"
|
|
113
109
|
}
|
|
114
110
|
),
|
|
115
|
-
/* @__PURE__ */ jsx(Primitive.ScrollProvider, { containerRef, children: /* @__PURE__ */ jsx(
|
|
111
|
+
/* @__PURE__ */ jsx(Primitive.ScrollProvider, { containerRef, children: /* @__PURE__ */ jsx(
|
|
112
|
+
"div",
|
|
113
|
+
{
|
|
114
|
+
className: twMerge(
|
|
115
|
+
"flex flex-col gap-1 text-muted-foreground",
|
|
116
|
+
!isMenu && "border-s-2"
|
|
117
|
+
),
|
|
118
|
+
children: items.map((item) => /* @__PURE__ */ jsx(TOCItem2, { item, setMarker: setPos }, item.url))
|
|
119
|
+
}
|
|
120
|
+
) })
|
|
116
121
|
]
|
|
117
122
|
}
|
|
118
123
|
) });
|
|
@@ -192,48 +197,56 @@ function LastUpdate(props) {
|
|
|
192
197
|
useEffect(() => {
|
|
193
198
|
setDate(props.date.toLocaleDateString());
|
|
194
199
|
}, [props.date]);
|
|
195
|
-
return /* @__PURE__ */ jsxs3("p", { className: "
|
|
200
|
+
return /* @__PURE__ */ jsxs3("p", { className: "text-xs text-muted-foreground", children: [
|
|
196
201
|
text.lastUpdate,
|
|
197
202
|
" ",
|
|
198
203
|
date
|
|
199
204
|
] });
|
|
200
205
|
}
|
|
206
|
+
var itemVariants = cva(
|
|
207
|
+
"flex w-full flex-col gap-2 rounded-lg border bg-card p-4 text-sm transition-colors hover:bg-accent/80 hover:text-accent-foreground"
|
|
208
|
+
);
|
|
209
|
+
var itemLabel = cva("inline-flex items-center gap-0.5 text-muted-foreground");
|
|
201
210
|
function Footer({ items }) {
|
|
202
211
|
const tree = useTreeContext();
|
|
203
212
|
const pathname = usePathname2();
|
|
204
|
-
const {
|
|
213
|
+
const { text } = useI18n();
|
|
205
214
|
const { previous = items?.previous, next = items?.next } = useMemo(() => {
|
|
206
|
-
const
|
|
207
|
-
(item) => item.url === pathname
|
|
208
|
-
);
|
|
215
|
+
const idx = tree.navigation.findIndex((item) => item.url === pathname);
|
|
209
216
|
return {
|
|
210
|
-
previous: tree.navigation[
|
|
211
|
-
next: tree.navigation[
|
|
217
|
+
previous: tree.navigation[idx - 1],
|
|
218
|
+
next: tree.navigation[idx + 1]
|
|
212
219
|
};
|
|
213
220
|
}, [pathname, tree.navigation]);
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
/* @__PURE__ */ jsxs3("div", { className: "inline-flex items-center gap-0.5 text-muted-foreground", children: [
|
|
221
|
+
return /* @__PURE__ */ jsxs3("div", { className: "grid grid-cols-2 gap-4 border-t py-6", children: [
|
|
222
|
+
previous ? /* @__PURE__ */ jsxs3(Link2, { href: previous.url, className: twMerge(itemVariants()), children: [
|
|
223
|
+
/* @__PURE__ */ jsxs3("div", { className: twMerge(itemLabel()), children: [
|
|
218
224
|
/* @__PURE__ */ jsx3(ChevronLeft, { className: "-ms-1 size-4 shrink-0 rtl:rotate-180" }),
|
|
219
|
-
/* @__PURE__ */ jsx3("p", { children: previousPage })
|
|
225
|
+
/* @__PURE__ */ jsx3("p", { children: text.previousPage })
|
|
220
226
|
] }),
|
|
221
227
|
/* @__PURE__ */ jsx3("p", { className: "font-medium", children: previous.name })
|
|
222
228
|
] }) : null,
|
|
223
|
-
next ? /* @__PURE__ */ jsxs3(
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
229
|
+
next ? /* @__PURE__ */ jsxs3(
|
|
230
|
+
Link2,
|
|
231
|
+
{
|
|
232
|
+
href: next.url,
|
|
233
|
+
className: twMerge(itemVariants({ className: "col-start-2 text-end" })),
|
|
234
|
+
children: [
|
|
235
|
+
/* @__PURE__ */ jsxs3("div", { className: twMerge(itemLabel({ className: "flex-row-reverse" })), children: [
|
|
236
|
+
/* @__PURE__ */ jsx3(ChevronRight2, { className: "-me-1 size-4 shrink-0 rtl:rotate-180" }),
|
|
237
|
+
/* @__PURE__ */ jsx3("p", { children: text.nextPage })
|
|
238
|
+
] }),
|
|
239
|
+
/* @__PURE__ */ jsx3("p", { className: "font-medium", children: next.name })
|
|
240
|
+
]
|
|
241
|
+
}
|
|
242
|
+
) : null
|
|
230
243
|
] });
|
|
231
244
|
}
|
|
232
245
|
export {
|
|
233
246
|
Breadcrumb,
|
|
234
247
|
Footer,
|
|
235
248
|
LastUpdate,
|
|
236
|
-
SubToc,
|
|
237
249
|
Toc,
|
|
250
|
+
TocPopover,
|
|
238
251
|
TocProvider
|
|
239
252
|
};
|
package/dist/page.d.ts
CHANGED
|
@@ -19,6 +19,12 @@ interface FooterOptions extends FooterProps {
|
|
|
19
19
|
}
|
|
20
20
|
interface DocsPageProps {
|
|
21
21
|
toc?: TableOfContents;
|
|
22
|
+
/**
|
|
23
|
+
* Extend the page to fill all available space
|
|
24
|
+
*
|
|
25
|
+
* @defaultValue false
|
|
26
|
+
*/
|
|
27
|
+
full?: boolean;
|
|
22
28
|
tableOfContent?: Partial<TableOfContentOptions>;
|
|
23
29
|
tableOfContentPopover?: Partial<TableOfContentOptions>;
|
|
24
30
|
/**
|
|
@@ -32,7 +38,7 @@ interface DocsPageProps {
|
|
|
32
38
|
lastUpdate?: Date | string | number;
|
|
33
39
|
children: ReactNode;
|
|
34
40
|
}
|
|
35
|
-
declare function DocsPage({ toc, tableOfContent, breadcrumb, tableOfContentPopover, footer, ...props }: DocsPageProps): React.ReactElement;
|
|
41
|
+
declare function DocsPage({ toc, tableOfContent, breadcrumb, tableOfContentPopover, lastUpdate, full, footer, ...props }: DocsPageProps): React.ReactElement;
|
|
36
42
|
/**
|
|
37
43
|
* Add typography styles
|
|
38
44
|
*/
|
package/dist/page.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Toc,
|
|
3
|
-
|
|
3
|
+
TocPopover,
|
|
4
4
|
Breadcrumb,
|
|
5
5
|
Footer,
|
|
6
6
|
TocProvider,
|
|
@@ -22,44 +22,64 @@ function DocsPage({
|
|
|
22
22
|
tableOfContent = {},
|
|
23
23
|
breadcrumb = {},
|
|
24
24
|
tableOfContentPopover = {},
|
|
25
|
+
lastUpdate,
|
|
26
|
+
full = false,
|
|
25
27
|
footer = {},
|
|
26
28
|
...props
|
|
27
29
|
}) {
|
|
30
|
+
const tocOptions = {
|
|
31
|
+
// disable TOC on full mode, you can still enable it with `enabled` option.
|
|
32
|
+
enabled: tableOfContent.enabled ?? !full,
|
|
33
|
+
...tableOfContent
|
|
34
|
+
};
|
|
28
35
|
return /* @__PURE__ */ jsxs(TocProvider, { toc, children: [
|
|
29
|
-
/* @__PURE__ */ jsxs(
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
replaceOrDefault(
|
|
38
|
-
props.children,
|
|
39
|
-
props.lastUpdate ? /* @__PURE__ */ jsx(LastUpdate, { date: new Date(props.lastUpdate) }) : null,
|
|
40
|
-
replaceOrDefault(footer, /* @__PURE__ */ jsx(Footer, { items: footer.items })),
|
|
41
|
-
replaceOrDefault(
|
|
36
|
+
/* @__PURE__ */ jsxs("div", { className: "flex min-w-0 flex-1 flex-col", children: [
|
|
37
|
+
/* @__PURE__ */ jsx(
|
|
38
|
+
"div",
|
|
39
|
+
{
|
|
40
|
+
className: twMerge(
|
|
41
|
+
"sticky top-12 z-10 -mb-4 border-b bg-background/60 text-sm font-medium backdrop-blur-md md:top-0 md:bg-card",
|
|
42
|
+
!full && "lg:hidden"
|
|
43
|
+
),
|
|
44
|
+
children: replaceOrDefault(
|
|
42
45
|
tableOfContentPopover,
|
|
43
46
|
/* @__PURE__ */ jsx(
|
|
44
|
-
|
|
47
|
+
TocPopover,
|
|
45
48
|
{
|
|
46
49
|
items: toc,
|
|
47
50
|
header: tableOfContentPopover.header,
|
|
48
|
-
footer: tableOfContentPopover.footer
|
|
51
|
+
footer: tableOfContentPopover.footer,
|
|
52
|
+
className: "inline-flex items-center gap-2 px-4 py-2 text-left max-md:size-full md:ps-6 md:text-muted-foreground"
|
|
49
53
|
}
|
|
50
54
|
)
|
|
51
55
|
)
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
56
|
+
}
|
|
57
|
+
),
|
|
58
|
+
/* @__PURE__ */ jsxs(
|
|
59
|
+
"article",
|
|
60
|
+
{
|
|
61
|
+
className: twMerge(
|
|
62
|
+
"mx-auto flex w-full max-w-[840px] flex-1 flex-col gap-6 px-4 pt-10 md:px-6 md:pt-12",
|
|
63
|
+
!tocOptions.enabled && "max-w-[1200px]"
|
|
64
|
+
),
|
|
65
|
+
children: [
|
|
66
|
+
replaceOrDefault(breadcrumb, /* @__PURE__ */ jsx(Breadcrumb, { full: breadcrumb.full })),
|
|
67
|
+
props.children,
|
|
68
|
+
/* @__PURE__ */ jsx("div", { className: "mt-auto" }),
|
|
69
|
+
lastUpdate ? /* @__PURE__ */ jsx(LastUpdate, { date: new Date(lastUpdate) }) : null,
|
|
70
|
+
replaceOrDefault(footer, /* @__PURE__ */ jsx(Footer, { items: footer.items }))
|
|
71
|
+
]
|
|
72
|
+
}
|
|
73
|
+
)
|
|
74
|
+
] }),
|
|
55
75
|
replaceOrDefault(
|
|
56
|
-
|
|
76
|
+
tocOptions,
|
|
57
77
|
/* @__PURE__ */ jsx(
|
|
58
78
|
Toc,
|
|
59
79
|
{
|
|
60
80
|
items: toc,
|
|
61
|
-
header:
|
|
62
|
-
footer:
|
|
81
|
+
header: tocOptions.header,
|
|
82
|
+
footer: tocOptions.footer
|
|
63
83
|
}
|
|
64
84
|
)
|
|
65
85
|
)
|
package/dist/provider.d.ts
CHANGED