schema-components 1.28.2 → 2.0.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.
- package/README.md +38 -16
- package/dist/core/adapter.d.mts +213 -3
- package/dist/core/adapter.mjs +21 -2
- package/dist/core/constraintHint.d.mts +15 -0
- package/dist/core/constraintHint.mjs +24 -0
- package/dist/core/constraints.d.mts +34 -2
- package/dist/core/constraints.mjs +33 -1
- package/dist/core/cssClasses.d.mts +1 -0
- package/dist/core/diagnostics.d.mts +1 -1
- package/dist/core/errors.d.mts +1 -1
- package/dist/core/errors.mjs +22 -12
- package/dist/core/fieldOrder.d.mts +1 -1
- package/dist/core/formats.d.mts +7 -1
- package/dist/core/formats.mjs +6 -0
- package/dist/core/idPath.d.mts +35 -5
- package/dist/core/idPath.mjs +79 -7
- package/dist/core/inferValue.d.mts +2 -0
- package/dist/core/inferValue.mjs +1 -0
- package/dist/core/limits.d.mts +1 -1
- package/dist/core/limits.mjs +6 -0
- package/dist/core/merge.d.mts +22 -1
- package/dist/core/merge.mjs +66 -3
- package/dist/core/normalise.d.mts +17 -2
- package/dist/core/normalise.mjs +1 -1
- package/dist/core/openapi30.mjs +1 -1
- package/dist/core/openapiConstants.d.mts +1 -0
- package/dist/core/ref.d.mts +1 -1
- package/dist/core/refChain.d.mts +3 -4
- package/dist/core/refChain.mjs +2 -3
- package/dist/core/renderer.d.mts +199 -2
- package/dist/core/renderer.mjs +5 -0
- package/dist/core/swagger2.d.mts +1 -1
- package/dist/core/swagger2.mjs +1 -1
- package/dist/core/typeInference.d.mts +3 -3
- package/dist/core/types.d.mts +1 -1
- package/dist/core/types.mjs +17 -0
- package/dist/core/unionMatch.d.mts +1 -1
- package/dist/core/uri.d.mts +12 -4
- package/dist/core/uri.mjs +30 -4
- package/dist/core/version.d.mts +1 -1
- package/dist/core/walkBuilders.d.mts +63 -6
- package/dist/core/walkBuilders.mjs +33 -1
- package/dist/core/walker.d.mts +14 -1
- package/dist/core/walker.mjs +18 -0
- package/dist/{diagnostics-Cbwak-ZX.d.mts → diagnostics-BTrm3O6J.d.mts} +9 -1
- package/dist/{errors-DQSIK4n1.d.mts → errors-Dki7tji4.d.mts} +23 -13
- package/dist/html/a11y.d.mts +3 -7
- package/dist/html/a11y.mjs +1 -16
- package/dist/html/html.d.mts +11 -0
- package/dist/html/html.mjs +11 -0
- package/dist/html/renderToHtml.d.mts +45 -12
- package/dist/html/renderToHtml.mjs +20 -4
- package/dist/html/renderToHtmlStream.d.mts +63 -18
- package/dist/html/renderToHtmlStream.mjs +34 -8
- package/dist/html/renderers.d.mts +6 -31
- package/dist/html/renderers.mjs +45 -91
- package/dist/html/streamRenderers.d.mts +31 -3
- package/dist/html/streamRenderers.mjs +41 -8
- package/dist/inferValue-PPXWJpbN.d.mts +77 -0
- package/dist/{limits-DJhgx5Ay.d.mts → limits-x4OiyJxh.d.mts} +6 -0
- package/dist/{normalise-Db1xaxgx.mjs → normalise-DB-Xtjmn.mjs} +43 -2
- package/dist/openapi/ApiCallbacks.d.mts +13 -1
- package/dist/openapi/ApiCallbacks.mjs +7 -0
- package/dist/openapi/ApiLinks.d.mts +13 -1
- package/dist/openapi/ApiLinks.mjs +7 -0
- package/dist/openapi/ApiResponseHeaders.d.mts +13 -1
- package/dist/openapi/ApiResponseHeaders.mjs +7 -0
- package/dist/openapi/ApiSecurity.d.mts +14 -1
- package/dist/openapi/ApiSecurity.mjs +29 -8
- package/dist/openapi/bundle.d.mts +31 -0
- package/dist/openapi/components.d.mts +135 -20
- package/dist/openapi/components.mjs +90 -15
- package/dist/openapi/parser.d.mts +140 -13
- package/dist/openapi/parser.mjs +84 -12
- package/dist/openapi/resolve.d.mts +42 -47
- package/dist/openapi/resolve.mjs +62 -56
- package/dist/react/SchemaComponent.d.mts +90 -88
- package/dist/react/SchemaComponent.mjs +74 -2
- package/dist/react/SchemaErrorBoundary.d.mts +18 -1
- package/dist/react/SchemaErrorBoundary.mjs +13 -1
- package/dist/react/SchemaView.d.mts +39 -11
- package/dist/react/SchemaView.mjs +23 -6
- package/dist/react/a11y.d.mts +74 -7
- package/dist/react/a11y.mjs +67 -6
- package/dist/react/fieldPath.d.mts +16 -1
- package/dist/react/fieldPath.mjs +25 -1
- package/dist/react/fieldShell.d.mts +49 -0
- package/dist/react/fieldShell.mjs +37 -0
- package/dist/react/headless.d.mts +1 -1
- package/dist/react/headlessRenderers.d.mts +13 -2
- package/dist/react/headlessRenderers.mjs +134 -54
- package/dist/{ref-TdeMfaV_.d.mts → ref-DdsbekXX.d.mts} +33 -1
- package/dist/themes/mantine.d.mts +54 -12
- package/dist/themes/mantine.mjs +195 -140
- package/dist/themes/mui.d.mts +64 -11
- package/dist/themes/mui.mjs +277 -213
- package/dist/themes/radix.d.mts +67 -15
- package/dist/themes/radix.mjs +235 -170
- package/dist/themes/shadcn.d.mts +25 -1
- package/dist/themes/shadcn.mjs +112 -91
- package/dist/{types-BTB73MB8.d.mts → types-BrYbjC7_.d.mts} +30 -0
- package/dist/{version-ZzL5R6cS.d.mts → version-DL8U5RuA.d.mts} +6 -0
- package/package.json +8 -1
- package/dist/adapter-DqlAnZ_w.d.mts +0 -172
- package/dist/renderer-Ul9taFYp.d.mts +0 -169
|
@@ -1,169 +0,0 @@
|
|
|
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-BTB73MB8.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
|
-
type RenderFunction = (props: RenderProps) => unknown;
|
|
97
|
-
interface ComponentResolver {
|
|
98
|
-
string?: RenderFunction;
|
|
99
|
-
number?: RenderFunction;
|
|
100
|
-
boolean?: RenderFunction;
|
|
101
|
-
null?: RenderFunction;
|
|
102
|
-
enum?: RenderFunction;
|
|
103
|
-
object?: RenderFunction;
|
|
104
|
-
array?: RenderFunction;
|
|
105
|
-
tuple?: RenderFunction;
|
|
106
|
-
record?: RenderFunction;
|
|
107
|
-
union?: RenderFunction;
|
|
108
|
-
discriminatedUnion?: RenderFunction;
|
|
109
|
-
conditional?: RenderFunction;
|
|
110
|
-
negation?: RenderFunction;
|
|
111
|
-
recursive?: RenderFunction;
|
|
112
|
-
literal?: RenderFunction;
|
|
113
|
-
file?: RenderFunction;
|
|
114
|
-
never?: RenderFunction;
|
|
115
|
-
unknown?: RenderFunction;
|
|
116
|
-
}
|
|
117
|
-
/** An HTML render function returns a string. */
|
|
118
|
-
type HtmlRenderFunction = (props: HtmlRenderProps) => string;
|
|
119
|
-
/**
|
|
120
|
-
* HTML resolver — maps schema types to HTML string renderers.
|
|
121
|
-
* Structurally mirrors ComponentResolver but produces strings.
|
|
122
|
-
*/
|
|
123
|
-
interface HtmlResolver {
|
|
124
|
-
string?: HtmlRenderFunction;
|
|
125
|
-
number?: HtmlRenderFunction;
|
|
126
|
-
boolean?: HtmlRenderFunction;
|
|
127
|
-
null?: HtmlRenderFunction;
|
|
128
|
-
enum?: HtmlRenderFunction;
|
|
129
|
-
object?: HtmlRenderFunction;
|
|
130
|
-
array?: HtmlRenderFunction;
|
|
131
|
-
tuple?: HtmlRenderFunction;
|
|
132
|
-
record?: HtmlRenderFunction;
|
|
133
|
-
union?: HtmlRenderFunction;
|
|
134
|
-
discriminatedUnion?: HtmlRenderFunction;
|
|
135
|
-
conditional?: HtmlRenderFunction;
|
|
136
|
-
negation?: HtmlRenderFunction;
|
|
137
|
-
recursive?: HtmlRenderFunction;
|
|
138
|
-
literal?: HtmlRenderFunction;
|
|
139
|
-
file?: HtmlRenderFunction;
|
|
140
|
-
never?: HtmlRenderFunction;
|
|
141
|
-
unknown?: HtmlRenderFunction;
|
|
142
|
-
}
|
|
143
|
-
declare const RESOLVER_KEYS: readonly ["string", "number", "boolean", "null", "enum", "object", "array", "tuple", "record", "union", "discriminatedUnion", "conditional", "negation", "literal", "file", "never", "unknown"];
|
|
144
|
-
type ResolverKey = (typeof RESOLVER_KEYS)[number];
|
|
145
|
-
/**
|
|
146
|
-
* Map a schema type to the resolver key that handles it.
|
|
147
|
-
* Every WalkedField variant has a direct resolver key — exhaustive switch
|
|
148
|
-
* ensures new variants surface as a type error rather than silently
|
|
149
|
-
* falling through to "unknown".
|
|
150
|
-
*/
|
|
151
|
-
declare function typeToKey(type: WalkedField["type"]): ResolverKey;
|
|
152
|
-
/**
|
|
153
|
-
* Look up the render function for a schema type in a ComponentResolver.
|
|
154
|
-
*/
|
|
155
|
-
declare function getRenderFunction(type: WalkedField["type"], resolver: ComponentResolver): RenderFunction | undefined;
|
|
156
|
-
/**
|
|
157
|
-
* Look up the render function for a schema type in an HtmlResolver.
|
|
158
|
-
*/
|
|
159
|
-
declare function getHtmlRenderFn(type: WalkedField["type"], resolver: HtmlResolver): HtmlRenderFunction | undefined;
|
|
160
|
-
/**
|
|
161
|
-
* Merge two ComponentResolvers — user values take priority, fallback fills gaps.
|
|
162
|
-
*/
|
|
163
|
-
declare function mergeResolvers(user: ComponentResolver, fallback: ComponentResolver): ComponentResolver;
|
|
164
|
-
/**
|
|
165
|
-
* Merge two HtmlResolvers — user values take priority, fallback fills gaps.
|
|
166
|
-
*/
|
|
167
|
-
declare function mergeHtmlResolvers(user: HtmlResolver, fallback: HtmlResolver): HtmlResolver;
|
|
168
|
-
//#endregion
|
|
169
|
-
export { HtmlRenderProps as a, RenderFunction as c, getHtmlRenderFn as d, getRenderFunction as f, typeToKey as h, HtmlRenderFunction as i, RenderProps as l, mergeResolvers as m, BaseFieldProps as n, HtmlResolver as o, mergeHtmlResolvers as p, ComponentResolver as r, RESOLVER_KEYS as s, AllConstraints as t, buildRenderProps as u };
|