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

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,154 @@
1
+ import type { OPTION_NO_LONGER_ELIGIBLE } from '@azx-pbc/axiom-runtime';
2
+ import type { FieldAccess, ScreenOutcome, ScreenReason, Severity, WireValue } from '@azx-pbc/axiom-runtime';
3
+ /** A failure a `validate` rule reported, or the same rule left to a server that has not run. */
4
+ export interface RuleFieldError {
5
+ readonly kind: 'validate' | 'deferred';
6
+ /** Whether this failure stops a submission on this device. */
7
+ readonly blocking: boolean;
8
+ readonly severity: Severity;
9
+ readonly status: 'FAIL' | 'UNKNOWN' | 'DEFERRED';
10
+ readonly messageKey: string;
11
+ readonly ruleId: string;
12
+ readonly params?: Readonly<Record<string, WireValue>>;
13
+ }
14
+ /**
15
+ * A required binding the record does not hold a value for.
16
+ *
17
+ * Only the runtime's decided `missing` is this error. `undetermined` — a server-tier answer
18
+ * this device cannot settle, or a value it withholds on the server's behalf (`redacted`) — is
19
+ * not a failure the user can fix, so it is reported by the form's `ready`/`hasDeferredChecks`
20
+ * and never as a blocking field error.
21
+ *
22
+ * The identity is the same one the runtime's `required` blocker names: a control can show
23
+ * which binding, and a summary can link the row's own control, without a second key list.
24
+ */
25
+ export interface RequiredFieldError {
26
+ readonly kind: 'required';
27
+ readonly blocking: true;
28
+ readonly status: 'FAIL';
29
+ readonly missing: 'missing';
30
+ readonly fieldId: string;
31
+ readonly rowKey?: string | number;
32
+ /**
33
+ * The row's own name, when its key is one the reader can see.
34
+ *
35
+ * A natural or value key is authored text; a key the host minted addresses the row and names
36
+ * nothing, so it is omitted rather than printed into a sentence.
37
+ */
38
+ readonly rowName?: string;
39
+ /**
40
+ * The sentence the artifact's `required` rule declared, when it declared one. Absent by
41
+ * design otherwise: the host writes the sentence for a value the artifact names no message.
42
+ */
43
+ readonly messageKey?: string;
44
+ readonly params?: Readonly<Record<string, WireValue>>;
45
+ }
46
+ /**
47
+ * An array whose entry count is outside its declared `minItems`/`maxItems`, `MODEL-2.1.17`.
48
+ *
49
+ * It is a decided blocking fact with no artifact message: the host writes the sentence, naming
50
+ * the array and the count in the host's own words. `count` and `limit` are stated so the host
51
+ * can interpolate both without re-reading the record.
52
+ */
53
+ export interface CardinalityFieldError {
54
+ readonly kind: 'cardinality';
55
+ readonly blocking: true;
56
+ readonly status: 'FAIL';
57
+ readonly bound: 'minItems' | 'maxItems';
58
+ readonly count: number;
59
+ readonly limit: number;
60
+ }
61
+ /**
62
+ * A value the record holds that the field's option domain refuses.
63
+ *
64
+ * The code is the runtime's vocabulary for it, `OPTION_NO_LONGER_ELIGIBLE` ([DATA-5.1.3]): the
65
+ * selected value is still in the record and the field states which one the domain refuses, so a
66
+ * host can name it, clear it, or leave it for the user to change. It covers a declared domain
67
+ * and a loaded one alike — the question is the same: does the domain offer this value?
68
+ */
69
+ export interface InvalidValueFieldError {
70
+ readonly kind: 'invalid-value';
71
+ readonly code: typeof OPTION_NO_LONGER_ELIGIBLE;
72
+ readonly blocking: true;
73
+ readonly status: 'FAIL';
74
+ }
75
+ /**
76
+ * The control shows no value because the resolved access withholds it.
77
+ *
78
+ * It states a `masked`, `hidden` or `write_only` value — the withholdings the access answer
79
+ * decides. A `redacted` value is withheld by the server, not by access, and is not this error
80
+ * even on a binding whose access withholds a write: the user still cannot read the value, but
81
+ * the reason is the server's redaction and the host needs no "not editable" claim.
82
+ *
83
+ * This is UI consistency, never enforcement (`[ACCESS-7.1.1]`): it never blocks a submission,
84
+ * and the server rejects a write to a withheld field independently.
85
+ */
86
+ export interface AccessFieldError {
87
+ readonly kind: 'access';
88
+ readonly blocking: false;
89
+ readonly access: FieldAccess;
90
+ }
91
+ /**
92
+ * One item of a gate that decided this submission may not proceed.
93
+ *
94
+ * A gate item appears in the form-level `blockers` and in the `blockers` argument of
95
+ * `onInvalid`, never in a binding `errors` list: it names no binding a control could paint.
96
+ */
97
+ export interface GateFieldError {
98
+ readonly kind: 'gate';
99
+ readonly blocking: true;
100
+ readonly messageKey: string;
101
+ readonly gateId: string;
102
+ readonly itemId: string;
103
+ readonly params?: Readonly<Record<string, WireValue>>;
104
+ }
105
+ /**
106
+ * A block-severity screen that did not pass.
107
+ *
108
+ * The screen names the sentence its rule declared and every reason the report states, so a host
109
+ * renders the author's words instead of inventing a form-level apology. `messageKey` is the
110
+ * declared key, or the screen's own rule id when the artifact declared none: a host translates
111
+ * one member either way, and a missing catalogue entry then shows the rule id rather than an
112
+ * empty sentence. A reason carries its own key and params (`RULES-2.1.3`), authored and engine
113
+ * causes alike, so each is translated on its own rather than folded into the screen's sentence.
114
+ */
115
+ export interface ScreenFieldError {
116
+ readonly kind: 'screen';
117
+ readonly blocking: true;
118
+ readonly screenId: string;
119
+ /** The declared sentence, or `screenId` when the artifact declared none. */
120
+ readonly messageKey: string;
121
+ readonly outcome: ScreenOutcome;
122
+ readonly reasons: readonly ScreenReason[];
123
+ }
124
+ /**
125
+ * The last value a control tried to write that the session refused because it would give two
126
+ * rows one identity.
127
+ *
128
+ * It is not blocking: the record still holds the value the binding showed, and that record is
129
+ * valid, so a submission is unaffected. It is the *entry* that failed, which is why the error
130
+ * carries the runtime's code and the key the entry would have shared rather than a
131
+ * `messageKey` the artifact never declared. A control announces it beside itself; the next
132
+ * successful write to the binding, a structural change to its array, or a reset clears it.
133
+ */
134
+ export interface RowKeyFieldError {
135
+ readonly kind: 'row-key';
136
+ readonly blocking: false;
137
+ readonly status: 'FAIL';
138
+ readonly code: 'ROW_KEY_DUPLICATE';
139
+ /** The sibling key the refused entry would have duplicated, kept as identity. */
140
+ readonly rowKey: string | number;
141
+ /** The row's own name when its key is authored text; omitted when the host minted it. */
142
+ readonly rowName?: string;
143
+ }
144
+ /**
145
+ * One reason a binding, or the form, cannot be submitted as it stands.
146
+ *
147
+ * The union is tagged by `kind` so a host can exhaust it: rule failures carry the artifact's
148
+ * `messageKey`, a missing required value carries the binding it names (and the artifact's
149
+ * sentence only when a `required` rule declared one), while the reasons the artifact states no
150
+ * message for carry the fact instead — inventing a key for them would create an i18n contract
151
+ * no artifact declares.
152
+ */
153
+ export type FieldError = RuleFieldError | RequiredFieldError | CardinalityFieldError | InvalidValueFieldError | AccessFieldError | GateFieldError | ScreenFieldError | RowKeyFieldError;
154
+ //# sourceMappingURL=field-error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"field-error.d.ts","sourceRoot":"","sources":["../src/field-error.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AACxE,OAAO,KAAK,EACV,WAAW,EACX,aAAa,EACb,YAAY,EACZ,QAAQ,EACR,SAAS,EACV,MAAM,wBAAwB,CAAC;AAEhC,gGAAgG;AAChG,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,IAAI,EAAE,UAAU,GAAG,UAAU,CAAC;IACvC,8DAA8D;IAC9D,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,UAAU,CAAC;IACjD,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,CAAC,EAAE,QAAQ,C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AAM,MAAM,UAAU,GAClB,cAAc,GACd,kBAAkB,GAClB,qBAAqB,GACrB,sBAAsB,GACtB,gBAAgB,GAChB,cAAc,GACd,gBAAgB,GAChB,gBAAgB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=field-error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"field-error.js","sourceRoot":"","sources":["../src/field-error.ts"],"names":[],"mappings":"","sourcesContent":["import type { OPTION_NO_LONGER_ELIGIBLE } from '@azx-pbc/axiom-runtime';\nimport type {\n FieldAccess,\n ScreenOutcome,\n ScreenReason,\n Severity,\n WireValue,\n} from '@azx-pbc/axiom-runtime';\n\n/** A failure a `validate` rule reported, or the same rule left to a server that has not run. */\nexport interface RuleFieldError {\n readonly kind: 'validate' | 'deferred';\n /** Whether this failure stops a submission on this device. */\n readonly blocking: boolean;\n readonly severity: Severity;\n readonly status: 'FAIL' | 'UNKNOWN' | 'DEFERRED';\n readonly messageKey: string;\n readonly ruleId: string;\n readonly params?: Readonly<Record<string, WireValue>>;\n}\n\n/**\n * A required binding the record does not hold a value for.\n *\n * Only the runtime's decided `missing` is this error. `undetermined` — a server-tier answer\n * this device cannot settle, or a value it withholds on the server's behalf (`redacted`) — is\n * not a failure the user can fix, so it is reported by the form's `ready`/`hasDeferredChecks`\n * and never as a blocking field error.\n *\n * The identity is the same one the runtime's `required` blocker names: a control can show\n * which binding, and a summary can link the row's own control, without a second key list.\n */\nexport interface RequiredFieldError {\n readonly kind: 'required';\n readonly blocking: true;\n readonly status: 'FAIL';\n readonly missing: 'missing';\n readonly fieldId: string;\n readonly rowKey?: string | number;\n /**\n * The row's own name, when its key is one the reader can see.\n *\n * A natural or value key is authored text; a key the host minted addresses the row and names\n * nothing, so it is omitted rather than printed into a sentence.\n */\n readonly rowName?: string;\n /**\n * The sentence the artifact's `required` rule declared, when it declared one. Absent by\n * design otherwise: the host writes the sentence for a value the artifact names no message.\n */\n readonly messageKey?: string;\n readonly params?: Readonly<Record<string, WireValue>>;\n}\n\n/**\n * An array whose entry count is outside its declared `minItems`/`maxItems`, `MODEL-2.1.17`.\n *\n * It is a decided blocking fact with no artifact message: the host writes the sentence, naming\n * the array and the count in the host's own words. `count` and `limit` are stated so the host\n * can interpolate both without re-reading the record.\n */\nexport interface CardinalityFieldError {\n readonly kind: 'cardinality';\n readonly blocking: true;\n readonly status: 'FAIL';\n readonly bound: 'minItems' | 'maxItems';\n readonly count: number;\n readonly limit: number;\n}\n\n/**\n * A value the record holds that the field's option domain refuses.\n *\n * The code is the runtime's vocabulary for it, `OPTION_NO_LONGER_ELIGIBLE` ([DATA-5.1.3]): the\n * selected value is still in the record and the field states which one the domain refuses, so a\n * host can name it, clear it, or leave it for the user to change. It covers a declared domain\n * and a loaded one alike — the question is the same: does the domain offer this value?\n */\nexport interface InvalidValueFieldError {\n readonly kind: 'invalid-value';\n readonly code: typeof OPTION_NO_LONGER_ELIGIBLE;\n readonly blocking: true;\n readonly status: 'FAIL';\n}\n\n/**\n * The control shows no value because the resolved access withholds it.\n *\n * It states a `masked`, `hidden` or `write_only` value — the withholdings the access answer\n * decides. A `redacted` value is withheld by the server, not by access, and is not this error\n * even on a binding whose access withholds a write: the user still cannot read the value, but\n * the reason is the server's redaction and the host needs no \"not editable\" claim.\n *\n * This is UI consistency, never enforcement (`[ACCESS-7.1.1]`): it never blocks a submission,\n * and the server rejects a write to a withheld field independently.\n */\nexport interface AccessFieldError {\n readonly kind: 'access';\n readonly blocking: false;\n readonly access: FieldAccess;\n}\n\n/**\n * One item of a gate that decided this submission may not proceed.\n *\n * A gate item appears in the form-level `blockers` and in the `blockers` argument of\n * `onInvalid`, never in a binding `errors` list: it names no binding a control could paint.\n */\nexport interface GateFieldError {\n readonly kind: 'gate';\n readonly blocking: true;\n readonly messageKey: string;\n readonly gateId: string;\n readonly itemId: string;\n readonly params?: Readonly<Record<string, WireValue>>;\n}\n\n/**\n * A block-severity screen that did not pass.\n *\n * The screen names the sentence its rule declared and every reason the report states, so a host\n * renders the author's words instead of inventing a form-level apology. `messageKey` is the\n * declared key, or the screen's own rule id when the artifact declared none: a host translates\n * one member either way, and a missing catalogue entry then shows the rule id rather than an\n * empty sentence. A reason carries its own key and params (`RULES-2.1.3`), authored and engine\n * causes alike, so each is translated on its own rather than folded into the screen's sentence.\n */\nexport interface ScreenFieldError {\n readonly kind: 'screen';\n readonly blocking: true;\n readonly screenId: string;\n /** The declared sentence, or `screenId` when the artifact declared none. */\n readonly messageKey: string;\n readonly outcome: ScreenOutcome;\n readonly reasons: readonly ScreenReason[];\n}\n\n/**\n * The last value a control tried to write that the session refused because it would give two\n * rows one identity.\n *\n * It is not blocking: the record still holds the value the binding showed, and that record is\n * valid, so a submission is unaffected. It is the *entry* that failed, which is why the error\n * carries the runtime's code and the key the entry would have shared rather than a\n * `messageKey` the artifact never declared. A control announces it beside itself; the next\n * successful write to the binding, a structural change to its array, or a reset clears it.\n */\nexport interface RowKeyFieldError {\n readonly kind: 'row-key';\n readonly blocking: false;\n readonly status: 'FAIL';\n readonly code: 'ROW_KEY_DUPLICATE';\n /** The sibling key the refused entry would have duplicated, kept as identity. */\n readonly rowKey: string | number;\n /** The row's own name when its key is authored text; omitted when the host minted it. */\n readonly rowName?: string;\n}\n\n/**\n * One reason a binding, or the form, cannot be submitted as it stands.\n *\n * The union is tagged by `kind` so a host can exhaust it: rule failures carry the artifact's\n * `messageKey`, a missing required value carries the binding it names (and the artifact's\n * sentence only when a `required` rule declared one), while the reasons the artifact states no\n * message for carry the fact instead — inventing a key for them would create an i18n contract\n * no artifact declares.\n */\nexport type FieldError =\n | RuleFieldError\n | RequiredFieldError\n | CardinalityFieldError\n | InvalidValueFieldError\n | AccessFieldError\n | GateFieldError\n | ScreenFieldError\n | RowKeyFieldError;\n"]}
@@ -0,0 +1,362 @@
1
+ import type { CompiledField, EngineOutcome, FieldAccess, FieldMessage, UnavailableOption, WireValue, WithheldReason } from '@azx-pbc/axiom-runtime';
2
+ import type { FieldComputation } from '@azx-pbc/axiom-runtime';
3
+ import type { FieldError } from './field-error.js';
4
+ import type { InputHints } from './hints.js';
5
+ export type { FieldComputation, FieldMessage } from '@azx-pbc/axiom-runtime';
6
+ /**
7
+ * The element id one binding's control uses, under one provider's prefix.
8
+ *
9
+ * Two facts make up the id, and both are needed:
10
+ *
11
+ * - The prefix identifies the form session. `bindingKey` alone is the same string in every
12
+ * provider over one artifact, so two forms on a page emitted duplicate `id`, `htmlFor` and
13
+ * `aria-describedby` values and the second form's label and error text pointed at the first
14
+ * form's control. `FormProvider` supplies one prefix per mount (`useId()` by default, or the
15
+ * host's `idPrefix`), so the ids differ by session and every relation resolves inside its own.
16
+ * - The key is percent-encoded because a natural row key is user text: a row called
17
+ * `kitchen island` keys as `f_label@string:kitchen island`, and an id with a space breaks every
18
+ * `htmlFor`/`aria-describedby` that names it. The encoding is injective, so two bindings never
19
+ * share an id. `%`, `@` and `.` are not CSS identifier characters, so a `#id` selector needs
20
+ * `CSS.escape`; `htmlFor`, `aria-describedby` and `getElementById` need no escaping.
21
+ *
22
+ * The prefix is encoded too, so a host's readable `idPrefix` cannot reintroduce an invalid id.
23
+ */
24
+ export declare function fieldDomId(idPrefix: string, bindingKey: string): string;
25
+ /**
26
+ * The identifier a binding renders its failure text into.
27
+ *
28
+ * Derived from `bindingKey`, so a field and each of its rows have distinct ids without the host
29
+ * inventing a convention, and stable across a write because the binding is. A control names it in
30
+ * `aria-describedby` (or `aria-errormessage`) and renders the text it reveals under this id.
31
+ *
32
+ * `@` separates the role from the key because it is always `%40` inside an encoded component, and
33
+ * a row key is user text: a row called `r1.error` must not own the id that carries row `r1`'s
34
+ * failure (`fieldErrorId(prefix, '…@string:r1')`).
35
+ */
36
+ export declare function fieldErrorId(idPrefix: string, bindingKey: string): string;
37
+ /**
38
+ * The identifier a binding renders its description text into, beside `fieldErrorId`.
39
+ *
40
+ * A control that shows both a description and a failure names both ids in `aria-describedby`,
41
+ * in that order, or swaps to the failure alone.
42
+ */
43
+ export declare function fieldDescriptionId(idPrefix: string, bindingKey: string): string;
44
+ /** What a control puts on the element it renders, so assistive technology agrees with the UI. */
45
+ export interface FieldA11y {
46
+ readonly required: boolean;
47
+ /** `showError`, not `invalid`: a rule that decided before the host's display rule said so is silent. */
48
+ readonly invalid: boolean;
49
+ /** Whether the control is disabled; a `read_only` control is not (it is `readOnly`). */
50
+ readonly disabled: boolean;
51
+ /** Whether the control is read-only and must stay focusable and copyable. */
52
+ readonly readOnly: boolean;
53
+ /**
54
+ * The element id the control uses, `fieldDomId(prefix, bindingKey)`.
55
+ *
56
+ * Use it for `id` and for the `htmlFor` of the label. It is not `bindingKey`: that is the
57
+ * session's cache key, it carries no session identity (two providers over one artifact agree on
58
+ * it) and a natural row key may carry spaces, which an HTML id cannot.
59
+ */
60
+ readonly controlId: string;
61
+ /**
62
+ * The id the failure text renders into, `fieldErrorId(prefix, bindingKey)`.
63
+ *
64
+ * The binding states the relation; the host paints the element. A control sets
65
+ * `aria-describedby={showError ? a11y.errorId : a11y.descriptionId}` and renders
66
+ * `<p id={a11y.errorId}>`, so the relation resolves without a host-wide id convention and two
67
+ * rows of one array cannot collide.
68
+ */
69
+ readonly errorId: string;
70
+ /**
71
+ * The id the description text renders into, `fieldDescriptionId(prefix, bindingKey)`.
72
+ *
73
+ * Present exactly when the binding declares a `descriptionKey`. Absent otherwise, so a control
74
+ * that puts it in `aria-describedby` never points at an element nothing renders; a host that
75
+ * paints its own help text must supply its own id.
76
+ */
77
+ readonly descriptionId?: string;
78
+ /**
79
+ * Whether an asynchronous answer this control is waiting for is in flight.
80
+ *
81
+ * It is true only while a submission that will settle a server-tier check on this binding is
82
+ * running. At rest a `deferred` check is a fact the device has not decided — reported as a
83
+ * `deferred` entry in `errors` — not a loading state, so `aria-busy` must not advertise a
84
+ * control as permanently busy. It is not `isSubmitting`, which belongs to the form and is read
85
+ * from `useFormState()`.
86
+ */
87
+ readonly busy: boolean;
88
+ }
89
+ /**
90
+ * The evaluated state of one binding: everything a control renders, and nothing else.
91
+ *
92
+ * It is a projection of the engine's frozen per-binding state plus the session facts the engine
93
+ * does not own — whether the control was touched, whether the value moved from its baseline,
94
+ * and the host's display rules — so a component never holds a value tree of its own.
95
+ *
96
+ * Painting guide: one affordance reads one answer. `mayWrite` is the only fillability answer;
97
+ * when it is false, a write reaches `setValue` and is refused, so an affordance without a
98
+ * read-only state paints the value as static text instead of an interactive control. `disabled`
99
+ * states the element attribute and never whether a write would be accepted. `readOnly` states
100
+ * that the resolved access is exactly `read_only`, in which case a text input stays focusable
101
+ * and copyable while every other affordance paints static text.
102
+ *
103
+ * | `mayWrite` | `readOnly` | `disabled` | paint |
104
+ * | true | false | false | the interactive control |
105
+ * | false | true | false | read-only text input, or static text where the |
106
+ * | | | | affordance has no read-only state |
107
+ * | false | false | true | static text (`text`), or a disabled control |
108
+ * | false | false | false | static text (`text`); the binding is masked, hidden, |
109
+ * | | | | computed, or a `signature_ref` |
110
+ */
111
+ export interface FieldProps {
112
+ readonly fieldId: string;
113
+ /** The row this binding names, absent for a field binding. */
114
+ readonly rowKey?: string | number;
115
+ /** `fieldId`, or `fieldId@<wire-typed row key>`; the key every cache and summary uses. */
116
+ readonly bindingKey: string;
117
+ /** The artifact's declaration, which a formatting layer reads. */
118
+ readonly descriptor: CompiledField;
119
+ /** The submitted value, or `undefined` when absent or withheld by access. */
120
+ readonly value: WireValue | undefined;
121
+ /**
122
+ * The text this binding shows, whatever its domain.
123
+ *
124
+ * `value` is the wire union — a money amount is an object, an authored empty value is `null` —
125
+ * so a control that interpolated it rendered `[object Object]` or the word `null`. This is the
126
+ * one display answer, the same text `renderFieldText(field)` returns: `maskedText` beside a
127
+ * withheld value, a writer's value for a computed field, a money amount in its declared scale,
128
+ * and `''` for absent. A control that *edits* a value reads `useFieldValue` for the tagged
129
+ * domain; this is for the label, the read-only control and the summary.
130
+ */
131
+ readonly text: string;
132
+ /**
133
+ * The value the device was delivered when the session was opened, or re-baselined by a reset.
134
+ *
135
+ * It is the baseline as this device may *read* it, so it is `undefined` for a value the access
136
+ * answer withholds — delivering the record's stored value here would disclose it. `dirty` is
137
+ * measured against the record's baseline rather than this projection, so a value that becomes
138
+ * readable is not an edit.
139
+ */
140
+ readonly initialValue: WireValue | undefined;
141
+ readonly access: FieldAccess;
142
+ /**
143
+ * Whether the binding is on the screen: neither it nor a container above it is `hidden` — a
144
+ * member is delivered only through its container — and no `visible` rule failed.
145
+ */
146
+ readonly visible: boolean;
147
+ /** Whether a control may accept user input: access permits a write and `enabled` rules pass. */
148
+ readonly enabled: boolean;
149
+ /**
150
+ * Whether an interactive affordance may accept a user write at all.
151
+ *
152
+ * It is the runtime's one fillability answer (`fillable`): the write predicate — the access
153
+ * permits a user write and every `enabled` rule passes — plus the facts the engine refuses
154
+ * before it (no writer owns the value, the field is not a `signature_ref`) and visibility. A
155
+ * checkbox, a `<select>`, a `Pressable` or any other affordance with no read-only state gates
156
+ * on this: when it is false,
157
+ * paint the value as static text (`text`) rather than an interactive control, or the write
158
+ * reaches `setValue` and throws `WriteRefusedError`. A text input is the one exception only
159
+ * when the answer is false for `read_only` access: it may stay focusable and copyable with
160
+ * `readOnly`. Every other false answer — masked, computed, a `signature_ref`, a failed
161
+ * `enabled` rule or a hidden binding — paints static or disabled.
162
+ *
163
+ * Not `enabled`: `enabled` states the access and `enabled` rules alone, so a writer-owned value
164
+ * and a `signature_ref` are `enabled` but never `mayWrite`.
165
+ */
166
+ readonly mayWrite: boolean;
167
+ /**
168
+ * Whether a host sets `disabled` on the control.
169
+ *
170
+ * Not `!enabled`: a `read_only` binding is `!enabled` but stays focusable and copyable, so it
171
+ * is announced by `readOnly`, not disabled. A field a failed `enabled` rule or an access that
172
+ * withholds writing (other than `read_only`) stops is disabled. Neither attribute says whether
173
+ * a write would be accepted — `mayWrite` is that answer.
174
+ */
175
+ readonly disabled: boolean;
176
+ /** Whether the resolved access is exactly `read_only` (`[ACCESS-1.2.1]`). */
177
+ readonly readOnly: boolean;
178
+ readonly required: boolean;
179
+ /**
180
+ * How many entries an array binding holds, when the device can count them, `MODEL-2.1.17`.
181
+ *
182
+ * Present exactly on an array binding whose declaration states `minItems` or `maxItems` and
183
+ * whose value this device may read or whose writer decided. `undefined` is an answer too: a
184
+ * withheld list states no length, and a host must not infer one from the absence of this
185
+ * member.
186
+ */
187
+ readonly rowCount?: number;
188
+ /**
189
+ * The declared entry-count refusal, if the array is outside its range.
190
+ *
191
+ * The host writes the sentence: `{count} of at least {limit}` for `belowMin`, or
192
+ * `{count} of at most {limit}` for `aboveMax`. It is also in `errors` as
193
+ * `kind: "cardinality"`, so a summary that reads one error list sees the same refusal.
194
+ */
195
+ readonly countViolation?: {
196
+ readonly kind: 'belowMin' | 'aboveMax';
197
+ readonly count: number;
198
+ readonly limit: number;
199
+ };
200
+ readonly computation: FieldComputation;
201
+ /**
202
+ * The option codes this record may not choose now, `ENGINE-7.1.7`.
203
+ *
204
+ * One answer per code, whether the declaration stated the condition or a host page marked the
205
+ * item `available: false`; the two are merged at the runtime and never re-decided here. A
206
+ * control paints a code it finds in this list as selectable-but-unavailable rather than as an
207
+ * offered choice, and a binding the record holds stays in the value (`RULES-7.1.6` never
208
+ * clears it). Absent when every offered code is available, so a control reads presence rather
209
+ * than an empty list to decide whether availability applies at all.
210
+ *
211
+ * The reason travels with the answer: `messageKey` and `params` when the declaration or the
212
+ * page stated words, and `cause` on an undetermined code, which the host writes its own
213
+ * sentence for.
214
+ */
215
+ readonly unavailableOptions?: readonly UnavailableOption[];
216
+ /** Every `validate` message targeting this binding, in artifact order. */
217
+ readonly messages: readonly FieldMessage[];
218
+ /**
219
+ * Every reason this binding cannot be submitted as it stands, plus the last entry the session
220
+ * refused. Only a blocking member stops a submission; a `row-key` entry states an attempted
221
+ * write the record would not take.
222
+ *
223
+ * This is the engine's fact list: it states every reason even when the host's reveal policy has
224
+ * not painted it yet. Read `visibleErrors` for the reasons to show now.
225
+ */
226
+ readonly errors: readonly FieldError[];
227
+ /**
228
+ * The reasons a control paints now, in artifact order.
229
+ *
230
+ * It is `errors` filtered by the session's reveal policy: a failure on a binding the user has
231
+ * not visited waits under `showErrors: "touched"`, a rule whose operands the user has not
232
+ * supplied waits even on a visited binding, and a failure already painted stays painted until
233
+ * it is corrected. A warning, a refused entry and the reasons a submit has just revealed are
234
+ * included. `readOnlyDiagnostics` remains the separate display list for a read-only binding.
235
+ */
236
+ readonly visibleErrors: readonly FieldError[];
237
+ /** The subset of `errors` a `read_only` or `masked` binding produced, for display only. */
238
+ readonly readOnlyDiagnostics: readonly FieldError[];
239
+ /** Whether any error blocks a submission on this device. */
240
+ readonly invalid: boolean;
241
+ /**
242
+ * Whether the control shows a failure: any blocking member of `visibleErrors`, or a refused
243
+ * entry.
244
+ *
245
+ * A refused write is an answer to something the user just did, so it is shown immediately and
246
+ * is not deferred by the reveal policy; a warning is in `visibleErrors` without making the
247
+ * control invalid.
248
+ */
249
+ readonly showError: boolean;
250
+ /**
251
+ * The failures a control renders now, in artifact order.
252
+ *
253
+ * It is `visibleErrors` when `showError` is true, and the painted warnings alone otherwise: a
254
+ * warning is visible without making the control invalid, while a blocking failure and a
255
+ * refused entry wait for `showError`. Read this in a control; read `errors` for a summary
256
+ * and `visibleErrors` for custom reveal chrome. Always present on props `useField` returns;
257
+ * see `PublishedFieldProps`.
258
+ */
259
+ readonly announce?: readonly FieldError[];
260
+ /**
261
+ * Whether the user has visited this binding: it lost focus, or its value changed deliberately.
262
+ *
263
+ * A programmatic write the session accepts is a deliberate change too. `dirty` answers a
264
+ * different question — whether the record moved from the one the session opened with — so a
265
+ * host can be touched without being dirty and dirty without being touched (`reset`).
266
+ */
267
+ readonly touched: boolean;
268
+ /**
269
+ * Whether the *record* moved from the session's baseline for this binding.
270
+ *
271
+ * The comparison is against what the record held, never against what access delivered: a
272
+ * `masked` value the host widens, a `hidden` value, or a server-redacted one was always there,
273
+ * so an access change is not an edit. A computed value is not an edit either — a writer owns
274
+ * it. A value this device may no longer read reports `false`, because it cannot compare what
275
+ * it may not see and the submission projection would not carry it.
276
+ */
277
+ readonly dirty: boolean;
278
+ /**
279
+ * The static text a control renders in place of an input, present exactly when the resolved
280
+ * access is `masked`.
281
+ *
282
+ * The record holds a value this device may not read, so there is nothing for a control to
283
+ * bind: render this text, never an input, a `<select>` or a buffered control. It is the host's
284
+ * `maskedDisplay` for this field — the text `text` already carries — or `''` when the host
285
+ * supplied none; it is never derived from the value or its length. A masked binding is never a
286
+ * buffer: `useBufferedInput` has no value to start from, and every keystroke would be refused.
287
+ */
288
+ readonly maskedText: string | undefined;
289
+ /**
290
+ * Whether this binding's value state is withheld from the device.
291
+ *
292
+ * Derived where `maskedText` is, from the value state the engine publishes: true exactly when
293
+ * that state is `withheld`, so a host never infers it from `value === undefined` (which also
294
+ * states an absent value). A masked or stored `write_only` binding is never an edit target:
295
+ * render `maskedText` or `text`, never an input. Redaction is different when `mayWrite` permits
296
+ * a replacement, so read that answer rather than treating every withheld binding as static.
297
+ */
298
+ readonly withheld: boolean;
299
+ /**
300
+ * Why the record withholds the value, present exactly when it does and absent otherwise, so a
301
+ * host reads presence rather than `undefined`.
302
+ */
303
+ readonly withheldReason?: WithheldReason;
304
+ readonly a11y: FieldA11y;
305
+ readonly hints: InputHints;
306
+ /**
307
+ * An opaque token that changes exactly when this binding's published props are replaced, so
308
+ * a host may use it as a memo key. It spells no value.
309
+ */
310
+ readonly signature: string;
311
+ /**
312
+ * Writes one value for this binding. The identity is owned by the store, so it is stable
313
+ * across renders and safe to pass to a memoised child or an effect dependency. It refuses by
314
+ * throwing the runtime's structured write error.
315
+ */
316
+ readonly setValue: (value: WireValue) => void;
317
+ /** `setValue`, under the handler name a control binds to `onChange`. */
318
+ readonly onChange: (value: WireValue) => void;
319
+ /**
320
+ * Writes one value for this binding without throwing for an expected refusal.
321
+ *
322
+ * It judges the write the way `setValue` does (the same guard, the same declaration parse,
323
+ * the same engine verdict) and returns the engine outcome instead of throwing it: a refused
324
+ * outcome carries the code the throwing door raises as `WriteRefusedError`, and a committed
325
+ * one carries the patches the write applied. A reference no binding addresses (an undeclared
326
+ * id, a row the record does not hold) still throws, because that is a programmer error rather
327
+ * than an answer to user intent. The identity is owned by the store, so it is stable across
328
+ * renders. Prefer this in an event handler; keep `setValue` where a throw already unwinds to
329
+ * a boundary the host paints. Always present on props `useField` returns; see
330
+ * `PublishedFieldProps`.
331
+ */
332
+ readonly trySetValue?: (value: WireValue) => EngineOutcome;
333
+ /** `trySetValue` for the authored empty value, `null`. */
334
+ readonly trySetNull?: () => EngineOutcome;
335
+ /** `trySetValue` for removing the value from the record. */
336
+ readonly tryRemoveValue?: () => EngineOutcome;
337
+ /** Writes the authored empty value, `null`. */
338
+ readonly setNull: () => void;
339
+ /** Removes the value from the record. */
340
+ readonly removeValue: () => void;
341
+ /**
342
+ * Records that a control for this binding lost focus. A no-op on a binding that is not
343
+ * writable or not visible, because a control the user could not use was never visited.
344
+ */
345
+ readonly onBlur: () => void;
346
+ }
347
+ /**
348
+ * The props a control actually renders: `FieldProps` with every derived member present.
349
+ *
350
+ * The snapshot layer states the members it owns and leaves these absent; the store extends each
351
+ * snapshot once per published state, so a props object read through `useField` always carries
352
+ * them. `withheldReason` is the one member presence still decides: it is present exactly when
353
+ * the record withholds the value, and absent otherwise. A host holding a bare `FieldProps`
354
+ * narrows with a check rather than a cast.
355
+ */
356
+ export type PublishedFieldProps = Omit<FieldProps, 'announce' | 'trySetValue' | 'trySetNull' | 'tryRemoveValue'> & {
357
+ readonly announce: readonly FieldError[];
358
+ readonly trySetValue: (value: WireValue) => EngineOutcome;
359
+ readonly trySetNull: () => EngineOutcome;
360
+ readonly tryRemoveValue: () => EngineOutcome;
361
+ };
362
+ //# sourceMappingURL=field-props.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"field-props.d.ts","sourceRoot":"","sources":["../src/field-props.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,aAAa,EACb,WAAW,EACX,YAAY,EACZ,iBAAiB,EACjB,SAAS,EACT,cAAc,E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AAa,CAAC;IAC3D,0DAA0D;IAC1D,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,aAAa,CAAC;IAC1C,4DAA4D;IAC5D,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,aAAa,CAAC;IAC9C,+CAA+C;IAC/C,QAAQ,CAAC,OAAO,EAAE,MAAM,IAAI,CAAC;IAC7B,yCAAyC;IACzC,QAAQ,CAAC,WAAW,EAAE,MAAM,IAAI,CAAC;IACjC;;;OAGG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,IAAI,CAAC;CAC7B;AAED;;;;;;;;GAQG;AACH,MAAM,MAAM,mBAAmB,GAAG,IAAI,CACpC,UAAU,EACV,UAAU,GAAG,aAAa,GAAG,YAAY,GAAG,gBAAgB,CAC7D,GAAG;IACF,QAAQ,CAAC,QAAQ,EAAE,SAAS,UAAU,EAAE,CAAC;IACzC,QAAQ,CAAC,WAAW,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,aAAa,CAAC;IAC1D,QAAQ,CAAC,UAAU,EAAE,MAAM,aAAa,CAAC;IACzC,QAAQ,CAAC,cAAc,EAAE,MAAM,aAAa,CAAC;CAC9C,CAAC"}
@@ -0,0 +1,64 @@
1
+ /**
2
+ * The element id one binding's control uses, under one provider's prefix.
3
+ *
4
+ * Two facts make up the id, and both are needed:
5
+ *
6
+ * - The prefix identifies the form session. `bindingKey` alone is the same string in every
7
+ * provider over one artifact, so two forms on a page emitted duplicate `id`, `htmlFor` and
8
+ * `aria-describedby` values and the second form's label and error text pointed at the first
9
+ * form's control. `FormProvider` supplies one prefix per mount (`useId()` by default, or the
10
+ * host's `idPrefix`), so the ids differ by session and every relation resolves inside its own.
11
+ * - The key is percent-encoded because a natural row key is user text: a row called
12
+ * `kitchen island` keys as `f_label@string:kitchen island`, and an id with a space breaks every
13
+ * `htmlFor`/`aria-describedby` that names it. The encoding is injective, so two bindings never
14
+ * share an id. `%`, `@` and `.` are not CSS identifier characters, so a `#id` selector needs
15
+ * `CSS.escape`; `htmlFor`, `aria-describedby` and `getElementById` need no escaping.
16
+ *
17
+ * The prefix is encoded too, so a host's readable `idPrefix` cannot reintroduce an invalid id.
18
+ */
19
+ export function fieldDomId(idPrefix, bindingKey) {
20
+ return `${encodeIdComponent(idPrefix)}-${encodeIdComponent(bindingKey)}`;
21
+ }
22
+ /**
23
+ * One id component, encoded per UTF-16 code unit.
24
+ *
25
+ * `encodeURIComponent` refuses an unpaired surrogate with `URIError`, and a natural row key is a
26
+ * string a host may have read from anywhere. Encoding each code unit keeps every JavaScript
27
+ * string representable, and `%uXXXX` is distinct from every `%XX` escape the built-in emits, so
28
+ * two distinct lone surrogates cannot collapse into one id.
29
+ */
30
+ function encodeIdComponent(value) {
31
+ let encoded = '';
32
+ for (const unit of value.split('')) {
33
+ const code = unit.charCodeAt(0);
34
+ encoded +=
35
+ code >= 0xd800 && code <= 0xdfff
36
+ ? `%u${code.toString(16).toUpperCase().padStart(4, '0')}`
37
+ : encodeURIComponent(unit);
38
+ }
39
+ return encoded;
40
+ }
41
+ /**
42
+ * The identifier a binding renders its failure text into.
43
+ *
44
+ * Derived from `bindingKey`, so a field and each of its rows have distinct ids without the host
45
+ * inventing a convention, and stable across a write because the binding is. A control names it in
46
+ * `aria-describedby` (or `aria-errormessage`) and renders the text it reveals under this id.
47
+ *
48
+ * `@` separates the role from the key because it is always `%40` inside an encoded component, and
49
+ * a row key is user text: a row called `r1.error` must not own the id that carries row `r1`'s
50
+ * failure (`fieldErrorId(prefix, '…@string:r1')`).
51
+ */
52
+ export function fieldErrorId(idPrefix, bindingKey) {
53
+ return `${fieldDomId(idPrefix, bindingKey)}@error`;
54
+ }
55
+ /**
56
+ * The identifier a binding renders its description text into, beside `fieldErrorId`.
57
+ *
58
+ * A control that shows both a description and a failure names both ids in `aria-describedby`,
59
+ * in that order, or swaps to the failure alone.
60
+ */
61
+ export function fieldDescriptionId(idPrefix, bindingKey) {
62
+ return `${fieldDomId(idPrefix, bindingKey)}@description`;
63
+ }
64
+ //# sourceMappingURL=field-props.js.map