@fumadocs/base-ui 16.7.12 → 16.7.14

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.
Files changed (16) hide show
  1. package/css/generated/shared.css +2 -7
  2. package/dist/components/image-zoom.d.ts +1 -1
  3. package/dist/components/image-zoom.js +2 -2
  4. package/dist/components/toc/clerk.js +32 -17
  5. package/dist/components/toc/default.js +43 -7
  6. package/dist/components/toc/index.d.ts +2 -11
  7. package/dist/components/toc/index.js +2 -59
  8. package/dist/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/Controlled.d.ts +36 -0
  9. package/dist/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/Controlled.js +435 -0
  10. package/dist/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.d.ts +7 -0
  11. package/dist/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 +17 -0
  12. package/dist/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/icons.js +24 -0
  13. package/dist/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/index.d.ts +2 -0
  14. package/dist/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/utils.js +372 -0
  15. package/dist/style.css +14 -14
  16. package/package.json +14 -11
@@ -0,0 +1,372 @@
1
+ //#region ../../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/utils.js
2
+ function isElement(el) {
3
+ if (typeof Element === "undefined") return false;
4
+ return el instanceof Element;
5
+ }
6
+ const testElType = (type, el) => isElement(el) && el.tagName.toUpperCase() === type;
7
+ const testDiv = (el) => testElType("DIV", el) || testElType("SPAN", el);
8
+ const testImg = (el) => testElType("IMG", el);
9
+ const testImgLoaded = (el) => el.complete && el.naturalHeight !== 0;
10
+ const testSvg = (el) => testElType("SVG", el);
11
+ const getScaleToWindow = ({ height, offset, width }) => Math.min((window.innerWidth - offset * 2) / width, (window.innerHeight - offset * 2) / height);
12
+ const getScaleToWindowMax = ({ containerHeight, containerWidth, offset, targetHeight, targetWidth }) => {
13
+ const scale = getScaleToWindow({
14
+ height: targetHeight,
15
+ offset,
16
+ width: targetWidth
17
+ });
18
+ const ratio = targetWidth > targetHeight ? targetWidth / containerWidth : targetHeight / containerHeight;
19
+ return scale > 1 ? ratio : scale * ratio;
20
+ };
21
+ const getScale = ({ containerHeight, containerWidth, hasScalableSrc, offset, targetHeight, targetWidth }) => {
22
+ if (containerHeight === 0 || containerWidth === 0) return 1;
23
+ return !hasScalableSrc && targetHeight !== 0 && targetWidth !== 0 ? getScaleToWindowMax({
24
+ containerHeight,
25
+ containerWidth,
26
+ offset,
27
+ targetHeight,
28
+ targetWidth
29
+ }) : getScaleToWindow({
30
+ height: containerHeight,
31
+ offset,
32
+ width: containerWidth
33
+ });
34
+ };
35
+ const URL_REGEX = /url(?:\(['"]?)(?<url>.*?)(?:['"]?\))/;
36
+ const getImgSrc = (imgEl) => {
37
+ if (imgEl !== null) {
38
+ if (testImg(imgEl)) return imgEl.currentSrc === "" ? void 0 : imgEl.currentSrc;
39
+ else if (testDiv(imgEl)) {
40
+ const { backgroundImage: bgImg } = window.getComputedStyle(imgEl);
41
+ if (bgImg !== "") return URL_REGEX.exec(bgImg)?.[1];
42
+ }
43
+ }
44
+ };
45
+ const getImgAlt = (imgEl) => {
46
+ if (imgEl !== null) if (testImg(imgEl)) return imgEl.alt;
47
+ else return imgEl.getAttribute("aria-label") ?? void 0;
48
+ };
49
+ const getImgRegularStyle = ({ containerHeight, containerLeft, containerTop, containerWidth, hasScalableSrc, offset, targetHeight, targetWidth }) => {
50
+ const scale = getScale({
51
+ containerHeight,
52
+ containerWidth,
53
+ hasScalableSrc,
54
+ offset,
55
+ targetHeight,
56
+ targetWidth
57
+ });
58
+ return {
59
+ top: containerTop,
60
+ left: containerLeft,
61
+ width: containerWidth * scale,
62
+ height: containerHeight * scale,
63
+ transform: `translate(0,0) scale(${1 / scale})`
64
+ };
65
+ };
66
+ const parsePosition = ({ position, relativeNum }) => {
67
+ const positionNum = parseFloat(position);
68
+ return position.endsWith("%") ? relativeNum * positionNum / 100 : positionNum;
69
+ };
70
+ const getImgObjectFitStyle = ({ containerHeight, containerLeft, containerTop, containerWidth, hasScalableSrc, objectFit: objectFitParam, objectPosition, offset, targetHeight, targetWidth }) => {
71
+ let resolvedObjectFit = objectFitParam;
72
+ if (resolvedObjectFit === "scale-down") if (targetWidth <= containerWidth && targetHeight <= containerHeight) resolvedObjectFit = "none";
73
+ else resolvedObjectFit = "contain";
74
+ if (resolvedObjectFit === "cover" || resolvedObjectFit === "contain") {
75
+ const widthRatio = containerWidth / targetWidth;
76
+ const heightRatio = containerHeight / targetHeight;
77
+ const ratio = resolvedObjectFit === "cover" ? Math.max(widthRatio, heightRatio) : Math.min(widthRatio, heightRatio);
78
+ const [posLeft = "50%", posTop = "50%"] = objectPosition.split(" ");
79
+ const posX = parsePosition({
80
+ position: posLeft,
81
+ relativeNum: containerWidth - targetWidth * ratio
82
+ });
83
+ const posY = parsePosition({
84
+ position: posTop,
85
+ relativeNum: containerHeight - targetHeight * ratio
86
+ });
87
+ const scale = getScale({
88
+ containerHeight: targetHeight * ratio,
89
+ containerWidth: targetWidth * ratio,
90
+ hasScalableSrc,
91
+ offset,
92
+ targetHeight,
93
+ targetWidth
94
+ });
95
+ return {
96
+ top: containerTop + posY,
97
+ left: containerLeft + posX,
98
+ width: targetWidth * ratio * scale,
99
+ height: targetHeight * ratio * scale,
100
+ transform: `translate(0,0) scale(${1 / scale})`
101
+ };
102
+ } else if (resolvedObjectFit === "none") {
103
+ const [posLeft = "50%", posTop = "50%"] = objectPosition.split(" ");
104
+ const posX = parsePosition({
105
+ position: posLeft,
106
+ relativeNum: containerWidth - targetWidth
107
+ });
108
+ const posY = parsePosition({
109
+ position: posTop,
110
+ relativeNum: containerHeight - targetHeight
111
+ });
112
+ const scale = getScale({
113
+ containerHeight: targetHeight,
114
+ containerWidth: targetWidth,
115
+ hasScalableSrc,
116
+ offset,
117
+ targetHeight,
118
+ targetWidth
119
+ });
120
+ return {
121
+ top: containerTop + posY,
122
+ left: containerLeft + posX,
123
+ width: targetWidth * scale,
124
+ height: targetHeight * scale,
125
+ transform: `translate(0,0) scale(${1 / scale})`
126
+ };
127
+ } else if (resolvedObjectFit === "fill") {
128
+ const widthRatio = containerWidth / targetWidth;
129
+ const heightRatio = containerHeight / targetHeight;
130
+ const ratio = Math.max(widthRatio, heightRatio);
131
+ const scale = getScale({
132
+ containerHeight: targetHeight * ratio,
133
+ containerWidth: targetWidth * ratio,
134
+ hasScalableSrc,
135
+ offset,
136
+ targetHeight,
137
+ targetWidth
138
+ });
139
+ return {
140
+ width: containerWidth * scale,
141
+ height: containerHeight * scale,
142
+ transform: `translate(0,0) scale(${1 / scale})`
143
+ };
144
+ } else return {};
145
+ };
146
+ const getDivImgStyle = ({ backgroundPosition, backgroundSize, containerHeight, containerLeft, containerTop, containerWidth, hasScalableSrc, offset, targetHeight, targetWidth }) => {
147
+ if (backgroundSize === "cover" || backgroundSize === "contain") {
148
+ const widthRatio = containerWidth / targetWidth;
149
+ const heightRatio = containerHeight / targetHeight;
150
+ const ratio = backgroundSize === "cover" ? Math.max(widthRatio, heightRatio) : Math.min(widthRatio, heightRatio);
151
+ const [posLeft = "50%", posTop = "50%"] = backgroundPosition.split(" ");
152
+ const posX = parsePosition({
153
+ position: posLeft,
154
+ relativeNum: containerWidth - targetWidth * ratio
155
+ });
156
+ const posY = parsePosition({
157
+ position: posTop,
158
+ relativeNum: containerHeight - targetHeight * ratio
159
+ });
160
+ const scale = getScale({
161
+ containerHeight: targetHeight * ratio,
162
+ containerWidth: targetWidth * ratio,
163
+ hasScalableSrc,
164
+ offset,
165
+ targetHeight,
166
+ targetWidth
167
+ });
168
+ return {
169
+ top: containerTop + posY,
170
+ left: containerLeft + posX,
171
+ width: targetWidth * ratio * scale,
172
+ height: targetHeight * ratio * scale,
173
+ transform: `translate(0,0) scale(${1 / scale})`
174
+ };
175
+ } else if (backgroundSize === "auto") {
176
+ const [posLeft = "50%", posTop = "50%"] = backgroundPosition.split(" ");
177
+ const posX = parsePosition({
178
+ position: posLeft,
179
+ relativeNum: containerWidth - targetWidth
180
+ });
181
+ const posY = parsePosition({
182
+ position: posTop,
183
+ relativeNum: containerHeight - targetHeight
184
+ });
185
+ const scale = getScale({
186
+ containerHeight: targetHeight,
187
+ containerWidth: targetWidth,
188
+ hasScalableSrc,
189
+ offset,
190
+ targetHeight,
191
+ targetWidth
192
+ });
193
+ return {
194
+ top: containerTop + posY,
195
+ left: containerLeft + posX,
196
+ width: targetWidth * scale,
197
+ height: targetHeight * scale,
198
+ transform: `translate(0,0) scale(${1 / scale})`
199
+ };
200
+ } else {
201
+ const [sizeW = "50%", sizeH = "50%"] = backgroundSize.split(" ");
202
+ const sizeWidth = parsePosition({
203
+ position: sizeW,
204
+ relativeNum: containerWidth
205
+ });
206
+ const sizeHeight = parsePosition({
207
+ position: sizeH,
208
+ relativeNum: containerHeight
209
+ });
210
+ const widthRatio = sizeWidth / targetWidth;
211
+ const heightRatio = sizeHeight / targetHeight;
212
+ const ratio = Math.min(widthRatio, heightRatio);
213
+ const [posLeft = "50%", posTop = "50%"] = backgroundPosition.split(" ");
214
+ const posX = parsePosition({
215
+ position: posLeft,
216
+ relativeNum: containerWidth - targetWidth * ratio
217
+ });
218
+ const posY = parsePosition({
219
+ position: posTop,
220
+ relativeNum: containerHeight - targetHeight * ratio
221
+ });
222
+ const scale = getScale({
223
+ containerHeight: targetHeight * ratio,
224
+ containerWidth: targetWidth * ratio,
225
+ hasScalableSrc,
226
+ offset,
227
+ targetHeight,
228
+ targetWidth
229
+ });
230
+ return {
231
+ top: containerTop + posY,
232
+ left: containerLeft + posX,
233
+ width: targetWidth * ratio * scale,
234
+ height: targetHeight * ratio * scale,
235
+ transform: `translate(0,0) scale(${1 / scale})`
236
+ };
237
+ }
238
+ };
239
+ const SRC_SVG_REGEX = /\.svg$/i;
240
+ const getStyleModalImg = ({ hasZoomImg, imgSrc, isSvg, isZoomed, loadedImgEl, offset, shouldRefresh, targetEl }) => {
241
+ const hasScalableSrc = isSvg || imgSrc?.slice(0, 18) === "data:image/svg+xml" || hasZoomImg || imgSrc !== void 0 && SRC_SVG_REGEX.test(imgSrc);
242
+ const imgRect = targetEl.getBoundingClientRect();
243
+ const targetElComputedStyle = window.getComputedStyle(targetEl);
244
+ const isDivImg = loadedImgEl != null && testDiv(targetEl);
245
+ const isImgObjectFit = loadedImgEl != null && !isDivImg;
246
+ const targetHeight = loadedImgEl != null && loadedImgEl.naturalHeight !== 0 ? loadedImgEl.naturalHeight : imgRect.height;
247
+ const targetWidth = loadedImgEl != null && loadedImgEl.naturalWidth !== 0 ? loadedImgEl.naturalWidth : imgRect.width;
248
+ const styleImgRegular = getImgRegularStyle({
249
+ containerHeight: imgRect.height,
250
+ containerLeft: imgRect.left,
251
+ containerTop: imgRect.top,
252
+ containerWidth: imgRect.width,
253
+ hasScalableSrc,
254
+ offset,
255
+ targetHeight,
256
+ targetWidth
257
+ });
258
+ const styleImgObjectFit = isImgObjectFit ? getImgObjectFitStyle({
259
+ containerHeight: imgRect.height,
260
+ containerLeft: imgRect.left,
261
+ containerTop: imgRect.top,
262
+ containerWidth: imgRect.width,
263
+ hasScalableSrc,
264
+ objectFit: targetElComputedStyle.objectFit,
265
+ objectPosition: targetElComputedStyle.objectPosition,
266
+ offset,
267
+ targetHeight,
268
+ targetWidth
269
+ }) : void 0;
270
+ const styleDivImg = isDivImg ? getDivImgStyle({
271
+ backgroundPosition: targetElComputedStyle.backgroundPosition,
272
+ backgroundSize: targetElComputedStyle.backgroundSize,
273
+ containerHeight: imgRect.height,
274
+ containerLeft: imgRect.left,
275
+ containerTop: imgRect.top,
276
+ containerWidth: imgRect.width,
277
+ hasScalableSrc,
278
+ offset,
279
+ targetHeight,
280
+ targetWidth
281
+ }) : void 0;
282
+ const style = {
283
+ ...styleImgRegular,
284
+ ...styleImgObjectFit,
285
+ ...styleDivImg
286
+ };
287
+ if (isZoomed) {
288
+ const viewportX = window.innerWidth / 2;
289
+ const viewportY = window.innerHeight / 2;
290
+ const childCenterX = parseFloat(String(style.left ?? 0)) + parseFloat(String(style.width ?? 0)) / 2;
291
+ const childCenterY = parseFloat(String(style.top ?? 0)) + parseFloat(String(style.height ?? 0)) / 2;
292
+ const translateX = viewportX - childCenterX;
293
+ const translateY = viewportY - childCenterY;
294
+ if (shouldRefresh) style.transitionDuration = "0.01ms";
295
+ style.transform = `translate(${translateX}px,${translateY}px) scale(1)`;
296
+ }
297
+ return style;
298
+ };
299
+ const getStyleGhost = (imgEl) => {
300
+ if (imgEl == null) return {};
301
+ if (testSvg(imgEl)) {
302
+ const { parentElement: parentEl } = imgEl;
303
+ const rect = imgEl.getBoundingClientRect();
304
+ if (parentEl == null) return {
305
+ height: rect.height,
306
+ left: rect.left,
307
+ width: rect.width,
308
+ top: rect.top
309
+ };
310
+ else {
311
+ const parentRect = parentEl.getBoundingClientRect();
312
+ return {
313
+ height: rect.height,
314
+ left: parentRect.left - rect.left,
315
+ top: parentRect.top - rect.top,
316
+ width: rect.width
317
+ };
318
+ }
319
+ } else return {
320
+ height: imgEl.offsetHeight,
321
+ left: imgEl.offsetLeft,
322
+ width: imgEl.offsetWidth,
323
+ top: imgEl.offsetTop
324
+ };
325
+ };
326
+ const adjustSvgIDs = (svgEl) => {
327
+ const newIdSuffix = "-zoom";
328
+ const attrs = [
329
+ "clip-path",
330
+ "fill",
331
+ "mask",
332
+ "marker-start",
333
+ "marker-mid",
334
+ "marker-end"
335
+ ];
336
+ const idMap = /* @__PURE__ */ new Map();
337
+ if (svgEl.hasAttribute("id")) {
338
+ const { id: oldId } = svgEl;
339
+ const newId = oldId + newIdSuffix;
340
+ idMap.set(oldId, newId);
341
+ const svgNode = svgEl;
342
+ svgNode.id = newId;
343
+ }
344
+ svgEl.querySelectorAll("[id]").forEach((el) => {
345
+ const { id: oldId } = el;
346
+ const newId = oldId + newIdSuffix;
347
+ idMap.set(oldId, newId);
348
+ const node = el;
349
+ node.id = newId;
350
+ });
351
+ idMap.forEach((newId, oldId) => {
352
+ const urlOldID = `url(#${oldId})`;
353
+ const urlNewID = `url(#${newId})`;
354
+ const attrsQuery = attrs.map((attr) => `[${attr}="${urlOldID}"]`).join(", ");
355
+ svgEl.querySelectorAll(attrsQuery).forEach((usedEl) => {
356
+ attrs.forEach((attr) => {
357
+ if (usedEl.getAttribute(attr) === urlOldID) usedEl.setAttribute(attr, urlNewID);
358
+ });
359
+ });
360
+ });
361
+ svgEl.querySelectorAll("style").forEach((styleEl) => {
362
+ idMap.forEach((newId, oldId) => {
363
+ const { textContent } = styleEl;
364
+ if (textContent !== "") {
365
+ const styleNode = styleEl;
366
+ styleNode.textContent = textContent.replaceAll(`#${oldId}`, `#${newId}`);
367
+ }
368
+ });
369
+ });
370
+ };
371
+ //#endregion
372
+ export { adjustSvgIDs, getImgAlt, getImgSrc, getStyleGhost, getStyleModalImg, testDiv, testImg, testImgLoaded, testSvg };
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.14",
4
4
  "description": "The Base UI version of Fumadocs UI",
5
5
  "keywords": [
6
6
  "Docs",
@@ -11,8 +11,8 @@
11
11
  "author": "Fuma Nama",
12
12
  "repository": "github:fuma-nama/fumadocs",
13
13
  "files": [
14
- "css/*",
15
- "dist/*"
14
+ "css",
15
+ "dist"
16
16
  ],
17
17
  "type": "module",
18
18
  "exports": {
@@ -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.5"
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.7",
146
+ "fumadocs-core": "16.7.14",
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.14"
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",