schema-components 2.0.1 → 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.
- package/README.md +98 -1
- package/dist/SchemaComponent-B__6-5-E.d.mts +277 -0
- package/dist/SchemaComponent-BxzzsHsK.mjs +668 -0
- package/dist/adapter-ktQaheWB.d.mts +213 -0
- package/dist/constructorTypes-BdCiMS6e.d.mts +30 -0
- package/dist/core/adapter.d.mts +3 -213
- package/dist/core/adapter.mjs +33 -25
- package/dist/core/constraintHint.d.mts +1 -1
- package/dist/core/constraints.d.mts +2 -2
- package/dist/core/contexts.d.mts +71 -0
- package/dist/core/contexts.mjs +1 -0
- package/dist/core/diagnostics.d.mts +1 -1
- package/dist/core/errors.d.mts +1 -1
- package/dist/core/fieldOrder.d.mts +1 -1
- package/dist/{react → core}/fieldPath.d.mts +2 -2
- package/dist/{react → core}/fieldPath.mjs +3 -3
- package/dist/core/formats.d.mts +1 -1
- package/dist/core/guards.d.mts +2 -2
- package/dist/core/guards.mjs +2 -2
- package/dist/core/inferValue.d.mts +1 -1
- package/dist/core/limits.d.mts +1 -1
- package/dist/core/merge.d.mts +1 -1
- package/dist/core/normalise.d.mts +6 -6
- package/dist/core/normalise.mjs +1 -1
- package/dist/core/openapi30.d.mts +1 -1
- package/dist/core/openapi30.mjs +1 -1
- package/dist/core/ref.d.mts +1 -1
- package/dist/core/renderField.d.mts +147 -0
- package/dist/core/renderField.mjs +81 -0
- package/dist/core/renderer.d.mts +2 -199
- package/dist/core/swagger2.d.mts +1 -1
- package/dist/core/swagger2.mjs +1 -1
- package/dist/core/typeInference.d.mts +1 -981
- package/dist/core/types.d.mts +1 -1
- package/dist/core/unionMatch.d.mts +1 -1
- package/dist/core/uri.d.mts +2 -2
- package/dist/core/uri.mjs +2 -2
- package/dist/core/version.d.mts +1 -1
- package/dist/core/walkBuilders.d.mts +4 -4
- package/dist/core/walkBuilders.mjs +1 -1
- package/dist/core/walker.d.mts +1 -1
- package/dist/core/walker.mjs +3 -3
- package/dist/{errors-Dki7tji4.d.mts → errors-DbaI04x2.d.mts} +1 -1
- package/dist/html/a11y.d.mts +2 -2
- package/dist/html/html.d.mts +10 -8
- package/dist/html/renderToHtml.d.mts +5 -5
- package/dist/html/renderToHtml.mjs +45 -24
- package/dist/html/renderToHtmlStream.d.mts +5 -5
- package/dist/html/renderers.d.mts +1 -1
- package/dist/html/streamRenderers.d.mts +3 -3
- package/dist/{inferValue-PPXWJpbN.d.mts → inferValue-eAnh50EM.d.mts} +6 -6
- package/dist/lit/SchemaComponent.d.mts +125 -0
- package/dist/lit/SchemaComponent.mjs +2 -0
- package/dist/lit/SchemaField.d.mts +65 -0
- package/dist/lit/SchemaField.mjs +2 -0
- package/dist/lit/SchemaView.d.mts +14 -0
- package/dist/lit/SchemaView.mjs +2 -0
- package/dist/lit/constructorTypes.d.mts +2 -0
- package/dist/lit/constructorTypes.mjs +1 -0
- package/dist/lit/contexts.d.mts +78 -0
- package/dist/lit/contexts.mjs +238 -0
- package/dist/lit/defaultResolver.d.mts +33 -0
- package/dist/lit/defaultResolver.mjs +2 -0
- package/dist/lit/registry.d.mts +66 -0
- package/dist/lit/registry.mjs +2 -0
- package/dist/lit/renderers/baseElement.d.mts +131 -0
- package/dist/lit/renderers/baseElement.mjs +109 -0
- package/dist/lit/renderers/recordHelpers.d.mts +25 -0
- package/dist/lit/renderers/recordHelpers.mjs +55 -0
- package/dist/lit/renderers/scArray.d.mts +14 -0
- package/dist/lit/renderers/scArray.mjs +86 -0
- package/dist/lit/renderers/scBoolean.d.mts +15 -0
- package/dist/lit/renderers/scBoolean.mjs +47 -0
- package/dist/lit/renderers/scConditional.d.mts +23 -0
- package/dist/lit/renderers/scConditional.mjs +65 -0
- package/dist/lit/renderers/scDiscriminated.d.mts +23 -0
- package/dist/lit/renderers/scDiscriminated.mjs +138 -0
- package/dist/lit/renderers/scEnum.d.mts +16 -0
- package/dist/lit/renderers/scEnum.mjs +66 -0
- package/dist/lit/renderers/scFile.d.mts +15 -0
- package/dist/lit/renderers/scFile.mjs +53 -0
- package/dist/lit/renderers/scLiteralNullNever.d.mts +30 -0
- package/dist/lit/renderers/scLiteralNullNever.mjs +57 -0
- package/dist/lit/renderers/scNumber.d.mts +15 -0
- package/dist/lit/renderers/scNumber.mjs +64 -0
- package/dist/lit/renderers/scObject.d.mts +14 -0
- package/dist/lit/renderers/scObject.mjs +57 -0
- package/dist/lit/renderers/scRecord.d.mts +14 -0
- package/dist/lit/renderers/scRecord.mjs +112 -0
- package/dist/lit/renderers/scString.d.mts +19 -0
- package/dist/lit/renderers/scString.mjs +165 -0
- package/dist/lit/renderers/scTuple.d.mts +14 -0
- package/dist/lit/renderers/scTuple.mjs +58 -0
- package/dist/lit/renderers/scUnion.d.mts +14 -0
- package/dist/lit/renderers/scUnion.mjs +44 -0
- package/dist/lit/renderers/scUnknown.d.mts +15 -0
- package/dist/lit/renderers/scUnknown.mjs +45 -0
- package/dist/lit/ssr.d.mts +37 -0
- package/dist/lit/ssr.mjs +9565 -0
- package/dist/lit/types.d.mts +2 -0
- package/dist/lit/types.mjs +1 -0
- package/dist/lit/widget.d.mts +71 -0
- package/dist/lit/widget.mjs +87 -0
- package/dist/{normalise-DB-Xtjmn.mjs → normalise-BkePrJ4v.mjs} +6 -6
- package/dist/openapi/ApiCallbacks.d.mts +1 -1
- package/dist/openapi/ApiLinks.d.mts +1 -1
- package/dist/openapi/ApiResponseHeaders.d.mts +1 -1
- package/dist/openapi/ApiSecurity.d.mts +1 -1
- package/dist/openapi/components.d.mts +5 -5
- package/dist/openapi/components.mjs +1 -1
- package/dist/openapi/parser.d.mts +2 -2
- package/dist/openapi/resolve.d.mts +1 -1
- package/dist/openapi/resolve.mjs +1 -1
- package/dist/preact/SchemaComponent.d.mts +3 -0
- package/dist/preact/SchemaComponent.mjs +26 -0
- package/dist/preact/SchemaErrorBoundary.d.mts +2 -0
- package/dist/preact/SchemaErrorBoundary.mjs +20 -0
- package/dist/preact/SchemaView.d.mts +2 -0
- package/dist/preact/SchemaView.mjs +22 -0
- package/dist/preact/headless.d.mts +2 -0
- package/dist/preact/headless.mjs +18 -0
- package/dist/react/SchemaComponent.d.mts +3 -270
- package/dist/react/SchemaComponent.mjs +48 -39
- package/dist/react/SchemaErrorBoundary.mjs +7 -4
- package/dist/react/SchemaView.d.mts +11 -10
- package/dist/react/SchemaView.mjs +32 -29
- package/dist/react/a11y.d.mts +2 -2
- package/dist/react/fieldShell.d.mts +1 -1
- package/dist/react/headless.d.mts +1 -1
- package/dist/react/headlessRenderers.d.mts +2 -2
- package/dist/{ref-DdsbekXX.d.mts → ref-DWrQG1Er.d.mts} +1 -1
- package/dist/renderer-ab9E52Bp.d.mts +245 -0
- package/dist/solid/SchemaComponent.d.mts +136 -0
- package/dist/solid/SchemaComponent.mjs +391 -0
- package/dist/solid/SchemaErrorBoundary.d.mts +38 -0
- package/dist/solid/SchemaErrorBoundary.mjs +57 -0
- package/dist/solid/SchemaField.d.mts +40 -0
- package/dist/solid/SchemaField.mjs +113 -0
- package/dist/solid/SchemaView.d.mts +54 -0
- package/dist/solid/SchemaView.mjs +168 -0
- package/dist/solid/a11y.d.mts +70 -0
- package/dist/solid/a11y.mjs +71 -0
- package/dist/solid/contexts.d.mts +37 -0
- package/dist/solid/contexts.mjs +66 -0
- package/dist/solid/headless.d.mts +10 -0
- package/dist/solid/headless.mjs +27 -0
- package/dist/solid/renderers.d.mts +79 -0
- package/dist/solid/renderers.mjs +840 -0
- package/dist/solid/types.d.mts +90 -0
- package/dist/solid/types.mjs +1 -0
- package/dist/solid/widget.d.mts +29 -0
- package/dist/solid/widget.mjs +35 -0
- package/dist/themes/mantine.d.mts +1 -1
- package/dist/themes/mui.d.mts +1 -1
- package/dist/themes/radix.d.mts +1 -1
- package/dist/themes/shadcn.d.mts +1 -1
- package/dist/typeInference-Y8tNEQJk.d.mts +983 -0
- package/dist/types-BCy7K3nk.d.mts +125 -0
- package/package.json +71 -1
- package/src/svelte/SchemaComponent.svelte +427 -0
- package/src/svelte/SchemaErrorBoundary.svelte +66 -0
- package/src/svelte/SchemaField.svelte +216 -0
- package/src/svelte/SchemaProvider.svelte +46 -0
- package/src/svelte/SchemaView.svelte +244 -0
- package/src/svelte/a11y.ts +112 -0
- package/src/svelte/contexts.ts +79 -0
- package/src/svelte/dispatch.ts +267 -0
- package/src/svelte/headless.ts +73 -0
- package/src/svelte/headlessFns.ts +124 -0
- package/src/svelte/renderers/Array.svelte +98 -0
- package/src/svelte/renderers/Boolean.svelte +43 -0
- package/src/svelte/renderers/Conditional.svelte +67 -0
- package/src/svelte/renderers/DiscriminatedUnion.svelte +197 -0
- package/src/svelte/renderers/Enum.svelte +53 -0
- package/src/svelte/renderers/Fallback.svelte +24 -0
- package/src/svelte/renderers/File.svelte +46 -0
- package/src/svelte/renderers/Literal.svelte +29 -0
- package/src/svelte/renderers/Mount.svelte +24 -0
- package/src/svelte/renderers/Negation.svelte +35 -0
- package/src/svelte/renderers/Never.svelte +24 -0
- package/src/svelte/renderers/Null.svelte +19 -0
- package/src/svelte/renderers/Number.svelte +68 -0
- package/src/svelte/renderers/Object.svelte +74 -0
- package/src/svelte/renderers/Record.svelte +134 -0
- package/src/svelte/renderers/RecursionSentinel.svelte +27 -0
- package/src/svelte/renderers/String.svelte +152 -0
- package/src/svelte/renderers/Tuple.svelte +84 -0
- package/src/svelte/renderers/Union.svelte +49 -0
- package/src/svelte/renderers/Unknown.svelte +42 -0
- package/src/svelte/svelte-modules.d.ts +25 -0
- package/src/svelte/types.ts +238 -0
- package/src/svelte/widget.ts +62 -0
- /package/dist/{diagnostics-BTrm3O6J.d.mts → diagnostics-mftUZI7c.d.mts} +0 -0
- /package/dist/{limits-x4OiyJxh.d.mts → limits-Vv9hUbI_.d.mts} +0 -0
- /package/dist/{types-BrYbjC7_.d.mts → types-BBQaEPfE.d.mts} +0 -0
- /package/dist/{version-DL8U5RuA.d.mts → version-BEBx10ND.d.mts} +0 -0
|
@@ -1,270 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as
|
|
3
|
-
|
|
4
|
-
import { ComponentResolver, RenderProps, WidgetMap } from "../core/renderer.mjs";
|
|
5
|
-
import { t as SchemaError } from "../errors-Dki7tji4.mjs";
|
|
6
|
-
import { FromJSONSchema, PathOfType, RejectUnrepresentableZod } from "../core/typeInference.mjs";
|
|
7
|
-
import { a as InferredValue, i as InferredOutputValue, n as InferSchemaValue, r as InferredInputValue, t as InferFields } from "../inferValue-PPXWJpbN.mjs";
|
|
8
|
-
import { z } from "zod";
|
|
9
|
-
import * as _$react_jsx_runtime0 from "react/jsx-runtime";
|
|
10
|
-
import { ReactNode } from "react";
|
|
11
|
-
|
|
12
|
-
//#region src/react/SchemaComponent.d.ts
|
|
13
|
-
/**
|
|
14
|
-
* Provide a theme resolver and scoped widgets to every `<SchemaComponent>`
|
|
15
|
-
* and `<SchemaView>` rendered inside the subtree.
|
|
16
|
-
*
|
|
17
|
-
* Wrap an application (or a region of it) with `<SchemaProvider>` so a
|
|
18
|
-
* single theme — typically one of the bundled adapters
|
|
19
|
-
* (`shadcnResolver`, `muiResolver`, `mantineResolver`, `radixResolver`)
|
|
20
|
-
* or a custom one — drives every schema render. Without a provider,
|
|
21
|
-
* schema-components fall back to the headless HTML renderer.
|
|
22
|
-
*
|
|
23
|
-
* @group Components
|
|
24
|
-
* @example
|
|
25
|
-
* ```tsx
|
|
26
|
-
* import { SchemaProvider } from "schema-components/react/SchemaComponent";
|
|
27
|
-
* import { shadcnResolver } from "schema-components/themes/shadcn";
|
|
28
|
-
*
|
|
29
|
-
* <SchemaProvider resolver={shadcnResolver}>
|
|
30
|
-
* <SchemaComponent schema={userSchema} value={user} onChange={setUser} />
|
|
31
|
-
* </SchemaProvider>
|
|
32
|
-
* ```
|
|
33
|
-
*/
|
|
34
|
-
declare function SchemaProvider({
|
|
35
|
-
resolver,
|
|
36
|
-
widgets,
|
|
37
|
-
children
|
|
38
|
-
}: {
|
|
39
|
-
resolver: ComponentResolver; /** Scoped widgets available to all SchemaComponents in this subtree. */
|
|
40
|
-
widgets?: WidgetMap;
|
|
41
|
-
children: ReactNode;
|
|
42
|
-
}): _$react_jsx_runtime0.JSX.Element;
|
|
43
|
-
/**
|
|
44
|
-
* Register a widget globally. The widget is resolved when a schema field
|
|
45
|
-
* has `.meta({ component: name })`.
|
|
46
|
-
*
|
|
47
|
-
* For scoped registration, use the `widgets` prop on `<SchemaComponent>`
|
|
48
|
-
* or `<SchemaProvider>` instead.
|
|
49
|
-
*/
|
|
50
|
-
declare function registerWidget(name: string, render: (props: RenderProps) => unknown): void;
|
|
51
|
-
/**
|
|
52
|
-
* Clear every globally registered widget. Intended for test isolation —
|
|
53
|
-
* `registerWidget` writes to module-level state and that state otherwise
|
|
54
|
-
* leaks across test cases, making the test suite order-dependent. Tests
|
|
55
|
-
* should call this from an `afterEach` hook.
|
|
56
|
-
*
|
|
57
|
-
* @internal
|
|
58
|
-
*/
|
|
59
|
-
declare function __clearGlobalWidgets(): void;
|
|
60
|
-
/**
|
|
61
|
-
* Props accepted by {@link SchemaComponent}.
|
|
62
|
-
*
|
|
63
|
-
* The generic parameters carry the inferred schema shape through to
|
|
64
|
-
* `value`, `onChange`, and `fields` so a typed `schema` prop drives
|
|
65
|
-
* typed props on the rest of the component.
|
|
66
|
-
*
|
|
67
|
-
* @group Components
|
|
68
|
-
*/
|
|
69
|
-
interface SchemaComponentProps<T = unknown, Ref extends string | undefined = undefined, Mode extends SchemaIoSide = "output"> {
|
|
70
|
-
/**
|
|
71
|
-
* Zod schema, JSON Schema object, or OpenAPI document.
|
|
72
|
-
*
|
|
73
|
-
* Zod 4 types that cannot round-trip through `z.toJSONSchema()`
|
|
74
|
-
* (bigint, date, map, set, symbol, function, undefined, void, nan,
|
|
75
|
-
* codec) are rejected at the type level via
|
|
76
|
-
* {@link RejectUnrepresentableZod}. Runtime conversion would throw
|
|
77
|
-
* `SchemaNormalisationError` with kind `zod-type-unrepresentable`
|
|
78
|
-
* — the static rejection surfaces the same failure at compile time.
|
|
79
|
-
*/
|
|
80
|
-
schema: RejectUnrepresentableZod<T>;
|
|
81
|
-
/** For OpenAPI: a ref string like "#/components/schemas/User" or "/users/post". */
|
|
82
|
-
ref?: Ref;
|
|
83
|
-
/**
|
|
84
|
-
* Which side of every transform / pipe / codec to render.
|
|
85
|
-
*
|
|
86
|
-
* - `"output"` (default) — renderer draws the OUTPUT side of the
|
|
87
|
-
* schema. For a `z.codec(z.string(), z.number(), …)` chain
|
|
88
|
-
* this renders a number input. `value` and `onChange` therefore
|
|
89
|
-
* carry the OUTPUT shape, and `validate` runs `safeEncode`
|
|
90
|
-
* (the reverse direction) so user-supplied OUTPUT values are
|
|
91
|
-
* validated against the codec.
|
|
92
|
-
* - `"input"` — renderer draws the INPUT side instead. For the
|
|
93
|
-
* same codec this renders a string input, `value` and
|
|
94
|
-
* `onChange` carry the INPUT shape, and `validate` runs
|
|
95
|
-
* `safeParse` (the forward direction).
|
|
96
|
-
*
|
|
97
|
-
* The choice is propagated through `normaliseSchema` →
|
|
98
|
-
* `normaliseZod4` → `z.toJSONSchema(..., { io })` so a single
|
|
99
|
-
* source of truth drives both the rendered JSON Schema shape and
|
|
100
|
-
* the validation direction. Has no effect for plain JSON Schema
|
|
101
|
-
* or OpenAPI inputs — those advertise a single canonical shape.
|
|
102
|
-
*/
|
|
103
|
-
io?: Mode;
|
|
104
|
-
/**
|
|
105
|
-
* Current value to render. Typed against `InferSchemaValue<T,
|
|
106
|
-
* Ref, Mode>` so the prop tracks the schema's inferred shape for
|
|
107
|
-
* the chosen `io` direction.
|
|
108
|
-
*
|
|
109
|
-
* Falls back to `unknown` when the schema's value type cannot be
|
|
110
|
-
* statically inferred (runtime `Record<string, unknown>` JSON
|
|
111
|
-
* Schemas, OpenAPI documents without a ref, etc.), so untyped
|
|
112
|
-
* call sites still compile.
|
|
113
|
-
*
|
|
114
|
-
* Use {@link InferredOutputValue} or {@link InferredInputValue}
|
|
115
|
-
* to narrow a value declared at the call site:
|
|
116
|
-
*
|
|
117
|
-
* ```tsx
|
|
118
|
-
* const user: InferredOutputValue<typeof userSchema> = { ... };
|
|
119
|
-
* <SchemaComponent schema={userSchema} value={user} readOnly />
|
|
120
|
-
* ```
|
|
121
|
-
*/
|
|
122
|
-
value?: InferSchemaValue<T, Ref, Mode>;
|
|
123
|
-
/**
|
|
124
|
-
* Called when the value changes (editable fields). The parameter
|
|
125
|
-
* shares the same shape as {@link SchemaComponentProps.value} so
|
|
126
|
-
* a controlled component can round-trip the value through React
|
|
127
|
-
* state without re-shaping.
|
|
128
|
-
*
|
|
129
|
-
* Falls back to `unknown` for schemas whose value type cannot be
|
|
130
|
-
* statically inferred — see {@link SchemaComponentProps.value}.
|
|
131
|
-
*/
|
|
132
|
-
onChange?: (value: InferSchemaValue<T, Ref, Mode>) => void;
|
|
133
|
-
/** Run schema.safeParse() on change and surface errors via onValidationError. */
|
|
134
|
-
validate?: boolean;
|
|
135
|
-
/** Called with the ZodError when validation fails. */
|
|
136
|
-
onValidationError?: (error: unknown) => void;
|
|
137
|
-
/** Called when schema normalisation or rendering fails. */
|
|
138
|
-
onError?: (error: SchemaError) => void;
|
|
139
|
-
/** Called with each diagnostic emitted during schema processing. */
|
|
140
|
-
onDiagnostic?: (diagnostic: Diagnostic) => void;
|
|
141
|
-
/** When true, any diagnostic becomes a thrown error. */
|
|
142
|
-
strict?: boolean;
|
|
143
|
-
/** Per-field meta overrides — nested object mirroring schema shape. */
|
|
144
|
-
fields?: InferFields<T, Ref>;
|
|
145
|
-
/** Meta overrides applied to the root schema. */
|
|
146
|
-
meta?: SchemaMeta;
|
|
147
|
-
/** Convenience: sets readOnly on all fields. */
|
|
148
|
-
readOnly?: boolean;
|
|
149
|
-
/** Convenience: sets writeOnly on all fields. */
|
|
150
|
-
writeOnly?: boolean;
|
|
151
|
-
/** Convenience: sets description on the root. */
|
|
152
|
-
description?: string;
|
|
153
|
-
/** Instance-scoped widgets — override context and global widgets. */
|
|
154
|
-
widgets?: WidgetMap;
|
|
155
|
-
/**
|
|
156
|
-
* Prefix used for every input `id`/label `htmlFor` in this component
|
|
157
|
-
* subtree. Defaults to a per-instance value from `useId()` so multiple
|
|
158
|
-
* `<SchemaComponent>` instances on the same page never collide. Override
|
|
159
|
-
* for deterministic ids in screenshot tests.
|
|
160
|
-
*/
|
|
161
|
-
idPrefix?: string;
|
|
162
|
-
}
|
|
163
|
-
/**
|
|
164
|
-
* Render an editable (or read-only) UI from a Zod schema, JSON Schema, or
|
|
165
|
-
* OpenAPI document.
|
|
166
|
-
*
|
|
167
|
-
* Auto-detects the input format, normalises to JSON Schema via the
|
|
168
|
-
* adapter, walks the JSON Schema tree, and delegates per-field rendering
|
|
169
|
-
* to the {@link ComponentResolver} supplied via {@link SchemaProvider} —
|
|
170
|
-
* falling back to a headless HTML renderer when no provider is present.
|
|
171
|
-
*
|
|
172
|
-
* Pass `readOnly` to render a presentational view instead of inputs, or
|
|
173
|
-
* wrap with `<SchemaProvider resolver={…}>` to swap the theme.
|
|
174
|
-
*
|
|
175
|
-
* @group Components
|
|
176
|
-
* @example
|
|
177
|
-
* ```tsx
|
|
178
|
-
* import { z } from "zod";
|
|
179
|
-
* import { SchemaComponent } from "schema-components/react/SchemaComponent";
|
|
180
|
-
*
|
|
181
|
-
* const userSchema = z.object({ name: z.string(), email: z.email() });
|
|
182
|
-
*
|
|
183
|
-
* <SchemaComponent schema={userSchema} value={user} onChange={setUser} />
|
|
184
|
-
* ```
|
|
185
|
-
*/
|
|
186
|
-
declare function SchemaComponent<T = unknown, Ref extends string | undefined = undefined, Mode extends SchemaIoSide = "output">(props: SchemaComponentProps<T, Ref, Mode>): ReactNode;
|
|
187
|
-
/**
|
|
188
|
-
* Append a child path suffix to a parent path. When the suffix is omitted
|
|
189
|
-
* (e.g. transparent wrappers like union options), the parent path is
|
|
190
|
-
* returned unchanged so the child inherits the parent's id.
|
|
191
|
-
*
|
|
192
|
-
* Bracketed array indices like `[0]` append directly so `tags` + `[0]`
|
|
193
|
-
* becomes `tags[0]` rather than `tags.[0]` — matching the canonical form
|
|
194
|
-
* used by `html/a11y.ts` `joinPath` and `react/fieldPath.ts` `resolvePath`,
|
|
195
|
-
* which already parses bracket notation when navigating WalkedField trees.
|
|
196
|
-
*/
|
|
197
|
-
declare function joinPath(parent: string, suffix: string | undefined): string;
|
|
198
|
-
/**
|
|
199
|
-
* Normalise a `useId()` value into a DOM-id-safe prefix. React's `useId`
|
|
200
|
-
* returns values containing `:` characters (e.g. `«:r0:»`) which are
|
|
201
|
-
* invalid in CSS selectors. Replace any run of non-alphanumeric characters
|
|
202
|
-
* with a single hyphen and trim leading/trailing hyphens.
|
|
203
|
-
*/
|
|
204
|
-
declare function sanitisePrefix(value: string): string;
|
|
205
|
-
/**
|
|
206
|
-
* Render a single walked field through the resolved widget /
|
|
207
|
-
* resolver / headless pipeline. Used internally by
|
|
208
|
-
* {@link SchemaComponent} and {@link SchemaField}, exported so other
|
|
209
|
-
* React-side components (e.g. the OpenAPI renderers) can dispatch
|
|
210
|
-
* into the same fallback chain.
|
|
211
|
-
*/
|
|
212
|
-
declare function renderField(tree: WalkedField, value: unknown, onChange: (v: unknown) => void, userResolver: ComponentResolver | undefined, renderChild: (tree: WalkedField, value: unknown, onChange: (v: unknown) => void, pathSuffix?: string) => ReactNode, path: string, instanceWidgets?: WidgetMap, contextWidgets?: WidgetMap, depth?: number): ReactNode;
|
|
213
|
-
/**
|
|
214
|
-
* Infer the schema's output type for SchemaField path inference.
|
|
215
|
-
*/
|
|
216
|
-
type InferSchemaType<T> = T extends z.ZodType ? z.infer<T> : T extends object ? unknown extends FromJSONSchema<T> ? unknown : FromJSONSchema<T> : unknown;
|
|
217
|
-
/**
|
|
218
|
-
* Props accepted by {@link SchemaField}. The generic `P` constrains
|
|
219
|
-
* `path` to dot-paths reachable through the schema's inferred value
|
|
220
|
-
* type — typed schemas get autocomplete; runtime schemas fall back to
|
|
221
|
-
* `string`.
|
|
222
|
-
*
|
|
223
|
-
* @group Components
|
|
224
|
-
*/
|
|
225
|
-
interface SchemaFieldProps<T = unknown, Ref extends string | undefined = undefined, P extends string = PathOfType<InferSchemaType<T>> | (string extends PathOfType<InferSchemaType<T>> ? string : never)> {
|
|
226
|
-
/**
|
|
227
|
-
* Dot-separated path to the field (e.g. "address.city").
|
|
228
|
-
* When the schema is a Zod schema or typed `as const`, only valid
|
|
229
|
-
* paths are accepted. Falls back to `string` for runtime schemas.
|
|
230
|
-
*/
|
|
231
|
-
path: P;
|
|
232
|
-
/**
|
|
233
|
-
* The schema to extract the field from. Subject to the same
|
|
234
|
-
* unrepresentable-Zod rejection as {@link SchemaComponentProps.schema}.
|
|
235
|
-
*/
|
|
236
|
-
schema: RejectUnrepresentableZod<T>;
|
|
237
|
-
/** For OpenAPI: a ref string. */
|
|
238
|
-
ref?: Ref;
|
|
239
|
-
/** Current value of the field at the given path. */
|
|
240
|
-
value?: unknown;
|
|
241
|
-
/** Called with the updated root value when this field changes. */
|
|
242
|
-
onChange?: (value: unknown) => void;
|
|
243
|
-
/** Override meta for this specific field. */
|
|
244
|
-
meta?: SchemaMeta;
|
|
245
|
-
/** Run validation on change. */
|
|
246
|
-
validate?: boolean;
|
|
247
|
-
onValidationError?: (error: unknown) => void;
|
|
248
|
-
}
|
|
249
|
-
/**
|
|
250
|
-
* Render a single field from a schema by dot-separated `path`.
|
|
251
|
-
*
|
|
252
|
-
* Walks the full schema tree and resolves the field at the supplied
|
|
253
|
-
* `path`, then renders only that field through the same resolver
|
|
254
|
-
* pipeline as {@link SchemaComponent}. Useful for embedding individual
|
|
255
|
-
* fields inside bespoke layouts.
|
|
256
|
-
*
|
|
257
|
-
* @group Components
|
|
258
|
-
*/
|
|
259
|
-
declare function SchemaField<T = unknown, Ref extends string | undefined = undefined, P extends string = PathOfType<InferSchemaType<T>> | (string extends PathOfType<InferSchemaType<T>> ? string : never)>({
|
|
260
|
-
path,
|
|
261
|
-
schema: schemaInput,
|
|
262
|
-
ref: refInput,
|
|
263
|
-
value,
|
|
264
|
-
onChange,
|
|
265
|
-
meta: fieldMeta,
|
|
266
|
-
validate,
|
|
267
|
-
onValidationError
|
|
268
|
-
}: SchemaFieldProps<T, Ref, P>): ReactNode;
|
|
269
|
-
//#endregion
|
|
270
|
-
export { type InferFields, type InferredInputValue, type InferredOutputValue, type InferredValue, SchemaComponent, SchemaComponentProps, SchemaField, SchemaFieldProps, SchemaProvider, __clearGlobalWidgets, joinPath, registerWidget, renderField, sanitisePrefix };
|
|
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";
|
|
3
|
+
export { InferFields, InferredInputValue, InferredOutputValue, InferredValue, SchemaComponent, SchemaComponentProps, SchemaField, SchemaFieldProps, SchemaProvider, __clearGlobalWidgets, joinPath, registerWidget, renderField, sanitisePrefix };
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { isObject, toRecordOrUndefined } from "../core/guards.mjs";
|
|
3
|
-
import "../core/
|
|
4
|
-
import { SchemaFieldError, SchemaNormalisationError, SchemaRenderError } from "../core/errors.mjs";
|
|
3
|
+
import { SchemaFieldError, SchemaNormalisationError } from "../core/errors.mjs";
|
|
5
4
|
import { isCodecSchema, normaliseSchema } from "../core/adapter.mjs";
|
|
5
|
+
import { resolvePath, resolveValue, setNestedValue } from "../core/fieldPath.mjs";
|
|
6
|
+
import { dispatchRenderField } from "../core/renderField.mjs";
|
|
6
7
|
import { buildRenderProps, getRenderFunction, mergeResolvers } from "../core/renderer.mjs";
|
|
7
8
|
import { walk } from "../core/walker.mjs";
|
|
8
9
|
import { headlessResolver } from "./headless.mjs";
|
|
9
|
-
import { resolvePath, resolveValue, setNestedValue } from "./fieldPath.mjs";
|
|
10
10
|
import { z } from "zod";
|
|
11
11
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
12
12
|
import { createContext, isValidElement, useCallback, useContext, useId, useMemo } from "react";
|
|
@@ -19,10 +19,10 @@ import { createContext, isValidElement, useCallback, useContext, useId, useMemo
|
|
|
19
19
|
* ComponentResolver (theme adapter). Falls back to headless HTML.
|
|
20
20
|
*
|
|
21
21
|
* The `fields` prop type is inferred from the `schema` prop:
|
|
22
|
-
* - Zod schemas → FieldOverrides<z.infer<T
|
|
23
|
-
* - JSON Schema `as const` → FieldOverrides<FromJSONSchema<T
|
|
24
|
-
* - OpenAPI `as const` + `ref` → FieldOverrides<ResolveOpenAPIRef<T, Ref
|
|
25
|
-
* - Runtime schemas → Record<string, FieldOverride
|
|
22
|
+
* - Zod schemas → `FieldOverrides<z.infer<T>>` (full autocomplete)
|
|
23
|
+
* - JSON Schema `as const` → `FieldOverrides<FromJSONSchema<T>>` (full autocomplete)
|
|
24
|
+
* - OpenAPI `as const` + `ref` → `FieldOverrides<ResolveOpenAPIRef<T, Ref>>`
|
|
25
|
+
* - Runtime schemas → `Record<string, FieldOverride>` (no autocomplete)
|
|
26
26
|
*/
|
|
27
27
|
const UserResolverContext = createContext(void 0);
|
|
28
28
|
const WidgetsContext = createContext(void 0);
|
|
@@ -199,7 +199,7 @@ function SchemaComponent(props) {
|
|
|
199
199
|
*
|
|
200
200
|
* Bracketed array indices like `[0]` append directly so `tags` + `[0]`
|
|
201
201
|
* becomes `tags[0]` rather than `tags.[0]` — matching the canonical form
|
|
202
|
-
* used by `html/a11y.ts` `joinPath` and `
|
|
202
|
+
* used by `html/a11y.ts` `joinPath` and `core/fieldPath.ts` `resolvePath`,
|
|
203
203
|
* which already parses bracket notation when navigating WalkedField trees.
|
|
204
204
|
*/
|
|
205
205
|
function joinPath(parent, suffix) {
|
|
@@ -281,41 +281,50 @@ function runValidation(zodSchema, jsonSchema, value, io, onDiagnostic) {
|
|
|
281
281
|
* {@link SchemaComponent} and {@link SchemaField}, exported so other
|
|
282
282
|
* React-side components (e.g. the OpenAPI renderers) can dispatch
|
|
283
283
|
* into the same fallback chain.
|
|
284
|
+
*
|
|
285
|
+
* Thin React-flavoured wrapper around the framework-agnostic
|
|
286
|
+
* `dispatchRenderField` (from `core/renderField`): it constructs a
|
|
287
|
+
* React-shaped `DispatchConfig` (widget lookup against the
|
|
288
|
+
* instance → context → global chain, recursion sentinel as a React
|
|
289
|
+
* `<fieldset>`, fallback as a `<span>`-wrapped value) and forwards
|
|
290
|
+
* the call.
|
|
284
291
|
*/
|
|
285
292
|
function renderField(tree, value, onChange, userResolver, renderChild, path, instanceWidgets, contextWidgets, depth = 0) {
|
|
286
293
|
if (path.length === 0) throw new Error("renderField requires a non-empty path. Pass the root path (derived from `idPrefix` or `useId()`) for the root field, and use renderChild's pathSuffix to derive child paths.");
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
294
|
+
return dispatchRenderField({
|
|
295
|
+
tree,
|
|
296
|
+
value,
|
|
297
|
+
path,
|
|
298
|
+
depth,
|
|
299
|
+
resolver: userResolver !== void 0 ? mergeResolvers(userResolver, headlessResolver) : headlessResolver,
|
|
300
|
+
config: {
|
|
301
|
+
buildProps: (fieldTree, fieldPath) => buildRenderProps(fieldTree, value, onChange, renderChild, fieldPath),
|
|
302
|
+
lookupRenderFn: (type, mergedResolver) => getRenderFunction(type, mergedResolver),
|
|
303
|
+
lookupWidget: (name) => instanceWidgets?.get(name) ?? contextWidgets?.get(name) ?? globalWidgets.get(name),
|
|
304
|
+
recursionSentinel: (fieldTree) => {
|
|
305
|
+
return /* @__PURE__ */ jsx("fieldset", { children: /* @__PURE__ */ jsxs("em", { children: [
|
|
306
|
+
"↻ ",
|
|
307
|
+
typeof fieldTree.meta.description === "string" ? fieldTree.meta.description : "schema",
|
|
308
|
+
" (recursive)"
|
|
309
|
+
] }) });
|
|
310
|
+
},
|
|
311
|
+
fallback: (_fieldTree, fieldValue) => {
|
|
312
|
+
if (fieldValue === void 0 || fieldValue === null) return /* @__PURE__ */ jsx("span", { children: "—" });
|
|
313
|
+
return /* @__PURE__ */ jsx("span", { children: typeof fieldValue === "string" ? fieldValue : JSON.stringify(fieldValue) });
|
|
314
|
+
},
|
|
315
|
+
coerceResult: (result, step) => {
|
|
316
|
+
if (step === "widget") {
|
|
317
|
+
if (result === void 0 || result === null) return void 0;
|
|
318
|
+
if (isValidElement(result)) return result;
|
|
319
|
+
if (typeof result === "string" || typeof result === "number") return result;
|
|
320
|
+
return null;
|
|
321
|
+
}
|
|
322
|
+
if (result === void 0 || result === null) return null;
|
|
298
323
|
if (isValidElement(result)) return result;
|
|
299
324
|
if (typeof result === "string" || typeof result === "number") return result;
|
|
300
|
-
return null;
|
|
301
325
|
}
|
|
302
326
|
}
|
|
303
|
-
}
|
|
304
|
-
const resolver = userResolver !== void 0 ? mergeResolvers(userResolver, headlessResolver) : headlessResolver;
|
|
305
|
-
const renderFn = getRenderFunction(tree.type, resolver);
|
|
306
|
-
if (renderFn !== void 0) {
|
|
307
|
-
let result;
|
|
308
|
-
try {
|
|
309
|
-
result = renderFn(buildRenderProps(tree, value, onChange, renderChild, path));
|
|
310
|
-
} catch (err) {
|
|
311
|
-
throw new SchemaRenderError(err instanceof Error ? err.message : `Render function threw for type "${tree.type}"`, tree, tree.type, err);
|
|
312
|
-
}
|
|
313
|
-
if (result === null || result === void 0) return null;
|
|
314
|
-
if (isValidElement(result)) return result;
|
|
315
|
-
if (typeof result === "string" || typeof result === "number") return result;
|
|
316
|
-
}
|
|
317
|
-
if (value === void 0 || value === null) return /* @__PURE__ */ jsx("span", { children: "—" });
|
|
318
|
-
return /* @__PURE__ */ jsx("span", { children: typeof value === "string" ? value : JSON.stringify(value) });
|
|
327
|
+
});
|
|
319
328
|
}
|
|
320
329
|
/**
|
|
321
330
|
* Render a single field from a schema by dot-separated `path`.
|
|
@@ -384,9 +393,9 @@ function SchemaField({ path, schema: schemaInput, ref: refInput, value, onChange
|
|
|
384
393
|
* (`FieldOverrides<U>`) and the loose `Record<string, FieldOverride>`
|
|
385
394
|
* fallback share the same structural shape, so the dispatch logic only
|
|
386
395
|
* needs the loose record. The previous parameter union
|
|
387
|
-
* (`Record<string, FieldOverride> | FieldOverrides<unknown> |
|
|
388
|
-
*
|
|
389
|
-
*
|
|
396
|
+
* (`Record<string, FieldOverride> | FieldOverrides<unknown> | undefined`)
|
|
397
|
+
* collapsed because `FieldOverrides<unknown>` reduces to `{}`,
|
|
398
|
+
* contributing no extra precision while adding noise to readers.
|
|
390
399
|
*/
|
|
391
400
|
function dispatchFieldErrors(fields, error) {
|
|
392
401
|
if (fields === void 0 || !isObject(error)) return;
|
|
@@ -10,11 +10,14 @@ import { Component } from "react";
|
|
|
10
10
|
* crashes the entire React tree.
|
|
11
11
|
*
|
|
12
12
|
* Usage:
|
|
13
|
-
* import { SchemaErrorBoundary } from "schema-components/react/SchemaErrorBoundary";
|
|
14
13
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
14
|
+
* ```tsx
|
|
15
|
+
* import { SchemaErrorBoundary } from "schema-components/react/SchemaErrorBoundary";
|
|
16
|
+
*
|
|
17
|
+
* <SchemaErrorBoundary fallback={(error) => <p>{error.message}</p>}>
|
|
18
|
+
* <SchemaComponent schema={userSchema} value={user} />
|
|
19
|
+
* </SchemaErrorBoundary>
|
|
20
|
+
* ```
|
|
18
21
|
*
|
|
19
22
|
* The boundary catches `SchemaRenderError` from theme adapters and any
|
|
20
23
|
* other errors thrown during rendering. It does NOT catch:
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { w as SchemaMeta } from "../types-
|
|
2
|
-
import { t as Diagnostic } from "../diagnostics-
|
|
3
|
-
import { SchemaIoSide } from "../
|
|
4
|
-
import {
|
|
5
|
-
import { RejectUnrepresentableZod } from "../
|
|
6
|
-
import { a as InferredValue, t as InferFields } from "../inferValue-
|
|
1
|
+
import { w as SchemaMeta } from "../types-BBQaEPfE.mjs";
|
|
2
|
+
import { t as Diagnostic } from "../diagnostics-mftUZI7c.mjs";
|
|
3
|
+
import { r as SchemaIoSide } from "../adapter-ktQaheWB.mjs";
|
|
4
|
+
import { d as WidgetMap, i as ComponentResolver } from "../renderer-ab9E52Bp.mjs";
|
|
5
|
+
import { f as RejectUnrepresentableZod } from "../typeInference-Y8tNEQJk.mjs";
|
|
6
|
+
import { a as InferredValue, t as InferFields } from "../inferValue-eAnh50EM.mjs";
|
|
7
7
|
import { ReactNode } from "react";
|
|
8
8
|
|
|
9
9
|
//#region src/react/SchemaView.d.ts
|
|
@@ -38,10 +38,11 @@ interface SchemaViewProps<T = unknown, Ref extends string | undefined = undefine
|
|
|
38
38
|
*/
|
|
39
39
|
io?: Mode;
|
|
40
40
|
/**
|
|
41
|
-
* Current value to render. Typed against
|
|
42
|
-
* Ref, Mode>` so the prop tracks the schema's
|
|
43
|
-
* the chosen `io` direction. Falls back to
|
|
44
|
-
* schemas where the value type cannot be
|
|
41
|
+
* 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
|
|
45
|
+
* statically inferred.
|
|
45
46
|
*/
|
|
46
47
|
value?: InferredValue<T, Ref, undefined, Mode>;
|
|
47
48
|
/**
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { toRecordOrUndefined } from "../core/guards.mjs";
|
|
2
|
-
import "../core/
|
|
3
|
-
import { SchemaNormalisationError, SchemaRenderError } from "../core/errors.mjs";
|
|
2
|
+
import { SchemaNormalisationError } from "../core/errors.mjs";
|
|
4
3
|
import { normaliseSchema } from "../core/adapter.mjs";
|
|
4
|
+
import { dispatchRenderField } from "../core/renderField.mjs";
|
|
5
5
|
import { buildRenderProps, getRenderFunction, mergeResolvers } from "../core/renderer.mjs";
|
|
6
6
|
import { walk } from "../core/walker.mjs";
|
|
7
7
|
import { headlessResolver } from "./headless.mjs";
|
|
8
8
|
import { joinPath, sanitisePrefix } from "./SchemaComponent.mjs";
|
|
9
9
|
import { jsx } from "react/jsx-runtime";
|
|
10
|
-
import {
|
|
10
|
+
import { isValidElement, useId } from "react";
|
|
11
11
|
//#region src/react/SchemaView.tsx
|
|
12
12
|
/**
|
|
13
13
|
* React Server Component for read-only schema rendering.
|
|
@@ -97,41 +97,44 @@ function SchemaView({ schema: schemaInput, ref: refInput, io, value, fields, met
|
|
|
97
97
|
const userResolver = resolver !== void 0 ? mergeResolvers(resolver, headlessResolver) : headlessResolver;
|
|
98
98
|
const makeRenderChild = (currentDepth, parentPath) => (childTree, childValue, pathSuffix) => {
|
|
99
99
|
const childPath = joinPath(parentPath, pathSuffix);
|
|
100
|
-
|
|
101
|
-
return renderFieldServer(childTree, childValue, userResolver, makeRenderChild(currentDepth + 1, childPath), childPath, widgets);
|
|
100
|
+
return renderFieldServer(childTree, childValue, userResolver, makeRenderChild(currentDepth + 1, childPath), childPath, widgets, currentDepth + 1);
|
|
102
101
|
};
|
|
103
102
|
const renderChild = makeRenderChild(0, rootPath);
|
|
104
|
-
return renderFieldServer(tree, value ?? tree.defaultValue, userResolver, renderChild, rootPath, widgets);
|
|
103
|
+
return renderFieldServer(tree, value ?? tree.defaultValue, userResolver, renderChild, rootPath, widgets, 0);
|
|
105
104
|
}
|
|
106
|
-
function renderFieldServer(tree, value, resolver, renderChild, path, widgets) {
|
|
105
|
+
function renderFieldServer(tree, value, resolver, renderChild, path, widgets, depth = 0) {
|
|
107
106
|
if (path.length === 0) throw new Error("renderFieldServer requires a non-empty path. Pass ROOT_PATH at the root and join children via joinPath().");
|
|
108
107
|
const adaptedRenderChild = (childTree, childValue, _childOnChange, pathSuffix) => renderChild(childTree, childValue, pathSuffix);
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
108
|
+
return dispatchRenderField({
|
|
109
|
+
tree,
|
|
110
|
+
value,
|
|
111
|
+
path,
|
|
112
|
+
depth,
|
|
113
|
+
resolver,
|
|
114
|
+
config: {
|
|
115
|
+
buildProps: (fieldTree, fieldPath) => buildRenderProps(fieldTree, value, void 0, adaptedRenderChild, fieldPath),
|
|
116
|
+
lookupRenderFn: (type, mergedResolver) => getRenderFunction(type, mergedResolver),
|
|
117
|
+
...widgets !== void 0 ? { lookupWidget: (name) => widgets.get(name) } : {},
|
|
118
|
+
recursionSentinel: (fieldTree) => {
|
|
119
|
+
return /* @__PURE__ */ jsx("fieldset", { children: /* @__PURE__ */ jsx("em", { children: `↻ ${typeof fieldTree.meta.description === "string" ? fieldTree.meta.description : "schema"} (recursive)` }) });
|
|
120
|
+
},
|
|
121
|
+
fallback: (_fieldTree, fieldValue) => {
|
|
122
|
+
if (fieldValue === void 0 || fieldValue === null) return /* @__PURE__ */ jsx("span", { children: "—" });
|
|
123
|
+
return /* @__PURE__ */ jsx("span", { children: typeof fieldValue === "string" ? fieldValue : JSON.stringify(fieldValue) });
|
|
124
|
+
},
|
|
125
|
+
coerceResult: (result, step) => {
|
|
126
|
+
if (step === "widget") {
|
|
127
|
+
if (result === void 0 || result === null) return void 0;
|
|
128
|
+
if (isValidElement(result)) return result;
|
|
129
|
+
if (typeof result === "string" || typeof result === "number") return result;
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
if (result === void 0 || result === null) return void 0;
|
|
115
133
|
if (isValidElement(result)) return result;
|
|
116
134
|
if (typeof result === "string" || typeof result === "number") return result;
|
|
117
135
|
}
|
|
118
136
|
}
|
|
119
|
-
}
|
|
120
|
-
const renderFn = getRenderFunction(tree.type, resolver);
|
|
121
|
-
if (renderFn !== void 0) {
|
|
122
|
-
const props = buildRenderProps(tree, value, void 0, adaptedRenderChild, path);
|
|
123
|
-
try {
|
|
124
|
-
const result = renderFn(props);
|
|
125
|
-
if (result !== void 0 && result !== null) {
|
|
126
|
-
if (isValidElement(result)) return result;
|
|
127
|
-
if (typeof result === "string" || typeof result === "number") return result;
|
|
128
|
-
}
|
|
129
|
-
} catch (err) {
|
|
130
|
-
throw new SchemaRenderError(err instanceof Error ? err.message : `Render function threw for type "${tree.type}"`, tree, tree.type, err);
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
if (value === void 0 || value === null) return /* @__PURE__ */ jsx("span", { children: "—" });
|
|
134
|
-
return /* @__PURE__ */ jsx("span", { children: typeof value === "string" ? value : JSON.stringify(value) });
|
|
137
|
+
});
|
|
135
138
|
}
|
|
136
139
|
//#endregion
|
|
137
140
|
export { SchemaView };
|
package/dist/react/a11y.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { j as WalkedField } from "../types-
|
|
2
|
-
import { AllConstraints } from "../
|
|
1
|
+
import { j as WalkedField } from "../types-BBQaEPfE.mjs";
|
|
2
|
+
import { t as AllConstraints } from "../renderer-ab9E52Bp.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/react/a11y.d.ts
|
|
5
5
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { j as WalkedField } from "../types-
|
|
2
|
-
import { RenderProps } from "../
|
|
1
|
+
import { j as WalkedField } from "../types-BBQaEPfE.mjs";
|
|
2
|
+
import { u as RenderProps } from "../renderer-ab9E52Bp.mjs";
|
|
3
3
|
import { ReactNode } from "react";
|
|
4
4
|
|
|
5
5
|
//#region src/react/headlessRenderers.d.ts
|