schema-components 2.0.2 → 2.1.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 (180) hide show
  1. package/README.md +98 -1
  2. package/dist/SchemaComponent-B__6-5-E.d.mts +277 -0
  3. package/dist/SchemaComponent-BxzzsHsK.mjs +668 -0
  4. package/dist/adapter-ktQaheWB.d.mts +213 -0
  5. package/dist/constructorTypes-BdCiMS6e.d.mts +30 -0
  6. package/dist/core/adapter.d.mts +3 -213
  7. package/dist/core/constraintHint.d.mts +1 -1
  8. package/dist/core/constraints.d.mts +2 -2
  9. package/dist/core/contexts.d.mts +71 -0
  10. package/dist/core/contexts.mjs +1 -0
  11. package/dist/core/diagnostics.d.mts +1 -1
  12. package/dist/core/errors.d.mts +1 -1
  13. package/dist/core/fieldOrder.d.mts +1 -1
  14. package/dist/{react → core}/fieldPath.d.mts +2 -2
  15. package/dist/{react → core}/fieldPath.mjs +3 -3
  16. package/dist/core/formats.d.mts +1 -1
  17. package/dist/core/inferValue.d.mts +1 -1
  18. package/dist/core/limits.d.mts +1 -1
  19. package/dist/core/merge.d.mts +1 -1
  20. package/dist/core/normalise.d.mts +2 -2
  21. package/dist/core/ref.d.mts +1 -1
  22. package/dist/core/renderField.d.mts +147 -0
  23. package/dist/core/renderField.mjs +81 -0
  24. package/dist/core/renderer.d.mts +2 -199
  25. package/dist/core/swagger2.d.mts +1 -1
  26. package/dist/core/typeInference.d.mts +1 -982
  27. package/dist/core/types.d.mts +1 -1
  28. package/dist/core/unionMatch.d.mts +1 -1
  29. package/dist/core/version.d.mts +1 -1
  30. package/dist/core/walkBuilders.d.mts +3 -3
  31. package/dist/core/walker.d.mts +1 -1
  32. package/dist/{errors-Dki7tji4.d.mts → errors-DbaI04x2.d.mts} +1 -1
  33. package/dist/html/a11y.d.mts +2 -2
  34. package/dist/html/renderToHtml.d.mts +5 -5
  35. package/dist/html/renderToHtml.mjs +33 -18
  36. package/dist/html/renderToHtmlStream.d.mts +5 -5
  37. package/dist/html/renderers.d.mts +1 -1
  38. package/dist/html/streamRenderers.d.mts +3 -3
  39. package/dist/{inferValue-Ce-PviSD.d.mts → inferValue-eAnh50EM.d.mts} +3 -3
  40. package/dist/lit/SchemaComponent.d.mts +125 -0
  41. package/dist/lit/SchemaComponent.mjs +2 -0
  42. package/dist/lit/SchemaField.d.mts +65 -0
  43. package/dist/lit/SchemaField.mjs +2 -0
  44. package/dist/lit/SchemaView.d.mts +14 -0
  45. package/dist/lit/SchemaView.mjs +2 -0
  46. package/dist/lit/constructorTypes.d.mts +2 -0
  47. package/dist/lit/constructorTypes.mjs +1 -0
  48. package/dist/lit/contexts.d.mts +78 -0
  49. package/dist/lit/contexts.mjs +238 -0
  50. package/dist/lit/defaultResolver.d.mts +33 -0
  51. package/dist/lit/defaultResolver.mjs +2 -0
  52. package/dist/lit/registry.d.mts +66 -0
  53. package/dist/lit/registry.mjs +2 -0
  54. package/dist/lit/renderers/baseElement.d.mts +131 -0
  55. package/dist/lit/renderers/baseElement.mjs +109 -0
  56. package/dist/lit/renderers/recordHelpers.d.mts +25 -0
  57. package/dist/lit/renderers/recordHelpers.mjs +55 -0
  58. package/dist/lit/renderers/scArray.d.mts +14 -0
  59. package/dist/lit/renderers/scArray.mjs +86 -0
  60. package/dist/lit/renderers/scBoolean.d.mts +15 -0
  61. package/dist/lit/renderers/scBoolean.mjs +47 -0
  62. package/dist/lit/renderers/scConditional.d.mts +23 -0
  63. package/dist/lit/renderers/scConditional.mjs +65 -0
  64. package/dist/lit/renderers/scDiscriminated.d.mts +23 -0
  65. package/dist/lit/renderers/scDiscriminated.mjs +138 -0
  66. package/dist/lit/renderers/scEnum.d.mts +16 -0
  67. package/dist/lit/renderers/scEnum.mjs +66 -0
  68. package/dist/lit/renderers/scFile.d.mts +15 -0
  69. package/dist/lit/renderers/scFile.mjs +53 -0
  70. package/dist/lit/renderers/scLiteralNullNever.d.mts +30 -0
  71. package/dist/lit/renderers/scLiteralNullNever.mjs +57 -0
  72. package/dist/lit/renderers/scNumber.d.mts +15 -0
  73. package/dist/lit/renderers/scNumber.mjs +64 -0
  74. package/dist/lit/renderers/scObject.d.mts +14 -0
  75. package/dist/lit/renderers/scObject.mjs +57 -0
  76. package/dist/lit/renderers/scRecord.d.mts +14 -0
  77. package/dist/lit/renderers/scRecord.mjs +112 -0
  78. package/dist/lit/renderers/scString.d.mts +19 -0
  79. package/dist/lit/renderers/scString.mjs +165 -0
  80. package/dist/lit/renderers/scTuple.d.mts +14 -0
  81. package/dist/lit/renderers/scTuple.mjs +58 -0
  82. package/dist/lit/renderers/scUnion.d.mts +14 -0
  83. package/dist/lit/renderers/scUnion.mjs +44 -0
  84. package/dist/lit/renderers/scUnknown.d.mts +15 -0
  85. package/dist/lit/renderers/scUnknown.mjs +45 -0
  86. package/dist/lit/ssr.d.mts +37 -0
  87. package/dist/lit/ssr.mjs +9565 -0
  88. package/dist/lit/types.d.mts +2 -0
  89. package/dist/lit/types.mjs +1 -0
  90. package/dist/lit/widget.d.mts +71 -0
  91. package/dist/lit/widget.mjs +87 -0
  92. package/dist/openapi/ApiCallbacks.d.mts +1 -1
  93. package/dist/openapi/ApiLinks.d.mts +1 -1
  94. package/dist/openapi/ApiResponseHeaders.d.mts +1 -1
  95. package/dist/openapi/ApiSecurity.d.mts +1 -1
  96. package/dist/openapi/components.d.mts +4 -4
  97. package/dist/openapi/parser.d.mts +2 -2
  98. package/dist/openapi/resolve.d.mts +1 -1
  99. package/dist/preact/SchemaComponent.d.mts +3 -0
  100. package/dist/preact/SchemaComponent.mjs +26 -0
  101. package/dist/preact/SchemaErrorBoundary.d.mts +2 -0
  102. package/dist/preact/SchemaErrorBoundary.mjs +20 -0
  103. package/dist/preact/SchemaView.d.mts +2 -0
  104. package/dist/preact/SchemaView.mjs +22 -0
  105. package/dist/preact/headless.d.mts +2 -0
  106. package/dist/preact/headless.mjs +18 -0
  107. package/dist/react/SchemaComponent.d.mts +3 -270
  108. package/dist/react/SchemaComponent.mjs +41 -32
  109. package/dist/react/SchemaView.d.mts +6 -6
  110. package/dist/react/SchemaView.mjs +32 -29
  111. package/dist/react/a11y.d.mts +2 -2
  112. package/dist/react/fieldShell.d.mts +1 -1
  113. package/dist/react/headless.d.mts +1 -1
  114. package/dist/react/headlessRenderers.d.mts +2 -2
  115. package/dist/{ref-DdsbekXX.d.mts → ref-DWrQG1Er.d.mts} +1 -1
  116. package/dist/renderer-ab9E52Bp.d.mts +245 -0
  117. package/dist/solid/SchemaComponent.d.mts +136 -0
  118. package/dist/solid/SchemaComponent.mjs +391 -0
  119. package/dist/solid/SchemaErrorBoundary.d.mts +38 -0
  120. package/dist/solid/SchemaErrorBoundary.mjs +57 -0
  121. package/dist/solid/SchemaField.d.mts +40 -0
  122. package/dist/solid/SchemaField.mjs +113 -0
  123. package/dist/solid/SchemaView.d.mts +54 -0
  124. package/dist/solid/SchemaView.mjs +168 -0
  125. package/dist/solid/a11y.d.mts +70 -0
  126. package/dist/solid/a11y.mjs +71 -0
  127. package/dist/solid/contexts.d.mts +37 -0
  128. package/dist/solid/contexts.mjs +66 -0
  129. package/dist/solid/headless.d.mts +10 -0
  130. package/dist/solid/headless.mjs +27 -0
  131. package/dist/solid/renderers.d.mts +79 -0
  132. package/dist/solid/renderers.mjs +840 -0
  133. package/dist/solid/types.d.mts +90 -0
  134. package/dist/solid/types.mjs +1 -0
  135. package/dist/solid/widget.d.mts +29 -0
  136. package/dist/solid/widget.mjs +35 -0
  137. package/dist/themes/mantine.d.mts +1 -1
  138. package/dist/themes/mui.d.mts +1 -1
  139. package/dist/themes/radix.d.mts +1 -1
  140. package/dist/themes/shadcn.d.mts +1 -1
  141. package/dist/typeInference-Y8tNEQJk.d.mts +983 -0
  142. package/dist/types-BCy7K3nk.d.mts +125 -0
  143. package/package.json +71 -1
  144. package/src/svelte/SchemaComponent.svelte +427 -0
  145. package/src/svelte/SchemaErrorBoundary.svelte +66 -0
  146. package/src/svelte/SchemaField.svelte +216 -0
  147. package/src/svelte/SchemaProvider.svelte +46 -0
  148. package/src/svelte/SchemaView.svelte +244 -0
  149. package/src/svelte/a11y.ts +112 -0
  150. package/src/svelte/contexts.ts +79 -0
  151. package/src/svelte/dispatch.ts +267 -0
  152. package/src/svelte/headless.ts +73 -0
  153. package/src/svelte/headlessFns.ts +124 -0
  154. package/src/svelte/renderers/Array.svelte +98 -0
  155. package/src/svelte/renderers/Boolean.svelte +43 -0
  156. package/src/svelte/renderers/Conditional.svelte +67 -0
  157. package/src/svelte/renderers/DiscriminatedUnion.svelte +197 -0
  158. package/src/svelte/renderers/Enum.svelte +53 -0
  159. package/src/svelte/renderers/Fallback.svelte +24 -0
  160. package/src/svelte/renderers/File.svelte +46 -0
  161. package/src/svelte/renderers/Literal.svelte +29 -0
  162. package/src/svelte/renderers/Mount.svelte +24 -0
  163. package/src/svelte/renderers/Negation.svelte +35 -0
  164. package/src/svelte/renderers/Never.svelte +24 -0
  165. package/src/svelte/renderers/Null.svelte +19 -0
  166. package/src/svelte/renderers/Number.svelte +68 -0
  167. package/src/svelte/renderers/Object.svelte +74 -0
  168. package/src/svelte/renderers/Record.svelte +134 -0
  169. package/src/svelte/renderers/RecursionSentinel.svelte +27 -0
  170. package/src/svelte/renderers/String.svelte +152 -0
  171. package/src/svelte/renderers/Tuple.svelte +84 -0
  172. package/src/svelte/renderers/Union.svelte +49 -0
  173. package/src/svelte/renderers/Unknown.svelte +42 -0
  174. package/src/svelte/svelte-modules.d.ts +25 -0
  175. package/src/svelte/types.ts +238 -0
  176. package/src/svelte/widget.ts +62 -0
  177. /package/dist/{diagnostics-BTrm3O6J.d.mts → diagnostics-mftUZI7c.d.mts} +0 -0
  178. /package/dist/{limits-x4OiyJxh.d.mts → limits-Vv9hUbI_.d.mts} +0 -0
  179. /package/dist/{types-BrYbjC7_.d.mts → types-BBQaEPfE.d.mts} +0 -0
  180. /package/dist/{version-DL8U5RuA.d.mts → version-BEBx10ND.d.mts} +0 -0
@@ -0,0 +1,147 @@
1
+ import { j as WalkedField } from "../types-BBQaEPfE.mjs";
2
+ import { l as RenderFunction } from "../renderer-ab9E52Bp.mjs";
3
+
4
+ //#region src/core/renderField.d.ts
5
+ /**
6
+ * Per-adapter configuration consumed by {@link dispatchRenderField}.
7
+ *
8
+ * Each adapter (React, HTML, future Vue / Solid / Svelte / Lit) supplies
9
+ * one of these to plug its own per-field-props shape, output type, and
10
+ * fallback/error behaviour into the shared dispatch loop without having
11
+ * the dispatcher hardcode any framework-specific imports.
12
+ *
13
+ * @typeParam Props - The shape of the per-field props passed to render
14
+ * functions and widgets (e.g. `RenderProps` for React,
15
+ * `HtmlRenderProps` for HTML).
16
+ * @typeParam Output - The type each render function and widget emits
17
+ * for a single field (e.g. `unknown` / `ReactNode` for React,
18
+ * `string` for HTML).
19
+ * @typeParam Resolver - The resolver shape that maps schema types to
20
+ * render functions (e.g. `ComponentResolver` for React,
21
+ * `HtmlResolver` for HTML).
22
+ */
23
+ interface DispatchConfig<Props, Output, Resolver> {
24
+ /**
25
+ * Build the per-field props handed to the render function or widget
26
+ * when it is about to be invoked. Called at most once per dispatch
27
+ * — adapters that need the same props for both the widget lookup
28
+ * and the resolver lookup may call it twice through the
29
+ * `dispatchRenderField` boundary.
30
+ */
31
+ buildProps: (tree: WalkedField, path: string) => Props;
32
+ /**
33
+ * Look up a render function for `tree.type` in the resolver. Each
34
+ * adapter wires this to its own `getRenderFunction` /
35
+ * `getHtmlRenderFn` lookup so the dispatcher does not need to know
36
+ * which resolver shape applies.
37
+ *
38
+ * The returned render function's output is typed `unknown` rather
39
+ * than `Output` so adapters whose render functions historically
40
+ * returned a broader type (React's
41
+ * `RenderFunction\<unknown, RenderProps\>`) compose naturally. The
42
+ * dispatcher hands the `unknown` return value to
43
+ * {@link DispatchConfig.coerceResult}, which narrows it to
44
+ * `Output` once per dispatch.
45
+ */
46
+ lookupRenderFn: (type: WalkedField["type"], resolver: Resolver) => RenderFunction<unknown, Props> | undefined;
47
+ /**
48
+ * Produce the output emitted when the dispatcher hits
49
+ * {@link MAX_RENDER_DEPTH}. Adapters return their own sentinel
50
+ * (React: a `<fieldset>` element; HTML: the `recursionSentinelHtml`
51
+ * string; etc.) so the caller decides how to mark recursive
52
+ * positions in the rendered output.
53
+ */
54
+ recursionSentinel: (tree: WalkedField) => Output;
55
+ /**
56
+ * Produce the output emitted when no widget or resolver render
57
+ * function handled the field. Most adapters either return a
58
+ * `<span>` of the stringified value (React) or throw — the
59
+ * dispatcher does not interpret the return value, only forwards
60
+ * it.
61
+ */
62
+ fallback: (tree: WalkedField, value: unknown, path: string) => Output;
63
+ /**
64
+ * Coerce the raw `unknown` return value of a render function or
65
+ * widget into the adapter's `Output` type, or `undefined` if the
66
+ * result should be discarded (so the dispatcher falls through to
67
+ * the next step).
68
+ *
69
+ * The `step` argument identifies which dispatch stage produced
70
+ * the result — `"widget"` for a `.meta({ component })` match,
71
+ * `"resolver"` for the per-type render function. The two cases
72
+ * historically differed in how they treated `null` /
73
+ * `undefined` returns (widget falls through; resolver
74
+ * short-circuits with `null` so empty-array suppressions render
75
+ * nothing), and adapters can preserve that asymmetry by
76
+ * branching on `step`.
77
+ *
78
+ * Each adapter applies its own validity check here — React
79
+ * narrows via `isValidElement`/string/number, HTML treats every
80
+ * string as valid, etc. Returning `undefined` makes the
81
+ * dispatcher behave as if no renderer produced output.
82
+ */
83
+ coerceResult: (result: unknown, step: "widget" | "resolver") => Output | undefined;
84
+ /**
85
+ * Optional widget-lookup hook. When present, the dispatcher
86
+ * consults it before the resolver lookup. Called once per
87
+ * dispatch with the value of `tree.meta.component`; should
88
+ * return the registered render function or `undefined` if no
89
+ * widget matches. The returned function's output type matches
90
+ * the resolver lookup (`unknown`) — see
91
+ * {@link DispatchConfig.lookupRenderFn}.
92
+ */
93
+ lookupWidget?: (name: string) => RenderFunction<unknown, Props> | undefined;
94
+ /**
95
+ * Wrap a render-time error in a {@link SchemaRenderError} (or a
96
+ * caller-specified subclass) so every adapter routes thrown
97
+ * errors through the same structured path. Called only for
98
+ * errors thrown by the resolver render function — widget errors
99
+ * propagate without wrapping, matching the historic React
100
+ * behaviour where widgets are user code at the application
101
+ * boundary.
102
+ */
103
+ wrapRenderError?: (err: unknown, tree: WalkedField, path: string) => Error;
104
+ }
105
+ /**
106
+ * Arguments accepted by {@link dispatchRenderField}.
107
+ *
108
+ * @typeParam Props - The per-field props shape.
109
+ * @typeParam Output - The adapter's per-field output type.
110
+ * @typeParam Resolver - The resolver shape mapping schema types to
111
+ * render functions.
112
+ */
113
+ interface DispatchArgs<Props, Output, Resolver> {
114
+ /** The walked field to render. */
115
+ tree: WalkedField;
116
+ /** The data value at this position in the tree. */
117
+ value: unknown;
118
+ /** Dot-separated path from the schema root. */
119
+ path: string;
120
+ /** Recursion depth — incremented by callers as they descend. */
121
+ depth: number;
122
+ /** The merged resolver to look up the per-type render function on. */
123
+ resolver: Resolver;
124
+ /** The dispatch configuration for the active adapter. */
125
+ config: DispatchConfig<Props, Output, Resolver>;
126
+ }
127
+ /**
128
+ * Framework-agnostic dispatch loop shared by the React, HTML, and
129
+ * future adapters. See the module-level documentation for the fixed
130
+ * dispatch order.
131
+ *
132
+ * The dispatcher itself is intentionally side-effect free — it never
133
+ * imports React, never builds HTML strings, and never reads any global
134
+ * state. Adapter-specific work (widget registry lookup, recursion
135
+ * sentinel construction, result coercion, error wrapping) is supplied
136
+ * via the {@link DispatchConfig} argument.
137
+ *
138
+ * @typeParam Props - The per-field props shape.
139
+ * @typeParam Output - The adapter's per-field output type.
140
+ * @typeParam Resolver - The resolver shape.
141
+ * @returns The output produced by the matched widget, render function,
142
+ * or fallback — exactly one of the four dispatch steps always emits
143
+ * a value.
144
+ */
145
+ declare function dispatchRenderField<Props, Output, Resolver>(args: DispatchArgs<Props, Output, Resolver>): Output;
146
+ //#endregion
147
+ export { DispatchArgs, DispatchConfig, dispatchRenderField };
@@ -0,0 +1,81 @@
1
+ import "./limits.mjs";
2
+ import { SchemaRenderError } from "./errors.mjs";
3
+ //#region src/core/renderField.ts
4
+ /**
5
+ * Framework-generic render-field dispatcher.
6
+ *
7
+ * Centralises the dispatch loop shared by the React `SchemaComponent` /
8
+ * `SchemaView` renderers, the synchronous HTML renderer in
9
+ * `renderToHtml`, and (in the future) Vue / Solid / Svelte / Lit
10
+ * adapters. The dispatcher is intentionally framework-agnostic: it
11
+ * neither imports React nor produces HTML strings directly. Each
12
+ * adapter supplies a small {@link DispatchConfig} describing how to
13
+ * build per-field props, how to handle a successful or absent resolver
14
+ * lookup, and (optionally) how to handle widget overrides and the
15
+ * recursion-depth cap.
16
+ *
17
+ * The dispatch order is fixed and matches the historic React-side
18
+ * behaviour so the React, HTML, and future adapters all observe the
19
+ * same resolution chain:
20
+ *
21
+ * 1. Depth cap — when `depth >= MAX_RENDER_DEPTH`, return the
22
+ * adapter's recursion sentinel without invoking any renderer.
23
+ * 2. Widget override — if a `.meta({ component })` hint matches a
24
+ * registered widget, call it. A non-empty result short-circuits.
25
+ * 3. Resolver render function — look up `tree.type` in the supplied
26
+ * resolver and call it. Render-time errors are wrapped via
27
+ * {@link DispatchConfig.wrapRenderError} so every adapter routes
28
+ * thrown errors through the same {@link SchemaRenderError} path.
29
+ * 4. Fallback — when no renderer produced output, return the
30
+ * adapter's `fallback` output.
31
+ *
32
+ * The helpers that find render functions, merge resolvers, and build
33
+ * the per-field props live in {@link "./renderer.ts"} and are reused
34
+ * here — `core/renderField.ts` is purely the dispatch shell.
35
+ */
36
+ /**
37
+ * Framework-agnostic dispatch loop shared by the React, HTML, and
38
+ * future adapters. See the module-level documentation for the fixed
39
+ * dispatch order.
40
+ *
41
+ * The dispatcher itself is intentionally side-effect free — it never
42
+ * imports React, never builds HTML strings, and never reads any global
43
+ * state. Adapter-specific work (widget registry lookup, recursion
44
+ * sentinel construction, result coercion, error wrapping) is supplied
45
+ * via the {@link DispatchConfig} argument.
46
+ *
47
+ * @typeParam Props - The per-field props shape.
48
+ * @typeParam Output - The adapter's per-field output type.
49
+ * @typeParam Resolver - The resolver shape.
50
+ * @returns The output produced by the matched widget, render function,
51
+ * or fallback — exactly one of the four dispatch steps always emits
52
+ * a value.
53
+ */
54
+ function dispatchRenderField(args) {
55
+ const { tree, value, path, depth, resolver, config } = args;
56
+ if (depth >= 10) return config.recursionSentinel(tree);
57
+ const componentHint = tree.meta.component;
58
+ if (config.lookupWidget !== void 0 && typeof componentHint === "string") {
59
+ const widget = config.lookupWidget(componentHint);
60
+ if (widget !== void 0) {
61
+ const rawResult = widget(config.buildProps(tree, path));
62
+ const coerced = config.coerceResult(rawResult, "widget");
63
+ if (coerced !== void 0) return coerced;
64
+ }
65
+ }
66
+ const renderFn = config.lookupRenderFn(tree.type, resolver);
67
+ if (renderFn !== void 0) {
68
+ let rawResult;
69
+ try {
70
+ rawResult = renderFn(config.buildProps(tree, path));
71
+ } catch (err) {
72
+ if (config.wrapRenderError !== void 0) throw config.wrapRenderError(err, tree, path);
73
+ throw new SchemaRenderError(err instanceof Error ? err.message : `Render function threw for type "${tree.type}"`, tree, tree.type, err);
74
+ }
75
+ const coerced = config.coerceResult(rawResult, "resolver");
76
+ if (coerced !== void 0) return coerced;
77
+ }
78
+ return config.fallback(tree, value, path);
79
+ }
80
+ //#endregion
81
+ export { dispatchRenderField };
@@ -1,199 +1,2 @@
1
- import { E as StringConstraints, f as FileConstraints, j as WalkedField, t as ArrayConstraints, w as SchemaMeta, x as ObjectConstraints, y as NumberConstraints } from "../types-BrYbjC7_.mjs";
2
-
3
- //#region src/core/renderer.d.ts
4
- /**
5
- * Flat intersection of all constraint types.
6
- * Used in renderer props where the render function receives the union
7
- * but knows (by resolver key) which subset applies.
8
- *
9
- * The walker's discriminated WalkedField enforces type-correct constraints
10
- * at construction time; the renderer consumes them as this flat type.
11
- */
12
- type AllConstraints = StringConstraints & NumberConstraints & ArrayConstraints & ObjectConstraints & FileConstraints;
13
- /**
14
- * Properties available on every schema field, regardless of rendering target.
15
- * Both React and HTML renderers receive these.
16
- *
17
- * Per-type schema data — enum values, object fields, array element schema,
18
- * union options, record key/value types, tuple `prefixItems`, conditional
19
- * if/then/else clauses, negation `negated`, recursive `refTarget`, literal
20
- * values — lives on the discriminated `tree`. Renderers narrow on
21
- * `tree.type` and read from the matching variant; there are no duplicate
22
- * sibling fields on these props.
23
- */
24
- interface BaseFieldProps {
25
- /** Current field value. */
26
- value: unknown;
27
- /** Whether to render as read-only display. */
28
- readOnly: boolean;
29
- /** Whether to render as an empty input. */
30
- writeOnly: boolean;
31
- /** Schema metadata for this field. */
32
- meta: SchemaMeta;
33
- /** Constraints from schema checks. */
34
- constraints: AllConstraints;
35
- /** Dot-separated path from root (e.g. "address.city"). */
36
- path: string;
37
- /** Example values from the schema's `examples` keyword. */
38
- examples?: unknown[];
39
- /** Walked field tree for recursive rendering. */
40
- tree: WalkedField;
41
- }
42
- /**
43
- * Props for React render functions. Extends BaseFieldProps with:
44
- * - `onChange` — callback to propagate value changes back to state
45
- * - `renderChild` — recursively renders a child field, threading onChange
46
- */
47
- interface RenderProps extends BaseFieldProps {
48
- /** Callback to update the field value. */
49
- onChange: (value: unknown) => void;
50
- /**
51
- * Render a child field. Theme adapters call this to recursively render
52
- * nested structures (object fields, array elements, union options).
53
- * The resolver and rendering context are already wired in.
54
- *
55
- * @param tree - The walked field tree for the child
56
- * @param value - The child's current value
57
- * @param onChange - Callback receiving the child's next value
58
- * @param pathSuffix - Path segment from the parent (e.g. "city",
59
- * "[0]"). Joined to the parent's path with a dot, or substituted
60
- * when the parent acts as a transparent wrapper (union options).
61
- * Required for every container — without it children inherit no
62
- * path and `inputId()` will throw.
63
- */
64
- renderChild: (tree: WalkedField, value: unknown, onChange: (v: unknown) => void, pathSuffix?: string) => unknown;
65
- }
66
- /**
67
- * Props for HTML render functions. Extends BaseFieldProps with:
68
- * - `renderChild` — recursively renders a child field to HTML string
69
- *
70
- * No `onChange` — HTML rendering is pure output with no event handling.
71
- */
72
- interface HtmlRenderProps extends BaseFieldProps {
73
- /**
74
- * Render a child field to an HTML string. Theme adapters call this
75
- * to recursively render nested structures.
76
- *
77
- * @param tree - The walked field tree for the child
78
- * @param value - The child's current value
79
- * @param pathSuffix - Path segment from the parent (e.g. "city",
80
- * "[0]"). When omitted, the child's description is used as fallback.
81
- */
82
- renderChild: (tree: WalkedField, value: unknown, pathSuffix?: string) => string;
83
- }
84
- /**
85
- * Build the `RenderProps` object handed to a resolver render function or a
86
- * widget. Used by both the server-side `<SchemaView>` (which has no
87
- * `onChange`) and the client-side `<SchemaComponent>` (which threads an
88
- * `onChange` callback).
89
- *
90
- * When `onChange` is `undefined` the caller is rendering in read-only mode:
91
- * a noop `onChange` is wired up, `readOnly` is forced to `true`, and
92
- * `writeOnly` is forced to `false`. Otherwise the editability is taken
93
- * from `tree.editability`.
94
- */
95
- declare function buildRenderProps(tree: WalkedField, value: unknown, onChange: ((next: unknown) => void) | undefined, renderChild: RenderProps["renderChild"], path: string): RenderProps;
96
- /**
97
- * Signature for a React render function attached to a
98
- * {@link ComponentResolver}. Receives the per-field {@link RenderProps}
99
- * built by the walker and returns any ReactNode-compatible value.
100
- */
101
- type RenderFunction = (props: RenderProps) => unknown;
102
- /**
103
- * Widget map — maps component hints (from `.meta({ component })`) to render
104
- * functions. A per-render bag consumed by every renderer surface that
105
- * dispatches widget overrides; conceptually parallel to
106
- * {@link ComponentResolver} but keyed by user-supplied hint names rather
107
- * than schema types.
108
- *
109
- * Scoped at three levels in the React renderer:
110
- *
111
- * 1. **Per-instance** — `widgets` prop on `<SchemaComponent>`
112
- * 2. **Context-scoped** — `widgets` prop on `<SchemaProvider>`
113
- * 3. **Global** — `registerWidget()` (app-wide defaults)
114
- *
115
- * Resolution order: instance → context → global → resolver → headless.
116
- */
117
- type WidgetMap = ReadonlyMap<string, RenderFunction>;
118
- /**
119
- * Theme adapter — maps every schema field type to its React renderer.
120
- * Unset keys fall back to the headless resolver. Pass to
121
- * `SchemaProvider` (or `SchemaView.resolver`) to drive every
122
- * schema-driven render with a specific theme.
123
- */
124
- interface ComponentResolver {
125
- string?: RenderFunction;
126
- number?: RenderFunction;
127
- boolean?: RenderFunction;
128
- null?: RenderFunction;
129
- enum?: RenderFunction;
130
- object?: RenderFunction;
131
- array?: RenderFunction;
132
- tuple?: RenderFunction;
133
- record?: RenderFunction;
134
- union?: RenderFunction;
135
- discriminatedUnion?: RenderFunction;
136
- conditional?: RenderFunction;
137
- negation?: RenderFunction;
138
- literal?: RenderFunction;
139
- file?: RenderFunction;
140
- never?: RenderFunction;
141
- unknown?: RenderFunction;
142
- }
143
- /** An HTML render function returns a string. */
144
- type HtmlRenderFunction = (props: HtmlRenderProps) => string;
145
- /**
146
- * HTML resolver — maps schema types to HTML string renderers.
147
- * Structurally mirrors ComponentResolver but produces strings.
148
- */
149
- interface HtmlResolver {
150
- string?: HtmlRenderFunction;
151
- number?: HtmlRenderFunction;
152
- boolean?: HtmlRenderFunction;
153
- null?: HtmlRenderFunction;
154
- enum?: HtmlRenderFunction;
155
- object?: HtmlRenderFunction;
156
- array?: HtmlRenderFunction;
157
- tuple?: HtmlRenderFunction;
158
- record?: HtmlRenderFunction;
159
- union?: HtmlRenderFunction;
160
- discriminatedUnion?: HtmlRenderFunction;
161
- conditional?: HtmlRenderFunction;
162
- negation?: HtmlRenderFunction;
163
- literal?: HtmlRenderFunction;
164
- file?: HtmlRenderFunction;
165
- never?: HtmlRenderFunction;
166
- unknown?: HtmlRenderFunction;
167
- }
168
- /**
169
- * Canonical list of resolver keys, one per {@link WalkedField} variant.
170
- * Iterated by the resolver merge helpers so adding a new key here is the
171
- * single point of change when a new field variant is introduced.
172
- */
173
- declare const RESOLVER_KEYS: readonly ["string", "number", "boolean", "null", "enum", "object", "array", "tuple", "record", "union", "discriminatedUnion", "conditional", "negation", "literal", "file", "never", "unknown"];
174
- type ResolverKey = (typeof RESOLVER_KEYS)[number];
175
- /**
176
- * Map a schema type to the resolver key that handles it.
177
- * Every WalkedField variant has a direct resolver key — exhaustive switch
178
- * ensures new variants surface as a type error rather than silently
179
- * falling through to "unknown".
180
- */
181
- declare function typeToKey(type: WalkedField["type"]): ResolverKey;
182
- /**
183
- * Look up the render function for a schema type in a ComponentResolver.
184
- */
185
- declare function getRenderFunction(type: WalkedField["type"], resolver: ComponentResolver): RenderFunction | undefined;
186
- /**
187
- * Look up the render function for a schema type in an HtmlResolver.
188
- */
189
- declare function getHtmlRenderFn(type: WalkedField["type"], resolver: HtmlResolver): HtmlRenderFunction | undefined;
190
- /**
191
- * Merge two ComponentResolvers — user values take priority, fallback fills gaps.
192
- */
193
- declare function mergeResolvers(user: ComponentResolver, fallback: ComponentResolver): ComponentResolver;
194
- /**
195
- * Merge two HtmlResolvers — user values take priority, fallback fills gaps.
196
- */
197
- declare function mergeHtmlResolvers(user: HtmlResolver, fallback: HtmlResolver): HtmlResolver;
198
- //#endregion
199
- export { AllConstraints, BaseFieldProps, ComponentResolver, HtmlRenderFunction, HtmlRenderProps, HtmlResolver, RESOLVER_KEYS, RenderFunction, RenderProps, WidgetMap, buildRenderProps, getHtmlRenderFn, getRenderFunction, mergeHtmlResolvers, mergeResolvers, typeToKey };
1
+ import { _ as typeToKey, a as HtmlRenderFunction, c as RESOLVER_KEYS, d as WidgetMap, f as buildRenderProps, g as mergeResolvers, h as mergeHtmlResolvers, i as ComponentResolver, l as RenderFunction, m as getRenderFunction, n as BaseFieldProps, o as HtmlRenderProps, p as getHtmlRenderFn, r as BaseRenderProps, s as HtmlResolver, t as AllConstraints, u as RenderProps } from "../renderer-ab9E52Bp.mjs";
2
+ export { AllConstraints, BaseFieldProps, BaseRenderProps, ComponentResolver, HtmlRenderFunction, HtmlRenderProps, HtmlResolver, RESOLVER_KEYS, RenderFunction, RenderProps, WidgetMap, buildRenderProps, getHtmlRenderFn, getRenderFunction, mergeHtmlResolvers, mergeResolvers, typeToKey };
@@ -1,4 +1,4 @@
1
- import { i as DiagnosticsOptions } from "../diagnostics-BTrm3O6J.mjs";
1
+ import { i as DiagnosticsOptions } from "../diagnostics-mftUZI7c.mjs";
2
2
  import { NodeTransform } from "./normalise.mjs";
3
3
 
4
4
  //#region src/core/swagger2.d.ts