fumadocs-ui 16.7.12 → 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.
@@ -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");
@@ -269,7 +267,6 @@
269
267
  @source inline("data-checked:text-fd-accent-foreground");
270
268
  @source inline("data-collapsed");
271
269
  @source inline("data-empty");
272
- @source inline("data-hidden");
273
270
  @source inline("data-icon");
274
271
  @source inline("data-line-numbers");
275
272
  @source inline("data-line-numbers-start");
@@ -692,7 +689,7 @@
692
689
  @source inline("onChange");
693
690
  @source inline("onChangeRef");
694
691
  @source inline("onClick");
695
- @source inline("onContainerResize");
692
+ @source inline("onCompute");
696
693
  @source inline("onCopy");
697
694
  @source inline("onKey");
698
695
  @source inline("onKeyDown");
@@ -702,7 +699,6 @@
702
699
  @source inline("onPointerLeave");
703
700
  @source inline("onPointerMove");
704
701
  @source inline("onPrint");
705
- @source inline("onResize");
706
702
  @source inline("onSearchChange");
707
703
  @source inline("onSearchChangeCallback");
708
704
  @source inline("onSelect");
@@ -908,6 +904,7 @@
908
904
  @source inline("setActive");
909
905
  @source inline("setChecked");
910
906
  @source inline("setCollapsed");
907
+ @source inline("setComputed");
911
908
  @source inline("setHover");
912
909
  @source inline("setIsOpen");
913
910
  @source inline("setIsTop");
@@ -1029,7 +1026,6 @@
1029
1026
  @source inline("this");
1030
1027
  @source inline("throw");
1031
1028
  @source inline("thumbBox");
1032
- @source inline("thumbRef");
1033
1029
  @source inline("tier");
1034
1030
  @source inline("timeoutRef");
1035
1031
  @source inline("timerRef");
@@ -1082,7 +1078,6 @@
1082
1078
  @source inline("updateAnchor");
1083
1079
  @source inline("updated");
1084
1080
  @source inline("updates");
1085
- @source inline("upper");
1086
1081
  @source inline("upperOffset");
1087
1082
  @source inline("upperX");
1088
1083
  @source inline("url");
@@ -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(Zoom, {
16
+ return /* @__PURE__ */ jsx(Uncontrolled, {
17
17
  zoomMargin: 20,
18
18
  wrapElement: "span",
19
19
  ...rmiz,
@@ -3,7 +3,7 @@ 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 { TocThumb, useTOCItems } from "./index.js";
6
+ import { useTOCItems } from "./index.js";
7
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";
@@ -31,7 +31,7 @@ function TOCItems({ ref, className, thumbBox = true, ...props }) {
31
31
  const output = [];
32
32
  for (let i = 0; i < items.length; i++) {
33
33
  const item = items[i];
34
- const element = container.querySelector(`a[href="#${item.url.slice(1)}"]`);
34
+ const element = container.querySelector(`a[href="${item.url}"]`);
35
35
  if (!element) continue;
36
36
  const styles = getComputedStyle(element);
37
37
  const x = getLineOffset(item.depth) + .5;
@@ -91,31 +91,27 @@ function TOCItems({ ref, className, thumbBox = true, ...props }) {
91
91
  width: w,
92
92
  height: h,
93
93
  d,
94
- itemLineLengths
94
+ itemLineLengths,
95
+ positions
95
96
  });
96
97
  }, [items, thumbBox]);
97
98
  useEffect(() => {
99
+ const container = containerRef.current;
100
+ if (!container) return;
101
+ const observer = new ResizeObserver(onPrint);
102
+ observer.observe(container);
98
103
  onPrint();
104
+ return () => {
105
+ observer.unobserve(container);
106
+ };
99
107
  }, [onPrint]);
100
- return /* @__PURE__ */ jsxs(Fragment$1, { children: [svg && /* @__PURE__ */ jsxs(TocThumb, {
101
- containerRef,
102
- onContainerResize: onPrint,
108
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [svg && /* @__PURE__ */ jsxs("div", {
103
109
  className: "absolute top-0 inset-s-0",
104
110
  style: {
105
111
  width: svg.width,
106
112
  height: svg.height
107
113
  },
108
- children: [/* @__PURE__ */ jsx("svg", {
109
- xmlns: "http://www.w3.org/2000/svg",
110
- viewBox: `0 0 ${svg.width} ${svg.height}`,
111
- className: "absolute transition-[clip-path]",
112
- style: {
113
- width: svg.width,
114
- height: svg.height,
115
- 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)))`
116
- },
117
- children: svg.content
118
- }), thumbBox && /* @__PURE__ */ jsx(ThumbBox, { computed: svg })]
114
+ children: [/* @__PURE__ */ jsx(ThumbTrack, { computed: svg }), thumbBox && /* @__PURE__ */ jsx(ThumbBox, { computed: svg })]
119
115
  }), /* @__PURE__ */ jsx("div", {
120
116
  ref: mergeRefs(containerRef, ref),
121
117
  className: cn("flex flex-col", className),
@@ -129,6 +125,25 @@ function TOCEmpty() {
129
125
  children: text.tocNoHeadings
130
126
  });
131
127
  }
128
+ function ThumbTrack({ computed }) {
129
+ const items = Primitive.useItems();
130
+ const startIdx = items.findIndex((item) => item.active);
131
+ if (startIdx === -1) return;
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
+ }
132
147
  function ThumbBox({ computed }) {
133
148
  const items = Primitive.useItems();
134
149
  const previousRef = useRef(null);
@@ -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 { TocThumb } from "./index.js";
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, RefObject } from "react";
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,14 +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
- onContainerResize?: () => void;
22
- }
23
- declare function TocThumb({
24
- containerRef,
25
- onContainerResize,
26
- ...props
27
- }: TocThumbProps): _$react_jsx_runtime0.JSX.Element;
28
19
  //#endregion
29
- export { TOCProvider, TOCProviderProps, TOCScrollArea, TocThumb, useActiveAnchor, useActiveAnchors, useItems, useTOCItems };
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, useEffect, useEffectEvent, useRef } from "react";
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,60 +41,5 @@ function TOCScrollArea({ ref, className, ...props }) {
43
41
  })
44
42
  });
45
43
  }
46
- function TocThumb({ containerRef, onContainerResize, ...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 onResize = useEffectEvent(() => {
78
- const result = calc(active);
79
- if (result) update(result);
80
- onContainerResize?.();
81
- });
82
- useEffect(() => {
83
- if (!containerRef.current) return;
84
- const container = containerRef.current;
85
- const observer = new ResizeObserver(onResize);
86
- observer.observe(container);
87
- return () => {
88
- observer.disconnect();
89
- };
90
- }, [containerRef]);
91
- useOnChange(active, () => {
92
- const result = calc(active);
93
- if (result) update(result);
94
- });
95
- return /* @__PURE__ */ jsx("div", {
96
- ref: thumbRef,
97
- "data-hidden": active.length === 0,
98
- ...props
99
- });
100
- }
101
44
  //#endregion
102
- export { TOCProvider, TOCScrollArea, TocThumb, toc_exports, useActiveAnchor, useActiveAnchors, useItems, useTOCItems };
45
+ export { TOCProvider, TOCScrollArea, toc_exports, useActiveAnchor, useActiveAnchors, useItems, useTOCItems };
@@ -9,8 +9,8 @@ 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;
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);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fumadocs-ui",
3
- "version": "16.7.12",
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
- "fuma-cli": "^0.0.3",
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.3"
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.5.2",
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.5",
163
- "fumadocs-core": "16.7.12",
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.12"
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",