@fumadocs/base-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.
@@ -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");
@@ -282,7 +280,6 @@
282
280
  @source inline("data-ending-style:h-0");
283
281
  @source inline("data-ending-style:opacity-0");
284
282
  @source inline("data-ending-style:scale-90");
285
- @source inline("data-hidden");
286
283
  @source inline("data-icon");
287
284
  @source inline("data-instant:transition-none");
288
285
  @source inline("data-line-numbers");
@@ -726,7 +723,7 @@
726
723
  @source inline("onChange");
727
724
  @source inline("onChangeRef");
728
725
  @source inline("onClick");
729
- @source inline("onContainerResize");
726
+ @source inline("onCompute");
730
727
  @source inline("onCopy");
731
728
  @source inline("onKey");
732
729
  @source inline("onKeyDown");
@@ -736,7 +733,6 @@
736
733
  @source inline("onPointerLeave");
737
734
  @source inline("onPointerMove");
738
735
  @source inline("onPrint");
739
- @source inline("onResize");
740
736
  @source inline("onSearchChange");
741
737
  @source inline("onSearchChangeCallback");
742
738
  @source inline("onSelect");
@@ -943,6 +939,7 @@
943
939
  @source inline("setActive");
944
940
  @source inline("setChecked");
945
941
  @source inline("setCollapsed");
942
+ @source inline("setComputed");
946
943
  @source inline("setHidden");
947
944
  @source inline("setHover");
948
945
  @source inline("setIsOpen");
@@ -1063,7 +1060,6 @@
1063
1060
  @source inline("this");
1064
1061
  @source inline("throw");
1065
1062
  @source inline("thumbBox");
1066
- @source inline("thumbRef");
1067
1063
  @source inline("tier");
1068
1064
  @source inline("timeoutRef");
1069
1065
  @source inline("timerRef");
@@ -1118,7 +1114,6 @@
1118
1114
  @source inline("updateAnchor");
1119
1115
  @source inline("updated");
1120
1116
  @source inline("updates");
1121
- @source inline("upper");
1122
1117
  @source inline("upperOffset");
1123
1118
  @source inline("upperX");
1124
1119
  @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 };
@@ -5,7 +5,7 @@ import * as _$class_variance_authority_types0 from "class-variance-authority/typ
5
5
  declare const buttonVariants: (props?: ({
6
6
  variant?: "primary" | "outline" | "ghost" | "secondary" | null | undefined;
7
7
  color?: "primary" | "outline" | "ghost" | "secondary" | null | undefined;
8
- size?: "icon" | "sm" | "icon-sm" | "icon-xs" | null | undefined;
8
+ size?: "sm" | "icon" | "icon-sm" | "icon-xs" | null | undefined;
9
9
  } & _$class_variance_authority_types0.ClassProp) | undefined) => string;
10
10
  type ButtonProps = VariantProps<typeof buttonVariants>;
11
11
  //#endregion
@@ -4,7 +4,7 @@ import * as _$class_variance_authority_types0 from "class-variance-authority/typ
4
4
 
5
5
  //#region src/layouts/home/slots/header.d.ts
6
6
  declare const navItemVariants: (props?: ({
7
- variant?: "icon" | "main" | "button" | null | undefined;
7
+ variant?: "icon" | "button" | "main" | null | undefined;
8
8
  } & _$class_variance_authority_types0.ClassProp) | undefined) => string;
9
9
  declare function Header(props: ComponentProps<'header'>): _$react_jsx_runtime0.JSX.Element;
10
10
  //#endregion
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);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fumadocs/base-ui",
3
- "version": "16.7.12",
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
- "fuma-cli": "^0.0.3",
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.3"
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.5.2",
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.5",
146
- "fumadocs-core": "16.7.12",
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.12"
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",