fumadocs-ui 16.7.11 → 16.7.13
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 +1 -0
- package/css/generated/notebook.css +1 -0
- package/css/generated/shared.css +13 -8
- package/dist/components/image-zoom.d.ts +1 -1
- package/dist/components/image-zoom.js +2 -2
- package/dist/components/toc/clerk.d.ts +6 -2
- package/dist/components/toc/clerk.js +78 -39
- package/dist/components/toc/default.d.ts +3 -2
- package/dist/components/toc/default.js +43 -7
- package/dist/components/toc/index.d.ts +2 -9
- package/dist/components/toc/index.js +2 -58
- package/dist/layouts/docs/page/index.d.ts +4 -4
- package/dist/layouts/docs/page/slots/toc.d.ts +22 -14
- package/dist/layouts/docs/page/slots/toc.js +13 -7
- package/dist/layouts/flux/page/index.d.ts +2 -3
- package/dist/layouts/flux/page/slots/toc.d.ts +12 -7
- package/dist/layouts/flux/page/slots/toc.js +6 -3
- package/dist/layouts/notebook/page/index.d.ts +4 -4
- package/dist/layouts/notebook/page/slots/toc.d.ts +22 -14
- package/dist/layouts/notebook/page/slots/toc.js +13 -7
- package/dist/style.css +19 -14
- package/package.json +12 -9
package/css/generated/docs.css
CHANGED
package/css/generated/shared.css
CHANGED
|
@@ -20,8 +20,6 @@
|
|
|
20
20
|
@source inline("--color-fd-muted");
|
|
21
21
|
@source inline("--fd-animated-height");
|
|
22
22
|
@source inline("--fd-banner-height");
|
|
23
|
-
@source inline("--fd-height");
|
|
24
|
-
@source inline("--fd-top");
|
|
25
23
|
@source inline("--padding-right");
|
|
26
24
|
@source inline("--radix-navigation-menu-viewport-height");
|
|
27
25
|
@source inline("--radix-popover-content-available-height");
|
|
@@ -210,6 +208,7 @@
|
|
|
210
208
|
@source inline("component");
|
|
211
209
|
@source inline("components");
|
|
212
210
|
@source inline("composedRef");
|
|
211
|
+
@source inline("computed");
|
|
213
212
|
@source inline("config");
|
|
214
213
|
@source inline("const");
|
|
215
214
|
@source inline("container");
|
|
@@ -268,7 +267,6 @@
|
|
|
268
267
|
@source inline("data-checked:text-fd-accent-foreground");
|
|
269
268
|
@source inline("data-collapsed");
|
|
270
269
|
@source inline("data-empty");
|
|
271
|
-
@source inline("data-hidden");
|
|
272
270
|
@source inline("data-icon");
|
|
273
271
|
@source inline("data-line-numbers");
|
|
274
272
|
@source inline("data-line-numbers-start");
|
|
@@ -522,6 +520,7 @@
|
|
|
522
520
|
@source inline("isWindows");
|
|
523
521
|
@source inline("it");
|
|
524
522
|
@source inline("item");
|
|
523
|
+
@source inline("itemLineLengths");
|
|
525
524
|
@source inline("itemVariants");
|
|
526
525
|
@source inline("items");
|
|
527
526
|
@source inline("items-center");
|
|
@@ -533,6 +532,7 @@
|
|
|
533
532
|
@source inline("key");
|
|
534
533
|
@source inline("keydown");
|
|
535
534
|
@source inline("keyof");
|
|
535
|
+
@source inline("l");
|
|
536
536
|
@source inline("label");
|
|
537
537
|
@source inline("lang");
|
|
538
538
|
@source inline("language");
|
|
@@ -682,11 +682,14 @@
|
|
|
682
682
|
@source inline("of");
|
|
683
683
|
@source inline("official");
|
|
684
684
|
@source inline("offset");
|
|
685
|
+
@source inline("offsetDistance");
|
|
686
|
+
@source inline("offsetPath");
|
|
685
687
|
@source inline("offsetTop");
|
|
686
688
|
@source inline("on");
|
|
687
689
|
@source inline("onChange");
|
|
688
690
|
@source inline("onChangeRef");
|
|
689
691
|
@source inline("onClick");
|
|
692
|
+
@source inline("onCompute");
|
|
690
693
|
@source inline("onCopy");
|
|
691
694
|
@source inline("onKey");
|
|
692
695
|
@source inline("onKeyDown");
|
|
@@ -696,7 +699,6 @@
|
|
|
696
699
|
@source inline("onPointerLeave");
|
|
697
700
|
@source inline("onPointerMove");
|
|
698
701
|
@source inline("onPrint");
|
|
699
|
-
@source inline("onResize");
|
|
700
702
|
@source inline("onSearchChange");
|
|
701
703
|
@source inline("onSearchChangeCallback");
|
|
702
704
|
@source inline("onSelect");
|
|
@@ -762,6 +764,7 @@
|
|
|
762
764
|
@source inline("placeholder:text-fd-muted-foreground");
|
|
763
765
|
@source inline("please");
|
|
764
766
|
@source inline("pointerType");
|
|
767
|
+
@source inline("positions");
|
|
765
768
|
@source inline("possible");
|
|
766
769
|
@source inline("powered");
|
|
767
770
|
@source inline("pre");
|
|
@@ -901,6 +904,7 @@
|
|
|
901
904
|
@source inline("setActive");
|
|
902
905
|
@source inline("setChecked");
|
|
903
906
|
@source inline("setCollapsed");
|
|
907
|
+
@source inline("setComputed");
|
|
904
908
|
@source inline("setHover");
|
|
905
909
|
@source inline("setIsOpen");
|
|
906
910
|
@source inline("setIsTop");
|
|
@@ -1021,7 +1025,7 @@
|
|
|
1021
1025
|
@source inline("themes");
|
|
1022
1026
|
@source inline("this");
|
|
1023
1027
|
@source inline("throw");
|
|
1024
|
-
@source inline("
|
|
1028
|
+
@source inline("thumbBox");
|
|
1025
1029
|
@source inline("tier");
|
|
1026
1030
|
@source inline("timeoutRef");
|
|
1027
1031
|
@source inline("timerRef");
|
|
@@ -1039,16 +1043,17 @@
|
|
|
1039
1043
|
@source inline("top-3");
|
|
1040
1044
|
@source inline("top-4");
|
|
1041
1045
|
@source inline("top-[calc(50%-var(--t,0px)+var(--b,0px))]");
|
|
1046
|
+
@source inline("topL");
|
|
1042
1047
|
@source inline("touch");
|
|
1043
1048
|
@source inline("transform");
|
|
1044
1049
|
@source inline("transition-[clip-path]");
|
|
1045
1050
|
@source inline("transition-[height]");
|
|
1051
|
+
@source inline("transition-[offset-distance]");
|
|
1046
1052
|
@source inline("transition-[width,height]");
|
|
1047
1053
|
@source inline("transition-all");
|
|
1048
1054
|
@source inline("transition-colors");
|
|
1049
1055
|
@source inline("transition-opacity");
|
|
1050
1056
|
@source inline("transition-transform");
|
|
1051
|
-
@source inline("translate");
|
|
1052
1057
|
@source inline("translations");
|
|
1053
1058
|
@source inline("transparent");
|
|
1054
1059
|
@source inline("tree");
|
|
@@ -1073,8 +1078,6 @@
|
|
|
1073
1078
|
@source inline("updateAnchor");
|
|
1074
1079
|
@source inline("updated");
|
|
1075
1080
|
@source inline("updates");
|
|
1076
|
-
@source inline("upper");
|
|
1077
|
-
@source inline("upperBottom");
|
|
1078
1081
|
@source inline("upperOffset");
|
|
1079
1082
|
@source inline("upperX");
|
|
1080
1083
|
@source inline("url");
|
|
@@ -1139,6 +1142,7 @@
|
|
|
1139
1142
|
@source inline("when");
|
|
1140
1143
|
@source inline("where");
|
|
1141
1144
|
@source inline("whether");
|
|
1145
|
+
@source inline("while");
|
|
1142
1146
|
@source inline("white");
|
|
1143
1147
|
@source inline("whitespace-nowrap");
|
|
1144
1148
|
@source inline("whitespaces");
|
|
@@ -1154,6 +1158,7 @@
|
|
|
1154
1158
|
@source inline("wrapped");
|
|
1155
1159
|
@source inline("x");
|
|
1156
1160
|
@source inline("xmlns");
|
|
1161
|
+
@source inline("y");
|
|
1157
1162
|
@source inline("you");
|
|
1158
1163
|
@source inline("your");
|
|
1159
1164
|
@source inline("z-2");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { UncontrolledProps } from "../node_modules/.pnpm/react-medium-image-zoom@5.4.3_react-dom@19.2.5_react@19.2.5__react@19.2.5/node_modules/react-medium-image-zoom/dist/Uncontrolled.js";
|
|
1
2
|
import { ComponentProps } from "react";
|
|
2
3
|
import { ImageProps } from "fumadocs-core/framework";
|
|
3
4
|
import * as _$react_jsx_runtime0 from "react/jsx-runtime";
|
|
4
|
-
import { UncontrolledProps } from "react-medium-image-zoom";
|
|
5
5
|
|
|
6
6
|
//#region src/components/image-zoom.d.ts
|
|
7
7
|
type ImageZoomProps = ImageProps & {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
import { Uncontrolled } from "../node_modules/.pnpm/react-medium-image-zoom@5.4.3_react-dom@19.2.5_react@19.2.5__react@19.2.5/node_modules/react-medium-image-zoom/dist/Uncontrolled.js";
|
|
2
3
|
import "./image-zoom2.css";
|
|
3
4
|
import { Image } from "fumadocs-core/framework";
|
|
4
5
|
import { jsx } from "react/jsx-runtime";
|
|
5
|
-
import Zoom from "react-medium-image-zoom";
|
|
6
6
|
//#region src/components/image-zoom.tsx
|
|
7
7
|
function getImageSrc(src) {
|
|
8
8
|
if (typeof src === "string") return src;
|
|
@@ -13,7 +13,7 @@ function getImageSrc(src) {
|
|
|
13
13
|
return "";
|
|
14
14
|
}
|
|
15
15
|
function ImageZoom({ zoomInProps, children, rmiz, ...props }) {
|
|
16
|
-
return /* @__PURE__ */ jsx(
|
|
16
|
+
return /* @__PURE__ */ jsx(Uncontrolled, {
|
|
17
17
|
zoomMargin: 20,
|
|
18
18
|
wrapElement: "span",
|
|
19
19
|
...rmiz,
|
|
@@ -3,11 +3,15 @@ import * as _$react_jsx_runtime0 from "react/jsx-runtime";
|
|
|
3
3
|
import * as Primitive from "fumadocs-core/toc";
|
|
4
4
|
|
|
5
5
|
//#region src/components/toc/clerk.d.ts
|
|
6
|
+
interface TOCItemsProps extends ComponentProps<'div'> {
|
|
7
|
+
thumbBox?: boolean;
|
|
8
|
+
}
|
|
6
9
|
declare function TOCItems({
|
|
7
10
|
ref,
|
|
8
11
|
className,
|
|
12
|
+
thumbBox,
|
|
9
13
|
...props
|
|
10
|
-
}:
|
|
14
|
+
}: TOCItemsProps): _$react_jsx_runtime0.JSX.Element;
|
|
11
15
|
declare function TOCEmpty(): _$react_jsx_runtime0.JSX.Element;
|
|
12
16
|
declare function TOCItem({
|
|
13
17
|
item,
|
|
@@ -16,4 +20,4 @@ declare function TOCItem({
|
|
|
16
20
|
item: Primitive.TOCItemType;
|
|
17
21
|
}): _$react_jsx_runtime0.JSX.Element;
|
|
18
22
|
//#endregion
|
|
19
|
-
export { TOCEmpty, TOCItem, TOCItems };
|
|
23
|
+
export { TOCEmpty, TOCItem, TOCItems, TOCItemsProps };
|
|
@@ -3,8 +3,8 @@ import { __exportAll } from "../../_virtual/_rolldown/runtime.js";
|
|
|
3
3
|
import { useI18n } from "../../contexts/i18n.js";
|
|
4
4
|
import { cn } from "../../utils/cn.js";
|
|
5
5
|
import { mergeRefs } from "../../utils/merge-refs.js";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
6
|
+
import { useTOCItems } from "./index.js";
|
|
7
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
8
8
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
9
9
|
import * as Primitive from "fumadocs-core/toc";
|
|
10
10
|
//#region src/components/toc/clerk.tsx
|
|
@@ -13,29 +13,41 @@ var clerk_exports = /* @__PURE__ */ __exportAll({
|
|
|
13
13
|
TOCItem: () => TOCItem,
|
|
14
14
|
TOCItems: () => TOCItems
|
|
15
15
|
});
|
|
16
|
-
function TOCItems({ ref, className, ...props }) {
|
|
16
|
+
function TOCItems({ ref, className, thumbBox = true, ...props }) {
|
|
17
17
|
const containerRef = useRef(null);
|
|
18
18
|
const items = useTOCItems();
|
|
19
|
-
const [svg, setSvg] = useState();
|
|
20
|
-
const
|
|
19
|
+
const [svg, setSvg] = useState(null);
|
|
20
|
+
const onPrint = useCallback(() => {
|
|
21
21
|
const container = containerRef.current;
|
|
22
22
|
if (!container || container.clientHeight === 0) return;
|
|
23
|
+
if (items.length === 0) {
|
|
24
|
+
setSvg(null);
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
23
27
|
let w = 0;
|
|
24
28
|
let h = 0;
|
|
25
|
-
let upperBottom = 0;
|
|
26
|
-
let upperX = 0;
|
|
27
29
|
let d = "";
|
|
30
|
+
const positions = [];
|
|
28
31
|
const output = [];
|
|
29
32
|
for (let i = 0; i < items.length; i++) {
|
|
30
33
|
const item = items[i];
|
|
31
|
-
const element = container.querySelector(`a[href="
|
|
34
|
+
const element = container.querySelector(`a[href="${item.url}"]`);
|
|
32
35
|
if (!element) continue;
|
|
33
36
|
const styles = getComputedStyle(element);
|
|
34
|
-
const x = getLineOffset(item.depth) + .5
|
|
37
|
+
const x = getLineOffset(item.depth) + .5;
|
|
38
|
+
const top = element.offsetTop + parseFloat(styles.paddingTop);
|
|
39
|
+
const bottom = element.offsetTop + element.clientHeight - parseFloat(styles.paddingBottom);
|
|
35
40
|
w = Math.max(x + 8, w);
|
|
36
41
|
h = Math.max(h, bottom);
|
|
37
42
|
if (i === 0) d += ` M${x} ${top} L${x} ${bottom}`;
|
|
38
|
-
else
|
|
43
|
+
else {
|
|
44
|
+
const [, upperBottom, upperX] = i > 0 ? positions[i - 1] : [
|
|
45
|
+
0,
|
|
46
|
+
0,
|
|
47
|
+
0
|
|
48
|
+
];
|
|
49
|
+
d += ` C ${upperX} ${top - 4} ${x} ${upperBottom + 4} ${x} ${top} L${x} ${bottom}`;
|
|
50
|
+
}
|
|
39
51
|
if (item._step !== void 0) output.push(/* @__PURE__ */ jsx("circle", {
|
|
40
52
|
cx: x,
|
|
41
53
|
cy: (top + bottom) / 2,
|
|
@@ -50,8 +62,11 @@ function TOCItems({ ref, className, ...props }) {
|
|
|
50
62
|
className: "fill-fd-primary-foreground font-medium text-xs leading-none font-mono",
|
|
51
63
|
children: item._step
|
|
52
64
|
}, `${i}-text`));
|
|
53
|
-
|
|
54
|
-
|
|
65
|
+
positions.push([
|
|
66
|
+
top,
|
|
67
|
+
bottom,
|
|
68
|
+
x
|
|
69
|
+
]);
|
|
55
70
|
}
|
|
56
71
|
output.unshift(/* @__PURE__ */ jsx("path", {
|
|
57
72
|
d,
|
|
@@ -59,39 +74,44 @@ function TOCItems({ ref, className, ...props }) {
|
|
|
59
74
|
strokeWidth: "1",
|
|
60
75
|
fill: "none"
|
|
61
76
|
}, "path"));
|
|
77
|
+
const itemLineLengths = [];
|
|
78
|
+
if (thumbBox) {
|
|
79
|
+
const path = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
80
|
+
path.setAttribute("d", d);
|
|
81
|
+
let l = 0;
|
|
82
|
+
for (const [top, bottom] of positions) {
|
|
83
|
+
while (path.getPointAtLength(l).y < top) l++;
|
|
84
|
+
const topL = l;
|
|
85
|
+
while (path.getPointAtLength(l).y < bottom) l++;
|
|
86
|
+
itemLineLengths.push([topL, l]);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
62
89
|
setSvg({
|
|
63
90
|
content: output,
|
|
64
91
|
width: w,
|
|
65
|
-
height: h
|
|
92
|
+
height: h,
|
|
93
|
+
d,
|
|
94
|
+
itemLineLengths,
|
|
95
|
+
positions
|
|
66
96
|
});
|
|
67
|
-
});
|
|
97
|
+
}, [items, thumbBox]);
|
|
68
98
|
useEffect(() => {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
observer.observe(
|
|
99
|
+
const container = containerRef.current;
|
|
100
|
+
if (!container) return;
|
|
101
|
+
const observer = new ResizeObserver(onPrint);
|
|
102
|
+
observer.observe(container);
|
|
103
|
+
onPrint();
|
|
73
104
|
return () => {
|
|
74
|
-
observer.
|
|
105
|
+
observer.unobserve(container);
|
|
75
106
|
};
|
|
76
|
-
}, []);
|
|
77
|
-
return /* @__PURE__ */ jsxs(Fragment$1, { children: [svg && /* @__PURE__ */ jsxs(
|
|
78
|
-
containerRef,
|
|
107
|
+
}, [onPrint]);
|
|
108
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [svg && /* @__PURE__ */ jsxs("div", {
|
|
79
109
|
className: "absolute top-0 inset-s-0",
|
|
80
110
|
style: {
|
|
81
111
|
width: svg.width,
|
|
82
112
|
height: svg.height
|
|
83
113
|
},
|
|
84
|
-
children: [/* @__PURE__ */ jsx(
|
|
85
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
86
|
-
viewBox: `0 0 ${svg.width} ${svg.height}`,
|
|
87
|
-
className: "absolute transition-[clip-path]",
|
|
88
|
-
style: {
|
|
89
|
-
width: svg.width,
|
|
90
|
-
height: svg.height,
|
|
91
|
-
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)))`
|
|
92
|
-
},
|
|
93
|
-
children: svg.content
|
|
94
|
-
}), /* @__PURE__ */ jsx(ThumbBox, {})]
|
|
114
|
+
children: [/* @__PURE__ */ jsx(ThumbTrack, { computed: svg }), thumbBox && /* @__PURE__ */ jsx(ThumbBox, { computed: svg })]
|
|
95
115
|
}), /* @__PURE__ */ jsx("div", {
|
|
96
116
|
ref: mergeRefs(containerRef, ref),
|
|
97
117
|
className: cn("flex flex-col", className),
|
|
@@ -105,12 +125,31 @@ function TOCEmpty() {
|
|
|
105
125
|
children: text.tocNoHeadings
|
|
106
126
|
});
|
|
107
127
|
}
|
|
108
|
-
function
|
|
128
|
+
function ThumbTrack({ computed }) {
|
|
109
129
|
const items = Primitive.useItems();
|
|
110
|
-
const previousRef = useRef(null);
|
|
111
130
|
const startIdx = items.findIndex((item) => item.active);
|
|
131
|
+
if (startIdx === -1) return;
|
|
112
132
|
const endIdx = items.findLastIndex((item) => item.active);
|
|
133
|
+
const top = `${computed.positions[startIdx][0]}px`;
|
|
134
|
+
const bottom = `${computed.positions[endIdx][1]}px`;
|
|
135
|
+
return /* @__PURE__ */ jsx("svg", {
|
|
136
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
137
|
+
viewBox: `0 0 ${computed.width} ${computed.height}`,
|
|
138
|
+
className: "absolute transition-[clip-path]",
|
|
139
|
+
style: {
|
|
140
|
+
width: computed.width,
|
|
141
|
+
height: computed.height,
|
|
142
|
+
clipPath: `polygon(0 ${top}, 100% ${top}, 100% ${bottom}, 0 ${bottom})`
|
|
143
|
+
},
|
|
144
|
+
children: computed.content
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
function ThumbBox({ computed }) {
|
|
148
|
+
const items = Primitive.useItems();
|
|
149
|
+
const previousRef = useRef(null);
|
|
150
|
+
const startIdx = items.findIndex((item) => item.active);
|
|
113
151
|
if (startIdx === -1) return;
|
|
152
|
+
const endIdx = items.findLastIndex((item) => item.active);
|
|
114
153
|
let isUp = false;
|
|
115
154
|
if (previousRef.current) {
|
|
116
155
|
const prev = previousRef.current;
|
|
@@ -121,12 +160,12 @@ function ThumbBox() {
|
|
|
121
160
|
endIdx,
|
|
122
161
|
isUp
|
|
123
162
|
};
|
|
124
|
-
const original = items[isUp ? startIdx : endIdx].original;
|
|
125
163
|
return /* @__PURE__ */ jsx("div", {
|
|
126
|
-
className: "absolute size-1 bg-fd-primary rounded-full transition-
|
|
164
|
+
className: "absolute size-1 bg-fd-primary rounded-full transition-[offset-distance]",
|
|
127
165
|
style: {
|
|
128
|
-
|
|
129
|
-
|
|
166
|
+
offsetPath: `path("${computed.d}")`,
|
|
167
|
+
offsetDistance: isUp ? computed.itemLineLengths[startIdx][0] : computed.itemLineLengths[endIdx][1],
|
|
168
|
+
scale: items[isUp ? startIdx : endIdx].original._step !== void 0 ? "0" : "1"
|
|
130
169
|
}
|
|
131
170
|
});
|
|
132
171
|
}
|
|
@@ -3,11 +3,12 @@ import * as _$react_jsx_runtime0 from "react/jsx-runtime";
|
|
|
3
3
|
import * as Primitive from "fumadocs-core/toc";
|
|
4
4
|
|
|
5
5
|
//#region src/components/toc/default.d.ts
|
|
6
|
+
type TOCItemsProps = ComponentProps<'div'>;
|
|
6
7
|
declare function TOCItems({
|
|
7
8
|
ref,
|
|
8
9
|
className,
|
|
9
10
|
...props
|
|
10
|
-
}:
|
|
11
|
+
}: TOCItemsProps): _$react_jsx_runtime0.JSX.Element;
|
|
11
12
|
declare function TOCEmpty(): _$react_jsx_runtime0.JSX.Element;
|
|
12
13
|
declare function TOCItem({
|
|
13
14
|
item,
|
|
@@ -16,4 +17,4 @@ declare function TOCItem({
|
|
|
16
17
|
item: Primitive.TOCItemType;
|
|
17
18
|
}): _$react_jsx_runtime0.JSX.Element;
|
|
18
19
|
//#endregion
|
|
19
|
-
export { TOCEmpty, TOCItem, TOCItems };
|
|
20
|
+
export { TOCEmpty, TOCItem, TOCItems, TOCItemsProps };
|
|
@@ -3,8 +3,8 @@ import { __exportAll } from "../../_virtual/_rolldown/runtime.js";
|
|
|
3
3
|
import { useI18n } from "../../contexts/i18n.js";
|
|
4
4
|
import { cn } from "../../utils/cn.js";
|
|
5
5
|
import { mergeRefs } from "../../utils/merge-refs.js";
|
|
6
|
-
import {
|
|
7
|
-
import { useRef } from "react";
|
|
6
|
+
import { useTOCItems } from "./index.js";
|
|
7
|
+
import { useCallback, useEffect, useRef, useState } from "react";
|
|
8
8
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
9
|
import * as Primitive from "fumadocs-core/toc";
|
|
10
10
|
//#region src/components/toc/default.tsx
|
|
@@ -15,19 +15,55 @@ var default_exports = /* @__PURE__ */ __exportAll({
|
|
|
15
15
|
});
|
|
16
16
|
function TOCItems({ ref, className, ...props }) {
|
|
17
17
|
const containerRef = useRef(null);
|
|
18
|
+
const items = useTOCItems();
|
|
19
|
+
const [computed, setComputed] = useState(null);
|
|
20
|
+
const onCompute = useCallback(() => {
|
|
21
|
+
const container = containerRef.current;
|
|
22
|
+
if (!container) return;
|
|
23
|
+
if (items.length === 0) {
|
|
24
|
+
setComputed(null);
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
const positions = [];
|
|
28
|
+
for (const item of items) {
|
|
29
|
+
const element = container.querySelector(`a[href="${item.url}"]`);
|
|
30
|
+
if (!element) continue;
|
|
31
|
+
const styles = getComputedStyle(element);
|
|
32
|
+
positions.push([element.offsetTop + parseFloat(styles.paddingTop), element.offsetTop + element.clientHeight - parseFloat(styles.paddingBottom)]);
|
|
33
|
+
}
|
|
34
|
+
setComputed({ positions });
|
|
35
|
+
}, [items]);
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
const container = containerRef.current;
|
|
38
|
+
if (!container) return;
|
|
39
|
+
const observer = new ResizeObserver(onCompute);
|
|
40
|
+
observer.observe(container);
|
|
41
|
+
onCompute();
|
|
42
|
+
return () => {
|
|
43
|
+
observer.disconnect();
|
|
44
|
+
};
|
|
45
|
+
}, [onCompute]);
|
|
18
46
|
return /* @__PURE__ */ jsxs("div", {
|
|
19
47
|
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", {
|
|
48
|
+
children: [computed && /* @__PURE__ */ jsx(TocThumb, { computed }), /* @__PURE__ */ jsx("div", {
|
|
25
49
|
ref: mergeRefs(ref, containerRef),
|
|
26
50
|
className: cn("flex flex-col border-s border-fd-foreground/10", className),
|
|
27
51
|
...props
|
|
28
52
|
})]
|
|
29
53
|
});
|
|
30
54
|
}
|
|
55
|
+
function TocThumb({ computed }) {
|
|
56
|
+
const items = Primitive.useItems();
|
|
57
|
+
const startIdx = items.findIndex((item) => item.active);
|
|
58
|
+
if (startIdx === -1) return;
|
|
59
|
+
const endIdx = items.findLastIndex((item) => item.active);
|
|
60
|
+
const top = `${computed.positions[startIdx][0]}px`;
|
|
61
|
+
const bottom = `${computed.positions[endIdx][1]}px`;
|
|
62
|
+
return /* @__PURE__ */ jsx("div", {
|
|
63
|
+
className: "absolute inset-y-0 inset-s-0 bg-fd-primary w-px transition-[clip-path]",
|
|
64
|
+
style: { clipPath: `polygon(0 ${top}, 100% ${top}, 100% ${bottom}, 0 ${bottom})` }
|
|
65
|
+
});
|
|
66
|
+
}
|
|
31
67
|
function TOCEmpty() {
|
|
32
68
|
const { text } = useI18n();
|
|
33
69
|
return /* @__PURE__ */ jsx("div", {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ComponentProps
|
|
1
|
+
import { ComponentProps } from "react";
|
|
2
2
|
import * as _$react_jsx_runtime0 from "react/jsx-runtime";
|
|
3
3
|
import * as Primitive from "fumadocs-core/toc";
|
|
4
4
|
|
|
@@ -16,12 +16,5 @@ declare function TOCScrollArea({
|
|
|
16
16
|
className,
|
|
17
17
|
...props
|
|
18
18
|
}: ComponentProps<'div'>): _$react_jsx_runtime0.JSX.Element;
|
|
19
|
-
interface TocThumbProps extends ComponentProps<'div'> {
|
|
20
|
-
containerRef: RefObject<HTMLElement | null>;
|
|
21
|
-
}
|
|
22
|
-
declare function TocThumb({
|
|
23
|
-
containerRef,
|
|
24
|
-
...props
|
|
25
|
-
}: TocThumbProps): _$react_jsx_runtime0.JSX.Element;
|
|
26
19
|
//#endregion
|
|
27
|
-
export { TOCProvider, TOCProviderProps, TOCScrollArea,
|
|
20
|
+
export { TOCProvider, TOCProviderProps, TOCScrollArea, useActiveAnchor, useActiveAnchors, useItems, useTOCItems };
|
|
@@ -2,15 +2,13 @@
|
|
|
2
2
|
import { __exportAll } from "../../_virtual/_rolldown/runtime.js";
|
|
3
3
|
import { cn } from "../../utils/cn.js";
|
|
4
4
|
import { mergeRefs } from "../../utils/merge-refs.js";
|
|
5
|
-
import { createContext, use,
|
|
5
|
+
import { createContext, use, useRef } from "react";
|
|
6
6
|
import { jsx } from "react/jsx-runtime";
|
|
7
7
|
import * as Primitive from "fumadocs-core/toc";
|
|
8
|
-
import { useOnChange } from "fumadocs-core/utils/use-on-change";
|
|
9
8
|
//#region src/components/toc/index.tsx
|
|
10
9
|
var toc_exports = /* @__PURE__ */ __exportAll({
|
|
11
10
|
TOCProvider: () => TOCProvider,
|
|
12
11
|
TOCScrollArea: () => TOCScrollArea,
|
|
13
|
-
TocThumb: () => TocThumb,
|
|
14
12
|
useActiveAnchor: () => useActiveAnchor,
|
|
15
13
|
useActiveAnchors: () => useActiveAnchors,
|
|
16
14
|
useItems: () => useItems,
|
|
@@ -43,59 +41,5 @@ function TOCScrollArea({ ref, className, ...props }) {
|
|
|
43
41
|
})
|
|
44
42
|
});
|
|
45
43
|
}
|
|
46
|
-
function TocThumb({ containerRef, ...props }) {
|
|
47
|
-
const thumbRef = useRef(null);
|
|
48
|
-
const active = useActiveAnchors();
|
|
49
|
-
function update(info) {
|
|
50
|
-
const element = thumbRef.current;
|
|
51
|
-
const container = containerRef.current;
|
|
52
|
-
if (!element || !container) return;
|
|
53
|
-
element.style.setProperty("--fd-top", `${info.top}px`);
|
|
54
|
-
element.style.setProperty("--fd-height", `${info.height}px`);
|
|
55
|
-
}
|
|
56
|
-
function calc(active) {
|
|
57
|
-
const container = containerRef.current;
|
|
58
|
-
if (!container || container.clientHeight === 0) return null;
|
|
59
|
-
if (active.length === 0) return {
|
|
60
|
-
height: 0,
|
|
61
|
-
top: 0
|
|
62
|
-
};
|
|
63
|
-
let upper = Number.MAX_VALUE;
|
|
64
|
-
let lower = 0;
|
|
65
|
-
for (const item of active) {
|
|
66
|
-
const element = container.querySelector(`a[href="#${item}"]`);
|
|
67
|
-
if (!element) continue;
|
|
68
|
-
const styles = getComputedStyle(element);
|
|
69
|
-
upper = Math.min(upper, element.offsetTop + parseFloat(styles.paddingTop));
|
|
70
|
-
lower = Math.max(lower, element.offsetTop + element.clientHeight - parseFloat(styles.paddingBottom));
|
|
71
|
-
}
|
|
72
|
-
return {
|
|
73
|
-
top: upper,
|
|
74
|
-
height: lower - upper
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
const onPrint = useEffectEvent(() => {
|
|
78
|
-
const result = calc(active);
|
|
79
|
-
if (result) update(result);
|
|
80
|
-
});
|
|
81
|
-
useEffect(() => {
|
|
82
|
-
if (!containerRef.current) return;
|
|
83
|
-
const container = containerRef.current;
|
|
84
|
-
const observer = new ResizeObserver(onPrint);
|
|
85
|
-
observer.observe(container);
|
|
86
|
-
return () => {
|
|
87
|
-
observer.disconnect();
|
|
88
|
-
};
|
|
89
|
-
}, [containerRef]);
|
|
90
|
-
useOnChange(active, () => {
|
|
91
|
-
const result = calc(active);
|
|
92
|
-
if (result) update(result);
|
|
93
|
-
});
|
|
94
|
-
return /* @__PURE__ */ jsx("div", {
|
|
95
|
-
ref: thumbRef,
|
|
96
|
-
"data-hidden": active.length === 0,
|
|
97
|
-
...props
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
44
|
//#endregion
|
|
101
|
-
export { TOCProvider, TOCScrollArea,
|
|
45
|
+
export { TOCProvider, TOCScrollArea, toc_exports, useActiveAnchor, useActiveAnchors, useItems, useTOCItems };
|
|
@@ -35,20 +35,20 @@ interface FooterOptions extends FooterProps {
|
|
|
35
35
|
*/
|
|
36
36
|
component?: ReactNode;
|
|
37
37
|
}
|
|
38
|
-
|
|
38
|
+
type TableOfContentOptions = Pick<TOCProviderProps, 'single'> & TOCProps & {
|
|
39
39
|
enabled?: boolean;
|
|
40
40
|
/**
|
|
41
41
|
* @deprecated use `slots.toc` instead.
|
|
42
42
|
*/
|
|
43
43
|
component?: ReactNode;
|
|
44
|
-
}
|
|
45
|
-
|
|
44
|
+
};
|
|
45
|
+
type TableOfContentPopoverOptions = TOCPopoverProps & {
|
|
46
46
|
enabled?: boolean;
|
|
47
47
|
/**
|
|
48
48
|
* @deprecated use `slots.tocPopover` instead.
|
|
49
49
|
*/
|
|
50
50
|
component?: ReactNode;
|
|
51
|
-
}
|
|
51
|
+
};
|
|
52
52
|
interface DocsPageSlots {
|
|
53
53
|
toc: {
|
|
54
54
|
provider: FC<TOCProviderProps>;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { TOCItemsProps } from "../../../../components/toc/clerk.js";
|
|
2
|
+
import { TOCItemsProps as TOCItemsProps$1 } from "../../../../components/toc/default.js";
|
|
1
3
|
import { TOCProviderProps as TOCProviderProps$1 } from "../../../../components/toc/index.js";
|
|
2
4
|
import { ComponentProps, ReactNode } from "react";
|
|
3
5
|
import * as _$react_jsx_runtime0 from "react/jsx-runtime";
|
|
@@ -5,7 +7,7 @@ import * as _$react_jsx_runtime0 from "react/jsx-runtime";
|
|
|
5
7
|
//#region src/layouts/docs/page/slots/toc.d.ts
|
|
6
8
|
type TOCProviderProps = TOCProviderProps$1;
|
|
7
9
|
declare function TOCProvider(props: TOCProviderProps): _$react_jsx_runtime0.JSX.Element;
|
|
8
|
-
|
|
10
|
+
type TOCProps = {
|
|
9
11
|
container?: ComponentProps<'div'>;
|
|
10
12
|
/**
|
|
11
13
|
* Custom content in TOC container, before the main TOC
|
|
@@ -15,18 +17,21 @@ interface TOCProps {
|
|
|
15
17
|
* Custom content in TOC container, after the main TOC
|
|
16
18
|
*/
|
|
17
19
|
footer?: ReactNode;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
} & ({
|
|
21
|
+
style?: 'normal';
|
|
22
|
+
list?: TOCItemsProps$1;
|
|
23
|
+
} | {
|
|
24
|
+
style: 'clerk';
|
|
25
|
+
list?: TOCItemsProps;
|
|
26
|
+
});
|
|
23
27
|
declare function TOC({
|
|
24
28
|
container,
|
|
25
29
|
header,
|
|
26
30
|
footer,
|
|
27
|
-
style
|
|
31
|
+
style,
|
|
32
|
+
list
|
|
28
33
|
}: TOCProps): _$react_jsx_runtime0.JSX.Element;
|
|
29
|
-
|
|
34
|
+
type TOCPopoverProps = {
|
|
30
35
|
container?: ComponentProps<'div'>;
|
|
31
36
|
trigger?: ComponentProps<'button'>;
|
|
32
37
|
content?: ComponentProps<'div'>;
|
|
@@ -38,18 +43,21 @@ interface TOCPopoverProps {
|
|
|
38
43
|
* Custom content in TOC container, after the main TOC
|
|
39
44
|
*/
|
|
40
45
|
footer?: ReactNode;
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
+
} & ({
|
|
47
|
+
style?: 'normal';
|
|
48
|
+
list?: TOCItemsProps$1;
|
|
49
|
+
} | {
|
|
50
|
+
style: 'clerk';
|
|
51
|
+
list?: TOCItemsProps;
|
|
52
|
+
});
|
|
46
53
|
declare function TOCPopover({
|
|
47
54
|
container,
|
|
48
55
|
trigger,
|
|
49
56
|
content,
|
|
50
57
|
header,
|
|
51
58
|
footer,
|
|
52
|
-
style
|
|
59
|
+
style,
|
|
60
|
+
list
|
|
53
61
|
}: TOCPopoverProps): _$react_jsx_runtime0.JSX.Element;
|
|
54
62
|
//#endregion
|
|
55
63
|
export { TOC, TOCPopover, TOCPopoverProps, TOCProps, TOCProvider, TOCProviderProps };
|
|
@@ -15,7 +15,7 @@ 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 = "normal" }) {
|
|
18
|
+
function TOC({ container, header, footer, style = "normal", list }) {
|
|
19
19
|
const items = useTOCItems();
|
|
20
20
|
const { TOCItems, TOCEmpty, TOCItem } = style === "clerk" ? clerk_exports : default_exports;
|
|
21
21
|
return /* @__PURE__ */ jsxs("div", {
|
|
@@ -29,13 +29,16 @@ function TOC({ container, header, footer, style = "normal" }) {
|
|
|
29
29
|
className: "inline-flex items-center gap-1.5 text-sm text-fd-muted-foreground",
|
|
30
30
|
children: [/* @__PURE__ */ jsx(Text, { className: "size-4" }), /* @__PURE__ */ jsx(I18nLabel, { label: "toc" })]
|
|
31
31
|
}),
|
|
32
|
-
/* @__PURE__ */ jsx(TOCScrollArea, { children: /* @__PURE__ */ jsxs(TOCItems, {
|
|
32
|
+
/* @__PURE__ */ jsx(TOCScrollArea, { children: /* @__PURE__ */ jsxs(TOCItems, {
|
|
33
|
+
...list,
|
|
34
|
+
children: [items.length === 0 && /* @__PURE__ */ jsx(TOCEmpty, {}), items.map((item) => /* @__PURE__ */ jsx(TOCItem, { item }, item.url))]
|
|
35
|
+
}) }),
|
|
33
36
|
footer
|
|
34
37
|
]
|
|
35
38
|
});
|
|
36
39
|
}
|
|
37
40
|
const TocPopoverContext = createContext(null);
|
|
38
|
-
function TOCPopover({ container, trigger, content, header, footer, style = "normal" }) {
|
|
41
|
+
function TOCPopover({ container, trigger, content, header, footer, style = "normal", list }) {
|
|
39
42
|
const items = useTOCItems();
|
|
40
43
|
const ref = useRef(null);
|
|
41
44
|
const [open, setOpen] = useState(false);
|
|
@@ -72,10 +75,13 @@ function TOCPopover({ container, trigger, content, header, footer, style = "norm
|
|
|
72
75
|
...content,
|
|
73
76
|
children: [
|
|
74
77
|
header,
|
|
75
|
-
/* @__PURE__ */ jsx(TOCScrollArea, { children: /* @__PURE__ */ jsxs(TOCItems, {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
78
|
+
/* @__PURE__ */ jsx(TOCScrollArea, { children: /* @__PURE__ */ jsxs(TOCItems, {
|
|
79
|
+
...list,
|
|
80
|
+
children: [items.length === 0 && /* @__PURE__ */ jsx(TOCEmpty, {}), items.map((item) => /* @__PURE__ */ jsx(TOCItem, {
|
|
81
|
+
item,
|
|
82
|
+
onClick: onClickItem
|
|
83
|
+
}, item.url))]
|
|
84
|
+
}) }),
|
|
79
85
|
footer
|
|
80
86
|
]
|
|
81
87
|
})]
|
|
@@ -15,19 +15,18 @@ interface DocsPageProps extends ComponentProps<'article'> {
|
|
|
15
15
|
* @defaultValue false
|
|
16
16
|
*/
|
|
17
17
|
full?: boolean;
|
|
18
|
-
children?: ReactNode;
|
|
19
18
|
slots?: Partial<DocsPageSlots>;
|
|
20
19
|
footer?: FooterOptions;
|
|
21
20
|
breadcrumb?: BreadcrumbOptions;
|
|
22
21
|
tableOfContent?: TableOfContentOptions;
|
|
23
22
|
}
|
|
24
|
-
|
|
23
|
+
type TableOfContentOptions = Pick<TOCProviderProps, 'single'> & TOCProps & {
|
|
25
24
|
enabled?: boolean;
|
|
26
25
|
/**
|
|
27
26
|
* @deprecated use `slots.toc` instead.
|
|
28
27
|
*/
|
|
29
28
|
component?: ReactNode;
|
|
30
|
-
}
|
|
29
|
+
};
|
|
31
30
|
interface BreadcrumbOptions extends BreadcrumbProps {
|
|
32
31
|
enabled?: boolean;
|
|
33
32
|
/**
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { TOCItemsProps } from "../../../../components/toc/clerk.js";
|
|
2
|
+
import { TOCItemsProps as TOCItemsProps$1 } from "../../../../components/toc/default.js";
|
|
1
3
|
import { TOCProvider as TOCProvider$1, TOCProviderProps as TOCProviderProps$1 } from "../../../../components/toc/index.js";
|
|
2
4
|
import { ComponentProps, ReactNode } from "react";
|
|
3
5
|
import * as _$react_jsx_runtime0 from "react/jsx-runtime";
|
|
@@ -5,7 +7,7 @@ import * as _$react_jsx_runtime0 from "react/jsx-runtime";
|
|
|
5
7
|
//#region src/layouts/flux/page/slots/toc.d.ts
|
|
6
8
|
type TOCProviderProps = TOCProviderProps$1;
|
|
7
9
|
declare const TOCProvider: typeof TOCProvider$1;
|
|
8
|
-
|
|
10
|
+
type TOCProps = {
|
|
9
11
|
container?: ComponentProps<'div'>;
|
|
10
12
|
trigger?: ComponentProps<'button'>;
|
|
11
13
|
content?: ComponentProps<'div'>;
|
|
@@ -17,18 +19,21 @@ interface TOCProps {
|
|
|
17
19
|
* Custom content in TOC container, after the main TOC
|
|
18
20
|
*/
|
|
19
21
|
footer?: ReactNode;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
} & ({
|
|
23
|
+
style?: 'normal';
|
|
24
|
+
list?: TOCItemsProps$1;
|
|
25
|
+
} | {
|
|
26
|
+
style: 'clerk';
|
|
27
|
+
list?: TOCItemsProps;
|
|
28
|
+
});
|
|
25
29
|
declare function TOC({
|
|
26
30
|
container,
|
|
27
31
|
trigger,
|
|
28
32
|
content,
|
|
29
33
|
header,
|
|
30
34
|
footer,
|
|
31
|
-
style
|
|
35
|
+
style,
|
|
36
|
+
list
|
|
32
37
|
}: TOCProps): _$react_jsx_runtime0.JSX.Element;
|
|
33
38
|
//#endregion
|
|
34
39
|
export { TOC, TOCProps, TOCProvider, TOCProviderProps };
|
|
@@ -9,12 +9,12 @@ import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "../../../..
|
|
|
9
9
|
import { createContext, use, useEffect, useEffectEvent, useMemo, useRef, useState } from "react";
|
|
10
10
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
11
11
|
import { ChevronDown } from "lucide-react";
|
|
12
|
-
import { AnimatePresence, motion } from "motion/react";
|
|
13
12
|
import { createPortal } from "react-dom";
|
|
13
|
+
import { AnimatePresence, motion } from "motion/react";
|
|
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 = "normal" }) {
|
|
17
|
+
function TOC({ container, trigger, content, header, footer, style = "normal", list }) {
|
|
18
18
|
const items = useTOCItems();
|
|
19
19
|
const { TOCItems, TOCEmpty, TOCItem } = style === "clerk" ? clerk_exports : default_exports;
|
|
20
20
|
return /* @__PURE__ */ jsxs(PageTOCPopover, {
|
|
@@ -23,7 +23,10 @@ function TOC({ container, trigger, content, header, footer, style = "normal" })
|
|
|
23
23
|
...content,
|
|
24
24
|
children: [
|
|
25
25
|
header,
|
|
26
|
-
/* @__PURE__ */ jsx(TOCScrollArea, { children: /* @__PURE__ */ jsxs(TOCItems, {
|
|
26
|
+
/* @__PURE__ */ jsx(TOCScrollArea, { children: /* @__PURE__ */ jsxs(TOCItems, {
|
|
27
|
+
...list,
|
|
28
|
+
children: [items.length === 0 && /* @__PURE__ */ jsx(TOCEmpty, {}), items.map((item) => /* @__PURE__ */ jsx(TOCItem, { item }, item.url))]
|
|
29
|
+
}) }),
|
|
27
30
|
footer
|
|
28
31
|
]
|
|
29
32
|
}), /* @__PURE__ */ jsx(PageTOCPopoverTrigger, { ...trigger })]
|
|
@@ -35,20 +35,20 @@ interface FooterOptions extends FooterProps {
|
|
|
35
35
|
*/
|
|
36
36
|
component?: ReactNode;
|
|
37
37
|
}
|
|
38
|
-
|
|
38
|
+
type TableOfContentOptions = Pick<TOCProviderProps, 'single'> & TOCProps & {
|
|
39
39
|
enabled?: boolean;
|
|
40
40
|
/**
|
|
41
41
|
* @deprecated use `slots.toc` instead.
|
|
42
42
|
*/
|
|
43
43
|
component?: ReactNode;
|
|
44
|
-
}
|
|
45
|
-
|
|
44
|
+
};
|
|
45
|
+
type TableOfContentPopoverOptions = TOCPopoverProps & {
|
|
46
46
|
enabled?: boolean;
|
|
47
47
|
/**
|
|
48
48
|
* @deprecated use `slots.tocPopover` instead.
|
|
49
49
|
*/
|
|
50
50
|
component?: ReactNode;
|
|
51
|
-
}
|
|
51
|
+
};
|
|
52
52
|
interface DocsPageSlots {
|
|
53
53
|
toc: {
|
|
54
54
|
provider: FC<TOCProviderProps>;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { TOCItemsProps } from "../../../../components/toc/clerk.js";
|
|
2
|
+
import { TOCItemsProps as TOCItemsProps$1 } from "../../../../components/toc/default.js";
|
|
1
3
|
import { TOCProviderProps as TOCProviderProps$1 } from "../../../../components/toc/index.js";
|
|
2
4
|
import { ComponentProps, ReactNode } from "react";
|
|
3
5
|
import * as _$react_jsx_runtime0 from "react/jsx-runtime";
|
|
@@ -5,7 +7,7 @@ import * as _$react_jsx_runtime0 from "react/jsx-runtime";
|
|
|
5
7
|
//#region src/layouts/notebook/page/slots/toc.d.ts
|
|
6
8
|
type TOCProviderProps = TOCProviderProps$1;
|
|
7
9
|
declare function TOCProvider(props: TOCProviderProps): _$react_jsx_runtime0.JSX.Element;
|
|
8
|
-
|
|
10
|
+
type TOCProps = {
|
|
9
11
|
container?: ComponentProps<'div'>;
|
|
10
12
|
/**
|
|
11
13
|
* Custom content in TOC container, before the main TOC
|
|
@@ -15,18 +17,21 @@ interface TOCProps {
|
|
|
15
17
|
* Custom content in TOC container, after the main TOC
|
|
16
18
|
*/
|
|
17
19
|
footer?: ReactNode;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
} & ({
|
|
21
|
+
style?: 'normal';
|
|
22
|
+
list?: TOCItemsProps$1;
|
|
23
|
+
} | {
|
|
24
|
+
style: 'clerk';
|
|
25
|
+
list?: TOCItemsProps;
|
|
26
|
+
});
|
|
23
27
|
declare function TOC({
|
|
24
28
|
container,
|
|
25
29
|
header,
|
|
26
30
|
footer,
|
|
27
|
-
style
|
|
31
|
+
style,
|
|
32
|
+
list
|
|
28
33
|
}: TOCProps): _$react_jsx_runtime0.JSX.Element;
|
|
29
|
-
|
|
34
|
+
type TOCPopoverProps = {
|
|
30
35
|
container?: ComponentProps<'div'>;
|
|
31
36
|
trigger?: ComponentProps<'button'>;
|
|
32
37
|
content?: ComponentProps<'div'>;
|
|
@@ -38,18 +43,21 @@ interface TOCPopoverProps {
|
|
|
38
43
|
* Custom content in TOC container, after the main TOC
|
|
39
44
|
*/
|
|
40
45
|
footer?: ReactNode;
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
+
} & ({
|
|
47
|
+
style?: 'normal';
|
|
48
|
+
list?: TOCItemsProps$1;
|
|
49
|
+
} | {
|
|
50
|
+
style: 'clerk';
|
|
51
|
+
list?: TOCItemsProps;
|
|
52
|
+
});
|
|
46
53
|
declare function TOCPopover({
|
|
47
54
|
container,
|
|
48
55
|
trigger,
|
|
49
56
|
content,
|
|
50
57
|
header,
|
|
51
58
|
footer,
|
|
52
|
-
style
|
|
59
|
+
style,
|
|
60
|
+
list
|
|
53
61
|
}: TOCPopoverProps): _$react_jsx_runtime0.JSX.Element;
|
|
54
62
|
//#endregion
|
|
55
63
|
export { TOC, TOCPopover, TOCPopoverProps, TOCProps, TOCProvider, TOCProviderProps };
|
|
@@ -14,7 +14,7 @@ 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 = "normal" }) {
|
|
17
|
+
function TOC({ container, header, footer, style = "normal", list }) {
|
|
18
18
|
const items = useTOCItems();
|
|
19
19
|
const { TOCItems, TOCEmpty, TOCItem } = style === "clerk" ? clerk_exports : default_exports;
|
|
20
20
|
return /* @__PURE__ */ jsxs("div", {
|
|
@@ -28,13 +28,16 @@ function TOC({ container, header, footer, style = "normal" }) {
|
|
|
28
28
|
className: "inline-flex items-center gap-1.5 text-sm text-fd-muted-foreground",
|
|
29
29
|
children: [/* @__PURE__ */ jsx(Text, { className: "size-4" }), /* @__PURE__ */ jsx(I18nLabel, { label: "toc" })]
|
|
30
30
|
}),
|
|
31
|
-
/* @__PURE__ */ jsx(TOCScrollArea, { children: /* @__PURE__ */ jsxs(TOCItems, {
|
|
31
|
+
/* @__PURE__ */ jsx(TOCScrollArea, { children: /* @__PURE__ */ jsxs(TOCItems, {
|
|
32
|
+
...list,
|
|
33
|
+
children: [items.length === 0 && /* @__PURE__ */ jsx(TOCEmpty, {}), items.map((item) => /* @__PURE__ */ jsx(TOCItem, { item }, item.url))]
|
|
34
|
+
}) }),
|
|
32
35
|
footer
|
|
33
36
|
]
|
|
34
37
|
});
|
|
35
38
|
}
|
|
36
39
|
const TocPopoverContext = createContext(null);
|
|
37
|
-
function TOCPopover({ container, trigger, content, header, footer, style = "normal" }) {
|
|
40
|
+
function TOCPopover({ container, trigger, content, header, footer, style = "normal", list }) {
|
|
38
41
|
const items = useTOCItems();
|
|
39
42
|
const ref = useRef(null);
|
|
40
43
|
const [open, setOpen] = useState(false);
|
|
@@ -71,10 +74,13 @@ function TOCPopover({ container, trigger, content, header, footer, style = "norm
|
|
|
71
74
|
...content,
|
|
72
75
|
children: [
|
|
73
76
|
header,
|
|
74
|
-
/* @__PURE__ */ jsx(TOCScrollArea, { children: /* @__PURE__ */ jsxs(TOCItems, {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
77
|
+
/* @__PURE__ */ jsx(TOCScrollArea, { children: /* @__PURE__ */ jsxs(TOCItems, {
|
|
78
|
+
...list,
|
|
79
|
+
children: [items.length === 0 && /* @__PURE__ */ jsx(TOCEmpty, {}), items.map((item) => /* @__PURE__ */ jsx(TOCItem, {
|
|
80
|
+
item,
|
|
81
|
+
onClick: onClickItem
|
|
82
|
+
}, item.url))]
|
|
83
|
+
}) }),
|
|
78
84
|
footer
|
|
79
85
|
]
|
|
80
86
|
})]
|
package/dist/style.css
CHANGED
|
@@ -763,20 +763,6 @@
|
|
|
763
763
|
:where(thead th code):not(:where([class~="not-prose"],[class~="not-prose"] *)) {
|
|
764
764
|
color: inherit;
|
|
765
765
|
}
|
|
766
|
-
:where(table):not(:where([class~="not-prose"],[class~="not-prose"] *)) {
|
|
767
|
-
font-size: 0.875em;
|
|
768
|
-
line-height: 1.7142857;
|
|
769
|
-
width: 100%;
|
|
770
|
-
table-layout: auto;
|
|
771
|
-
margin-top: 2em;
|
|
772
|
-
margin-bottom: 2em;
|
|
773
|
-
border-collapse: separate;
|
|
774
|
-
border-spacing: 0;
|
|
775
|
-
background: var(--color-fd-card);
|
|
776
|
-
border-radius: var(--radius-lg);
|
|
777
|
-
border: 1px solid var(--color-fd-border);
|
|
778
|
-
overflow: hidden;
|
|
779
|
-
}
|
|
780
766
|
:where(thead th):not(:where([class~="not-prose"],[class~="not-prose"] *)) {
|
|
781
767
|
color: var(--tw-prose-headings);
|
|
782
768
|
font-weight: 600;
|
|
@@ -835,6 +821,20 @@
|
|
|
835
821
|
:where(.prose > :last-child):not(:where([class~="not-prose"],[class~="not-prose"] *)) {
|
|
836
822
|
margin-bottom: 0;
|
|
837
823
|
}
|
|
824
|
+
:where(table):not(:where([class~="not-prose"],[class~="not-prose"] *)) {
|
|
825
|
+
font-size: 0.875em;
|
|
826
|
+
line-height: 1.7142857;
|
|
827
|
+
width: 100%;
|
|
828
|
+
table-layout: auto;
|
|
829
|
+
margin-top: 2em;
|
|
830
|
+
margin-bottom: 2em;
|
|
831
|
+
border-collapse: separate;
|
|
832
|
+
border-spacing: 0;
|
|
833
|
+
background: var(--color-fd-card);
|
|
834
|
+
border-radius: var(--radius-lg);
|
|
835
|
+
border: 1px solid var(--color-fd-border);
|
|
836
|
+
overflow: hidden;
|
|
837
|
+
}
|
|
838
838
|
:where(th):not(:where([class~="not-prose"],[class~="not-prose"] *)) {
|
|
839
839
|
text-align: start;
|
|
840
840
|
padding: calc(var(--spacing) * 2.5);
|
|
@@ -1894,6 +1894,11 @@
|
|
|
1894
1894
|
transition-timing-function: var(--tw-ease, var(--default-transition-timing-function));
|
|
1895
1895
|
transition-duration: var(--tw-duration, var(--default-transition-duration));
|
|
1896
1896
|
}
|
|
1897
|
+
.transition-\[offset-distance\] {
|
|
1898
|
+
transition-property: offset-distance;
|
|
1899
|
+
transition-timing-function: var(--tw-ease, var(--default-transition-timing-function));
|
|
1900
|
+
transition-duration: var(--tw-duration, var(--default-transition-duration));
|
|
1901
|
+
}
|
|
1897
1902
|
.transition-\[opacity\,translate\,color\] {
|
|
1898
1903
|
transition-property: opacity,translate,color;
|
|
1899
1904
|
transition-timing-function: var(--tw-ease, var(--default-transition-timing-function));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fumadocs-ui",
|
|
3
|
-
"version": "16.7.
|
|
3
|
+
"version": "16.7.13",
|
|
4
4
|
"description": "The Radix UI version of Fumadocs UI",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Docs",
|
|
@@ -135,32 +135,32 @@
|
|
|
135
135
|
"@radix-ui/react-slot": "^1.2.4",
|
|
136
136
|
"@radix-ui/react-tabs": "^1.1.13",
|
|
137
137
|
"class-variance-authority": "^0.7.1",
|
|
138
|
-
"
|
|
139
|
-
"lucide-react": "^1.7.0",
|
|
138
|
+
"lucide-react": "^1.8.0",
|
|
140
139
|
"motion": "^12.38.0",
|
|
141
140
|
"next-themes": "^0.4.6",
|
|
142
|
-
"react-medium-image-zoom": "^5.4.3",
|
|
143
141
|
"react-remove-scroll": "^2.7.2",
|
|
144
142
|
"rehype-raw": "^7.0.0",
|
|
145
143
|
"scroll-into-view-if-needed": "^3.1.0",
|
|
146
144
|
"tailwind-merge": "^3.5.0",
|
|
147
145
|
"unist-util-visit": "^5.1.0",
|
|
148
|
-
"@fumadocs/tailwind": "0.0.
|
|
146
|
+
"@fumadocs/tailwind": "0.0.4"
|
|
149
147
|
},
|
|
150
148
|
"devDependencies": {
|
|
151
149
|
"@tailwindcss/cli": "^4.2.2",
|
|
152
150
|
"@tsdown/css": "^0.21.6",
|
|
153
151
|
"@types/hast": "^3.0.4",
|
|
154
152
|
"@types/mdx": "^2.0.13",
|
|
155
|
-
"@types/node": "^25.
|
|
153
|
+
"@types/node": "^25.6.0",
|
|
156
154
|
"@types/react": "^19.2.14",
|
|
157
155
|
"@types/react-dom": "^19.2.3",
|
|
156
|
+
"fuma-cli": "^0.0.5",
|
|
157
|
+
"react-medium-image-zoom": "^5.4.3",
|
|
158
158
|
"shiki": "^4.0.2",
|
|
159
159
|
"tailwindcss": "^4.2.2",
|
|
160
160
|
"tsdown": "0.21.7",
|
|
161
161
|
"unified": "^11.0.5",
|
|
162
|
-
"@fumadocs/cli": "1.3.
|
|
163
|
-
"fumadocs-core": "16.7.
|
|
162
|
+
"@fumadocs/cli": "1.3.6",
|
|
163
|
+
"fumadocs-core": "16.7.13",
|
|
164
164
|
"tsconfig": "0.0.0"
|
|
165
165
|
},
|
|
166
166
|
"peerDependencies": {
|
|
@@ -171,7 +171,7 @@
|
|
|
171
171
|
"react": "^19.2.0",
|
|
172
172
|
"react-dom": "^19.2.0",
|
|
173
173
|
"shiki": "*",
|
|
174
|
-
"fumadocs-core": "16.7.
|
|
174
|
+
"fumadocs-core": "16.7.13"
|
|
175
175
|
},
|
|
176
176
|
"peerDependenciesMeta": {
|
|
177
177
|
"next": {
|
|
@@ -190,6 +190,9 @@
|
|
|
190
190
|
"optional": true
|
|
191
191
|
}
|
|
192
192
|
},
|
|
193
|
+
"inlinedDependencies": {
|
|
194
|
+
"react-medium-image-zoom": "5.4.3"
|
|
195
|
+
},
|
|
193
196
|
"scripts": {
|
|
194
197
|
"build": "pnpm build:layout && pnpm build:tailwind",
|
|
195
198
|
"build:layout": "tsdown --config-loader unrun",
|