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.
Files changed (196) 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/adapter.mjs +33 -25
  8. package/dist/core/constraintHint.d.mts +1 -1
  9. package/dist/core/constraints.d.mts +2 -2
  10. package/dist/core/contexts.d.mts +71 -0
  11. package/dist/core/contexts.mjs +1 -0
  12. package/dist/core/diagnostics.d.mts +1 -1
  13. package/dist/core/errors.d.mts +1 -1
  14. package/dist/core/fieldOrder.d.mts +1 -1
  15. package/dist/{react → core}/fieldPath.d.mts +2 -2
  16. package/dist/{react → core}/fieldPath.mjs +3 -3
  17. package/dist/core/formats.d.mts +1 -1
  18. package/dist/core/guards.d.mts +2 -2
  19. package/dist/core/guards.mjs +2 -2
  20. package/dist/core/inferValue.d.mts +1 -1
  21. package/dist/core/limits.d.mts +1 -1
  22. package/dist/core/merge.d.mts +1 -1
  23. package/dist/core/normalise.d.mts +6 -6
  24. package/dist/core/normalise.mjs +1 -1
  25. package/dist/core/openapi30.d.mts +1 -1
  26. package/dist/core/openapi30.mjs +1 -1
  27. package/dist/core/ref.d.mts +1 -1
  28. package/dist/core/renderField.d.mts +147 -0
  29. package/dist/core/renderField.mjs +81 -0
  30. package/dist/core/renderer.d.mts +2 -199
  31. package/dist/core/swagger2.d.mts +1 -1
  32. package/dist/core/swagger2.mjs +1 -1
  33. package/dist/core/typeInference.d.mts +1 -981
  34. package/dist/core/types.d.mts +1 -1
  35. package/dist/core/unionMatch.d.mts +1 -1
  36. package/dist/core/uri.d.mts +2 -2
  37. package/dist/core/uri.mjs +2 -2
  38. package/dist/core/version.d.mts +1 -1
  39. package/dist/core/walkBuilders.d.mts +4 -4
  40. package/dist/core/walkBuilders.mjs +1 -1
  41. package/dist/core/walker.d.mts +1 -1
  42. package/dist/core/walker.mjs +3 -3
  43. package/dist/{errors-Dki7tji4.d.mts → errors-DbaI04x2.d.mts} +1 -1
  44. package/dist/html/a11y.d.mts +2 -2
  45. package/dist/html/html.d.mts +10 -8
  46. package/dist/html/renderToHtml.d.mts +5 -5
  47. package/dist/html/renderToHtml.mjs +45 -24
  48. package/dist/html/renderToHtmlStream.d.mts +5 -5
  49. package/dist/html/renderers.d.mts +1 -1
  50. package/dist/html/streamRenderers.d.mts +3 -3
  51. package/dist/{inferValue-PPXWJpbN.d.mts → inferValue-eAnh50EM.d.mts} +6 -6
  52. package/dist/lit/SchemaComponent.d.mts +125 -0
  53. package/dist/lit/SchemaComponent.mjs +2 -0
  54. package/dist/lit/SchemaField.d.mts +65 -0
  55. package/dist/lit/SchemaField.mjs +2 -0
  56. package/dist/lit/SchemaView.d.mts +14 -0
  57. package/dist/lit/SchemaView.mjs +2 -0
  58. package/dist/lit/constructorTypes.d.mts +2 -0
  59. package/dist/lit/constructorTypes.mjs +1 -0
  60. package/dist/lit/contexts.d.mts +78 -0
  61. package/dist/lit/contexts.mjs +238 -0
  62. package/dist/lit/defaultResolver.d.mts +33 -0
  63. package/dist/lit/defaultResolver.mjs +2 -0
  64. package/dist/lit/registry.d.mts +66 -0
  65. package/dist/lit/registry.mjs +2 -0
  66. package/dist/lit/renderers/baseElement.d.mts +131 -0
  67. package/dist/lit/renderers/baseElement.mjs +109 -0
  68. package/dist/lit/renderers/recordHelpers.d.mts +25 -0
  69. package/dist/lit/renderers/recordHelpers.mjs +55 -0
  70. package/dist/lit/renderers/scArray.d.mts +14 -0
  71. package/dist/lit/renderers/scArray.mjs +86 -0
  72. package/dist/lit/renderers/scBoolean.d.mts +15 -0
  73. package/dist/lit/renderers/scBoolean.mjs +47 -0
  74. package/dist/lit/renderers/scConditional.d.mts +23 -0
  75. package/dist/lit/renderers/scConditional.mjs +65 -0
  76. package/dist/lit/renderers/scDiscriminated.d.mts +23 -0
  77. package/dist/lit/renderers/scDiscriminated.mjs +138 -0
  78. package/dist/lit/renderers/scEnum.d.mts +16 -0
  79. package/dist/lit/renderers/scEnum.mjs +66 -0
  80. package/dist/lit/renderers/scFile.d.mts +15 -0
  81. package/dist/lit/renderers/scFile.mjs +53 -0
  82. package/dist/lit/renderers/scLiteralNullNever.d.mts +30 -0
  83. package/dist/lit/renderers/scLiteralNullNever.mjs +57 -0
  84. package/dist/lit/renderers/scNumber.d.mts +15 -0
  85. package/dist/lit/renderers/scNumber.mjs +64 -0
  86. package/dist/lit/renderers/scObject.d.mts +14 -0
  87. package/dist/lit/renderers/scObject.mjs +57 -0
  88. package/dist/lit/renderers/scRecord.d.mts +14 -0
  89. package/dist/lit/renderers/scRecord.mjs +112 -0
  90. package/dist/lit/renderers/scString.d.mts +19 -0
  91. package/dist/lit/renderers/scString.mjs +165 -0
  92. package/dist/lit/renderers/scTuple.d.mts +14 -0
  93. package/dist/lit/renderers/scTuple.mjs +58 -0
  94. package/dist/lit/renderers/scUnion.d.mts +14 -0
  95. package/dist/lit/renderers/scUnion.mjs +44 -0
  96. package/dist/lit/renderers/scUnknown.d.mts +15 -0
  97. package/dist/lit/renderers/scUnknown.mjs +45 -0
  98. package/dist/lit/ssr.d.mts +37 -0
  99. package/dist/lit/ssr.mjs +9565 -0
  100. package/dist/lit/types.d.mts +2 -0
  101. package/dist/lit/types.mjs +1 -0
  102. package/dist/lit/widget.d.mts +71 -0
  103. package/dist/lit/widget.mjs +87 -0
  104. package/dist/{normalise-DB-Xtjmn.mjs → normalise-BkePrJ4v.mjs} +6 -6
  105. package/dist/openapi/ApiCallbacks.d.mts +1 -1
  106. package/dist/openapi/ApiLinks.d.mts +1 -1
  107. package/dist/openapi/ApiResponseHeaders.d.mts +1 -1
  108. package/dist/openapi/ApiSecurity.d.mts +1 -1
  109. package/dist/openapi/components.d.mts +5 -5
  110. package/dist/openapi/components.mjs +1 -1
  111. package/dist/openapi/parser.d.mts +2 -2
  112. package/dist/openapi/resolve.d.mts +1 -1
  113. package/dist/openapi/resolve.mjs +1 -1
  114. package/dist/preact/SchemaComponent.d.mts +3 -0
  115. package/dist/preact/SchemaComponent.mjs +26 -0
  116. package/dist/preact/SchemaErrorBoundary.d.mts +2 -0
  117. package/dist/preact/SchemaErrorBoundary.mjs +20 -0
  118. package/dist/preact/SchemaView.d.mts +2 -0
  119. package/dist/preact/SchemaView.mjs +22 -0
  120. package/dist/preact/headless.d.mts +2 -0
  121. package/dist/preact/headless.mjs +18 -0
  122. package/dist/react/SchemaComponent.d.mts +3 -270
  123. package/dist/react/SchemaComponent.mjs +48 -39
  124. package/dist/react/SchemaErrorBoundary.mjs +7 -4
  125. package/dist/react/SchemaView.d.mts +11 -10
  126. package/dist/react/SchemaView.mjs +32 -29
  127. package/dist/react/a11y.d.mts +2 -2
  128. package/dist/react/fieldShell.d.mts +1 -1
  129. package/dist/react/headless.d.mts +1 -1
  130. package/dist/react/headlessRenderers.d.mts +2 -2
  131. package/dist/{ref-DdsbekXX.d.mts → ref-DWrQG1Er.d.mts} +1 -1
  132. package/dist/renderer-ab9E52Bp.d.mts +245 -0
  133. package/dist/solid/SchemaComponent.d.mts +136 -0
  134. package/dist/solid/SchemaComponent.mjs +391 -0
  135. package/dist/solid/SchemaErrorBoundary.d.mts +38 -0
  136. package/dist/solid/SchemaErrorBoundary.mjs +57 -0
  137. package/dist/solid/SchemaField.d.mts +40 -0
  138. package/dist/solid/SchemaField.mjs +113 -0
  139. package/dist/solid/SchemaView.d.mts +54 -0
  140. package/dist/solid/SchemaView.mjs +168 -0
  141. package/dist/solid/a11y.d.mts +70 -0
  142. package/dist/solid/a11y.mjs +71 -0
  143. package/dist/solid/contexts.d.mts +37 -0
  144. package/dist/solid/contexts.mjs +66 -0
  145. package/dist/solid/headless.d.mts +10 -0
  146. package/dist/solid/headless.mjs +27 -0
  147. package/dist/solid/renderers.d.mts +79 -0
  148. package/dist/solid/renderers.mjs +840 -0
  149. package/dist/solid/types.d.mts +90 -0
  150. package/dist/solid/types.mjs +1 -0
  151. package/dist/solid/widget.d.mts +29 -0
  152. package/dist/solid/widget.mjs +35 -0
  153. package/dist/themes/mantine.d.mts +1 -1
  154. package/dist/themes/mui.d.mts +1 -1
  155. package/dist/themes/radix.d.mts +1 -1
  156. package/dist/themes/shadcn.d.mts +1 -1
  157. package/dist/typeInference-Y8tNEQJk.d.mts +983 -0
  158. package/dist/types-BCy7K3nk.d.mts +125 -0
  159. package/package.json +71 -1
  160. package/src/svelte/SchemaComponent.svelte +427 -0
  161. package/src/svelte/SchemaErrorBoundary.svelte +66 -0
  162. package/src/svelte/SchemaField.svelte +216 -0
  163. package/src/svelte/SchemaProvider.svelte +46 -0
  164. package/src/svelte/SchemaView.svelte +244 -0
  165. package/src/svelte/a11y.ts +112 -0
  166. package/src/svelte/contexts.ts +79 -0
  167. package/src/svelte/dispatch.ts +267 -0
  168. package/src/svelte/headless.ts +73 -0
  169. package/src/svelte/headlessFns.ts +124 -0
  170. package/src/svelte/renderers/Array.svelte +98 -0
  171. package/src/svelte/renderers/Boolean.svelte +43 -0
  172. package/src/svelte/renderers/Conditional.svelte +67 -0
  173. package/src/svelte/renderers/DiscriminatedUnion.svelte +197 -0
  174. package/src/svelte/renderers/Enum.svelte +53 -0
  175. package/src/svelte/renderers/Fallback.svelte +24 -0
  176. package/src/svelte/renderers/File.svelte +46 -0
  177. package/src/svelte/renderers/Literal.svelte +29 -0
  178. package/src/svelte/renderers/Mount.svelte +24 -0
  179. package/src/svelte/renderers/Negation.svelte +35 -0
  180. package/src/svelte/renderers/Never.svelte +24 -0
  181. package/src/svelte/renderers/Null.svelte +19 -0
  182. package/src/svelte/renderers/Number.svelte +68 -0
  183. package/src/svelte/renderers/Object.svelte +74 -0
  184. package/src/svelte/renderers/Record.svelte +134 -0
  185. package/src/svelte/renderers/RecursionSentinel.svelte +27 -0
  186. package/src/svelte/renderers/String.svelte +152 -0
  187. package/src/svelte/renderers/Tuple.svelte +84 -0
  188. package/src/svelte/renderers/Union.svelte +49 -0
  189. package/src/svelte/renderers/Unknown.svelte +42 -0
  190. package/src/svelte/svelte-modules.d.ts +25 -0
  191. package/src/svelte/types.ts +238 -0
  192. package/src/svelte/widget.ts +62 -0
  193. /package/dist/{diagnostics-BTrm3O6J.d.mts → diagnostics-mftUZI7c.d.mts} +0 -0
  194. /package/dist/{limits-x4OiyJxh.d.mts → limits-Vv9hUbI_.d.mts} +0 -0
  195. /package/dist/{types-BrYbjC7_.d.mts → types-BBQaEPfE.d.mts} +0 -0
  196. /package/dist/{version-DL8U5RuA.d.mts → version-BEBx10ND.d.mts} +0 -0
@@ -1,2 +1,2 @@
1
- import { A as UnknownField, B as isNeverField, C as RecordField, D as StringField, E as StringConstraints, F as isDiscriminatedUnionField, G as isStringField, H as isNumberField, I as isEnumField, J as isUnknownField, K as isTupleField, L as isFileField, M as isArrayField, N as isBooleanField, O as TupleField, P as isConditionalField, R as isLiteralField, S as ObjectField, T as SchemaType, U as isObjectField, V as isNullField, W as isRecordField, Y as resolveEditability, _ as NeverField, a as DiscriminatedUnionField, b as NumberField, c as FieldBase, d as FieldOverrides, f as FileConstraints, g as NegationField, h as LiteralField, i as ConditionalField, j as WalkedField, k as UnionField, l as FieldConstraints, m as JsonObject, n as ArrayField, o as Editability, p as FileField, q as isUnionField, r as BooleanField, s as EnumField, t as ArrayConstraints, u as FieldOverride, v as NullField, w as SchemaMeta, x as ObjectConstraints, y as NumberConstraints, z as isNegationField } from "../types-BrYbjC7_.mjs";
1
+ import { A as UnknownField, B as isNeverField, C as RecordField, D as StringField, E as StringConstraints, F as isDiscriminatedUnionField, G as isStringField, H as isNumberField, I as isEnumField, J as isUnknownField, K as isTupleField, L as isFileField, M as isArrayField, N as isBooleanField, O as TupleField, P as isConditionalField, R as isLiteralField, S as ObjectField, T as SchemaType, U as isObjectField, V as isNullField, W as isRecordField, Y as resolveEditability, _ as NeverField, a as DiscriminatedUnionField, b as NumberField, c as FieldBase, d as FieldOverrides, f as FileConstraints, g as NegationField, h as LiteralField, i as ConditionalField, j as WalkedField, k as UnionField, l as FieldConstraints, m as JsonObject, n as ArrayField, o as Editability, p as FileField, q as isUnionField, r as BooleanField, s as EnumField, t as ArrayConstraints, u as FieldOverride, v as NullField, w as SchemaMeta, x as ObjectConstraints, y as NumberConstraints, z as isNegationField } from "../types-BBQaEPfE.mjs";
2
2
  export { ArrayConstraints, ArrayField, BooleanField, ConditionalField, DiscriminatedUnionField, Editability, EnumField, FieldBase, FieldConstraints, FieldOverride, FieldOverrides, FileConstraints, FileField, JsonObject, LiteralField, NegationField, NeverField, NullField, NumberConstraints, NumberField, ObjectConstraints, ObjectField, RecordField, SchemaMeta, SchemaType, StringConstraints, StringField, TupleField, UnionField, UnknownField, WalkedField, isArrayField, isBooleanField, isConditionalField, isDiscriminatedUnionField, isEnumField, isFileField, isLiteralField, isNegationField, isNeverField, isNullField, isNumberField, isObjectField, isRecordField, isStringField, isTupleField, isUnionField, isUnknownField, resolveEditability };
@@ -1,4 +1,4 @@
1
- import { j as WalkedField } from "../types-BrYbjC7_.mjs";
1
+ import { j as WalkedField } from "../types-BBQaEPfE.mjs";
2
2
 
3
3
  //#region src/core/unionMatch.d.ts
4
4
  /**
@@ -33,8 +33,8 @@ declare function isSafeHyperlink(value: string): boolean;
33
33
  * the resulting `mailto:` URI. Refuse any value containing `%` to close
34
34
  * that header-injection vector. The plain email-format regex stays a
35
35
  * pure email-syntax check; the additional `%` filter lives here so other
36
- * callers of the format pattern (form validators, JSON Schema `format:
37
- * email` checks) are not affected.
36
+ * callers of the format pattern (form validators, JSON Schema
37
+ * `format: email` checks) are not affected.
38
38
  */
39
39
  declare function isSafeMailtoAddress(value: string): boolean;
40
40
  /**
package/dist/core/uri.mjs CHANGED
@@ -70,8 +70,8 @@ function isSafeHyperlink(value) {
70
70
  * the resulting `mailto:` URI. Refuse any value containing `%` to close
71
71
  * that header-injection vector. The plain email-format regex stays a
72
72
  * pure email-syntax check; the additional `%` filter lives here so other
73
- * callers of the format pattern (form validators, JSON Schema `format:
74
- * email` checks) are not affected.
73
+ * callers of the format pattern (form validators, JSON Schema
74
+ * `format: email` checks) are not affected.
75
75
  */
76
76
  function isSafeMailtoAddress(value) {
77
77
  if (value.includes("%")) return false;
@@ -1,2 +1,2 @@
1
- import { a as detectJsonSchemaDraft, c as inferJsonSchemaDraftWithReason, d as isSwagger2, f as matchJsonSchemaDraftUri, i as OpenApiVersionInfo, l as isOpenApi30, n as JsonSchemaDialectInfo, o as detectOpenApiVersion, p as readJsonSchemaDialect, r as JsonSchemaDraft, s as inferJsonSchemaDraft, t as InferredDraft, u as isOpenApi31 } from "../version-DL8U5RuA.mjs";
1
+ import { a as detectJsonSchemaDraft, c as inferJsonSchemaDraftWithReason, d as isSwagger2, f as matchJsonSchemaDraftUri, i as OpenApiVersionInfo, l as isOpenApi30, n as JsonSchemaDialectInfo, o as detectOpenApiVersion, p as readJsonSchemaDialect, r as JsonSchemaDraft, s as inferJsonSchemaDraft, t as InferredDraft, u as isOpenApi31 } from "../version-BEBx10ND.mjs";
2
2
  export { InferredDraft, JsonSchemaDialectInfo, JsonSchemaDraft, OpenApiVersionInfo, detectJsonSchemaDraft, detectOpenApiVersion, inferJsonSchemaDraft, inferJsonSchemaDraftWithReason, isOpenApi30, isOpenApi31, isSwagger2, matchJsonSchemaDraftUri, readJsonSchemaDialect };
@@ -1,6 +1,6 @@
1
- import { A as UnknownField, D as StringField, b as NumberField, c as FieldBase, d as FieldOverrides, j as WalkedField, o as Editability, p as FileField, r as BooleanField, v as NullField, w as SchemaMeta } from "../types-BrYbjC7_.mjs";
2
- import { i as DiagnosticsOptions } from "../diagnostics-BTrm3O6J.mjs";
3
- import { t as ExternalResolver } from "../ref-DdsbekXX.mjs";
1
+ import { A as UnknownField, D as StringField, b as NumberField, c as FieldBase, d as FieldOverrides, j as WalkedField, o as Editability, p as FileField, r as BooleanField, v as NullField, w as SchemaMeta } from "../types-BBQaEPfE.mjs";
2
+ import { i as DiagnosticsOptions } from "../diagnostics-mftUZI7c.mjs";
3
+ import { t as ExternalResolver } from "../ref-DWrQG1Er.mjs";
4
4
 
5
5
  //#region src/core/walkBuilders.d.ts
6
6
  /** Read a key from a JSON object, returning the value when it is a string and `undefined` otherwise. */
@@ -115,7 +115,7 @@ declare function buildFileField(schema: Record<string, unknown>, ctx: WalkContex
115
115
  * cannot represent a JSON Schema and have no walk-time meaning.
116
116
  */
117
117
  declare function walkSubSchemaMap<T>(map: Record<string, unknown>, walkSubSchema: (schema: unknown, ctx: WalkContext) => T, ctx: WalkContext): Record<string, T>;
118
- /** Walk a dependentRequired map (Record<string, string[]>). */
118
+ /** Walk a dependentRequired map (`Record<string, string[]>`). */
119
119
  declare function walkDependentRequiredMap(map: Record<string, unknown>): Record<string, string[]>;
120
120
  /**
121
121
  * Return a copy of the schema without the specified keys.
@@ -161,7 +161,7 @@ function walkSubSchemaMap(map, walkSubSchema, ctx) {
161
161
  for (const [key, value] of Object.entries(map)) if (isObject(value) || typeof value === "boolean") result[key] = walkSubSchema(value, ctx);
162
162
  return result;
163
163
  }
164
- /** Walk a dependentRequired map (Record<string, string[]>). */
164
+ /** Walk a dependentRequired map (`Record<string, string[]>`). */
165
165
  function walkDependentRequiredMap(map) {
166
166
  const result = {};
167
167
  for (const [key, value] of Object.entries(map)) if (Array.isArray(value)) result[key] = value.filter((x) => typeof x === "string");
@@ -1,4 +1,4 @@
1
- import { j as WalkedField } from "../types-BrYbjC7_.mjs";
1
+ import { j as WalkedField } from "../types-BBQaEPfE.mjs";
2
2
  import { WalkOptions } from "./walkBuilders.mjs";
3
3
 
4
4
  //#region src/core/walker.d.ts
@@ -47,9 +47,9 @@ function walkSubSchema(value, ctx) {
47
47
  * JSON Schema 2020-12 §11.2/§11.3 semantics:
48
48
  *
49
49
  * false (forbid all extras)
50
- * > schema-object (extras must match the schema)
51
- * > true (extras explicitly permitted)
52
- * > absent (extras implicitly permitted)
50
+ * \> schema-object (extras must match the schema)
51
+ * \> true (extras explicitly permitted)
52
+ * \> absent (extras implicitly permitted)
53
53
  *
54
54
  * Unknown shapes (numbers, arrays, strings) sort below absent — we
55
55
  * cannot reason about them, so do not let them override anything.
@@ -1,4 +1,4 @@
1
- import { T as SchemaType } from "./types-BrYbjC7_.mjs";
1
+ import { T as SchemaType } from "./types-BBQaEPfE.mjs";
2
2
 
3
3
  //#region src/core/errors.d.ts
4
4
  /**
@@ -1,5 +1,5 @@
1
- import { j as WalkedField } from "../types-BrYbjC7_.mjs";
2
- import { AllConstraints } from "../core/renderer.mjs";
1
+ import { j as WalkedField } from "../types-BBQaEPfE.mjs";
2
+ import { t as AllConstraints } from "../renderer-ab9E52Bp.mjs";
3
3
  import { constraintHint } from "../core/constraintHint.mjs";
4
4
  import { HtmlAttributes, HtmlNode } from "./html.mjs";
5
5
 
@@ -12,16 +12,18 @@
12
12
  *
13
13
  * Usage:
14
14
  *
15
- * import { h, serialize } from "./html.ts";
15
+ * ```ts
16
+ * import { h, serialize } from "./html.ts";
16
17
  *
17
- * const el = h("input", { type: "text", id: "name", "aria-required": true });
18
- * serialize(el); // → '<input type="text" id="name" aria-required>'
18
+ * const el = h("input", { type: "text", id: "name", "aria-required": true });
19
+ * serialize(el); // → '<input type="text" id="name" aria-required>'
19
20
  *
20
- * const form = h("form", {},
21
- * h("label", { for: "name" }, "Name"),
22
- * h("input", { type: "text", id: "name" }),
23
- * );
24
- * serialize(form); // → '<form><label for="name">Name</label><input type="text" id="name"></form>'
21
+ * const form = h("form", {},
22
+ * h("label", { for: "name" }, "Name"),
23
+ * h("input", { type: "text", id: "name" }),
24
+ * );
25
+ * serialize(form); // → '<form><label for="name">Name</label><input type="text" id="name"></form>'
26
+ * ```
25
27
  */
26
28
  /**
27
29
  * An HTML element node. Void elements (input, br, etc.) have no children
@@ -1,8 +1,8 @@
1
- import { w as SchemaMeta } from "../types-BrYbjC7_.mjs";
2
- import { SchemaIoSide } from "../core/adapter.mjs";
3
- import { HtmlResolver } from "../core/renderer.mjs";
4
- import { RejectUnrepresentableZod } from "../core/typeInference.mjs";
5
- import { a as InferredValue, t as InferFields } from "../inferValue-PPXWJpbN.mjs";
1
+ import { w as SchemaMeta } from "../types-BBQaEPfE.mjs";
2
+ import { r as SchemaIoSide } from "../adapter-ktQaheWB.mjs";
3
+ import { s as HtmlResolver } from "../renderer-ab9E52Bp.mjs";
4
+ import { f as RejectUnrepresentableZod } from "../typeInference-Y8tNEQJk.mjs";
5
+ import { a as InferredValue, t as InferFields } from "../inferValue-eAnh50EM.mjs";
6
6
 
7
7
  //#region src/html/renderToHtml.d.ts
8
8
  /**
@@ -1,6 +1,6 @@
1
1
  import { toRecordOrUndefined } from "../core/guards.mjs";
2
- import "../core/limits.mjs";
3
2
  import { normaliseSchema } from "../core/adapter.mjs";
3
+ import { dispatchRenderField } from "../core/renderField.mjs";
4
4
  import { getHtmlRenderFn, mergeHtmlResolvers } from "../core/renderer.mjs";
5
5
  import { walk } from "../core/walker.mjs";
6
6
  import { h, serialize } from "./html.mjs";
@@ -18,14 +18,20 @@ import { defaultHtmlResolver } from "./renderers.mjs";
18
18
  * compile-time tag/attribute checking and automatic escaping.
19
19
  *
20
20
  * Usage:
21
- * import { renderToHtml } from "schema-components/html/renderToHtml";
22
- * const html = renderToHtml(userSchema, { value: userData });
21
+ *
22
+ * ```ts
23
+ * import { renderToHtml } from "schema-components/html/renderToHtml";
24
+ * const html = renderToHtml(userSchema, { value: userData });
25
+ * ```
23
26
  *
24
27
  * Custom resolver:
25
- * const html = renderToHtml(schema, {
26
- * value,
27
- * resolver: { string: (props) => h("b", {}, String(props.value)) },
28
- * });
28
+ *
29
+ * ```ts
30
+ * const html = renderToHtml(schema, {
31
+ * value,
32
+ * resolver: { string: (props) => h("b", {}, String(props.value)) },
33
+ * });
34
+ * ```
29
35
  */
30
36
  /**
31
37
  * Build the recursion-cap sentinel element used when the renderer
@@ -72,31 +78,46 @@ function renderToHtml(schema, options = {}) {
72
78
  });
73
79
  const resolver = options.resolver ?? defaultHtmlResolver;
74
80
  const makeRenderChild = (currentDepth, parentPath) => (childTree, childValue, pathSuffix) => {
75
- if (currentDepth >= 10) return recursionSentinelHtml(typeof childTree.meta.description === "string" ? childTree.meta.description : "schema");
76
81
  const childPath = joinPath(parentPath, pathSuffix);
77
- return renderFieldHtml(childTree, childValue, resolver, childPath, makeRenderChild(currentDepth + 1, childPath));
82
+ return renderFieldHtml(childTree, childValue, resolver, childPath, makeRenderChild(currentDepth + 1, childPath), currentDepth + 1);
78
83
  };
79
84
  const renderChild = makeRenderChild(0, "");
80
- return renderFieldHtml(tree, options.value ?? tree.defaultValue, resolver, "", renderChild);
85
+ return renderFieldHtml(tree, options.value ?? tree.defaultValue, resolver, "", renderChild, 0);
81
86
  }
82
- function renderFieldHtml(tree, value, resolver, path, renderChild) {
87
+ function renderFieldHtml(tree, value, resolver, path, renderChild, depth = 0) {
83
88
  if (tree.meta.visible === false) return "";
84
89
  const effectiveValue = value ?? tree.defaultValue;
85
- const mergedResolver = mergeHtmlResolvers(resolver, defaultHtmlResolver);
86
- const renderFn = getHtmlRenderFn(tree.type, mergedResolver);
87
- if (renderFn === void 0) throw new Error(`renderToHtml: no HTML renderer registered for type "${tree.type}"`);
88
- const props = {
90
+ return dispatchRenderField({
91
+ tree,
89
92
  value: effectiveValue,
90
- readOnly: tree.editability === "presentation",
91
- writeOnly: tree.editability === "input",
92
- meta: tree.meta,
93
- constraints: tree.constraints,
94
93
  path,
95
- tree,
96
- renderChild
97
- };
98
- if (tree.examples !== void 0) props.examples = tree.examples;
99
- return renderFn(props);
94
+ depth,
95
+ resolver: mergeHtmlResolvers(resolver, defaultHtmlResolver),
96
+ config: {
97
+ buildProps: (fieldTree, fieldPath) => {
98
+ const props = {
99
+ value: effectiveValue,
100
+ readOnly: fieldTree.editability === "presentation",
101
+ writeOnly: fieldTree.editability === "input",
102
+ meta: fieldTree.meta,
103
+ constraints: fieldTree.constraints,
104
+ path: fieldPath,
105
+ tree: fieldTree,
106
+ renderChild
107
+ };
108
+ if (fieldTree.examples !== void 0) props.examples = fieldTree.examples;
109
+ return props;
110
+ },
111
+ lookupRenderFn: (type, htmlResolver) => getHtmlRenderFn(type, htmlResolver),
112
+ recursionSentinel: (fieldTree) => {
113
+ return recursionSentinelHtml(typeof fieldTree.meta.description === "string" ? fieldTree.meta.description : "schema");
114
+ },
115
+ fallback: (fieldTree) => {
116
+ throw new Error(`renderToHtml: no HTML renderer registered for type "${fieldTree.type}"`);
117
+ },
118
+ coerceResult: (result) => typeof result === "string" ? result : void 0
119
+ }
120
+ });
100
121
  }
101
122
  //#endregion
102
123
  export { recursionSentinelHtml, renderToHtml };
@@ -1,8 +1,8 @@
1
- import { w as SchemaMeta } from "../types-BrYbjC7_.mjs";
2
- import { SchemaIoSide } from "../core/adapter.mjs";
3
- import { HtmlResolver } from "../core/renderer.mjs";
4
- import { RejectUnrepresentableZod } from "../core/typeInference.mjs";
5
- import { a as InferredValue, t as InferFields } from "../inferValue-PPXWJpbN.mjs";
1
+ import { w as SchemaMeta } from "../types-BBQaEPfE.mjs";
2
+ import { r as SchemaIoSide } from "../adapter-ktQaheWB.mjs";
3
+ import { s as HtmlResolver } from "../renderer-ab9E52Bp.mjs";
4
+ import { f as RejectUnrepresentableZod } from "../typeInference-Y8tNEQJk.mjs";
5
+ import { a as InferredValue, t as InferFields } from "../inferValue-eAnh50EM.mjs";
6
6
 
7
7
  //#region src/html/renderToHtmlStream.d.ts
8
8
  /**
@@ -1,4 +1,4 @@
1
- import { HtmlResolver } from "../core/renderer.mjs";
1
+ import { s as HtmlResolver } from "../renderer-ab9E52Bp.mjs";
2
2
  import { dateInputType } from "../core/formats.mjs";
3
3
  import { matchUnionOption } from "../core/unionMatch.mjs";
4
4
 
@@ -1,6 +1,6 @@
1
- import { j as WalkedField } from "../types-BrYbjC7_.mjs";
2
- import { i as DiagnosticsOptions } from "../diagnostics-BTrm3O6J.mjs";
3
- import { HtmlResolver } from "../core/renderer.mjs";
1
+ import { j as WalkedField } from "../types-BBQaEPfE.mjs";
2
+ import { i as DiagnosticsOptions } from "../diagnostics-mftUZI7c.mjs";
3
+ import { s as HtmlResolver } from "../renderer-ab9E52Bp.mjs";
4
4
  import { HtmlElement } from "./html.mjs";
5
5
 
6
6
  //#region src/html/streamRenderers.d.ts
@@ -1,6 +1,6 @@
1
- import { d as FieldOverrides, u as FieldOverride } from "./types-BrYbjC7_.mjs";
2
- import { SchemaIoSide } from "./core/adapter.mjs";
3
- import { FromJSONSchema, FromJSONSchemaMode, IsSwagger2Doc, ResolveOpenAPIRef, TypeAtPath, __SchemaInferenceFellBack } from "./core/typeInference.mjs";
1
+ import { d as FieldOverrides, u as FieldOverride } from "./types-BBQaEPfE.mjs";
2
+ import { r as SchemaIoSide } from "./adapter-ktQaheWB.mjs";
3
+ import { c as IsSwagger2Doc, i as FromJSONSchemaMode, m as TypeAtPath, p as ResolveOpenAPIRef, r as FromJSONSchema, v as __SchemaInferenceFellBack } from "./typeInference-Y8tNEQJk.mjs";
4
4
  import { z } from "zod";
5
5
 
6
6
  //#region src/core/inferValue.d.ts
@@ -46,9 +46,9 @@ type NarrowAtPath<V, P extends string | undefined> = P extends string ? TypeAtPa
46
46
  * Public alias mapping a schema input to the rendered value type.
47
47
  *
48
48
  * Picks the OUTPUT side (server → client) of every transform / pipe /
49
- * codec. For an `<SchemaComponent io="output">` or `<SchemaView
50
- * io="output">` (both defaults), this is the inferred shape of
51
- * `value` and the parameter of `onChange`.
49
+ * codec. For a `<SchemaComponent io="output">` or `<SchemaView io="output">`
50
+ * (both defaults), this is the inferred shape of `value` and the
51
+ * parameter of `onChange`.
52
52
  */
53
53
  type InferredOutputValue<T, Ref extends string | undefined = undefined, P extends string | undefined = undefined> = NarrowAtPath<InferSchemaValue<T, Ref, "output">, P>;
54
54
  /**
@@ -0,0 +1,125 @@
1
+ import { j as WalkedField, 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 { r as LitRenderProps, t as LitComponentResolver } from "../types-BCy7K3nk.mjs";
5
+ import { LitElement, TemplateResult } from "lit";
6
+
7
+ //#region src/lit/SchemaComponent.d.ts
8
+ /**
9
+ * Public change-event detail emitted on the top-level `<schema-component>`.
10
+ *
11
+ * The `value` payload carries the updated root value as returned by
12
+ * the user's most recent edit. Consumers wire this into their
13
+ * framework's binding system — React via `addEventListener` on the
14
+ * canonical `change` event, Vue via a `@change` directive, Svelte
15
+ * via `on:change`. The detail object always carries a single
16
+ * `value` field with the post-edit root value.
17
+ */
18
+ interface SchemaChangeEventDetail {
19
+ value: unknown;
20
+ }
21
+ /**
22
+ * Lit Custom Element for editable schema-driven UI.
23
+ *
24
+ * Tag: `<schema-component>` (default) or `<{prefix}schema-component>`
25
+ * (when `registerSchemaComponents(prefix)` is called).
26
+ *
27
+ * **Required:** call {@link registerSchemaComponents} once at module
28
+ * setup before instantiating this element in HTML markup, otherwise
29
+ * none of the per-type `<sc-*>` children will upgrade and the tree
30
+ * will render as unknown elements.
31
+ */
32
+ declare class SchemaComponent extends LitElement {
33
+ /**
34
+ * Element property declarations.
35
+ *
36
+ * All four "data" properties (`schema`, `value`, `resolver`,
37
+ * `widgets`) carry `attribute: false`: Custom Element attributes
38
+ * are strings, and these payloads (an arbitrary Zod schema, an
39
+ * arbitrary JS value, a resolver function map, a widget tag map)
40
+ * cannot round-trip through attribute serialisation. Set them via
41
+ * direct property assignment.
42
+ *
43
+ * `readOnly` is a boolean attribute (and reflects to DOM) so the
44
+ * common "render read-only view" case is reachable from plain
45
+ * HTML markup (`<schema-component readonly></schema-component>`).
46
+ * The capitalisation is `readOnly` on the property and `readonly`
47
+ * on the attribute — matching the HTML `readonly` attribute on
48
+ * `<input>` / `<textarea>`.
49
+ */
50
+ static readonly properties: {
51
+ schema: {
52
+ attribute: boolean;
53
+ };
54
+ value: {
55
+ attribute: boolean;
56
+ };
57
+ resolver: {
58
+ attribute: boolean;
59
+ };
60
+ widgets: {
61
+ attribute: boolean;
62
+ };
63
+ fields: {
64
+ attribute: boolean;
65
+ };
66
+ meta: {
67
+ attribute: boolean;
68
+ };
69
+ ref: {
70
+ attribute: boolean;
71
+ };
72
+ io: {
73
+ attribute: boolean;
74
+ };
75
+ idPrefix: {
76
+ attribute: boolean;
77
+ };
78
+ onDiagnostic: {
79
+ attribute: boolean;
80
+ };
81
+ readOnly: {
82
+ type: BooleanConstructor;
83
+ reflect: boolean;
84
+ attribute: string;
85
+ };
86
+ strict: {
87
+ type: BooleanConstructor;
88
+ };
89
+ };
90
+ /**
91
+ * Reactive property declarations. Each field is declared with
92
+ * `declare` (no runtime emit) so Lit's `static properties`
93
+ * accessors are not shadowed by class-field initialisers. Default
94
+ * values are seeded in the constructor.
95
+ */
96
+ schema: unknown;
97
+ ref: string | undefined;
98
+ io: SchemaIoSide | undefined;
99
+ value: unknown;
100
+ resolver: LitComponentResolver | undefined;
101
+ widgets: ReadonlyMap<string, string> | undefined;
102
+ fields: Record<string, unknown> | undefined;
103
+ meta: SchemaMeta | undefined;
104
+ idPrefix: string | undefined;
105
+ readOnly: boolean;
106
+ strict: boolean;
107
+ onDiagnostic: ((diagnostic: Diagnostic) => void) | undefined;
108
+ constructor();
109
+ render(): TemplateResult;
110
+ /**
111
+ * Build the recursive `renderChild` closure threaded through every
112
+ * container renderer.
113
+ */
114
+ protected makeRenderChild(currentDepth: number, parentPath: string, userResolver: LitComponentResolver): LitRenderProps["renderChild"];
115
+ /**
116
+ * Dispatch a single walked field through the resolver, widget
117
+ * registry, and recursion limit. Parallel to
118
+ * `renderField` in `react/SchemaComponent.tsx`.
119
+ */
120
+ protected renderField(tree: WalkedField, value: unknown, change: (next: unknown) => void, userResolver: LitComponentResolver, renderChild: LitRenderProps["renderChild"], path: string): TemplateResult;
121
+ private applyWidgetProperties;
122
+ private buildDiagnostics;
123
+ }
124
+ //#endregion
125
+ export { SchemaChangeEventDetail, SchemaComponent };
@@ -0,0 +1,2 @@
1
+ import { t as SchemaComponent } from "../SchemaComponent-BxzzsHsK.mjs";
2
+ export { SchemaComponent };
@@ -0,0 +1,65 @@
1
+ import { SchemaComponent } from "./SchemaComponent.mjs";
2
+ import { TemplateResult } from "lit";
3
+
4
+ //#region src/lit/SchemaField.d.ts
5
+ /**
6
+ * Lit Custom Element rendering a single sub-field of a schema.
7
+ *
8
+ * Tag: `<schema-field>` (registered by `registerSchemaComponents`).
9
+ */
10
+ declare class SchemaField extends SchemaComponent {
11
+ /**
12
+ * Dot-separated path identifying the field to render
13
+ * (e.g. `"address.city"` or `"tags[0]"`). Declared via `declare`
14
+ * so Lit's accessor (installed by the static `properties` table)
15
+ * is not shadowed by a class-field initialiser.
16
+ */
17
+ path: string;
18
+ static readonly properties: {
19
+ path: {
20
+ attribute: boolean;
21
+ };
22
+ schema: {
23
+ attribute: boolean;
24
+ };
25
+ value: {
26
+ attribute: boolean;
27
+ };
28
+ resolver: {
29
+ attribute: boolean;
30
+ };
31
+ widgets: {
32
+ attribute: boolean;
33
+ };
34
+ fields: {
35
+ attribute: boolean;
36
+ };
37
+ meta: {
38
+ attribute: boolean;
39
+ };
40
+ ref: {
41
+ attribute: boolean;
42
+ };
43
+ io: {
44
+ attribute: boolean;
45
+ };
46
+ idPrefix: {
47
+ attribute: boolean;
48
+ };
49
+ onDiagnostic: {
50
+ attribute: boolean;
51
+ };
52
+ readOnly: {
53
+ type: BooleanConstructor;
54
+ reflect: boolean;
55
+ attribute: string;
56
+ };
57
+ strict: {
58
+ type: BooleanConstructor;
59
+ };
60
+ };
61
+ constructor();
62
+ render(): TemplateResult;
63
+ }
64
+ //#endregion
65
+ export { SchemaField };
@@ -0,0 +1,2 @@
1
+ import { o as SchemaField } from "../SchemaComponent-BxzzsHsK.mjs";
2
+ export { SchemaField };
@@ -0,0 +1,14 @@
1
+ import { SchemaComponent } from "./SchemaComponent.mjs";
2
+
3
+ //#region src/lit/SchemaView.d.ts
4
+ /**
5
+ * Lit Custom Element rendering a schema in read-only mode.
6
+ *
7
+ * Tag: `<schema-view>` (registered by `registerSchemaComponents`).
8
+ */
9
+ declare class SchemaView extends SchemaComponent {
10
+ constructor();
11
+ connectedCallback(): void;
12
+ }
13
+ //#endregion
14
+ export { SchemaView };
@@ -0,0 +1,2 @@
1
+ import { s as SchemaView } from "../SchemaComponent-BxzzsHsK.mjs";
2
+ export { SchemaView };
@@ -0,0 +1,2 @@
1
+ import { t as Constructor } from "../constructorTypes-BdCiMS6e.mjs";
2
+ export { Constructor };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,78 @@
1
+ import { ContextPort } from "../core/contexts.mjs";
2
+ import { t as LitComponentResolver } from "../types-BCy7K3nk.mjs";
3
+ import { ReactiveControllerHost, ReactiveElement } from "lit";
4
+
5
+ //#region src/lit/contexts.d.ts
6
+ /**
7
+ * Context key identifying the {@link LitComponentResolver} provided at
8
+ * a host element. Re-used by every built-in `<sc-*>` Custom Element so
9
+ * a single `<schema-component>` provider seeds the whole subtree —
10
+ * matching the behaviour of `<SchemaProvider>` on the React side.
11
+ *
12
+ * The literal `"sc-resolver"` value is the runtime key carried in the
13
+ * Context Protocol's `context-request` event; consumers and providers
14
+ * must use the same `Context` object (not just the same string) to
15
+ * match, which is why this is exported rather than redeclared per
16
+ * element.
17
+ */
18
+ declare const resolverContext: {
19
+ __context__: LitComponentResolver;
20
+ };
21
+ /**
22
+ * Lit binding wrapping `ContextProvider` / `ContextConsumer` from
23
+ * `@lit/context` for the {@link resolverContext}.
24
+ *
25
+ * The port is host-scoped — both `provide` and `consume` require a
26
+ * `ReactiveControllerHost` reference so `@lit/context` can register
27
+ * its controllers on the element's lifecycle. This is unavoidable
28
+ * given Lit's reactive update model and is the reason the Lit port
29
+ * does not match the canonical {@link ContextPort} signature in
30
+ * `core/contexts.ts` directly — see this module's docstring for the
31
+ * rationale.
32
+ */
33
+ declare const resolverContextPort: {
34
+ provide(host: ReactiveControllerHost & ReactiveElement, value: LitComponentResolver): {
35
+ setValue: (value: LitComponentResolver) => void;
36
+ };
37
+ consume(host: ReactiveControllerHost & ReactiveElement): {
38
+ readonly value?: LitComponentResolver;
39
+ };
40
+ };
41
+ /**
42
+ * Widget map — name → custom element tag.
43
+ *
44
+ * Where the React adapter's `WidgetMap` is `ReadonlyMap<string, RenderFunction>`
45
+ * (a function value per hint name), the Lit adapter resolves widgets by
46
+ * Custom Element tag name. A schema field carrying
47
+ * `.meta({ component: "color-picker" })` looks up `widgets.get("color-picker")`
48
+ * and renders the matching tag — preserving the Web-Components-native
49
+ * pattern where every renderer override IS a Custom Element.
50
+ *
51
+ * Tags must be registered via `customElements.define` before they can
52
+ * be rendered. Unregistered tags surface as unknown elements with no
53
+ * upgrade — matching the browser's behaviour rather than throwing.
54
+ */
55
+ type LitWidgetMap = ReadonlyMap<string, string>;
56
+ /**
57
+ * Context key for {@link LitWidgetMap}.
58
+ */
59
+ declare const widgetsContext: {
60
+ __context__: LitWidgetMap;
61
+ };
62
+ /**
63
+ * Lit binding wrapping `ContextProvider` / `ContextConsumer` from
64
+ * `@lit/context` for the {@link widgetsContext}. Parallel to
65
+ * {@link resolverContextPort}; see that export for the rationale on
66
+ * why the Lit port is host-scoped rather than matching the canonical
67
+ * {@link ContextPort} signature directly.
68
+ */
69
+ declare const widgetsContextPort: {
70
+ provide(host: ReactiveControllerHost & ReactiveElement, value: LitWidgetMap): {
71
+ setValue: (value: LitWidgetMap) => void;
72
+ };
73
+ consume(host: ReactiveControllerHost & ReactiveElement): {
74
+ readonly value?: LitWidgetMap;
75
+ };
76
+ };
77
+ //#endregion
78
+ export { type ContextPort, LitWidgetMap, resolverContext, resolverContextPort, widgetsContext, widgetsContextPort };