@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":"option-pages.js","sourceRoot":"","sources":["../../src/store/option-pages.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,sBAAsB,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACvF,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AA0B3C;;;;;;;;GAQG;AACH,MAAM,wBAAwB,GAAG,GAAG,CAAC;AAErC,mGAAmG;AACnG,MAAM,4BAA4B,GAAG,GAAG,CAAC;AAEzC;;;;;GAKG;AACH,SAAS,oBAAoB,CAAC,IAAY;IACxC,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;IAC5B,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACnC,OAAO,MAAM,CAAC,MAAM,IAAI,4BAA4B;QAClD,CAAC,CAAC,OAAO;QACT,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,4BAA4B,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AAC7D,CAAC;AA2ED,MAAM,WAAW,GAA0B,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AAE7D,MAA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,CAAC;IAChB,MAAM,IAAI,GAAoB,MAAM,CAAC,MAAM,CAAC,EAAE,GAAG,KAAK,EAAE,GAAG,QAAQ,EAAE,cAAc,EAAE,QAAQ,EAAE,CAAC,CAAC;IACjG,UAAU,CAAC,GAAG,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;IAC/B,SAAS,CAAC,GAAG,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;IACjC,OAAO,IAAI,CAAC;AACd,CAAC;AAED,0FAA0F;AAC1F,MAAM,UAAU,aAAa,CAAC,OAAe,EAAE,MAAmC;IAChF,OAAO,UAAU,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;AACrC,CAAC","sourcesContent":["import type {\n CancellationPort,\n CancellationSignal,\n OptionDomains,\n OptionItem,\n OptionPage,\n WireValue,\n} from '@azx-pbc/axiom-runtime';\nimport { canonicalizeRestricted, isRecord, isWireValue } from '@azx-pbc/axiom-runtime';\nimport { bindingKey } from './bindings.js';\n\n/**\n * What a host's option loader is asked for: one bounded page for one binding,\n * `[MODEL-3.1.8]`.\n *\n * The row key is addressing metadata, not an undeclared dependency: a source declared inside\n * an array receives the row it belongs to so one row's page can be loaded and cancelled\n * without touching its siblings. `dependsOn` carries the current value of every declared\n * dependency, so the loader sees the basis the page was keyed by.\n *\n * `query` is the reader's search text, trimmed and capped, and empty while they have typed\n * nothing. It is request metadata rather than a record answer: it never enters `values`, no\n * rule reads it, and it appears in no report, submission or candidate delta.\n */\nexport interface OptionRequest {\n readonly sourceId: string;\n readonly fieldId: string;\n readonly rowKey?: string | number;\n readonly dependsOn: Readonly<Record<string, WireValue | undefined>>;\n readonly query: string;\n readonly cursor: string | null;\n readonly pageSize: number;\n readonly signal: CancellationSignal;\n}\n\n/**\n * How long a settled search waits before the loader is asked for a page.\n *\n * Only the request is debounced: the renderer publishes each edit immediately, the machine\n * drops the pages that answered the previous query and aborts the request in flight, and the\n * loader is invoked once the reader has stopped typing for this long. The wait itself is the\n * host's (`QueryDefer`): these bindings read no clock, and the same code renders on a server, in\n * a browser and on a device.\n */\nconst OPTION_QUERY_DEBOUNCE_MS = 250;\n\n/** The most code points a query may carry; text past this is truncated before a loader sees it. */\nconst OPTION_QUERY_MAX_CODE_POINTS = 200;\n\n/**\n * The reader's text as a loader receives it: trimmed, and truncated to the code-point bound.\n *\n * A code point is not a UTF-16 unit, so an astral character costs one: slicing the string at\n * 200 units would cut a surrogate pair in half and hand the loader a lone surrogate.\n */\nfunction normaliseOptionQuery(text: string): string {\n const trimmed = text.trim();\n const points = Array.from(trimmed);\n return points.length <= OPTION_QUERY_MAX_CODE_POINTS\n ? trimmed\n : points.slice(0, OPTION_QUERY_MAX_CODE_POINTS).join('');\n}\n\n/**\n * The host's timer for a search that waits for the reader to stop typing.\n *\n * The bindings are compiled with no ambient host types and read no clock, so the one thing a\n * debounced search needs that ECMAScript does not provide is the host's: it runs the callback\n * after the delay and the release it returns cancels a wait a newer edit superseded. A search\n * attempted without one is refused before the pages move or a loader is called; a host whose\n * controls never search needs none.\n */\nexport type QueryDefer = (callback: () => void, delayMs: number) => () => void;\n\n/** The host code that answers one page. A rejected promise and a thrown error are one failure. */\nexport type OptionLoader<V extends WireValue = WireValue> = (\n request: OptionRequest,\n) => Promise<OptionPage<V>>;\n\n/**\n * The basis one page list is keyed by.\n *\n * A change to any member invalidates the loaded pages and starts a load through the same path\n * a manual `reload` takes, so \"reload only when asked\" is not a rule the machine has: the\n * declared dependencies, the session's record date and the access version are the rule. The\n * reader's search text is the one key that is not here: `search` publishes it, drops the pages it\n * narrows and owns the request that answers it, so a render that follows an edit never asks the\n * loader for a second page of the same text.\n */\nexport interface OptionBasis {\n readonly fieldId: string;\n readonly rowKey?: string | number;\n readonly sourceId: string;\n readonly dependsOn: Readonly<Record<string, WireValue | undefined>>;\n /** Whether every dependency may be read; a withheld one never reaches the loader. */\n readonly readable: boolean;\n readonly signature: string;\n}\n\n/** What one binding's page machine currently states. */\nexport interface OptionPageState {\n /** The items the current query's pages hold, in the order the source offered them. */\n readonly items: readonly OptionItem[];\n /**\n * Every item this basis has offered, painted or not.\n *\n * A page is one window on the domain, so a held value a later query no longer paints is\n * still offered: this list is the domain the session judges eligibility by, and it is where\n * a control finds the label of a value the reader is not searching for.\n */\n readonly offered: readonly OptionItem[];\n /** Whether a page for the current query is requested, including while the loader waits. */\n readonly loading: boolean;\n /** Whether a page for the current query has resolved, including one whose items are empty. */\n readonly resolved: boolean;\n readonly error: Error | undefined;\n readonly hasMore: boolean;\n /** The cursor the next page is requested with, or `null` on the last page. */\n readonly cursor: string | null;\n}\n\n/** The stable controls one binding's consumer is handed. */\nexport interface OptionControls {\n readonly loadMore: () => void;\n readonly reload: () => void;\n /**\n * Publishes the reader's search text for this binding.\n *\n * The edit takes effect immediately: the pages that answered the previous query are dropped\n * and the request in flight is aborted, so a response for a superseded query paints nothing.\n * The loader itself is asked once the text has settled, and two edits that trim to one query\n * are one search.\n */\n readonly search: (query: string) => void;\n}\n\nconst EMPTY_ITEMS: readonly OptionItem[] = Object.freeze([]);\n\nconst EMPTY_STATE: OptionPageState = Object.freeze({\n items: EMPTY_ITEMS,\n offered: EMPTY_ITEMS,\n loading: false,\n resolved: false,\n error: undefined,\n hasMore: false,\n cursor: null,\n});\n\ninterface Entry {\n readonly key: string;\n readonly fieldId: string;\n readonly rowKey?: string | number;\n readonly port: CancellationPort;\n basis: OptionBasis | undefined;\n pageSize: number;\n /** The reader's search text this binding's pages answer, already normalised. */\n query: string;\n items: readonly OptionItem[];\n /** Everything this basis has offered, including items a later query no longer paints. */\n evidence: readonly OptionItem[];\n /** The canonical text of every value in `evidence`, so a page's codes are matched once. */\n offeredKeys: Set<string>;\n /** Whether a page of this basis has resolved; a loaded empty page is a domain offering none. */\n loaded: boolean;\n /**\n * Whether the source has answered for this basis at all.\n *\n * It survives a query, because a query narrows the window onto a domain the source has already\n * answered: a search in flight must not turn an answered \"this source offers nothing\" into an\n * unanswered question, which would let a refused value look eligible for as long as the reader\n * types.\n */\n answered: boolean;\n loading: boolean;\n error: Error | undefined;\n nextCursor: string | null;\n signal: CancellationSignal | undefined;\n /** Releases the wait; `undefined` once the wait has ended or been cancelled. */\n stopWaiting: (() => void) | undefined;\n subscribers: number;\n state: OptionPageState | undefined;\n controls: OptionControls | undefined;\n}\n\n/**\n * The page machine: one bounded, cancellable page list per array row or top-level field.\n *\n * The engine stores no option state, so everything a loaded domain needs lives here: the pages,\n * the cursor, the error and the one signal that decides staleness. `begin()` on the binding's\n * cancellation port cancels the previous request before returning, so a response that arrives\n * after a newer request began — or after unmount — commits nothing on either arm.\n */\nexport class OptionPages {\n private readonly loaders: Readonly<Record<string, OptionLoader>>;\n private readonly createPort: () => CancellationPort;\n private readonly defer: QueryDefer | undefined;\n private readonly entries = new Map<string, Entry>();\n private readonly listeners = new Set<() => void>();\n private domainsCache: OptionDomains | undefined;\n private unmounted = false;\n\n constructor(\n loaders: Readonly<Record<string, OptionLoader>>,\n createPort: () => CancellationPort,\n defer?: QueryDefer,\n ) {\n this.loaders = { ...loaders };\n this.createPort = createPort;\n this.defer = defer;\n }\n\n /** One binding's current page state; the same object until a fact it states changes. */\n stateOf(key: string): OptionPageState {\n const entry = this.entries.get(key);\n if (entry === undefined) return EMPTY_STATE;\n entry.state ??= Object.freeze({\n items: entry.items,\n offered: entry.evidence,\n loading: entry.loading,\n resolved: entry.loaded,\n error: entry.error,\n hasMore: entry.nextCursor !== null,\n cursor: entry.nextCursor,\n });\n return entry.state;\n }\n\n /** Registers a listener for every page-list change; the returned release is idempotent. */\n subscribe(listener: () => void): () => void {\n this.listeners.add(listener);\n return (): void => {\n this.listeners.delete(listener);\n };\n }\n\n /** Registers a consumer of one binding; the release cancels and evicts when it was the last. */\n retain(key: string, fieldId: string, rowKey: string | number | undefined): () => void {\n const entry = this.entryFor(key, fieldId, rowKey);\n entry.subscribers += 1;\n return (): void => {\n entry.subscribers -= 1;\n if (entry.subscribers > 0) return;\n this.cancelWaiting(entry);\n entry.signal?.abort();\n this.entries.delete(key);\n this.domainsCache = undefined;\n this.notify();\n };\n }\n\n /**\n * Keys one binding's pages by the basis they were loaded for, starting a load when it moved.\n *\n * A dependency the access answer withholds makes the basis unreadable: the pages are dropped\n * and no request is made, because a stale domain must never stand in for a value this device\n * may not read.\n *\n * A query edit is not this door's work: `search` has already dropped the pages that answered\n * the previous text and scheduled the one request for the new text, so a render that follows\n * an edit only records the basis it will be asked with. Every other member still starts its\n * load at once.\n */\n ensure(key: string, basis: OptionBasis, pageSize: number): void {\n const entry = this.entryFor(key, basis.fieldId, basis.rowKey);\n if (\n entry.basis?.signature === basis.signature &&\n entry.basis.readable === basis.readable &&\n entry.pageSize === pageSize\n ) {\n return;\n }\n entry.basis = basis;\n entry.pageSize = pageSize;\n // A basis-driven retry keeps the previous failure on screen until this request settles, so a\n // keystroke cannot unmount and re-insert the same alert. A basis that is not readable starts\n // no request, so no failure survives it.\n this.resetBasis(entry, basis.readable);\n this.notify();\n // StrictMode can replay a child's effect before the provider's remount effect. Record the\n // basis now; `mount()` starts that pending list as soon as the session is live again.\n if (!basis.readable || this.unmounted) return;\n this.load(entry, null);\n }\n\n /**\n * Publishes the reader's search text, dropping the pages that answered the previous query.\n *\n * The edit lands at once and only the request waits: the aborted signal is what keeps a page\n * that resolves after the edit from painting, and the pages are cleared so nothing states a\n * match for text the reader has already changed. Two edits that trim to one query are one\n * search, so surrounding whitespace never reaches a loader twice.\n */\n search(key: string, text: string): void {\n const entry = this.entries.get(key);\n if (entry === undefined) return;\n const query = normaliseOptionQuery(text);\n if (entry.query === query) return;\n const answers = !this.unmounted && entry.basis !== undefined && entry.basis.readable;\n const defer = this.defer;\n if (defer === undefined) {\n // Searching without the clock would issue one request per edit rather than one per settled\n // query. Refuse the missing host capability before moving the pages or asking the loader.\n throw new Error(\n \"option search requires FormProvider's `defer` timer so the loader call can wait 250 ms\",\n );\n }\n entry.query = query;\n this.clearPages(entry, true);\n this.cancelWaiting(entry);\n if (answers && defer !== undefined) {\n // The pages are gone and this binding is loading from the edit, which is the state the\n // control paints as busy: the request that answers the text is scheduled, not yet started.\n entry.loading = true;\n entry.stopWaiting = defer(() => {\n entry.stopWaiting = undefined;\n if (this.unmounted || entry.basis === undefined || !entry.basis.readable) {\n entry.loading = false;\n this.invalidate(entry);\n this.notify();\n return;\n }\n this.load(entry, null);\n }, OPTION_QUERY_DEBOUNCE_MS);\n }\n this.invalidate(entry);\n this.notify();\n }\n\n /** The stable controls one binding's consumers receive. */\n controls(key: string): OptionControls {\n const entry = this.entries.get(key);\n if (entry?.controls !== undefined) return entry.controls;\n const controls: OptionControls = Object.freeze({\n loadMore: (): void => this.loadMore(key),\n reload: (): void => this.reload(key),\n search: (query: string): void => this.search(key, query),\n });\n if (entry !== undefined) entry.controls = controls;\n return controls;\n }\n\n /** The domain every offered binding states, keyed by binding key; eligibility reads this. */\n domains(): OptionDomains {\n this.domainsCache ??= new Map(\n [...this.entries].flatMap(([key, entry]) => {\n // A page is one window on the source, so the domain is everything the pages for this\n // basis have offered: a query narrows what is painted, never what is offered, and a\n // reader's search cannot make the value they hold ineligible.\n if (entry.evidence.length > 0) return [[key, entry.evidence] as const];\n // A resolved empty page is an answer like any other — the source offers nothing — while\n // a binding the source has not answered yet decides nothing, so a selection is not\n // refused by a question the host has not answered.\n return entry.answered ? [[key, EMPTY_ITEMS] as const] : [];\n }),\n );\n return this.domainsCache;\n }\n\n /** Resumes after a remount, including a child effect that recorded its basis while unmounted. */\n mount(): void {\n this.unmounted = false;\n for (const entry of this.entries.values()) {\n if (entry.basis?.readable === true && !entry.loaded && !entry.loading) {\n this.load(entry, null);\n }\n }\n }\n\n /** Cancels every in-flight request; the page lists stay readable for a remount. */\n cancelAll(): void {\n for (const entry of this.entries.values()) {\n this.cancelWaiting(entry);\n entry.signal?.abort();\n }\n }\n\n /** Drops every entry; a provider that unmounts publishes nothing afterwards. */\n unmount(): void {\n this.unmounted = true;\n this.cancelAll();\n this.entries.clear();\n // Listeners stay registered: a StrictMode remount resumes the same session, and the store's\n // own domain observer must survive it.\n this.domainsCache = undefined;\n }\n\n private entryFor(keyValue: string, fieldId: string, rowKey: string | number | undefined): Entry {\n const existing = this.entries.get(keyValue);\n if (existing !== undefined) return existing;\n const entry: Entry = {\n key: keyValue,\n fieldId,\n ...(rowKey === undefined ? {} : { rowKey }),\n port: this.createPort(),\n basis: undefined,\n pageSize: 0,\n query: '',\n items: EMPTY_ITEMS,\n evidence: EMPTY_ITEMS,\n offeredKeys: new Set(),\n loaded: false,\n answered: false,\n loading: false,\n error: undefined,\n nextCursor: null,\n signal: undefined,\n stopWaiting: undefined,\n subscribers: 0,\n state: undefined,\n controls: undefined,\n };\n this.entries.set(keyValue, entry);\n return entry;\n }\n\n private loadMore(keyValue: string): void {\n const entry = this.entries.get(keyValue);\n if (entry === undefined || entry.loading || entry.nextCursor === null) return;\n if (entry.basis === undefined || !entry.basis.readable) return;\n this.load(entry, entry.nextCursor);\n }\n\n private reload(keyValue: string): void {\n const entry = this.entries.get(keyValue);\n if (entry?.basis === undefined || !entry.basis.readable) return;\n // A manual reload is a new request the user asked for; its failure is a new announcement.\n this.resetBasis(entry, false);\n this.notify();\n this.load(entry, null);\n }\n\n /**\n * Drops this binding's pages and everything the pages prove about the domain.\n *\n * The domain evidence is only as good as the basis it was gathered under: a moved dependency,\n * record date or access version makes it a statement about a superseded question, so it goes\n * with the pages.\n */\n private resetBasis(entry: Entry, keepError: boolean): void {\n this.cancelWaiting(entry);\n this.clearPages(entry, keepError);\n entry.evidence = EMPTY_ITEMS;\n entry.offeredKeys.clear();\n entry.answered = false;\n this.domainsCache = undefined;\n }\n\n /** Drops the painted pages and aborts the request that would replace them, evidence excepted. */\n private clearPages(entry: Entry, keepError: boolean): void {\n entry.signal?.abort();\n entry.signal = undefined;\n entry.items = EMPTY_ITEMS;\n entry.loaded = false;\n entry.loading = false;\n if (!keepError) entry.error = undefined;\n entry.nextCursor = null;\n this.invalidate(entry);\n }\n\n /** Stops a query waiting out the debounce; the text itself stays published. */\n private cancelWaiting(entry: Entry): void {\n entry.stopWaiting?.();\n entry.stopWaiting = undefined;\n }\n\n private load(entry: Entry, cursor: string | null): void {\n if (this.unmounted || entry.basis === undefined) return;\n const loader = Object.hasOwn(this.loaders, entry.basis.sourceId)\n ? this.loaders[entry.basis.sourceId]\n : undefined;\n if (loader === undefined) {\n entry.loading = false;\n entry.error = new Error(\n `no option loader is registered for source ${JSON.stringify(entry.basis.sourceId)}`,\n );\n this.invalidate(entry);\n this.notify();\n return;\n }\n // `begin()` cancels the previous request for this binding before it hands out the next\n // signal, so the signal alone answers \"is this response stale?\".\n const signal = entry.port.begin();\n entry.signal = signal;\n entry.loading = true;\n // The previous failure stays stated until this request settles: unmounting the alert and\n // re-inserting the same text announces it again on a keystroke that changed no failure.\n this.invalidate(entry);\n this.notify();\n const request: OptionRequest = {\n sourceId: entry.basis.sourceId,\n fieldId: entry.fieldId,\n ...(entry.rowKey === undefined ? {} : { rowKey: entry.rowKey }),\n dependsOn: entry.basis.dependsOn,\n query: entry.query,\n cursor,\n pageSize: entry.pageSize,\n signal,\n };\n // A loader that throws synchronously is a failure too, so it is started through the promise\n // chain rather than beside it.\n void Promise.resolve()\n .then(() => (signal.aborted ? undefined : loader(request)))\n .then(\n (page) => {\n if (signal.aborted || page === undefined) return;\n const checked = pageOf(page);\n if (checked.kind === 'refused') {\n entry.loading = false;\n entry.error = new Error(checked.detail);\n entry.nextCursor = null;\n entry.signal = undefined;\n this.invalidate(entry);\n this.notify();\n return;\n }\n entry.loading = false;\n entry.error = undefined;\n entry.items =\n cursor === null\n ? checked.page.items\n : Object.freeze([...entry.items, ...checked.page.items]);\n entry.loaded = true;\n entry.answered = true;\n entry.nextCursor = checked.page.nextCursor;\n entry.signal = undefined;\n this.offer(entry, checked.page.items);\n // A page answers for the domain even when it offers nothing, and a resolved empty page\n // is that answer: the map is rebuilt whether or not an item joined the evidence.\n this.domainsCache = undefined;\n this.invalidate(entry);\n this.notify();\n },\n (cause: unknown) => {\n // A rejected request on an aborted signal is the cancellation succeeding, not a\n // failure the host must show or the console must report.\n if (signal.aborted) return;\n entry.loading = false;\n entry.error =\n cause instanceof Error\n ? cause\n : new Error('the option source rejected without an error', { cause });\n entry.nextCursor = null;\n entry.signal = undefined;\n this.invalidate(entry);\n this.notify();\n },\n );\n }\n\n /**\n * Adds what a page offered to the domain this basis states, a repeated code taking the answer\n * the newest page gives.\n *\n * A page is a window on the source rather than the whole of it, so an item the reader has\n * already seen keeps answering eligibility after a query stops painting it. Each value keeps\n * the position it was first offered at, so the domain a control reads does not reorder itself\n * as pages arrive.\n */\n private offer(entry: Entry, items: readonly OptionItem[]): void {\n if (items.length === 0) return;\n const added: OptionItem[] = [];\n const repeated = new Set<string>();\n for (const item of items) {\n const key = canonicalizeRestricted(item.value);\n // A code a later page repeats takes the newest answer; the domain keeps the position the\n // value was first offered at.\n if (entry.offeredKeys.has(key)) repeated.add(key);\n else added.push(item);\n entry.offeredKeys.add(key);\n }\n if (added.length === items.length) {\n entry.evidence = Object.freeze([...entry.evidence, ...added]);\n return;\n }\n const answer = new Map(\n items.map((item) => [canonicalizeRestricted(item.value), item] as const),\n );\n const replaced = entry.evidence.map((item) => {\n const key = canonicalizeRestricted(item.value);\n return repeated.has(key) ? (answer.get(key) ?? item) : item;\n });\n entry.evidence = Object.freeze([...replaced, ...added]);\n }\n\n private invalidate(entry: Entry): void {\n entry.state = undefined;\n }\n\n private notify(): void {\n for (const listener of [...this.listeners]) listener();\n }\n}\n\n/** A page the host returned, validated at the boundary so a malformed one fails loudly. */\ntype CheckedPage =\n | { readonly kind: 'ok'; readonly page: OptionPage }\n | { readonly kind: 'refused'; readonly detail: string };\n\nfunction pageOf(value: unknown): CheckedPage {\n if (!isRecord(value)) {\n return { kind: 'refused', detail: 'an option loader must resolve to an option page' };\n }\n const items = value['items'];\n const nextCursor = value['nextCursor'];\n if (!Array.isArray(items)) {\n return { kind: 'refused', detail: 'an option page must carry an items array' };\n }\n if (nextCursor !== null && typeof nextCursor !== 'string') {\n return {\n kind: 'refused',\n detail: 'an option page states `nextCursor` as a string or null',\n };\n }\n const checked = optionItemsOf(items);\n if (checked.kind === 'refused') return checked;\n return { kind: 'ok', page: { items: checked.items, nextCursor } };\n}\n\n/**\n * The page's items, as the host's loader typed them.\n *\n * The loader runs host code compiled against `OptionLoader`, so an item's `value` is already\n * the field's wire type; what a JavaScript host can still get wrong is the page's shape, which\n * the caller checks. The label key is checked here because a renderer would otherwise show\n * `undefined` where a message key belongs.\n */\nfunction optionItemsOf(items: readonly unknown[]):\n | { readonly kind: 'ok'; readonly items: readonly OptionItem[] }\n | {\n readonly kind: 'refused';\n readonly detail: string;\n } {\n const checked: OptionItem[] = [];\n for (const raw of items) {\n if (!isRecord(raw) || typeof raw['labelKey'] !== 'string' || !Object.hasOwn(raw, 'value')) {\n return {\n kind: 'refused',\n detail: 'an option page item carries a `value` and a string `labelKey`',\n };\n }\n const deprecated = raw['deprecated'];\n if (deprecated !== undefined && typeof deprecated !== 'boolean') {\n return {\n kind: 'refused',\n detail: 'an option item states `deprecated` as a boolean when it states it',\n };\n }\n // A page answers availability for the codes it holds, `RULES-7.1.5`, so its answer and the\n // sentence that explains it are part of the item rather than decoration: dropping them here\n // would make the domain offer a code the host just said this record may not use.\n const available = raw['available'];\n if (available !== undefined && typeof available !== 'boolean') {\n return {\n kind: 'refused',\n detail: 'an option item states `available` as a boolean when it states it',\n };\n }\n const unavailableMessageKey = raw['unavailableMessageKey'];\n if (unavailableMessageKey !== undefined && typeof unavailableMessageKey !== 'string') {\n return {\n kind: 'refused',\n detail: 'an option item states `unavailableMessageKey` as a string when it states it',\n };\n }\n const unavailableParams = optionParamsOf(raw['unavailableParams']);\n if (unavailableParams.kind === 'refused') {\n return {\n kind: 'refused',\n detail: 'an option item states `unavailableParams` as a record of wire values',\n };\n }\n const value = copyOptionValue(raw['value']);\n if (value === undefined) {\n return {\n kind: 'refused',\n detail: 'an option item’s `value` is a wire value',\n };\n }\n checked.push(\n Object.freeze({\n value,\n labelKey: raw['labelKey'],\n ...(deprecated === true ? { deprecated: true } : {}),\n ...(available === undefined ? {} : { available }),\n ...(unavailableMessageKey === undefined ? {} : { unavailableMessageKey }),\n ...(unavailableParams.kind === 'absent'\n ? {}\n : { unavailableParams: unavailableParams.params }),\n }),\n );\n }\n return { kind: 'ok', items: Object.freeze(checked) };\n}\n\n/** One option item's message arguments: absent, a copy, or a shape the page may not carry. */\ntype OptionParamsReadout =\n | { readonly kind: 'absent' }\n | { readonly kind: 'refused' }\n | { readonly kind: 'params'; readonly params: Readonly<Record<string, WireValue>> };\n\n/** Reads one option item's message arguments, or refuses a value that is not message payload. */\nfunction optionParamsOf(raw: unknown): OptionParamsReadout {\n if (raw === undefined) return { kind: 'absent' };\n if (!isRecord(raw)) return { kind: 'refused' };\n const params: Record<string, WireValue> = {};\n for (const [name, value] of Object.entries(raw)) {\n const copied = copyOptionValue(value);\n if (copied === undefined) return { kind: 'refused' };\n setOwn(params, name, copied);\n }\n return { kind: 'params', params: Object.freeze(params) };\n}\n\n/** Stores a wire member without invoking the legacy `__proto__` setter on a plain object. */\nfunction setOwn(target: Record<string, WireValue>, key: string, value: WireValue): void {\n Object.defineProperty(target, key, {\n value,\n enumerable: true,\n configurable: true,\n writable: true,\n });\n}\n\n/**\n * A private copy of one option value, or `undefined` when it is not a wire value.\n *\n * The loader is host code and the store outlives the page it was handed, so keeping the\n * caller's object would let a later mutation of their item change a domain the session has\n * already derived. Every other host input crosses the wire reader; this copy is the same\n * guarantee for a value whose field declaration the page machine does not receive. The copy\n * is frozen, so the domain the store publishes cannot be edited in place either.\n */\nfunction copyOptionValue(value: unknown): WireValue | undefined {\n // The loader's answer is untrusted data. Share the runtime's profile walk so a cycle, a sparse\n // list, an accessor or excessive depth is a page refusal rather than a recursive host failure.\n if (!isWireValue(value)) return undefined;\n if (value === null || typeof value === 'string' || typeof value === 'boolean') return value;\n if (typeof value === 'number') {\n return Number.isSafeInteger(value) && !Object.is(value, -0) ? value : undefined;\n }\n if (Array.isArray(value)) {\n const items: WireValue[] = [];\n for (const item of value) {\n const copied = copyOptionValue(item);\n if (copied === undefined) return undefined;\n items.push(copied);\n }\n return Object.freeze(items);\n }\n if (isRecord(value)) {\n const copy: Record<string, WireValue> = {};\n for (const [key, member] of Object.entries(value)) {\n const copied = copyOptionValue(member);\n if (copied === undefined) return undefined;\n setOwn(copy, key, copied);\n }\n return Object.freeze(copy);\n }\n return undefined;\n}\n\n/**\n * The object one `useAsyncOptions` consumer renders: the page state plus the callbacks.\n *\n * Memoised by the state identity, so the snapshot a subscriber compares is the same object\n * until a page fact, the basis or its readability actually moves.\n */\nexport interface AsyncOptionList extends OptionPageState, OptionControls {\n /** Whether every declared dependency may be read; false means no page was requested. */\n readonly readable: boolean;\n /**\n * The basis the list is keyed by. It is part of the published value so a dependency, the\n * record date or the access version moving re-renders the picker even before a page arrives.\n */\n readonly basisSignature: string;\n}\n\nconst COMPOSITE = new WeakMap<OptionPageState, WeakMap<OptionControls, AsyncOptionList>>();\n\nexport function asyncOptionListOf(\n state: OptionPageState,\n controls: OptionControls,\n basisSignature: string,\n readable: boolean,\n): AsyncOptionList {\n const byControls = COMPOSITE.get(state) ?? new WeakMap<OptionControls, AsyncOptionList>();\n const cached = byControls.get(controls);\n if (\n cached !== undefined &&\n cached.basisSignature === basisSignature &&\n cached.readable === readable\n )\n return cached;\n const list: AsyncOptionList = Object.freeze({ ...state, ...controls, basisSignature, readable });\n byControls.set(controls, list);\n COMPOSITE.set(state, byControls);\n return list;\n}\n\n/** The binding key a page list is filed under; one row's pages never answer another's. */\nexport function optionPageKey(fieldId: string, rowKey: string | number | undefined): string {\n return bindingKey(fieldId, rowKey);\n}\n"]}
@@ -0,0 +1,105 @@
1
+ import type { CompiledField, WireValue } from '@azx-pbc/axiom-runtime';
2
+ /**
3
+ * The one text↔value contract a buffered input is bound to.
4
+ *
5
+ * A control's text passes through states the wire cannot hold — `12.`, `-`, `+`, `2026-0` —
6
+ * so the text is never the value. A parse answers with one of three states: a wire value the
7
+ * session can take, a partial entry that is still being typed, or an entry the format refuses
8
+ * with a stable reason key the host translates. Only the first is ever written.
9
+ */
10
+ export type BufferedFormat = {
11
+ readonly kind: 'decimal';
12
+ } | {
13
+ readonly kind: 'integer';
14
+ } | {
15
+ readonly kind: 'money';
16
+ }
17
+ /**
18
+ * An exact amount and the unit its field is measured in. The unit is the one the control's
19
+ * picker currently shows, so one text entry writes both members of the wire value.
20
+ */
21
+ | {
22
+ readonly kind: 'quantity';
23
+ readonly unit: string;
24
+ } | {
25
+ readonly kind: 'phone';
26
+ } | {
27
+ readonly kind: 'date';
28
+ };
29
+ /**
30
+ * Why one text entry cannot be a value.
31
+ *
32
+ * These are stable keys, not prose: the layer is headless and has no locale, so a host renders
33
+ * them through its own catalogue (`parseError` plus `parseErrorParams`). A key is also what a
34
+ * test can pin, while an English sentence would change with the wording.
35
+ */
36
+ export type BufferRefusalReason = 'buffer.decimal.one_point' | 'buffer.decimal.digits' | 'buffer.decimal.fraction_digits' | 'buffer.decimal.not_canonical' | 'buffer.integer.digits' | 'buffer.integer.no_point' | 'buffer.integer.not_safe' | 'buffer.money.not_amount' | 'buffer.money.scale_exceeded' | 'buffer.phone.e164' | 'buffer.date.nonexistent_day' | 'buffer.date.format';
37
+ /** One refusal, with the values its message interpolates. */
38
+ export interface BufferRefusal {
39
+ readonly reason: BufferRefusalReason;
40
+ readonly params?: Readonly<Record<string, string | number>>;
41
+ }
42
+ /** The locale's punctuation for one decimal number, as an input expects to read it. */
43
+ export interface NumericSeparators {
44
+ /** The mark between the whole part and the fraction (`125,50` in `es`). */
45
+ readonly decimal: string;
46
+ /** The mark between digit groups (`1.234` in `es`). */
47
+ readonly group: string;
48
+ /**
49
+ * CLDR's `minimumGroupingDigits`: how many digits beyond three must appear before a group mark
50
+ * is printed (`1` groups from four digits; `2` leaves four-digit integers ungrouped and starts
51
+ * at five, matching Spanish and Italian). Defaults to `1`.
52
+ */
53
+ readonly minimumGroupingDigits?: 1 | 2;
54
+ }
55
+ /** What one text entry means to the session. */
56
+ export type ParseOutcome = {
57
+ readonly kind: 'value';
58
+ readonly value: WireValue;
59
+ } | {
60
+ readonly kind: 'partial';
61
+ } | ({
62
+ readonly kind: 'invalid';
63
+ } & BufferRefusal);
64
+ /**
65
+ * The resolved format: the kind the control asks for, and the money domain when it is money.
66
+ *
67
+ * `currency` and `scale` are the field declaration's, never the host's: a money field's
68
+ * declaration is mandatory, so two fields with different currencies cannot share a parser and
69
+ * no host needs per-field format configuration.
70
+ */
71
+ export interface FormatContract {
72
+ readonly format: BufferedFormat;
73
+ readonly currency?: string;
74
+ /**
75
+ * The declared fractional-digit bound. A money amount uses it to place the minor units; a
76
+ * quantity uses it to refuse an amount the declaration cannot hold. A quantity with no stated
77
+ * scale reads `0`, the integer quantity.
78
+ */
79
+ readonly scale?: number;
80
+ /** The marks the entry may use. Absent reads the canonical `.` decimal and `,` group. */
81
+ readonly separators?: NumericSeparators;
82
+ }
83
+ /**
84
+ * The contract one field is buffered against.
85
+ *
86
+ * A `money` format with no declared `(currency, scale)` is a programmer error rather than a
87
+ * default: guessing a currency would print an amount the record never held. `locale` is the
88
+ * host's request for that control's punctuation; it changes which marks parse and print, never
89
+ * the value the record holds.
90
+ */
91
+ export declare function formatContractOf(field: CompiledField, format: BufferedFormat, locale?: string, separators?: NumericSeparators): FormatContract;
92
+ /**
93
+ * The identity of a contract's text, compared by value.
94
+ *
95
+ * `formatContractOf` builds a fresh object on every render, so a buffer cannot compare the
96
+ * contract its text was entered under with the object the control now holds. This spelling names
97
+ * every member that changes how text is read or written, so two renders of the same format agree
98
+ * and a locale or declaration change does not.
99
+ */
100
+ export declare function contractSignature(contract: FormatContract): string;
101
+ /** The text a committed value shows, or empty text for the authored empty value. */
102
+ export declare function printEntry(value: WireValue | undefined, contract: FormatContract): string;
103
+ /** The wire value one text entry names, or why it names none yet. */
104
+ export declare function parseEntry(text: string, contract: FormatContract): ParseOutcome;
105
+ //# sourceMappingURL=parse-print.d.ts.map
@@ -0,0 +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,EAAE,CAAC,GAAG,CAAC,CAAC;CACxC;AA+CD,gDAAgD;AAChD,MAAM,MAAM,YAAY,GACpB;IAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAA;CAAE,GACrD;IAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAA;CAAE,GAC5B,CAAC;IAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAA;CAAE,GAAG,aAAa,CAAC,CAAC;AAEnD;;;;;;GAMG;AACH,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC;IAChC,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B;;;;OAIG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,yFAAyF;IACzF,QAAQ,CAAC,UAAU,CAAC,EAAE,iBAAiB,CAAC;CACzC;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,aAAa,EACpB,MAAM,EAAE,cAAc,EACtB,MAAM,CAAC,EAAE,MAAM,EACf,UAAU,CAAC,EAAE,iBAAiB,GAC7B,cAAc,CA4BhB;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,cAAc,GAAG,MAAM,CAalE;AAED,oFAAoF;AACpF,wBAAgB,UAAU,CAAC,KAAK,EAAE,SAAS,GAAG,SAAS,EAAE,QAAQ,EAAE,cAAc,GAAG,MAAM,CAgBzF;AAED,qEAAqE;AACrE,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,cAAc,GAAG,YAAY,CAiB/E"}
@@ -0,0 +1,415 @@
1
+ import { asDecimalString, AxiomError, DECIMAL_TEXT_PATTERN, formatPlainDate, isE164PhoneNumber, isRecord, moneyFromMinor, parsePlainDate, } from '@azx-pbc/axiom-runtime';
2
+ /** The separators a contract without a locale reads: the canonical `125.50` and `1,234`. */
3
+ const DEFAULT_SEPARATORS = Object.freeze({
4
+ decimal: '.',
5
+ group: ',',
6
+ });
7
+ /** One separator table per requested locale, so a keystroke does not re-read a table. */
8
+ const SEPARATORS = new Map();
9
+ /**
10
+ * The decimal and grouping marks this layer reads for one language.
11
+ *
12
+ * It is a vendored table, not the host's locale database: the package must render the same entry
13
+ * on Node, in a browser and on a device, exactly as it reads plural rules from its own registry.
14
+ * The marks cover every locale the reference host ships (en, es, fr, de, ru, it, zh, ar, pt);
15
+ * Chinese and Arabic are listed explicitly so neither depends on the canonical fallback. Arabic
16
+ * uses the ASCII decimal and group marks to match the display layer and Western digit policy, so
17
+ * an entry prints and accepts the same spelling the page displays. A language outside this table
18
+ * keeps the canonical `.` decimal and `,` group, and a host with another convention may pass
19
+ * `separators` explicitly. An entry the chosen marks cannot parse is refused rather than guessed
20
+ * at.
21
+ */
22
+ const LOCALE_SEPARATORS = Object.freeze({
23
+ en: DEFAULT_SEPARATORS,
24
+ es: { decimal: ',', group: '.', minimumGroupingDigits: 2 },
25
+ de: { decimal: ',', group: '.' },
26
+ it: { decimal: ',', group: '.', minimumGroupingDigits: 2 },
27
+ pt: { decimal: ',', group: '.' },
28
+ fr: { decimal: ',', group: ' ' },
29
+ ru: { decimal: ',', group: ' ' },
30
+ zh: DEFAULT_SEPARATORS,
31
+ ar: DEFAULT_SEPARATORS,
32
+ });
33
+ /** The language subtag of a requested tag, so `es-MX` reads the `es` marks. */
34
+ function separatorsOf(locale) {
35
+ if (locale === undefined || locale === '')
36
+ return DEFAULT_SEPARATORS;
37
+ const cached = SEPARATORS.get(locale);
38
+ if (cached !== undefined)
39
+ return cached;
40
+ const language = locale.split(/[-_]/)[0] ?? '';
41
+ const separators = LOCALE_SEPARATORS[language] ?? DEFAULT_SEPARATORS;
42
+ SEPARATORS.set(locale, separators);
43
+ return separators;
44
+ }
45
+ /**
46
+ * The contract one field is buffered against.
47
+ *
48
+ * A `money` format with no declared `(currency, scale)` is a programmer error rather than a
49
+ * default: guessing a currency would print an amount the record never held. `locale` is the
50
+ * host's request for that control's punctuation; it changes which marks parse and print, never
51
+ * the value the record holds.
52
+ */
53
+ export function formatContractOf(field, format, locale, separators) {
54
+ const marks = separators ?? separatorsOf(locale);
55
+ if (format.kind === 'quantity') {
56
+ if (field.units === undefined) {
57
+ throw new AxiomError('ENGINE_ERROR', `a quantity buffer needs the declared units of ${field.fieldId}; its declaration states none`, field.fieldId);
58
+ }
59
+ if (!field.units.includes(format.unit)) {
60
+ throw new AxiomError('ENGINE_ERROR', `the unit ${format.unit} is not one ${field.fieldId} declares`, field.fieldId);
61
+ }
62
+ return { format, scale: field.scale ?? 0, separators: marks };
63
+ }
64
+ if (format.kind !== 'money')
65
+ return { format, separators: marks };
66
+ if (field.currency === undefined || field.scale === undefined) {
67
+ throw new AxiomError('ENGINE_ERROR', `a money buffer needs the declared (currency, scale) of ${field.fieldId}; its declaration states none`, field.fieldId);
68
+ }
69
+ return { format, currency: field.currency, scale: field.scale, separators: marks };
70
+ }
71
+ /**
72
+ * The identity of a contract's text, compared by value.
73
+ *
74
+ * `formatContractOf` builds a fresh object on every render, so a buffer cannot compare the
75
+ * contract its text was entered under with the object the control now holds. This spelling names
76
+ * every member that changes how text is read or written, so two renders of the same format agree
77
+ * and a locale or declaration change does not.
78
+ */
79
+ export function contractSignature(contract) {
80
+ const format = contract.format;
81
+ const unit = format.kind === 'quantity' ? format.unit : '';
82
+ const marks = contract.separators ?? DEFAULT_SEPARATORS;
83
+ return [
84
+ format.kind,
85
+ unit,
86
+ contract.currency ?? '',
87
+ contract.scale === undefined ? '' : String(contract.scale),
88
+ marks.decimal,
89
+ marks.group,
90
+ String(marks.minimumGroupingDigits ?? 1),
91
+ ].join('\u0000');
92
+ }
93
+ /** The text a committed value shows, or empty text for the authored empty value. */
94
+ export function printEntry(value, contract) {
95
+ if (value === undefined || value === null)
96
+ return '';
97
+ switch (contract.format.kind) {
98
+ case 'decimal':
99
+ return typeof value === 'string' || typeof value === 'number'
100
+ ? printDecimalText(String(value), contract)
101
+ : '';
102
+ case 'integer':
103
+ case 'phone':
104
+ case 'date':
105
+ return typeof value === 'string' || typeof value === 'number' ? String(value) : '';
106
+ case 'money':
107
+ return isMoney(value) ? printMoney(value, contract) : '';
108
+ case 'quantity':
109
+ return printQuantity(value, contract);
110
+ }
111
+ }
112
+ /** The wire value one text entry names, or why it names none yet. */
113
+ export function parseEntry(text, contract) {
114
+ if (text.trim() === '')
115
+ return { kind: 'value', value: null };
116
+ const separators = contract.separators ?? DEFAULT_SEPARATORS;
117
+ switch (contract.format.kind) {
118
+ case 'decimal':
119
+ return parseDecimalText(text.trim(), false, separators);
120
+ case 'integer':
121
+ return parseIntegerText(text.trim(), separators);
122
+ case 'money':
123
+ return parseMoneyText(text.trim(), contract, separators);
124
+ case 'quantity':
125
+ return parseQuantityText(text.trim(), contract, separators);
126
+ case 'phone':
127
+ return parsePhoneText(text.trim());
128
+ case 'date':
129
+ return parseDateText(text.trim());
130
+ }
131
+ }
132
+ /** Canonical digit text with no leading zeros; the amount zero loses its sign too. */
133
+ function stripLeadingZeros(digits) {
134
+ const without = digits.replace(/^0+(?=[0-9])/, '');
135
+ return without === '0' ? '0' : without;
136
+ }
137
+ /**
138
+ * One digit run with the locale's grouping removed, or `undefined` when the groups are malformed.
139
+ *
140
+ * A group mark is accepted only between groups: the first group is one to three digits and every
141
+ * later one is exactly three, so `1,20` is refused rather than read as `120`.
142
+ */
143
+ function ungroupDigits(whole, group) {
144
+ const negative = whole.startsWith('-');
145
+ const body = negative ? whole.slice(1) : whole;
146
+ if (body === '')
147
+ return negative ? '-' : '';
148
+ if (!body.includes(group)) {
149
+ return /^[0-9]*$/.test(body) ? `${negative ? '-' : ''}${body}` : undefined;
150
+ }
151
+ const groups = body.split(group);
152
+ const [first = '', ...rest] = groups;
153
+ if (!/^[0-9]{1,3}$/.test(first))
154
+ return undefined;
155
+ if (rest.some((entry) => !/^[0-9]{3}$/.test(entry)))
156
+ return undefined;
157
+ return `${negative ? '-' : ''}${groups.join('')}`;
158
+ }
159
+ /** The spaces a spreadsheet export may carry where a person saw the group mark. */
160
+ const PASTED_SPACE = /[\u00A0\u202F]/g;
161
+ /**
162
+ * Pasted grouping spaces as the mark the entry reads.
163
+ *
164
+ * A no-break space and a narrow no-break space become the group mark when the entry reads a
165
+ * space-like group (`fr`, `ru`, or a host override in the same family), and the plain space
166
+ * otherwise. Under any other marks the plain space is still no group mark, so the entry keeps
167
+ * its refusal, and a host override that names a non-breaking group keeps reading it.
168
+ */
169
+ function normalizePastedSpaces(body, group) {
170
+ const target = group === ' ' || group === '\u00A0' || group === '\u202F' ? group : ' ';
171
+ return body.replace(PASTED_SPACE, target);
172
+ }
173
+ /**
174
+ * One leading plus as no sign, so a pasted `+12.50` reads as the amount it names.
175
+ *
176
+ * A bare `+` is a half-typed entry, like `-`. A plus followed by another sign (`+-12`) is no
177
+ * sign at all and stays refused.
178
+ */
179
+ function withoutLeadingPlus(body) {
180
+ if (!body.startsWith('+'))
181
+ return body;
182
+ const rest = body.slice(1);
183
+ if (rest.startsWith('-') || rest.startsWith('+'))
184
+ return undefined;
185
+ return rest;
186
+ }
187
+ /**
188
+ * One decimal entry, in the locale's punctuation, as canonical wire text.
189
+ *
190
+ * The decimal mark is taken before the group mark: `1.234,56` under `de` is a grouped thousand
191
+ * and a fraction, while `1,234.56` under `en` is the same amount. A mark used twice as a decimal
192
+ * is refused (`12,3,4`), and a group mark inside the fraction is refused rather than stripped, so
193
+ * an ambiguous entry never becomes a number the user did not type. Pasted text is normalised
194
+ * first: the two spreadsheet spaces become the group mark where that mark is itself a space,
195
+ * else the plain space, and one leading plus is dropped, while anything else keeps its refusal.
196
+ */
197
+ function parseDecimalText(body, integerOnly, separators) {
198
+ const { decimal, group } = usableSeparators(separators);
199
+ const unsigned = withoutLeadingPlus(normalizePastedSpaces(body, group));
200
+ if (unsigned === undefined) {
201
+ return {
202
+ kind: 'invalid',
203
+ reason: integerOnly ? 'buffer.integer.digits' : 'buffer.decimal.digits',
204
+ };
205
+ }
206
+ const parts = unsigned.split(decimal);
207
+ if (parts.length > 2) {
208
+ return { kind: 'invalid', reason: 'buffer.decimal.one_point' };
209
+ }
210
+ const wholeRaw = parts[0] ?? '';
211
+ const fraction = parts[1];
212
+ const plainWhole = ungroupDigits(wholeRaw, group);
213
+ if (plainWhole === undefined) {
214
+ return {
215
+ kind: 'invalid',
216
+ reason: integerOnly ? 'buffer.integer.digits' : 'buffer.decimal.digits',
217
+ };
218
+ }
219
+ if (fraction !== undefined && !/^[0-9]*$/.test(fraction)) {
220
+ // A group mark in the fraction is one of these characters; it is refused with the fraction
221
+ // message rather than silently removed.
222
+ return { kind: 'invalid', reason: 'buffer.decimal.fraction_digits' };
223
+ }
224
+ if (integerOnly && fraction !== undefined) {
225
+ return { kind: 'invalid', reason: 'buffer.integer.no_point' };
226
+ }
227
+ const negative = plainWhole.startsWith('-');
228
+ const digits = stripLeadingZeros(negative ? plainWhole.slice(1) : plainWhole);
229
+ // The integer part alone, or the point with no digit after it, is an entry still being typed.
230
+ if (digits === '' || fraction === '')
231
+ return { kind: 'partial' };
232
+ const trimmed = fraction === undefined ? '' : fraction.replace(/0+$/, '');
233
+ const text = trimmed === ''
234
+ ? `${negative && digits !== '0' ? '-' : ''}${digits}`
235
+ : `${negative ? '-' : ''}${digits}.${trimmed}`;
236
+ if (!DECIMAL_TEXT_PATTERN.test(text)) {
237
+ return { kind: 'invalid', reason: 'buffer.decimal.not_canonical' };
238
+ }
239
+ return { kind: 'value', value: text };
240
+ }
241
+ /** The marks a parse may use; a table whose marks collide falls back to the canonical pair. */
242
+ function usableSeparators(separators) {
243
+ if (separators.decimal === '' ||
244
+ separators.group === '' ||
245
+ separators.decimal === separators.group) {
246
+ return DEFAULT_SEPARATORS;
247
+ }
248
+ return separators;
249
+ }
250
+ function parseIntegerText(text, separators) {
251
+ const parsed = parseDecimalText(text, true, separators);
252
+ if (parsed.kind !== 'value')
253
+ return parsed;
254
+ const value = Number(parsed.value);
255
+ if (!Number.isSafeInteger(value) || Object.is(value, -0)) {
256
+ return { kind: 'invalid', reason: 'buffer.integer.not_safe' };
257
+ }
258
+ return { kind: 'value', value };
259
+ }
260
+ /**
261
+ * A currency symbol at either edge of a pasted amount.
262
+ *
263
+ * The declaration names the currency, so a symbol the text carries is not part of the amount:
264
+ * `$1,234.56` and `1.234,56 €` read as the digits they surround. Only an edge symbol is removed;
265
+ * a space between digits is not a declared group mark, so `1 234,56` is refused rather than
266
+ * guessed at. Pasted spaces are normalised to the plain space before this read, so a no-break
267
+ * space refuses exactly where the plain space refuses. The sign survives a leading symbol, so
268
+ * `-$12.50` is a negative amount.
269
+ */
270
+ const CURRENCY_SYMBOL_EDGE = /^(\s*[-+]?\s*)\p{Sc}\s*|\s*\p{Sc}\s*$/gu;
271
+ function withoutCurrencySymbol(text) {
272
+ return text.replace(CURRENCY_SYMBOL_EDGE, '$1');
273
+ }
274
+ function parseMoneyText(text, contract, separators) {
275
+ const currency = contract.currency;
276
+ const scale = contract.scale;
277
+ if (currency === undefined || scale === undefined) {
278
+ throw new AxiomError('ENGINE_ERROR', 'a money buffer needs a declared (currency, scale)', contract.format.kind);
279
+ }
280
+ const decimal = parseDecimalText(withoutCurrencySymbol(text), false, separators);
281
+ if (decimal.kind !== 'value')
282
+ return decimal;
283
+ if (decimal.value === null || typeof decimal.value !== 'string') {
284
+ return { kind: 'invalid', reason: 'buffer.money.not_amount' };
285
+ }
286
+ const [whole = '', fraction = ''] = decimal.value.split('.');
287
+ if (fraction.length > scale) {
288
+ return {
289
+ kind: 'invalid',
290
+ reason: 'buffer.money.scale_exceeded',
291
+ params: { scale },
292
+ };
293
+ }
294
+ const digits = `${whole.replace('-', '')}${fraction.padEnd(scale, '0')}`;
295
+ const canonical = stripLeadingZeros(digits);
296
+ const minor = canonical === '0' || !decimal.value.startsWith('-') ? canonical : `-${canonical}`;
297
+ return {
298
+ kind: 'value',
299
+ value: moneyFromMinor(asDecimalString(minor), currency, scale, 'half_up'),
300
+ };
301
+ }
302
+ /**
303
+ * One quantity entry as the wire record `{ value, unit }`, `MODEL-2.1.21`.
304
+ *
305
+ * The amount is exact decimal text at the declaration's scale; the unit is the one the
306
+ * control's picker holds, so the text and the picker always name one measured value. A scale of
307
+ * zero is an integer quantity and refuses a decimal point, because the declaration cannot hold
308
+ * the fraction the user typed.
309
+ */
310
+ function parseQuantityText(text, contract, separators) {
311
+ if (contract.format.kind !== 'quantity') {
312
+ throw new AxiomError('ENGINE_ERROR', 'a quantity parse needs a quantity format', text);
313
+ }
314
+ const scale = contract.scale;
315
+ if (scale === undefined || !Number.isInteger(scale) || scale < 0) {
316
+ throw new AxiomError('ENGINE_ERROR', 'a quantity buffer needs a declared scale', text);
317
+ }
318
+ const decimal = parseDecimalText(text, scale === 0, separators);
319
+ if (decimal.kind !== 'value')
320
+ return decimal;
321
+ if (typeof decimal.value !== 'string') {
322
+ return { kind: 'invalid', reason: 'buffer.decimal.not_canonical' };
323
+ }
324
+ const fraction = decimal.value.split('.')[1] ?? '';
325
+ if (fraction.length > scale) {
326
+ return {
327
+ kind: 'invalid',
328
+ reason: 'buffer.money.scale_exceeded',
329
+ params: { scale },
330
+ };
331
+ }
332
+ return { kind: 'value', value: { value: decimal.value, unit: contract.format.unit } };
333
+ }
334
+ function parsePhoneText(text) {
335
+ if (isE164PhoneNumber(text))
336
+ return { kind: 'value', value: text };
337
+ const digitsOnly = /^\+?[0-9]*$/.test(text);
338
+ if (digitsOnly && text.length <= 16 && (text.length <= 1 || text[1] !== '0')) {
339
+ return { kind: 'partial' };
340
+ }
341
+ return { kind: 'invalid', reason: 'buffer.phone.e164' };
342
+ }
343
+ const PARTIAL_DATE = /^[0-9]{0,4}(?:-[0-9]{0,2}){0,2}$/;
344
+ function parseDateText(text) {
345
+ if (PARTIAL_DATE.test(text)) {
346
+ // A spelling shorter than a full date is a half-typed one: no day is refused yet.
347
+ if (text.length < 10)
348
+ return { kind: 'partial' };
349
+ try {
350
+ return { kind: 'value', value: formatPlainDate(parsePlainDate(text)) };
351
+ }
352
+ catch (error) {
353
+ if (error instanceof AxiomError) {
354
+ // A complete-looking date that names no civil day is a refusal, not a half-typed entry.
355
+ return { kind: 'invalid', reason: 'buffer.date.nonexistent_day' };
356
+ }
357
+ throw error;
358
+ }
359
+ }
360
+ return { kind: 'invalid', reason: 'buffer.date.format' };
361
+ }
362
+ function isMoney(value) {
363
+ return isRecord(value) && typeof value['minor'] === 'string';
364
+ }
365
+ /** Canonical decimal text in the contract's grouping and decimal marks. */
366
+ function printDecimalText(raw, contract) {
367
+ const negative = raw.startsWith('-');
368
+ const unsigned = negative ? raw.slice(1) : raw;
369
+ const point = unsigned.indexOf('.');
370
+ const whole = point === -1 ? unsigned : unsigned.slice(0, point);
371
+ const fraction = point === -1 ? '' : unsigned.slice(point + 1);
372
+ const marks = contract.separators ?? DEFAULT_SEPARATORS;
373
+ const grouped = groupDigits(whole, marks.group, marks.minimumGroupingDigits ?? 1);
374
+ return `${negative ? '-' : ''}${grouped}${fraction === '' ? '' : `${marks.decimal}${fraction}`}`;
375
+ }
376
+ /** The amount member of a committed quantity, in the locale's grouping and decimal punctuation. */
377
+ function printQuantity(value, contract) {
378
+ if (!isRecord(value))
379
+ return '';
380
+ const amount = value['value'];
381
+ if (typeof amount !== 'string')
382
+ return '';
383
+ return printDecimalText(amount, contract);
384
+ }
385
+ /** `minor` rendered at the field's declared scale: `120000` at scale 2 is `1200.00`. */
386
+ function printMoney(value, contract) {
387
+ const scale = contract.scale;
388
+ if (scale === undefined || !Number.isInteger(scale) || scale < 0)
389
+ return '';
390
+ const negative = value.minor.startsWith('-');
391
+ const digits = stripLeadingZeros(negative ? value.minor.slice(1) : value.minor).padStart(scale + 1, '0');
392
+ const whole = digits.slice(0, digits.length - scale);
393
+ const marks = contract.separators ?? DEFAULT_SEPARATORS;
394
+ const fraction = scale === 0 ? '' : `${marks.decimal}${digits.slice(digits.length - scale)}`;
395
+ return `${negative && digits.replaceAll('0', '') !== '' ? '-' : ''}${groupDigits(whole, marks.group, marks.minimumGroupingDigits ?? 1)}${fraction}`;
396
+ }
397
+ /**
398
+ * A digit run grouped from the right once it reaches the locale's minimum grouping width.
399
+ *
400
+ * The scale fixes the fraction; the group mark and minimum grouping threshold are the locale's,
401
+ * and the value the record holds is still canonical text with no separators. Parsing removes the
402
+ * same groups (`ungroupDigits`), so printing and reading one amount are inverses.
403
+ */
404
+ function groupDigits(digits, group, minimumGroupingDigits = 1) {
405
+ if (group === '' || digits.length < 3 + minimumGroupingDigits)
406
+ return digits;
407
+ let grouped = '';
408
+ for (let end = digits.length; end > 0; end -= 3) {
409
+ const start = Math.max(0, end - 3);
410
+ const part = digits.slice(start, end);
411
+ grouped = grouped === '' ? part : `${part}${group}${grouped}`;
412
+ }
413
+ return grouped;
414
+ }
415
+ //# sourceMappingURL=parse-print.js.map