fumadocs-ui 16.7.14 → 16.7.15

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,6 +20,8 @@
20
20
  @source inline("--color-fd-muted");
21
21
  @source inline("--fd-animated-height");
22
22
  @source inline("--fd-banner-height");
23
+ @source inline("--offset-distance");
24
+ @source inline("--opacity");
23
25
  @source inline("--padding-right");
24
26
  @source inline("--radix-navigation-menu-viewport-height");
25
27
  @source inline("--radix-popover-content-available-height");
@@ -29,6 +31,8 @@
29
31
  @source inline("--shiki-light-bg");
30
32
  @source inline("--spacing");
31
33
  @source inline("--t");
34
+ @source inline("--track-bottom");
35
+ @source inline("--track-top");
32
36
  @source inline("-circle");
33
37
  @source inline("-mb-px");
34
38
  @source inline("-me-0.5");
@@ -69,6 +73,7 @@
69
73
  @source inline("[&_svg]:size-5");
70
74
  @source inline("[&_svg]:size-full");
71
75
  @source inline("[&_svg]:text-fd-muted-foreground");
76
+ @source inline("[offset-distance:var(--offset-distance,0)]");
72
77
  @source inline("[scrollbar-width:none]");
73
78
  @source inline("a");
74
79
  @source inline("about");
@@ -160,6 +165,8 @@
160
165
  @source inline("bottom-0");
161
166
  @source inline("bottom-1.5");
162
167
  @source inline("boundary");
168
+ @source inline("box");
169
+ @source inline("boxRef");
163
170
  @source inline("breaking");
164
171
  @source inline("button");
165
172
  @source inline("buttonVariants");
@@ -682,7 +689,6 @@
682
689
  @source inline("of");
683
690
  @source inline("official");
684
691
  @source inline("offset");
685
- @source inline("offsetDistance");
686
692
  @source inline("offsetPath");
687
693
  @source inline("offsetTop");
688
694
  @source inline("on");
@@ -705,8 +711,10 @@
705
711
  @source inline("onSelectCallback");
706
712
  @source inline("onTagChange");
707
713
  @source inline("onTagChangeCallback");
714
+ @source inline("onUpdate");
708
715
  @source inline("onValueChange");
709
716
  @source inline("only");
717
+ @source inline("opacity-(--opacity,0)");
710
718
  @source inline("opacity-0");
711
719
  @source inline("open");
712
720
  @source inline("opening");
@@ -821,6 +829,7 @@
821
829
  @source inline("rainbowColors");
822
830
  @source inline("raw");
823
831
  @source inline("rawTree");
832
+ @source inline("re-exported");
824
833
  @source inline("react");
825
834
  @source inline("react-hooks/exhaustive-deps");
826
835
  @source inline("react-hooks/rules-of-hooks");
@@ -874,7 +883,6 @@
874
883
  @source inline("rtl:rotate-180");
875
884
  @source inline("rtl:rotate-90");
876
885
  @source inline("s");
877
- @source inline("scale");
878
886
  @source inline("scope");
879
887
  @source inline("scroll");
880
888
  @source inline("scroll-into-view-if-needed");
@@ -978,6 +986,7 @@
978
986
  @source inline("supposed");
979
987
  @source inline("sure");
980
988
  @source inline("svg");
989
+ @source inline("svgRef");
981
990
  @source inline("switch");
982
991
  @source inline("system");
983
992
  @source inline("t");
@@ -1033,6 +1042,7 @@
1033
1042
  @source inline("title");
1034
1043
  @source inline("to");
1035
1044
  @source inline("toc");
1045
+ @source inline("tocInfo");
1036
1046
  @source inline("tocNoHeadings");
1037
1047
  @source inline("toolbar");
1038
1048
  @source inline("top");
@@ -1048,7 +1058,7 @@
1048
1058
  @source inline("transform");
1049
1059
  @source inline("transition-[clip-path]");
1050
1060
  @source inline("transition-[height]");
1051
- @source inline("transition-[offset-distance]");
1061
+ @source inline("transition-[opacity,offset-distance]");
1052
1062
  @source inline("transition-[width,height]");
1053
1063
  @source inline("transition-all");
1054
1064
  @source inline("transition-colors");
@@ -105,13 +105,9 @@ function TOCItems({ ref, className, thumbBox = true, ...props }) {
105
105
  observer.unobserve(container);
106
106
  };
107
107
  }, [onPrint]);
108
- return /* @__PURE__ */ jsxs(Fragment$1, { children: [svg && /* @__PURE__ */ jsxs("div", {
109
- className: "absolute top-0 inset-s-0",
110
- style: {
111
- width: svg.width,
112
- height: svg.height
113
- },
114
- children: [/* @__PURE__ */ jsx(ThumbTrack, { computed: svg }), thumbBox && /* @__PURE__ */ jsx(ThumbBox, { computed: svg })]
108
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [svg && /* @__PURE__ */ jsx(ThumbTrack, {
109
+ computed: svg,
110
+ thumbBox
115
111
  }), /* @__PURE__ */ jsx("div", {
116
112
  ref: mergeRefs(containerRef, ref),
117
113
  className: cn("flex flex-col", className),
@@ -125,48 +121,61 @@ function TOCEmpty() {
125
121
  children: text.tocNoHeadings
126
122
  });
127
123
  }
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]",
124
+ function ThumbTrack({ computed, thumbBox }) {
125
+ const svgRef = useRef(null);
126
+ const boxRef = useRef(null);
127
+ const previousRef = useRef(null);
128
+ const tocInfo = Primitive.useTOC();
129
+ const onUpdate = useCallback((items) => {
130
+ const svg = svgRef.current;
131
+ if (!svg) return;
132
+ const startIdx = items.findIndex((item) => item.active);
133
+ if (startIdx === -1) return;
134
+ const endIdx = items.findLastIndex((item) => item.active);
135
+ svg.style.setProperty("--track-top", `${computed.positions[startIdx][0]}px`);
136
+ svg.style.setProperty("--track-bottom", `${computed.positions[endIdx][1]}px`);
137
+ const box = boxRef.current;
138
+ if (box) {
139
+ let isUp = false;
140
+ if (previousRef.current) {
141
+ const prev = previousRef.current;
142
+ isUp = prev.startIdx > startIdx || prev.endIdx > endIdx || prev.startIdx === startIdx && prev.endIdx === endIdx && prev.isUp;
143
+ }
144
+ previousRef.current = {
145
+ startIdx,
146
+ endIdx,
147
+ isUp
148
+ };
149
+ box.style.setProperty("--offset-distance", isUp ? `${computed.itemLineLengths[startIdx][0]}px` : `${computed.itemLineLengths[endIdx][1]}px`);
150
+ box.style.setProperty("--opacity", items[isUp ? startIdx : endIdx].original._step !== void 0 ? "0" : "1");
151
+ }
152
+ }, [computed]);
153
+ Primitive.useTOCListener(onUpdate);
154
+ useEffect(() => {
155
+ onUpdate(tocInfo.get());
156
+ }, [onUpdate, tocInfo]);
157
+ return /* @__PURE__ */ jsxs("div", {
158
+ className: "absolute top-0 inset-s-0",
139
159
  style: {
140
160
  width: computed.width,
141
- height: computed.height,
142
- clipPath: `polygon(0 ${top}, 100% ${top}, 100% ${bottom}, 0 ${bottom})`
161
+ height: computed.height
143
162
  },
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);
151
- if (startIdx === -1) return;
152
- const endIdx = items.findLastIndex((item) => item.active);
153
- let isUp = false;
154
- if (previousRef.current) {
155
- const prev = previousRef.current;
156
- isUp = prev.startIdx > startIdx || prev.endIdx > endIdx || prev.startIdx === startIdx && prev.endIdx === endIdx && prev.isUp;
157
- }
158
- previousRef.current = {
159
- startIdx,
160
- endIdx,
161
- isUp
162
- };
163
- return /* @__PURE__ */ jsx("div", {
164
- className: "absolute size-1 bg-fd-primary rounded-full transition-[offset-distance]",
165
- style: {
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"
169
- }
163
+ children: [/* @__PURE__ */ jsx("svg", {
164
+ ref: svgRef,
165
+ xmlns: "http://www.w3.org/2000/svg",
166
+ viewBox: `0 0 ${computed.width} ${computed.height}`,
167
+ className: "absolute transition-[clip-path]",
168
+ style: {
169
+ width: computed.width,
170
+ height: computed.height,
171
+ clipPath: `polygon(0 var(--track-top,0), 100% var(--track-top,0), 100% var(--track-bottom,0), 0 var(--track-bottom,0))`
172
+ },
173
+ children: computed.content
174
+ }), thumbBox && /* @__PURE__ */ jsx("div", {
175
+ ref: boxRef,
176
+ className: "absolute size-1 bg-fd-primary rounded-full [offset-distance:var(--offset-distance,0)] opacity-(--opacity,0) transition-[opacity,offset-distance]",
177
+ style: { offsetPath: `path("${computed.d}")` }
178
+ })]
170
179
  });
171
180
  }
172
181
  const a = 8;
@@ -53,15 +53,25 @@ function TOCItems({ ref, className, ...props }) {
53
53
  });
54
54
  }
55
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`;
56
+ const ref = useRef(null);
57
+ const tocInfo = Primitive.useTOC();
58
+ const onUpdate = useCallback((items) => {
59
+ const element = ref.current;
60
+ if (!element) return;
61
+ const startIdx = items.findIndex((item) => item.active);
62
+ if (startIdx === -1) return;
63
+ const endIdx = items.findLastIndex((item) => item.active);
64
+ element.style.setProperty("--track-top", `${computed.positions[startIdx][0]}px`);
65
+ element.style.setProperty("--track-bottom", `${computed.positions[endIdx][1]}px`);
66
+ }, [computed]);
67
+ Primitive.useTOCListener(onUpdate);
68
+ useEffect(() => {
69
+ onUpdate(tocInfo.get());
70
+ }, [onUpdate, tocInfo]);
62
71
  return /* @__PURE__ */ jsx("div", {
72
+ ref,
63
73
  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})` }
74
+ style: { clipPath: `polygon(0 var(--track-top,0), 100% var(--track-top,0), 100% var(--track-bottom,0), 0 var(--track-bottom,0))` }
65
75
  });
66
76
  }
67
77
  function TOCEmpty() {
@@ -5,7 +5,7 @@ import * as _$class_variance_authority_types0 from "class-variance-authority/typ
5
5
 
6
6
  //#region src/layouts/home/slots/header.d.ts
7
7
  declare const navItemVariants: (props?: ({
8
- variant?: "button" | "main" | "icon" | null | undefined;
8
+ variant?: "icon" | "main" | "button" | null | undefined;
9
9
  } & _$class_variance_authority_types0.ClassProp) | undefined) => string;
10
10
  declare function Header(props: ComponentProps<'header'>): string | number | bigint | true | _$react_jsx_runtime0.JSX.Element | Iterable<_$react.ReactNode> | Promise<string | number | bigint | boolean | _$react.ReactPortal | _$react.ReactElement<unknown, string | _$react.JSXElementConstructor<any>> | Iterable<_$react.ReactNode> | null | undefined>;
11
11
  //#endregion
@@ -1,9 +1,9 @@
1
1
  import { SearchProviderProps } from "../contexts/search.js";
2
2
  import { DefaultSearchDialogProps } from "../components/dialog/search-default.js";
3
3
  import { I18nProviderProps } from "../contexts/i18n.js";
4
- import { ComponentPropsWithoutRef, ReactNode } from "react";
4
+ import { ReactNode } from "react";
5
5
  import * as _$react_jsx_runtime0 from "react/jsx-runtime";
6
- import { ThemeProvider } from "next-themes";
6
+ import { ThemeProviderProps, UseThemeProps, useTheme } from "next-themes";
7
7
 
8
8
  //#region src/provider/base.d.ts
9
9
  interface SearchOptions extends Omit<SearchProviderProps, 'options' | 'children'> {
@@ -15,6 +15,14 @@ interface SearchOptions extends Omit<SearchProviderProps, 'options' | 'children'
15
15
  */
16
16
  enabled?: boolean;
17
17
  }
18
+ interface ThemeOptions extends ThemeProviderProps {
19
+ /**
20
+ * Enable `next-themes`
21
+ *
22
+ * @defaultValue true
23
+ */
24
+ enabled?: boolean;
25
+ }
18
26
  interface RootProviderProps {
19
27
  /**
20
28
  * `dir` option for Radix UI
@@ -25,16 +33,9 @@ interface RootProviderProps {
25
33
  */
26
34
  search?: Partial<SearchOptions>;
27
35
  /**
28
- * Customise options of `next-themes`
36
+ * Customise options for `next-themes`
29
37
  */
30
- theme?: Partial<ComponentPropsWithoutRef<typeof ThemeProvider>> & {
31
- /**
32
- * Enable `next-themes`
33
- *
34
- * @defaultValue true
35
- */
36
- enabled?: boolean;
37
- };
38
+ theme?: ThemeOptions;
38
39
  i18n?: Omit<I18nProviderProps, 'children'>;
39
40
  children?: ReactNode;
40
41
  }
@@ -46,4 +47,4 @@ declare function RootProvider({
46
47
  i18n
47
48
  }: RootProviderProps): _$react_jsx_runtime0.JSX.Element;
48
49
  //#endregion
49
- export { RootProvider, RootProviderProps };
50
+ export { RootProvider, RootProviderProps, type UseThemeProps, useTheme };
@@ -3,7 +3,7 @@ import { I18nProvider } from "../contexts/i18n.js";
3
3
  import { SearchProvider } from "../contexts/search.js";
4
4
  import { lazy } from "react";
5
5
  import { jsx } from "react/jsx-runtime";
6
- import { ThemeProvider } from "next-themes";
6
+ import { ThemeProvider, useTheme } from "next-themes";
7
7
  import { DirectionProvider } from "@radix-ui/react-direction";
8
8
  //#region src/provider/base.tsx
9
9
  const DefaultSearchDialog = lazy(() => import("../components/dialog/search-default.js"));
@@ -32,4 +32,4 @@ function RootProvider({ children, dir = "ltr", theme = {}, search, i18n }) {
32
32
  });
33
33
  }
34
34
  //#endregion
35
- export { RootProvider };
35
+ export { RootProvider, useTheme };
package/dist/style.css CHANGED
@@ -1827,6 +1827,9 @@
1827
1827
  .underline {
1828
1828
  text-decoration-line: underline;
1829
1829
  }
1830
+ .opacity-\(--opacity\,0\) {
1831
+ opacity: var(--opacity,0);
1832
+ }
1830
1833
  .opacity-0 {
1831
1834
  opacity: 0%;
1832
1835
  }
@@ -1894,8 +1897,8 @@
1894
1897
  transition-timing-function: var(--tw-ease, var(--default-transition-timing-function));
1895
1898
  transition-duration: var(--tw-duration, var(--default-transition-duration));
1896
1899
  }
1897
- .transition-\[offset-distance\] {
1898
- transition-property: offset-distance;
1900
+ .transition-\[opacity\,offset-distance\] {
1901
+ transition-property: opacity,offset-distance;
1899
1902
  transition-timing-function: var(--tw-ease, var(--default-transition-timing-function));
1900
1903
  transition-duration: var(--tw-duration, var(--default-transition-duration));
1901
1904
  }
@@ -2000,6 +2003,9 @@
2000
2003
  .\[grid-area\:toc\] {
2001
2004
  grid-area: toc;
2002
2005
  }
2006
+ .\[offset-distance\:var\(--offset-distance\,0\)\] {
2007
+ offset-distance: var(--offset-distance,0);
2008
+ }
2003
2009
  .\[scrollbar-width\:none\] {
2004
2010
  scrollbar-width: none;
2005
2011
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fumadocs-ui",
3
- "version": "16.7.14",
3
+ "version": "16.7.15",
4
4
  "description": "The Radix UI version of Fumadocs UI",
5
5
  "keywords": [
6
6
  "Docs",
@@ -141,6 +141,7 @@
141
141
  "react-remove-scroll": "^2.7.2",
142
142
  "rehype-raw": "^7.0.0",
143
143
  "scroll-into-view-if-needed": "^3.1.0",
144
+ "shiki": "^4.0.2",
144
145
  "tailwind-merge": "^3.5.0",
145
146
  "unist-util-visit": "^5.1.0",
146
147
  "@fumadocs/tailwind": "0.0.5"
@@ -155,12 +156,11 @@
155
156
  "@types/react-dom": "^19.2.3",
156
157
  "fuma-cli": "^0.0.5",
157
158
  "react-medium-image-zoom": "^5.4.3",
158
- "shiki": "^4.0.2",
159
159
  "tailwindcss": "^4.2.2",
160
160
  "tsdown": "0.21.7",
161
161
  "unified": "^11.0.5",
162
162
  "@fumadocs/cli": "1.3.7",
163
- "fumadocs-core": "16.7.14",
163
+ "fumadocs-core": "16.7.15",
164
164
  "tsconfig": "0.0.0"
165
165
  },
166
166
  "peerDependencies": {
@@ -170,16 +170,12 @@
170
170
  "next": "16.x.x",
171
171
  "react": "^19.2.0",
172
172
  "react-dom": "^19.2.0",
173
- "shiki": "*",
174
- "fumadocs-core": "16.7.14"
173
+ "fumadocs-core": "16.7.15"
175
174
  },
176
175
  "peerDependenciesMeta": {
177
176
  "next": {
178
177
  "optional": true
179
178
  },
180
- "shiki": {
181
- "optional": true
182
- },
183
179
  "@takumi-rs/image-response": {
184
180
  "optional": true
185
181
  },