fumadocs-openapi 10.10.2 → 10.10.3

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.
@@ -4,9 +4,10 @@
4
4
  @source inline("---");
5
5
  @source inline("--fd-docs-row-1");
6
6
  @source inline("--min-height");
7
+ @source inline("--radix-popover-content-available-width");
7
8
  @source inline("-mode");
8
9
  @source inline("-ms-2");
9
- @source inline("-mx-2");
10
+ @source inline("-mx-3");
10
11
  @source inline("-translate-x-1/2");
11
12
  @source inline("-translate-y-1/2");
12
13
  @source inline("@4xl:flex-row");
@@ -29,6 +30,7 @@
29
30
  @source inline("@scalar/api-client-react");
30
31
  @source inline("@see");
31
32
  @source inline("@typescript-eslint/no-explicit-any");
33
+ @source inline("[&_svg]:size-3.5");
32
34
  @source inline("a");
33
35
  @source inline("absolute");
34
36
  @source inline("access_token");
@@ -111,6 +113,7 @@
111
113
  @source inline("bg-fd-secondary");
112
114
  @source inline("binary");
113
115
  @source inline("blob");
116
+ @source inline("block");
114
117
  @source inline("blue");
115
118
  @source inline("body");
116
119
  @source inline("bodyMediaType");
@@ -173,6 +176,7 @@
173
176
  @source inline("codegens");
174
177
  @source inline("col-span-full");
175
178
  @source inline("collapsible");
179
+ @source inline("collisionPadding");
176
180
  @source inline("color");
177
181
  @source inline("com");
178
182
  @source inline("compile");
@@ -282,6 +286,7 @@
282
286
  @source inline("encodeInternalRef");
283
287
  @source inline("encodeRequestData");
284
288
  @source inline("encoded");
289
+ @source inline("end");
285
290
  @source inline("end-2");
286
291
  @source inline("endpoint");
287
292
  @source inline("enforce");
@@ -308,6 +313,7 @@
308
313
  @source inline("false");
309
314
  @source inline("fast-content-type-parse");
310
315
  @source inline("fd-page-tree-item-name");
316
+ @source inline("fd-scroll-container");
311
317
  @source inline("fetch");
312
318
  @source inline("fetchOptions");
313
319
  @source inline("fetcher");
@@ -408,7 +414,6 @@
408
414
  @source inline("group-data-[state=open]:rotate-180");
409
415
  @source inline("group-focus-visible/accordion:text-fd-primary");
410
416
  @source inline("group/accordion");
411
- @source inline("group/property");
412
417
  @source inline("groupId");
413
418
  @source inline("h-10");
414
419
  @source inline("h-9");
@@ -425,7 +430,6 @@
425
430
  @source inline("headerParameters");
426
431
  @source inline("headers");
427
432
  @source inline("headingLevel");
428
- @source inline("height");
429
433
  @source inline("hidden");
430
434
  @source inline("hiddenProperties");
431
435
  @source inline("highlighted");
@@ -451,6 +455,7 @@
451
455
  @source inline("import");
452
456
  @source inline("imports");
453
457
  @source inline("in");
458
+ @source inline("in-popover");
454
459
  @source inline("include");
455
460
  @source inline("index");
456
461
  @source inline("indexItemMatch");
@@ -461,7 +466,6 @@
461
466
  @source inline("initial");
462
467
  @source inline("inline-flex");
463
468
  @source inline("input");
464
- @source inline("inputContainer");
465
469
  @source inline("inputs");
466
470
  @source inline("inset-0");
467
471
  @source inline("instanceof");
@@ -527,10 +531,12 @@
527
531
  @source inline("max");
528
532
  @source inline("max-age");
529
533
  @source inline("max-h-[460px]");
534
+ @source inline("max-w-(--radix-popover-content-available-width)");
530
535
  @source inline("max-w-[600px]");
531
536
  @source inline("max-w-full");
532
537
  @source inline("max-w-lg");
533
538
  @source inline("may");
539
+ @source inline("mb-0!");
534
540
  @source inline("mb-1");
535
541
  @source inline("mb-2");
536
542
  @source inline("mb-auto");
@@ -550,16 +556,16 @@
550
556
  @source inline("migrated");
551
557
  @source inline("mime");
552
558
  @source inline("min");
553
- @source inline("min-h-(--min-height,0)");
559
+ @source inline("min-h-(--min-height,200px)");
554
560
  @source inline("min-w-0");
555
561
  @source inline("missing");
556
562
  @source inline("modify");
557
563
  @source inline("mounted");
558
- @source inline("ms-2");
559
564
  @source inline("ms-auto");
560
565
  @source inline("mt-0!");
561
566
  @source inline("mt-10");
562
567
  @source inline("mt-2");
568
+ @source inline("mt-2!");
563
569
  @source inline("mt-3");
564
570
  @source inline("multipart/form-data");
565
571
  @source inline("multiple");
@@ -606,6 +612,7 @@
606
612
  @source inline("onKeyDown");
607
613
  @source inline("onOpenAutoFocus");
608
614
  @source inline("onOpenChange");
615
+ @source inline("onScrollEnd");
609
616
  @source inline("onSubmit");
610
617
  @source inline("onValueChange");
611
618
  @source inline("once");
@@ -653,6 +660,8 @@
653
660
  @source inline("parameters");
654
661
  @source inline("params");
655
662
  @source inline("parent");
663
+ @source inline("parentItem");
664
+ @source inline("parentPathIndex");
656
665
  @source inline("parseSecurities");
657
666
  @source inline("parsed");
658
667
  @source inline("parsedState");
@@ -673,7 +682,6 @@
673
682
  @source inline("pb-2");
674
683
  @source inline("pe-2");
675
684
  @source inline("pe-3");
676
- @source inline("peer");
677
685
  @source inline("peer-disabled:cursor-not-allowed");
678
686
  @source inline("peer-disabled:opacity-70");
679
687
  @source inline("perhaps");
@@ -696,7 +704,6 @@
696
704
  @source inline("pre");
697
705
  @source inline("prefix");
698
706
  @source inline("prev");
699
- @source inline("prevProperties");
700
707
  @source inline("prevent");
701
708
  @source inline("preventScroll");
702
709
  @source inline("primary");
@@ -713,6 +720,7 @@
713
720
  @source inline("proxyForwardCookie");
714
721
  @source inline("proxyUrl");
715
722
  @source inline("ps-2");
723
+ @source inline("ps-3");
716
724
  @source inline("ps-4.5");
717
725
  @source inline("ps-6");
718
726
  @source inline("pt-0");
@@ -20,24 +20,15 @@ function useStates() {
20
20
  }
21
21
  function SchemaUI({ name, required = false, as = "property", generated }) {
22
22
  const rootId = useAnchorId([name]);
23
- const [path, _setPath] = useState(() => [{
23
+ const [path, setPath] = useState(() => [{
24
24
  $ref: generated.$root,
25
25
  name
26
26
  }]);
27
27
  const ref = useRef(null);
28
- const popoverRef = useRef(null);
29
- const setPath = useCallback((v) => {
30
- for (const item of v) delete item.highlighted;
31
- _setPath((current) => {
32
- if (popoverRef.current && current.length > 0) current[current.length - 1].scrollTop = popoverRef.current.scrollTop;
33
- return v;
34
- });
35
- }, []);
36
- useEffect(() => {
37
- const element = popoverRef.current;
28
+ const popoverRef = useCallback((element) => {
38
29
  if (!element) return;
39
30
  element.scrollTop = path.at(-1).scrollTop ?? 0;
40
- const current = parseFloat(element.style.getPropertyValue("--min-height") || "0");
31
+ const current = parseFloat(element.style.getPropertyValue("--min-height") || "200px");
41
32
  element.style.setProperty("--min-height", Math.max(element.clientHeight + 2, current) + "px");
42
33
  }, [path]);
43
34
  useEffect(() => {
@@ -46,7 +37,7 @@ function SchemaUI({ name, required = false, as = "property", generated }) {
46
37
  if (url.hash !== `#${rootId}` || !param) return;
47
38
  const decoded = decodePath(param, url.searchParams.get("s-highlight"));
48
39
  if (!decoded || decoded.length === 0 || decoded.some((item) => !generated.refs[item.$ref])) return;
49
- _setPath(decoded);
40
+ setPath(decoded);
50
41
  if (!decoded.at(-1).highlighted) ref.current?.scrollIntoView({ behavior: "smooth" });
51
42
  }, [rootId]);
52
43
  return /* @__PURE__ */ jsx(Context, {
@@ -56,24 +47,30 @@ function SchemaUI({ name, required = false, as = "property", generated }) {
56
47
  generated,
57
48
  setPath,
58
49
  renderTypeInfoTrigger: ({ $ref, children, pathName }) => /* @__PURE__ */ jsxs(Popover, {
59
- open: path[1] && path[1].$ref === $ref && path[1].name === pathName && !path.at(-1).closed,
50
+ open: path.length > 1 && path[1].$ref === $ref && path[1].name === pathName && !path[0].closed,
60
51
  onOpenChange: (v) => {
61
- if (v) setPath([path[0], {
52
+ if (v) setPath([{
53
+ ...path[0],
54
+ closed: false
55
+ }, {
62
56
  name: pathName,
63
57
  $ref
64
58
  }]);
65
- else {
66
- const next = [...path];
67
- next.at(-1).closed = true;
68
- setPath(next);
69
- }
59
+ else setPath(path.map((item, i) => i === 0 ? {
60
+ ...item,
61
+ closed: true
62
+ } : item));
70
63
  },
71
64
  children: [/* @__PURE__ */ jsx(PopoverTrigger, {
72
65
  className: cn(typeVariants({ variant: "trigger" })),
73
66
  children
74
67
  }), /* @__PURE__ */ jsx(PopoverContent, {
75
68
  ref: popoverRef,
76
- className: "w-[600px] min-h-(--min-height,0) max-h-[460px] px-2 pt-0",
69
+ collisionPadding: 10,
70
+ className: "w-[600px] max-w-(--radix-popover-content-available-width) min-h-(--min-height,200px) fd-scroll-container max-h-[460px] px-3 pt-0",
71
+ onScrollEnd: (e) => {
72
+ path.at(-1).scrollTop = e.target.scrollTop;
73
+ },
77
74
  onOpenAutoFocus: (e) => {
78
75
  const input = e.target.querySelector("input[data-object-search-input]");
79
76
  if (!(input instanceof HTMLInputElement)) return;
@@ -87,13 +84,14 @@ function SchemaUI({ name, required = false, as = "property", generated }) {
87
84
  generated,
88
85
  path,
89
86
  rootId,
90
- setPath
87
+ popoverRef
91
88
  ]),
92
89
  children: as === "property" || generated.refs[generated.$root].type === "primitive" ? /* @__PURE__ */ jsx(ObjectProperty, {
93
90
  ref,
94
91
  id: rootId,
95
92
  name,
96
93
  $type: generated.$root,
94
+ parentPathIndex: 0,
97
95
  required
98
96
  }) : /* @__PURE__ */ jsx("div", {
99
97
  id: rootId,
@@ -112,11 +110,21 @@ function SchemaDescription({ schema, ...props }) {
112
110
  })]
113
111
  });
114
112
  }
115
- function ObjectProperty({ name, $type, required, ...props }) {
113
+ function ObjectProperty({ name, $type, required, parentPathIndex, ...props }) {
116
114
  const t = useTranslations();
117
115
  const { path, generated: { refs }, rootId } = useStates();
118
116
  const schema = refs[$type];
119
- const highlighted = path.at(-1).highlighted === name;
117
+ const parentItem = path[parentPathIndex];
118
+ const ref = useCallback((element) => {
119
+ if (!element || parentItem.highlighted !== name) return;
120
+ window.setTimeout(() => {
121
+ element.scrollIntoView({
122
+ behavior: "smooth",
123
+ block: "end"
124
+ });
125
+ delete parentItem.highlighted;
126
+ }, 300);
127
+ }, [parentItem, name]);
120
128
  const [isChecked, onClick] = useCopyButton(() => {
121
129
  const url = new URL(window.location.href);
122
130
  url.hash = `#${rootId}`;
@@ -126,17 +134,15 @@ function ObjectProperty({ name, $type, required, ...props }) {
126
134
  });
127
135
  return /* @__PURE__ */ jsxs("div", {
128
136
  ...props,
129
- ref: mergeRefs(props.ref, useCallback((element) => {
130
- if (element && highlighted) element.scrollIntoView();
131
- }, [highlighted])),
132
- className: cn("group/property text-sm border-t py-4 first:border-t-0", props.className),
137
+ ref: mergeRefs(props.ref, ref),
138
+ className: cn("text-sm border-t py-4 scroll-m-20 first:border-t-0", props.className),
133
139
  children: [/* @__PURE__ */ jsxs("div", {
134
- className: "flex flex-wrap items-center gap-3 not-prose",
140
+ className: "flex flex-wrap items-center gap-2 not-prose",
135
141
  children: [
136
142
  /* @__PURE__ */ jsxs("span", {
137
143
  className: "font-medium font-mono",
138
144
  children: [/* @__PURE__ */ jsx("span", {
139
- className: cn(highlighted ? "bg-fd-primary text-fd-primary-foreground rounded-sm" : "text-fd-primary", schema.deprecated && "line-through opacity-80"),
145
+ className: cn(parentItem.highlighted === name ? "bg-fd-primary text-fd-primary-foreground rounded-sm" : "text-fd-primary", schema.deprecated && "line-through opacity-80"),
140
146
  children: name
141
147
  }), required ? /* @__PURE__ */ jsx("span", {
142
148
  className: "text-red-400",
@@ -164,7 +170,7 @@ function ObjectProperty({ name, $type, required, ...props }) {
164
170
  className: cn(buttonVariants({
165
171
  size: "icon-xs",
166
172
  variant: "ghost"
167
- }), "text-fd-muted-foreground"),
173
+ }), "text-fd-muted-foreground [&_svg]:size-3.5"),
168
174
  onClick,
169
175
  children: isChecked ? /* @__PURE__ */ jsx(CheckIcon, {}) : /* @__PURE__ */ jsx(LinkIcon, {})
170
176
  })
@@ -218,37 +224,33 @@ function PathItemBody({ pathIndex, asSchema, tabDepth = 0, objectSearchOverrides
218
224
  });
219
225
  }
220
226
  if (schema.type === "object" && schema.props.length > 0) return /* @__PURE__ */ jsx(ObjectSearch, {
221
- properties: schema.props,
227
+ pathIndex,
228
+ schema,
222
229
  ...objectSearchOverrides,
223
230
  children: /* @__PURE__ */ jsx(SchemaDescription, { schema })
224
231
  });
225
232
  if (schema.type === "array") return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(SchemaDescription, { schema }), /* @__PURE__ */ jsx(ObjectProperty, {
226
233
  name: "[index: integer]",
227
- $type: schema.item.$type
234
+ $type: schema.item.$type,
235
+ parentPathIndex: pathIndex
228
236
  })] });
229
237
  return /* @__PURE__ */ jsx(SchemaDescription, { schema });
230
238
  }
231
- function ObjectSearch({ variant = "secondary", properties, inputContainer, children }) {
239
+ function ObjectSearch({ variant = "default", schema, pathIndex, children }) {
232
240
  const { path, setPath } = useStates();
233
241
  const [search, setSearch] = useState("");
234
242
  const deferredValue = useDeferredValue(search);
235
243
  const firstItemRef = useRef(null);
236
- const prevProperties = useRef(properties);
237
244
  const t = useTranslations();
238
- if (prevProperties.current !== properties) {
239
- prevProperties.current = properties;
240
- setSearch("");
241
- }
242
245
  return /* @__PURE__ */ jsxs(Fragment$1, { children: [
243
246
  /* @__PURE__ */ jsxs("div", {
244
- ...inputContainer,
245
- className: cn("flex items-center bg-fd-secondary text-fd-secondary-foreground transition-colors", variant === "ghost" && "border-b focus-within:[&_svg]:text-fd-primary", variant === "secondary" && "border bg-fd-secondary rounded-md shadow-sm focus-within:ring-2 focus-within:ring-fd-ring", inputContainer?.className),
246
- children: [/* @__PURE__ */ jsx(FilterIcon, { className: "text-fd-muted-foreground ms-2 size-3.5 transition-colors" }), /* @__PURE__ */ jsx("input", {
247
+ className: cn("flex items-center bg-fd-secondary text-fd-secondary-foreground transition-colors", variant === "in-popover" && "sticky top-10 -mx-3 ps-3 border-b focus-within:[&_svg]:text-fd-primary", variant === "default" && "border rounded-md ps-2 shadow-sm focus-within:ring-2 focus-within:ring-fd-ring"),
248
+ children: [/* @__PURE__ */ jsx(FilterIcon, { className: "text-fd-muted-foreground size-3.5 transition-colors" }), /* @__PURE__ */ jsx("input", {
247
249
  value: search,
248
250
  "data-object-search-input": "",
249
251
  onChange: (e) => setSearch(e.target.value),
250
252
  placeholder: t.schemaFilterPropertiesPlaceholder,
251
- className: "peer text-sm ps-2 py-2 flex-1 outline-none placeholder:text-fd-muted-foreground",
253
+ className: "text-sm ps-2 py-2 flex-1 outline-none placeholder:text-fd-muted-foreground",
252
254
  onKeyDown: (e) => {
253
255
  if (e.key === "Enter") {
254
256
  const item = firstItemRef.current;
@@ -264,34 +266,36 @@ function ObjectSearch({ variant = "secondary", properties, inputContainer, child
264
266
  children,
265
267
  /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(ObjectSearchContent, {
266
268
  search: deferredValue,
267
- properties,
268
- firstItemRef
269
+ properties: schema.props,
270
+ firstItemRef,
271
+ empty: () => /* @__PURE__ */ jsxs("p", {
272
+ className: "text-fd-muted-foreground text-sm mt-2! mb-0!",
273
+ children: [
274
+ t.schemaFilterPropertiesEmpty,
275
+ " ",
276
+ /* @__PURE__ */ jsx("span", {
277
+ className: "text-fd-foreground font-medium",
278
+ children: `"${deferredValue}"`
279
+ })
280
+ ]
281
+ }),
282
+ render: (item) => /* @__PURE__ */ jsx(ObjectProperty, {
283
+ name: item.name,
284
+ $type: item.$type,
285
+ required: item.required,
286
+ parentPathIndex: pathIndex
287
+ }, item.name)
269
288
  }) })
270
289
  ] });
271
290
  }
272
- function ObjectSearchContent({ search: rawSearch, firstItemRef, properties }) {
273
- const t = useTranslations();
291
+ function ObjectSearchContent({ search: rawSearch, firstItemRef, properties, empty, render }) {
274
292
  const filtered = useMemo(() => {
275
293
  const search = rawSearch.trim().toLowerCase();
276
294
  return search.length > 0 ? properties.filter((prop) => prop.name.toLowerCase().includes(search)) : properties;
277
295
  }, [properties, rawSearch]);
278
296
  firstItemRef.current = filtered[0] ?? null;
279
- if (filtered.length === 0) return /* @__PURE__ */ jsxs("p", {
280
- className: "text-fd-muted-foreground text-sm",
281
- children: [
282
- t.schemaFilterPropertiesEmpty,
283
- " ",
284
- /* @__PURE__ */ jsx("span", {
285
- className: "text-fd-foreground font-medium",
286
- children: `"${rawSearch}"`
287
- })
288
- ]
289
- });
290
- return filtered.map((prop) => /* @__PURE__ */ jsx(ObjectProperty, {
291
- name: prop.name,
292
- $type: prop.$type,
293
- required: prop.required
294
- }, prop.name));
297
+ if (filtered.length === 0) return empty();
298
+ return filtered.map(render);
295
299
  }
296
300
  function InfoTag({ tag }) {
297
301
  const ref = useRef(null);
@@ -325,7 +329,7 @@ function SchemaUIPopover() {
325
329
  })
326
330
  }), [states]),
327
331
  children: [/* @__PURE__ */ jsx("div", {
328
- className: "sticky top-0 -mx-2 flex flex-row overflow-x-auto overflow-y-hidden items-center text-sm font-medium font-mono bg-fd-popover px-2 h-10 border-b z-20",
332
+ className: "sticky top-0 -mx-3 flex overflow-x-auto overflow-y-hidden items-center text-sm font-medium font-mono bg-fd-secondary text-fd-secondary-foreground px-3 h-10 border-b z-20",
329
333
  children: path.map((item, i) => {
330
334
  if (i === 0) return;
331
335
  const isDuplicated = path.some((other, j) => j !== i && other.$ref === item.$ref);
@@ -342,10 +346,7 @@ function SchemaUIPopover() {
342
346
  })
343
347
  }), /* @__PURE__ */ jsx(PathItemBody, {
344
348
  pathIndex: path.length - 1,
345
- objectSearchOverrides: {
346
- variant: "ghost",
347
- inputContainer: { className: "sticky top-10 -mx-2" }
348
- }
349
+ objectSearchOverrides: { variant: "in-popover" }
349
350
  })]
350
351
  });
351
352
  }
@@ -390,7 +391,7 @@ function encodePath(path) {
390
391
  item.name,
391
392
  item.$ref,
392
393
  ...item.tabValues ?? []
393
- ].join("\0").replaceAll("|", "")).join("|");
394
+ ].join("\0")).join("|");
394
395
  }
395
396
  function decodePath(path, highlighted) {
396
397
  const out = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fumadocs-openapi",
3
- "version": "10.10.2",
3
+ "version": "10.10.3",
4
4
  "description": "Generate MDX docs for your OpenAPI spec",
5
5
  "keywords": [
6
6
  "Docs",
@@ -72,8 +72,8 @@
72
72
  "tsdown": "0.22.0",
73
73
  "xml-js": "^1.6.11",
74
74
  "fumadocs-core": "16.9.3",
75
- "tsconfig": "0.0.0",
76
- "fumadocs-ui": "16.9.3"
75
+ "fumadocs-ui": "16.9.3",
76
+ "tsconfig": "0.0.0"
77
77
  },
78
78
  "peerDependencies": {
79
79
  "@scalar/api-client-react": "^2.0.20",