schema-components 1.28.2 → 1.29.0

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 (81) hide show
  1. package/dist/{adapter-DqlAnZ_w.d.mts → adapter-DcWi4XXn.d.mts} +60 -9
  2. package/dist/core/adapter.d.mts +2 -2
  3. package/dist/core/adapter.mjs +20 -1
  4. package/dist/core/constraints.d.mts +34 -2
  5. package/dist/core/constraints.mjs +32 -0
  6. package/dist/core/cssClasses.d.mts +1 -0
  7. package/dist/core/diagnostics.d.mts +1 -1
  8. package/dist/core/errors.d.mts +1 -1
  9. package/dist/core/errors.mjs +22 -12
  10. package/dist/core/fieldOrder.d.mts +1 -1
  11. package/dist/core/formats.d.mts +7 -1
  12. package/dist/core/formats.mjs +6 -0
  13. package/dist/core/limits.d.mts +1 -1
  14. package/dist/core/limits.mjs +1 -0
  15. package/dist/core/merge.d.mts +11 -1
  16. package/dist/core/normalise.d.mts +17 -2
  17. package/dist/core/openapiConstants.d.mts +1 -0
  18. package/dist/core/ref.d.mts +1 -1
  19. package/dist/core/renderer.d.mts +1 -1
  20. package/dist/core/renderer.mjs +5 -0
  21. package/dist/core/swagger2.d.mts +1 -1
  22. package/dist/core/typeInference.d.mts +2 -2
  23. package/dist/core/types.d.mts +1 -1
  24. package/dist/core/types.mjs +17 -0
  25. package/dist/core/unionMatch.d.mts +1 -1
  26. package/dist/core/version.d.mts +1 -1
  27. package/dist/core/walkBuilders.d.mts +48 -3
  28. package/dist/core/walkBuilders.mjs +30 -0
  29. package/dist/core/walker.d.mts +14 -1
  30. package/dist/core/walker.mjs +13 -0
  31. package/dist/{diagnostics-Cbwak-ZX.d.mts → diagnostics-ByEzkjrA.d.mts} +8 -0
  32. package/dist/{errors-DQSIK4n1.d.mts → errors-D8JndRwI.d.mts} +23 -13
  33. package/dist/html/a11y.d.mts +2 -2
  34. package/dist/html/html.d.mts +11 -0
  35. package/dist/html/html.mjs +11 -0
  36. package/dist/html/renderToHtml.d.mts +25 -5
  37. package/dist/html/renderToHtml.mjs +18 -3
  38. package/dist/html/renderToHtmlStream.d.mts +41 -9
  39. package/dist/html/renderToHtmlStream.mjs +32 -7
  40. package/dist/html/renderers.d.mts +7 -1
  41. package/dist/html/renderers.mjs +6 -0
  42. package/dist/html/streamRenderers.d.mts +31 -3
  43. package/dist/html/streamRenderers.mjs +28 -0
  44. package/dist/{limits-DJhgx5Ay.d.mts → limits-DswmqWuy.d.mts} +1 -0
  45. package/dist/openapi/ApiCallbacks.d.mts +13 -1
  46. package/dist/openapi/ApiCallbacks.mjs +7 -0
  47. package/dist/openapi/ApiLinks.d.mts +13 -1
  48. package/dist/openapi/ApiLinks.mjs +7 -0
  49. package/dist/openapi/ApiResponseHeaders.d.mts +13 -1
  50. package/dist/openapi/ApiResponseHeaders.mjs +7 -0
  51. package/dist/openapi/ApiSecurity.d.mts +14 -1
  52. package/dist/openapi/ApiSecurity.mjs +8 -0
  53. package/dist/openapi/components.d.mts +96 -12
  54. package/dist/openapi/components.mjs +71 -2
  55. package/dist/openapi/parser.d.mts +129 -2
  56. package/dist/openapi/parser.mjs +72 -0
  57. package/dist/openapi/resolve.d.mts +7 -1
  58. package/dist/react/SchemaComponent.d.mts +84 -6
  59. package/dist/react/SchemaComponent.mjs +62 -1
  60. package/dist/react/SchemaErrorBoundary.d.mts +18 -1
  61. package/dist/react/SchemaErrorBoundary.mjs +13 -1
  62. package/dist/react/SchemaView.d.mts +32 -8
  63. package/dist/react/SchemaView.mjs +20 -5
  64. package/dist/react/a11y.d.mts +1 -1
  65. package/dist/react/fieldPath.d.mts +1 -1
  66. package/dist/react/headless.d.mts +1 -1
  67. package/dist/react/headlessRenderers.d.mts +13 -2
  68. package/dist/react/headlessRenderers.mjs +12 -1
  69. package/dist/{ref-TdeMfaV_.d.mts → ref-CPh8rKQ3.d.mts} +1 -1
  70. package/dist/{renderer-Ul9taFYp.d.mts → renderer-OaOz-n6-.d.mts} +17 -1
  71. package/dist/themes/mantine.d.mts +29 -3
  72. package/dist/themes/mantine.mjs +28 -2
  73. package/dist/themes/mui.d.mts +29 -2
  74. package/dist/themes/mui.mjs +29 -2
  75. package/dist/themes/radix.d.mts +40 -3
  76. package/dist/themes/radix.mjs +39 -2
  77. package/dist/themes/shadcn.d.mts +22 -1
  78. package/dist/themes/shadcn.mjs +21 -0
  79. package/dist/{types-BTB73MB8.d.mts → types-C2Ay1FEh.d.mts} +23 -0
  80. package/dist/{version-ZzL5R6cS.d.mts → version-DL8U5RuA.d.mts} +6 -0
  81. package/package.json +5 -1
@@ -1,6 +1,27 @@
1
- import { r as ComponentResolver } from "../renderer-Ul9taFYp.mjs";
1
+ import { r as ComponentResolver } from "../renderer-OaOz-n6-.mjs";
2
2
 
3
3
  //#region src/themes/shadcn.d.ts
4
+ /**
5
+ * Component resolver mapping schema field types to shadcn/ui components.
6
+ *
7
+ * Pass to `SchemaProvider` to render every `<SchemaComponent>` /
8
+ * `<SchemaView>` in the subtree with shadcn/ui inputs, selects, and
9
+ * cards. Built on top of the headless resolver so any field types the
10
+ * theme does not override fall back to plain HTML.
11
+ *
12
+ * Requires `shadcn/ui` components installed in the consuming project.
13
+ *
14
+ * @group Themes
15
+ * @example
16
+ * ```tsx
17
+ * import { SchemaProvider } from "schema-components/react/SchemaComponent";
18
+ * import { shadcnResolver } from "schema-components/themes/shadcn";
19
+ *
20
+ * <SchemaProvider resolver={shadcnResolver}>
21
+ * <SchemaComponent schema={userSchema} value={user} onChange={setUser} />
22
+ * </SchemaProvider>
23
+ * ```
24
+ */
4
25
  declare const shadcnResolver: ComponentResolver;
5
26
  //#endregion
6
27
  export { shadcnResolver };
@@ -185,6 +185,27 @@ function buildResolver() {
185
185
  if (headlessResolver.unknown !== void 0) resolver.unknown = headlessResolver.unknown;
186
186
  return resolver;
187
187
  }
188
+ /**
189
+ * Component resolver mapping schema field types to shadcn/ui components.
190
+ *
191
+ * Pass to `SchemaProvider` to render every `<SchemaComponent>` /
192
+ * `<SchemaView>` in the subtree with shadcn/ui inputs, selects, and
193
+ * cards. Built on top of the headless resolver so any field types the
194
+ * theme does not override fall back to plain HTML.
195
+ *
196
+ * Requires `shadcn/ui` components installed in the consuming project.
197
+ *
198
+ * @group Themes
199
+ * @example
200
+ * ```tsx
201
+ * import { SchemaProvider } from "schema-components/react/SchemaComponent";
202
+ * import { shadcnResolver } from "schema-components/themes/shadcn";
203
+ *
204
+ * <SchemaProvider resolver={shadcnResolver}>
205
+ * <SchemaComponent schema={userSchema} value={user} onChange={setUser} />
206
+ * </SchemaProvider>
207
+ * ```
208
+ */
188
209
  const shadcnResolver = buildResolver();
189
210
  //#endregion
190
211
  export { shadcnResolver };
@@ -26,6 +26,12 @@ interface SchemaMeta {
26
26
  /** Arbitrary UI hints passed through to theme adapters. */
27
27
  [key: string]: unknown;
28
28
  }
29
+ /**
30
+ * Resolved editability state for a walked field. `presentation` renders
31
+ * as a read-only value, `input` as a write-only input (e.g. password
32
+ * fields), `editable` as a full input that round-trips through
33
+ * `onChange`. Produced by {@link resolveEditability}.
34
+ */
29
35
  type Editability = "presentation" | "input" | "editable";
30
36
  /**
31
37
  * Resolved editability state for a single field.
@@ -285,22 +291,39 @@ interface UnknownField extends FieldBase {
285
291
  * Use `field.type` to narrow to a specific variant.
286
292
  */
287
293
  type WalkedField = StringField | NumberField | BooleanField | NullField | EnumField | LiteralField | ObjectField | ArrayField | TupleField | RecordField | UnionField | DiscriminatedUnionField | ConditionalField | NegationField | NeverField | FileField | UnknownField;
294
+ /** Type guard: narrows a `WalkedField` to its `string` variant. */
288
295
  declare function isStringField(field: WalkedField): field is StringField;
296
+ /** Type guard: narrows a `WalkedField` to its `number` variant. */
289
297
  declare function isNumberField(field: WalkedField): field is NumberField;
298
+ /** Type guard: narrows a `WalkedField` to its `boolean` variant. */
290
299
  declare function isBooleanField(field: WalkedField): field is BooleanField;
300
+ /** Type guard: narrows a `WalkedField` to its `null` variant. */
291
301
  declare function isNullField(field: WalkedField): field is NullField;
302
+ /** Type guard: narrows a `WalkedField` to its `enum` variant. */
292
303
  declare function isEnumField(field: WalkedField): field is EnumField;
304
+ /** Type guard: narrows a `WalkedField` to its `literal` variant. */
293
305
  declare function isLiteralField(field: WalkedField): field is LiteralField;
306
+ /** Type guard: narrows a `WalkedField` to its `object` variant. */
294
307
  declare function isObjectField(field: WalkedField): field is ObjectField;
308
+ /** Type guard: narrows a `WalkedField` to its `array` variant. */
295
309
  declare function isArrayField(field: WalkedField): field is ArrayField;
310
+ /** Type guard: narrows a `WalkedField` to its `tuple` variant. */
296
311
  declare function isTupleField(field: WalkedField): field is TupleField;
312
+ /** Type guard: narrows a `WalkedField` to its `record` variant. */
297
313
  declare function isRecordField(field: WalkedField): field is RecordField;
314
+ /** Type guard: narrows a `WalkedField` to its plain `union` variant. */
298
315
  declare function isUnionField(field: WalkedField): field is UnionField;
316
+ /** Type guard: narrows a `WalkedField` to its `discriminatedUnion` variant. */
299
317
  declare function isDiscriminatedUnionField(field: WalkedField): field is DiscriminatedUnionField;
318
+ /** Type guard: narrows a `WalkedField` to its `conditional` (if/then/else) variant. */
300
319
  declare function isConditionalField(field: WalkedField): field is ConditionalField;
320
+ /** Type guard: narrows a `WalkedField` to its `negation` (`not`) variant. */
301
321
  declare function isNegationField(field: WalkedField): field is NegationField;
322
+ /** Type guard: narrows a `WalkedField` to its `file` variant. */
302
323
  declare function isFileField(field: WalkedField): field is FileField;
324
+ /** Type guard: narrows a `WalkedField` to its `never` variant (false schema). */
303
325
  declare function isNeverField(field: WalkedField): field is NeverField;
326
+ /** Type guard: narrows a `WalkedField` to its `unknown` variant (permissive). */
304
327
  declare function isUnknownField(field: WalkedField): field is UnknownField;
305
328
  //#endregion
306
329
  export { UnknownField as A, isNeverField as B, RecordField as C, StringField as D, StringConstraints as E, isDiscriminatedUnionField as F, isStringField as G, isNumberField as H, isEnumField as I, isUnknownField as J, isTupleField as K, isFileField as L, isArrayField as M, isBooleanField as N, TupleField as O, isConditionalField as P, isLiteralField as R, ObjectField as S, SchemaType as T, isObjectField as U, isNullField as V, isRecordField as W, resolveEditability as Y, NeverField as _, DiscriminatedUnionField as a, NumberField as b, FieldBase as c, FieldOverrides as d, FileConstraints as f, NegationField as g, LiteralField as h, ConditionalField as i, WalkedField as j, UnionField as k, FieldConstraints as l, JsonObject as m, ArrayField as n, Editability as o, FileField as p, isUnionField as q, BooleanField as r, EnumField as s, ArrayConstraints as t, FieldOverride as u, NullField as v, SchemaMeta as w, ObjectConstraints as x, NumberConstraints as y, isNegationField as z };
@@ -49,6 +49,12 @@ declare function inferJsonSchemaDraft(schema: Record<string, unknown>): JsonSche
49
49
  * triggered the inference, for diagnostic emission.
50
50
  */
51
51
  declare function inferJsonSchemaDraftWithReason(schema: Record<string, unknown>): InferredDraft;
52
+ /**
53
+ * Parsed OpenAPI version triple (e.g. `{ major: 3, minor: 1, patch: 0 }`).
54
+ * Produced by `detectOpenApiVersion` so downstream helpers can switch on
55
+ * the canonical numeric form rather than re-parsing the raw `openapi` /
56
+ * `swagger` string.
57
+ */
52
58
  interface OpenApiVersionInfo {
53
59
  major: number;
54
60
  minor: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "schema-components",
3
- "version": "1.28.2",
3
+ "version": "1.29.0",
4
4
  "description": "React components that render UI from Zod schemas, JSON Schema, and OpenAPI documents",
5
5
  "type": "module",
6
6
  "exports": {
@@ -41,6 +41,7 @@
41
41
  "_test:coverage": "vitest run --project=unit --coverage",
42
42
  "_build": "tsdown && cp src/html/styles.css dist/html/styles.css",
43
43
  "_typedoc": "typedoc",
44
+ "_api-urls": "node scripts/build-api-urls.mjs",
44
45
  "_readme": "node scripts/build-readme-inventory.mjs",
45
46
  "typecheck": "turbo run _typecheck",
46
47
  "lint": "turbo run _lint",
@@ -51,6 +52,7 @@
51
52
  "validate": "turbo run _validate",
52
53
  "build": "turbo run _build",
53
54
  "typedoc": "turbo run _typedoc",
55
+ "api-urls": "turbo run _api-urls",
54
56
  "readme": "turbo run _readme"
55
57
  },
56
58
  "keywords": [
@@ -96,6 +98,8 @@
96
98
  "tsdown": "0.22.0",
97
99
  "tslib": "2.8.1",
98
100
  "typedoc": "0.28.19",
101
+ "typedoc-material-theme": "1.4.1",
102
+ "typedoc-plugin-mermaid": "1.12.0",
99
103
  "typedoc-plugin-missing-exports": "4.1.3",
100
104
  "typescript": "6.0.3",
101
105
  "typescript-eslint": "8.59.2",