@fumadocs/api-docs 0.0.1

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 (179) hide show
  1. package/LICENSE +21 -0
  2. package/css/generated/shared.css +1 -0
  3. package/css/preset.css +1 -0
  4. package/dist/.translations/index.d.ts +28 -0
  5. package/dist/.translations/keys.js +28 -0
  6. package/dist/_virtual/_rolldown/runtime.js +4 -0
  7. package/dist/auto-anchor/client.d.ts +16 -0
  8. package/dist/auto-anchor/client.js +20 -0
  9. package/dist/auto-anchor/index.d.ts +9 -0
  10. package/dist/auto-anchor/index.js +17 -0
  11. package/dist/codegen.d.ts +38 -0
  12. package/dist/codegen.js +35 -0
  13. package/dist/components/accordion.d.ts +22 -0
  14. package/dist/components/accordion.js +67 -0
  15. package/dist/components/dialog.d.ts +39 -0
  16. package/dist/components/dialog.js +61 -0
  17. package/dist/components/input.d.ts +8 -0
  18. package/dist/components/input.js +17 -0
  19. package/dist/components/playground/inputs.d.ts +50 -0
  20. package/dist/components/playground/inputs.js +426 -0
  21. package/dist/components/playground/schema.d.ts +66 -0
  22. package/dist/components/playground/schema.js +144 -0
  23. package/dist/components/schema/client.d.ts +17 -0
  24. package/dist/components/schema/client.js +415 -0
  25. package/dist/components/schema/index.d.ts +102 -0
  26. package/dist/components/schema/index.js +276 -0
  27. package/dist/components/select-tab.d.ts +33 -0
  28. package/dist/components/select-tab.js +56 -0
  29. package/dist/components/select.d.ts +16 -0
  30. package/dist/components/select.js +72 -0
  31. package/dist/components/spinner.d.ts +7 -0
  32. package/dist/components/spinner.js +14 -0
  33. package/dist/i18n.d.ts +7 -0
  34. package/dist/i18n.js +7 -0
  35. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/bundle.js +239 -0
  36. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/dereference.js +187 -0
  37. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/index.d.ts +157 -0
  38. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/index.js +136 -0
  39. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/normalize-args.js +41 -0
  40. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/options.d.ts +166 -0
  41. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/options.js +124 -0
  42. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/parse.js +109 -0
  43. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/parsers/binary.js +30 -0
  44. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/parsers/json.js +46 -0
  45. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/parsers/text.js +36 -0
  46. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/parsers/yaml.js +49 -0
  47. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/pointer.d.ts +96 -0
  48. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/pointer.js +242 -0
  49. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/ref.d.ts +190 -0
  50. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/ref.js +247 -0
  51. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/refs.d.ts +134 -0
  52. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/refs.js +210 -0
  53. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/resolve-external.js +100 -0
  54. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/resolvers/file.js +41 -0
  55. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/resolvers/http.js +112 -0
  56. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/types/index.d.ts +133 -0
  57. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/util/convert-path-to-posix.js +8 -0
  58. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/util/errors.d.ts +34 -0
  59. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/util/errors.js +146 -0
  60. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/util/is-windows.js +5 -0
  61. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/util/maybe.js +18 -0
  62. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/util/next.js +11 -0
  63. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/util/plugins.js +99 -0
  64. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/util/schema-resources.js +30 -0
  65. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/util/url.js +315 -0
  66. package/dist/node_modules/.pnpm/@fastify_deepmerge@3.2.1/node_modules/@fastify/deepmerge/index.js +108 -0
  67. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/2020.js +110 -0
  68. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/codegen/code.js +138 -0
  69. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/codegen/index.js +674 -0
  70. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/codegen/scope.js +141 -0
  71. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/errors.js +102 -0
  72. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/index.js +223 -0
  73. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/names.js +28 -0
  74. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/ref_error.js +18 -0
  75. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/resolve.js +133 -0
  76. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/rules.js +61 -0
  77. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/util.js +146 -0
  78. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/applicability.js +23 -0
  79. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/boolSchema.js +48 -0
  80. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/dataType.js +172 -0
  81. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/defaults.js +31 -0
  82. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/index.js +433 -0
  83. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/keyword.js +113 -0
  84. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/subschema.js +72 -0
  85. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/core.js +583 -0
  86. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/data.js +18 -0
  87. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/json-schema-2020-12/index.js +42 -0
  88. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/json-schema-2020-12/meta/applicator.js +50 -0
  89. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/json-schema-2020-12/meta/content.js +20 -0
  90. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/json-schema-2020-12/meta/core.js +51 -0
  91. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/json-schema-2020-12/meta/format-annotation.js +16 -0
  92. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/json-schema-2020-12/meta/meta-data.js +36 -0
  93. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/json-schema-2020-12/meta/unevaluated.js +19 -0
  94. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/json-schema-2020-12/meta/validation.js +85 -0
  95. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/json-schema-2020-12/schema.js +59 -0
  96. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/runtime/equal.js +12 -0
  97. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/runtime/ucs2length.js +25 -0
  98. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/runtime/uri.js +12 -0
  99. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/runtime/validation_error.js +16 -0
  100. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/additionalItems.js +57 -0
  101. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js +96 -0
  102. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/allOf.js +29 -0
  103. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/anyOf.js +16 -0
  104. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/contains.js +89 -0
  105. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/dependencies.js +87 -0
  106. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/dependentSchemas.js +16 -0
  107. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/if.js +62 -0
  108. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/index.js +60 -0
  109. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/items.js +59 -0
  110. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/items2020.js +34 -0
  111. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/not.js +31 -0
  112. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/oneOf.js +51 -0
  113. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/patternProperties.js +61 -0
  114. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/prefixItems.js +17 -0
  115. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/properties.js +52 -0
  116. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/propertyNames.js +41 -0
  117. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/thenElse.js +17 -0
  118. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/code.js +130 -0
  119. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/core/id.js +14 -0
  120. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/core/index.js +22 -0
  121. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/core/ref.js +112 -0
  122. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/discriminator/index.js +101 -0
  123. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/discriminator/types.js +14 -0
  124. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/draft2020.js +35 -0
  125. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/dynamic/dynamicAnchor.js +46 -0
  126. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/dynamic/dynamicRef.js +45 -0
  127. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/dynamic/index.js +22 -0
  128. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/dynamic/recursiveAnchor.js +20 -0
  129. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/dynamic/recursiveRef.js +15 -0
  130. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/format/format.js +92 -0
  131. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/format/index.js +10 -0
  132. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/metadata.js +23 -0
  133. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/next.js +19 -0
  134. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/unevaluated/index.js +13 -0
  135. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/unevaluated/unevaluatedItems.js +46 -0
  136. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/unevaluated/unevaluatedProperties.js +59 -0
  137. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/const.js +27 -0
  138. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/dependentRequired.js +17 -0
  139. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/enum.js +49 -0
  140. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/index.js +48 -0
  141. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/limitContains.js +18 -0
  142. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/limitItems.js +28 -0
  143. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/limitLength.js +33 -0
  144. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/limitNumber.js +47 -0
  145. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/limitProperties.js +28 -0
  146. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/multipleOf.js +27 -0
  147. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/pattern.js +38 -0
  148. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/required.js +72 -0
  149. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/uniqueItems.js +70 -0
  150. package/dist/node_modules/.pnpm/fast-deep-equal@3.1.3/node_modules/fast-deep-equal/index.js +33 -0
  151. package/dist/node_modules/.pnpm/fast-uri@3.1.0/node_modules/fast-uri/index.js +236 -0
  152. package/dist/node_modules/.pnpm/fast-uri@3.1.0/node_modules/fast-uri/lib/schemes.js +187 -0
  153. package/dist/node_modules/.pnpm/fast-uri@3.1.0/node_modules/fast-uri/lib/utils.js +282 -0
  154. package/dist/node_modules/.pnpm/json-schema-traverse@1.0.0/node_modules/json-schema-traverse/index.js +78 -0
  155. package/dist/schema/bundle.d.ts +2 -0
  156. package/dist/schema/bundle.js +2 -0
  157. package/dist/schema/dereference.d.ts +19 -0
  158. package/dist/schema/dereference.js +49 -0
  159. package/dist/schema/index.d.ts +21 -0
  160. package/dist/schema/index.js +0 -0
  161. package/dist/schema/merge.d.ts +12 -0
  162. package/dist/schema/merge.js +156 -0
  163. package/dist/schema/ref.d.ts +20 -0
  164. package/dist/schema/ref.js +43 -0
  165. package/dist/schema/resolve-ref.d.ts +4 -0
  166. package/dist/schema/resolve-ref.js +11 -0
  167. package/dist/schema/sample.d.ts +12 -0
  168. package/dist/schema/sample.js +442 -0
  169. package/dist/schema/to-string.d.ts +10 -0
  170. package/dist/schema/to-string.js +51 -0
  171. package/dist/utils/cn.js +2 -0
  172. package/dist/utils/deep-equal.js +21 -0
  173. package/dist/utils/id-to-title.d.ts +4 -0
  174. package/dist/utils/id-to-title.js +12 -0
  175. package/dist/utils/is-plain-object.js +8 -0
  176. package/dist/utils/merge-refs.js +11 -0
  177. package/dist/utils/url.d.ts +5 -0
  178. package/dist/utils/url.js +13 -0
  179. package/package.json +105 -0
@@ -0,0 +1,415 @@
1
+ "use client";
2
+ import { useAnchorId } from "../../auto-anchor/client.js";
3
+ import { cn } from "../../utils/cn.js";
4
+ import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "../select.js";
5
+ import { mergeRefs } from "../../utils/merge-refs.js";
6
+ import { Fragment, Suspense, createContext, use, useCallback, useDeferredValue, useEffect, useMemo, useRef, useState } from "react";
7
+ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
8
+ import { CheckIcon, FilterIcon, LinkIcon } from "lucide-react";
9
+ import { buttonVariants } from "fumadocs-ui/components/ui/button";
10
+ import { cva } from "class-variance-authority";
11
+ import { useTranslations } from "@fuma-translate/react";
12
+ import { Popover, PopoverContent, PopoverTrigger } from "fumadocs-ui/components/ui/popover";
13
+ import { useCopyButton } from "fumadocs-ui/utils/use-copy-button";
14
+ //#region src/components/schema/client.tsx
15
+ const typeVariants = cva("text-sm text-start text-fd-muted-foreground font-mono", { variants: { variant: { trigger: "underline hover:text-fd-accent-foreground data-[state=open]:text-fd-accent-foreground" } } });
16
+ const Context = createContext(null);
17
+ function useStates() {
18
+ return use(Context);
19
+ }
20
+ const ExcludedFromAutoAnchor = /* @__PURE__ */ new Set();
21
+ function SchemaUI({ name, required = false, as = "property", generated }) {
22
+ const rootId = useAnchorId([name]);
23
+ const [path, setPath] = useState(() => [{
24
+ $ref: generated.$root,
25
+ name
26
+ }]);
27
+ const ref = useRef(null);
28
+ const popoverRef = useCallback((element) => {
29
+ if (!element) return;
30
+ element.scrollTop = path.at(-1).scrollTop ?? 0;
31
+ const current = parseFloat(element.style.getPropertyValue("--min-height") || "200px");
32
+ element.style.setProperty("--min-height", Math.max(element.clientHeight + 2, current) + "px");
33
+ }, [path]);
34
+ useEffect(() => {
35
+ if (ExcludedFromAutoAnchor.has(rootId)) return;
36
+ const url = new URL(window.location.href);
37
+ const param = url.searchParams.get("path");
38
+ if (url.hash !== `#${rootId}` || !param) return;
39
+ const decoded = decodePath(param, url.searchParams.get("s-highlight"));
40
+ if (!decoded || decoded.length === 0 || decoded.some((item) => !generated.refs[item.$ref])) return;
41
+ setPath(decoded);
42
+ ExcludedFromAutoAnchor.add(rootId);
43
+ if (!decoded.at(-1).highlighted) ref.current?.scrollIntoView({ behavior: "smooth" });
44
+ }, [rootId, generated.refs]);
45
+ return /* @__PURE__ */ jsx(Context, {
46
+ value: useMemo(() => ({
47
+ rootId,
48
+ path,
49
+ generated,
50
+ setPath,
51
+ renderTypeInfoTrigger: ({ $ref, children, pathName }) => /* @__PURE__ */ jsxs(Popover, {
52
+ open: path.length > 1 && path[1].$ref === $ref && path[1].name === pathName && !path[0].closed,
53
+ onOpenChange: (v) => {
54
+ if (v) setPath([{
55
+ ...path[0],
56
+ closed: false
57
+ }, {
58
+ name: pathName,
59
+ $ref
60
+ }]);
61
+ else setPath(path.map((item, i) => i === 0 ? {
62
+ ...item,
63
+ closed: true
64
+ } : item));
65
+ },
66
+ children: [/* @__PURE__ */ jsx(PopoverTrigger, {
67
+ className: cn(typeVariants({ variant: "trigger" })),
68
+ children
69
+ }), /* @__PURE__ */ jsx(PopoverContent, {
70
+ ref: popoverRef,
71
+ collisionPadding: 10,
72
+ 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",
73
+ onScrollEnd: (e) => {
74
+ path.at(-1).scrollTop = e.target.scrollTop;
75
+ },
76
+ onOpenAutoFocus: (e) => {
77
+ const input = e.target.querySelector("input[data-object-search-input]");
78
+ if (!(input instanceof HTMLInputElement)) return;
79
+ input.focus({ preventScroll: true });
80
+ e.preventDefault();
81
+ },
82
+ children: /* @__PURE__ */ jsx(SchemaUIPopover, {})
83
+ })]
84
+ })
85
+ }), [
86
+ generated,
87
+ path,
88
+ rootId,
89
+ popoverRef
90
+ ]),
91
+ children: as === "property" || generated.refs[generated.$root].type === "primitive" ? /* @__PURE__ */ jsx(ObjectProperty, {
92
+ ref,
93
+ id: rootId,
94
+ name,
95
+ $type: generated.$root,
96
+ parentPathIndex: 0,
97
+ required
98
+ }) : /* @__PURE__ */ jsx("div", {
99
+ id: rootId,
100
+ ref,
101
+ children: /* @__PURE__ */ jsx(PathItemBody, { pathIndex: 0 })
102
+ })
103
+ });
104
+ }
105
+ function SchemaDescription({ schema, ...props }) {
106
+ return /* @__PURE__ */ jsxs("div", {
107
+ ...props,
108
+ className: cn("prose-no-margin py-2 empty:hidden", props.className),
109
+ children: [schema.description, schema.infoTags && schema.infoTags.length > 0 && /* @__PURE__ */ jsx("div", {
110
+ className: "flex flex-row gap-2 flex-wrap mt-2 not-prose empty:hidden",
111
+ children: schema.infoTags.map((tag, i) => /* @__PURE__ */ jsx(InfoTag, { tag }, i))
112
+ })]
113
+ });
114
+ }
115
+ function ObjectProperty({ name, $type, required, parentPathIndex, ...props }) {
116
+ const t = useTranslations({ note: "schema UI" });
117
+ const { path, generated: { refs }, rootId } = useStates();
118
+ const schema = refs[$type];
119
+ const parentItem = path[parentPathIndex];
120
+ const ref = useCallback((element) => {
121
+ if (!element || parentItem.highlighted !== name) return;
122
+ window.setTimeout(() => {
123
+ element.scrollIntoView({
124
+ behavior: "smooth",
125
+ block: "end"
126
+ });
127
+ delete parentItem.highlighted;
128
+ }, 300);
129
+ }, [parentItem, name]);
130
+ const [isChecked, onClick] = useCopyButton(() => {
131
+ const url = new URL(window.location.href);
132
+ url.hash = `#${rootId}`;
133
+ url.searchParams.set("s-highlight", name);
134
+ url.searchParams.set("path", encodePath(path));
135
+ return navigator.clipboard.writeText(url.href);
136
+ });
137
+ return /* @__PURE__ */ jsxs("div", {
138
+ ...props,
139
+ ref: mergeRefs(props.ref, ref),
140
+ className: cn("text-sm border-t py-4 scroll-m-20 first:border-t-0", props.className),
141
+ children: [/* @__PURE__ */ jsxs("div", {
142
+ className: "flex flex-wrap items-center gap-2 not-prose",
143
+ children: [
144
+ /* @__PURE__ */ jsxs("span", {
145
+ className: "font-medium font-mono",
146
+ children: [/* @__PURE__ */ jsx("span", {
147
+ className: cn(parentItem.highlighted === name ? "bg-fd-primary text-fd-primary-foreground rounded-sm" : "text-fd-primary", schema.deprecated && "line-through opacity-80"),
148
+ children: name
149
+ }), required ? /* @__PURE__ */ jsx("span", {
150
+ className: "text-red-400",
151
+ children: "*"
152
+ }) : /* @__PURE__ */ jsx("span", {
153
+ className: "text-fd-muted-foreground",
154
+ children: "?"
155
+ })]
156
+ }),
157
+ schema.type === "primitive" ? /* @__PURE__ */ jsx("span", {
158
+ className: cn(typeVariants()),
159
+ children: schema.aliasName
160
+ }) : /* @__PURE__ */ jsx(TypeInfoTrigger, {
161
+ pathName: name,
162
+ $ref: $type,
163
+ children: schema.aliasName
164
+ }),
165
+ /* @__PURE__ */ jsx("div", { className: "flex-1" }),
166
+ schema.deprecated && /* @__PURE__ */ jsx("span", {
167
+ className: "text-xs font-mono text-yellow-600 dark:text-yellow-400",
168
+ children: t("Deprecated")
169
+ }),
170
+ /* @__PURE__ */ jsx("button", {
171
+ className: cn(buttonVariants({
172
+ size: "icon-xs",
173
+ variant: "ghost"
174
+ }), "text-fd-muted-foreground [&_svg]:size-3.5"),
175
+ onClick,
176
+ children: isChecked ? /* @__PURE__ */ jsx(CheckIcon, {}) : /* @__PURE__ */ jsx(LinkIcon, {})
177
+ })
178
+ ]
179
+ }), /* @__PURE__ */ jsx(SchemaDescription, {
180
+ schema,
181
+ className: "pb-0"
182
+ })]
183
+ });
184
+ }
185
+ function PathItemBody({ pathIndex, asSchema, tabDepth = 0, objectSearchOverrides }) {
186
+ const { path, setPath, generated: { refs } } = useStates();
187
+ const schema = asSchema ?? refs[path[pathIndex].$ref];
188
+ if ((schema.type === "or" || schema.type === "and") && schema.items.length > 0) {
189
+ const value = path[pathIndex].tabValues?.[tabDepth] ?? schema.items[0].$type;
190
+ const items = schema.items.map((item) => ({
191
+ label: /* @__PURE__ */ jsx("code", {
192
+ className: "text-xs font-medium",
193
+ children: item.name
194
+ }),
195
+ value: item.$type
196
+ }));
197
+ return /* @__PURE__ */ jsxs(Select, {
198
+ value,
199
+ onValueChange: (v) => {
200
+ const next = [...path];
201
+ (next[pathIndex].tabValues ??= []).splice(tabDepth, 1, v);
202
+ setPath(next);
203
+ },
204
+ children: [/* @__PURE__ */ jsxs("div", {
205
+ className: "flex flex-row my-2 gap-2 items-center",
206
+ children: [
207
+ /* @__PURE__ */ jsx(SchemaDescription, {
208
+ schema,
209
+ className: "flex-1 py-0"
210
+ }),
211
+ /* @__PURE__ */ jsx(SelectTrigger, {
212
+ className: "not-prose w-fit min-w-0 mb-auto *:min-w-0",
213
+ children: /* @__PURE__ */ jsx(SelectValue, { children: items.find((item) => item.value === value)?.label })
214
+ }),
215
+ /* @__PURE__ */ jsx(SelectContent, { children: items.map(({ label, value }) => /* @__PURE__ */ jsx(SelectItem, {
216
+ value,
217
+ children: label
218
+ }, value)) })
219
+ ]
220
+ }), /* @__PURE__ */ jsx(PathItemBody, {
221
+ asSchema: refs[value],
222
+ pathIndex,
223
+ tabDepth: tabDepth + 1
224
+ })]
225
+ });
226
+ }
227
+ if (schema.type === "object" && schema.props.length > 0) return /* @__PURE__ */ jsx(ObjectSearch, {
228
+ pathIndex,
229
+ schema,
230
+ ...objectSearchOverrides,
231
+ children: /* @__PURE__ */ jsx(SchemaDescription, { schema })
232
+ });
233
+ if (schema.type === "array") return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(SchemaDescription, { schema }), /* @__PURE__ */ jsx(ObjectProperty, {
234
+ name: "[index: integer]",
235
+ $type: schema.item.$type,
236
+ parentPathIndex: pathIndex
237
+ })] });
238
+ return /* @__PURE__ */ jsx(SchemaDescription, { schema });
239
+ }
240
+ function ObjectSearch({ variant = "default", schema, pathIndex, children }) {
241
+ const { path, setPath } = useStates();
242
+ const [search, setSearch] = useState("");
243
+ const deferredValue = useDeferredValue(search);
244
+ const firstItemRef = useRef(null);
245
+ const t = useTranslations({ note: "schema UI" });
246
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [
247
+ /* @__PURE__ */ jsxs("div", {
248
+ 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"),
249
+ children: [/* @__PURE__ */ jsx(FilterIcon, { className: "text-fd-muted-foreground size-3.5 transition-colors" }), /* @__PURE__ */ jsx("input", {
250
+ value: search,
251
+ "data-object-search-input": "",
252
+ onChange: (e) => setSearch(e.target.value),
253
+ placeholder: t("Filter Properties"),
254
+ className: "text-sm ps-2 py-2 flex-1 outline-none placeholder:text-fd-muted-foreground",
255
+ onKeyDown: (e) => {
256
+ if (e.key === "Enter") {
257
+ const item = firstItemRef.current;
258
+ if (item) setPath([...path, {
259
+ name: item.name,
260
+ $ref: item.$type
261
+ }]);
262
+ e.preventDefault();
263
+ }
264
+ }
265
+ })]
266
+ }),
267
+ children,
268
+ /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(ObjectSearchContent, {
269
+ search: deferredValue,
270
+ properties: schema.props,
271
+ firstItemRef,
272
+ empty: () => /* @__PURE__ */ jsxs("p", {
273
+ className: "text-fd-muted-foreground text-sm my-2!",
274
+ children: [
275
+ t("No property matching"),
276
+ " ",
277
+ /* @__PURE__ */ jsx("span", {
278
+ className: "text-fd-foreground font-medium",
279
+ children: `"${deferredValue}"`
280
+ })
281
+ ]
282
+ }),
283
+ render: (item) => /* @__PURE__ */ jsx(ObjectProperty, {
284
+ name: item.name,
285
+ $type: item.$type,
286
+ required: item.required,
287
+ parentPathIndex: pathIndex
288
+ }, item.name)
289
+ }) })
290
+ ] });
291
+ }
292
+ function ObjectSearchContent({ search: rawSearch, firstItemRef, properties, empty, render }) {
293
+ const filtered = useMemo(() => {
294
+ const search = rawSearch.trim().toLowerCase();
295
+ return search.length > 0 ? properties.filter((prop) => prop.name.toLowerCase().includes(search)) : properties;
296
+ }, [properties, rawSearch]);
297
+ firstItemRef.current = filtered[0] ?? null;
298
+ if (filtered.length === 0) return empty();
299
+ return filtered.map(render);
300
+ }
301
+ function InfoTag({ tag }) {
302
+ const ref = useRef(null);
303
+ const [open, setOpen] = useState(false);
304
+ return /* @__PURE__ */ jsxs("button", {
305
+ className: "inline-flex text-start items-start gap-2 bg-fd-secondary border rounded-lg text-xs p-1.5 shadow-md max-w-full",
306
+ onClick: () => setOpen((prev) => !prev),
307
+ children: [/* @__PURE__ */ jsx("span", {
308
+ className: "font-medium",
309
+ children: tag.label
310
+ }), /* @__PURE__ */ jsx("code", {
311
+ ref,
312
+ className: cn("min-w-0 flex-1 text-fd-muted-foreground", open ? "wrap-break-word" : "truncate"),
313
+ children: tag.value
314
+ })]
315
+ });
316
+ }
317
+ function SchemaUIPopover() {
318
+ const states = useStates();
319
+ const { path, setPath } = states;
320
+ return /* @__PURE__ */ jsxs(Context, {
321
+ value: useMemo(() => ({
322
+ ...states,
323
+ renderTypeInfoTrigger: ({ $ref, pathName, children }) => /* @__PURE__ */ jsx("button", {
324
+ className: cn(typeVariants({ variant: "trigger" })),
325
+ onClick: () => setPath([...path, {
326
+ name: pathName,
327
+ $ref
328
+ }]),
329
+ children
330
+ })
331
+ }), [
332
+ states,
333
+ setPath,
334
+ path
335
+ ]),
336
+ children: [/* @__PURE__ */ jsx("div", {
337
+ 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",
338
+ children: path.map((item, i) => {
339
+ if (i === 0) return;
340
+ const isDuplicated = path.some((other, j) => j !== i && other.$ref === item.$ref);
341
+ let text;
342
+ const indexItemMatch = /^\[(\w+): (\w+)]$/.exec(item.name);
343
+ if (indexItemMatch) text = `[${indexItemMatch[1]}]`;
344
+ else if (i > 1) text = `.${item.name}`;
345
+ else text = item.name;
346
+ return /* @__PURE__ */ jsx("button", {
347
+ onClick: () => setPath(path.slice(0, i + 1)),
348
+ className: cn("hover:underline hover:text-fd-accent-foreground", isDuplicated && "text-orange-400"),
349
+ children: text
350
+ }, i);
351
+ })
352
+ }), /* @__PURE__ */ jsx(PathItemBody, {
353
+ pathIndex: path.length - 1,
354
+ objectSearchOverrides: { variant: "in-popover" }
355
+ })]
356
+ });
357
+ }
358
+ function TypeInfoTrigger({ pathName, $ref, children }) {
359
+ const { generated: { refs }, renderTypeInfoTrigger } = useStates();
360
+ const schema = refs[$ref];
361
+ if (schema.type === "primitive" && !schema.description && (!schema.infoTags || schema.infoTags.length === 0)) return /* @__PURE__ */ jsx("span", {
362
+ className: cn(typeVariants()),
363
+ children
364
+ });
365
+ if (schema.type === "and" || schema.type === "or") {
366
+ const sep = schema.type === "and" ? "&" : "|";
367
+ return /* @__PURE__ */ jsx("span", {
368
+ className: cn(typeVariants(), "flex flex-row gap-2 items-center flex-wrap"),
369
+ children: schema.items.map((item, i) => /* @__PURE__ */ jsxs(Fragment, { children: [i > 0 && /* @__PURE__ */ jsx("span", { children: sep }), /* @__PURE__ */ jsx(TypeInfoTrigger, {
370
+ pathName,
371
+ $ref: item.$type,
372
+ children: item.name
373
+ })] }, item.$type))
374
+ });
375
+ }
376
+ if (schema.type === "array") return /* @__PURE__ */ jsxs("span", {
377
+ className: cn(typeVariants(), "flex flex-row items-center flex-wrap"),
378
+ children: [
379
+ "array<",
380
+ /* @__PURE__ */ jsx(TypeInfoTrigger, {
381
+ pathName: `${pathName}[]`,
382
+ $ref: schema.item.$type,
383
+ children: refs[schema.item.$type].aliasName
384
+ }),
385
+ ">"
386
+ ]
387
+ });
388
+ return renderTypeInfoTrigger({
389
+ $ref,
390
+ pathName,
391
+ children
392
+ });
393
+ }
394
+ function encodePath(path) {
395
+ return path.map((item) => [
396
+ item.name,
397
+ item.$ref,
398
+ ...item.tabValues ?? []
399
+ ].join("\0")).join("|");
400
+ }
401
+ function decodePath(path, highlighted) {
402
+ const out = [];
403
+ for (const part of path.split("|")) {
404
+ const [name, $ref, ...tabValues] = part.split("\0");
405
+ out.push({
406
+ name,
407
+ $ref,
408
+ tabValues
409
+ });
410
+ }
411
+ if (highlighted && out.length > 0) out[out.length - 1].highlighted = highlighted;
412
+ return out;
413
+ }
414
+ //#endregion
415
+ export { SchemaUI };
@@ -0,0 +1,102 @@
1
+ import { ParsedSchema, SchemaResolver } from "../../schema/index.js";
2
+ import { SchemaUIProps } from "./client.js";
3
+ import { ReactNode } from "react";
4
+
5
+ //#region src/components/schema/index.d.ts
6
+ interface FieldBase {
7
+ description?: ReactNode;
8
+ infoTags?: InfoTag[];
9
+ typeName: string;
10
+ aliasName: string;
11
+ deprecated?: boolean;
12
+ }
13
+ interface InfoTag {
14
+ label: ReactNode;
15
+ value: string;
16
+ }
17
+ interface SchemaDataObjectProperty {
18
+ name: string;
19
+ $type: string;
20
+ required: boolean;
21
+ }
22
+ type SchemaData = FieldBase & ({
23
+ type: 'primitive';
24
+ } | {
25
+ type: 'object';
26
+ props: SchemaDataObjectProperty[];
27
+ } | {
28
+ type: 'array';
29
+ item: {
30
+ $type: string;
31
+ };
32
+ } | {
33
+ type: 'or';
34
+ items: {
35
+ name: string;
36
+ $type: string;
37
+ }[];
38
+ } | {
39
+ type: 'and';
40
+ items: {
41
+ name: string;
42
+ $type: string;
43
+ }[];
44
+ });
45
+ interface SchemaUIOptions {
46
+ root: ParsedSchema;
47
+ client: Omit<SchemaUIProps, 'generated'>;
48
+ resolver: SchemaResolver;
49
+ renderMarkdown: (md: string) => ReactNode;
50
+ /**
51
+ * include read only props
52
+ */
53
+ readOnly?: boolean;
54
+ /**
55
+ * include write only props
56
+ */
57
+ writeOnly?: boolean;
58
+ /**
59
+ * Show example values as tags
60
+ *
61
+ * @default false
62
+ */
63
+ showExample?: boolean;
64
+ }
65
+ interface SchemaUIGeneratedData {
66
+ $root: string;
67
+ refs: Record<string, SchemaData>;
68
+ }
69
+ interface SchemaUILabels {
70
+ default: string;
71
+ match: string;
72
+ format: string;
73
+ multipleOf: string;
74
+ range: string;
75
+ length: string;
76
+ properties: string;
77
+ items: string;
78
+ valueIn: string;
79
+ example: string;
80
+ }
81
+ declare function Schema({
82
+ client,
83
+ root,
84
+ readOnly,
85
+ writeOnly,
86
+ resolver,
87
+ showExample,
88
+ renderMarkdown
89
+ }: SchemaUIOptions): import("react").JSX.Element;
90
+ declare function generateSchemaUI({
91
+ root,
92
+ resolver,
93
+ renderMarkdown,
94
+ readOnly,
95
+ writeOnly,
96
+ showExample,
97
+ labels
98
+ }: Omit<SchemaUIOptions, 'client'> & {
99
+ labels: SchemaUILabels;
100
+ }): SchemaUIGeneratedData;
101
+ //#endregion
102
+ export { FieldBase, InfoTag, Schema, SchemaData, SchemaDataObjectProperty, SchemaUIGeneratedData, SchemaUIOptions, generateSchemaUI };