@fumadocs/base-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 +5 -2
- 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
|
@@ -24,8 +24,6 @@
|
|
|
24
24
|
@source inline("--easing");
|
|
25
25
|
@source inline("--fd-animated-height");
|
|
26
26
|
@source inline("--fd-banner-height");
|
|
27
|
-
@source inline("--fd-height");
|
|
28
|
-
@source inline("--fd-top");
|
|
29
27
|
@source inline("--padding-right");
|
|
30
28
|
@source inline("--popup-height");
|
|
31
29
|
@source inline("--popup-width");
|
|
@@ -212,6 +210,7 @@
|
|
|
212
210
|
@source inline("component");
|
|
213
211
|
@source inline("components");
|
|
214
212
|
@source inline("composedRef");
|
|
213
|
+
@source inline("computed");
|
|
215
214
|
@source inline("config");
|
|
216
215
|
@source inline("const");
|
|
217
216
|
@source inline("container");
|
|
@@ -281,7 +280,6 @@
|
|
|
281
280
|
@source inline("data-ending-style:h-0");
|
|
282
281
|
@source inline("data-ending-style:opacity-0");
|
|
283
282
|
@source inline("data-ending-style:scale-90");
|
|
284
|
-
@source inline("data-hidden");
|
|
285
283
|
@source inline("data-icon");
|
|
286
284
|
@source inline("data-instant:transition-none");
|
|
287
285
|
@source inline("data-line-numbers");
|
|
@@ -551,6 +549,7 @@
|
|
|
551
549
|
@source inline("isWindows");
|
|
552
550
|
@source inline("it");
|
|
553
551
|
@source inline("item");
|
|
552
|
+
@source inline("itemLineLengths");
|
|
554
553
|
@source inline("itemVariants");
|
|
555
554
|
@source inline("items");
|
|
556
555
|
@source inline("items-center");
|
|
@@ -563,6 +562,7 @@
|
|
|
563
562
|
@source inline("key");
|
|
564
563
|
@source inline("keydown");
|
|
565
564
|
@source inline("keyof");
|
|
565
|
+
@source inline("l");
|
|
566
566
|
@source inline("label");
|
|
567
567
|
@source inline("lang");
|
|
568
568
|
@source inline("language");
|
|
@@ -715,12 +715,15 @@
|
|
|
715
715
|
@source inline("of");
|
|
716
716
|
@source inline("official");
|
|
717
717
|
@source inline("offset");
|
|
718
|
+
@source inline("offsetDistance");
|
|
719
|
+
@source inline("offsetPath");
|
|
718
720
|
@source inline("offsetTop");
|
|
719
721
|
@source inline("on");
|
|
720
722
|
@source inline("onAnimationEnd");
|
|
721
723
|
@source inline("onChange");
|
|
722
724
|
@source inline("onChangeRef");
|
|
723
725
|
@source inline("onClick");
|
|
726
|
+
@source inline("onCompute");
|
|
724
727
|
@source inline("onCopy");
|
|
725
728
|
@source inline("onKey");
|
|
726
729
|
@source inline("onKeyDown");
|
|
@@ -730,7 +733,6 @@
|
|
|
730
733
|
@source inline("onPointerLeave");
|
|
731
734
|
@source inline("onPointerMove");
|
|
732
735
|
@source inline("onPrint");
|
|
733
|
-
@source inline("onResize");
|
|
734
736
|
@source inline("onSearchChange");
|
|
735
737
|
@source inline("onSearchChangeCallback");
|
|
736
738
|
@source inline("onSelect");
|
|
@@ -795,6 +797,7 @@
|
|
|
795
797
|
@source inline("placeholder:text-fd-muted-foreground");
|
|
796
798
|
@source inline("please");
|
|
797
799
|
@source inline("pointerType");
|
|
800
|
+
@source inline("positions");
|
|
798
801
|
@source inline("possible");
|
|
799
802
|
@source inline("powered");
|
|
800
803
|
@source inline("pre");
|
|
@@ -936,6 +939,7 @@
|
|
|
936
939
|
@source inline("setActive");
|
|
937
940
|
@source inline("setChecked");
|
|
938
941
|
@source inline("setCollapsed");
|
|
942
|
+
@source inline("setComputed");
|
|
939
943
|
@source inline("setHidden");
|
|
940
944
|
@source inline("setHover");
|
|
941
945
|
@source inline("setIsOpen");
|
|
@@ -1055,7 +1059,7 @@
|
|
|
1055
1059
|
@source inline("themes");
|
|
1056
1060
|
@source inline("this");
|
|
1057
1061
|
@source inline("throw");
|
|
1058
|
-
@source inline("
|
|
1062
|
+
@source inline("thumbBox");
|
|
1059
1063
|
@source inline("tier");
|
|
1060
1064
|
@source inline("timeoutRef");
|
|
1061
1065
|
@source inline("timerRef");
|
|
@@ -1073,18 +1077,19 @@
|
|
|
1073
1077
|
@source inline("top-2.5");
|
|
1074
1078
|
@source inline("top-4");
|
|
1075
1079
|
@source inline("top-[calc(50%-var(--t,0px)+var(--b,0px))]");
|
|
1080
|
+
@source inline("topL");
|
|
1076
1081
|
@source inline("touch");
|
|
1077
1082
|
@source inline("transform");
|
|
1078
1083
|
@source inline("transition-[clip-path]");
|
|
1079
1084
|
@source inline("transition-[height,opacity]");
|
|
1080
1085
|
@source inline("transition-[height]");
|
|
1086
|
+
@source inline("transition-[offset-distance]");
|
|
1081
1087
|
@source inline("transition-[opacity,transform,translate]");
|
|
1082
1088
|
@source inline("transition-[opacity,transform,width,height,scale,translate]");
|
|
1083
1089
|
@source inline("transition-all");
|
|
1084
1090
|
@source inline("transition-colors");
|
|
1085
1091
|
@source inline("transition-opacity");
|
|
1086
1092
|
@source inline("transition-transform");
|
|
1087
|
-
@source inline("translate");
|
|
1088
1093
|
@source inline("translations");
|
|
1089
1094
|
@source inline("transparent");
|
|
1090
1095
|
@source inline("tree");
|
|
@@ -1109,8 +1114,6 @@
|
|
|
1109
1114
|
@source inline("updateAnchor");
|
|
1110
1115
|
@source inline("updated");
|
|
1111
1116
|
@source inline("updates");
|
|
1112
|
-
@source inline("upper");
|
|
1113
|
-
@source inline("upperBottom");
|
|
1114
1117
|
@source inline("upperOffset");
|
|
1115
1118
|
@source inline("upperX");
|
|
1116
1119
|
@source inline("url");
|
|
@@ -1176,6 +1179,7 @@
|
|
|
1176
1179
|
@source inline("when");
|
|
1177
1180
|
@source inline("where");
|
|
1178
1181
|
@source inline("whether");
|
|
1182
|
+
@source inline("while");
|
|
1179
1183
|
@source inline("white");
|
|
1180
1184
|
@source inline("whitespace-nowrap");
|
|
1181
1185
|
@source inline("whitespaces");
|
|
@@ -1191,6 +1195,7 @@
|
|
|
1191
1195
|
@source inline("wrapped");
|
|
1192
1196
|
@source inline("x");
|
|
1193
1197
|
@source inline("xmlns");
|
|
1198
|
+
@source inline("y");
|
|
1194
1199
|
@source inline("you");
|
|
1195
1200
|
@source inline("your");
|
|
1196
1201
|
@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 };
|
|
@@ -14,7 +14,7 @@ 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
|
@@ -747,20 +747,6 @@
|
|
|
747
747
|
:where(thead th code):not(:where([class~="not-prose"],[class~="not-prose"] *)) {
|
|
748
748
|
color: inherit;
|
|
749
749
|
}
|
|
750
|
-
:where(table):not(:where([class~="not-prose"],[class~="not-prose"] *)) {
|
|
751
|
-
font-size: 0.875em;
|
|
752
|
-
line-height: 1.7142857;
|
|
753
|
-
width: 100%;
|
|
754
|
-
table-layout: auto;
|
|
755
|
-
margin-top: 2em;
|
|
756
|
-
margin-bottom: 2em;
|
|
757
|
-
border-collapse: separate;
|
|
758
|
-
border-spacing: 0;
|
|
759
|
-
background: var(--color-fd-card);
|
|
760
|
-
border-radius: var(--radius-lg);
|
|
761
|
-
border: 1px solid var(--color-fd-border);
|
|
762
|
-
overflow: hidden;
|
|
763
|
-
}
|
|
764
750
|
:where(thead th):not(:where([class~="not-prose"],[class~="not-prose"] *)) {
|
|
765
751
|
color: var(--tw-prose-headings);
|
|
766
752
|
font-weight: 600;
|
|
@@ -819,6 +805,20 @@
|
|
|
819
805
|
:where(.prose > :last-child):not(:where([class~="not-prose"],[class~="not-prose"] *)) {
|
|
820
806
|
margin-bottom: 0;
|
|
821
807
|
}
|
|
808
|
+
:where(table):not(:where([class~="not-prose"],[class~="not-prose"] *)) {
|
|
809
|
+
font-size: 0.875em;
|
|
810
|
+
line-height: 1.7142857;
|
|
811
|
+
width: 100%;
|
|
812
|
+
table-layout: auto;
|
|
813
|
+
margin-top: 2em;
|
|
814
|
+
margin-bottom: 2em;
|
|
815
|
+
border-collapse: separate;
|
|
816
|
+
border-spacing: 0;
|
|
817
|
+
background: var(--color-fd-card);
|
|
818
|
+
border-radius: var(--radius-lg);
|
|
819
|
+
border: 1px solid var(--color-fd-border);
|
|
820
|
+
overflow: hidden;
|
|
821
|
+
}
|
|
822
822
|
:where(th):not(:where([class~="not-prose"],[class~="not-prose"] *)) {
|
|
823
823
|
text-align: start;
|
|
824
824
|
padding: calc(var(--spacing) * 2.5);
|
|
@@ -1885,6 +1885,11 @@
|
|
|
1885
1885
|
transition-timing-function: var(--tw-ease, var(--default-transition-timing-function));
|
|
1886
1886
|
transition-duration: var(--tw-duration, var(--default-transition-duration));
|
|
1887
1887
|
}
|
|
1888
|
+
.transition-\[offset-distance\] {
|
|
1889
|
+
transition-property: offset-distance;
|
|
1890
|
+
transition-timing-function: var(--tw-ease, var(--default-transition-timing-function));
|
|
1891
|
+
transition-duration: var(--tw-duration, var(--default-transition-duration));
|
|
1892
|
+
}
|
|
1888
1893
|
.transition-\[opacity\,transform\,translate\] {
|
|
1889
1894
|
transition-property: opacity,transform,translate;
|
|
1890
1895
|
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/base-ui",
|
|
3
|
-
"version": "16.7.
|
|
3
|
+
"version": "16.7.13",
|
|
4
4
|
"description": "The Base UI version of Fumadocs UI",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Docs",
|
|
@@ -118,32 +118,32 @@
|
|
|
118
118
|
"dependencies": {
|
|
119
119
|
"@base-ui/react": "^1.3.0",
|
|
120
120
|
"class-variance-authority": "^0.7.1",
|
|
121
|
-
"
|
|
122
|
-
"lucide-react": "^1.7.0",
|
|
121
|
+
"lucide-react": "^1.8.0",
|
|
123
122
|
"motion": "^12.38.0",
|
|
124
123
|
"next-themes": "^0.4.6",
|
|
125
|
-
"react-medium-image-zoom": "^5.4.3",
|
|
126
124
|
"react-remove-scroll": "^2.7.2",
|
|
127
125
|
"rehype-raw": "^7.0.0",
|
|
128
126
|
"scroll-into-view-if-needed": "^3.1.0",
|
|
129
127
|
"tailwind-merge": "^3.5.0",
|
|
130
128
|
"unist-util-visit": "^5.1.0",
|
|
131
|
-
"@fumadocs/tailwind": "0.0.
|
|
129
|
+
"@fumadocs/tailwind": "0.0.4"
|
|
132
130
|
},
|
|
133
131
|
"devDependencies": {
|
|
134
132
|
"@tailwindcss/cli": "^4.2.2",
|
|
135
133
|
"@tsdown/css": "^0.21.6",
|
|
136
134
|
"@types/hast": "^3.0.4",
|
|
137
135
|
"@types/mdx": "^2.0.13",
|
|
138
|
-
"@types/node": "^25.
|
|
136
|
+
"@types/node": "^25.6.0",
|
|
139
137
|
"@types/react": "^19.2.14",
|
|
140
138
|
"@types/react-dom": "^19.2.3",
|
|
139
|
+
"fuma-cli": "^0.0.5",
|
|
140
|
+
"react-medium-image-zoom": "^5.4.3",
|
|
141
141
|
"shiki": "^4.0.2",
|
|
142
142
|
"tailwindcss": "^4.2.2",
|
|
143
143
|
"tsdown": "0.21.7",
|
|
144
144
|
"unified": "^11.0.5",
|
|
145
|
-
"@fumadocs/cli": "1.3.
|
|
146
|
-
"fumadocs-core": "16.7.
|
|
145
|
+
"@fumadocs/cli": "1.3.6",
|
|
146
|
+
"fumadocs-core": "16.7.13",
|
|
147
147
|
"tsconfig": "0.0.0"
|
|
148
148
|
},
|
|
149
149
|
"peerDependencies": {
|
|
@@ -154,7 +154,7 @@
|
|
|
154
154
|
"react": "^19.2.0",
|
|
155
155
|
"react-dom": "^19.2.0",
|
|
156
156
|
"shiki": "*",
|
|
157
|
-
"fumadocs-core": "16.7.
|
|
157
|
+
"fumadocs-core": "16.7.13"
|
|
158
158
|
},
|
|
159
159
|
"peerDependenciesMeta": {
|
|
160
160
|
"shiki": {
|
|
@@ -173,6 +173,9 @@
|
|
|
173
173
|
"optional": true
|
|
174
174
|
}
|
|
175
175
|
},
|
|
176
|
+
"inlinedDependencies": {
|
|
177
|
+
"react-medium-image-zoom": "5.4.3"
|
|
178
|
+
},
|
|
176
179
|
"scripts": {
|
|
177
180
|
"build": "pnpm build:layout && pnpm build:tailwind",
|
|
178
181
|
"build:layout": "tsdown --config-loader unrun",
|