@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.
- package/LICENSE +21 -0
- package/README.md +604 -2
- package/dist/FormErrorBoundary.d.ts +37 -0
- package/dist/FormErrorBoundary.d.ts.map +1 -0
- package/dist/FormErrorBoundary.js +54 -0
- package/dist/FormErrorBoundary.js.map +1 -0
- package/dist/FormProvider.d.ts +197 -0
- package/dist/FormProvider.d.ts.map +1 -0
- package/dist/FormProvider.js +149 -0
- package/dist/FormProvider.js.map +1 -0
- package/dist/field-error.d.ts +154 -0
- package/dist/field-error.d.ts.map +1 -0
- package/dist/field-error.js +2 -0
- package/dist/field-error.js.map +1 -0
- package/dist/field-props.d.ts +362 -0
- package/dist/field-props.d.ts.map +1 -0
- package/dist/field-props.js +64 -0
- package/dist/field-props.js.map +1 -0
- package/dist/form-context.d.ts +31 -0
- package/dist/form-context.d.ts.map +1 -0
- package/dist/form-context.js +13 -0
- package/dist/form-context.js.map +1 -0
- package/dist/form-store.d.ts +784 -0
- package/dist/form-store.d.ts.map +1 -0
- package/dist/form-store.js +2179 -0
- package/dist/form-store.js.map +1 -0
- package/dist/hints.d.ts +60 -0
- package/dist/hints.d.ts.map +1 -0
- package/dist/hints.js +158 -0
- package/dist/hints.js.map +1 -0
- package/dist/index.d.ts +57 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +36 -0
- package/dist/index.js.map +1 -0
- package/dist/render/field-value.d.ts +92 -0
- package/dist/render/field-value.d.ts.map +1 -0
- package/dist/render/field-value.js +124 -0
- package/dist/render/field-value.js.map +1 -0
- package/dist/render/nodes.d.ts +303 -0
- package/dist/render/nodes.d.ts.map +1 -0
- package/dist/render/nodes.js +325 -0
- package/dist/render/nodes.js.map +1 -0
- package/dist/render/schema.d.ts +30 -0
- package/dist/render/schema.d.ts.map +1 -0
- package/dist/render/schema.js +40 -0
- package/dist/render/schema.js.map +1 -0
- package/dist/render/value-text.d.ts +59 -0
- package/dist/render/value-text.d.ts.map +1 -0
- package/dist/render/value-text.js +104 -0
- package/dist/render/value-text.js.map +1 -0
- package/dist/store/array-bindings.d.ts +110 -0
- package/dist/store/array-bindings.d.ts.map +1 -0
- package/dist/store/array-bindings.js +181 -0
- package/dist/store/array-bindings.js.map +1 -0
- package/dist/store/bindings.d.ts +12 -0
- package/dist/store/bindings.d.ts.map +1 -0
- package/dist/store/bindings.js +16 -0
- package/dist/store/bindings.js.map +1 -0
- package/dist/store/buffer-state.d.ts +42 -0
- package/dist/store/buffer-state.d.ts.map +1 -0
- package/dist/store/buffer-state.js +51 -0
- package/dist/store/buffer-state.js.map +1 -0
- package/dist/store/configure.d.ts +19 -0
- package/dist/store/configure.d.ts.map +1 -0
- package/dist/store/configure.js +28 -0
- package/dist/store/configure.js.map +1 -0
- package/dist/store/derive.d.ts +106 -0
- package/dist/store/derive.d.ts.map +1 -0
- package/dist/store/derive.js +417 -0
- package/dist/store/derive.js.map +1 -0
- package/dist/store/errors.d.ts +20 -0
- package/dist/store/errors.d.ts.map +1 -0
- package/dist/store/errors.js +101 -0
- package/dist/store/errors.js.map +1 -0
- package/dist/store/fields.d.ts +35 -0
- package/dist/store/fields.d.ts.map +1 -0
- package/dist/store/fields.js +81 -0
- package/dist/store/fields.js.map +1 -0
- package/dist/store/form-channel.d.ts +174 -0
- package/dist/store/form-channel.d.ts.map +1 -0
- package/dist/store/form-channel.js +411 -0
- package/dist/store/form-channel.js.map +1 -0
- package/dist/store/gates.d.ts +22 -0
- package/dist/store/gates.d.ts.map +1 -0
- package/dist/store/gates.js +44 -0
- package/dist/store/gates.js.map +1 -0
- package/dist/store/ids.d.ts +20 -0
- package/dist/store/ids.d.ts.map +1 -0
- package/dist/store/ids.js +28 -0
- package/dist/store/ids.js.map +1 -0
- package/dist/store/inputs.d.ts +114 -0
- package/dist/store/inputs.d.ts.map +1 -0
- package/dist/store/inputs.js +202 -0
- package/dist/store/inputs.js.map +1 -0
- package/dist/store/layout.d.ts +81 -0
- package/dist/store/layout.d.ts.map +1 -0
- package/dist/store/layout.js +285 -0
- package/dist/store/layout.js.map +1 -0
- package/dist/store/messages.d.ts +56 -0
- package/dist/store/messages.d.ts.map +1 -0
- package/dist/store/messages.js +157 -0
- package/dist/store/messages.js.map +1 -0
- package/dist/store/option-pages.d.ts +193 -0
- package/dist/store/option-pages.d.ts.map +1 -0
- package/dist/store/option-pages.js +598 -0
- package/dist/store/option-pages.js.map +1 -0
- package/dist/store/parse-print.d.ts +105 -0
- package/dist/store/parse-print.d.ts.map +1 -0
- package/dist/store/parse-print.js +415 -0
- package/dist/store/parse-print.js.map +1 -0
- package/dist/store/proposals.d.ts +114 -0
- package/dist/store/proposals.d.ts.map +1 -0
- package/dist/store/proposals.js +90 -0
- package/dist/store/proposals.js.map +1 -0
- package/dist/store/publish.d.ts +48 -0
- package/dist/store/publish.d.ts.map +1 -0
- package/dist/store/publish.js +96 -0
- package/dist/store/publish.js.map +1 -0
- package/dist/store/snapshots.d.ts +63 -0
- package/dist/store/snapshots.d.ts.map +1 -0
- package/dist/store/snapshots.js +154 -0
- package/dist/store/snapshots.js.map +1 -0
- package/dist/store/steps.d.ts +13 -0
- package/dist/store/steps.d.ts.map +1 -0
- package/dist/store/steps.js +31 -0
- package/dist/store/steps.js.map +1 -0
- package/dist/store/view.d.ts +124 -0
- package/dist/store/view.d.ts.map +1 -0
- package/dist/store/view.js +301 -0
- package/dist/store/view.js.map +1 -0
- package/dist/store/visibility.d.ts +68 -0
- package/dist/store/visibility.d.ts.map +1 -0
- package/dist/store/visibility.js +231 -0
- package/dist/store/visibility.js.map +1 -0
- package/dist/store/wizard-cursor.d.ts +43 -0
- package/dist/store/wizard-cursor.d.ts.map +1 -0
- package/dist/store/wizard-cursor.js +67 -0
- package/dist/store/wizard-cursor.js.map +1 -0
- package/dist/store/writes.d.ts +50 -0
- package/dist/store/writes.d.ts.map +1 -0
- package/dist/store/writes.js +91 -0
- package/dist/store/writes.js.map +1 -0
- package/dist/typed.d.ts +134 -0
- package/dist/typed.d.ts.map +1 -0
- package/dist/typed.js +74 -0
- package/dist/typed.js.map +1 -0
- package/dist/useAsyncOptions.d.ts +20 -0
- package/dist/useAsyncOptions.d.ts.map +1 -0
- package/dist/useAsyncOptions.js +70 -0
- package/dist/useAsyncOptions.js.map +1 -0
- package/dist/useBufferedInput.d.ts +69 -0
- package/dist/useBufferedInput.d.ts.map +1 -0
- package/dist/useBufferedInput.js +132 -0
- package/dist/useBufferedInput.js.map +1 -0
- package/dist/useField.d.ts +42 -0
- package/dist/useField.d.ts.map +1 -0
- package/dist/useField.js +63 -0
- package/dist/useField.js.map +1 -0
- package/dist/useFieldArray.d.ts +25 -0
- package/dist/useFieldArray.d.ts.map +1 -0
- package/dist/useFieldArray.js +18 -0
- package/dist/useFieldArray.js.map +1 -0
- package/dist/useForm.d.ts +20 -0
- package/dist/useForm.d.ts.map +1 -0
- package/dist/useForm.js +9 -0
- package/dist/useForm.js.map +1 -0
- package/dist/useFormState.d.ts +23 -0
- package/dist/useFormState.d.ts.map +1 -0
- package/dist/useFormState.js +11 -0
- package/dist/useFormState.js.map +1 -0
- package/dist/useGate.d.ts +15 -0
- package/dist/useGate.d.ts.map +1 -0
- package/dist/useGate.js +21 -0
- package/dist/useGate.js.map +1 -0
- package/dist/useLayout.d.ts +29 -0
- package/dist/useLayout.d.ts.map +1 -0
- package/dist/useLayout.js +59 -0
- package/dist/useLayout.js.map +1 -0
- package/dist/useMessage.d.ts +58 -0
- package/dist/useMessage.d.ts.map +1 -0
- package/dist/useMessage.js +62 -0
- package/dist/useMessage.js.map +1 -0
- package/dist/useWatch.d.ts +19 -0
- package/dist/useWatch.d.ts.map +1 -0
- package/dist/useWatch.js +17 -0
- package/dist/useWatch.js.map +1 -0
- package/dist/useWizard.d.ts +166 -0
- package/dist/useWizard.d.ts.map +1 -0
- package/dist/useWizard.js +554 -0
- package/dist/useWizard.js.map +1 -0
- package/package.json +62 -3
|
@@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gB,KAAK,SAAS;QAAE,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC;IAC9E,IAAI,MAAM,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAC3C,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,CAAC;AAC1C,CAAC;AAED,uFAAuF;AACvF,SAAS,WAAW,CAAC,MAAc,EAAE,GAAa;IAChD,IAAI,CAAC;QACH,OAAO,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAClD,CAAC;IAAC,MAAM,CAAC;QACP,4FAA4F;QAC5F,6FAA6F;QAC7F,kFAAkF;QAClF,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC;AAED,gFAAgF;AAChF,SAAS,YAAY,CAAC,KAAuB;IAC3C,OAAO,CACL,KAAK,CAAC,KAAK,CAAC,IAAI,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,KAAK,OAAO,IAAI,KAAK,CAAC,KAAK,CAAC,KAAK,KAAK,IAAI,CAAC,CAC9F,CAAC;AACJ,CAAC;AAED,sEAAsE;AACtE,MAAM,UAAU,SAAS,CAAC,IAAyB,EAAE,KAA0B;IAC7E,IAAI,IAAI,KAAK,KAAK;QAAE,OAAO,IAAI,CAAC;IAChC,IAAI,IAAI,CAAC,IAAI,KAAK,KAAK,CAAC,IAAI;QAAE,OAAO,KAAK,CAAC;IAC3C,KAAK,MAAM,KAAK,IAAI,IAAI;QAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC;YAAE,OAAO,KAAK,CAAC;IAC9D,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import type { Engine, EngineFieldState, FieldRef } from '@azx-pbc/axiom-runtime';\nimport type { FieldError } from '../field-error.js';\nimport { bindingKey } from './bindings.js';\nimport { bindingErrors } from './errors.js';\nimport type { BindingView } from './derive.js';\nimport type { FieldFacts } from './fields.js';\n\n/**\n * When a control reveals the failures the engine already decided.\n *\n * The engine evaluates on every pass in every policy; this decides only what is painted. A policy\n * is presentation and never a verdict: `BLOCKED` stays `BLOCKED` while its reasons are still\n * hidden, and a submission is refused by the same `verdict` the engine computed.\n */\nexport type ShowErrorsPolicy =\n /** A failure appears once the user has visited this binding and no operand is still unanswered. */\n | 'touched'\n /** Every decided failure is painted as soon as the engine states it. */\n | 'always'\n /** Nothing is painted until a submission is attempted; afterwards everything is. */\n | 'submit';\n\n/** The policy a provider that does not state one uses. */\nexport const DEFAULT_POLICY: ShowErrorsPolicy = 'touched';\n\n/** The empty set every binding without a missing operand shares, so identity is stable. */\nconst EMPTY: ReadonlySet<string> = Object.freeze(new Set<string>());\n\n/**\n * What one binding's visibility derivation needs besides the engine's own state.\n *\n * `incompleteRules` names the rules on this binding that read an operand the user has not\n * supplied; `revealedErrors` is the sticky set of failures this binding has already painted.\n * Both are precomputed because they depend on other bindings and on session history, and both\n * are carried by identity so an unchanged answer does not replace the published props.\n */\nexport interface BindingVisibility {\n readonly incompleteRules: ReadonlySet<string>;\n readonly revealedErrors: ReadonlySet<string>;\n}\n\n/** The visibility of a binding with nothing missing and nothing revealed yet. */\nexport const NO_VISIBILITY: BindingVisibility = Object.freeze({\n incompleteRules: EMPTY,\n revealedErrors: EMPTY,\n});\n\n/**\n * The stable identity of one failure inside a binding.\n *\n * It is the reason, not the whole state: two decisions of the same rule name the same failure,\n * so a sticky reveal survives a new parameter value while the failure itself holds. A corrected\n * failure removes the key, which is what lets a later, different failure be judged afresh.\n */\nexport function errorKey(error: FieldError): string {\n switch (error.kind) {\n case 'validate':\n case 'deferred':\n return `${error.kind}:${error.ruleId}:${error.messageKey}`;\n case 'required':\n return `required:${error.fieldId}@${String(error.rowKey ?? '')}`;\n case 'cardinality':\n return `cardinality:${error.bound}`;\n case 'invalid-value':\n return `invalid-value:${error.code}`;\n case 'access':\n return `access:${error.access}`;\n case 'gate':\n return `gate:${error.gateId}:${error.itemId}:${error.messageKey}`;\n case 'screen':\n return `screen:${error.screenId}:${error.outcome}`;\n case 'row-key':\n return `row-key:${error.code}:${String(error.rowKey)}`;\n }\n}\n\n/**\n * Whether this failure is hidden because the user has not supplied what the rule reads.\n *\n * A rule whose answer is `UNKNOWN` or `DEFERRED` is undecided, not failed: the engine already\n * declines to call it blocking, and naming it would state an outcome no pass reached. A decided\n * failure is still incomplete when a field it reads is empty and untouched — the message would\n * accuse the user of a fact they have not had the chance to supply.\n */\nfunction isIncomplete(error: FieldError, visibility: BindingVisibility): boolean {\n if (error.kind !== 'validate') return false;\n if (error.status !== 'FAIL') return true;\n return visibility.incompleteRules.has(error.ruleId);\n}\n\n/** Whether a decided blocking failure is old enough to paint under this binding's policy. */\nfunction revealGate(\n error: FieldError,\n view: BindingView,\n policy: ShowErrorsPolicy,\n visibility: BindingVisibility,\n): boolean {\n switch (policy) {\n case 'always':\n return true;\n case 'submit':\n return view.submitted || visibility.revealedErrors.has(errorKey(error));\n case 'touched':\n // A failure already painted stays painted until it is corrected (it is no longer in the\n // list then) or the session is reset. Without that, clearing a sibling operand would make\n // a sentence the user already saw disappear and reappear around their next keystroke.\n return (\n visibility.revealedErrors.has(errorKey(error)) ||\n (view.touched && !isIncomplete(error, visibility))\n );\n }\n}\n\n/**\n * The failures one control paints, in artifact order.\n *\n * This is the presentation list, not the engine's fact list: `FieldProps.errors` keeps stating\n * every reason the record has, while this states the reasons the user is being told about now.\n * A hidden binding paints nothing. A refused entry answers something the user just did and is\n * shown immediately; a warning is informational and is not deferred by the policy; access\n * diagnostics and undecided checks are never failures a control announces.\n */\nexport function visibleErrorsOf(\n state: EngineFieldState,\n view: BindingView,\n policy: ShowErrorsPolicy,\n visibility: BindingVisibility,\n): readonly FieldError[] {\n if (!state.visible) return EMPTY_ERRORS;\n const engineErrors = bindingErrors(state);\n const visible: FieldError[] = [];\n for (const error of engineErrors.errors) {\n switch (error.kind) {\n case 'access':\n case 'deferred':\n break;\n case 'validate':\n // A status other than `FAIL` is an open question, not a failure. A warning is shown as\n // soon as it exists: it is a note, not an accusation, and hiding it until the user\n // touches the field would lose information they may act on before editing.\n if (error.status !== 'FAIL') break;\n if (error.severity === 'warn' || revealGate(error, view, policy, visibility)) {\n visible.push(error);\n }\n break;\n case 'required':\n case 'cardinality':\n case 'invalid-value':\n if (revealGate(error, view, policy, visibility)) visible.push(error);\n break;\n case 'gate':\n case 'screen':\n case 'row-key':\n // Gate and screen reasons are form-level and the summary states them; a refused entry\n // is appended below from the session, because it is not an engine fact.\n break;\n }\n }\n if (view.refusal !== undefined) visible.push(view.refusal);\n return visible.length === 0 ? EMPTY_ERRORS : Object.freeze(visible);\n}\n\n/** A stable empty list, so a binding with nothing to paint keeps its props identity. */\nconst EMPTY_ERRORS: readonly FieldError[] = Object.freeze([]);\n\n/** Whether any painted failure makes the control announce itself as invalid. */\nexport function showsErrorOf(visible: readonly FieldError[]): boolean {\n return visible.some((error) => error.blocking || error.kind === 'row-key');\n}\n\n/** The rule ids on one binding whose operands are not all supplied.\n *\n * A rule is incomplete when its own answer is not `FAIL` (`UNKNOWN`/`DEFERRED`) or when it reads\n * a field that holds no value and that the user has neither visited nor written. Absence is the\n * same empty the record contract states: `absent`, or the authored `null`. A computed value is\n * never a question for the user, and a read this derivation cannot address (a row member read\n * by a field-scope rule) is not treated as missing rather than guessed at.\n */\nexport function incompleteRulesOf(\n engine: Engine,\n facts: ReadonlyMap<string, FieldFacts>,\n ruleReads: ReadonlyMap<string, readonly FieldRef[]>,\n state: EngineFieldState,\n rowKey: string | number | undefined,\n isAnswered: (key: string) => boolean,\n): ReadonlySet<string> {\n if (state.messages.length === 0) return EMPTY;\n let incomplete: Set<string> | undefined;\n for (const message of state.messages) {\n const ruleId = message.ruleId;\n if (message.status !== 'FAIL') {\n incomplete ??= new Set<string>();\n incomplete.add(ruleId);\n continue;\n }\n const reads = ruleReads.get(ruleId);\n if (reads === undefined) continue;\n for (const read of reads) {\n const ref = readRefOf(read.fieldId, rowKey, facts);\n if (ref === undefined) continue;\n if (isAnswered(bindingKey(ref.fieldId, ref.rowKey))) continue;\n const readState = readStateOf(engine, ref);\n if (readState === undefined) continue;\n // A writer owns a computed value: its absence is an answer the device produced, not a\n // question the user has been asked, so it is never \"not supplied yet\".\n if (readState.systemComputed) continue;\n if (!isEmptyValue(readState)) continue;\n incomplete ??= new Set<string>();\n incomplete.add(ruleId);\n break;\n }\n }\n return incomplete === undefined ? EMPTY : incomplete;\n}\n\n/** Whether one rule's operands are complete, from the rule id a summary blocker names. */\nexport function ruleBlockComplete(\n engine: Engine,\n facts: ReadonlyMap<string, FieldFacts>,\n ruleReads: ReadonlyMap<string, readonly FieldRef[]>,\n ruleId: string,\n isAnswered: (key: string) => boolean,\n): boolean {\n const reads = ruleReads.get(ruleId);\n if (reads === undefined) return true;\n for (const read of reads) {\n const ref = readRefOf(read.fieldId, undefined, facts);\n if (ref === undefined) continue;\n if (isAnswered(bindingKey(ref.fieldId, ref.rowKey))) continue;\n const readState = readStateOf(engine, ref);\n if (readState === undefined || readState.systemComputed) continue;\n if (!isEmptyValue(readState)) continue;\n return false;\n }\n return true;\n}\n\n/**\n * The binding a read names.\n *\n * A read of a member is per row, so it follows the row the message belongs to. A read of an item\n * member from a field-scope rule has no row to follow and is left unresolved; a container read is\n * always the field itself, even inside an item rule.\n */\nfunction readRefOf(\n readFieldId: string,\n rowKey: string | number | undefined,\n facts: ReadonlyMap<string, FieldFacts>,\n): FieldRef | undefined {\n const readFacts = facts.get(readFieldId);\n if (readFacts === undefined) return undefined;\n if (readFacts.arrayContainerId === undefined) return { fieldId: readFieldId };\n if (rowKey === undefined) return undefined;\n return { fieldId: readFieldId, rowKey };\n}\n\n/** One binding's state, or `undefined` when committed state no longer addresses it. */\nfunction readStateOf(engine: Engine, ref: FieldRef): EngineFieldState | undefined {\n try {\n return engine.getField(ref.fieldId, ref.rowKey);\n } catch {\n // A row that commits after the message was derived is a read this derivation cannot answer.\n // Treating it as absent would suppress a failure; treating it as present leaves the engine's\n // verdict untouched. The latter is the only safe reading for a presentation gate.\n return undefined;\n }\n}\n\n/** `empty()` semantics for a state: an absence, or the authored empty value. */\nfunction isEmptyValue(state: EngineFieldState): boolean {\n return (\n state.value.kind === 'absent' || (state.value.kind === 'value' && state.value.value === null)\n );\n}\n\n/** Whether one set of rule ids states the same members as another. */\nexport function sameIdSet(left: ReadonlySet<string>, right: ReadonlySet<string>): boolean {\n if (left === right) return true;\n if (left.size !== right.size) return false;\n for (const value of left) if (!right.has(value)) return false;\n return true;\n}\n"]}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One wizard cursor per form session, shared by every `useWizard` caller.
|
|
3
|
+
*
|
|
4
|
+
* A cursor is session state, like the values a control writes: two components that ask the
|
|
5
|
+
* provider for it must see one step, one history and one answer about whether the page may be
|
|
6
|
+
* left. The store keeps the form's values; this keeps the navigation the form's record does not
|
|
7
|
+
* carry, and it notifies `useSyncExternalStore` consumers only when the cursor or its visited
|
|
8
|
+
* history actually moved.
|
|
9
|
+
*/
|
|
10
|
+
/** The cursor's own facts: the step the host asked for, and the pages it has reached. */
|
|
11
|
+
export interface WizardCursorState {
|
|
12
|
+
readonly chosen: string | undefined;
|
|
13
|
+
readonly visited: ReadonlySet<string>;
|
|
14
|
+
}
|
|
15
|
+
/** One more visited page, with the same set when it was already in the history. */
|
|
16
|
+
export declare function visitedWith(visited: ReadonlySet<string>, stepId: string | undefined): ReadonlySet<string>;
|
|
17
|
+
/** A session's wizard cursor: one mutable state behind a subscription, never per hook call. */
|
|
18
|
+
export declare class WizardCursor {
|
|
19
|
+
private state;
|
|
20
|
+
private readonly listeners;
|
|
21
|
+
constructor(initialStepId?: string);
|
|
22
|
+
/** The published state; the same object until a move changes the cursor or its history. */
|
|
23
|
+
readonly getSnapshot: () => WizardCursorState;
|
|
24
|
+
/** Subscribes one consumer to cursor changes, which are the only updates this store has. */
|
|
25
|
+
readonly subscribe: (listener: () => void) => (() => void);
|
|
26
|
+
/**
|
|
27
|
+
* Seeds the session's starting step once, before any caller or move has placed the cursor.
|
|
28
|
+
*
|
|
29
|
+
* Because one cursor serves every `useWizard` caller in the provider, only the first seed
|
|
30
|
+
* takes effect: once the cursor has a chosen step, later seeds are ignored so callers cannot
|
|
31
|
+
* split one session onto two steps.
|
|
32
|
+
*/
|
|
33
|
+
seed(stepId: string): void;
|
|
34
|
+
/**
|
|
35
|
+
* Applies one pure move.
|
|
36
|
+
*
|
|
37
|
+
* The updater runs against the current state, so two calls in one event advance from the
|
|
38
|
+
* first call's answer rather than both reading the render they started in. It returns the
|
|
39
|
+
* state it was given when nothing moved, and no listener is woken then.
|
|
40
|
+
*/
|
|
41
|
+
update(updater: (state: WizardCursorState) => WizardCursorState): void;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=wizard-cursor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wizard-cursor.d.ts","sourceRoot":"","sources":["../../src/store/wizard-cursor.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,yFAAyF;AACzF,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;CACvC;AAKD,mFAAmF;AACnF,wBAAgB,WAAW,CACzB,OAAO,EAAE,WAAW,CAAC,MAAM,CAAC,EAC5B,MAAM,EAAE,MAAM,GAAG,SAAS,GACzB,WAAW,CAAC,MAAM,CAAC,CAGrB;AAED,+FAA+F;AAC/F,qBAAa,YAAY;IACvB,OAAO,CAAC,KAAK,CAAoB;IACjC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAyB;IAEnD,YAAY,aAAa,CAAC,EAAE,MAAM,EAKjC;IAED,2FAA2F;IAC3F,QAAQ,CAAC,WAAW,QAAO,iBAAiB,CAAe;IAE3D,4FAA4F;IAC5F,QAAQ,CAAC,SAAS,aAAc,MAAM,IAAI,KAAG,CAAC,MAAM,IAAI,CAAC,CAKvD;IAEF;;;;;;OAMG;IACH,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAIzB;IAED;;;;;;OAMG;IACH,MAAM,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,iBAAiB,KAAK,iBAAiB,GAAG,IAAI,CAKrE;CACF"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One wizard cursor per form session, shared by every `useWizard` caller.
|
|
3
|
+
*
|
|
4
|
+
* A cursor is session state, like the values a control writes: two components that ask the
|
|
5
|
+
* provider for it must see one step, one history and one answer about whether the page may be
|
|
6
|
+
* left. The store keeps the form's values; this keeps the navigation the form's record does not
|
|
7
|
+
* carry, and it notifies `useSyncExternalStore` consumers only when the cursor or its visited
|
|
8
|
+
* history actually moved.
|
|
9
|
+
*/
|
|
10
|
+
/** The empty history, one identity so a fresh cursor shares it. */
|
|
11
|
+
const EMPTY_VISITED = Object.freeze(new Set());
|
|
12
|
+
/** One more visited page, with the same set when it was already in the history. */
|
|
13
|
+
export function visitedWith(visited, stepId) {
|
|
14
|
+
if (stepId === undefined || visited.has(stepId))
|
|
15
|
+
return visited;
|
|
16
|
+
return new Set([...visited, stepId]);
|
|
17
|
+
}
|
|
18
|
+
/** A session's wizard cursor: one mutable state behind a subscription, never per hook call. */
|
|
19
|
+
export class WizardCursor {
|
|
20
|
+
state;
|
|
21
|
+
listeners = new Set();
|
|
22
|
+
constructor(initialStepId) {
|
|
23
|
+
this.state = Object.freeze({
|
|
24
|
+
chosen: initialStepId,
|
|
25
|
+
visited: EMPTY_VISITED,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
/** The published state; the same object until a move changes the cursor or its history. */
|
|
29
|
+
getSnapshot = () => this.state;
|
|
30
|
+
/** Subscribes one consumer to cursor changes, which are the only updates this store has. */
|
|
31
|
+
subscribe = (listener) => {
|
|
32
|
+
this.listeners.add(listener);
|
|
33
|
+
return () => {
|
|
34
|
+
this.listeners.delete(listener);
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Seeds the session's starting step once, before any caller or move has placed the cursor.
|
|
39
|
+
*
|
|
40
|
+
* Because one cursor serves every `useWizard` caller in the provider, only the first seed
|
|
41
|
+
* takes effect: once the cursor has a chosen step, later seeds are ignored so callers cannot
|
|
42
|
+
* split one session onto two steps.
|
|
43
|
+
*/
|
|
44
|
+
seed(stepId) {
|
|
45
|
+
if (this.state.chosen !== undefined)
|
|
46
|
+
return;
|
|
47
|
+
this.state = Object.freeze({ chosen: stepId, visited: this.state.visited });
|
|
48
|
+
for (const listener of this.listeners)
|
|
49
|
+
listener();
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Applies one pure move.
|
|
53
|
+
*
|
|
54
|
+
* The updater runs against the current state, so two calls in one event advance from the
|
|
55
|
+
* first call's answer rather than both reading the render they started in. It returns the
|
|
56
|
+
* state it was given when nothing moved, and no listener is woken then.
|
|
57
|
+
*/
|
|
58
|
+
update(updater) {
|
|
59
|
+
const next = updater(this.state);
|
|
60
|
+
if (next === this.state)
|
|
61
|
+
return;
|
|
62
|
+
this.state = next;
|
|
63
|
+
for (const listener of this.listeners)
|
|
64
|
+
listener();
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=wizard-cursor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wizard-cursor.js","sourceRoot":"","sources":["../../src/store/wizard-cursor.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAQH,mEAAmE;AACnE,MAAM,aAAa,GAAwB,MAAM,CAAC,MAAM,CAAC,IAAI,GAAG,EAAU,CAAC,CAAC;AAE5E,mFAAmF;AACnF,MAAM,UAAU,WAAW,CACzB,OAA4B,EAC5B,MAA0B;IAE1B,IAAI,MAAM,KAAK,SAAS,IAAI,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC;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B,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,SAAS;YAAE,QAAQ,EAAE,CAAC;IACpD,CAAC;CACF","sourcesContent":["/**\n * One wizard cursor per form session, shared by every `useWizard` caller.\n *\n * A cursor is session state, like the values a control writes: two components that ask the\n * provider for it must see one step, one history and one answer about whether the page may be\n * left. The store keeps the form's values; this keeps the navigation the form's record does not\n * carry, and it notifies `useSyncExternalStore` consumers only when the cursor or its visited\n * history actually moved.\n */\n\n/** The cursor's own facts: the step the host asked for, and the pages it has reached. */\nexport interface WizardCursorState {\n readonly chosen: string | undefined;\n readonly visited: ReadonlySet<string>;\n}\n\n/** The empty history, one identity so a fresh cursor shares it. */\nconst EMPTY_VISITED: ReadonlySet<string> = Object.freeze(new Set<string>());\n\n/** One more visited page, with the same set when it was already in the history. */\nexport function visitedWith(\n visited: ReadonlySet<string>,\n stepId: string | undefined,\n): ReadonlySet<string> {\n if (stepId === undefined || visited.has(stepId)) return visited;\n return new Set([...visited, stepId]);\n}\n\n/** A session's wizard cursor: one mutable state behind a subscription, never per hook call. */\nexport class WizardCursor {\n private state: WizardCursorState;\n private readonly listeners = new Set<() => void>();\n\n constructor(initialStepId?: string) {\n this.state = Object.freeze({\n chosen: initialStepId,\n visited: EMPTY_VISITED,\n });\n }\n\n /** The published state; the same object until a move changes the cursor or its history. */\n readonly getSnapshot = (): WizardCursorState => this.state;\n\n /** Subscribes one consumer to cursor changes, which are the only updates this store has. */\n readonly subscribe = (listener: () => void): (() => void) => {\n this.listeners.add(listener);\n return () => {\n this.listeners.delete(listener);\n };\n };\n\n /**\n * Seeds the session's starting step once, before any caller or move has placed the cursor.\n *\n * Because one cursor serves every `useWizard` caller in the provider, only the first seed\n * takes effect: once the cursor has a chosen step, later seeds are ignored so callers cannot\n * split one session onto two steps.\n */\n seed(stepId: string): void {\n if (this.state.chosen !== undefined) return;\n this.state = Object.freeze({ chosen: stepId, visited: this.state.visited });\n for (const listener of this.listeners) listener();\n }\n\n /**\n * Applies one pure move.\n *\n * The updater runs against the current state, so two calls in one event advance from the\n * first call's answer rather than both reading the render they started in. It returns the\n * state it was given when nothing moved, and no listener is woken then.\n */\n update(updater: (state: WizardCursorState) => WizardCursorState): void {\n const next = updater(this.state);\n if (next === this.state) return;\n this.state = next;\n for (const listener of this.listeners) listener();\n }\n}\n"]}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { SessionRefusal, WireDeclaration } from '@azx-pbc/axiom-runtime';
|
|
2
|
+
import type { BindingWriters } from './derive.js';
|
|
3
|
+
import type { FieldFacts } from './fields.js';
|
|
4
|
+
/**
|
|
5
|
+
* The declaration one binding's value is read against.
|
|
6
|
+
*
|
|
7
|
+
* A field is read against its own declaration, a member of a row against the member's, and a
|
|
8
|
+
* row of an array against the array's item domain — the same domain the engine validates the
|
|
9
|
+
* write with. Reading it here keeps the parse that refuses a half-typed decimal on the side
|
|
10
|
+
* that holds the error, so a refusal carries the message and path the host can act on.
|
|
11
|
+
*/
|
|
12
|
+
export declare function declarationFor(facts: FieldFacts, rowKey: string | number | undefined): WireDeclaration;
|
|
13
|
+
/**
|
|
14
|
+
* The declaration one element of an array is read against: a structural append or insert
|
|
15
|
+
* writes an element, never the container, so the array's item domain is the authority.
|
|
16
|
+
*/
|
|
17
|
+
export declare function itemDeclarationFor(facts: FieldFacts): WireDeclaration;
|
|
18
|
+
/**
|
|
19
|
+
* The error a refused session write is thrown as.
|
|
20
|
+
*
|
|
21
|
+
* A guard refusal keeps its code, so the control that rendered the state and the writer that
|
|
22
|
+
* tried to change it agree about why (`[ACCESS-1.2.4]`). `INVALID_VALUE` is a write code too: a
|
|
23
|
+
* value outside its declaration is the session refusing the write, not a programmer error, and
|
|
24
|
+
* the handle reports it tagged. Every remaining code is a value or an identity the session would
|
|
25
|
+
* not commit — a row key or a basis, not one of the four write codes — and is raised as the
|
|
26
|
+
* runtime's own error naming the code and the reference, because inventing a message for a
|
|
27
|
+
* reason only the session knows would put wording in a layer that does not own it.
|
|
28
|
+
*/
|
|
29
|
+
export declare function writeRefusalError(refusal: SessionRefusal, cause?: unknown): Error;
|
|
30
|
+
/**
|
|
31
|
+
* The stable callbacks one binding is handed.
|
|
32
|
+
*
|
|
33
|
+
* The identity is owned here rather than derived during a render, so a control may pass
|
|
34
|
+
* `setValue` to a memoised child or an effect dependency and never see it change.
|
|
35
|
+
*/
|
|
36
|
+
export declare class FieldWriters {
|
|
37
|
+
private readonly writers;
|
|
38
|
+
/** The same object on every call for one binding key. */
|
|
39
|
+
for(key: string, build: () => BindingWriters): BindingWriters;
|
|
40
|
+
/**
|
|
41
|
+
* Drops one binding's callbacks. A removed row's writers close over its reference; the next
|
|
42
|
+
* control bound at that key builds its own.
|
|
43
|
+
*/
|
|
44
|
+
retire(key: string): void;
|
|
45
|
+
/** How many bindings currently hold callbacks, so a churned list can be counted. */
|
|
46
|
+
retained(): number;
|
|
47
|
+
/** Drops every callback; a reset starts a session whose bindings have written nothing. */
|
|
48
|
+
clear(): void;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=writes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"writes.d.ts","sourceRoot":"","sources":["../../src/store/writes.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC9E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAC5B,KAAK,EAAE,UAAU,EACjB,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,GAClC,eAAe,CAKjB;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,UAAU,GAAG,eAAe,CAQrE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,cAAc,EAAE,KAAK,CAAC,EAAE,OAAO,GAAG,KAAK,CAuBjF;AAED;;;;;GAKG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAqC;IAE7D,yDAAyD;IACzD,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,cAAc,GAAG,cAAc,CAM5D;IAED;;;OAGG;IACH,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAExB;IAED,oFAAoF;IACpF,QAAQ,IAAI,MAAM,CAEjB;IAED,0FAA0F;IAC1F,KAAK,IAAI,IAAI,CAEZ;CACF"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { AxiomError, wireDeclarationOf, WriteRefusedError } from '@azx-pbc/axiom-runtime';
|
|
2
|
+
/**
|
|
3
|
+
* The declaration one binding's value is read against.
|
|
4
|
+
*
|
|
5
|
+
* A field is read against its own declaration, a member of a row against the member's, and a
|
|
6
|
+
* row of an array against the array's item domain — the same domain the engine validates the
|
|
7
|
+
* write with. Reading it here keeps the parse that refuses a half-typed decimal on the side
|
|
8
|
+
* that holds the error, so a refusal carries the message and path the host can act on.
|
|
9
|
+
*/
|
|
10
|
+
export function declarationFor(facts, rowKey) {
|
|
11
|
+
if (rowKey === undefined || facts.arrayContainerId !== undefined) {
|
|
12
|
+
return wireDeclarationOf(facts.field);
|
|
13
|
+
}
|
|
14
|
+
return itemDeclarationFor(facts);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* The declaration one element of an array is read against: a structural append or insert
|
|
18
|
+
* writes an element, never the container, so the array's item domain is the authority.
|
|
19
|
+
*/
|
|
20
|
+
export function itemDeclarationFor(facts) {
|
|
21
|
+
const items = facts.field.items;
|
|
22
|
+
if (items === undefined)
|
|
23
|
+
return { primitive: 'record', fields: facts.field.fields ?? [] };
|
|
24
|
+
return {
|
|
25
|
+
primitive: items.primitive,
|
|
26
|
+
...(items.currency === undefined ? {} : { currency: items.currency }),
|
|
27
|
+
...(items.scale === undefined ? {} : { scale: items.scale }),
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* The error a refused session write is thrown as.
|
|
32
|
+
*
|
|
33
|
+
* A guard refusal keeps its code, so the control that rendered the state and the writer that
|
|
34
|
+
* tried to change it agree about why (`[ACCESS-1.2.4]`). `INVALID_VALUE` is a write code too: a
|
|
35
|
+
* value outside its declaration is the session refusing the write, not a programmer error, and
|
|
36
|
+
* the handle reports it tagged. Every remaining code is a value or an identity the session would
|
|
37
|
+
* not commit — a row key or a basis, not one of the four write codes — and is raised as the
|
|
38
|
+
* runtime's own error naming the code and the reference, because inventing a message for a
|
|
39
|
+
* reason only the session knows would put wording in a layer that does not own it.
|
|
40
|
+
*/
|
|
41
|
+
export function writeRefusalError(refusal, cause) {
|
|
42
|
+
switch (refusal.code) {
|
|
43
|
+
case 'ACCESS_DENIED':
|
|
44
|
+
case 'DISABLED':
|
|
45
|
+
case 'ROW_UNADDRESSABLE':
|
|
46
|
+
case 'INVALID_VALUE':
|
|
47
|
+
return new WriteRefusedError({
|
|
48
|
+
outcome: 'refused',
|
|
49
|
+
code: refusal.code,
|
|
50
|
+
origin: refusal.origin ?? 'user',
|
|
51
|
+
fieldId: refusal.fieldId ?? '',
|
|
52
|
+
...(refusal.rowKey === undefined ? {} : { rowKey: refusal.rowKey }),
|
|
53
|
+
}, cause === undefined ? undefined : { cause });
|
|
54
|
+
default:
|
|
55
|
+
return new AxiomError('ENGINE_ERROR', `the session refused this write with ${refusal.code}`, refusal.path ?? refusal.fieldId ?? '');
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* The stable callbacks one binding is handed.
|
|
60
|
+
*
|
|
61
|
+
* The identity is owned here rather than derived during a render, so a control may pass
|
|
62
|
+
* `setValue` to a memoised child or an effect dependency and never see it change.
|
|
63
|
+
*/
|
|
64
|
+
export class FieldWriters {
|
|
65
|
+
writers = new Map();
|
|
66
|
+
/** The same object on every call for one binding key. */
|
|
67
|
+
for(key, build) {
|
|
68
|
+
const cached = this.writers.get(key);
|
|
69
|
+
if (cached !== undefined)
|
|
70
|
+
return cached;
|
|
71
|
+
const writers = build();
|
|
72
|
+
this.writers.set(key, writers);
|
|
73
|
+
return writers;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Drops one binding's callbacks. A removed row's writers close over its reference; the next
|
|
77
|
+
* control bound at that key builds its own.
|
|
78
|
+
*/
|
|
79
|
+
retire(key) {
|
|
80
|
+
this.writers.delete(key);
|
|
81
|
+
}
|
|
82
|
+
/** How many bindings currently hold callbacks, so a churned list can be counted. */
|
|
83
|
+
retained() {
|
|
84
|
+
return this.writers.size;
|
|
85
|
+
}
|
|
86
|
+
/** Drops every callback; a reset starts a session whose bindings have written nothing. */
|
|
87
|
+
clear() {
|
|
88
|
+
this.writers.clear();
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=writes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"writes.js","sourceRoot":"","sources":["../../src/store/writes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAK1F;;;;;;;GAOG;AACH,MAAM,UAAU,cAAc,CAC5B,KAAiB,EACjB,MAAmC;IAEnC,IAAI,MAAM,KAAK,SAAS,IAAI,KAAK,CAAC,gBAAgB,KAAK,SAAS,EAAE,CAAC;QACjE,OAAO,iBAAiB,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACxC,CAAC;IACD,OAAO,kBAAkB,CAAC,KAAK,CAAC,CAAC;AACnC,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAAiB;IAClD,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC;IAChC,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,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CAAC;AAED;;;;;GAKG;AACH,MAAM,OAAO,YAAY;IACN,OAAO,GAAG,IAAI,GAAG,EAA0B,CAAC;IAE7D,yDAAyD;IACzD,GAAG,CAAC,GAAW,EAAE,KAA2B;QAC1C,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACrC,IAAI,MAAM,KAAK,SAAS;YAAE,OAAO,MAAM,CAAC;QACxC,MAAM,OAAO,GAAG,KAAK,EAAE,CAAC;QACxB,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;QAC/B,OAAO,OAAO,CAAC;IACjB,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,GAAW;QAChB,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAC3B,CAAC;IAED,oFAAoF;IACpF,QAAQ;QACN,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;IAC3B,CAAC;IAED,0FAA0F;IAC1F,KAAK;QACH,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;IACvB,CAAC;CACF","sourcesContent":["import { AxiomError, wireDeclarationOf, WriteRefusedError } from '@azx-pbc/axiom-runtime';\nimport type { SessionRefusal, WireDeclaration } from '@azx-pbc/axiom-runtime';\nimport type { BindingWriters } from './derive.js';\nimport type { FieldFacts } from './fields.js';\n\n/**\n * The declaration one binding's value is read against.\n *\n * A field is read against its own declaration, a member of a row against the member's, and a\n * row of an array against the array's item domain — the same domain the engine validates the\n * write with. Reading it here keeps the parse that refuses a half-typed decimal on the side\n * that holds the error, so a refusal carries the message and path the host can act on.\n */\nexport function declarationFor(\n facts: FieldFacts,\n rowKey: string | number | undefined,\n): WireDeclaration {\n if (rowKey === undefined || facts.arrayContainerId !== undefined) {\n return wireDeclarationOf(facts.field);\n }\n return itemDeclarationFor(facts);\n}\n\n/**\n * The declaration one element of an array is read against: a structural append or insert\n * writes an element, never the container, so the array's item domain is the authority.\n */\nexport function itemDeclarationFor(facts: FieldFacts): WireDeclaration {\n const items = facts.field.items;\n if (items === undefined) return { primitive: 'record', fields: facts.field.fields ?? [] };\n return {\n primitive: items.primitive,\n ...(items.currency === undefined ? {} : { currency: items.currency }),\n ...(items.scale === undefined ? {} : { scale: items.scale }),\n };\n}\n\n/**\n * The error a refused session write is thrown as.\n *\n * A guard refusal keeps its code, so the control that rendered the state and the writer that\n * tried to change it agree about why (`[ACCESS-1.2.4]`). `INVALID_VALUE` is a write code too: a\n * value outside its declaration is the session refusing the write, not a programmer error, and\n * the handle reports it tagged. Every remaining code is a value or an identity the session would\n * not commit — a row key or a basis, not one of the four write codes — and is raised as the\n * runtime's own error naming the code and the reference, because inventing a message for a\n * reason only the session knows would put wording in a layer that does not own it.\n */\nexport function writeRefusalError(refusal: SessionRefusal, cause?: unknown): Error {\n switch (refusal.code) {\n case 'ACCESS_DENIED':\n case 'DISABLED':\n case 'ROW_UNADDRESSABLE':\n case 'INVALID_VALUE':\n return new WriteRefusedError(\n {\n outcome: 'refused',\n code: refusal.code,\n origin: refusal.origin ?? 'user',\n fieldId: refusal.fieldId ?? '',\n ...(refusal.rowKey === undefined ? {} : { rowKey: refusal.rowKey }),\n },\n cause === undefined ? undefined : { cause },\n );\n default:\n return new AxiomError(\n 'ENGINE_ERROR',\n `the session refused this write with ${refusal.code}`,\n refusal.path ?? refusal.fieldId ?? '',\n );\n }\n}\n\n/**\n * The stable callbacks one binding is handed.\n *\n * The identity is owned here rather than derived during a render, so a control may pass\n * `setValue` to a memoised child or an effect dependency and never see it change.\n */\nexport class FieldWriters {\n private readonly writers = new Map<string, BindingWriters>();\n\n /** The same object on every call for one binding key. */\n for(key: string, build: () => BindingWriters): BindingWriters {\n const cached = this.writers.get(key);\n if (cached !== undefined) return cached;\n const writers = build();\n this.writers.set(key, writers);\n return writers;\n }\n\n /**\n * Drops one binding's callbacks. A removed row's writers close over its reference; the next\n * control bound at that key builds its own.\n */\n retire(key: string): void {\n this.writers.delete(key);\n }\n\n /** How many bindings currently hold callbacks, so a churned list can be counted. */\n retained(): number {\n return this.writers.size;\n }\n\n /** Drops every callback; a reset starts a session whose bindings have written nothing. */\n clear(): void {\n this.writers.clear();\n }\n}\n"]}
|
package/dist/typed.d.ts
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import type { ArtifactShape, FieldIdsOf, FieldShapeOf, FormBlocker, RecordOf, RowKeyRequirement, SubmissionProjectionOptions, TypedArtifact, ValueState, WireValueOf } from '@azx-pbc/axiom-runtime';
|
|
2
|
+
import type { FieldProps } from './field-props.js';
|
|
3
|
+
import type { FieldError } from './field-error.js';
|
|
4
|
+
import type { FormSummary } from './store/form-channel.js';
|
|
5
|
+
import type { FormHandle } from './form-store.js';
|
|
6
|
+
/**
|
|
7
|
+
* The React bindings' typed surface, derived from a `defineDocument` definition.
|
|
8
|
+
*
|
|
9
|
+
* Nothing here adds a runtime fact. A typed binding is the same binding the untyped hook returns,
|
|
10
|
+
* narrowed by the declaration the definition compiled: the field id, the row-key requirement the
|
|
11
|
+
* declaration's position and primitive state, and the wire value the primitive makes knowable.
|
|
12
|
+
* The untyped doors keep their existing signatures, so a host that holds a runtime artifact string
|
|
13
|
+
* and names no types is unaffected.
|
|
14
|
+
*/
|
|
15
|
+
/** The arguments one binding states after the field id, decided by the field's declaration. */
|
|
16
|
+
type RowKeyArgs<Requirement extends RowKeyRequirement> = [Requirement] extends ['required'] ? [rowKey: string | number] : [Requirement] extends ['forbidden'] ? [rowKey?: undefined] : [rowKey?: string | number];
|
|
17
|
+
/**
|
|
18
|
+
* The rest arguments a typed binding accepts.
|
|
19
|
+
*
|
|
20
|
+
* A row key is mandatory for a member of an array, accepted for an array container, and absent
|
|
21
|
+
* for every field that holds no rows. The tuple wrapping keeps a widened requirement (a shape
|
|
22
|
+
* whose field map is a string index) permissive rather than silently refusing every row key.
|
|
23
|
+
*/
|
|
24
|
+
export type FieldBindingArgs<Shape extends ArtifactShape, Id extends FieldIdsOf<Shape>> = RowKeyArgs<FieldShapeOf<Shape, Id>['rowKey']>;
|
|
25
|
+
/**
|
|
26
|
+
* The declared ids that name an array container, for the hooks that read structure.
|
|
27
|
+
*
|
|
28
|
+
* A member of an array has no list to publish and a scalar holds no rows, so the array door
|
|
29
|
+
* refuses both at compile time while the engine still judges the call. A host that holds a
|
|
30
|
+
* runtime artifact and names no types reaches the same binding through the untyped door, which
|
|
31
|
+
* is unchanged.
|
|
32
|
+
*/
|
|
33
|
+
export type ArrayFieldIdsOf<Shape extends ArtifactShape> = {
|
|
34
|
+
[Id in FieldIdsOf<Shape>]: FieldShapeOf<Shape, Id>['primitive'] extends 'array' ? Id : never;
|
|
35
|
+
}[FieldIdsOf<Shape>];
|
|
36
|
+
/**
|
|
37
|
+
* One binding's value state, narrowed to the declared field.
|
|
38
|
+
*
|
|
39
|
+
* The `absent` and `withheld` arms carry no value, so they are the union's own arms; only the
|
|
40
|
+
* `value` arm is narrowed, to the declared wire value. A withheld value stays withheld
|
|
41
|
+
* whatever the declaration states: the narrowing states a fact about the declaration, never a
|
|
42
|
+
* claim on what access delivered.
|
|
43
|
+
*/
|
|
44
|
+
export type TypedValueState<Shape extends ArtifactShape, Id extends FieldIdsOf<Shape>> = {
|
|
45
|
+
readonly kind: 'value';
|
|
46
|
+
readonly value: WireValueOf<Shape, Id>;
|
|
47
|
+
} | Extract<ValueState, {
|
|
48
|
+
readonly kind: 'absent';
|
|
49
|
+
}> | Extract<ValueState, {
|
|
50
|
+
readonly kind: 'withheld';
|
|
51
|
+
}>;
|
|
52
|
+
/**
|
|
53
|
+
* One binding's props, narrowed to the declared field.
|
|
54
|
+
*
|
|
55
|
+
* `value` and `initialValue` are the declared wire value, the authored empty `null`, or `undefined`
|
|
56
|
+
* for an absent or access-withheld value. The store validates every value it accepts against the
|
|
57
|
+
* declaration, so the narrowing states a fact rather than a hope; it does not claim a range, a
|
|
58
|
+
* precision or a currency the primitive cannot express.
|
|
59
|
+
*/
|
|
60
|
+
export type TypedFieldProps<Shape extends ArtifactShape, Id extends FieldIdsOf<Shape>> = Omit<FieldProps, 'fieldId' | 'value' | 'initialValue'> & {
|
|
61
|
+
readonly fieldId: Id;
|
|
62
|
+
readonly value: WireValueOf<Shape, Id> | null | undefined;
|
|
63
|
+
readonly initialValue: WireValueOf<Shape, Id> | null | undefined;
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* A binding key of a shape's declaration: a field id, or a field id and a row key.
|
|
67
|
+
*
|
|
68
|
+
* The row half is a template rather than a literal union of row keys because rows are data: a
|
|
69
|
+
* natural key is a value of the key member and an assigned key is host-minted, so no artifact
|
|
70
|
+
* states the set at compile time.
|
|
71
|
+
*/
|
|
72
|
+
export type BindingKeyOf<Shape extends ArtifactShape> = FieldIdsOf<Shape> | `${FieldIdsOf<Shape>}@${string}`;
|
|
73
|
+
/**
|
|
74
|
+
* One binding a summary key names, parsed into the field and the row it addresses.
|
|
75
|
+
*
|
|
76
|
+
* A `field` arm names a field binding; a `row` arm names one row of an array binding, with
|
|
77
|
+
* the wire-typed row key the binding was registered under. The row half stays
|
|
78
|
+
* `string | number` for the same reason `BindingKeyOf` states a template: rows are data, so
|
|
79
|
+
* no artifact states the set at compile time. Switch on `kind` and end with `assertNever`,
|
|
80
|
+
* so a new arm fails typecheck instead of falling through.
|
|
81
|
+
*/
|
|
82
|
+
export type BindingRefOf<Shape extends ArtifactShape> = {
|
|
83
|
+
readonly kind: 'field';
|
|
84
|
+
readonly fieldId: FieldIdsOf<Shape>;
|
|
85
|
+
} | {
|
|
86
|
+
readonly kind: 'row';
|
|
87
|
+
readonly fieldId: FieldIdsOf<Shape>;
|
|
88
|
+
readonly rowKey: string | number;
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* Reads a binding key back into the field and row it names, so a host can bind what a summary reports.
|
|
92
|
+
*
|
|
93
|
+
* `useFormState` reports keys (`firstErrorBindingKey`, `dirtyFields`) while a hook binds a
|
|
94
|
+
* field id and a row key, and splitting the string by hand leaves the pieces untyped. The
|
|
95
|
+
* returned reference carries the declared id, so it binds with no cast. A key that names no
|
|
96
|
+
* declared field of the definition, or a row half that states no wire-typed key
|
|
97
|
+
* (`string:<text>` or `number:<digits>`), is a host programming error and is refused with an
|
|
98
|
+
* `Error` naming the key and the schema, because a summary the engine produced always parses.
|
|
99
|
+
*
|
|
100
|
+
* The row pairing is the key's own structure, not a second declaration check: whether the
|
|
101
|
+
* named field holds rows is the type's job (`BindingKeyOf`, `FieldBindingArgs`) and the
|
|
102
|
+
* engine's job at bind time.
|
|
103
|
+
*/
|
|
104
|
+
export declare function parseBindingKey<Shape extends ArtifactShape>(definition: TypedArtifact<Shape>, key: string): BindingRefOf<Shape>;
|
|
105
|
+
/**
|
|
106
|
+
* The form summary, with every binding key restricted to the definition's declarations.
|
|
107
|
+
*
|
|
108
|
+
* The summary deliberately carries no record value: it subscribes only to facts that change its
|
|
109
|
+
* verdict and counters, so a keystroke that changes a value alone does not re-render a host that
|
|
110
|
+
* reads it. The record type is carried by `useForm(def).handleSubmit` and `exportSubmission`,
|
|
111
|
+
* which read committed state when they are called.
|
|
112
|
+
*/
|
|
113
|
+
export interface TypedFormSummary<Shape extends ArtifactShape> extends Omit<FormSummary, 'dirtyFields' | 'touchedFields' | 'missingRequiredFields' | 'visibleMissingRequiredFields'> {
|
|
114
|
+
readonly dirtyFields: readonly BindingKeyOf<Shape>[];
|
|
115
|
+
readonly touchedFields: readonly BindingKeyOf<Shape>[];
|
|
116
|
+
readonly missingRequiredFields: readonly BindingKeyOf<Shape>[];
|
|
117
|
+
readonly visibleMissingRequiredFields: readonly BindingKeyOf<Shape>[];
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* The imperative handle, with the submit door typed by the definition.
|
|
121
|
+
*
|
|
122
|
+
* `handleSubmit` hands `onValid` the submission projection the runtime already builds — the
|
|
123
|
+
* record the artifact declares, keyed by its top-level field ids, with a member optional where
|
|
124
|
+
* the projection omits a field no input supplied. `getState` is the typed summary; every other
|
|
125
|
+
* method keeps the handle's existing signature, because its ids address imperative operations
|
|
126
|
+
* rather than a render binding and the runtime judges them at the call.
|
|
127
|
+
*/
|
|
128
|
+
export interface TypedFormHandle<Shape extends ArtifactShape> extends Omit<FormHandle, 'handleSubmit' | 'exportSubmission' | 'getState'> {
|
|
129
|
+
handleSubmit(onValid: (values: RecordOf<Shape>) => void | Promise<void>, onInvalid?: (errors: readonly FieldError[], blockers: readonly FormBlocker[]) => void): Promise<void>;
|
|
130
|
+
exportSubmission(options?: SubmissionProjectionOptions): RecordOf<Shape>;
|
|
131
|
+
getState(): TypedFormSummary<Shape>;
|
|
132
|
+
}
|
|
133
|
+
export {};
|
|
134
|
+
//# sourceMappingURL=typed.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typed.d.ts","sourceRoot":"","sources":["../src/typed.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EAEb,UAAU,EACV,YAAY,EACZ,WAAW,EACX,QAAQ,EACR,iBAAiB,EACjB,2BAA2B,EAC3B,aAAa,EACb,UAAU,EACV,WAAW,EACZ,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD;;;;;;;;GAQG;AAEH,+FAA+F;AAC/F,KAAK,UAAU,CAAC,WAAW,SAAS,iBAAiB,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,UAAU,CAAC,GACvF,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,GACzB,CAAC,WAAW,CAAC,SAAS,CAAC,WAAW,CAAC,GACjC,CAAC,MAAM,CAAC,EAAE,SAAS,CAAC,GACpB,CA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,SAAS,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC;CACvE;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,eAAe,CAAC,KAAK,SAAS,aAAa,CAC1D,SAAQ,IAAI,CAAC,UAAU,EAAE,cAAc,GAAG,kBAAkB,GAAG,UAAU,CAAC;IAC1E,YAAY,CACV,OAAO,EAAE,CAAC,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,EAC1D,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,SAAS,UAAU,EAAE,EAAE,QAAQ,EAAE,SAAS,WAAW,EAAE,KAAK,IAAI,GACpF,OAAO,CAAC,IAAI,CAAC,CAAC;IACjB,gBAAgB,CAAC,OAAO,CAAC,EAAE,2BAA2B,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IACzE,QAAQ,IAAI,gBAAgB,CAAC,KAAK,CAAC,CAAC;CACrC"}
|
package/dist/typed.js
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reads a binding key back into the field and row it names, so a host can bind what a summary reports.
|
|
3
|
+
*
|
|
4
|
+
* `useFormState` reports keys (`firstErrorBindingKey`, `dirtyFields`) while a hook binds a
|
|
5
|
+
* field id and a row key, and splitting the string by hand leaves the pieces untyped. The
|
|
6
|
+
* returned reference carries the declared id, so it binds with no cast. A key that names no
|
|
7
|
+
* declared field of the definition, or a row half that states no wire-typed key
|
|
8
|
+
* (`string:<text>` or `number:<digits>`), is a host programming error and is refused with an
|
|
9
|
+
* `Error` naming the key and the schema, because a summary the engine produced always parses.
|
|
10
|
+
*
|
|
11
|
+
* The row pairing is the key's own structure, not a second declaration check: whether the
|
|
12
|
+
* named field holds rows is the type's job (`BindingKeyOf`, `FieldBindingArgs`) and the
|
|
13
|
+
* engine's job at bind time.
|
|
14
|
+
*/
|
|
15
|
+
export function parseBindingKey(definition, key) {
|
|
16
|
+
const separator = key.indexOf('@');
|
|
17
|
+
const fieldId = separator === -1 ? key : key.slice(0, separator);
|
|
18
|
+
if (!isDeclaredFieldId(definition, fieldId)) {
|
|
19
|
+
throw new Error(`@azx-pbc/axiom-react: binding key ${JSON.stringify(key)} names no field of schema ${definition.schemaId}`);
|
|
20
|
+
}
|
|
21
|
+
if (separator === -1) {
|
|
22
|
+
return { kind: 'field', fieldId };
|
|
23
|
+
}
|
|
24
|
+
const rowKey = rowKeyOfToken(key.slice(separator + 1));
|
|
25
|
+
if (rowKey === undefined) {
|
|
26
|
+
throw new Error(`@azx-pbc/axiom-react: binding key ${JSON.stringify(key)} states no wire-typed row key of schema ${definition.schemaId}`);
|
|
27
|
+
}
|
|
28
|
+
return { kind: 'row', fieldId, rowKey };
|
|
29
|
+
}
|
|
30
|
+
/** Whether the definition declares the id, so a summary key resolves without a cast. */
|
|
31
|
+
function isDeclaredFieldId(definition, fieldId) {
|
|
32
|
+
return hasDeclaredFieldId(definition.fields, fieldId);
|
|
33
|
+
}
|
|
34
|
+
/** Whether the declaration list, at any nesting level, declares the id. */
|
|
35
|
+
function hasDeclaredFieldId(fields, fieldId) {
|
|
36
|
+
for (const field of fields) {
|
|
37
|
+
if (field.fieldId === fieldId) {
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
if (field.fields !== undefined && hasDeclaredFieldId(field.fields, fieldId)) {
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* The row key a binding key's `@` half states, or `undefined` when it states none.
|
|
48
|
+
*
|
|
49
|
+
* The half carries the wire type (`string:<text>`, `number:<digits>`), which keeps the
|
|
50
|
+
* integer `7` and the text `"7"` two rows. The split is at the first colon, so a text key
|
|
51
|
+
* that itself carries a colon or an `@` still parses. A numeric half parses only when it is
|
|
52
|
+
* the canonical spelling of a safe integer, so `007`, `-0` and out-of-range digits are
|
|
53
|
+
* refused rather than coerced.
|
|
54
|
+
*/
|
|
55
|
+
function rowKeyOfToken(token) {
|
|
56
|
+
const separator = token.indexOf(':');
|
|
57
|
+
if (separator === -1) {
|
|
58
|
+
return undefined;
|
|
59
|
+
}
|
|
60
|
+
const tag = token.slice(0, separator);
|
|
61
|
+
const text = token.slice(separator + 1);
|
|
62
|
+
if (tag === 'string') {
|
|
63
|
+
return text === '' ? undefined : text;
|
|
64
|
+
}
|
|
65
|
+
if (tag === 'number') {
|
|
66
|
+
const value = Number(text);
|
|
67
|
+
if (!Number.isSafeInteger(value) || String(value) !== text) {
|
|
68
|
+
return undefined;
|
|
69
|
+
}
|
|
70
|
+
return value;
|
|
71
|
+
}
|
|
72
|
+
return undefined;
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=typed.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typed.js","sourceRoot":"","sources":["../src/typed.ts"],"names":[],"mappings":"AAqHA;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,eAAe,CAC7B,UAAgC,EAChC,GAAW;IAEX,MAAM,SAAS,GAAG,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACnC,MAAM,OAAO,GAAG,SAAS,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC;IACjE,IAAI,CAAC,iBAAiB,CAAC,UAAU,EAAE,OAAO,CAAC,EAAE,CAAC;QAC5C,MAAM,IAAI,KAAK,CACb,qCAAqC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,6BAA6B,UAAU,CAAC,QAAQ,EAAE,CAC3G,CAAC;IACJ,CAAC;IACD,IAAI,SAAS,KAAK,CAAC,CAAC,EAAE,CAAC;QACrB,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;IACpC,CAAC;IACD,MAAM,MAAM,GAAG,aAAa,CAAC,GAAG,CAAC,KAAK,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,OAAO,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC;IACxC,CAAC;IACD,IAAI,GAAG,KAAK,QAAQ,EAAE,CAAC;QACrB,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;QAC3B,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC,KAAK,IAAI,EAAE,CAAC;YAC3D,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["import type {\n ArtifactShape,\n CompiledField,\n FieldIdsOf,\n FieldShapeOf,\n FormBlocker,\n RecordOf,\n RowKeyRequirement,\n SubmissionProjectionOptions,\n TypedArtifact,\n ValueState,\n WireValueOf,\n} from '@azx-pbc/axiom-runtime';\nimport type { FieldProps } from './field-props.js';\nimport type { FieldError } from './field-error.js';\nimport type { FormSummary } from './store/form-channel.js';\nimport type { FormHandle } from './form-store.js';\n\n/**\n * The React bindings' typed surface, derived from a `defineDocument` definition.\n *\n * Nothing here adds a runtime fact. A typed binding is the same binding the untyped hook returns,\n * narrowed by the declaration the definition compiled: the field id, the row-key requirement the\n * declaration's position and primitive state, and the wire value the primitive makes knowable.\n * The untyped doors keep their existing signatures, so a host that holds a runtime artifact string\n * and names no types is unaffected.\n */\n\n/** The arguments one binding states after the field id, decided by the field's declaration. */\ntype RowKeyArgs<Requirement extends RowKeyRequirement> = [Requirement] extends ['required']\n ? [rowKey: string | number]\n : [Requirement] extends ['forbidden']\n ? [rowKey?: undefined]\n : [rowKey?: string | number];\n\n/**\n * The rest arguments a typed binding accepts.\n *\n * A row key is mandatory for a member of an array, accepted for an array container, and absent\n * for every field that holds no rows. The tuple wrapping keeps a widened requirement (a shape\n * whose field map is a string index) permissive rather than silently refusing every row key.\n */\nexport type FieldBindingArgs<\n Shape extends ArtifactShape,\n Id extends FieldIdsOf<Shape>,\n> = RowKeyArgs<FieldShapeOf<Shape, Id>['rowKey']>;\n\n/**\n * The declared ids that name an array container, for the hooks that read structure.\n *\n * A member of an array has no list to publish and a scalar holds no rows, so the array door\n * refuses both at compile time while the engine still judges the call. A host that holds a\n * runtime artifact and names no types reaches the same binding through the untyped door, which\n * is unchanged.\n */\nexport type ArrayFieldIdsOf<Shape extends ArtifactShape> = {\n [Id in FieldIdsOf<Shape>]: FieldShapeOf<Shape, Id>['primitive'] extends 'array' ? Id : never;\n}[FieldIdsOf<Shape>];\n\n/**\n * One binding's value state, narrowed to the declared field.\n *\n * The `absent` and `withheld` arms carry no value, so they are the union's own arms; only the\n * `value` arm is narrowed, to the declared wire value. A withheld value stays withheld\n * whatever the declaration states: the narrowing states a fact about the declaration, never a\n * claim on what access delivered.\n */\nexport type TypedValueState<Shape extends ArtifactShape, Id extends FieldIdsOf<Shape>> =\n | { readonly kind: 'value'; readonly value: WireValueOf<Shape, Id> }\n | Extract<ValueState, { readonly kind: 'absent' }>\n | Extract<ValueState, { readonly kind: 'withheld' }>;\n\n/**\n * One binding's props, narrowed to the declared field.\n *\n * `value` and `initialValue` are the declared wire value, the authored empty `null`, or `undefined`\n * for an absent or access-withheld value. The store validates every value it accepts against the\n * declaration, so the narrowing states a fact rather than a hope; it does not claim a range, a\n * precision or a currency the primitive cannot express.\n */\nexport type TypedFieldProps<Shape extends ArtifactShape, Id extends FieldIdsOf<Shape>> = Omit<\n FieldProps,\n 'fieldId' | 'value' | 'initialValue'\n> & {\n readonly fieldId: Id;\n readonly value: WireValueOf<Shape, Id> | null | undefined;\n readonly initialValue: WireValueOf<Shape, Id> | null | undefined;\n};\n\n/**\n * A binding key of a shape's declaration: a field id, or a field id and a row key.\n *\n * The row half is a template rather than a literal union of row keys because rows are data: a\n * natural key is a value of the key member and an assigned key is host-minted, so no artifact\n * states the set at compile time.\n */\nexport type BindingKeyOf<Shape extends ArtifactShape> =\n | FieldIdsOf<Shape>\n | `${FieldIdsOf<Shape>}@${string}`;\n\n/**\n * One binding a summary key names, parsed into the field and the row it addresses.\n *\n * A `field` arm names a field binding; a `row` arm names one row of an array binding, with\n * the wire-typed row key the binding was registered under. The row half stays\n * `string | number` for the same reason `BindingKeyOf` states a template: rows are data, so\n * no artifact states the set at compile time. Switch on `kind` and end with `assertNever`,\n * so a new arm fails typecheck instead of falling through.\n */\nexport type BindingRefOf<Shape extends ArtifactShape> =\n | { readonly kind: 'field'; readonly fieldId: FieldIdsOf<Shape> }\n | {\n readonly kind: 'row';\n readonly fieldId: FieldIdsOf<Shape>;\n readonly rowKey: string | number;\n };\n\n/**\n * Reads a binding key back into the field and row it names, so a host can bind what a summary reports.\n *\n * `useFormState` reports keys (`firstErrorBindingKey`, `dirtyFields`) while a hook binds a\n * field id and a row key, and splitting the string by hand leaves the pieces untyped. The\n * returned reference carries the declared id, so it binds with no cast. A key that names no\n * declared field of the definition, or a row half that states no wire-typed key\n * (`string:<text>` or `number:<digits>`), is a host programming error and is refused with an\n * `Error` naming the key and the schema, because a summary the engine produced always parses.\n *\n * The row pairing is the key's own structure, not a second declaration check: whether the\n * named field holds rows is the type's job (`BindingKeyOf`, `FieldBindingArgs`) and the\n * engine's job at bind time.\n */\nexport function parseBindingKey<Shape extends ArtifactShape>(\n definition: TypedArtifact<Shape>,\n key: string,\n): BindingRefOf<Shape> {\n const separator = key.indexOf('@');\n const fieldId = separator === -1 ? key : key.slice(0, separator);\n if (!isDeclaredFieldId(definition, fieldId)) {\n throw new Error(\n `@azx-pbc/axiom-react: binding key ${JSON.stringify(key)} names no field of schema ${definition.schemaId}`,\n );\n }\n if (separator === -1) {\n return { kind: 'field', fieldId };\n }\n const rowKey = rowKeyOfToken(key.slice(separator + 1));\n if (rowKey === undefined) {\n throw new Error(\n `@azx-pbc/axiom-react: binding key ${JSON.stringify(key)} states no wire-typed row key of schema ${definition.schemaId}`,\n );\n }\n return { kind: 'row', fieldId, rowKey };\n}\n\n/** Whether the definition declares the id, so a summary key resolves without a cast. */\nfunction isDeclaredFieldId<Shape extends ArtifactShape>(\n definition: TypedArtifact<Shape>,\n fieldId: string,\n): fieldId is FieldIdsOf<Shape> {\n return hasDeclaredFieldId(definition.fields, fieldId);\n}\n\n/** Whether the declaration list, at any nesting level, declares the id. */\nfunction hasDeclaredFieldId(fields: readonly CompiledField[], fieldId: string): boolean {\n for (const field of fields) {\n if (field.fieldId === fieldId) {\n return true;\n }\n if (field.fields !== undefined && hasDeclaredFieldId(field.fields, fieldId)) {\n return true;\n }\n }\n return false;\n}\n\n/**\n * The row key a binding key's `@` half states, or `undefined` when it states none.\n *\n * The half carries the wire type (`string:<text>`, `number:<digits>`), which keeps the\n * integer `7` and the text `\"7\"` two rows. The split is at the first colon, so a text key\n * that itself carries a colon or an `@` still parses. A numeric half parses only when it is\n * the canonical spelling of a safe integer, so `007`, `-0` and out-of-range digits are\n * refused rather than coerced.\n */\nfunction rowKeyOfToken(token: string): string | number | undefined {\n const separator = token.indexOf(':');\n if (separator === -1) {\n return undefined;\n }\n const tag = token.slice(0, separator);\n const text = token.slice(separator + 1);\n if (tag === 'string') {\n return text === '' ? undefined : text;\n }\n if (tag === 'number') {\n const value = Number(text);\n if (!Number.isSafeInteger(value) || String(value) !== text) {\n return undefined;\n }\n return value;\n }\n return undefined;\n}\n\n/**\n * The form summary, with every binding key restricted to the definition's declarations.\n *\n * The summary deliberately carries no record value: it subscribes only to facts that change its\n * verdict and counters, so a keystroke that changes a value alone does not re-render a host that\n * reads it. The record type is carried by `useForm(def).handleSubmit` and `exportSubmission`,\n * which read committed state when they are called.\n */\nexport interface TypedFormSummary<Shape extends ArtifactShape>\n extends Omit<\n FormSummary,\n 'dirtyFields' | 'touchedFields' | 'missingRequiredFields' | 'visibleMissingRequiredFields'\n > {\n readonly dirtyFields: readonly BindingKeyOf<Shape>[];\n readonly touchedFields: readonly BindingKeyOf<Shape>[];\n readonly missingRequiredFields: readonly BindingKeyOf<Shape>[];\n readonly visibleMissingRequiredFields: readonly BindingKeyOf<Shape>[];\n}\n\n/**\n * The imperative handle, with the submit door typed by the definition.\n *\n * `handleSubmit` hands `onValid` the submission projection the runtime already builds — the\n * record the artifact declares, keyed by its top-level field ids, with a member optional where\n * the projection omits a field no input supplied. `getState` is the typed summary; every other\n * method keeps the handle's existing signature, because its ids address imperative operations\n * rather than a render binding and the runtime judges them at the call.\n */\nexport interface TypedFormHandle<Shape extends ArtifactShape>\n extends Omit<FormHandle, 'handleSubmit' | 'exportSubmission' | 'getState'> {\n handleSubmit(\n onValid: (values: RecordOf<Shape>) => void | Promise<void>,\n onInvalid?: (errors: readonly FieldError[], blockers: readonly FormBlocker[]) => void,\n ): Promise<void>;\n exportSubmission(options?: SubmissionProjectionOptions): RecordOf<Shape>;\n getState(): TypedFormSummary<Shape>;\n}\n"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { AsyncOptionList } from './store/option-pages.js';
|
|
2
|
+
/** Pages a picker requests when the host states none; a bounded page, never the whole domain. */
|
|
3
|
+
export declare const DEFAULT_OPTION_PAGE_SIZE = 50;
|
|
4
|
+
/**
|
|
5
|
+
* A host-loaded option domain for one field or one row of an array, `[MODEL-3.1.8]`.
|
|
6
|
+
*
|
|
7
|
+
* The pages are keyed by the basis the artifact declares — the source, the current values of
|
|
8
|
+
* its `dependsOn` fields, the session record date and the access version — plus the binding's
|
|
9
|
+
* row identity, so editing one row's dependency loads that row and no sibling, and a reorder
|
|
10
|
+
* loads nothing. A change to any member of the basis starts exactly one load through the same
|
|
11
|
+
* path a manual `reload` takes. The reader's search text is the one key `search` owns: it is
|
|
12
|
+
* published at the edit, drops the pages it narrows, and asks the loader once the text settles.
|
|
13
|
+
*
|
|
14
|
+
* Staleness has one answer: beginning a request cancels the previous signal, so a response
|
|
15
|
+
* that arrives after a newer request began — or after unmount — commits nothing on either the
|
|
16
|
+
* resolve or the reject arm. Eligibility is not this hook's answer; the selected value's
|
|
17
|
+
* `invalidValue` is derived once by the session from the loaded domain.
|
|
18
|
+
*/
|
|
19
|
+
export declare function useAsyncOptions(fieldId: string, rowKey?: string | number, pageSize?: number): AsyncOptionList;
|
|
20
|
+
//# sourceMappingURL=useAsyncOptions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAsyncOptions.d.ts","sourceRoot":"","sources":["../src/useAsyncOptions.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAkB,MAAM,yBAAyB,CAAC;AAG/E,iGAAiG;AACjG,eAAO,MAAM,wBAAwB,KAAK,CAAC;AAE3C;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,MAAM,EACf,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EACxB,QAAQ,GAAE,MAAiC,GAC1C,eAAe,CA0DjB"}
|