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.
Files changed (48) hide show
  1. package/dist/adapter-MiEFkRVV.d.mts +172 -0
  2. package/dist/core/adapter.d.mts +2 -141
  3. package/dist/core/adapter.mjs +39 -5
  4. package/dist/core/constraints.d.mts +1 -1
  5. package/dist/core/diagnostics.d.mts +1 -1
  6. package/dist/core/errors.d.mts +1 -1
  7. package/dist/core/formats.d.mts +1 -1
  8. package/dist/core/limits.d.mts +1 -1
  9. package/dist/core/merge.d.mts +1 -1
  10. package/dist/core/normalise.d.mts +2 -2
  11. package/dist/core/ref.d.mts +1 -1
  12. package/dist/core/ref.mjs +4 -5
  13. package/dist/core/renderer.d.mts +1 -1
  14. package/dist/core/swagger2.d.mts +1 -1
  15. package/dist/core/typeInference.d.mts +1 -1
  16. package/dist/core/version.d.mts +1 -1
  17. package/dist/core/walkBuilders.d.mts +2 -2
  18. package/dist/{diagnostics-BS2kaUyE.d.mts → diagnostics-Cbwak-ZX.d.mts} +1 -1
  19. package/dist/html/a11y.d.mts +1 -1
  20. package/dist/html/renderToHtml.d.mts +1 -1
  21. package/dist/html/renderToHtmlStream.d.mts +1 -1
  22. package/dist/html/renderers.d.mts +6 -17
  23. package/dist/html/renderers.mjs +5 -16
  24. package/dist/html/streamRenderers.d.mts +2 -2
  25. package/dist/openapi/components.d.mts +1 -1
  26. package/dist/openapi/components.mjs +2 -2
  27. package/dist/openapi/parser.d.mts +13 -4
  28. package/dist/openapi/parser.mjs +59 -33
  29. package/dist/openapi/resolve.d.mts +1 -1
  30. package/dist/openapi/resolve.mjs +2 -2
  31. package/dist/react/SchemaComponent.d.mts +74 -64
  32. package/dist/react/SchemaComponent.mjs +23 -31
  33. package/dist/react/SchemaView.d.mts +24 -20
  34. package/dist/react/SchemaView.mjs +6 -3
  35. package/dist/react/headless.d.mts +1 -1
  36. package/dist/react/headlessRenderers.d.mts +1 -1
  37. package/dist/react/headlessRenderers.mjs +1 -1
  38. package/dist/{ref-DjLEKa_E.d.mts → ref-TdeMfaV_.d.mts} +1 -1
  39. package/dist/themes/mantine.d.mts +1 -1
  40. package/dist/themes/mui.d.mts +1 -1
  41. package/dist/themes/mui.mjs +1 -1
  42. package/dist/themes/radix.d.mts +1 -1
  43. package/dist/themes/shadcn.d.mts +1 -1
  44. package/package.json +6 -2
  45. /package/dist/{errors-g_MCTQel.d.mts → errors-DQSIK4n1.d.mts} +0 -0
  46. /package/dist/{limits-Cw5QZND8.d.mts → limits-DJhgx5Ay.d.mts} +0 -0
  47. /package/dist/{renderer-CXJ8y0qw.d.mts → renderer-Ul9taFYp.d.mts} +0 -0
  48. /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-BS2kaUyE.mjs";
3
- import { r as ComponentResolver } from "../renderer-CXJ8y0qw.mjs";
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 {@link SchemaComponentProps.schema} — see
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
- * Current value to render.
22
- *
23
- * TYPE BOUNDARY NOTE: mirrors `SchemaComponentProps.value` kept
24
- * as `unknown` so the same boundary holds for both the editable
25
- * (`SchemaComponent`) and read-only (`SchemaView`) entry points.
26
- * The {@link InferredOutputValue} alias is the recommended way
27
- * for callers to narrow on the consumer side.
28
- *
29
- * TODO(round7-integration): promote to
30
- * `InferSchemaValue<T, Ref, "output">` alongside the matching
31
- * `SchemaComponent` change. See the type-boundary note on
32
- * `SchemaComponentProps.value` for the migration coordination.
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?: unknown;
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 ? { 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;
@@ -1,4 +1,4 @@
1
- import { r as ComponentResolver } from "../renderer-CXJ8y0qw.mjs";
1
+ import { r as ComponentResolver } from "../renderer-Ul9taFYp.mjs";
2
2
 
3
3
  //#region src/react/headless.d.ts
4
4
  /**
@@ -1,5 +1,5 @@
1
1
  import { j as WalkedField } from "../types-BTB73MB8.mjs";
2
- import { l as RenderProps } from "../renderer-CXJ8y0qw.mjs";
2
+ import { l as RenderProps } from "../renderer-Ul9taFYp.mjs";
3
3
  import { ReactNode } from "react";
4
4
 
5
5
  //#region src/react/headlessRenderers.d.ts
@@ -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.
@@ -1,4 +1,4 @@
1
- import { i as DiagnosticsOptions } from "./diagnostics-BS2kaUyE.mjs";
1
+ import { i as DiagnosticsOptions } from "./diagnostics-Cbwak-ZX.mjs";
2
2
 
3
3
  //#region src/core/ref.d.ts
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { r as ComponentResolver } from "../renderer-CXJ8y0qw.mjs";
1
+ import { r as ComponentResolver } from "../renderer-Ul9taFYp.mjs";
2
2
 
3
3
  //#region src/themes/mantine.d.ts
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { r as ComponentResolver } from "../renderer-CXJ8y0qw.mjs";
1
+ import { r as ComponentResolver } from "../renderer-Ul9taFYp.mjs";
2
2
 
3
3
  //#region src/themes/mui.d.ts
4
4
  /**
@@ -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 };
@@ -1,4 +1,4 @@
1
- import { r as ComponentResolver } from "../renderer-CXJ8y0qw.mjs";
1
+ import { r as ComponentResolver } from "../renderer-Ul9taFYp.mjs";
2
2
 
3
3
  //#region src/themes/radix.d.ts
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { r as ComponentResolver } from "../renderer-CXJ8y0qw.mjs";
1
+ import { r as ComponentResolver } from "../renderer-Ul9taFYp.mjs";
2
2
 
3
3
  //#region src/themes/shadcn.d.ts
4
4
  declare const shadcnResolver: ComponentResolver;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "schema-components",
3
- "version": "1.23.0",
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",