schema-components 1.23.0 → 1.26.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/dist/adapter-MiEFkRVV.d.mts +172 -0
- package/dist/core/adapter.d.mts +2 -141
- package/dist/core/adapter.mjs +39 -5
- package/dist/core/constraints.d.mts +1 -1
- package/dist/core/diagnostics.d.mts +1 -1
- package/dist/core/errors.d.mts +1 -1
- package/dist/core/formats.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 +2 -2
- package/dist/core/ref.d.mts +1 -1
- package/dist/core/ref.mjs +4 -5
- package/dist/core/renderer.d.mts +1 -1
- package/dist/core/swagger2.d.mts +1 -1
- package/dist/core/typeInference.d.mts +1 -1
- package/dist/core/version.d.mts +1 -1
- package/dist/core/walkBuilders.d.mts +2 -2
- package/dist/{diagnostics-BS2kaUyE.d.mts → diagnostics-Cbwak-ZX.d.mts} +1 -1
- package/dist/html/a11y.d.mts +1 -1
- package/dist/html/renderToHtml.d.mts +1 -1
- package/dist/html/renderToHtmlStream.d.mts +1 -1
- package/dist/html/renderers.d.mts +6 -17
- package/dist/html/renderers.mjs +5 -16
- package/dist/html/streamRenderers.d.mts +2 -2
- package/dist/openapi/components.d.mts +1 -1
- package/dist/openapi/components.mjs +2 -2
- package/dist/openapi/parser.d.mts +13 -4
- package/dist/openapi/parser.mjs +59 -33
- package/dist/openapi/resolve.d.mts +1 -1
- package/dist/openapi/resolve.mjs +2 -2
- package/dist/react/SchemaComponent.d.mts +74 -64
- package/dist/react/SchemaComponent.mjs +23 -31
- package/dist/react/SchemaView.d.mts +24 -20
- package/dist/react/SchemaView.mjs +6 -3
- package/dist/react/headless.d.mts +1 -1
- package/dist/react/headlessRenderers.d.mts +1 -1
- package/dist/react/headlessRenderers.mjs +1 -1
- package/dist/{ref-DjLEKa_E.d.mts → ref-TdeMfaV_.d.mts} +1 -1
- package/dist/themes/mantine.d.mts +1 -1
- package/dist/themes/mui.d.mts +1 -1
- package/dist/themes/mui.mjs +1 -1
- package/dist/themes/radix.d.mts +1 -1
- package/dist/themes/shadcn.d.mts +1 -1
- package/package.json +6 -2
- /package/dist/{errors-g_MCTQel.d.mts → errors-DQSIK4n1.d.mts} +0 -0
- /package/dist/{limits-Cw5QZND8.d.mts → limits-DJhgx5Ay.d.mts} +0 -0
- /package/dist/{renderer-CXJ8y0qw.d.mts → renderer-Ul9taFYp.d.mts} +0 -0
- /package/dist/{version-BFTVLsdb.d.mts → version-ZzL5R6cS.d.mts} +0 -0
|
@@ -1,37 +1,40 @@
|
|
|
1
1
|
import { w as SchemaMeta } from "../types-BTB73MB8.mjs";
|
|
2
|
-
import { t as Diagnostic } from "../diagnostics-
|
|
3
|
-
import {
|
|
2
|
+
import { t as Diagnostic } from "../diagnostics-Cbwak-ZX.mjs";
|
|
3
|
+
import { i as SchemaIoSide } from "../adapter-MiEFkRVV.mjs";
|
|
4
|
+
import { r as ComponentResolver } from "../renderer-Ul9taFYp.mjs";
|
|
4
5
|
import { RejectUnrepresentableZod } from "../core/typeInference.mjs";
|
|
5
|
-
import { WidgetMap } from "./SchemaComponent.mjs";
|
|
6
|
+
import { InferredValue, WidgetMap } from "./SchemaComponent.mjs";
|
|
6
7
|
import { ReactNode } from "react";
|
|
7
8
|
|
|
8
9
|
//#region src/react/SchemaView.d.ts
|
|
9
|
-
interface SchemaViewProps<T = unknown, Ref extends string | undefined = undefined> {
|
|
10
|
+
interface SchemaViewProps<T = unknown, Ref extends string | undefined = undefined, Mode extends SchemaIoSide = "output"> {
|
|
10
11
|
/**
|
|
11
12
|
* Zod schema, JSON Schema object, or OpenAPI document.
|
|
12
13
|
*
|
|
13
14
|
* Subject to the same compile-time rejection of unrepresentable
|
|
14
|
-
* Zod 4 types as
|
|
15
|
+
* Zod 4 types as the `schema` prop on `<SchemaComponent>` — see
|
|
15
16
|
* {@link RejectUnrepresentableZod}.
|
|
16
17
|
*/
|
|
17
18
|
schema: RejectUnrepresentableZod<T>;
|
|
18
19
|
/** For OpenAPI: a ref string like "#/components/schemas/User". */
|
|
19
20
|
ref?: Ref;
|
|
20
21
|
/**
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
*
|
|
32
|
-
*
|
|
22
|
+
* Which side of every transform / pipe / codec to render. Mirrors
|
|
23
|
+
* `<SchemaComponent io>`. Defaults to `"output"` — the inferred
|
|
24
|
+
* shape consumers receive from the server. Switch to `"input"`
|
|
25
|
+
* to render the INPUT side (omits `readOnly` properties for
|
|
26
|
+
* JSON Schema inputs, picks the input half of a `z.codec(...)`).
|
|
27
|
+
* Has no effect for plain JSON Schema or OpenAPI inputs without
|
|
28
|
+
* codec/transform constructs.
|
|
29
|
+
*/
|
|
30
|
+
io?: Mode;
|
|
31
|
+
/**
|
|
32
|
+
* Current value to render. Typed against `InferSchemaValue<T,
|
|
33
|
+
* Ref, Mode>` so the prop tracks the schema's inferred shape for
|
|
34
|
+
* the chosen `io` direction. Falls back to `unknown` for runtime
|
|
35
|
+
* schemas where the value type cannot be statically inferred.
|
|
33
36
|
*/
|
|
34
|
-
value?:
|
|
37
|
+
value?: InferredValue<T, Ref, undefined, Mode>;
|
|
35
38
|
/** Per-field meta overrides. */
|
|
36
39
|
fields?: Record<string, unknown>;
|
|
37
40
|
/** Meta overrides applied to the root schema. */
|
|
@@ -64,9 +67,10 @@ interface SchemaViewProps<T = unknown, Ref extends string | undefined = undefine
|
|
|
64
67
|
* Always renders in read-only mode. For editable forms, use
|
|
65
68
|
* `<SchemaComponent>` with `"use client"`.
|
|
66
69
|
*/
|
|
67
|
-
declare function SchemaView<T = unknown, Ref extends string | undefined = undefined>({
|
|
70
|
+
declare function SchemaView<T = unknown, Ref extends string | undefined = undefined, Mode extends SchemaIoSide = "output">({
|
|
68
71
|
schema: schemaInput,
|
|
69
72
|
ref: refInput,
|
|
73
|
+
io,
|
|
70
74
|
value,
|
|
71
75
|
fields,
|
|
72
76
|
meta: componentMeta,
|
|
@@ -76,6 +80,6 @@ declare function SchemaView<T = unknown, Ref extends string | undefined = undefi
|
|
|
76
80
|
onDiagnostic,
|
|
77
81
|
strict,
|
|
78
82
|
idPrefix
|
|
79
|
-
}: SchemaViewProps<T, Ref>): ReactNode;
|
|
83
|
+
}: SchemaViewProps<T, Ref, Mode>): ReactNode;
|
|
80
84
|
//#endregion
|
|
81
85
|
export { SchemaView, SchemaViewProps };
|
|
@@ -5,8 +5,8 @@ import { buildRenderProps, getRenderFunction, mergeResolvers } from "../core/ren
|
|
|
5
5
|
import { walk } from "../core/walker.mjs";
|
|
6
6
|
import { headlessResolver } from "./headless.mjs";
|
|
7
7
|
import { joinPath, sanitisePrefix } from "./SchemaComponent.mjs";
|
|
8
|
-
import { jsx } from "react/jsx-runtime";
|
|
9
8
|
import { createElement, isValidElement, useId } from "react";
|
|
9
|
+
import { jsx } from "react/jsx-runtime";
|
|
10
10
|
//#region src/react/SchemaView.tsx
|
|
11
11
|
/**
|
|
12
12
|
* React Server Component for read-only schema rendering.
|
|
@@ -42,7 +42,7 @@ import { createElement, isValidElement, useId } from "react";
|
|
|
42
42
|
* Always renders in read-only mode. For editable forms, use
|
|
43
43
|
* `<SchemaComponent>` with `"use client"`.
|
|
44
44
|
*/
|
|
45
|
-
function SchemaView({ schema: schemaInput, ref: refInput, value, fields, meta: componentMeta, description, resolver, widgets, onDiagnostic, strict, idPrefix }) {
|
|
45
|
+
function SchemaView({ schema: schemaInput, ref: refInput, io, value, fields, meta: componentMeta, description, resolver, widgets, onDiagnostic, strict, idPrefix }) {
|
|
46
46
|
const generatedId = useId();
|
|
47
47
|
const rootPath = idPrefix ?? sanitisePrefix(generatedId);
|
|
48
48
|
const mergedMeta = {
|
|
@@ -58,7 +58,10 @@ function SchemaView({ schema: schemaInput, ref: refInput, value, fields, meta: c
|
|
|
58
58
|
let rootMeta;
|
|
59
59
|
let rootDocument;
|
|
60
60
|
try {
|
|
61
|
-
const normalised = normaliseSchema(schemaInput, refInput, diagnostics !== void 0
|
|
61
|
+
const normalised = normaliseSchema(schemaInput, refInput, diagnostics !== void 0 || io !== void 0 ? {
|
|
62
|
+
...diagnostics !== void 0 ? { diagnostics } : {},
|
|
63
|
+
...io !== void 0 ? { io } : {}
|
|
64
|
+
} : void 0);
|
|
62
65
|
jsonSchema = normalised.jsonSchema;
|
|
63
66
|
rootMeta = normalised.rootMeta;
|
|
64
67
|
rootDocument = normalised.rootDocument;
|
|
@@ -7,8 +7,8 @@ import { fieldDomId, panelIdFor, tabIdFor } from "../core/idPath.mjs";
|
|
|
7
7
|
import { matchUnionOption, resolveDiscriminatedActive } from "../core/unionMatch.mjs";
|
|
8
8
|
import { displayJsonValue } from "../core/walkBuilders.mjs";
|
|
9
9
|
import { buildAriaAttrs } from "./a11y.mjs";
|
|
10
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
11
10
|
import { isValidElement, useCallback, useEffect, useRef } from "react";
|
|
11
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
12
12
|
//#region src/react/headlessRenderers.tsx
|
|
13
13
|
/**
|
|
14
14
|
* Headless renderer functions — one per schema type.
|
package/dist/themes/mui.d.mts
CHANGED
package/dist/themes/mui.mjs
CHANGED
|
@@ -2,8 +2,8 @@ import { isObject } from "../core/guards.mjs";
|
|
|
2
2
|
import { sortFieldsByOrder } from "../core/fieldOrder.mjs";
|
|
3
3
|
import { inputId, toReactNode } from "../react/headlessRenderers.mjs";
|
|
4
4
|
import { headlessResolver } from "../react/headless.mjs";
|
|
5
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
5
|
import { isValidElement } from "react";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
7
|
//#region src/themes/mui.tsx
|
|
8
8
|
function ariaRequired(tree) {
|
|
9
9
|
return { required: tree.isOptional === false };
|
package/dist/themes/radix.d.mts
CHANGED
package/dist/themes/shadcn.d.mts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "schema-components",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.26.0",
|
|
4
4
|
"description": "React components that render UI from Zod schemas, JSON Schema, and OpenAPI documents",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -40,6 +40,7 @@
|
|
|
40
40
|
"_test:e2e": "vitest run --project=e2e",
|
|
41
41
|
"_test:coverage": "vitest run --project=unit --coverage",
|
|
42
42
|
"_build": "tsdown && cp src/html/styles.css dist/html/styles.css",
|
|
43
|
+
"_docs": "typedoc",
|
|
43
44
|
"typecheck": "turbo run _typecheck",
|
|
44
45
|
"lint": "turbo run _lint",
|
|
45
46
|
"lint:fix": "turbo run _lint:fix",
|
|
@@ -47,7 +48,8 @@
|
|
|
47
48
|
"test:coverage": "turbo run _test:coverage",
|
|
48
49
|
"check": "turbo run _check",
|
|
49
50
|
"validate": "turbo run _validate",
|
|
50
|
-
"build": "turbo run _build"
|
|
51
|
+
"build": "turbo run _build",
|
|
52
|
+
"docs": "turbo run _docs"
|
|
51
53
|
},
|
|
52
54
|
"keywords": [
|
|
53
55
|
"react",
|
|
@@ -91,6 +93,8 @@
|
|
|
91
93
|
"react-dom": "19.2.6",
|
|
92
94
|
"tsdown": "0.22.0",
|
|
93
95
|
"tslib": "2.8.1",
|
|
96
|
+
"typedoc": "0.28.19",
|
|
97
|
+
"typedoc-plugin-missing-exports": "4.1.3",
|
|
94
98
|
"typescript": "6.0.3",
|
|
95
99
|
"typescript-eslint": "8.59.2",
|
|
96
100
|
"vitest": "4.1.5",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|