fumadocs-ui 16.7.4 → 16.7.6
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/css/generated/docs.css +4 -1
- package/css/generated/flux.css +0 -1
- package/css/generated/notebook.css +3 -1
- package/css/generated/shared.css +7 -10
- package/css/lib/shiki.css +0 -1
- package/dist/components/toc/clerk.d.ts +9 -1
- package/dist/components/toc/clerk.js +75 -52
- package/dist/components/toc/default.d.ts +9 -1
- package/dist/components/toc/default.js +27 -16
- package/dist/components/toc/index.d.ts +2 -2
- package/dist/components/toc/index.js +3 -2
- package/dist/layouts/docs/client.d.ts +1 -0
- package/dist/layouts/docs/page/slots/toc.js +36 -33
- package/dist/layouts/flux/page/slots/toc.js +13 -12
- package/dist/layouts/home/slots/header.d.ts +1 -1
- package/dist/layouts/notebook/client.d.ts +1 -0
- package/dist/layouts/notebook/page/slots/toc.js +36 -33
- package/dist/og.js +1 -1
- package/dist/style.css +0 -16
- package/dist/utils/use-footer-items.js +3 -3
- package/package.json +7 -7
package/css/generated/docs.css
CHANGED
|
@@ -39,7 +39,6 @@
|
|
|
39
39
|
@source inline("[grid-area:toc]");
|
|
40
40
|
@source inline("a");
|
|
41
41
|
@source inline("absolute");
|
|
42
|
-
@source inline("active");
|
|
43
42
|
@source inline("after");
|
|
44
43
|
@source inline("all");
|
|
45
44
|
@source inline("always");
|
|
@@ -223,6 +222,7 @@
|
|
|
223
222
|
@source inline("inset-0");
|
|
224
223
|
@source inline("inset-y-0");
|
|
225
224
|
@source inline("inset-y-2");
|
|
225
|
+
@source inline("instanceof");
|
|
226
226
|
@source inline("interface");
|
|
227
227
|
@source inline("invisible");
|
|
228
228
|
@source inline("isActive");
|
|
@@ -300,6 +300,8 @@
|
|
|
300
300
|
@source inline("of");
|
|
301
301
|
@source inline("on");
|
|
302
302
|
@source inline("onClick");
|
|
303
|
+
@source inline("onClickItem");
|
|
304
|
+
@source inline("onClickOutside");
|
|
303
305
|
@source inline("onOpenChange");
|
|
304
306
|
@source inline("opacity-0");
|
|
305
307
|
@source inline("open");
|
|
@@ -364,6 +366,7 @@
|
|
|
364
366
|
@source inline("searchTrigger");
|
|
365
367
|
@source inline("secondary");
|
|
366
368
|
@source inline("selected");
|
|
369
|
+
@source inline("selectedIdx");
|
|
367
370
|
@source inline("setDate");
|
|
368
371
|
@source inline("setOpen");
|
|
369
372
|
@source inline("shadow-lg");
|
package/css/generated/flux.css
CHANGED
|
@@ -43,7 +43,6 @@
|
|
|
43
43
|
@source inline("[grid-area:toc]");
|
|
44
44
|
@source inline("a");
|
|
45
45
|
@source inline("absolute");
|
|
46
|
-
@source inline("active");
|
|
47
46
|
@source inline("after");
|
|
48
47
|
@source inline("all");
|
|
49
48
|
@source inline("always");
|
|
@@ -240,6 +239,7 @@
|
|
|
240
239
|
@source inline("inset-0");
|
|
241
240
|
@source inline("inset-y-0");
|
|
242
241
|
@source inline("inset-y-2");
|
|
242
|
+
@source inline("instanceof");
|
|
243
243
|
@source inline("interface");
|
|
244
244
|
@source inline("invisible");
|
|
245
245
|
@source inline("isActive");
|
|
@@ -331,6 +331,8 @@
|
|
|
331
331
|
@source inline("of");
|
|
332
332
|
@source inline("on");
|
|
333
333
|
@source inline("onClick");
|
|
334
|
+
@source inline("onClickItem");
|
|
335
|
+
@source inline("onClickOutside");
|
|
334
336
|
@source inline("onOpenChange");
|
|
335
337
|
@source inline("onPointerEnter");
|
|
336
338
|
@source inline("onPointerLeave");
|
package/css/generated/shared.css
CHANGED
|
@@ -104,8 +104,7 @@
|
|
|
104
104
|
@source inline("at");
|
|
105
105
|
@source inline("attribute");
|
|
106
106
|
@source inline("await");
|
|
107
|
-
@source inline("
|
|
108
|
-
@source inline("b2");
|
|
107
|
+
@source inline("b0");
|
|
109
108
|
@source inline("backdrop-blur-lg");
|
|
110
109
|
@source inline("backdrop-blur-xs");
|
|
111
110
|
@source inline("background");
|
|
@@ -330,6 +329,7 @@
|
|
|
330
329
|
@source inline("enabled");
|
|
331
330
|
@source inline("end");
|
|
332
331
|
@source inline("end-2");
|
|
332
|
+
@source inline("endIdx");
|
|
333
333
|
@source inline("endpoint");
|
|
334
334
|
@source inline("environment");
|
|
335
335
|
@source inline("equal");
|
|
@@ -428,7 +428,6 @@
|
|
|
428
428
|
@source inline("guides");
|
|
429
429
|
@source inline("h");
|
|
430
430
|
@source inline("h-(--fd-animated-height)");
|
|
431
|
-
@source inline("h-(--fd-height)");
|
|
432
431
|
@source inline("h-(--radix-navigation-menu-viewport-height)");
|
|
433
432
|
@source inline("h-1.5");
|
|
434
433
|
@source inline("h-9.5");
|
|
@@ -474,7 +473,6 @@
|
|
|
474
473
|
@source inline("iconClass");
|
|
475
474
|
@source inline("id");
|
|
476
475
|
@source inline("idea");
|
|
477
|
-
@source inline("ids");
|
|
478
476
|
@source inline("idx");
|
|
479
477
|
@source inline("if");
|
|
480
478
|
@source inline("if-needed");
|
|
@@ -506,6 +504,7 @@
|
|
|
506
504
|
@source inline("isActive");
|
|
507
505
|
@source inline("isLoading");
|
|
508
506
|
@source inline("isOpen");
|
|
507
|
+
@source inline("isStart");
|
|
509
508
|
@source inline("isTabActive");
|
|
510
509
|
@source inline("isWindows");
|
|
511
510
|
@source inline("it");
|
|
@@ -528,6 +527,7 @@
|
|
|
528
527
|
@source inline("languages");
|
|
529
528
|
@source inline("last:pb-0");
|
|
530
529
|
@source inline("last:rounded-b-xl");
|
|
530
|
+
@source inline("lastInactiveIdx");
|
|
531
531
|
@source inline("lastUpdate");
|
|
532
532
|
@source inline("layer");
|
|
533
533
|
@source inline("layout");
|
|
@@ -683,6 +683,7 @@
|
|
|
683
683
|
@source inline("onPointerLeave");
|
|
684
684
|
@source inline("onPointerMove");
|
|
685
685
|
@source inline("onPrint");
|
|
686
|
+
@source inline("onResize");
|
|
686
687
|
@source inline("onSearchChange");
|
|
687
688
|
@source inline("onSearchChangeCallback");
|
|
688
689
|
@source inline("onSelect");
|
|
@@ -848,7 +849,6 @@
|
|
|
848
849
|
@source inline("round");
|
|
849
850
|
@source inline("rounded-2xl");
|
|
850
851
|
@source inline("rounded-[inherit]");
|
|
851
|
-
@source inline("rounded-e-full");
|
|
852
852
|
@source inline("rounded-full");
|
|
853
853
|
@source inline("rounded-lg");
|
|
854
854
|
@source inline("rounded-md");
|
|
@@ -941,6 +941,7 @@
|
|
|
941
941
|
@source inline("stars");
|
|
942
942
|
@source inline("start-3");
|
|
943
943
|
@source inline("start-6");
|
|
944
|
+
@source inline("startIdx");
|
|
944
945
|
@source inline("state");
|
|
945
946
|
@source inline("static");
|
|
946
947
|
@source inline("sticky");
|
|
@@ -961,11 +962,9 @@
|
|
|
961
962
|
@source inline("supposed");
|
|
962
963
|
@source inline("sure");
|
|
963
964
|
@source inline("svg");
|
|
964
|
-
@source inline("svgRef");
|
|
965
965
|
@source inline("switch");
|
|
966
966
|
@source inline("system");
|
|
967
967
|
@source inline("t");
|
|
968
|
-
@source inline("t2");
|
|
969
968
|
@source inline("tab");
|
|
970
969
|
@source inline("tabIndex");
|
|
971
970
|
@source inline("table");
|
|
@@ -1020,7 +1019,6 @@
|
|
|
1020
1019
|
@source inline("tocNoHeadings");
|
|
1021
1020
|
@source inline("toolbar");
|
|
1022
1021
|
@source inline("top");
|
|
1023
|
-
@source inline("top-(--fd-top)");
|
|
1024
1022
|
@source inline("top-0");
|
|
1025
1023
|
@source inline("top-1.5");
|
|
1026
1024
|
@source inline("top-1/2");
|
|
@@ -1031,7 +1029,6 @@
|
|
|
1031
1029
|
@source inline("transform");
|
|
1032
1030
|
@source inline("transition-[clip-path]");
|
|
1033
1031
|
@source inline("transition-[height]");
|
|
1034
|
-
@source inline("transition-[top,height]");
|
|
1035
1032
|
@source inline("transition-[width,height]");
|
|
1036
1033
|
@source inline("transition-all");
|
|
1037
1034
|
@source inline("transition-colors");
|
|
@@ -1069,12 +1066,12 @@
|
|
|
1069
1066
|
@source inline("urls");
|
|
1070
1067
|
@source inline("usage");
|
|
1071
1068
|
@source inline("use");
|
|
1072
|
-
@source inline("useActiveAnchors");
|
|
1073
1069
|
@source inline("useCopyButton");
|
|
1074
1070
|
@source inline("useDocsSearch");
|
|
1075
1071
|
@source inline("useI18n");
|
|
1076
1072
|
@source inline("useId");
|
|
1077
1073
|
@source inline("useIsDocsLayout");
|
|
1074
|
+
@source inline("useItems");
|
|
1078
1075
|
@source inline("useMediaQuery");
|
|
1079
1076
|
@source inline("useMemo");
|
|
1080
1077
|
@source inline("useOnChange");
|
package/css/lib/shiki.css
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ComponentProps } from "react";
|
|
2
2
|
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
3
|
+
import * as Primitive from "fumadocs-core/toc";
|
|
3
4
|
|
|
4
5
|
//#region src/components/toc/clerk.d.ts
|
|
5
6
|
declare function TOCItems({
|
|
@@ -7,5 +8,12 @@ declare function TOCItems({
|
|
|
7
8
|
className,
|
|
8
9
|
...props
|
|
9
10
|
}: ComponentProps<'div'>): react_jsx_runtime0.JSX.Element;
|
|
11
|
+
declare function TOCEmpty(): react_jsx_runtime0.JSX.Element;
|
|
12
|
+
declare function TOCItem({
|
|
13
|
+
item,
|
|
14
|
+
...props
|
|
15
|
+
}: Primitive.TOCItemProps & {
|
|
16
|
+
item: Primitive.TOCItemType;
|
|
17
|
+
}): react_jsx_runtime0.JSX.Element;
|
|
10
18
|
//#endregion
|
|
11
|
-
export { TOCItems };
|
|
19
|
+
export { TOCEmpty, TOCItem, TOCItems };
|
|
@@ -1,59 +1,58 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
import { __exportAll } from "../../_virtual/_rolldown/runtime.js";
|
|
2
3
|
import { useI18n } from "../../contexts/i18n.js";
|
|
3
4
|
import { cn } from "../../utils/cn.js";
|
|
4
5
|
import { mergeRefs } from "../../utils/merge-refs.js";
|
|
5
6
|
import { TocThumb, useTOCItems } from "./index.js";
|
|
6
|
-
import { useEffect, useRef, useState } from "react";
|
|
7
|
+
import { useEffect, useEffectEvent, useMemo, useRef, useState } from "react";
|
|
7
8
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
8
9
|
import * as Primitive from "fumadocs-core/toc";
|
|
9
10
|
//#region src/components/toc/clerk.tsx
|
|
11
|
+
var clerk_exports = /* @__PURE__ */ __exportAll({
|
|
12
|
+
TOCEmpty: () => TOCEmpty,
|
|
13
|
+
TOCItem: () => TOCItem,
|
|
14
|
+
TOCItems: () => TOCItems
|
|
15
|
+
});
|
|
10
16
|
function TOCItems({ ref, className, ...props }) {
|
|
11
17
|
const containerRef = useRef(null);
|
|
12
18
|
const items = useTOCItems();
|
|
13
|
-
const { text } = useI18n();
|
|
14
|
-
const svgRef = useRef(null);
|
|
15
19
|
const [svg, setSvg] = useState();
|
|
16
|
-
|
|
17
|
-
if (!containerRef.current) return;
|
|
20
|
+
const onResize = useEffectEvent(() => {
|
|
18
21
|
const container = containerRef.current;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
w += 1;
|
|
37
|
-
if (!svgRef.current || svgRef.current.d !== d) {
|
|
38
|
-
svgRef.current = {
|
|
39
|
-
d,
|
|
40
|
-
width: w,
|
|
41
|
-
height: h
|
|
42
|
-
};
|
|
43
|
-
setSvg(svgRef.current);
|
|
22
|
+
if (!container || container.clientHeight === 0) return;
|
|
23
|
+
let w = 0;
|
|
24
|
+
let h = 0;
|
|
25
|
+
let b0 = 0;
|
|
26
|
+
let d = "";
|
|
27
|
+
for (let i = 0; i < items.length; i++) {
|
|
28
|
+
const element = container.querySelector(`a[href="#${items[i].url.slice(1)}"]`);
|
|
29
|
+
if (!element) continue;
|
|
30
|
+
const styles = getComputedStyle(element);
|
|
31
|
+
const offset = getLineOffset(items[i].depth) + 1, top = element.offsetTop + parseFloat(styles.paddingTop), bottom = element.offsetTop + element.clientHeight - parseFloat(styles.paddingBottom);
|
|
32
|
+
w = Math.max(offset, w);
|
|
33
|
+
h = Math.max(h, bottom);
|
|
34
|
+
if (i === 0) d += ` M${offset} ${top} L${offset} ${bottom}`;
|
|
35
|
+
else {
|
|
36
|
+
const pOffset = getLineOffset(items[i - 1].depth) + 1;
|
|
37
|
+
d += ` C ${pOffset} ${top - 4} ${offset} ${b0 + 4} ${offset} ${top} L${offset} ${bottom}`;
|
|
44
38
|
}
|
|
39
|
+
b0 = bottom;
|
|
45
40
|
}
|
|
41
|
+
setSvg({
|
|
42
|
+
d,
|
|
43
|
+
width: w + 1,
|
|
44
|
+
height: h
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
useEffect(() => {
|
|
48
|
+
if (!containerRef.current) return;
|
|
46
49
|
const observer = new ResizeObserver(onResize);
|
|
47
50
|
onResize();
|
|
48
|
-
observer.observe(
|
|
51
|
+
observer.observe(containerRef.current);
|
|
49
52
|
return () => {
|
|
50
53
|
observer.disconnect();
|
|
51
54
|
};
|
|
52
|
-
}, [
|
|
53
|
-
if (items.length === 0) return /* @__PURE__ */ jsx("div", {
|
|
54
|
-
className: "rounded-lg border bg-fd-card p-3 text-xs text-fd-muted-foreground",
|
|
55
|
-
children: text.tocNoHeadings
|
|
56
|
-
});
|
|
55
|
+
}, []);
|
|
57
56
|
return /* @__PURE__ */ jsxs(Fragment$1, { children: [svg && /* @__PURE__ */ jsxs(TocThumb, {
|
|
58
57
|
containerRef,
|
|
59
58
|
className: "absolute top-0 inset-s-0",
|
|
@@ -80,22 +79,33 @@ function TOCItems({ ref, className, ...props }) {
|
|
|
80
79
|
}), /* @__PURE__ */ jsx("div", {
|
|
81
80
|
ref: mergeRefs(containerRef, ref),
|
|
82
81
|
className: cn("flex flex-col", className),
|
|
83
|
-
...props
|
|
84
|
-
children: items.map((item, i) => /* @__PURE__ */ jsx(TOCItem, {
|
|
85
|
-
item,
|
|
86
|
-
upper: items[i - 1]?.depth,
|
|
87
|
-
lower: items[i + 1]?.depth
|
|
88
|
-
}, item.url))
|
|
82
|
+
...props
|
|
89
83
|
})] });
|
|
90
84
|
}
|
|
85
|
+
function TOCEmpty() {
|
|
86
|
+
const { text } = useI18n();
|
|
87
|
+
return /* @__PURE__ */ jsx("div", {
|
|
88
|
+
className: "rounded-lg border bg-fd-card p-3 text-xs text-fd-muted-foreground",
|
|
89
|
+
children: text.tocNoHeadings
|
|
90
|
+
});
|
|
91
|
+
}
|
|
91
92
|
function ThumbBox() {
|
|
92
|
-
const items =
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
93
|
+
const items = Primitive.useItems();
|
|
94
|
+
let startIdx = -1;
|
|
95
|
+
let endIdx = -1;
|
|
96
|
+
let lastInactiveIdx = -1;
|
|
97
|
+
for (let i = 0; i < items.length; i++) {
|
|
98
|
+
const item = items[i];
|
|
99
|
+
if (item.active) {
|
|
100
|
+
if (startIdx === -1) startIdx = i;
|
|
101
|
+
endIdx = i;
|
|
102
|
+
} else if (lastInactiveIdx === -1 || items[lastInactiveIdx].t < item.t) lastInactiveIdx = i;
|
|
103
|
+
}
|
|
104
|
+
if (startIdx === -1) return;
|
|
105
|
+
const isStart = endIdx < lastInactiveIdx;
|
|
96
106
|
return /* @__PURE__ */ jsx("div", {
|
|
97
107
|
className: "absolute size-1 bg-fd-primary rounded-full transition-transform",
|
|
98
|
-
style: { translate: `calc(${getLineOffset(
|
|
108
|
+
style: { translate: `calc(${getLineOffset(items[isStart ? startIdx : endIdx].original.depth)}px - 1.25px) ${isStart ? "var(--fd-top)" : "calc(var(--fd-top) + var(--fd-height))"}` }
|
|
99
109
|
});
|
|
100
110
|
}
|
|
101
111
|
function getItemOffset(depth) {
|
|
@@ -108,12 +118,25 @@ function getLineOffset(depth) {
|
|
|
108
118
|
if (depth === 3) return 10;
|
|
109
119
|
return 20;
|
|
110
120
|
}
|
|
111
|
-
function TOCItem({ item,
|
|
112
|
-
const
|
|
121
|
+
function TOCItem({ item, ...props }) {
|
|
122
|
+
const items = useTOCItems();
|
|
123
|
+
const { lowerOffset, offset, upperOffset } = useMemo(() => {
|
|
124
|
+
const index = items.indexOf(item);
|
|
125
|
+
const offset = getLineOffset(item.depth);
|
|
126
|
+
return {
|
|
127
|
+
offset,
|
|
128
|
+
upperOffset: index > 0 ? getLineOffset(items[index - 1].depth) : offset,
|
|
129
|
+
lowerOffset: index + 1 < items.length ? getLineOffset(items[index + 1].depth) : offset
|
|
130
|
+
};
|
|
131
|
+
}, [items, item]);
|
|
113
132
|
return /* @__PURE__ */ jsxs(Primitive.TOCItem, {
|
|
114
133
|
href: item.url,
|
|
115
|
-
|
|
116
|
-
className: "prose relative py-1.5 text-sm scroll-m-4 text-fd-muted-foreground hover:text-fd-accent-foreground transition-colors wrap-anywhere first:pt-0 last:pb-0 data-[active=true]:text-fd-primary",
|
|
134
|
+
...props,
|
|
135
|
+
className: cn("prose relative py-1.5 text-sm scroll-m-4 text-fd-muted-foreground hover:text-fd-accent-foreground transition-colors wrap-anywhere first:pt-0 last:pb-0 data-[active=true]:text-fd-primary", props.className),
|
|
136
|
+
style: {
|
|
137
|
+
paddingInlineStart: getItemOffset(item.depth),
|
|
138
|
+
...props.style
|
|
139
|
+
},
|
|
117
140
|
children: [
|
|
118
141
|
offset !== upperOffset && /* @__PURE__ */ jsx("svg", {
|
|
119
142
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -141,4 +164,4 @@ function TOCItem({ item, upper = item.depth, lower = item.depth }) {
|
|
|
141
164
|
});
|
|
142
165
|
}
|
|
143
166
|
//#endregion
|
|
144
|
-
export { TOCItems };
|
|
167
|
+
export { TOCEmpty, TOCItem, TOCItems, clerk_exports };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ComponentProps } from "react";
|
|
2
2
|
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
3
|
+
import * as Primitive from "fumadocs-core/toc";
|
|
3
4
|
|
|
4
5
|
//#region src/components/toc/default.d.ts
|
|
5
6
|
declare function TOCItems({
|
|
@@ -7,5 +8,12 @@ declare function TOCItems({
|
|
|
7
8
|
className,
|
|
8
9
|
...props
|
|
9
10
|
}: ComponentProps<'div'>): react_jsx_runtime0.JSX.Element;
|
|
11
|
+
declare function TOCEmpty(): react_jsx_runtime0.JSX.Element;
|
|
12
|
+
declare function TOCItem({
|
|
13
|
+
item,
|
|
14
|
+
...props
|
|
15
|
+
}: Primitive.TOCItemProps & {
|
|
16
|
+
item: Primitive.TOCItemType;
|
|
17
|
+
}): react_jsx_runtime0.JSX.Element;
|
|
10
18
|
//#endregion
|
|
11
|
-
export { TOCItems };
|
|
19
|
+
export { TOCEmpty, TOCItem, TOCItems };
|
|
@@ -1,36 +1,47 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
import { __exportAll } from "../../_virtual/_rolldown/runtime.js";
|
|
2
3
|
import { useI18n } from "../../contexts/i18n.js";
|
|
3
4
|
import { cn } from "../../utils/cn.js";
|
|
4
5
|
import { mergeRefs } from "../../utils/merge-refs.js";
|
|
5
|
-
import { TocThumb
|
|
6
|
+
import { TocThumb } from "./index.js";
|
|
6
7
|
import { useRef } from "react";
|
|
7
|
-
import {
|
|
8
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
9
|
import * as Primitive from "fumadocs-core/toc";
|
|
9
10
|
//#region src/components/toc/default.tsx
|
|
11
|
+
var default_exports = /* @__PURE__ */ __exportAll({
|
|
12
|
+
TOCEmpty: () => TOCEmpty,
|
|
13
|
+
TOCItem: () => TOCItem,
|
|
14
|
+
TOCItems: () => TOCItems
|
|
15
|
+
});
|
|
10
16
|
function TOCItems({ ref, className, ...props }) {
|
|
11
17
|
const containerRef = useRef(null);
|
|
12
|
-
|
|
18
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
19
|
+
className: "relative",
|
|
20
|
+
children: [/* @__PURE__ */ jsx(TocThumb, {
|
|
21
|
+
containerRef,
|
|
22
|
+
className: "absolute inset-y-0 inset-s-0 bg-fd-primary w-px transition-[clip-path]",
|
|
23
|
+
style: { clipPath: "polygon(0 var(--fd-top), 100% var(--fd-top), 100% calc(var(--fd-top) + var(--fd-height)), 0 calc(var(--fd-top) + var(--fd-height)))" }
|
|
24
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
25
|
+
ref: mergeRefs(ref, containerRef),
|
|
26
|
+
className: cn("flex flex-col border-s border-fd-foreground/10", className),
|
|
27
|
+
...props
|
|
28
|
+
})]
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
function TOCEmpty() {
|
|
13
32
|
const { text } = useI18n();
|
|
14
|
-
|
|
33
|
+
return /* @__PURE__ */ jsx("div", {
|
|
15
34
|
className: "rounded-lg border bg-fd-card p-3 text-xs text-fd-muted-foreground",
|
|
16
35
|
children: text.tocNoHeadings
|
|
17
36
|
});
|
|
18
|
-
return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(TocThumb, {
|
|
19
|
-
containerRef,
|
|
20
|
-
className: "absolute top-(--fd-top) inset-s-0 w-0.5 h-(--fd-height) rounded-e-full bg-fd-primary transition-[top,height]"
|
|
21
|
-
}), /* @__PURE__ */ jsx("div", {
|
|
22
|
-
ref: mergeRefs(ref, containerRef),
|
|
23
|
-
className: cn("flex flex-col border-s border-fd-foreground/10", className),
|
|
24
|
-
...props,
|
|
25
|
-
children: items.map((item) => /* @__PURE__ */ jsx(TOCItem, { item }, item.url))
|
|
26
|
-
})] });
|
|
27
37
|
}
|
|
28
|
-
function TOCItem({ item }) {
|
|
38
|
+
function TOCItem({ item, ...props }) {
|
|
29
39
|
return /* @__PURE__ */ jsx(Primitive.TOCItem, {
|
|
30
40
|
href: item.url,
|
|
31
|
-
|
|
41
|
+
...props,
|
|
42
|
+
className: cn("prose py-1.5 text-sm text-fd-muted-foreground scroll-m-4 transition-colors wrap-anywhere first:pt-0 last:pb-0 data-[active=true]:text-fd-primary hover:text-fd-accent-foreground", item.depth <= 2 && "ps-3", item.depth === 3 && "ps-6", item.depth >= 4 && "ps-8", props.className),
|
|
32
43
|
children: item.title
|
|
33
44
|
});
|
|
34
45
|
}
|
|
35
46
|
//#endregion
|
|
36
|
-
export { TOCItems };
|
|
47
|
+
export { TOCEmpty, TOCItem, TOCItems, default_exports };
|
|
@@ -5,7 +5,7 @@ import * as Primitive from "fumadocs-core/toc";
|
|
|
5
5
|
//#region src/components/toc/index.d.ts
|
|
6
6
|
declare function useTOCItems(): Primitive.TOCItemType[];
|
|
7
7
|
type TOCProviderProps = Primitive.AnchorProviderProps;
|
|
8
|
-
declare const useActiveAnchor: typeof Primitive.useActiveAnchor, useActiveAnchors: typeof Primitive.useActiveAnchors;
|
|
8
|
+
declare const useActiveAnchor: typeof Primitive.useActiveAnchor, useActiveAnchors: typeof Primitive.useActiveAnchors, useItems: typeof Primitive.useItems;
|
|
9
9
|
declare function TOCProvider({
|
|
10
10
|
toc,
|
|
11
11
|
children,
|
|
@@ -26,4 +26,4 @@ declare function TocThumb({
|
|
|
26
26
|
...props
|
|
27
27
|
}: TocThumbProps): react_jsx_runtime0.JSX.Element;
|
|
28
28
|
//#endregion
|
|
29
|
-
export { TOCProvider, TOCProviderProps, TOCScrollArea, TocThumb, useActiveAnchor, useActiveAnchors, useTOCItems };
|
|
29
|
+
export { TOCProvider, TOCProviderProps, TOCScrollArea, TocThumb, useActiveAnchor, useActiveAnchors, useItems, useTOCItems };
|
|
@@ -13,13 +13,14 @@ var toc_exports = /* @__PURE__ */ __exportAll({
|
|
|
13
13
|
TocThumb: () => TocThumb,
|
|
14
14
|
useActiveAnchor: () => useActiveAnchor,
|
|
15
15
|
useActiveAnchors: () => useActiveAnchors,
|
|
16
|
+
useItems: () => useItems,
|
|
16
17
|
useTOCItems: () => useTOCItems
|
|
17
18
|
});
|
|
18
19
|
const TOCContext = createContext([]);
|
|
19
20
|
function useTOCItems() {
|
|
20
21
|
return use(TOCContext);
|
|
21
22
|
}
|
|
22
|
-
const { useActiveAnchor, useActiveAnchors } = Primitive;
|
|
23
|
+
const { useActiveAnchor, useActiveAnchors, useItems } = Primitive;
|
|
23
24
|
function TOCProvider({ toc, children, ...props }) {
|
|
24
25
|
return /* @__PURE__ */ jsx(TOCContext, {
|
|
25
26
|
value: toc,
|
|
@@ -103,4 +104,4 @@ function TocThumb({ containerRef, align = "end", ...props }) {
|
|
|
103
104
|
});
|
|
104
105
|
}
|
|
105
106
|
//#endregion
|
|
106
|
-
export { TOCProvider, TOCScrollArea, TocThumb, toc_exports, useActiveAnchor, useActiveAnchors, useTOCItems };
|
|
107
|
+
export { TOCProvider, TOCScrollArea, TocThumb, toc_exports, useActiveAnchor, useActiveAnchors, useItems, useTOCItems };
|
|
@@ -3,6 +3,7 @@ import { LayoutTab, LinkItemType } from "../shared/index.js";
|
|
|
3
3
|
import { SidebarProps, SidebarProviderProps } from "./slots/sidebar.js";
|
|
4
4
|
import { DocsLayoutProps } from "./index.js";
|
|
5
5
|
import { ComponentProps, FC } from "react";
|
|
6
|
+
|
|
6
7
|
//#region src/layouts/docs/client.d.ts
|
|
7
8
|
interface DocsSlots extends BaseSlots {
|
|
8
9
|
container: FC<ComponentProps<'div'>>;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { I18nLabel, useI18n } from "../../../../contexts/i18n.js";
|
|
3
3
|
import { cn } from "../../../../utils/cn.js";
|
|
4
|
-
import { TOCProvider as TOCProvider$1, TOCScrollArea,
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
4
|
+
import { TOCProvider as TOCProvider$1, TOCScrollArea, useItems, useTOCItems } from "../../../../components/toc/index.js";
|
|
5
|
+
import { default_exports } from "../../../../components/toc/default.js";
|
|
6
|
+
import { clerk_exports } from "../../../../components/toc/clerk.js";
|
|
7
7
|
import { useTreePath } from "../../../../contexts/tree.js";
|
|
8
8
|
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "../../../../components/ui/collapsible.js";
|
|
9
9
|
import { useDocsLayout } from "../../client.js";
|
|
@@ -15,7 +15,9 @@ import { ChevronDown, Text } from "lucide-react";
|
|
|
15
15
|
function TOCProvider(props) {
|
|
16
16
|
return /* @__PURE__ */ jsx(TOCProvider$1, { ...props });
|
|
17
17
|
}
|
|
18
|
-
function TOC({ container, header, footer, style }) {
|
|
18
|
+
function TOC({ container, header, footer, style = "normal" }) {
|
|
19
|
+
const items = useTOCItems();
|
|
20
|
+
const { TOCItems, TOCEmpty, TOCItem } = style === "clerk" ? clerk_exports : default_exports;
|
|
19
21
|
return /* @__PURE__ */ jsxs("div", {
|
|
20
22
|
id: "nd-toc",
|
|
21
23
|
...container,
|
|
@@ -27,37 +29,29 @@ function TOC({ container, header, footer, style }) {
|
|
|
27
29
|
className: "inline-flex items-center gap-1.5 text-sm text-fd-muted-foreground",
|
|
28
30
|
children: [/* @__PURE__ */ jsx(Text, { className: "size-4" }), /* @__PURE__ */ jsx(I18nLabel, { label: "toc" })]
|
|
29
31
|
}),
|
|
30
|
-
/* @__PURE__ */ jsx(TOCScrollArea, { children:
|
|
32
|
+
/* @__PURE__ */ jsx(TOCScrollArea, { children: /* @__PURE__ */ jsxs(TOCItems, { children: [items.length === 0 && /* @__PURE__ */ jsx(TOCEmpty, {}), items.map((item) => /* @__PURE__ */ jsx(TOCItem, { item }, item.url))] }) }),
|
|
31
33
|
footer
|
|
32
34
|
]
|
|
33
35
|
});
|
|
34
36
|
}
|
|
35
37
|
const TocPopoverContext = createContext(null);
|
|
36
|
-
function TOCPopover({ container, trigger, content, header, footer, style }) {
|
|
37
|
-
|
|
38
|
-
...container,
|
|
39
|
-
children: [/* @__PURE__ */ jsx(PageTOCPopoverTrigger, { ...trigger }), /* @__PURE__ */ jsxs(PageTOCPopoverContent, {
|
|
40
|
-
...content,
|
|
41
|
-
children: [
|
|
42
|
-
header,
|
|
43
|
-
/* @__PURE__ */ jsx(TOCScrollArea, { children: style === "clerk" ? /* @__PURE__ */ jsx(TOCItems$1, {}) : /* @__PURE__ */ jsx(TOCItems, {}) }),
|
|
44
|
-
footer
|
|
45
|
-
]
|
|
46
|
-
})]
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
function PageTOCPopover({ className, children, ...rest }) {
|
|
38
|
+
function TOCPopover({ container, trigger, content, header, footer, style = "normal" }) {
|
|
39
|
+
const items = useTOCItems();
|
|
50
40
|
const ref = useRef(null);
|
|
51
41
|
const [open, setOpen] = useState(false);
|
|
52
42
|
const { isNavTransparent } = useDocsLayout();
|
|
53
|
-
const
|
|
54
|
-
|
|
43
|
+
const { TOCItems, TOCItem, TOCEmpty } = style === "clerk" ? clerk_exports : default_exports;
|
|
44
|
+
const onClickOutside = useEffectEvent((e) => {
|
|
45
|
+
if (!open || !(e.target instanceof HTMLElement)) return;
|
|
55
46
|
if (ref.current && !ref.current.contains(e.target)) setOpen(false);
|
|
56
47
|
});
|
|
48
|
+
const onClickItem = () => {
|
|
49
|
+
setOpen(false);
|
|
50
|
+
};
|
|
57
51
|
useEffect(() => {
|
|
58
|
-
window.addEventListener("click",
|
|
52
|
+
window.addEventListener("click", onClickOutside);
|
|
59
53
|
return () => {
|
|
60
|
-
window.removeEventListener("click",
|
|
54
|
+
window.removeEventListener("click", onClickOutside);
|
|
61
55
|
};
|
|
62
56
|
}, []);
|
|
63
57
|
return /* @__PURE__ */ jsx(TocPopoverContext, {
|
|
@@ -69,12 +63,22 @@ function PageTOCPopover({ className, children, ...rest }) {
|
|
|
69
63
|
open,
|
|
70
64
|
onOpenChange: setOpen,
|
|
71
65
|
"data-toc-popover": "",
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
children: /* @__PURE__ */
|
|
66
|
+
...container,
|
|
67
|
+
className: cn("sticky top-(--fd-docs-row-2) z-10 [grid-area:toc-popover] h-(--fd-toc-popover-height) xl:hidden max-xl:layout:[--fd-toc-popover-height:--spacing(10)]", container?.className),
|
|
68
|
+
children: /* @__PURE__ */ jsxs("header", {
|
|
75
69
|
ref,
|
|
76
70
|
className: cn("border-b backdrop-blur-sm transition-colors", (!isNavTransparent || open) && "bg-fd-background/80", open && "shadow-lg"),
|
|
77
|
-
children
|
|
71
|
+
children: [/* @__PURE__ */ jsx(PageTOCPopoverTrigger, { ...trigger }), /* @__PURE__ */ jsxs(PageTOCPopoverContent, {
|
|
72
|
+
...content,
|
|
73
|
+
children: [
|
|
74
|
+
header,
|
|
75
|
+
/* @__PURE__ */ jsx(TOCScrollArea, { children: /* @__PURE__ */ jsxs(TOCItems, { children: [items.length === 0 && /* @__PURE__ */ jsx(TOCEmpty, {}), items.map((item) => /* @__PURE__ */ jsx(TOCItem, {
|
|
76
|
+
item,
|
|
77
|
+
onClick: onClickItem
|
|
78
|
+
}, item.url))] }) }),
|
|
79
|
+
footer
|
|
80
|
+
]
|
|
81
|
+
})]
|
|
78
82
|
})
|
|
79
83
|
})
|
|
80
84
|
});
|
|
@@ -82,18 +86,17 @@ function PageTOCPopover({ className, children, ...rest }) {
|
|
|
82
86
|
function PageTOCPopoverTrigger({ className, ...props }) {
|
|
83
87
|
const { text } = useI18n();
|
|
84
88
|
const { open } = use(TocPopoverContext);
|
|
85
|
-
const items =
|
|
86
|
-
const
|
|
87
|
-
const selected = useMemo(() => items.findIndex((item) => active === item.url.slice(1)), [items, active]);
|
|
89
|
+
const items = useItems();
|
|
90
|
+
const selectedIdx = items.findIndex((item) => item.active);
|
|
88
91
|
const path = useTreePath().at(-1);
|
|
89
|
-
const showItem =
|
|
92
|
+
const showItem = selectedIdx !== -1 && !open;
|
|
90
93
|
return /* @__PURE__ */ jsxs(CollapsibleTrigger, {
|
|
91
94
|
className: cn("flex w-full h-10 items-center text-sm text-fd-muted-foreground gap-2.5 px-4 py-2.5 text-start focus-visible:outline-none [&_svg]:size-4 md:px-6", className),
|
|
92
95
|
"data-toc-popover-trigger": "",
|
|
93
96
|
...props,
|
|
94
97
|
children: [
|
|
95
98
|
/* @__PURE__ */ jsx(ProgressCircle, {
|
|
96
|
-
value: (
|
|
99
|
+
value: (selectedIdx + 1) / Math.max(1, items.length),
|
|
97
100
|
max: 1,
|
|
98
101
|
className: cn("shrink-0", open && "text-fd-primary")
|
|
99
102
|
}),
|
|
@@ -104,7 +107,7 @@ function PageTOCPopoverTrigger({ className, ...props }) {
|
|
|
104
107
|
children: path?.name ?? text.toc
|
|
105
108
|
}), /* @__PURE__ */ jsx("span", {
|
|
106
109
|
className: cn("truncate transition-[opacity,translate]", !showItem && "opacity-0 translate-y-full pointer-events-none"),
|
|
107
|
-
children: items[
|
|
110
|
+
children: items[selectedIdx]?.original.title
|
|
108
111
|
})]
|
|
109
112
|
}),
|
|
110
113
|
/* @__PURE__ */ jsx(ChevronDown, { className: cn("shrink-0 transition-transform mx-0.5", open && "rotate-180") })
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { useI18n } from "../../../../contexts/i18n.js";
|
|
3
3
|
import { cn } from "../../../../utils/cn.js";
|
|
4
|
-
import { TOCScrollArea, toc_exports,
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
4
|
+
import { TOCScrollArea, toc_exports, useItems, useTOCItems } from "../../../../components/toc/index.js";
|
|
5
|
+
import { default_exports } from "../../../../components/toc/default.js";
|
|
6
|
+
import { clerk_exports } from "../../../../components/toc/clerk.js";
|
|
7
7
|
import { useTreePath } from "../../../../contexts/tree.js";
|
|
8
8
|
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "../../../../components/ui/collapsible.js";
|
|
9
9
|
import { createContext, use, useEffect, useEffectEvent, useMemo, useRef, useState } from "react";
|
|
@@ -14,14 +14,16 @@ import { createPortal } from "react-dom";
|
|
|
14
14
|
//#region src/layouts/flux/page/slots/toc.tsx
|
|
15
15
|
const TocPopoverContext = createContext(null);
|
|
16
16
|
const { TOCProvider } = toc_exports;
|
|
17
|
-
function TOC({ container, trigger, content, header, footer, style }) {
|
|
17
|
+
function TOC({ container, trigger, content, header, footer, style = "normal" }) {
|
|
18
|
+
const items = useTOCItems();
|
|
19
|
+
const { TOCItems, TOCEmpty, TOCItem } = style === "clerk" ? clerk_exports : default_exports;
|
|
18
20
|
return /* @__PURE__ */ jsxs(PageTOCPopover, {
|
|
19
21
|
...container,
|
|
20
22
|
children: [/* @__PURE__ */ jsxs(PageTOCPopoverContent, {
|
|
21
23
|
...content,
|
|
22
24
|
children: [
|
|
23
25
|
header,
|
|
24
|
-
/* @__PURE__ */ jsx(TOCScrollArea, { children:
|
|
26
|
+
/* @__PURE__ */ jsx(TOCScrollArea, { children: /* @__PURE__ */ jsxs(TOCItems, { children: [items.length === 0 && /* @__PURE__ */ jsx(TOCEmpty, {}), items.map((item) => /* @__PURE__ */ jsx(TOCItem, { item }, item.url))] }) }),
|
|
25
27
|
footer
|
|
26
28
|
]
|
|
27
29
|
}), /* @__PURE__ */ jsx(PageTOCPopoverTrigger, { ...trigger })]
|
|
@@ -72,9 +74,8 @@ function PageTOCPopoverPhysical({ className, children, ...rest }) {
|
|
|
72
74
|
function PageTOCPopoverTrigger({ className, ...props }) {
|
|
73
75
|
const { text } = useI18n();
|
|
74
76
|
const { open } = use(TocPopoverContext);
|
|
75
|
-
const items =
|
|
76
|
-
const
|
|
77
|
-
const selected = useMemo(() => items.findIndex((item) => active === item.url.slice(1)), [items, active]);
|
|
77
|
+
const items = useItems();
|
|
78
|
+
const selectedIdx = items.findIndex((item) => item.active);
|
|
78
79
|
const path = useTreePath().at(-1);
|
|
79
80
|
const spanProps = {
|
|
80
81
|
transition: { duration: .1 },
|
|
@@ -98,16 +99,16 @@ function PageTOCPopoverTrigger({ className, ...props }) {
|
|
|
98
99
|
...props,
|
|
99
100
|
children: [
|
|
100
101
|
/* @__PURE__ */ jsx(ProgressCircle, {
|
|
101
|
-
value: (
|
|
102
|
+
value: (selectedIdx + 1) / Math.max(1, items.length),
|
|
102
103
|
max: 1,
|
|
103
104
|
className: cn("shrink-0", open && "text-fd-primary")
|
|
104
105
|
}),
|
|
105
106
|
/* @__PURE__ */ jsx(AnimatePresence, {
|
|
106
107
|
mode: "wait",
|
|
107
|
-
children: items[
|
|
108
|
+
children: items[selectedIdx] && !open ? /* @__PURE__ */ jsx(motion.span, {
|
|
108
109
|
...spanProps,
|
|
109
|
-
children: items[
|
|
110
|
-
},
|
|
110
|
+
children: items[selectedIdx].original.title
|
|
111
|
+
}, selectedIdx) : path ? /* @__PURE__ */ jsx(motion.span, {
|
|
111
112
|
...spanProps,
|
|
112
113
|
children: path.name
|
|
113
114
|
}, path.$id ?? ":pathId") : /* @__PURE__ */ jsx(motion.span, {
|
|
@@ -5,7 +5,7 @@ import * as class_variance_authority_types0 from "class-variance-authority/types
|
|
|
5
5
|
|
|
6
6
|
//#region src/layouts/home/slots/header.d.ts
|
|
7
7
|
declare const navItemVariants: (props?: ({
|
|
8
|
-
variant?: "
|
|
8
|
+
variant?: "icon" | "main" | "button" | null | undefined;
|
|
9
9
|
} & class_variance_authority_types0.ClassProp) | undefined) => string;
|
|
10
10
|
declare function Header(props: ComponentProps<'header'>): string | number | bigint | true | react_jsx_runtime0.JSX.Element | Iterable<react.ReactNode> | Promise<string | number | bigint | boolean | react.ReactPortal | react.ReactElement<unknown, string | react.JSXElementConstructor<any>> | Iterable<react.ReactNode> | null | undefined>;
|
|
11
11
|
//#endregion
|
|
@@ -3,6 +3,7 @@ import { LayoutTab, LinkItemType } from "../shared/index.js";
|
|
|
3
3
|
import { SidebarProps, SidebarProviderProps } from "./slots/sidebar.js";
|
|
4
4
|
import { DocsLayoutProps } from "./index.js";
|
|
5
5
|
import { ComponentProps, FC } from "react";
|
|
6
|
+
|
|
6
7
|
//#region src/layouts/notebook/client.d.ts
|
|
7
8
|
interface DocsSlots extends BaseSlots {
|
|
8
9
|
container: FC<ComponentProps<'div'>>;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { I18nLabel, useI18n } from "../../../../contexts/i18n.js";
|
|
3
3
|
import { cn } from "../../../../utils/cn.js";
|
|
4
|
-
import { TOCProvider as TOCProvider$1, TOCScrollArea,
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
4
|
+
import { TOCProvider as TOCProvider$1, TOCScrollArea, useItems, useTOCItems } from "../../../../components/toc/index.js";
|
|
5
|
+
import { default_exports } from "../../../../components/toc/default.js";
|
|
6
|
+
import { clerk_exports } from "../../../../components/toc/clerk.js";
|
|
7
7
|
import { useTreePath } from "../../../../contexts/tree.js";
|
|
8
8
|
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "../../../../components/ui/collapsible.js";
|
|
9
9
|
import { useNotebookLayout } from "../../client.js";
|
|
@@ -14,7 +14,9 @@ import { ChevronDown, Text } from "lucide-react";
|
|
|
14
14
|
function TOCProvider(props) {
|
|
15
15
|
return /* @__PURE__ */ jsx(TOCProvider$1, { ...props });
|
|
16
16
|
}
|
|
17
|
-
function TOC({ container, header, footer, style }) {
|
|
17
|
+
function TOC({ container, header, footer, style = "normal" }) {
|
|
18
|
+
const items = useTOCItems();
|
|
19
|
+
const { TOCItems, TOCEmpty, TOCItem } = style === "clerk" ? clerk_exports : default_exports;
|
|
18
20
|
return /* @__PURE__ */ jsxs("div", {
|
|
19
21
|
id: "nd-toc",
|
|
20
22
|
...container,
|
|
@@ -26,37 +28,29 @@ function TOC({ container, header, footer, style }) {
|
|
|
26
28
|
className: "inline-flex items-center gap-1.5 text-sm text-fd-muted-foreground",
|
|
27
29
|
children: [/* @__PURE__ */ jsx(Text, { className: "size-4" }), /* @__PURE__ */ jsx(I18nLabel, { label: "toc" })]
|
|
28
30
|
}),
|
|
29
|
-
/* @__PURE__ */ jsx(TOCScrollArea, { children:
|
|
31
|
+
/* @__PURE__ */ jsx(TOCScrollArea, { children: /* @__PURE__ */ jsxs(TOCItems, { children: [items.length === 0 && /* @__PURE__ */ jsx(TOCEmpty, {}), items.map((item) => /* @__PURE__ */ jsx(TOCItem, { item }, item.url))] }) }),
|
|
30
32
|
footer
|
|
31
33
|
]
|
|
32
34
|
});
|
|
33
35
|
}
|
|
34
36
|
const TocPopoverContext = createContext(null);
|
|
35
|
-
function TOCPopover({ container, trigger, content, header, footer, style }) {
|
|
36
|
-
|
|
37
|
-
...container,
|
|
38
|
-
children: [/* @__PURE__ */ jsx(PageTOCPopoverTrigger, { ...trigger }), /* @__PURE__ */ jsxs(PageTOCPopoverContent, {
|
|
39
|
-
...content,
|
|
40
|
-
children: [
|
|
41
|
-
header,
|
|
42
|
-
/* @__PURE__ */ jsx(TOCScrollArea, { children: style === "clerk" ? /* @__PURE__ */ jsx(TOCItems$1, {}) : /* @__PURE__ */ jsx(TOCItems, {}) }),
|
|
43
|
-
footer
|
|
44
|
-
]
|
|
45
|
-
})]
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
function PageTOCPopover({ className, children, ...rest }) {
|
|
37
|
+
function TOCPopover({ container, trigger, content, header, footer, style = "normal" }) {
|
|
38
|
+
const items = useTOCItems();
|
|
49
39
|
const ref = useRef(null);
|
|
50
40
|
const [open, setOpen] = useState(false);
|
|
51
41
|
const { isNavTransparent } = useNotebookLayout();
|
|
52
|
-
const
|
|
53
|
-
|
|
42
|
+
const { TOCItems, TOCItem, TOCEmpty } = style === "clerk" ? clerk_exports : default_exports;
|
|
43
|
+
const onClickOutside = useEffectEvent((e) => {
|
|
44
|
+
if (!open || !(e.target instanceof HTMLElement)) return;
|
|
54
45
|
if (ref.current && !ref.current.contains(e.target)) setOpen(false);
|
|
55
46
|
});
|
|
47
|
+
const onClickItem = () => {
|
|
48
|
+
setOpen(false);
|
|
49
|
+
};
|
|
56
50
|
useEffect(() => {
|
|
57
|
-
window.addEventListener("click",
|
|
51
|
+
window.addEventListener("click", onClickOutside);
|
|
58
52
|
return () => {
|
|
59
|
-
window.removeEventListener("click",
|
|
53
|
+
window.removeEventListener("click", onClickOutside);
|
|
60
54
|
};
|
|
61
55
|
}, []);
|
|
62
56
|
return /* @__PURE__ */ jsx(TocPopoverContext, {
|
|
@@ -68,12 +62,22 @@ function PageTOCPopover({ className, children, ...rest }) {
|
|
|
68
62
|
open,
|
|
69
63
|
onOpenChange: setOpen,
|
|
70
64
|
"data-toc-popover": "",
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
children: /* @__PURE__ */
|
|
65
|
+
...container,
|
|
66
|
+
className: cn("sticky top-(--fd-docs-row-2) z-10 [grid-area:toc-popover] h-(--fd-toc-popover-height) xl:hidden max-xl:layout:[--fd-toc-popover-height:--spacing(10)]", container?.className),
|
|
67
|
+
children: /* @__PURE__ */ jsxs("header", {
|
|
74
68
|
ref,
|
|
75
69
|
className: cn("border-b backdrop-blur-sm transition-colors", (!isNavTransparent || open) && "bg-fd-background/80", open && "shadow-lg"),
|
|
76
|
-
children
|
|
70
|
+
children: [/* @__PURE__ */ jsx(PageTOCPopoverTrigger, { ...trigger }), /* @__PURE__ */ jsxs(PageTOCPopoverContent, {
|
|
71
|
+
...content,
|
|
72
|
+
children: [
|
|
73
|
+
header,
|
|
74
|
+
/* @__PURE__ */ jsx(TOCScrollArea, { children: /* @__PURE__ */ jsxs(TOCItems, { children: [items.length === 0 && /* @__PURE__ */ jsx(TOCEmpty, {}), items.map((item) => /* @__PURE__ */ jsx(TOCItem, {
|
|
75
|
+
item,
|
|
76
|
+
onClick: onClickItem
|
|
77
|
+
}, item.url))] }) }),
|
|
78
|
+
footer
|
|
79
|
+
]
|
|
80
|
+
})]
|
|
77
81
|
})
|
|
78
82
|
})
|
|
79
83
|
});
|
|
@@ -81,18 +85,17 @@ function PageTOCPopover({ className, children, ...rest }) {
|
|
|
81
85
|
function PageTOCPopoverTrigger({ className, ...props }) {
|
|
82
86
|
const { text } = useI18n();
|
|
83
87
|
const { open } = use(TocPopoverContext);
|
|
84
|
-
const items =
|
|
85
|
-
const
|
|
86
|
-
const selected = useMemo(() => items.findIndex((item) => active === item.url.slice(1)), [items, active]);
|
|
88
|
+
const items = useItems();
|
|
89
|
+
const selectedIdx = items.findIndex((item) => item.active);
|
|
87
90
|
const path = useTreePath().at(-1);
|
|
88
|
-
const showItem =
|
|
91
|
+
const showItem = selectedIdx !== -1 && !open;
|
|
89
92
|
return /* @__PURE__ */ jsxs(CollapsibleTrigger, {
|
|
90
93
|
className: cn("flex w-full h-10 items-center text-sm text-fd-muted-foreground gap-2.5 px-4 py-2.5 text-start focus-visible:outline-none [&_svg]:size-4 md:px-6", className),
|
|
91
94
|
"data-toc-popover-trigger": "",
|
|
92
95
|
...props,
|
|
93
96
|
children: [
|
|
94
97
|
/* @__PURE__ */ jsx(ProgressCircle, {
|
|
95
|
-
value: (
|
|
98
|
+
value: (selectedIdx + 1) / Math.max(1, items.length),
|
|
96
99
|
max: 1,
|
|
97
100
|
className: cn("shrink-0", open && "text-fd-primary")
|
|
98
101
|
}),
|
|
@@ -103,7 +106,7 @@ function PageTOCPopoverTrigger({ className, ...props }) {
|
|
|
103
106
|
children: path?.name ?? text.toc
|
|
104
107
|
}), /* @__PURE__ */ jsx("span", {
|
|
105
108
|
className: cn("truncate transition-[opacity,translate]", !showItem && "opacity-0 translate-y-full pointer-events-none"),
|
|
106
|
-
children: items[
|
|
109
|
+
children: items[selectedIdx]?.original.title
|
|
107
110
|
})]
|
|
108
111
|
}),
|
|
109
112
|
/* @__PURE__ */ jsx(ChevronDown, { className: cn("shrink-0 transition-transform mx-0.5", open && "rotate-180") })
|
package/dist/og.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { ImageResponse } from "next/og";
|
|
2
|
+
import { ImageResponse } from "next/og.js";
|
|
3
3
|
//#region src/og.tsx
|
|
4
4
|
function generateOGImage(options) {
|
|
5
5
|
const { title, description, icon, site, primaryColor, primaryTextColor, ...rest } = options;
|
package/dist/style.css
CHANGED
|
@@ -353,9 +353,6 @@
|
|
|
353
353
|
.top-\(--fd-docs-row-3\) {
|
|
354
354
|
top: var(--fd-docs-row-3);
|
|
355
355
|
}
|
|
356
|
-
.top-\(--fd-top\) {
|
|
357
|
-
top: var(--fd-top);
|
|
358
|
-
}
|
|
359
356
|
.top-0 {
|
|
360
357
|
top: calc(var(--spacing) * 0);
|
|
361
358
|
}
|
|
@@ -987,9 +984,6 @@
|
|
|
987
984
|
.h-\(--fd-header-height\) {
|
|
988
985
|
height: var(--fd-header-height);
|
|
989
986
|
}
|
|
990
|
-
.h-\(--fd-height\) {
|
|
991
|
-
height: var(--fd-height);
|
|
992
|
-
}
|
|
993
987
|
.h-\(--fd-toc-popover-height\) {
|
|
994
988
|
height: var(--fd-toc-popover-height);
|
|
995
989
|
}
|
|
@@ -1369,10 +1363,6 @@
|
|
|
1369
1363
|
.rounded-xl {
|
|
1370
1364
|
border-radius: var(--radius-xl);
|
|
1371
1365
|
}
|
|
1372
|
-
.rounded-e-full {
|
|
1373
|
-
border-start-end-radius: calc(infinity * 1px);
|
|
1374
|
-
border-end-end-radius: calc(infinity * 1px);
|
|
1375
|
-
}
|
|
1376
1366
|
.border {
|
|
1377
1367
|
border-style: var(--tw-border-style);
|
|
1378
1368
|
border-width: 1px;
|
|
@@ -1885,11 +1875,6 @@
|
|
|
1885
1875
|
transition-timing-function: var(--tw-ease, var(--default-transition-timing-function));
|
|
1886
1876
|
transition-duration: var(--tw-duration, var(--default-transition-duration));
|
|
1887
1877
|
}
|
|
1888
|
-
.transition-\[top\,height\] {
|
|
1889
|
-
transition-property: top,height;
|
|
1890
|
-
transition-timing-function: var(--tw-ease, var(--default-transition-timing-function));
|
|
1891
|
-
transition-duration: var(--tw-duration, var(--default-transition-duration));
|
|
1892
|
-
}
|
|
1893
1878
|
.transition-\[width\,height\] {
|
|
1894
1879
|
transition-property: width,height;
|
|
1895
1880
|
transition-timing-function: var(--tw-ease, var(--default-transition-timing-function));
|
|
@@ -2979,7 +2964,6 @@
|
|
|
2979
2964
|
}
|
|
2980
2965
|
.highlighted {
|
|
2981
2966
|
--fd-counter-color: var(--color-fd-primary);
|
|
2982
|
-
padding-left: calc(var(--padding-left) - 2px);
|
|
2983
2967
|
background-color: color-mix(in srgb, hsl(0, 0%, 9%) 10%, transparent);
|
|
2984
2968
|
@supports (color: color-mix(in lab, red, red)) {
|
|
2985
2969
|
background-color: color-mix(in oklab, var(--color-fd-primary) 10%, transparent);
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { useTreeContext } from "../contexts/tree.js";
|
|
3
3
|
//#region src/utils/use-footer-items.ts
|
|
4
|
-
const footerCache = /* @__PURE__ */ new
|
|
4
|
+
const footerCache = /* @__PURE__ */ new WeakMap();
|
|
5
5
|
/**
|
|
6
6
|
* @returns a list of page tree items (linear), that you can obtain footer items
|
|
7
7
|
*/
|
|
8
8
|
function useFooterItems() {
|
|
9
9
|
const { root } = useTreeContext();
|
|
10
|
-
const cached = footerCache.get(root
|
|
10
|
+
const cached = footerCache.get(root);
|
|
11
11
|
if (cached) return cached;
|
|
12
12
|
const list = [];
|
|
13
13
|
function onNode(node) {
|
|
@@ -17,7 +17,7 @@ function useFooterItems() {
|
|
|
17
17
|
} else if (node.type === "page" && !node.external) list.push(node);
|
|
18
18
|
}
|
|
19
19
|
for (const child of root.children) onNode(child);
|
|
20
|
-
footerCache.set(root
|
|
20
|
+
footerCache.set(root, list);
|
|
21
21
|
return list;
|
|
22
22
|
}
|
|
23
23
|
//#endregion
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fumadocs-ui",
|
|
3
|
-
"version": "16.7.
|
|
3
|
+
"version": "16.7.6",
|
|
4
4
|
"description": "The Radix UI version of Fumadocs UI",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Docs",
|
|
@@ -134,7 +134,7 @@
|
|
|
134
134
|
"@radix-ui/react-slot": "^1.2.4",
|
|
135
135
|
"@radix-ui/react-tabs": "^1.1.13",
|
|
136
136
|
"class-variance-authority": "^0.7.1",
|
|
137
|
-
"lucide-react": "^
|
|
137
|
+
"lucide-react": "^1.6.0",
|
|
138
138
|
"motion": "^12.38.0",
|
|
139
139
|
"next-themes": "^0.4.6",
|
|
140
140
|
"react-medium-image-zoom": "^5.4.1",
|
|
@@ -147,7 +147,7 @@
|
|
|
147
147
|
},
|
|
148
148
|
"devDependencies": {
|
|
149
149
|
"@tailwindcss/cli": "^4.2.2",
|
|
150
|
-
"@tsdown/css": "^0.21.
|
|
150
|
+
"@tsdown/css": "^0.21.5",
|
|
151
151
|
"@types/hast": "^3.0.4",
|
|
152
152
|
"@types/mdx": "^2.0.13",
|
|
153
153
|
"@types/node": "^25.5.0",
|
|
@@ -155,11 +155,11 @@
|
|
|
155
155
|
"@types/react-dom": "^19.2.3",
|
|
156
156
|
"shiki": "^4.0.2",
|
|
157
157
|
"tailwindcss": "^4.2.2",
|
|
158
|
-
"tsdown": "0.21.
|
|
158
|
+
"tsdown": "0.21.5",
|
|
159
159
|
"unified": "^11.0.5",
|
|
160
|
+
"@fumadocs/cli": "1.3.2",
|
|
160
161
|
"eslint-config-custom": "0.0.0",
|
|
161
|
-
"
|
|
162
|
-
"fumadocs-core": "16.7.4",
|
|
162
|
+
"fumadocs-core": "16.7.6",
|
|
163
163
|
"tsconfig": "0.0.0"
|
|
164
164
|
},
|
|
165
165
|
"peerDependencies": {
|
|
@@ -170,7 +170,7 @@
|
|
|
170
170
|
"react": "^19.2.0",
|
|
171
171
|
"react-dom": "^19.2.0",
|
|
172
172
|
"shiki": "*",
|
|
173
|
-
"fumadocs-core": "16.7.
|
|
173
|
+
"fumadocs-core": "16.7.6"
|
|
174
174
|
},
|
|
175
175
|
"peerDependenciesMeta": {
|
|
176
176
|
"next": {
|