schema-components 2.1.1 → 3.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.
package/README.md CHANGED
@@ -165,8 +165,8 @@ import { SchemaComponent } from "schema-components/react/SchemaComponent";
165
165
  // JSON Schema object
166
166
  <SchemaComponent schema={{ type: "object", properties: { name: { type: "string" } } }} value={data} />
167
167
 
168
- // OpenAPI document + ref
169
- <SchemaComponent schema={openApiSpec} ref="#/components/schemas/User" value={data} />
168
+ // OpenAPI document + schemaRef
169
+ <SchemaComponent schema={openApiSpec} schemaRef="#/components/schemas/User" value={data} />
170
170
  ```
171
171
 
172
172
  ### Props
@@ -178,7 +178,7 @@ import { SchemaComponent } from "schema-components/react/SchemaComponent";
178
178
  | `onChange` | `(value: unknown) => void` | Callback when value changes |
179
179
  | `readOnly` | `boolean` | Force read-only presentation |
180
180
  | `writeOnly` | `boolean` | Force write-only (blank inputs) |
181
- | `ref` | `string` | JSON Pointer into OpenAPI document |
181
+ | `schemaRef` | `string` | JSON Pointer into OpenAPI document |
182
182
  | `fields` | `InferFields<T>` | Type-safe per-field overrides |
183
183
  | `widgets` | `WidgetMap` | Instance-scoped widget overrides |
184
184
  | `validate` | `boolean` | Enable Zod validation on change |
@@ -257,7 +257,7 @@ const jsonSchema = {
257
257
  }}
258
258
  />
259
259
 
260
- // OpenAPI as const + ref — full autocomplete
260
+ // OpenAPI as const + schemaRef — full autocomplete
261
261
  const spec = {
262
262
  openapi: "3.1.0",
263
263
  components: {
@@ -276,9 +276,9 @@ const spec = {
276
276
 
277
277
  <SchemaComponent
278
278
  schema={spec}
279
- ref="#/components/schemas/User"
279
+ schemaRef="#/components/schemas/User"
280
280
  fields={{
281
- id: { readOnly: true }, // ✓ inferred through ref
281
+ id: { readOnly: true }, // ✓ inferred through schemaRef
282
282
  }}
283
283
  />
284
284
  ```
@@ -66,7 +66,7 @@ declare function __clearGlobalWidgets(): void;
66
66
  *
67
67
  * @group Components
68
68
  */
69
- interface SchemaComponentProps<T = unknown, Ref extends string | undefined = undefined, Mode extends SchemaIoSide = "output"> {
69
+ interface SchemaComponentProps<T = unknown, SchemaRef extends string | undefined = undefined, Mode extends SchemaIoSide = "output"> {
70
70
  /**
71
71
  * Zod schema, JSON Schema object, or OpenAPI document.
72
72
  *
@@ -78,8 +78,16 @@ interface SchemaComponentProps<T = unknown, Ref extends string | undefined = und
78
78
  * — the static rejection surfaces the same failure at compile time.
79
79
  */
80
80
  schema: RejectUnrepresentableZod<T>;
81
- /** For OpenAPI: a ref string like "#/components/schemas/User" or "/users/post". */
82
- ref?: Ref;
81
+ /**
82
+ * For OpenAPI / JSON Schema documents: a `$ref` string pointing at
83
+ * the sub-schema to render — e.g. `"#/components/schemas/User"` or
84
+ * `"/users/post"`.
85
+ *
86
+ * Named `schemaRef` (not `ref`) so the prop survives the React /
87
+ * `preact/compat` `createElement` boundary, which strips the
88
+ * reserved `ref` name from the vnode prop bag.
89
+ */
90
+ schemaRef?: SchemaRef;
83
91
  /**
84
92
  * Which side of every transform / pipe / codec to render.
85
93
  *
@@ -103,8 +111,8 @@ interface SchemaComponentProps<T = unknown, Ref extends string | undefined = und
103
111
  io?: Mode;
104
112
  /**
105
113
  * Current value to render. Typed against
106
- * `InferSchemaValue<T, Ref, Mode>` so the prop tracks the schema's
107
- * inferred shape for the chosen `io` direction.
114
+ * `InferSchemaValue<T, SchemaRef, Mode>` so the prop tracks the
115
+ * schema's inferred shape for the chosen `io` direction.
108
116
  *
109
117
  * Falls back to `unknown` when the schema's value type cannot be
110
118
  * statically inferred (runtime `Record<string, unknown>` JSON
@@ -119,7 +127,7 @@ interface SchemaComponentProps<T = unknown, Ref extends string | undefined = und
119
127
  * <SchemaComponent schema={userSchema} value={user} readOnly />
120
128
  * ```
121
129
  */
122
- value?: InferSchemaValue<T, Ref, Mode>;
130
+ value?: InferSchemaValue<T, SchemaRef, Mode>;
123
131
  /**
124
132
  * Called when the value changes (editable fields). The parameter
125
133
  * shares the same shape as {@link SchemaComponentProps.value} so
@@ -129,7 +137,7 @@ interface SchemaComponentProps<T = unknown, Ref extends string | undefined = und
129
137
  * Falls back to `unknown` for schemas whose value type cannot be
130
138
  * statically inferred — see {@link SchemaComponentProps.value}.
131
139
  */
132
- onChange?: (value: InferSchemaValue<T, Ref, Mode>) => void;
140
+ onChange?: (value: InferSchemaValue<T, SchemaRef, Mode>) => void;
133
141
  /** Run schema.safeParse() on change and surface errors via onValidationError. */
134
142
  validate?: boolean;
135
143
  /** Called with the ZodError when validation fails. */
@@ -141,7 +149,7 @@ interface SchemaComponentProps<T = unknown, Ref extends string | undefined = und
141
149
  /** When true, any diagnostic becomes a thrown error. */
142
150
  strict?: boolean;
143
151
  /** Per-field meta overrides — nested object mirroring schema shape. */
144
- fields?: InferFields<T, Ref>;
152
+ fields?: InferFields<T, SchemaRef>;
145
153
  /** Meta overrides applied to the root schema. */
146
154
  meta?: SchemaMeta;
147
155
  /** Convenience: sets readOnly on all fields. */
@@ -183,7 +191,7 @@ interface SchemaComponentProps<T = unknown, Ref extends string | undefined = und
183
191
  * <SchemaComponent schema={userSchema} value={user} onChange={setUser} />
184
192
  * ```
185
193
  */
186
- declare function SchemaComponent<T = unknown, Ref extends string | undefined = undefined, Mode extends SchemaIoSide = "output">(props: SchemaComponentProps<T, Ref, Mode>): ReactNode;
194
+ declare function SchemaComponent<T = unknown, SchemaRef extends string | undefined = undefined, Mode extends SchemaIoSide = "output">(props: SchemaComponentProps<T, SchemaRef, Mode>): ReactNode;
187
195
  /**
188
196
  * Append a child path suffix to a parent path. When the suffix is omitted
189
197
  * (e.g. transparent wrappers like union options), the parent path is
@@ -229,7 +237,7 @@ type InferSchemaType<T> = T extends z.ZodType ? z.infer<T> : T extends object ?
229
237
  *
230
238
  * @group Components
231
239
  */
232
- interface SchemaFieldProps<T = unknown, Ref extends string | undefined = undefined, P extends string = PathOfType<InferSchemaType<T>> | (string extends PathOfType<InferSchemaType<T>> ? string : never)> {
240
+ interface SchemaFieldProps<T = unknown, SchemaRef extends string | undefined = undefined, P extends string = PathOfType<InferSchemaType<T>> | (string extends PathOfType<InferSchemaType<T>> ? string : never)> {
233
241
  /**
234
242
  * Dot-separated path to the field (e.g. "address.city").
235
243
  * When the schema is a Zod schema or typed `as const`, only valid
@@ -241,8 +249,12 @@ interface SchemaFieldProps<T = unknown, Ref extends string | undefined = undefin
241
249
  * unrepresentable-Zod rejection as {@link SchemaComponentProps.schema}.
242
250
  */
243
251
  schema: RejectUnrepresentableZod<T>;
244
- /** For OpenAPI: a ref string. */
245
- ref?: Ref;
252
+ /**
253
+ * For OpenAPI / JSON Schema documents: a `$ref` string. Named
254
+ * `schemaRef` (not `ref`) to avoid the React / `preact/compat`
255
+ * reserved prop name. See {@link SchemaComponentProps.schemaRef}.
256
+ */
257
+ schemaRef?: SchemaRef;
246
258
  /** Current value of the field at the given path. */
247
259
  value?: unknown;
248
260
  /** Called with the updated root value when this field changes. */
@@ -263,15 +275,15 @@ interface SchemaFieldProps<T = unknown, Ref extends string | undefined = undefin
263
275
  *
264
276
  * @group Components
265
277
  */
266
- declare function SchemaField<T = unknown, Ref extends string | undefined = undefined, P extends string = PathOfType<InferSchemaType<T>> | (string extends PathOfType<InferSchemaType<T>> ? string : never)>({
278
+ declare function SchemaField<T = unknown, SchemaRef extends string | undefined = undefined, P extends string = PathOfType<InferSchemaType<T>> | (string extends PathOfType<InferSchemaType<T>> ? string : never)>({
267
279
  path,
268
280
  schema: schemaInput,
269
- ref: refInput,
281
+ schemaRef: schemaRefInput,
270
282
  value,
271
283
  onChange,
272
284
  meta: fieldMeta,
273
285
  validate,
274
286
  onValidationError
275
- }: SchemaFieldProps<T, Ref, P>): ReactNode;
287
+ }: SchemaFieldProps<T, SchemaRef, P>): ReactNode;
276
288
  //#endregion
277
289
  export { SchemaProvider as a, registerWidget as c, SchemaFieldProps as i, renderField as l, SchemaComponentProps as n, __clearGlobalWidgets as o, SchemaField as r, joinPath as s, SchemaComponent as t, sanitisePrefix as u };
@@ -95,7 +95,7 @@ var SchemaField = class extends SchemaComponent {
95
95
  let rootMeta;
96
96
  let rootDocument;
97
97
  try {
98
- const normalised = normaliseSchema(this.schema, this.ref);
98
+ const normalised = normaliseSchema(this.schema, this.schemaRef);
99
99
  jsonSchema = normalised.jsonSchema;
100
100
  rootMeta = normalised.rootMeta;
101
101
  rootDocument = normalised.rootDocument;
@@ -504,7 +504,7 @@ var SchemaComponent = class extends LitElement {
504
504
  widgets: { attribute: false },
505
505
  fields: { attribute: false },
506
506
  meta: { attribute: false },
507
- ref: { attribute: false },
507
+ schemaRef: { attribute: false },
508
508
  io: { attribute: false },
509
509
  idPrefix: { attribute: false },
510
510
  onDiagnostic: { attribute: false },
@@ -533,7 +533,7 @@ var SchemaComponent = class extends LitElement {
533
533
  ...diagnosticsOptions !== void 0 ? { diagnostics: diagnosticsOptions } : {},
534
534
  ...this.io !== void 0 ? { io: this.io } : {}
535
535
  } : void 0;
536
- const normalised = normaliseSchema(this.schema, this.ref, normaliseOptions);
536
+ const normalised = normaliseSchema(this.schema, this.schemaRef, normaliseOptions);
537
537
  jsonSchema = normalised.jsonSchema;
538
538
  rootMeta = normalised.rootMeta;
539
539
  rootDocument = normalised.rootDocument;
@@ -66,7 +66,7 @@ declare class SchemaComponent extends LitElement {
66
66
  meta: {
67
67
  attribute: boolean;
68
68
  };
69
- ref: {
69
+ schemaRef: {
70
70
  attribute: boolean;
71
71
  };
72
72
  io: {
@@ -94,7 +94,7 @@ declare class SchemaComponent extends LitElement {
94
94
  * values are seeded in the constructor.
95
95
  */
96
96
  schema: unknown;
97
- ref: string | undefined;
97
+ schemaRef: string | undefined;
98
98
  io: SchemaIoSide | undefined;
99
99
  value: unknown;
100
100
  resolver: LitComponentResolver | undefined;
@@ -1,2 +1,2 @@
1
- import { t as SchemaComponent } from "../SchemaComponent-BxzzsHsK.mjs";
1
+ import { t as SchemaComponent } from "../SchemaComponent-Cga5oJfP.mjs";
2
2
  export { SchemaComponent };
@@ -37,7 +37,7 @@ declare class SchemaField extends SchemaComponent {
37
37
  meta: {
38
38
  attribute: boolean;
39
39
  };
40
- ref: {
40
+ schemaRef: {
41
41
  attribute: boolean;
42
42
  };
43
43
  io: {
@@ -1,2 +1,2 @@
1
- import { o as SchemaField } from "../SchemaComponent-BxzzsHsK.mjs";
1
+ import { o as SchemaField } from "../SchemaComponent-Cga5oJfP.mjs";
2
2
  export { SchemaField };
@@ -1,2 +1,2 @@
1
- import { s as SchemaView } from "../SchemaComponent-BxzzsHsK.mjs";
1
+ import { s as SchemaView } from "../SchemaComponent-Cga5oJfP.mjs";
2
2
  export { SchemaView };
@@ -1,2 +1,2 @@
1
- import { n as TYPE_TO_CANONICAL_TAG, r as createDefaultLitResolver } from "../SchemaComponent-BxzzsHsK.mjs";
1
+ import { n as TYPE_TO_CANONICAL_TAG, r as createDefaultLitResolver } from "../SchemaComponent-Cga5oJfP.mjs";
2
2
  export { TYPE_TO_CANONICAL_TAG, createDefaultLitResolver };
@@ -1,2 +1,2 @@
1
- import { a as registerSchemaComponents, i as BUILT_IN_ELEMENTS } from "../SchemaComponent-BxzzsHsK.mjs";
1
+ import { a as registerSchemaComponents, i as BUILT_IN_ELEMENTS } from "../SchemaComponent-Cga5oJfP.mjs";
2
2
  export { BUILT_IN_ELEMENTS, registerSchemaComponents };
@@ -1,3 +1,3 @@
1
1
  import { a as InferredValue, i as InferredOutputValue, r as InferredInputValue, t as InferFields } from "../inferValue-eAnh50EM.mjs";
2
- import { a as SchemaProvider, c as registerWidget, i as SchemaFieldProps, n as SchemaComponentProps, r as SchemaField, t as SchemaComponent } from "../SchemaComponent-B__6-5-E.mjs";
2
+ import { a as SchemaProvider, c as registerWidget, i as SchemaFieldProps, n as SchemaComponentProps, r as SchemaField, t as SchemaComponent } from "../SchemaComponent-CRgCVDhz.mjs";
3
3
  export { type InferFields, type InferredInputValue, type InferredOutputValue, type InferredValue, SchemaComponent, type SchemaComponentProps, SchemaField, type SchemaFieldProps, SchemaProvider, registerWidget };
@@ -1,3 +1,3 @@
1
1
  import { a as InferredValue, i as InferredOutputValue, r as InferredInputValue, t as InferFields } from "../inferValue-eAnh50EM.mjs";
2
- import { a as SchemaProvider, c as registerWidget, i as SchemaFieldProps, l as renderField, n as SchemaComponentProps, o as __clearGlobalWidgets, r as SchemaField, s as joinPath, t as SchemaComponent, u as sanitisePrefix } from "../SchemaComponent-B__6-5-E.mjs";
2
+ import { a as SchemaProvider, c as registerWidget, i as SchemaFieldProps, l as renderField, n as SchemaComponentProps, o as __clearGlobalWidgets, r as SchemaField, s as joinPath, t as SchemaComponent, u as sanitisePrefix } from "../SchemaComponent-CRgCVDhz.mjs";
3
3
  export { InferFields, InferredInputValue, InferredOutputValue, InferredValue, SchemaComponent, SchemaComponentProps, SchemaField, SchemaFieldProps, SchemaProvider, __clearGlobalWidgets, joinPath, registerWidget, renderField, sanitisePrefix };
@@ -21,7 +21,7 @@ import { createContext, isValidElement, useCallback, useContext, useId, useMemo
21
21
  * The `fields` prop type is inferred from the `schema` prop:
22
22
  * - Zod schemas → `FieldOverrides<z.infer<T>>` (full autocomplete)
23
23
  * - JSON Schema `as const` → `FieldOverrides<FromJSONSchema<T>>` (full autocomplete)
24
- * - OpenAPI `as const` + `ref` → `FieldOverrides<ResolveOpenAPIRef<T, Ref>>`
24
+ * - OpenAPI `as const` + `schemaRef` → `FieldOverrides<ResolveOpenAPIRef<T, SchemaRef>>`
25
25
  * - Runtime schemas → `Record<string, FieldOverride>` (no autocomplete)
26
26
  */
27
27
  const UserResolverContext = createContext(void 0);
@@ -103,7 +103,7 @@ function __clearGlobalWidgets() {
103
103
  * ```
104
104
  */
105
105
  function SchemaComponent(props) {
106
- const { schema: schemaInput, ref: refInput, io, value, onChange, validate, onValidationError, onError, onDiagnostic, strict, fields, meta: componentMeta, readOnly, writeOnly, description, widgets: instanceWidgets, idPrefix } = props;
106
+ const { schema: schemaInput, schemaRef: schemaRefInput, io, value, onChange, validate, onValidationError, onError, onDiagnostic, strict, fields, meta: componentMeta, readOnly, writeOnly, description, widgets: instanceWidgets, idPrefix } = props;
107
107
  const userResolver = useContext(UserResolverContext);
108
108
  const contextWidgets = useContext(WidgetsContext);
109
109
  const generatedId = useId();
@@ -129,7 +129,7 @@ function SchemaComponent(props) {
129
129
  let rootMeta;
130
130
  let rootDocument;
131
131
  try {
132
- const normalised = normaliseSchema(schemaInput, refInput, diagnostics !== void 0 || io !== void 0 ? {
132
+ const normalised = normaliseSchema(schemaInput, schemaRefInput, diagnostics !== void 0 || io !== void 0 ? {
133
133
  ...diagnostics !== void 0 ? { diagnostics } : {},
134
134
  ...io !== void 0 ? { io } : {}
135
135
  } : void 0);
@@ -336,7 +336,7 @@ function renderField(tree, value, onChange, userResolver, renderChild, path, ins
336
336
  *
337
337
  * @group Components
338
338
  */
339
- function SchemaField({ path, schema: schemaInput, ref: refInput, value, onChange, meta: fieldMeta, validate, onValidationError }) {
339
+ function SchemaField({ path, schema: schemaInput, schemaRef: schemaRefInput, value, onChange, meta: fieldMeta, validate, onValidationError }) {
340
340
  const userResolver = useContext(UserResolverContext);
341
341
  const contextWidgets = useContext(WidgetsContext);
342
342
  const generatedId = useId();
@@ -345,7 +345,7 @@ function SchemaField({ path, schema: schemaInput, ref: refInput, value, onChange
345
345
  let rootMeta;
346
346
  let rootDocument;
347
347
  try {
348
- const normalised = normaliseSchema(schemaInput, refInput);
348
+ const normalised = normaliseSchema(schemaInput, schemaRefInput);
349
349
  jsonSchema = normalised.jsonSchema;
350
350
  zodSchema = normalised.zodSchema;
351
351
  rootMeta = normalised.rootMeta;
@@ -389,7 +389,7 @@ function SchemaField({ path, schema: schemaInput, ref: refInput, value, onChange
389
389
  * Walks the fields override tree and matches errors by path prefix.
390
390
  *
391
391
  * The runtime shape of `fields` is always `Record<string, FieldOverride>`
392
- * after `InferFields<T, Ref>` is erased — the typed variants
392
+ * after `InferFields<T, SchemaRef>` is erased — the typed variants
393
393
  * (`FieldOverrides<U>`) and the loose `Record<string, FieldOverride>`
394
394
  * fallback share the same structural shape, so the dispatch logic only
395
395
  * needs the loose record. The previous parameter union
@@ -16,7 +16,7 @@ import { ReactNode } from "react";
16
16
  *
17
17
  * @group Components
18
18
  */
19
- interface SchemaViewProps<T = unknown, Ref extends string | undefined = undefined, Mode extends SchemaIoSide = "output"> {
19
+ interface SchemaViewProps<T = unknown, SchemaRef extends string | undefined = undefined, Mode extends SchemaIoSide = "output"> {
20
20
  /**
21
21
  * Zod schema, JSON Schema object, or OpenAPI document.
22
22
  *
@@ -25,8 +25,13 @@ interface SchemaViewProps<T = unknown, Ref extends string | undefined = undefine
25
25
  * {@link RejectUnrepresentableZod}.
26
26
  */
27
27
  schema: RejectUnrepresentableZod<T>;
28
- /** For OpenAPI: a ref string like "#/components/schemas/User". */
29
- ref?: Ref;
28
+ /**
29
+ * For OpenAPI / JSON Schema documents: a `$ref` string like
30
+ * `"#/components/schemas/User"`. Named `schemaRef` (not `ref`) to
31
+ * avoid the React / `preact/compat` reserved prop name. See
32
+ * {@link SchemaComponentProps.schemaRef}.
33
+ */
34
+ schemaRef?: SchemaRef;
30
35
  /**
31
36
  * Which side of every transform / pipe / codec to render. Mirrors
32
37
  * `<SchemaComponent io>`. Defaults to `"output"` — the inferred
@@ -39,18 +44,18 @@ interface SchemaViewProps<T = unknown, Ref extends string | undefined = undefine
39
44
  io?: Mode;
40
45
  /**
41
46
  * Current value to render. Typed against
42
- * `InferSchemaValue<T, Ref, Mode>` so the prop tracks the schema's
43
- * inferred shape for the chosen `io` direction. Falls back to
44
- * `unknown` for runtime schemas where the value type cannot be
47
+ * `InferSchemaValue<T, SchemaRef, Mode>` so the prop tracks the
48
+ * schema's inferred shape for the chosen `io` direction. Falls back
49
+ * to `unknown` for runtime schemas where the value type cannot be
45
50
  * statically inferred.
46
51
  */
47
- value?: InferredValue<T, Ref, undefined, Mode>;
52
+ value?: InferredValue<T, SchemaRef, undefined, Mode>;
48
53
  /**
49
54
  * Per-field meta overrides — nested object mirroring schema shape.
50
55
  * Typed against {@link InferFields} so a typed `schema` prop drives
51
56
  * autocomplete on the override map, matching `<SchemaComponent>`.
52
57
  */
53
- fields?: InferFields<T, Ref>;
58
+ fields?: InferFields<T, SchemaRef>;
54
59
  /** Meta overrides applied to the root schema. */
55
60
  meta?: SchemaMeta;
56
61
  /** Convenience: sets description on the root. */
@@ -96,9 +101,9 @@ interface SchemaViewProps<T = unknown, Ref extends string | undefined = undefine
96
101
  * }
97
102
  * ```
98
103
  */
99
- declare function SchemaView<T = unknown, Ref extends string | undefined = undefined, Mode extends SchemaIoSide = "output">({
104
+ declare function SchemaView<T = unknown, SchemaRef extends string | undefined = undefined, Mode extends SchemaIoSide = "output">({
100
105
  schema: schemaInput,
101
- ref: refInput,
106
+ schemaRef: schemaRefInput,
102
107
  io,
103
108
  value,
104
109
  fields,
@@ -109,6 +114,6 @@ declare function SchemaView<T = unknown, Ref extends string | undefined = undefi
109
114
  onDiagnostic,
110
115
  strict,
111
116
  idPrefix
112
- }: SchemaViewProps<T, Ref, Mode>): ReactNode;
117
+ }: SchemaViewProps<T, SchemaRef, Mode>): ReactNode;
113
118
  //#endregion
114
119
  export { SchemaView, SchemaViewProps };
@@ -58,7 +58,7 @@ import { isValidElement, useId } from "react";
58
58
  * }
59
59
  * ```
60
60
  */
61
- function SchemaView({ schema: schemaInput, ref: refInput, io, value, fields, meta: componentMeta, description, resolver, widgets, onDiagnostic, strict, idPrefix }) {
61
+ function SchemaView({ schema: schemaInput, schemaRef: schemaRefInput, io, value, fields, meta: componentMeta, description, resolver, widgets, onDiagnostic, strict, idPrefix }) {
62
62
  const generatedId = useId();
63
63
  const rootPath = idPrefix ?? sanitisePrefix(generatedId);
64
64
  const mergedMeta = {
@@ -74,7 +74,7 @@ function SchemaView({ schema: schemaInput, ref: refInput, io, value, fields, met
74
74
  let rootMeta;
75
75
  let rootDocument;
76
76
  try {
77
- const normalised = normaliseSchema(schemaInput, refInput, diagnostics !== void 0 || io !== void 0 ? {
77
+ const normalised = normaliseSchema(schemaInput, schemaRefInput, diagnostics !== void 0 || io !== void 0 ? {
78
78
  ...diagnostics !== void 0 ? { diagnostics } : {},
79
79
  ...io !== void 0 ? { io } : {}
80
80
  } : void 0);
@@ -42,17 +42,17 @@ declare function SchemaProvider(props: {
42
42
  *
43
43
  * @group Components
44
44
  */
45
- interface SchemaComponentProps<T = unknown, Ref extends string | undefined = undefined, Mode extends SchemaIoSide = "output"> {
45
+ interface SchemaComponentProps<T = unknown, SchemaRef extends string | undefined = undefined, Mode extends SchemaIoSide = "output"> {
46
46
  /** Zod schema, JSON Schema object, or OpenAPI document. */
47
47
  schema: RejectUnrepresentableZod<T>;
48
48
  /** For OpenAPI: a ref string like `"#/components/schemas/User"`. */
49
- ref?: Ref;
49
+ schemaRef?: SchemaRef;
50
50
  /** Which side of every transform / pipe / codec to render. */
51
51
  io?: Mode;
52
52
  /** Current value to render — typed against the schema's inferred shape. */
53
- value?: InferSchemaValue<T, Ref, Mode>;
53
+ value?: InferSchemaValue<T, SchemaRef, Mode>;
54
54
  /** Called when the value changes; receives the next value. */
55
- onChange?: (value: InferSchemaValue<T, Ref, Mode>) => void;
55
+ onChange?: (value: InferSchemaValue<T, SchemaRef, Mode>) => void;
56
56
  /** Run `safeParse` / `safeEncode` on change and route errors. */
57
57
  validate?: boolean;
58
58
  /** Called with the validation error when validation fails. */
@@ -64,7 +64,7 @@ interface SchemaComponentProps<T = unknown, Ref extends string | undefined = und
64
64
  /** When true, any diagnostic becomes a thrown error. */
65
65
  strict?: boolean;
66
66
  /** Per-field meta overrides — nested object mirroring schema shape. */
67
- fields?: InferFields<T, Ref>;
67
+ fields?: InferFields<T, SchemaRef>;
68
68
  /** Meta overrides applied to the root schema. */
69
69
  meta?: SchemaMeta;
70
70
  /** Convenience: sets readOnly on all fields. */
@@ -131,6 +131,6 @@ declare function renderField(tree: WalkedField, value: unknown, onChange: (v: un
131
131
  * <SchemaComponent schema={userSchema} value={user} onChange={setUser} />
132
132
  * ```
133
133
  */
134
- declare function SchemaComponent<T = unknown, Ref extends string | undefined = undefined, Mode extends SchemaIoSide = "output">(props: SchemaComponentProps<T, Ref, Mode>): JSX.Element;
134
+ declare function SchemaComponent<T = unknown, SchemaRef extends string | undefined = undefined, Mode extends SchemaIoSide = "output">(props: SchemaComponentProps<T, SchemaRef, Mode>): JSX.Element;
135
135
  //#endregion
136
136
  export { type InferFields, type InferredInputValue, type InferredOutputValue, type InferredValue, SchemaComponent, SchemaComponentProps, SchemaProvider, joinPath, renderField, sanitisePrefix };
@@ -232,7 +232,7 @@ function SchemaComponent(props) {
232
232
  const onDiagnostic = rest.onDiagnostic;
233
233
  const strict = rest.strict;
234
234
  const io = rest.io;
235
- const refInput = rest.ref;
235
+ const refInput = rest.schemaRef;
236
236
  const onError = rest.onError;
237
237
  const idPrefix = rest.idPrefix;
238
238
  const mergedMeta = { ...componentMeta };
@@ -16,10 +16,10 @@ type InferSchemaType<T> = T extends z.ZodType ? z.infer<T> : T extends object ?
16
16
  *
17
17
  * @group Components
18
18
  */
19
- interface SchemaFieldProps<T = unknown, Ref extends string | undefined = undefined, P extends string = PathOfType<InferSchemaType<T>> | (string extends PathOfType<InferSchemaType<T>> ? string : never)> {
19
+ interface SchemaFieldProps<T = unknown, SchemaRef extends string | undefined = undefined, P extends string = PathOfType<InferSchemaType<T>> | (string extends PathOfType<InferSchemaType<T>> ? string : never)> {
20
20
  path: P;
21
21
  schema: RejectUnrepresentableZod<T>;
22
- ref?: Ref;
22
+ schemaRef?: SchemaRef;
23
23
  value?: unknown;
24
24
  onChange?: (value: unknown) => void;
25
25
  meta?: SchemaMeta;
@@ -35,6 +35,6 @@ interface SchemaFieldProps<T = unknown, Ref extends string | undefined = undefin
35
35
  *
36
36
  * @group Components
37
37
  */
38
- declare function SchemaField<T = unknown, Ref extends string | undefined = undefined, P extends string = PathOfType<InferSchemaType<T>> | (string extends PathOfType<InferSchemaType<T>> ? string : never)>(props: SchemaFieldProps<T, Ref, P>): JSX.Element;
38
+ declare function SchemaField<T = unknown, SchemaRef extends string | undefined = undefined, P extends string = PathOfType<InferSchemaType<T>> | (string extends PathOfType<InferSchemaType<T>> ? string : never)>(props: SchemaFieldProps<T, SchemaRef, P>): JSX.Element;
39
39
  //#endregion
40
40
  export { SchemaField, SchemaFieldProps };
@@ -40,7 +40,7 @@ function SchemaField(props) {
40
40
  let rootMeta;
41
41
  let rootDocument;
42
42
  try {
43
- const normalised = normaliseSchema(props.schema, props.ref);
43
+ const normalised = normaliseSchema(props.schema, props.schemaRef);
44
44
  jsonSchema = normalised.jsonSchema;
45
45
  zodSchema = normalised.zodSchema;
46
46
  rootMeta = normalised.rootMeta;
@@ -17,12 +17,12 @@ import { JSX } from "solid-js";
17
17
  *
18
18
  * @group Components
19
19
  */
20
- interface SchemaViewProps<T = unknown, Ref extends string | undefined = undefined, Mode extends SchemaIoSide = "output"> {
20
+ interface SchemaViewProps<T = unknown, SchemaRef extends string | undefined = undefined, Mode extends SchemaIoSide = "output"> {
21
21
  schema: RejectUnrepresentableZod<T>;
22
- ref?: Ref;
22
+ schemaRef?: SchemaRef;
23
23
  io?: Mode;
24
- value?: InferredValue<T, Ref, undefined, Mode>;
25
- fields?: InferFields<T, Ref>;
24
+ value?: InferredValue<T, SchemaRef, undefined, Mode>;
25
+ fields?: InferFields<T, SchemaRef>;
26
26
  meta?: SchemaMeta;
27
27
  description?: string;
28
28
  /** Theme resolver. Falls back to the headless resolver if omitted. */
@@ -49,6 +49,6 @@ interface SchemaViewProps<T = unknown, Ref extends string | undefined = undefine
49
49
  * }
50
50
  * ```
51
51
  */
52
- declare function SchemaView<T = unknown, Ref extends string | undefined = undefined, Mode extends SchemaIoSide = "output">(props: SchemaViewProps<T, Ref, Mode>): JSX.Element;
52
+ declare function SchemaView<T = unknown, SchemaRef extends string | undefined = undefined, Mode extends SchemaIoSide = "output">(props: SchemaViewProps<T, SchemaRef, Mode>): JSX.Element;
53
53
  //#endregion
54
54
  export { SchemaView, SchemaViewProps };
@@ -66,7 +66,7 @@ function SchemaView(props) {
66
66
  ...diagnostics !== void 0 ? { diagnostics } : {},
67
67
  ...props.io !== void 0 ? { io: props.io } : {}
68
68
  } : void 0;
69
- const normalised = normaliseSchema(props.schema, props.ref, normaliseOptions);
69
+ const normalised = normaliseSchema(props.schema, props.schemaRef, normaliseOptions);
70
70
  jsonSchema = normalised.jsonSchema;
71
71
  rootMeta = normalised.rootMeta;
72
72
  rootDocument = normalised.rootDocument;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "schema-components",
3
- "version": "2.1.1",
3
+ "version": "3.0.1",
4
4
  "description": "React components that render UI from Zod schemas, JSON Schema, and OpenAPI documents",
5
5
  "type": "module",
6
6
  "exports": {
@@ -41,7 +41,7 @@
41
41
  constraint Vue, Solid, and React impose on shared mutable
42
42
  state and is documented in the package README.
43
43
  -->
44
- <script lang="ts" generics="T = unknown, Ref extends string | undefined = undefined">
44
+ <script lang="ts" generics="T = unknown, SchemaRef extends string | undefined = undefined">
45
45
  import { z } from "zod";
46
46
  import { walk } from "../core/walker.ts";
47
47
  import type { WalkOptions } from "../core/walkBuilders.ts";
@@ -78,13 +78,13 @@
78
78
  /** Zod 4, JSON Schema, or OpenAPI document. */
79
79
  schema: T;
80
80
  /** OpenAPI ref string, e.g. "#/components/schemas/User". */
81
- ref?: Ref;
81
+ schemaRef?: SchemaRef;
82
82
  /** Direction (`"output"` / `"input"`) for codec / transform schemas. */
83
83
  io?: SchemaIoSide;
84
84
  /** Current value to render. */
85
- value?: InferSchemaValue<T, Ref, "output">;
85
+ value?: InferSchemaValue<T, SchemaRef, "output">;
86
86
  /** Called when the value changes. */
87
- onChange?: (value: InferSchemaValue<T, Ref, "output">) => void;
87
+ onChange?: (value: InferSchemaValue<T, SchemaRef, "output">) => void;
88
88
  /** Run `safeParse` / `safeEncode` on change. */
89
89
  validate?: boolean;
90
90
  /** Called with the ZodError on validation failure. */
@@ -96,7 +96,7 @@
96
96
  /** When true, any diagnostic becomes a thrown error. */
97
97
  strict?: boolean;
98
98
  /** Per-field meta overrides. */
99
- fields?: InferFields<T, Ref>;
99
+ fields?: InferFields<T, SchemaRef>;
100
100
  /** Meta overrides applied to the root schema. */
101
101
  meta?: SchemaMeta;
102
102
  /** Convenience: sets readOnly on all fields. */
@@ -119,7 +119,7 @@
119
119
 
120
120
  const {
121
121
  schema,
122
- ref,
122
+ schemaRef,
123
123
  io,
124
124
  value,
125
125
  onChange,
@@ -176,7 +176,7 @@
176
176
  }
177
177
 
178
178
  const normalisedResult = $derived<NormalisedShape | SchemaError>(
179
- normaliseSafely(schema, ref, io, diagnostics)
179
+ normaliseSafely(schema, schemaRef, io, diagnostics)
180
180
  );
181
181
 
182
182
  /**
@@ -234,7 +234,7 @@
234
234
  // contravariant assignment cannot be proven by
235
235
  // TypeScript and is the same pattern used in
236
236
  // `react/SchemaComponent.tsx`.
237
- onChange(nextValue as InferSchemaValue<T, Ref, "output">);
237
+ onChange(nextValue as InferSchemaValue<T, SchemaRef, "output">);
238
238
  }
239
239
  }
240
240
 
@@ -7,7 +7,7 @@
7
7
  fields inside bespoke layouts when `<SchemaComponent>` would
8
8
  render too much.
9
9
  -->
10
- <script lang="ts" generics="T = unknown, Ref extends string | undefined = undefined">
10
+ <script lang="ts" generics="T = unknown, SchemaRef extends string | undefined = undefined">
11
11
  import { walk } from "../core/walker.ts";
12
12
  import type { WalkOptions } from "../core/walkBuilders.ts";
13
13
  import {
@@ -40,7 +40,7 @@
40
40
  /** The schema to extract the field from. */
41
41
  schema: T;
42
42
  /** OpenAPI ref string. */
43
- ref?: Ref;
43
+ schemaRef?: SchemaRef;
44
44
  /** Direction (`"output"` / `"input"`) for codec / transform schemas. */
45
45
  io?: SchemaIoSide;
46
46
  /** Current value of the root schema. */
@@ -59,7 +59,7 @@
59
59
  const {
60
60
  path,
61
61
  schema,
62
- ref,
62
+ schemaRef,
63
63
  io,
64
64
  value,
65
65
  onChange,
@@ -80,7 +80,7 @@
80
80
  }
81
81
 
82
82
  const normalisedResult = $derived<NormalisedShape>(
83
- normaliseOrThrow(schema, ref, io)
83
+ normaliseOrThrow(schema, schemaRef, io)
84
84
  );
85
85
 
86
86
  const walkOptions = $derived<WalkOptions>({
@@ -20,7 +20,7 @@
20
20
  - No global widget lookup — Svelte SSR mustn't read
21
21
  module-level mutable state.
22
22
  -->
23
- <script lang="ts" generics="T = unknown, Ref extends string | undefined = undefined">
23
+ <script lang="ts" generics="T = unknown, SchemaRef extends string | undefined = undefined">
24
24
  import { walk } from "../core/walker.ts";
25
25
  import type { WalkOptions } from "../core/walkBuilders.ts";
26
26
  import {
@@ -51,10 +51,10 @@
51
51
 
52
52
  interface Props {
53
53
  schema: T;
54
- ref?: Ref;
54
+ schemaRef?: SchemaRef;
55
55
  io?: SchemaIoSide;
56
- value?: InferredValue<T, Ref, undefined, "output">;
57
- fields?: InferFields<T, Ref>;
56
+ value?: InferredValue<T, SchemaRef, undefined, "output">;
57
+ fields?: InferFields<T, SchemaRef>;
58
58
  meta?: SchemaMeta;
59
59
  description?: string;
60
60
  /** Theme resolver — Svelte SSR has no context fallthrough, pass explicitly. */
@@ -68,7 +68,7 @@
68
68
 
69
69
  const {
70
70
  schema,
71
- ref,
71
+ schemaRef,
72
72
  io,
73
73
  value,
74
74
  fields,
@@ -113,7 +113,7 @@
113
113
  }
114
114
 
115
115
  const normalisedResult = $derived<NormalisedShape>(
116
- normaliseOrThrow(schema, ref, io, diagnostics)
116
+ normaliseOrThrow(schema, schemaRef, io, diagnostics)
117
117
  );
118
118
 
119
119
  const fieldsRecord = $derived(toRecordOrUndefined(fields));
@@ -40,7 +40,7 @@ const props = withDefaults(
40
40
  /** Zod schema, JSON Schema object, or OpenAPI document. */
41
41
  schema: unknown;
42
42
  /** For OpenAPI: a ref string like `#/components/schemas/User`. */
43
- refPath?: string;
43
+ schemaRef?: string;
44
44
  /** v-model binding for the current value. */
45
45
  modelValue?: unknown;
46
46
  /**
@@ -72,7 +72,7 @@ const props = withDefaults(
72
72
  onError?: (error: SchemaNormalisationError) => void;
73
73
  }>(),
74
74
  {
75
- refPath: undefined,
75
+ schemaRef: undefined,
76
76
  modelValue: undefined,
77
77
  onChange: undefined,
78
78
  readOnly: false,
@@ -141,7 +141,7 @@ const normalised = computed<Normalised>(() => {
141
141
  // consistency with the React adapter, which receives raw
142
142
  // values directly.
143
143
  const rawSchema = toRaw(props.schema);
144
- const result = normaliseSchema(rawSchema, props.refPath, opts);
144
+ const result = normaliseSchema(rawSchema, props.schemaRef, opts);
145
145
  return {
146
146
  jsonSchema: result.jsonSchema,
147
147
  rootMeta: result.rootMeta,
@@ -41,7 +41,7 @@ const props = withDefaults(
41
41
  /** The schema to extract the field from. */
42
42
  schema: unknown;
43
43
  /** For OpenAPI: a ref string. */
44
- refPath?: string;
44
+ schemaRef?: string;
45
45
  /** Current value of the root object the field belongs to. */
46
46
  modelValue?: unknown;
47
47
  /** Explicit onChange callback. Wired alongside `update:modelValue`. */
@@ -52,7 +52,7 @@ const props = withDefaults(
52
52
  idPrefix?: string;
53
53
  }>(),
54
54
  {
55
- refPath: undefined,
55
+ schemaRef: undefined,
56
56
  modelValue: undefined,
57
57
  onChange: undefined,
58
58
  meta: () => ({}),
@@ -80,7 +80,7 @@ const normalised = computed<Normalised>(() => {
80
80
  // Zod schemas carry non-configurable members that Vue's
81
81
  // default reactive Proxy cannot mirror.
82
82
  const rawSchema = toRaw(props.schema);
83
- const result = normaliseSchema(rawSchema, props.refPath);
83
+ const result = normaliseSchema(rawSchema, props.schemaRef);
84
84
  return {
85
85
  jsonSchema: result.jsonSchema,
86
86
  rootMeta: result.rootMeta,
@@ -38,7 +38,7 @@ const props = withDefaults(
38
38
  /** Zod schema, JSON Schema object, or OpenAPI document. */
39
39
  schema: unknown;
40
40
  /** For OpenAPI: a ref string. */
41
- refPath?: string;
41
+ schemaRef?: string;
42
42
  /** Current value to render. */
43
43
  value?: unknown;
44
44
  /** Meta overrides applied to the root schema. */
@@ -63,7 +63,7 @@ const props = withDefaults(
63
63
  strict?: boolean;
64
64
  }>(),
65
65
  {
66
- refPath: undefined,
66
+ schemaRef: undefined,
67
67
  value: undefined,
68
68
  meta: () => ({}),
69
69
  description: undefined,
@@ -110,7 +110,7 @@ const normalised = computed<Normalised>(() => {
110
110
  // `_zod` data members that Vue's default Proxy cannot mirror).
111
111
  // See the matching comment in `SchemaComponent.vue`.
112
112
  const rawSchema = toRaw(props.schema);
113
- const result = normaliseSchema(rawSchema, props.refPath, opts);
113
+ const result = normaliseSchema(rawSchema, props.schemaRef, opts);
114
114
  return {
115
115
  jsonSchema: result.jsonSchema,
116
116
  rootMeta: result.rootMeta,