@azx-pbc/axiom-react 0.0.0-stage → 0.0.6

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 (191) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +604 -2
  3. package/dist/FormErrorBoundary.d.ts +37 -0
  4. package/dist/FormErrorBoundary.d.ts.map +1 -0
  5. package/dist/FormErrorBoundary.js +54 -0
  6. package/dist/FormErrorBoundary.js.map +1 -0
  7. package/dist/FormProvider.d.ts +197 -0
  8. package/dist/FormProvider.d.ts.map +1 -0
  9. package/dist/FormProvider.js +149 -0
  10. package/dist/FormProvider.js.map +1 -0
  11. package/dist/field-error.d.ts +154 -0
  12. package/dist/field-error.d.ts.map +1 -0
  13. package/dist/field-error.js +2 -0
  14. package/dist/field-error.js.map +1 -0
  15. package/dist/field-props.d.ts +362 -0
  16. package/dist/field-props.d.ts.map +1 -0
  17. package/dist/field-props.js +64 -0
  18. package/dist/field-props.js.map +1 -0
  19. package/dist/form-context.d.ts +31 -0
  20. package/dist/form-context.d.ts.map +1 -0
  21. package/dist/form-context.js +13 -0
  22. package/dist/form-context.js.map +1 -0
  23. package/dist/form-store.d.ts +784 -0
  24. package/dist/form-store.d.ts.map +1 -0
  25. package/dist/form-store.js +2179 -0
  26. package/dist/form-store.js.map +1 -0
  27. package/dist/hints.d.ts +60 -0
  28. package/dist/hints.d.ts.map +1 -0
  29. package/dist/hints.js +158 -0
  30. package/dist/hints.js.map +1 -0
  31. package/dist/index.d.ts +57 -0
  32. package/dist/index.d.ts.map +1 -0
  33. package/dist/index.js +36 -0
  34. package/dist/index.js.map +1 -0
  35. package/dist/render/field-value.d.ts +92 -0
  36. package/dist/render/field-value.d.ts.map +1 -0
  37. package/dist/render/field-value.js +124 -0
  38. package/dist/render/field-value.js.map +1 -0
  39. package/dist/render/nodes.d.ts +303 -0
  40. package/dist/render/nodes.d.ts.map +1 -0
  41. package/dist/render/nodes.js +325 -0
  42. package/dist/render/nodes.js.map +1 -0
  43. package/dist/render/schema.d.ts +30 -0
  44. package/dist/render/schema.d.ts.map +1 -0
  45. package/dist/render/schema.js +40 -0
  46. package/dist/render/schema.js.map +1 -0
  47. package/dist/render/value-text.d.ts +59 -0
  48. package/dist/render/value-text.d.ts.map +1 -0
  49. package/dist/render/value-text.js +104 -0
  50. package/dist/render/value-text.js.map +1 -0
  51. package/dist/store/array-bindings.d.ts +110 -0
  52. package/dist/store/array-bindings.d.ts.map +1 -0
  53. package/dist/store/array-bindings.js +181 -0
  54. package/dist/store/array-bindings.js.map +1 -0
  55. package/dist/store/bindings.d.ts +12 -0
  56. package/dist/store/bindings.d.ts.map +1 -0
  57. package/dist/store/bindings.js +16 -0
  58. package/dist/store/bindings.js.map +1 -0
  59. package/dist/store/buffer-state.d.ts +42 -0
  60. package/dist/store/buffer-state.d.ts.map +1 -0
  61. package/dist/store/buffer-state.js +51 -0
  62. package/dist/store/buffer-state.js.map +1 -0
  63. package/dist/store/configure.d.ts +19 -0
  64. package/dist/store/configure.d.ts.map +1 -0
  65. package/dist/store/configure.js +28 -0
  66. package/dist/store/configure.js.map +1 -0
  67. package/dist/store/derive.d.ts +106 -0
  68. package/dist/store/derive.d.ts.map +1 -0
  69. package/dist/store/derive.js +417 -0
  70. package/dist/store/derive.js.map +1 -0
  71. package/dist/store/errors.d.ts +20 -0
  72. package/dist/store/errors.d.ts.map +1 -0
  73. package/dist/store/errors.js +101 -0
  74. package/dist/store/errors.js.map +1 -0
  75. package/dist/store/fields.d.ts +35 -0
  76. package/dist/store/fields.d.ts.map +1 -0
  77. package/dist/store/fields.js +81 -0
  78. package/dist/store/fields.js.map +1 -0
  79. package/dist/store/form-channel.d.ts +174 -0
  80. package/dist/store/form-channel.d.ts.map +1 -0
  81. package/dist/store/form-channel.js +411 -0
  82. package/dist/store/form-channel.js.map +1 -0
  83. package/dist/store/gates.d.ts +22 -0
  84. package/dist/store/gates.d.ts.map +1 -0
  85. package/dist/store/gates.js +44 -0
  86. package/dist/store/gates.js.map +1 -0
  87. package/dist/store/ids.d.ts +20 -0
  88. package/dist/store/ids.d.ts.map +1 -0
  89. package/dist/store/ids.js +28 -0
  90. package/dist/store/ids.js.map +1 -0
  91. package/dist/store/inputs.d.ts +114 -0
  92. package/dist/store/inputs.d.ts.map +1 -0
  93. package/dist/store/inputs.js +202 -0
  94. package/dist/store/inputs.js.map +1 -0
  95. package/dist/store/layout.d.ts +81 -0
  96. package/dist/store/layout.d.ts.map +1 -0
  97. package/dist/store/layout.js +285 -0
  98. package/dist/store/layout.js.map +1 -0
  99. package/dist/store/messages.d.ts +56 -0
  100. package/dist/store/messages.d.ts.map +1 -0
  101. package/dist/store/messages.js +157 -0
  102. package/dist/store/messages.js.map +1 -0
  103. package/dist/store/option-pages.d.ts +193 -0
  104. package/dist/store/option-pages.d.ts.map +1 -0
  105. package/dist/store/option-pages.js +598 -0
  106. package/dist/store/option-pages.js.map +1 -0
  107. package/dist/store/parse-print.d.ts +105 -0
  108. package/dist/store/parse-print.d.ts.map +1 -0
  109. package/dist/store/parse-print.js +415 -0
  110. package/dist/store/parse-print.js.map +1 -0
  111. package/dist/store/proposals.d.ts +114 -0
  112. package/dist/store/proposals.d.ts.map +1 -0
  113. package/dist/store/proposals.js +90 -0
  114. package/dist/store/proposals.js.map +1 -0
  115. package/dist/store/publish.d.ts +48 -0
  116. package/dist/store/publish.d.ts.map +1 -0
  117. package/dist/store/publish.js +96 -0
  118. package/dist/store/publish.js.map +1 -0
  119. package/dist/store/snapshots.d.ts +63 -0
  120. package/dist/store/snapshots.d.ts.map +1 -0
  121. package/dist/store/snapshots.js +154 -0
  122. package/dist/store/snapshots.js.map +1 -0
  123. package/dist/store/steps.d.ts +13 -0
  124. package/dist/store/steps.d.ts.map +1 -0
  125. package/dist/store/steps.js +31 -0
  126. package/dist/store/steps.js.map +1 -0
  127. package/dist/store/view.d.ts +124 -0
  128. package/dist/store/view.d.ts.map +1 -0
  129. package/dist/store/view.js +301 -0
  130. package/dist/store/view.js.map +1 -0
  131. package/dist/store/visibility.d.ts +68 -0
  132. package/dist/store/visibility.d.ts.map +1 -0
  133. package/dist/store/visibility.js +231 -0
  134. package/dist/store/visibility.js.map +1 -0
  135. package/dist/store/wizard-cursor.d.ts +43 -0
  136. package/dist/store/wizard-cursor.d.ts.map +1 -0
  137. package/dist/store/wizard-cursor.js +67 -0
  138. package/dist/store/wizard-cursor.js.map +1 -0
  139. package/dist/store/writes.d.ts +50 -0
  140. package/dist/store/writes.d.ts.map +1 -0
  141. package/dist/store/writes.js +91 -0
  142. package/dist/store/writes.js.map +1 -0
  143. package/dist/typed.d.ts +134 -0
  144. package/dist/typed.d.ts.map +1 -0
  145. package/dist/typed.js +74 -0
  146. package/dist/typed.js.map +1 -0
  147. package/dist/useAsyncOptions.d.ts +20 -0
  148. package/dist/useAsyncOptions.d.ts.map +1 -0
  149. package/dist/useAsyncOptions.js +70 -0
  150. package/dist/useAsyncOptions.js.map +1 -0
  151. package/dist/useBufferedInput.d.ts +69 -0
  152. package/dist/useBufferedInput.d.ts.map +1 -0
  153. package/dist/useBufferedInput.js +132 -0
  154. package/dist/useBufferedInput.js.map +1 -0
  155. package/dist/useField.d.ts +42 -0
  156. package/dist/useField.d.ts.map +1 -0
  157. package/dist/useField.js +63 -0
  158. package/dist/useField.js.map +1 -0
  159. package/dist/useFieldArray.d.ts +25 -0
  160. package/dist/useFieldArray.d.ts.map +1 -0
  161. package/dist/useFieldArray.js +18 -0
  162. package/dist/useFieldArray.js.map +1 -0
  163. package/dist/useForm.d.ts +20 -0
  164. package/dist/useForm.d.ts.map +1 -0
  165. package/dist/useForm.js +9 -0
  166. package/dist/useForm.js.map +1 -0
  167. package/dist/useFormState.d.ts +23 -0
  168. package/dist/useFormState.d.ts.map +1 -0
  169. package/dist/useFormState.js +11 -0
  170. package/dist/useFormState.js.map +1 -0
  171. package/dist/useGate.d.ts +15 -0
  172. package/dist/useGate.d.ts.map +1 -0
  173. package/dist/useGate.js +21 -0
  174. package/dist/useGate.js.map +1 -0
  175. package/dist/useLayout.d.ts +29 -0
  176. package/dist/useLayout.d.ts.map +1 -0
  177. package/dist/useLayout.js +59 -0
  178. package/dist/useLayout.js.map +1 -0
  179. package/dist/useMessage.d.ts +58 -0
  180. package/dist/useMessage.d.ts.map +1 -0
  181. package/dist/useMessage.js +62 -0
  182. package/dist/useMessage.js.map +1 -0
  183. package/dist/useWatch.d.ts +19 -0
  184. package/dist/useWatch.d.ts.map +1 -0
  185. package/dist/useWatch.js +17 -0
  186. package/dist/useWatch.js.map +1 -0
  187. package/dist/useWizard.d.ts +166 -0
  188. package/dist/useWizard.d.ts.map +1 -0
  189. package/dist/useWizard.js +554 -0
  190. package/dist/useWizard.js.map +1 -0
  191. package/package.json +62 -3
@@ -0,0 +1 @@
1
+ {"version":3,"file":"field-props.js","sourceRoot":"","sources":["../src/field-props.ts"],"names":[],"mappings":"AAeA;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,UAAU,CAAC,QAAgB,EAAE,UAAkB;IAC7D,OAAO,GAAG,iBAAiB,CAAC,QAAQ,CAAC,IAAI,iBAAiB,CAAC,UAAU,CAAC,EAAE,CAAC;AAC3E,CAAC;AAED;;;;;;;GAOG;AACH,SAAS,iBAAiB,CAAC,KAAa;IACtC,IAAI,OAAO,GAAG,EAAE,CAAC;IACjB,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,CAAC;QACnC,MAAM,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;QAChC,OAAO;YACL,IAAI,IAAI,MAAM,IAAI,IAAI,IAAI,MAAM;gBAC9B,CAAC,CAAC,KAAK,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE;gBACzD,CAAC,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC;IACjC,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,YAAY,CAAC,QAAgB,EAAE,UAAkB;IAC/D,OAAO,GAAG,UAAU,CAAC,QAAQ,EAAE,UAAU,CAAC,QAAQ,CAAC;AACrD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAAC,QAAgB,EAAE,UAAkB;IACrE,OAAO,GAAG,UAAU,CAAC,QAAQ,EAAE,UAAU,CAAC,cAAc,CAAC;AAC3D,CAAC","sourcesContent":["import type {\n CompiledField,\n EngineOutcome,\n FieldAccess,\n FieldMessage,\n UnavailableOption,\n WireValue,\n WithheldReason,\n} from '@azx-pbc/axiom-runtime';\nimport type { FieldComputation } from '@azx-pbc/axiom-runtime';\nimport type { FieldError } from './field-error.js';\nimport type { InputHints } from './hints.js';\n\nexport type { FieldComputation, FieldMessage } from '@azx-pbc/axiom-runtime';\n\n/**\n * The element id one binding's control uses, under one provider's prefix.\n *\n * Two facts make up the id, and both are needed:\n *\n * - The prefix identifies the form session. `bindingKey` alone is the same string in every\n * provider over one artifact, so two forms on a page emitted duplicate `id`, `htmlFor` and\n * `aria-describedby` values and the second form's label and error text pointed at the first\n * form's control. `FormProvider` supplies one prefix per mount (`useId()` by default, or the\n * host's `idPrefix`), so the ids differ by session and every relation resolves inside its own.\n * - The key is percent-encoded because a natural row key is user text: a row called\n * `kitchen island` keys as `f_label@string:kitchen island`, and an id with a space breaks every\n * `htmlFor`/`aria-describedby` that names it. The encoding is injective, so two bindings never\n * share an id. `%`, `@` and `.` are not CSS identifier characters, so a `#id` selector needs\n * `CSS.escape`; `htmlFor`, `aria-describedby` and `getElementById` need no escaping.\n *\n * The prefix is encoded too, so a host's readable `idPrefix` cannot reintroduce an invalid id.\n */\nexport function fieldDomId(idPrefix: string, bindingKey: string): string {\n return `${encodeIdComponent(idPrefix)}-${encodeIdComponent(bindingKey)}`;\n}\n\n/**\n * One id component, encoded per UTF-16 code unit.\n *\n * `encodeURIComponent` refuses an unpaired surrogate with `URIError`, and a natural row key is a\n * string a host may have read from anywhere. Encoding each code unit keeps every JavaScript\n * string representable, and `%uXXXX` is distinct from every `%XX` escape the built-in emits, so\n * two distinct lone surrogates cannot collapse into one id.\n */\nfunction encodeIdComponent(value: string): string {\n let encoded = '';\n for (const unit of value.split('')) {\n const code = unit.charCodeAt(0);\n encoded +=\n code >= 0xd800 && code <= 0xdfff\n ? `%u${code.toString(16).toUpperCase().padStart(4, '0')}`\n : encodeURIComponent(unit);\n }\n return encoded;\n}\n\n/**\n * The identifier a binding renders its failure text into.\n *\n * Derived from `bindingKey`, so a field and each of its rows have distinct ids without the host\n * inventing a convention, and stable across a write because the binding is. A control names it in\n * `aria-describedby` (or `aria-errormessage`) and renders the text it reveals under this id.\n *\n * `@` separates the role from the key because it is always `%40` inside an encoded component, and\n * a row key is user text: a row called `r1.error` must not own the id that carries row `r1`'s\n * failure (`fieldErrorId(prefix, '…@string:r1')`).\n */\nexport function fieldErrorId(idPrefix: string, bindingKey: string): string {\n return `${fieldDomId(idPrefix, bindingKey)}@error`;\n}\n\n/**\n * The identifier a binding renders its description text into, beside `fieldErrorId`.\n *\n * A control that shows both a description and a failure names both ids in `aria-describedby`,\n * in that order, or swaps to the failure alone.\n */\nexport function fieldDescriptionId(idPrefix: string, bindingKey: string): string {\n return `${fieldDomId(idPrefix, bindingKey)}@description`;\n}\n\n/** What a control puts on the element it renders, so assistive technology agrees with the UI. */\nexport interface FieldA11y {\n readonly required: boolean;\n /** `showError`, not `invalid`: a rule that decided before the host's display rule said so is silent. */\n readonly invalid: boolean;\n /** Whether the control is disabled; a `read_only` control is not (it is `readOnly`). */\n readonly disabled: boolean;\n /** Whether the control is read-only and must stay focusable and copyable. */\n readonly readOnly: boolean;\n /**\n * The element id the control uses, `fieldDomId(prefix, bindingKey)`.\n *\n * Use it for `id` and for the `htmlFor` of the label. It is not `bindingKey`: that is the\n * session's cache key, it carries no session identity (two providers over one artifact agree on\n * it) and a natural row key may carry spaces, which an HTML id cannot.\n */\n readonly controlId: string;\n /**\n * The id the failure text renders into, `fieldErrorId(prefix, bindingKey)`.\n *\n * The binding states the relation; the host paints the element. A control sets\n * `aria-describedby={showError ? a11y.errorId : a11y.descriptionId}` and renders\n * `<p id={a11y.errorId}>`, so the relation resolves without a host-wide id convention and two\n * rows of one array cannot collide.\n */\n readonly errorId: string;\n /**\n * The id the description text renders into, `fieldDescriptionId(prefix, bindingKey)`.\n *\n * Present exactly when the binding declares a `descriptionKey`. Absent otherwise, so a control\n * that puts it in `aria-describedby` never points at an element nothing renders; a host that\n * paints its own help text must supply its own id.\n */\n readonly descriptionId?: string;\n /**\n * Whether an asynchronous answer this control is waiting for is in flight.\n *\n * It is true only while a submission that will settle a server-tier check on this binding is\n * running. At rest a `deferred` check is a fact the device has not decided — reported as a\n * `deferred` entry in `errors` — not a loading state, so `aria-busy` must not advertise a\n * control as permanently busy. It is not `isSubmitting`, which belongs to the form and is read\n * from `useFormState()`.\n */\n readonly busy: boolean;\n}\n\n/**\n * The evaluated state of one binding: everything a control renders, and nothing else.\n *\n * It is a projection of the engine's frozen per-binding state plus the session facts the engine\n * does not own — whether the control was touched, whether the value moved from its baseline,\n * and the host's display rules — so a component never holds a value tree of its own.\n *\n * Painting guide: one affordance reads one answer. `mayWrite` is the only fillability answer;\n * when it is false, a write reaches `setValue` and is refused, so an affordance without a\n * read-only state paints the value as static text instead of an interactive control. `disabled`\n * states the element attribute and never whether a write would be accepted. `readOnly` states\n * that the resolved access is exactly `read_only`, in which case a text input stays focusable\n * and copyable while every other affordance paints static text.\n *\n * | `mayWrite` | `readOnly` | `disabled` | paint |\n * | true | false | false | the interactive control |\n * | false | true | false | read-only text input, or static text where the |\n * | | | | affordance has no read-only state |\n * | false | false | true | static text (`text`), or a disabled control |\n * | false | false | false | static text (`text`); the binding is masked, hidden, |\n * | | | | computed, or a `signature_ref` |\n */\nexport interface FieldProps {\n readonly fieldId: string;\n /** The row this binding names, absent for a field binding. */\n readonly rowKey?: string | number;\n /** `fieldId`, or `fieldId@<wire-typed row key>`; the key every cache and summary uses. */\n readonly bindingKey: string;\n /** The artifact's declaration, which a formatting layer reads. */\n readonly descriptor: CompiledField;\n /** The submitted value, or `undefined` when absent or withheld by access. */\n readonly value: WireValue | undefined;\n /**\n * The text this binding shows, whatever its domain.\n *\n * `value` is the wire union — a money amount is an object, an authored empty value is `null` —\n * so a control that interpolated it rendered `[object Object]` or the word `null`. This is the\n * one display answer, the same text `renderFieldText(field)` returns: `maskedText` beside a\n * withheld value, a writer's value for a computed field, a money amount in its declared scale,\n * and `''` for absent. A control that *edits* a value reads `useFieldValue` for the tagged\n * domain; this is for the label, the read-only control and the summary.\n */\n readonly text: string;\n /**\n * The value the device was delivered when the session was opened, or re-baselined by a reset.\n *\n * It is the baseline as this device may *read* it, so it is `undefined` for a value the access\n * answer withholds — delivering the record's stored value here would disclose it. `dirty` is\n * measured against the record's baseline rather than this projection, so a value that becomes\n * readable is not an edit.\n */\n readonly initialValue: WireValue | undefined;\n readonly access: FieldAccess;\n /**\n * Whether the binding is on the screen: neither it nor a container above it is `hidden` — a\n * member is delivered only through its container — and no `visible` rule failed.\n */\n readonly visible: boolean;\n /** Whether a control may accept user input: access permits a write and `enabled` rules pass. */\n readonly enabled: boolean;\n /**\n * Whether an interactive affordance may accept a user write at all.\n *\n * It is the runtime's one fillability answer (`fillable`): the write predicate — the access\n * permits a user write and every `enabled` rule passes — plus the facts the engine refuses\n * before it (no writer owns the value, the field is not a `signature_ref`) and visibility. A\n * checkbox, a `<select>`, a `Pressable` or any other affordance with no read-only state gates\n * on this: when it is false,\n * paint the value as static text (`text`) rather than an interactive control, or the write\n * reaches `setValue` and throws `WriteRefusedError`. A text input is the one exception only\n * when the answer is false for `read_only` access: it may stay focusable and copyable with\n * `readOnly`. Every other false answer — masked, computed, a `signature_ref`, a failed\n * `enabled` rule or a hidden binding — paints static or disabled.\n *\n * Not `enabled`: `enabled` states the access and `enabled` rules alone, so a writer-owned value\n * and a `signature_ref` are `enabled` but never `mayWrite`.\n */\n readonly mayWrite: boolean;\n /**\n * Whether a host sets `disabled` on the control.\n *\n * Not `!enabled`: a `read_only` binding is `!enabled` but stays focusable and copyable, so it\n * is announced by `readOnly`, not disabled. A field a failed `enabled` rule or an access that\n * withholds writing (other than `read_only`) stops is disabled. Neither attribute says whether\n * a write would be accepted — `mayWrite` is that answer.\n */\n readonly disabled: boolean;\n /** Whether the resolved access is exactly `read_only` (`[ACCESS-1.2.1]`). */\n readonly readOnly: boolean;\n readonly required: boolean;\n /**\n * How many entries an array binding holds, when the device can count them, `MODEL-2.1.17`.\n *\n * Present exactly on an array binding whose declaration states `minItems` or `maxItems` and\n * whose value this device may read or whose writer decided. `undefined` is an answer too: a\n * withheld list states no length, and a host must not infer one from the absence of this\n * member.\n */\n readonly rowCount?: number;\n /**\n * The declared entry-count refusal, if the array is outside its range.\n *\n * The host writes the sentence: `{count} of at least {limit}` for `belowMin`, or\n * `{count} of at most {limit}` for `aboveMax`. It is also in `errors` as\n * `kind: \"cardinality\"`, so a summary that reads one error list sees the same refusal.\n */\n readonly countViolation?: {\n readonly kind: 'belowMin' | 'aboveMax';\n readonly count: number;\n readonly limit: number;\n };\n readonly computation: FieldComputation;\n /**\n * The option codes this record may not choose now, `ENGINE-7.1.7`.\n *\n * One answer per code, whether the declaration stated the condition or a host page marked the\n * item `available: false`; the two are merged at the runtime and never re-decided here. A\n * control paints a code it finds in this list as selectable-but-unavailable rather than as an\n * offered choice, and a binding the record holds stays in the value (`RULES-7.1.6` never\n * clears it). Absent when every offered code is available, so a control reads presence rather\n * than an empty list to decide whether availability applies at all.\n *\n * The reason travels with the answer: `messageKey` and `params` when the declaration or the\n * page stated words, and `cause` on an undetermined code, which the host writes its own\n * sentence for.\n */\n readonly unavailableOptions?: readonly UnavailableOption[];\n /** Every `validate` message targeting this binding, in artifact order. */\n readonly messages: readonly FieldMessage[];\n /**\n * Every reason this binding cannot be submitted as it stands, plus the last entry the session\n * refused. Only a blocking member stops a submission; a `row-key` entry states an attempted\n * write the record would not take.\n *\n * This is the engine's fact list: it states every reason even when the host's reveal policy has\n * not painted it yet. Read `visibleErrors` for the reasons to show now.\n */\n readonly errors: readonly FieldError[];\n /**\n * The reasons a control paints now, in artifact order.\n *\n * It is `errors` filtered by the session's reveal policy: a failure on a binding the user has\n * not visited waits under `showErrors: \"touched\"`, a rule whose operands the user has not\n * supplied waits even on a visited binding, and a failure already painted stays painted until\n * it is corrected. A warning, a refused entry and the reasons a submit has just revealed are\n * included. `readOnlyDiagnostics` remains the separate display list for a read-only binding.\n */\n readonly visibleErrors: readonly FieldError[];\n /** The subset of `errors` a `read_only` or `masked` binding produced, for display only. */\n readonly readOnlyDiagnostics: readonly FieldError[];\n /** Whether any error blocks a submission on this device. */\n readonly invalid: boolean;\n /**\n * Whether the control shows a failure: any blocking member of `visibleErrors`, or a refused\n * entry.\n *\n * A refused write is an answer to something the user just did, so it is shown immediately and\n * is not deferred by the reveal policy; a warning is in `visibleErrors` without making the\n * control invalid.\n */\n readonly showError: boolean;\n /**\n * The failures a control renders now, in artifact order.\n *\n * It is `visibleErrors` when `showError` is true, and the painted warnings alone otherwise: a\n * warning is visible without making the control invalid, while a blocking failure and a\n * refused entry wait for `showError`. Read this in a control; read `errors` for a summary\n * and `visibleErrors` for custom reveal chrome. Always present on props `useField` returns;\n * see `PublishedFieldProps`.\n */\n readonly announce?: readonly FieldError[];\n /**\n * Whether the user has visited this binding: it lost focus, or its value changed deliberately.\n *\n * A programmatic write the session accepts is a deliberate change too. `dirty` answers a\n * different question — whether the record moved from the one the session opened with — so a\n * host can be touched without being dirty and dirty without being touched (`reset`).\n */\n readonly touched: boolean;\n /**\n * Whether the *record* moved from the session's baseline for this binding.\n *\n * The comparison is against what the record held, never against what access delivered: a\n * `masked` value the host widens, a `hidden` value, or a server-redacted one was always there,\n * so an access change is not an edit. A computed value is not an edit either — a writer owns\n * it. A value this device may no longer read reports `false`, because it cannot compare what\n * it may not see and the submission projection would not carry it.\n */\n readonly dirty: boolean;\n /**\n * The static text a control renders in place of an input, present exactly when the resolved\n * access is `masked`.\n *\n * The record holds a value this device may not read, so there is nothing for a control to\n * bind: render this text, never an input, a `<select>` or a buffered control. It is the host's\n * `maskedDisplay` for this field — the text `text` already carries — or `''` when the host\n * supplied none; it is never derived from the value or its length. A masked binding is never a\n * buffer: `useBufferedInput` has no value to start from, and every keystroke would be refused.\n */\n readonly maskedText: string | undefined;\n /**\n * Whether this binding's value state is withheld from the device.\n *\n * Derived where `maskedText` is, from the value state the engine publishes: true exactly when\n * that state is `withheld`, so a host never infers it from `value === undefined` (which also\n * states an absent value). A masked or stored `write_only` binding is never an edit target:\n * render `maskedText` or `text`, never an input. Redaction is different when `mayWrite` permits\n * a replacement, so read that answer rather than treating every withheld binding as static.\n */\n readonly withheld: boolean;\n /**\n * Why the record withholds the value, present exactly when it does and absent otherwise, so a\n * host reads presence rather than `undefined`.\n */\n readonly withheldReason?: WithheldReason;\n readonly a11y: FieldA11y;\n readonly hints: InputHints;\n /**\n * An opaque token that changes exactly when this binding's published props are replaced, so\n * a host may use it as a memo key. It spells no value.\n */\n readonly signature: string;\n /**\n * Writes one value for this binding. The identity is owned by the store, so it is stable\n * across renders and safe to pass to a memoised child or an effect dependency. It refuses by\n * throwing the runtime's structured write error.\n */\n readonly setValue: (value: WireValue) => void;\n /** `setValue`, under the handler name a control binds to `onChange`. */\n readonly onChange: (value: WireValue) => void;\n /**\n * Writes one value for this binding without throwing for an expected refusal.\n *\n * It judges the write the way `setValue` does (the same guard, the same declaration parse,\n * the same engine verdict) and returns the engine outcome instead of throwing it: a refused\n * outcome carries the code the throwing door raises as `WriteRefusedError`, and a committed\n * one carries the patches the write applied. A reference no binding addresses (an undeclared\n * id, a row the record does not hold) still throws, because that is a programmer error rather\n * than an answer to user intent. The identity is owned by the store, so it is stable across\n * renders. Prefer this in an event handler; keep `setValue` where a throw already unwinds to\n * a boundary the host paints. Always present on props `useField` returns; see\n * `PublishedFieldProps`.\n */\n readonly trySetValue?: (value: WireValue) => EngineOutcome;\n /** `trySetValue` for the authored empty value, `null`. */\n readonly trySetNull?: () => EngineOutcome;\n /** `trySetValue` for removing the value from the record. */\n readonly tryRemoveValue?: () => EngineOutcome;\n /** Writes the authored empty value, `null`. */\n readonly setNull: () => void;\n /** Removes the value from the record. */\n readonly removeValue: () => void;\n /**\n * Records that a control for this binding lost focus. A no-op on a binding that is not\n * writable or not visible, because a control the user could not use was never visited.\n */\n readonly onBlur: () => void;\n}\n\n/**\n * The props a control actually renders: `FieldProps` with every derived member present.\n *\n * The snapshot layer states the members it owns and leaves these absent; the store extends each\n * snapshot once per published state, so a props object read through `useField` always carries\n * them. `withheldReason` is the one member presence still decides: it is present exactly when\n * the record withholds the value, and absent otherwise. A host holding a bare `FieldProps`\n * narrows with a check rather than a cast.\n */\nexport type PublishedFieldProps = Omit<\n FieldProps,\n 'announce' | 'trySetValue' | 'trySetNull' | 'tryRemoveValue'\n> & {\n readonly announce: readonly FieldError[];\n readonly trySetValue: (value: WireValue) => EngineOutcome;\n readonly trySetNull: () => EngineOutcome;\n readonly tryRemoveValue: () => EngineOutcome;\n};\n"]}
@@ -0,0 +1,31 @@
1
+ import type { Context } from 'react';
2
+ import type { FormCandidate, FormStore } from './form-store.js';
3
+ import type { WizardCursor } from './store/wizard-cursor.js';
4
+ /**
5
+ * Whether this build reports development diagnostics.
6
+ *
7
+ * Production is the builds that state `NODE_ENV=production`; every other host (a dev server, a
8
+ * test run, a device bundle without the flag) reports. Guards read this once per render, so a
9
+ * development check costs nothing once the flag is set.
10
+ */
11
+ export declare function isDevelopmentBuild(): boolean;
12
+ /**
13
+ * The form session the nearest provider owns: the store, the candidate the current render
14
+ * derived from it, and the session's one wizard cursor.
15
+ *
16
+ * `candidate` is what a render reads, so the access and values a control shows are the ones
17
+ * its inputs produce even before the commit adopts them. It stops being the current view
18
+ * once a write moves the session on; `useField` then reads the committed store. `null` for
19
+ * the session itself means there is no provider, which `useField` refuses rather than
20
+ * inventing a default field state.
21
+ *
22
+ * The cursor lives here because navigation is session state: every `useWizard` caller under
23
+ * one provider must read the same step and the same visited history.
24
+ */
25
+ export interface FormSession {
26
+ readonly store: FormStore;
27
+ readonly candidate: FormCandidate;
28
+ readonly wizard: WizardCursor;
29
+ }
30
+ export declare const FormContext: Context<FormSession | null>;
31
+ //# sourceMappingURL=form-context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"form-context.d.ts","sourceRoot":"","sources":["../src/form-context.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AACrC,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAChE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAI7D;;;;;;GAMG;AACH,wBAAgB,kBAAkB,IAAI,OAAO,CAE5C;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC;IAC1B,QAAQ,CAAC,SAAS,EAAE,aAAa,CAAC;IAClC,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;CAC/B;AAED,eAAO,MAAM,WAAW,EAAE,OAAO,CAAC,WAAW,GAAG,IAAI,CAA2C,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { createContext } from 'react';
2
+ /**
3
+ * Whether this build reports development diagnostics.
4
+ *
5
+ * Production is the builds that state `NODE_ENV=production`; every other host (a dev server, a
6
+ * test run, a device bundle without the flag) reports. Guards read this once per render, so a
7
+ * development check costs nothing once the flag is set.
8
+ */
9
+ export function isDevelopmentBuild() {
10
+ return typeof process === 'undefined' || process.env?.NODE_ENV !== 'production';
11
+ }
12
+ export const FormContext = createContext(null);
13
+ //# sourceMappingURL=form-context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"form-context.js","sourceRoot":"","sources":["../src/form-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAOtC;;;;;;GAMG;AACH,MAAM,UAAU,kBAAkB;IAChC,OAAO,OAAO,OAAO,KAAK,WAAW,IAAI,OAAO,CAAC,GAAG,EAAE,QAAQ,KAAK,YAAY,CAAC;AAClF,CAAC;AAqBD,MAAM,CAAC,MAAM,WAAW,GAAgC,aAAa,CAAqB,IAAI,CAAC,CAAC","sourcesContent":["import { createContext } from 'react';\nimport type { Context } from 'react';\nimport type { FormCandidate, FormStore } from './form-store.js';\nimport type { WizardCursor } from './store/wizard-cursor.js';\n\ndeclare const process: { readonly env?: { readonly NODE_ENV?: string } } | undefined;\n\n/**\n * Whether this build reports development diagnostics.\n *\n * Production is the builds that state `NODE_ENV=production`; every other host (a dev server, a\n * test run, a device bundle without the flag) reports. Guards read this once per render, so a\n * development check costs nothing once the flag is set.\n */\nexport function isDevelopmentBuild(): boolean {\n return typeof process === 'undefined' || process.env?.NODE_ENV !== 'production';\n}\n\n/**\n * The form session the nearest provider owns: the store, the candidate the current render\n * derived from it, and the session's one wizard cursor.\n *\n * `candidate` is what a render reads, so the access and values a control shows are the ones\n * its inputs produce even before the commit adopts them. It stops being the current view\n * once a write moves the session on; `useField` then reads the committed store. `null` for\n * the session itself means there is no provider, which `useField` refuses rather than\n * inventing a default field state.\n *\n * The cursor lives here because navigation is session state: every `useWizard` caller under\n * one provider must read the same step and the same visited history.\n */\nexport interface FormSession {\n readonly store: FormStore;\n readonly candidate: FormCandidate;\n readonly wizard: WizardCursor;\n}\n\nexport const FormContext: Context<FormSession | null> = createContext<FormSession | null>(null);\n"]}