@wow-two-beta/fe 0.0.39 → 0.0.40
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/dist/formsEngine/AppForm.d.ts +12 -3
- package/dist/formsEngine/FormOperations.d.ts +18 -0
- package/dist/formsEngine/FormOperations.js +9 -0
- package/dist/formsEngine/FormOperations.js.map +1 -1
- package/dist/formsEngine/adapters/house/HouseFormCore.js +15 -6
- package/dist/formsEngine/adapters/house/HouseFormCore.js.map +1 -1
- package/dist/formsEngine/adapters/tanstack/TanstackFormOverlay.d.ts +4 -0
- package/dist/formsEngine/adapters/tanstack/TanstackFormOverlay.js +10 -1
- package/dist/formsEngine/adapters/tanstack/TanstackFormOverlay.js.map +1 -1
- package/dist/formsEngine/adapters/tanstack/UseAppForm.js +9 -6
- package/dist/formsEngine/adapters/tanstack/UseAppForm.js.map +1 -1
- package/dist/foundation/animation/animatedLayout/AnimatedLayout.d.ts +3 -3
- package/dist/foundation/dom/FocusTarget.d.ts +13 -0
- package/dist/foundation/dom/FocusTarget.js +12 -0
- package/dist/foundation/dom/FocusTarget.js.map +1 -0
- package/dist/foundation/dom/index.d.ts +1 -0
- package/dist/foundation/dom/index.js +3 -0
- package/dist/foundation/dom/index.js.map +1 -1
- package/dist/foundation/primitives/index.d.ts +1 -0
- package/dist/foundation/primitives/index.js +3 -0
- package/dist/foundation/primitives/index.js.map +1 -1
- package/dist/foundation/primitives/swapTransition/SwapTransition.d.ts +76 -0
- package/dist/foundation/primitives/swapTransition/SwapTransition.js +240 -0
- package/dist/foundation/primitives/swapTransition/SwapTransition.js.map +1 -0
- package/dist/foundation/primitives/swapTransition/index.d.ts +1 -0
- package/dist/index.css +11 -0
- package/dist/presentation/display/animatedNumberText/AnimatedNumberText.vue.d.ts +1 -1
- package/dist/presentation/display/carousel/Carousel.vue.d.ts +1 -1
- package/dist/presentation/display/countUpText/CountUpText.vue.d.ts +1 -1
- package/dist/presentation/display/scrollRevealGroup/ScrollRevealGroup.vue.d.ts +2 -2
- package/dist/presentation/forms/imageCropEditor/ImageCropEditor.vue.d.ts +1 -1
- package/dist/presentation/forms/imageEditor/ImageEditor.vue.d.ts +1 -1
- package/dist/presentation/forms/phoneInput/PhoneInput.vue.d.ts +4 -0
- package/dist/presentation/forms/phoneInput/PhoneInput.vue.js +19 -6
- package/dist/presentation/forms/phoneInput/PhoneInput.vue.js.map +1 -1
- package/dist/router/adapters/vueRouter/routeAnnouncer/RouteAnnouncer.vue.js +17 -5
- package/dist/router/adapters/vueRouter/routeAnnouncer/RouteAnnouncer.vue.js.map +1 -1
- package/package.json +1 -1
|
@@ -20,12 +20,17 @@ export interface AppFormOptions<TValues extends object, TOutput = TValues> {
|
|
|
20
20
|
readonly defaultValues: TValues;
|
|
21
21
|
/** The whole-form validator — any Standard Schema (zod / valibot / arktype). Sync or async. */
|
|
22
22
|
readonly schema?: StandardSchemaV1<TValues, TOutput>;
|
|
23
|
-
/**
|
|
23
|
+
/**
|
|
24
|
+
* When client validation runs. `'submit'` re-validates touched fields on change after the first attempt.
|
|
25
|
+
* Validation is form-wide, but a field DISPLAYS its client error only once it was blurred, after a submit
|
|
26
|
+
* attempt, or — under `'change'` — once it changed ({@link AppFieldApi.errors}).
|
|
27
|
+
*/
|
|
24
28
|
readonly validateOn?: 'change' | 'blur' | 'submit';
|
|
25
29
|
/**
|
|
26
30
|
* Validate once on mount — seeds `isValid` / field errors before any interaction (edit-screen
|
|
27
31
|
* validity indicators, wizard step-entry gating). Fields stay untouched (`isTouched` false), so
|
|
28
|
-
* the initial pass populates state without asserting the user has interacted
|
|
32
|
+
* the initial pass populates `state.isValid` without asserting the user has interacted: a field's
|
|
33
|
+
* error displays once that field is touched, changed (`'change'`) or a submit is attempted. Default `false`.
|
|
29
34
|
*/
|
|
30
35
|
readonly validateOnMount?: boolean;
|
|
31
36
|
/** Performs the submit with valid values — usually a `useAppMutation` / `useOptimisticMutation` `mutateAsync`. */
|
|
@@ -103,7 +108,11 @@ export interface AppFieldApi<TValue> {
|
|
|
103
108
|
readonly setValue: (value: TValue) => void;
|
|
104
109
|
/** Marks the field touched — the Field glue also wires it onto the control's blur. */
|
|
105
110
|
readonly onBlur: () => void;
|
|
106
|
-
/**
|
|
111
|
+
/**
|
|
112
|
+
* The messages to display, client first. Server messages always display and clear on the next change to
|
|
113
|
+
* the field. A client message displays once the field is touched, after a submit attempt, or — under
|
|
114
|
+
* `validateOn: 'change'` — once it changed; until then it stays in `form.state.isValid` only.
|
|
115
|
+
*/
|
|
107
116
|
readonly errors: ReadonlyArray<string>;
|
|
108
117
|
readonly isDirty: boolean;
|
|
109
118
|
readonly isTouched: boolean;
|
|
@@ -3,6 +3,24 @@ import { ResolveValidationMessage } from '../foundation/validators';
|
|
|
3
3
|
import { StandardSchemaV1 } from './StandardSchema';
|
|
4
4
|
/** Matches path segments, so selecting row 1 never selects row 10. Root errors always apply. */
|
|
5
5
|
export declare function includesValidationPath(path: string, fields?: ReadonlyArray<string>): boolean;
|
|
6
|
+
/** The per-form interaction marks that decide which field shows its client error. */
|
|
7
|
+
export interface FieldMarks {
|
|
8
|
+
/** Blurred paths (and paths a scoped `validate({ fields })` touched). */
|
|
9
|
+
readonly touched: ReadonlySet<string>;
|
|
10
|
+
/** Paths a write reached — `setValue`, field assignment, array operations. */
|
|
11
|
+
readonly changed: ReadonlySet<string>;
|
|
12
|
+
readonly submitCount: number;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Per-field error display, shared by every adapter. Validation runs form-wide, so a client error can
|
|
16
|
+
* exist for a field the user has not reached; it displays only once that field was blurred, after a
|
|
17
|
+
* submit attempt, or — under `validateOn: 'change'`, where every write validates — once it changed.
|
|
18
|
+
* A path matches its own mark and its descendants' (a touched `rules` array touches its rows).
|
|
19
|
+
*/
|
|
20
|
+
export declare function resolveFieldDisplay(path: string, marks: FieldMarks, validateOn: 'change' | 'blur' | 'submit' | undefined): {
|
|
21
|
+
readonly isTouched: boolean;
|
|
22
|
+
readonly showsClientErrors: boolean;
|
|
23
|
+
};
|
|
6
24
|
/** Runs a display-only gate and filters issues without bypassing whole-form submit parsing. */
|
|
7
25
|
export declare function validateFormScope<TValues extends object>(values: TValues, options: AppFormValidationOptions<TValues>, schema: StandardSchemaV1<TValues, unknown> | undefined, resolver: ResolveValidationMessage, fallback: string): Promise<Record<string, ReadonlyArray<string>>>;
|
|
8
26
|
/** Settles even when a transport ignores abort, while observing its eventual rejection. */
|
|
@@ -11,6 +11,14 @@ function includesValidationPath(path, fields) {
|
|
|
11
11
|
return selected.every((segment, index) => segments[index] === segment);
|
|
12
12
|
});
|
|
13
13
|
}
|
|
14
|
+
function resolveFieldDisplay(path, marks, validateOn) {
|
|
15
|
+
const isMarked = (set) => {
|
|
16
|
+
for (const mark of set) if (includesValidationPath(path, [mark])) return true;
|
|
17
|
+
return false;
|
|
18
|
+
};
|
|
19
|
+
const isTouched = marks.submitCount > 0 || isMarked(marks.touched);
|
|
20
|
+
return { isTouched, showsClientErrors: isTouched || validateOn === "change" && isMarked(marks.changed) };
|
|
21
|
+
}
|
|
14
22
|
async function validateFormScope(values, options, schema, resolver, fallback) {
|
|
15
23
|
try {
|
|
16
24
|
const selected = options.schema ?? schema;
|
|
@@ -49,6 +57,7 @@ async function submitWithFocus(submit, isCurrent, event, root) {
|
|
|
49
57
|
}
|
|
50
58
|
export {
|
|
51
59
|
includesValidationPath,
|
|
60
|
+
resolveFieldDisplay,
|
|
52
61
|
submitWithFocus,
|
|
53
62
|
untilFormAbort,
|
|
54
63
|
validateFormScope
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormOperations.js","sources":["../../src/formsEngine/FormOperations.ts"],"sourcesContent":["import { nextTick } from 'vue';\n\nimport type { AppFormValidationOptions } from './AppForm';\nimport { focusFirstInvalid } from './FocusFirstInvalid';\nimport { snapshotFormValues } from './FormSnapshot';\nimport { parsePath } from './Paths';\nimport { formParseFailure, parseStandardSchema } from './SchemaValidation';\nimport type { ResolveValidationMessage } from '../foundation/validators';\nimport type { StandardSchemaV1 } from './StandardSchema';\n\n/** Matches path segments, so selecting row 1 never selects row 10. Root errors always apply. */\nexport function includesValidationPath(path: string, fields?: ReadonlyArray<string>): boolean {\n if (!fields || path === '') return true;\n const segments = parsePath(path);\n return fields.some((field) => {\n const selected = parsePath(field);\n return selected.every((segment, index) => segments[index] === segment);\n });\n}\n\n/** Runs a display-only gate and filters issues without bypassing whole-form submit parsing. */\nexport async function validateFormScope<TValues extends object>(\n values: TValues,\n options: AppFormValidationOptions<TValues>,\n schema: StandardSchemaV1<TValues, unknown> | undefined,\n resolver: ResolveValidationMessage,\n fallback: string,\n): Promise<Record<string, ReadonlyArray<string>>> {\n try {\n const selected = options.schema ?? schema;\n if (!selected) return {};\n const result = await parseStandardSchema(selected, snapshotFormValues(values), resolver);\n return result.ok\n ? {}\n : Object.fromEntries(\n Object.entries(result.failure.fieldErrors).filter(([path]) => includesValidationPath(path, options.fields)),\n );\n } catch {\n const result = formParseFailure({ '': [fallback] });\n return result.ok ? {} : result.failure.fieldErrors;\n }\n}\n\n/** Settles even when a transport ignores abort, while observing its eventual rejection. */\nexport function untilFormAbort<T>(work: Promise<T>, signal: AbortSignal, cancelled: T): Promise<T> {\n if (signal.aborted) {\n void work.catch(() => undefined);\n return Promise.resolve(cancelled);\n }\n return new Promise<T>((resolve, reject) => {\n const abort = (): void => resolve(cancelled);\n signal.addEventListener('abort', abort, { once: true });\n void work.then(resolve, reject).finally(() => signal.removeEventListener('abort', abort));\n });\n}\n\n/** Captures event scope synchronously, then focuses rendered failures only for current manual attempts. */\nexport async function submitWithFocus(\n submit: () => Promise<boolean>,\n isCurrent: () => boolean,\n event?: Event,\n root?: ParentNode | null,\n): Promise<boolean> {\n event?.preventDefault();\n const target = event?.currentTarget;\n const scope = root ?? (target && 'querySelector' in target ? (target as ParentNode) : null);\n const successful = await submit();\n await nextTick();\n if (!successful && isCurrent() && scope && !focusFirstInvalid(scope)) {\n const summary = scope.querySelector<HTMLElement>('[data-form-error-summary]');\n if (summary && !summary.closest('[inert], [hidden], [aria-hidden=\"true\"]')) summary.focus();\n }\n return successful;\n}\n"],"names":[],"mappings":";;;;;AAWO,SAAS,uBAAuB,MAAc,QAAyC;AAC5F,MAAI,CAAC,UAAU,SAAS,GAAI,QAAO;AACnC,QAAM,WAAW,UAAU,IAAI;AAC/B,SAAO,OAAO,KAAK,CAAC,UAAU;AAC5B,UAAM,WAAW,UAAU,KAAK;AAChC,WAAO,SAAS,MAAM,CAAC,SAAS,UAAU,SAAS,KAAK,MAAM,OAAO;AAAA,EACvE,CAAC;AACH;AAGA,eAAsB,kBACpB,QACA,SACA,QACA,UACA,UACgD;AAChD,MAAI;AACF,UAAM,WAAW,QAAQ,UAAU;AACnC,QAAI,CAAC,SAAU,QAAO,CAAA;AACtB,UAAM,SAAS,MAAM,oBAAoB,UAAU,mBAAmB,MAAM,GAAG,QAAQ;AACvF,WAAO,OAAO,KACV,CAAA,IACA,OAAO;AAAA,MACL,OAAO,QAAQ,OAAO,QAAQ,WAAW,EAAE,OAAO,CAAC,CAAC,IAAI,MAAM,uBAAuB,MAAM,QAAQ,MAAM,CAAC;AAAA,IAAA;AAAA,EAElH,QAAQ;AACN,UAAM,SAAS,iBAAiB,EAAE,IAAI,CAAC,QAAQ,GAAG;AAClD,WAAO,OAAO,KAAK,CAAA,IAAK,OAAO,QAAQ;AAAA,EACzC;AACF;AAGO,SAAS,eAAkB,MAAkB,QAAqB,WAA0B;AACjG,MAAI,OAAO,SAAS;AAClB,SAAK,KAAK,MAAM,MAAM,MAAS;AAC/B,WAAO,QAAQ,QAAQ,SAAS;AAAA,EAClC;AACA,SAAO,IAAI,QAAW,CAAC,SAAS,WAAW;AACzC,UAAM,QAAQ,MAAY,QAAQ,SAAS;AAC3C,WAAO,iBAAiB,SAAS,OAAO,EAAE,MAAM,MAAM;AACtD,SAAK,KAAK,KAAK,SAAS,MAAM,EAAE,QAAQ,MAAM,OAAO,oBAAoB,SAAS,KAAK,CAAC;AAAA,EAC1F,CAAC;AACH;AAGA,eAAsB,gBACpB,QACA,WACA,OACA,MACkB;AAClB,SAAO,eAAA;AACP,QAAM,SAAS,OAAO;AACtB,QAAM,QAAQ,SAAS,UAAU,mBAAmB,SAAU,SAAwB;AACtF,QAAM,aAAa,MAAM,OAAA;AACzB,QAAM,SAAA;AACN,MAAI,CAAC,cAAc,UAAA,KAAe,SAAS,CAAC,kBAAkB,KAAK,GAAG;AACpE,UAAM,UAAU,MAAM,cAA2B,2BAA2B;AAC5E,QAAI,WAAW,CAAC,QAAQ,QAAQ,yCAAyC,WAAW,MAAA;AAAA,EACtF;AACA,SAAO;AACT;"}
|
|
1
|
+
{"version":3,"file":"FormOperations.js","sources":["../../src/formsEngine/FormOperations.ts"],"sourcesContent":["import { nextTick } from 'vue';\n\nimport type { AppFormValidationOptions } from './AppForm';\nimport { focusFirstInvalid } from './FocusFirstInvalid';\nimport { snapshotFormValues } from './FormSnapshot';\nimport { parsePath } from './Paths';\nimport { formParseFailure, parseStandardSchema } from './SchemaValidation';\nimport type { ResolveValidationMessage } from '../foundation/validators';\nimport type { StandardSchemaV1 } from './StandardSchema';\n\n/** Matches path segments, so selecting row 1 never selects row 10. Root errors always apply. */\nexport function includesValidationPath(path: string, fields?: ReadonlyArray<string>): boolean {\n if (!fields || path === '') return true;\n const segments = parsePath(path);\n return fields.some((field) => {\n const selected = parsePath(field);\n return selected.every((segment, index) => segments[index] === segment);\n });\n}\n\n/** The per-form interaction marks that decide which field shows its client error. */\nexport interface FieldMarks {\n /** Blurred paths (and paths a scoped `validate({ fields })` touched). */\n readonly touched: ReadonlySet<string>;\n /** Paths a write reached — `setValue`, field assignment, array operations. */\n readonly changed: ReadonlySet<string>;\n readonly submitCount: number;\n}\n\n/**\n * Per-field error display, shared by every adapter. Validation runs form-wide, so a client error can\n * exist for a field the user has not reached; it displays only once that field was blurred, after a\n * submit attempt, or — under `validateOn: 'change'`, where every write validates — once it changed.\n * A path matches its own mark and its descendants' (a touched `rules` array touches its rows).\n */\nexport function resolveFieldDisplay(\n path: string,\n marks: FieldMarks,\n validateOn: 'change' | 'blur' | 'submit' | undefined,\n): { readonly isTouched: boolean; readonly showsClientErrors: boolean } {\n const isMarked = (set: ReadonlySet<string>): boolean => {\n for (const mark of set) if (includesValidationPath(path, [mark])) return true;\n return false;\n };\n // A submit attempt counts as touching everything.\n const isTouched = marks.submitCount > 0 || isMarked(marks.touched);\n return { isTouched, showsClientErrors: isTouched || (validateOn === 'change' && isMarked(marks.changed)) };\n}\n\n/** Runs a display-only gate and filters issues without bypassing whole-form submit parsing. */\nexport async function validateFormScope<TValues extends object>(\n values: TValues,\n options: AppFormValidationOptions<TValues>,\n schema: StandardSchemaV1<TValues, unknown> | undefined,\n resolver: ResolveValidationMessage,\n fallback: string,\n): Promise<Record<string, ReadonlyArray<string>>> {\n try {\n const selected = options.schema ?? schema;\n if (!selected) return {};\n const result = await parseStandardSchema(selected, snapshotFormValues(values), resolver);\n return result.ok\n ? {}\n : Object.fromEntries(\n Object.entries(result.failure.fieldErrors).filter(([path]) => includesValidationPath(path, options.fields)),\n );\n } catch {\n const result = formParseFailure({ '': [fallback] });\n return result.ok ? {} : result.failure.fieldErrors;\n }\n}\n\n/** Settles even when a transport ignores abort, while observing its eventual rejection. */\nexport function untilFormAbort<T>(work: Promise<T>, signal: AbortSignal, cancelled: T): Promise<T> {\n if (signal.aborted) {\n void work.catch(() => undefined);\n return Promise.resolve(cancelled);\n }\n return new Promise<T>((resolve, reject) => {\n const abort = (): void => resolve(cancelled);\n signal.addEventListener('abort', abort, { once: true });\n void work.then(resolve, reject).finally(() => signal.removeEventListener('abort', abort));\n });\n}\n\n/** Captures event scope synchronously, then focuses rendered failures only for current manual attempts. */\nexport async function submitWithFocus(\n submit: () => Promise<boolean>,\n isCurrent: () => boolean,\n event?: Event,\n root?: ParentNode | null,\n): Promise<boolean> {\n event?.preventDefault();\n const target = event?.currentTarget;\n const scope = root ?? (target && 'querySelector' in target ? (target as ParentNode) : null);\n const successful = await submit();\n await nextTick();\n if (!successful && isCurrent() && scope && !focusFirstInvalid(scope)) {\n const summary = scope.querySelector<HTMLElement>('[data-form-error-summary]');\n if (summary && !summary.closest('[inert], [hidden], [aria-hidden=\"true\"]')) summary.focus();\n }\n return successful;\n}\n"],"names":[],"mappings":";;;;;AAWO,SAAS,uBAAuB,MAAc,QAAyC;AAC5F,MAAI,CAAC,UAAU,SAAS,GAAI,QAAO;AACnC,QAAM,WAAW,UAAU,IAAI;AAC/B,SAAO,OAAO,KAAK,CAAC,UAAU;AAC5B,UAAM,WAAW,UAAU,KAAK;AAChC,WAAO,SAAS,MAAM,CAAC,SAAS,UAAU,SAAS,KAAK,MAAM,OAAO;AAAA,EACvE,CAAC;AACH;AAiBO,SAAS,oBACd,MACA,OACA,YACsE;AACtE,QAAM,WAAW,CAAC,QAAsC;AACtD,eAAW,QAAQ,IAAK,KAAI,uBAAuB,MAAM,CAAC,IAAI,CAAC,EAAG,QAAO;AACzE,WAAO;AAAA,EACT;AAEA,QAAM,YAAY,MAAM,cAAc,KAAK,SAAS,MAAM,OAAO;AACjE,SAAO,EAAE,WAAW,mBAAmB,aAAc,eAAe,YAAY,SAAS,MAAM,OAAO,EAAA;AACxG;AAGA,eAAsB,kBACpB,QACA,SACA,QACA,UACA,UACgD;AAChD,MAAI;AACF,UAAM,WAAW,QAAQ,UAAU;AACnC,QAAI,CAAC,SAAU,QAAO,CAAA;AACtB,UAAM,SAAS,MAAM,oBAAoB,UAAU,mBAAmB,MAAM,GAAG,QAAQ;AACvF,WAAO,OAAO,KACV,CAAA,IACA,OAAO;AAAA,MACL,OAAO,QAAQ,OAAO,QAAQ,WAAW,EAAE,OAAO,CAAC,CAAC,IAAI,MAAM,uBAAuB,MAAM,QAAQ,MAAM,CAAC;AAAA,IAAA;AAAA,EAElH,QAAQ;AACN,UAAM,SAAS,iBAAiB,EAAE,IAAI,CAAC,QAAQ,GAAG;AAClD,WAAO,OAAO,KAAK,CAAA,IAAK,OAAO,QAAQ;AAAA,EACzC;AACF;AAGO,SAAS,eAAkB,MAAkB,QAAqB,WAA0B;AACjG,MAAI,OAAO,SAAS;AAClB,SAAK,KAAK,MAAM,MAAM,MAAS;AAC/B,WAAO,QAAQ,QAAQ,SAAS;AAAA,EAClC;AACA,SAAO,IAAI,QAAW,CAAC,SAAS,WAAW;AACzC,UAAM,QAAQ,MAAY,QAAQ,SAAS;AAC3C,WAAO,iBAAiB,SAAS,OAAO,EAAE,MAAM,MAAM;AACtD,SAAK,KAAK,KAAK,SAAS,MAAM,EAAE,QAAQ,MAAM,OAAO,oBAAoB,SAAS,KAAK,CAAC;AAAA,EAC1F,CAAC;AACH;AAGA,eAAsB,gBACpB,QACA,WACA,OACA,MACkB;AAClB,SAAO,eAAA;AACP,QAAM,SAAS,OAAO;AACtB,QAAM,QAAQ,SAAS,UAAU,mBAAmB,SAAU,SAAwB;AACtF,QAAM,aAAa,MAAM,OAAA;AACzB,QAAM,SAAA;AACN,MAAI,CAAC,cAAc,UAAA,KAAe,SAAS,CAAC,kBAAkB,KAAK,GAAG;AACpE,UAAM,UAAU,MAAM,cAA2B,2BAA2B;AAC5E,QAAI,WAAW,CAAC,QAAQ,QAAQ,yCAAyC,WAAW,MAAA;AAAA,EACtF;AACA,SAAO;AACT;"}
|
|
@@ -2,7 +2,7 @@ import { shallowRef } from "vue";
|
|
|
2
2
|
import { fieldIssues } from "../../../foundation/http/FieldErrors.js";
|
|
3
3
|
import { AppErrorFactory } from "../../../foundation/results/AppErrorFactory.js";
|
|
4
4
|
import { deepEqual } from "../../DeepEqual.js";
|
|
5
|
-
import { untilFormAbort, validateFormScope, includesValidationPath } from "../../FormOperations.js";
|
|
5
|
+
import { untilFormAbort, validateFormScope, includesValidationPath, resolveFieldDisplay } from "../../FormOperations.js";
|
|
6
6
|
import { snapshotFormValues } from "../../FormSnapshot.js";
|
|
7
7
|
import { getPath, mutateRows, remapPathSet, remapPathMap, setPath, hasPath } from "../../Paths.js";
|
|
8
8
|
import { parseStandardSchema, createOptionsMessageResolver, formParseFailure } from "../../SchemaValidation.js";
|
|
@@ -41,6 +41,7 @@ function createHouseFormEngine(getOptions) {
|
|
|
41
41
|
serverErrors: EmptyMap,
|
|
42
42
|
errors: EmptyMap,
|
|
43
43
|
touched: /* @__PURE__ */ new Set(),
|
|
44
|
+
changed: /* @__PURE__ */ new Set(),
|
|
44
45
|
submitCount: 0,
|
|
45
46
|
isSubmitting: false,
|
|
46
47
|
isValidating: false,
|
|
@@ -141,12 +142,14 @@ function createHouseFormEngine(getOptions) {
|
|
|
141
142
|
const cached = fieldCache.get(path);
|
|
142
143
|
if (cached) return cached;
|
|
143
144
|
const value = getPath(state.values, path);
|
|
145
|
+
const { isTouched, showsClientErrors } = resolveFieldDisplay(path, state, currentOptions().validateOn);
|
|
146
|
+
const client = showsClientErrors ? state.clientErrors[path] ?? EmptyErrors : EmptyErrors;
|
|
147
|
+
const server = state.serverErrors[path] ?? EmptyErrors;
|
|
144
148
|
const computed = {
|
|
145
149
|
value,
|
|
146
|
-
errors:
|
|
150
|
+
errors: server.length === 0 ? client : client.length === 0 ? server : [...client, ...server],
|
|
147
151
|
isDirty: !deepEqual(value, getPath(state.baseline, path)),
|
|
148
|
-
|
|
149
|
-
isTouched: [...state.touched].some((selected) => includesValidationPath(path, [selected])) || state.submitCount > 0
|
|
152
|
+
isTouched
|
|
150
153
|
};
|
|
151
154
|
const previous = previousFieldCache.get(path);
|
|
152
155
|
const stable = previous && fieldStatesEqual(previous, computed) ? previous : computed;
|
|
@@ -156,7 +159,11 @@ function createHouseFormEngine(getOptions) {
|
|
|
156
159
|
function setValue(path, value) {
|
|
157
160
|
const state = peek();
|
|
158
161
|
const serverErrors = Object.prototype.hasOwnProperty.call(state.serverErrors, path) ? Object.fromEntries(Object.entries(state.serverErrors).filter(([key]) => key !== path)) : state.serverErrors;
|
|
159
|
-
patch({
|
|
162
|
+
patch({
|
|
163
|
+
values: setPath(state.values, path, snapshotFormValues(value)),
|
|
164
|
+
serverErrors,
|
|
165
|
+
changed: state.changed.has(path) ? state.changed : new Set(state.changed).add(path)
|
|
166
|
+
});
|
|
160
167
|
if (shouldValidateOnChange()) void runValidation();
|
|
161
168
|
scheduleAutoSubmit();
|
|
162
169
|
}
|
|
@@ -184,7 +191,8 @@ function createHouseFormEngine(getOptions) {
|
|
|
184
191
|
// Row-scoped errors + touched marks follow their rows (insert/remove/swap/move reindex).
|
|
185
192
|
clientErrors: remapPathMap(state.clientErrors, path, operation),
|
|
186
193
|
serverErrors: remapPathMap(state.serverErrors, path, operation),
|
|
187
|
-
touched: remapPathSet(state.touched, path, operation)
|
|
194
|
+
touched: remapPathSet(state.touched, path, operation),
|
|
195
|
+
changed: remapPathSet(new Set(state.changed).add(path), path, operation)
|
|
188
196
|
});
|
|
189
197
|
if (shouldValidateOnChange()) void runValidation();
|
|
190
198
|
scheduleAutoSubmit();
|
|
@@ -204,6 +212,7 @@ function createHouseFormEngine(getOptions) {
|
|
|
204
212
|
serverErrors: EmptyMap,
|
|
205
213
|
errors: EmptyMap,
|
|
206
214
|
touched: /* @__PURE__ */ new Set(),
|
|
215
|
+
changed: /* @__PURE__ */ new Set(),
|
|
207
216
|
submitCount: 0,
|
|
208
217
|
isSubmitting: false,
|
|
209
218
|
isValidating: false,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HouseFormCore.js","sources":["../../../../src/formsEngine/adapters/house/HouseFormCore.ts"],"sourcesContent":["import { shallowRef, type ShallowRef } from 'vue';\n\nimport { fieldIssues } from '../../../foundation/http';\nimport { AppErrorFactory, type AppError } from '../../../foundation/results';\n\nimport type { AppFormOptions, AppFormState, AppFormValidationOptions } from '../../AppForm';\nimport { deepEqual } from '../../DeepEqual';\nimport { includesValidationPath, untilFormAbort, validateFormScope } from '../../FormOperations';\nimport { snapshotFormValues } from '../../FormSnapshot';\nimport { getPath, hasPath, mutateRows, remapPathMap, remapPathSet, setPath, type ArrayOperation } from '../../Paths';\nimport {\n createOptionsMessageResolver,\n parseStandardSchema,\n formParseFailure,\n type FormParseResult,\n} from '../../SchemaValidation';\nimport { defaultMapFieldPath, resolveSubmitFailure, toSubmitError } from '../../SubmitErrors';\n\n/*\n * The house micro-store — one immutable state object in a `shallowRef`.\n * SCOPE CEILING (docs/analysis/forms-engine.md §7): flat + dot-path store, whole-schema\n * Standard Schema validation, arrays, dirty/touched, submit pipeline. NO typed deep\n * paths, NO per-field async/debounce validators, NO linked-field graphs — a form that\n * needs those uses the tanstack adapter. Complete shared facade capabilities here;\n * vendor-specific graphs remain the `form.engine` escape hatch.\n *\n * NOTIFICATION IS THE `shallowRef` ITSELF — no listener list, no subscribe call. `commit` assigns\n * the ref and any getter that reads it is tracked wherever it is read. State stays ONE\n * frozen-by-convention object replaced whole, and the generation caching below hands out\n * identity-stable per-path slices so a field re-renders only when its own slice changed.\n */\n\ntype ErrorMap = Readonly<Record<string, ReadonlyArray<string>>>;\n\nconst EmptyErrors: ReadonlyArray<string> = Object.freeze([]);\nconst EmptyMap: ErrorMap = Object.freeze(Object.create(null) as Record<string, ReadonlyArray<string>>);\n\n/** The per-field slice the `Field` glue reads — identity-stable while its members are unchanged. */\nexport interface HouseFieldState {\n readonly value: unknown;\n readonly errors: ReadonlyArray<string>;\n readonly isDirty: boolean;\n readonly isTouched: boolean;\n}\n\ninterface InternalState<TValues extends object> {\n readonly values: TValues;\n /** The dirty baseline — `reset(next)` re-seeds it. */\n readonly baseline: TValues;\n readonly clientErrors: ErrorMap;\n readonly serverErrors: ErrorMap;\n /** Merged per-path messages, client first — rebuilt whenever either source changes. */\n readonly errors: ErrorMap;\n readonly touched: ReadonlySet<string>;\n readonly submitCount: number;\n readonly isSubmitting: boolean;\n readonly isValidating: boolean;\n readonly submitError: AppError | null;\n /** The last completed submit's verdict — `null` until the first attempt completes and after `reset()`. */\n readonly isSubmitSuccessful: boolean | null;\n}\n\n/** The native house form instance — what `form.engine` exposes on the house adapter. */\nexport interface HouseFormEngine<TValues extends object> {\n /**\n * The raw store. Reading `state.value` inside a `computed` / render / `watchEffect` subscribes\n * to it — the engine's one reactive seam.\n */\n readonly state: Readonly<ShallowRef<unknown>>;\n readonly getFormState: () => AppFormState<TValues>;\n readonly getFieldState: (path: string) => HouseFieldState;\n readonly setValue: (path: string, value: unknown) => void;\n readonly blurField: (path: string) => void;\n readonly applyArrayOperation: (path: string, operation: ArrayOperation) => void;\n readonly reset: (next?: TValues) => void;\n readonly setFieldErrors: (errors: Record<string, ReadonlyArray<string>>) => void;\n readonly clearSubmitError: () => void;\n readonly submit: () => Promise<boolean>;\n /** Validates without submitting — populates errors, marks touched, resolves client validity. */\n readonly validate: (options?: AppFormValidationOptions<TValues>) => Promise<boolean>;\n readonly cancelSubmit: () => void;\n /** Releases the pending auto-submit timer (`submitOn: 'change'`) on scope teardown. */\n readonly dispose: () => void;\n}\n\nfunction mergeErrors(client: ErrorMap, server: ErrorMap): ErrorMap {\n const clientKeys = Object.keys(client);\n const serverKeys = Object.keys(server);\n if (serverKeys.length === 0) return client;\n if (clientKeys.length === 0) return server;\n const merged: Record<string, ReadonlyArray<string>> = Object.assign(Object.create(null), client);\n for (const key of serverKeys) {\n const existing = merged[key];\n merged[key] = existing ? [...existing, ...(server[key] ?? [])] : (server[key] ?? EmptyErrors);\n }\n return merged;\n}\n\nfunction sameMessages(a: ReadonlyArray<string>, b: ReadonlyArray<string>): boolean {\n return a === b || (a.length === b.length && a.every((message, index) => message === b[index]));\n}\n\nfunction fieldStatesEqual(a: HouseFieldState, b: HouseFieldState): boolean {\n return (\n Object.is(a.value, b.value) &&\n a.isDirty === b.isDirty &&\n a.isTouched === b.isTouched &&\n sameMessages(a.errors, b.errors)\n );\n}\n\nfunction normalizeErrorMap(errors: Record<string, ReadonlyArray<string>>): ErrorMap {\n const normalized: Record<string, ReadonlyArray<string>> = Object.create(null);\n for (const [path, messages] of Object.entries(errors)) normalized[path] = [...messages];\n return normalized;\n}\n\n/** Creates the house form store. `getOptions` reads the latest options (`AppFormOptionsSource`). */\nexport function createHouseFormEngine<TValues extends object, TOutput = TValues>(\n getOptions: () => AppFormOptions<TValues, TOutput>,\n): HouseFormEngine<TValues> {\n const initialValues = snapshotFormValues(getOptions().defaultValues);\n\n const store = shallowRef<InternalState<TValues>>({\n values: initialValues,\n baseline: snapshotFormValues(initialValues),\n clientErrors: EmptyMap,\n serverErrors: EmptyMap,\n errors: EmptyMap,\n touched: new Set<string>(),\n submitCount: 0,\n isSubmitting: false,\n isValidating: false,\n submitError: null,\n isSubmitSuccessful: null,\n });\n\n /** The generation the caches below belong to — swapped lazily on the first read after a commit. */\n let generation: InternalState<TValues> | null = null;\n let formState: AppFormState<TValues> | null = null;\n /** Per-path field slices for the current generation, rebuilt lazily and reusing identity when unchanged. */\n let fieldCache = new Map<string, HouseFieldState>();\n let previousFieldCache = new Map<string, HouseFieldState>();\n /** Monotonic guard: only the newest validation run may apply its result (async schemas). */\n let validationEpoch = 0;\n let lifecycleEpoch = 0;\n let requestController = new AbortController();\n let disposed = false;\n let trailingSubmit = false;\n let submittingValues: TValues | null = null;\n /** The pending trailing-debounce auto-submit timer (`submitOn: 'change'`); cleared on reset / teardown. */\n let autoSubmitTimer: ReturnType<typeof setTimeout> | null = null;\n /** Single-flight latch: an in-flight submit coalesces re-entrant triggers (double-click / change-burst). */\n let inFlight: Promise<boolean> | null = null;\n /** The form's message resolver, memoized against the `messages` / `labels` option identities. */\n const messageResolver = createOptionsMessageResolver(getOptions);\n\n /**\n * Reads the store — THE reactive dependency every getter below inherits — and rolls the cache\n * generation when it has moved. Rolling it on read, not eagerly in `commit`, keeps the commit\n * path free of work no one may look at.\n */\n function currentState(): InternalState<TValues> {\n const internal = store.value;\n if (generation !== internal) {\n generation = internal;\n formState = null;\n previousFieldCache = fieldCache;\n fieldCache = new Map();\n }\n return internal;\n }\n\n /** The untracked read — for the imperative paths (submit, validation, actions), which must never subscribe. */\n function peek(): InternalState<TValues> {\n return store.value;\n }\n\n function buildFormState(internal: InternalState<TValues>): AppFormState<TValues> {\n return {\n values: internal.values,\n isDirty: !deepEqual(internal.values, internal.baseline),\n isValid: Object.keys(internal.errors).length === 0,\n isSubmitting: internal.isSubmitting,\n isValidating: internal.isValidating,\n submitError: internal.submitError,\n isSubmitSuccessful: internal.isSubmitSuccessful,\n };\n }\n\n function commit(next: InternalState<TValues>): void {\n if (disposed) return;\n store.value = next;\n }\n\n function patch(partial: Partial<InternalState<TValues>>): void {\n const next = { ...peek(), ...partial };\n const errorsChanged = partial.clientErrors !== undefined || partial.serverErrors !== undefined;\n commit(errorsChanged ? { ...next, errors: mergeErrors(next.clientErrors, next.serverErrors) } : next);\n }\n\n function currentOptions(): AppFormOptions<TValues, TOutput> {\n return getOptions();\n }\n\n function shouldValidateOnChange(): boolean {\n const validateOn = currentOptions().validateOn ?? 'submit';\n // 'submit' (default) + 'blur' both re-validate on change after the first attempt,\n // so errors clear as the user fixes them.\n return validateOn === 'change' || peek().submitCount > 0 || peek().touched.size > 0;\n }\n\n function clearAutoSubmitTimer(): void {\n if (autoSubmitTimer !== null) {\n clearTimeout(autoSubmitTimer);\n autoSubmitTimer = null;\n }\n }\n\n /**\n * Schedules a trailing-debounced auto-submit for `submitOn: 'change'` — a user-origin write\n * calls this; a change burst coalesces onto one submit (the timer resets each write), and the\n * single-flight guard queues the latest overlapping edit. No-op for `'blur'` / `'manual'`. `reset()` cancels it.\n */\n function scheduleAutoSubmit(): void {\n if ((currentOptions().submitOn ?? 'manual') !== 'change') return;\n clearAutoSubmitTimer();\n const delay = currentOptions().submitDebounceMs ?? 0;\n autoSubmitTimer = setTimeout(() => {\n autoSubmitTimer = null;\n void submit();\n }, delay);\n }\n\n /** Runs whole-schema validation; sync schemas apply synchronously, async ones flip `isValidating`. */\n function runValidation(\n values = snapshotFormValues(peek().values),\n ): FormParseResult<TOutput> | Promise<FormParseResult<TOutput>> {\n const epoch = ++validationEpoch;\n const schema = currentOptions().schema;\n const apply = (result: FormParseResult<TOutput>): FormParseResult<TOutput> => {\n if (epoch === validationEpoch && deepEqual(values, peek().values)) {\n patch({ clientErrors: normalizeErrorMap(result.ok ? {} : result.failure.fieldErrors), isValidating: false });\n } else if (epoch === validationEpoch) patch({ isValidating: false });\n return result;\n };\n const failed = (): FormParseResult<TOutput> =>\n apply(formParseFailure({ '': [currentOptions().fallbackErrorMessage ?? 'Validation failed'] }));\n try {\n const outcome = schema\n ? parseStandardSchema(schema, snapshotFormValues(values), messageResolver())\n : { ok: true as const, value: snapshotFormValues(values) as unknown as TOutput };\n if (outcome instanceof Promise) {\n patch({ isValidating: true });\n return outcome.then(apply, failed);\n }\n return apply(outcome);\n } catch {\n return failed();\n }\n }\n\n function getFieldState(path: string): HouseFieldState {\n const state = currentState();\n const cached = fieldCache.get(path);\n if (cached) return cached;\n const value = getPath(state.values, path);\n const computed: HouseFieldState = {\n value,\n errors: state.errors[path] ?? EmptyErrors,\n isDirty: !deepEqual(value, getPath(state.baseline, path)),\n // A submit attempt counts as touching everything — error-display gating works post-attempt.\n isTouched:\n [...state.touched].some((selected) => includesValidationPath(path, [selected])) || state.submitCount > 0,\n };\n const previous = previousFieldCache.get(path);\n const stable = previous && fieldStatesEqual(previous, computed) ? previous : computed;\n fieldCache.set(path, stable);\n return stable;\n }\n\n function setValue(path: string, value: unknown): void {\n const state = peek();\n // Server messages clear on the next change to the field (contract JSDoc).\n const serverErrors = Object.prototype.hasOwnProperty.call(state.serverErrors, path)\n ? Object.fromEntries(Object.entries(state.serverErrors).filter(([key]) => key !== path))\n : state.serverErrors;\n patch({ values: setPath(state.values, path, snapshotFormValues(value)), serverErrors });\n if (shouldValidateOnChange()) void runValidation();\n scheduleAutoSubmit();\n }\n\n function blurField(path: string): void {\n const state = peek();\n if (!state.touched.has(path)) {\n const touched = new Set(state.touched);\n touched.add(path);\n patch({ touched });\n }\n const options = currentOptions();\n if ((options.validateOn ?? 'submit') === 'blur') void runValidation();\n if ((options.submitOn ?? 'manual') === 'blur') void submit();\n }\n\n function applyArrayOperation(path: string, operation: ArrayOperation): void {\n const state = peek();\n const current = getPath(state.values, path);\n const rows: unknown[] = Array.isArray(current) ? [...(current as unknown[])] : [];\n mutateRows(\n rows,\n operation.kind === 'push' || operation.kind === 'insert'\n ? { ...operation, value: snapshotFormValues(operation.value) }\n : operation,\n );\n patch({\n values: setPath(state.values, path, rows),\n // Row-scoped errors + touched marks follow their rows (insert/remove/swap/move reindex).\n clientErrors: remapPathMap(state.clientErrors, path, operation),\n serverErrors: remapPathMap(state.serverErrors, path, operation),\n touched: remapPathSet(state.touched, path, operation),\n });\n if (shouldValidateOnChange()) void runValidation();\n scheduleAutoSubmit();\n }\n\n function reset(next?: TValues): void {\n validationEpoch += 1;\n lifecycleEpoch += 1;\n requestController.abort();\n requestController = new AbortController();\n trailingSubmit = false;\n clearAutoSubmitTimer(); // a reset/prefill never auto-submits — drop any pending trailing submit\n const values = snapshotFormValues(next ?? peek().baseline);\n commit({\n values,\n baseline: snapshotFormValues(values),\n clientErrors: EmptyMap,\n serverErrors: EmptyMap,\n errors: EmptyMap,\n touched: new Set<string>(),\n submitCount: 0,\n isSubmitting: false,\n isValidating: false,\n submitError: null,\n isSubmitSuccessful: null,\n });\n }\n\n function setFieldErrorsAction(errors: Record<string, ReadonlyArray<string>>): void {\n patch({ serverErrors: normalizeErrorMap(errors) });\n }\n\n function clearSubmitError(): void {\n if (peek().submitError !== null) patch({ submitError: null });\n }\n\n async function performSubmit(values: TValues): Promise<boolean> {\n if (disposed || currentOptions().isDisabled) return false;\n const epoch = lifecycleEpoch;\n const signal = requestController.signal;\n const isCurrent = (): boolean => !disposed && epoch === lifecycleEpoch;\n patch({ submitCount: peek().submitCount + 1, serverErrors: EmptyMap, submitError: null, isSubmitSuccessful: null });\n const parsed = await runValidation(values);\n if (!isCurrent()) return false;\n if (!parsed.ok) {\n patch({ isSubmitSuccessful: false });\n return false;\n }\n const options = currentOptions();\n patch({ isSubmitting: true });\n let successful = false;\n try {\n const result = await untilFormAbort(options.onSubmit(parsed.value, { signal }), signal, {\n ok: false,\n failure: AppErrorFactory.cancelled(),\n });\n successful = result.ok;\n if (isCurrent() && result.ok) patch({ baseline: values });\n else if (isCurrent() && !result.ok) {\n const resolution = resolveSubmitFailure(\n result.failure,\n options.mapSubmitError ?? fieldIssues,\n options.mapFieldPath ?? defaultMapFieldPath,\n (path) => hasPath(values, path) && deepEqual(getPath(values, path), getPath(peek().values, path)),\n options.fallbackErrorMessage,\n messageResolver(),\n );\n patch({ serverErrors: normalizeErrorMap(resolution.fieldErrors), submitError: resolution.submitError });\n }\n } catch (error) {\n if (isCurrent()) {\n const resolution = resolveSubmitFailure(\n toSubmitError(error, options.fallbackErrorMessage),\n options.mapSubmitError ?? fieldIssues,\n options.mapFieldPath ?? defaultMapFieldPath,\n (path) => hasPath(values, path) && deepEqual(getPath(values, path), getPath(peek().values, path)),\n options.fallbackErrorMessage,\n messageResolver(),\n );\n patch({ serverErrors: normalizeErrorMap(resolution.fieldErrors), submitError: resolution.submitError });\n }\n } finally {\n if (isCurrent()) patch({ isSubmitting: false, isSubmitSuccessful: successful });\n }\n return successful && isCurrent();\n }\n\n /** Serializes submissions and coalesces newer edits into one trailing snapshot. */\n async function submit(): Promise<boolean> {\n if (disposed) return false;\n if (inFlight) {\n if (!deepEqual(peek().values, submittingValues)) trailingSubmit = true;\n return inFlight;\n }\n const run = async (): Promise<boolean> => {\n let successful = false;\n do {\n trailingSubmit = false;\n submittingValues = snapshotFormValues(peek().values);\n successful = await untilFormAbort(performSubmit(submittingValues), requestController.signal, false);\n } while (\n !disposed &&\n trailingSubmit &&\n !deepEqual(peek().values, submittingValues) &&\n !deepEqual(peek().values, peek().baseline)\n );\n return successful;\n };\n inFlight = run();\n try {\n return await inFlight;\n } finally {\n inFlight = null;\n submittingValues = null;\n }\n }\n\n /**\n * Validates without submitting — the validation half of `submit()`: marks every field touched\n * (so errors display and subsequent changes re-validate), runs the whole-form schema, and resolves\n * the client validity. `onSubmit` never runs; the server-error overlay is left untouched.\n */\n async function validate(options?: AppFormValidationOptions<TValues>): Promise<boolean> {\n if (disposed) return false;\n if (options) {\n const epoch = ++validationEpoch;\n const lifecycle = lifecycleEpoch;\n const values = snapshotFormValues(peek().values);\n const touched = new Set(peek().touched);\n for (const path of options.fields ?? Object.keys(values)) touched.add(path);\n patch({ touched, isValidating: true });\n const errors = await untilFormAbort(\n validateFormScope(\n values,\n options,\n currentOptions().schema,\n messageResolver(),\n currentOptions().fallbackErrorMessage ?? 'Validation failed',\n ),\n requestController.signal,\n {},\n );\n if (epoch !== validationEpoch || lifecycle !== lifecycleEpoch || disposed) return false;\n if (!deepEqual(values, peek().values)) {\n patch({ isValidating: false });\n return false;\n }\n const retained = Object.fromEntries(\n Object.entries(peek().clientErrors).filter(([path]) => !includesValidationPath(path, options.fields)),\n );\n patch({ clientErrors: Object.assign(Object.create(null), retained, errors), isValidating: false });\n return Object.keys(errors).length === 0;\n }\n if (peek().submitCount === 0) patch({ submitCount: 1 });\n const lifecycle = lifecycleEpoch;\n const values = snapshotFormValues(peek().values);\n const result = await untilFormAbort(Promise.resolve(runValidation(values)), requestController.signal, null);\n return (\n !disposed && lifecycle === lifecycleEpoch && deepEqual(values, peek().values) && result !== null && result.ok\n );\n }\n\n // Validate on mount when flagged — seed `isValid` / field errors before any interaction WITHOUT\n // marking fields touched (submitCount stays 0), so an edit screen shows validity without asserting\n // the user has interacted. Runs after every action above is defined.\n if (currentOptions().validateOnMount) void runValidation();\n\n return {\n state: store,\n getFormState: () => {\n const internal = currentState();\n formState ??= buildFormState(internal);\n return formState;\n },\n getFieldState,\n setValue,\n blurField,\n applyArrayOperation,\n reset,\n setFieldErrors: setFieldErrorsAction,\n clearSubmitError,\n submit,\n validate,\n cancelSubmit: () => {\n lifecycleEpoch += 1;\n validationEpoch += 1;\n requestController.abort();\n requestController = new AbortController();\n trailingSubmit = false;\n clearAutoSubmitTimer();\n patch({\n isSubmitting: false,\n isValidating: false,\n submitError: AppErrorFactory.cancelled(),\n isSubmitSuccessful: false,\n });\n },\n dispose: () => {\n requestController.abort();\n disposed = true;\n lifecycleEpoch += 1;\n validationEpoch += 1;\n trailingSubmit = false;\n clearAutoSubmitTimer();\n },\n };\n}\n"],"names":["lifecycle","values"],"mappings":";;;;;;;;;AAkCA,MAAM,cAAqC,OAAO,OAAO,EAAE;AAC3D,MAAM,WAAqB,OAAO,OAAO,uBAAO,OAAO,IAAI,CAA0C;AAkDrG,SAAS,YAAY,QAAkB,QAA4B;AACjE,QAAM,aAAa,OAAO,KAAK,MAAM;AACrC,QAAM,aAAa,OAAO,KAAK,MAAM;AACrC,MAAI,WAAW,WAAW,EAAG,QAAO;AACpC,MAAI,WAAW,WAAW,EAAG,QAAO;AACpC,QAAM,SAAgD,OAAO,8BAAc,OAAO,IAAI,GAAG,MAAM;AAC/F,aAAW,OAAO,YAAY;AAC5B,UAAM,WAAW,OAAO,GAAG;AAC3B,WAAO,GAAG,IAAI,WAAW,CAAC,GAAG,UAAU,GAAI,OAAO,GAAG,KAAK,CAAA,CAAG,IAAK,OAAO,GAAG,KAAK;AAAA,EACnF;AACA,SAAO;AACT;AAEA,SAAS,aAAa,GAA0B,GAAmC;AACjF,SAAO,MAAM,KAAM,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,CAAC,SAAS,UAAU,YAAY,EAAE,KAAK,CAAC;AAC9F;AAEA,SAAS,iBAAiB,GAAoB,GAA6B;AACzE,SACE,OAAO,GAAG,EAAE,OAAO,EAAE,KAAK,KAC1B,EAAE,YAAY,EAAE,WAChB,EAAE,cAAc,EAAE,aAClB,aAAa,EAAE,QAAQ,EAAE,MAAM;AAEnC;AAEA,SAAS,kBAAkB,QAAyD;AAClF,QAAM,aAAoD,uBAAO,OAAO,IAAI;AAC5E,aAAW,CAAC,MAAM,QAAQ,KAAK,OAAO,QAAQ,MAAM,EAAG,YAAW,IAAI,IAAI,CAAC,GAAG,QAAQ;AACtF,SAAO;AACT;AAGO,SAAS,sBACd,YAC0B;AAC1B,QAAM,gBAAgB,mBAAmB,WAAA,E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AAC,YAAY,cAAc,kBAAkB,UAAU,QAAQ,KAAA,EAAO,MAAM,KAAK,WAAW,QAAQ,OAAO;AAAA,EAE/G;AAKA,MAAI,eAAA,EAAiB,gBAAiB,MAAK,cAAA;AAE3C,SAAO;AAAA,IACL,OAAO;AAAA,IACP,cAAc,MAAM;AAClB,YAAM,WAAW,aAAA;AACjB,oBAAc,eAAe,QAAQ;AACrC,aAAO;AAAA,IACT;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,gBAAgB;AAAA,IAChB;AAAA,IACA;AAAA,IACA;AAAA,IACA,cAAc,MAAM;AAClB,wBAAkB;AAClB,yBAAmB;AACnB,wBAAkB,MAAA;AAClB,0BAAoB,IAAI,gBAAA;AACxB,uBAAiB;AACjB,2BAAA;AACA,YAAM;AAAA,QACJ,cAAc;AAAA,QACd,cAAc;AAAA,QACd,aAAa,gBAAgB,UAAA;AAAA,QAC7B,oBAAoB;AAAA,MAAA,CACrB;AAAA,IACH;AAAA,IACA,SAAS,MAAM;AACb,wBAAkB,MAAA;AAClB,iBAAW;AACX,wBAAkB;AAClB,yBAAmB;AACnB,uBAAiB;AACjB,2BAAA;AAAA,IACF;AAAA,EAAA;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"HouseFormCore.js","sources":["../../../../src/formsEngine/adapters/house/HouseFormCore.ts"],"sourcesContent":["import { shallowRef, type ShallowRef } from 'vue';\n\nimport { fieldIssues } from '../../../foundation/http';\nimport { AppErrorFactory, type AppError } from '../../../foundation/results';\n\nimport type { AppFormOptions, AppFormState, AppFormValidationOptions } from '../../AppForm';\nimport { deepEqual } from '../../DeepEqual';\nimport { includesValidationPath, resolveFieldDisplay, untilFormAbort, validateFormScope } from '../../FormOperations';\nimport { snapshotFormValues } from '../../FormSnapshot';\nimport { getPath, hasPath, mutateRows, remapPathMap, remapPathSet, setPath, type ArrayOperation } from '../../Paths';\nimport {\n createOptionsMessageResolver,\n parseStandardSchema,\n formParseFailure,\n type FormParseResult,\n} from '../../SchemaValidation';\nimport { defaultMapFieldPath, resolveSubmitFailure, toSubmitError } from '../../SubmitErrors';\n\n/*\n * The house micro-store — one immutable state object in a `shallowRef`.\n * SCOPE CEILING (docs/analysis/forms-engine.md §7): flat + dot-path store, whole-schema\n * Standard Schema validation, arrays, dirty/touched, submit pipeline. NO typed deep\n * paths, NO per-field async/debounce validators, NO linked-field graphs — a form that\n * needs those uses the tanstack adapter. Complete shared facade capabilities here;\n * vendor-specific graphs remain the `form.engine` escape hatch.\n *\n * NOTIFICATION IS THE `shallowRef` ITSELF — no listener list, no subscribe call. `commit` assigns\n * the ref and any getter that reads it is tracked wherever it is read. State stays ONE\n * frozen-by-convention object replaced whole, and the generation caching below hands out\n * identity-stable per-path slices so a field re-renders only when its own slice changed.\n */\n\ntype ErrorMap = Readonly<Record<string, ReadonlyArray<string>>>;\n\nconst EmptyErrors: ReadonlyArray<string> = Object.freeze([]);\nconst EmptyMap: ErrorMap = Object.freeze(Object.create(null) as Record<string, ReadonlyArray<string>>);\n\n/** The per-field slice the `Field` glue reads — identity-stable while its members are unchanged. */\nexport interface HouseFieldState {\n readonly value: unknown;\n readonly errors: ReadonlyArray<string>;\n readonly isDirty: boolean;\n readonly isTouched: boolean;\n}\n\ninterface InternalState<TValues extends object> {\n readonly values: TValues;\n /** The dirty baseline — `reset(next)` re-seeds it. */\n readonly baseline: TValues;\n readonly clientErrors: ErrorMap;\n readonly serverErrors: ErrorMap;\n /** Merged per-path messages, client first — rebuilt whenever either source changes. */\n readonly errors: ErrorMap;\n readonly touched: ReadonlySet<string>;\n /** Paths a write reached — never the blur mark `touched` holds. */\n readonly changed: ReadonlySet<string>;\n readonly submitCount: number;\n readonly isSubmitting: boolean;\n readonly isValidating: boolean;\n readonly submitError: AppError | null;\n /** The last completed submit's verdict — `null` until the first attempt completes and after `reset()`. */\n readonly isSubmitSuccessful: boolean | null;\n}\n\n/** The native house form instance — what `form.engine` exposes on the house adapter. */\nexport interface HouseFormEngine<TValues extends object> {\n /**\n * The raw store. Reading `state.value` inside a `computed` / render / `watchEffect` subscribes\n * to it — the engine's one reactive seam.\n */\n readonly state: Readonly<ShallowRef<unknown>>;\n readonly getFormState: () => AppFormState<TValues>;\n readonly getFieldState: (path: string) => HouseFieldState;\n readonly setValue: (path: string, value: unknown) => void;\n readonly blurField: (path: string) => void;\n readonly applyArrayOperation: (path: string, operation: ArrayOperation) => void;\n readonly reset: (next?: TValues) => void;\n readonly setFieldErrors: (errors: Record<string, ReadonlyArray<string>>) => void;\n readonly clearSubmitError: () => void;\n readonly submit: () => Promise<boolean>;\n /** Validates without submitting — populates errors, marks touched, resolves client validity. */\n readonly validate: (options?: AppFormValidationOptions<TValues>) => Promise<boolean>;\n readonly cancelSubmit: () => void;\n /** Releases the pending auto-submit timer (`submitOn: 'change'`) on scope teardown. */\n readonly dispose: () => void;\n}\n\nfunction mergeErrors(client: ErrorMap, server: ErrorMap): ErrorMap {\n const clientKeys = Object.keys(client);\n const serverKeys = Object.keys(server);\n if (serverKeys.length === 0) return client;\n if (clientKeys.length === 0) return server;\n const merged: Record<string, ReadonlyArray<string>> = Object.assign(Object.create(null), client);\n for (const key of serverKeys) {\n const existing = merged[key];\n merged[key] = existing ? [...existing, ...(server[key] ?? [])] : (server[key] ?? EmptyErrors);\n }\n return merged;\n}\n\nfunction sameMessages(a: ReadonlyArray<string>, b: ReadonlyArray<string>): boolean {\n return a === b || (a.length === b.length && a.every((message, index) => message === b[index]));\n}\n\nfunction fieldStatesEqual(a: HouseFieldState, b: HouseFieldState): boolean {\n return (\n Object.is(a.value, b.value) &&\n a.isDirty === b.isDirty &&\n a.isTouched === b.isTouched &&\n sameMessages(a.errors, b.errors)\n );\n}\n\nfunction normalizeErrorMap(errors: Record<string, ReadonlyArray<string>>): ErrorMap {\n const normalized: Record<string, ReadonlyArray<string>> = Object.create(null);\n for (const [path, messages] of Object.entries(errors)) normalized[path] = [...messages];\n return normalized;\n}\n\n/** Creates the house form store. `getOptions` reads the latest options (`AppFormOptionsSource`). */\nexport function createHouseFormEngine<TValues extends object, TOutput = TValues>(\n getOptions: () => AppFormOptions<TValues, TOutput>,\n): HouseFormEngine<TValues> {\n const initialValues = snapshotFormValues(getOptions().defaultValues);\n\n const store = shallowRef<InternalState<TValues>>({\n values: initialValues,\n baseline: snapshotFormValues(initialValues),\n clientErrors: EmptyMap,\n serverErrors: EmptyMap,\n errors: EmptyMap,\n touched: new Set<string>(),\n changed: new Set<string>(),\n submitCount: 0,\n isSubmitting: false,\n isValidating: false,\n submitError: null,\n isSubmitSuccessful: null,\n });\n\n /** The generation the caches below belong to — swapped lazily on the first read after a commit. */\n let generation: InternalState<TValues> | null = null;\n let formState: AppFormState<TValues> | null = null;\n /** Per-path field slices for the current generation, rebuilt lazily and reusing identity when unchanged. */\n let fieldCache = new Map<string, HouseFieldState>();\n let previousFieldCache = new Map<string, HouseFieldState>();\n /** Monotonic guard: only the newest validation run may apply its result (async schemas). */\n let validationEpoch = 0;\n let lifecycleEpoch = 0;\n let requestController = new AbortController();\n let disposed = false;\n let trailingSubmit = false;\n let submittingValues: TValues | null = null;\n /** The pending trailing-debounce auto-submit timer (`submitOn: 'change'`); cleared on reset / teardown. */\n let autoSubmitTimer: ReturnType<typeof setTimeout> | null = null;\n /** Single-flight latch: an in-flight submit coalesces re-entrant triggers (double-click / change-burst). */\n let inFlight: Promise<boolean> | null = null;\n /** The form's message resolver, memoized against the `messages` / `labels` option identities. */\n const messageResolver = createOptionsMessageResolver(getOptions);\n\n /**\n * Reads the store — THE reactive dependency every getter below inherits — and rolls the cache\n * generation when it has moved. Rolling it on read, not eagerly in `commit`, keeps the commit\n * path free of work no one may look at.\n */\n function currentState(): InternalState<TValues> {\n const internal = store.value;\n if (generation !== internal) {\n generation = internal;\n formState = null;\n previousFieldCache = fieldCache;\n fieldCache = new Map();\n }\n return internal;\n }\n\n /** The untracked read — for the imperative paths (submit, validation, actions), which must never subscribe. */\n function peek(): InternalState<TValues> {\n return store.value;\n }\n\n function buildFormState(internal: InternalState<TValues>): AppFormState<TValues> {\n return {\n values: internal.values,\n isDirty: !deepEqual(internal.values, internal.baseline),\n isValid: Object.keys(internal.errors).length === 0,\n isSubmitting: internal.isSubmitting,\n isValidating: internal.isValidating,\n submitError: internal.submitError,\n isSubmitSuccessful: internal.isSubmitSuccessful,\n };\n }\n\n function commit(next: InternalState<TValues>): void {\n if (disposed) return;\n store.value = next;\n }\n\n function patch(partial: Partial<InternalState<TValues>>): void {\n const next = { ...peek(), ...partial };\n const errorsChanged = partial.clientErrors !== undefined || partial.serverErrors !== undefined;\n commit(errorsChanged ? { ...next, errors: mergeErrors(next.clientErrors, next.serverErrors) } : next);\n }\n\n function currentOptions(): AppFormOptions<TValues, TOutput> {\n return getOptions();\n }\n\n function shouldValidateOnChange(): boolean {\n const validateOn = currentOptions().validateOn ?? 'submit';\n // 'submit' (default) + 'blur' both re-validate on change after the first attempt,\n // so errors clear as the user fixes them.\n return validateOn === 'change' || peek().submitCount > 0 || peek().touched.size > 0;\n }\n\n function clearAutoSubmitTimer(): void {\n if (autoSubmitTimer !== null) {\n clearTimeout(autoSubmitTimer);\n autoSubmitTimer = null;\n }\n }\n\n /**\n * Schedules a trailing-debounced auto-submit for `submitOn: 'change'` — a user-origin write\n * calls this; a change burst coalesces onto one submit (the timer resets each write), and the\n * single-flight guard queues the latest overlapping edit. No-op for `'blur'` / `'manual'`. `reset()` cancels it.\n */\n function scheduleAutoSubmit(): void {\n if ((currentOptions().submitOn ?? 'manual') !== 'change') return;\n clearAutoSubmitTimer();\n const delay = currentOptions().submitDebounceMs ?? 0;\n autoSubmitTimer = setTimeout(() => {\n autoSubmitTimer = null;\n void submit();\n }, delay);\n }\n\n /** Runs whole-schema validation; sync schemas apply synchronously, async ones flip `isValidating`. */\n function runValidation(\n values = snapshotFormValues(peek().values),\n ): FormParseResult<TOutput> | Promise<FormParseResult<TOutput>> {\n const epoch = ++validationEpoch;\n const schema = currentOptions().schema;\n const apply = (result: FormParseResult<TOutput>): FormParseResult<TOutput> => {\n if (epoch === validationEpoch && deepEqual(values, peek().values)) {\n patch({ clientErrors: normalizeErrorMap(result.ok ? {} : result.failure.fieldErrors), isValidating: false });\n } else if (epoch === validationEpoch) patch({ isValidating: false });\n return result;\n };\n const failed = (): FormParseResult<TOutput> =>\n apply(formParseFailure({ '': [currentOptions().fallbackErrorMessage ?? 'Validation failed'] }));\n try {\n const outcome = schema\n ? parseStandardSchema(schema, snapshotFormValues(values), messageResolver())\n : { ok: true as const, value: snapshotFormValues(values) as unknown as TOutput };\n if (outcome instanceof Promise) {\n patch({ isValidating: true });\n return outcome.then(apply, failed);\n }\n return apply(outcome);\n } catch {\n return failed();\n }\n }\n\n function getFieldState(path: string): HouseFieldState {\n const state = currentState();\n const cached = fieldCache.get(path);\n if (cached) return cached;\n const value = getPath(state.values, path);\n const { isTouched, showsClientErrors } = resolveFieldDisplay(path, state, currentOptions().validateOn);\n // Validation is form-wide; display follows the field's own marks. Server messages always display.\n const client = showsClientErrors ? (state.clientErrors[path] ?? EmptyErrors) : EmptyErrors;\n const server = state.serverErrors[path] ?? EmptyErrors;\n const computed: HouseFieldState = {\n value,\n errors: server.length === 0 ? client : client.length === 0 ? server : [...client, ...server],\n isDirty: !deepEqual(value, getPath(state.baseline, path)),\n isTouched,\n };\n const previous = previousFieldCache.get(path);\n const stable = previous && fieldStatesEqual(previous, computed) ? previous : computed;\n fieldCache.set(path, stable);\n return stable;\n }\n\n function setValue(path: string, value: unknown): void {\n const state = peek();\n // Server messages clear on the next change to the field (contract JSDoc).\n const serverErrors = Object.prototype.hasOwnProperty.call(state.serverErrors, path)\n ? Object.fromEntries(Object.entries(state.serverErrors).filter(([key]) => key !== path))\n : state.serverErrors;\n patch({\n values: setPath(state.values, path, snapshotFormValues(value)),\n serverErrors,\n changed: state.changed.has(path) ? state.changed : new Set(state.changed).add(path),\n });\n if (shouldValidateOnChange()) void runValidation();\n scheduleAutoSubmit();\n }\n\n function blurField(path: string): void {\n const state = peek();\n if (!state.touched.has(path)) {\n const touched = new Set(state.touched);\n touched.add(path);\n patch({ touched });\n }\n const options = currentOptions();\n if ((options.validateOn ?? 'submit') === 'blur') void runValidation();\n if ((options.submitOn ?? 'manual') === 'blur') void submit();\n }\n\n function applyArrayOperation(path: string, operation: ArrayOperation): void {\n const state = peek();\n const current = getPath(state.values, path);\n const rows: unknown[] = Array.isArray(current) ? [...(current as unknown[])] : [];\n mutateRows(\n rows,\n operation.kind === 'push' || operation.kind === 'insert'\n ? { ...operation, value: snapshotFormValues(operation.value) }\n : operation,\n );\n patch({\n values: setPath(state.values, path, rows),\n // Row-scoped errors + touched marks follow their rows (insert/remove/swap/move reindex).\n clientErrors: remapPathMap(state.clientErrors, path, operation),\n serverErrors: remapPathMap(state.serverErrors, path, operation),\n touched: remapPathSet(state.touched, path, operation),\n changed: remapPathSet(new Set(state.changed).add(path), path, operation),\n });\n if (shouldValidateOnChange()) void runValidation();\n scheduleAutoSubmit();\n }\n\n function reset(next?: TValues): void {\n validationEpoch += 1;\n lifecycleEpoch += 1;\n requestController.abort();\n requestController = new AbortController();\n trailingSubmit = false;\n clearAutoSubmitTimer(); // a reset/prefill never auto-submits — drop any pending trailing submit\n const values = snapshotFormValues(next ?? peek().baseline);\n commit({\n values,\n baseline: snapshotFormValues(values),\n clientErrors: EmptyMap,\n serverErrors: EmptyMap,\n errors: EmptyMap,\n touched: new Set<string>(),\n changed: new Set<string>(),\n submitCount: 0,\n isSubmitting: false,\n isValidating: false,\n submitError: null,\n isSubmitSuccessful: null,\n });\n }\n\n function setFieldErrorsAction(errors: Record<string, ReadonlyArray<string>>): void {\n patch({ serverErrors: normalizeErrorMap(errors) });\n }\n\n function clearSubmitError(): void {\n if (peek().submitError !== null) patch({ submitError: null });\n }\n\n async function performSubmit(values: TValues): Promise<boolean> {\n if (disposed || currentOptions().isDisabled) return false;\n const epoch = lifecycleEpoch;\n const signal = requestController.signal;\n const isCurrent = (): boolean => !disposed && epoch === lifecycleEpoch;\n patch({ submitCount: peek().submitCount + 1, serverErrors: EmptyMap, submitError: null, isSubmitSuccessful: null });\n const parsed = await runValidation(values);\n if (!isCurrent()) return false;\n if (!parsed.ok) {\n patch({ isSubmitSuccessful: false });\n return false;\n }\n const options = currentOptions();\n patch({ isSubmitting: true });\n let successful = false;\n try {\n const result = await untilFormAbort(options.onSubmit(parsed.value, { signal }), signal, {\n ok: false,\n failure: AppErrorFactory.cancelled(),\n });\n successful = result.ok;\n if (isCurrent() && result.ok) patch({ baseline: values });\n else if (isCurrent() && !result.ok) {\n const resolution = resolveSubmitFailure(\n result.failure,\n options.mapSubmitError ?? fieldIssues,\n options.mapFieldPath ?? defaultMapFieldPath,\n (path) => hasPath(values, path) && deepEqual(getPath(values, path), getPath(peek().values, path)),\n options.fallbackErrorMessage,\n messageResolver(),\n );\n patch({ serverErrors: normalizeErrorMap(resolution.fieldErrors), submitError: resolution.submitError });\n }\n } catch (error) {\n if (isCurrent()) {\n const resolution = resolveSubmitFailure(\n toSubmitError(error, options.fallbackErrorMessage),\n options.mapSubmitError ?? fieldIssues,\n options.mapFieldPath ?? defaultMapFieldPath,\n (path) => hasPath(values, path) && deepEqual(getPath(values, path), getPath(peek().values, path)),\n options.fallbackErrorMessage,\n messageResolver(),\n );\n patch({ serverErrors: normalizeErrorMap(resolution.fieldErrors), submitError: resolution.submitError });\n }\n } finally {\n if (isCurrent()) patch({ isSubmitting: false, isSubmitSuccessful: successful });\n }\n return successful && isCurrent();\n }\n\n /** Serializes submissions and coalesces newer edits into one trailing snapshot. */\n async function submit(): Promise<boolean> {\n if (disposed) return false;\n if (inFlight) {\n if (!deepEqual(peek().values, submittingValues)) trailingSubmit = true;\n return inFlight;\n }\n const run = async (): Promise<boolean> => {\n let successful = false;\n do {\n trailingSubmit = false;\n submittingValues = snapshotFormValues(peek().values);\n successful = await untilFormAbort(performSubmit(submittingValues), requestController.signal, false);\n } while (\n !disposed &&\n trailingSubmit &&\n !deepEqual(peek().values, submittingValues) &&\n !deepEqual(peek().values, peek().baseline)\n );\n return successful;\n };\n inFlight = run();\n try {\n return await inFlight;\n } finally {\n inFlight = null;\n submittingValues = null;\n }\n }\n\n /**\n * Validates without submitting — the validation half of `submit()`: marks every field touched\n * (so errors display and subsequent changes re-validate), runs the whole-form schema, and resolves\n * the client validity. `onSubmit` never runs; the server-error overlay is left untouched.\n */\n async function validate(options?: AppFormValidationOptions<TValues>): Promise<boolean> {\n if (disposed) return false;\n if (options) {\n const epoch = ++validationEpoch;\n const lifecycle = lifecycleEpoch;\n const values = snapshotFormValues(peek().values);\n const touched = new Set(peek().touched);\n for (const path of options.fields ?? Object.keys(values)) touched.add(path);\n patch({ touched, isValidating: true });\n const errors = await untilFormAbort(\n validateFormScope(\n values,\n options,\n currentOptions().schema,\n messageResolver(),\n currentOptions().fallbackErrorMessage ?? 'Validation failed',\n ),\n requestController.signal,\n {},\n );\n if (epoch !== validationEpoch || lifecycle !== lifecycleEpoch || disposed) return false;\n if (!deepEqual(values, peek().values)) {\n patch({ isValidating: false });\n return false;\n }\n const retained = Object.fromEntries(\n Object.entries(peek().clientErrors).filter(([path]) => !includesValidationPath(path, options.fields)),\n );\n patch({ clientErrors: Object.assign(Object.create(null), retained, errors), isValidating: false });\n return Object.keys(errors).length === 0;\n }\n if (peek().submitCount === 0) patch({ submitCount: 1 });\n const lifecycle = lifecycleEpoch;\n const values = snapshotFormValues(peek().values);\n const result = await untilFormAbort(Promise.resolve(runValidation(values)), requestController.signal, null);\n return (\n !disposed && lifecycle === lifecycleEpoch && deepEqual(values, peek().values) && result !== null && result.ok\n );\n }\n\n // Validate on mount when flagged — seed `isValid` / field errors before any interaction WITHOUT\n // marking fields touched (submitCount stays 0), so an edit screen shows validity without asserting\n // the user has interacted. Runs after every action above is defined.\n if (currentOptions().validateOnMount) void runValidation();\n\n return {\n state: store,\n getFormState: () => {\n const internal = currentState();\n formState ??= buildFormState(internal);\n return formState;\n },\n getFieldState,\n setValue,\n blurField,\n applyArrayOperation,\n reset,\n setFieldErrors: setFieldErrorsAction,\n clearSubmitError,\n submit,\n validate,\n cancelSubmit: () => {\n lifecycleEpoch += 1;\n validationEpoch += 1;\n requestController.abort();\n requestController = new AbortController();\n trailingSubmit = false;\n clearAutoSubmitTimer();\n patch({\n isSubmitting: false,\n isValidating: false,\n submitError: AppErrorFactory.cancelled(),\n isSubmitSuccessful: false,\n });\n },\n dispose: () => {\n requestController.abort();\n disposed = true;\n lifecycleEpoch += 1;\n validationEpoch += 1;\n trailingSubmit = false;\n clearAutoSubmitTimer();\n },\n };\n}\n"],"names":["lifecycle","values"],"mappings":";;;;;;;;;AAkCA,MAAM,cAAqC,OAAO,OAAO,EAAE;AAC3D,MAAM,WAAqB,OAAO,OAAO,uBAAO,OAAO,IAAI,CAA0C;AAoDrG,SAAS,YAAY,QAAkB,QAA4B;AACjE,QAAM,aAAa,OAAO,KAAK,MAAM;AACrC,QAAM,aAAa,OAAO,KAAK,MAAM;AACrC,MAAI,WAAW,WAAW,EAAG,QAAO;AACpC,MAAI,WAAW,WAAW,EAAG,QAAO;AACpC,QAAM,SAAgD,OAAO,8BAAc,OAAO,IAAI,GAAG,MAAM;AAC/F,aAAW,OAAO,YAAY;AAC5B,UAAM,WAAW,OAAO,GAAG;AAC3B,WAAO,GAAG,IAAI,WAAW,CAAC,GAAG,UAAU,GAAI,OAAO,GAAG,KAAK,CAAA,CAAG,IAAK,OAAO,GAAG,KAAK;AAAA,EACnF;AACA,SAAO;AACT;AAEA,SAAS,aAAa,GAA0B,GAAmC;AACjF,SAAO,MAAM,KAAM,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,CAAC,SAAS,UAAU,YAAY,EAAE,KAAK,CAAC;AAC9F;AAEA,SAAS,iBAAiB,GAAoB,GAA6B;AACzE,SACE,OAAO,GAAG,EAAE,OAAO,EAAE,KAAK,KAC1B,EAAE,YAAY,EAAE,WAChB,EAAE,cAAc,EAAE,aAClB,aAAa,EAAE,QAAQ,EAAE,MAAM;AAEnC;AAEA,SA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AAA,IACA,SAAS,MAAM;AACb,wBAAkB,MAAA;AAClB,iBAAW;AACX,wBAAkB;AAClB,yBAAmB;AACnB,uBAAiB;AACjB,2BAAA;AAAA,IACF;AAAA,EAAA;AAEJ;"}
|
|
@@ -13,6 +13,8 @@ export interface TanstackOverlayState<TValues extends object> {
|
|
|
13
13
|
/** The server-error overlay, keyed by form path (`rules[0].destination`). */
|
|
14
14
|
readonly serverErrors: ErrorMap;
|
|
15
15
|
readonly touched: ReadonlySet<string>;
|
|
16
|
+
/** Paths a write reached (`setValue`, array operations) — never the blur mark `touched` holds. */
|
|
17
|
+
readonly changed: ReadonlySet<string>;
|
|
16
18
|
readonly submitCount: number;
|
|
17
19
|
readonly isSubmitting: boolean;
|
|
18
20
|
readonly submitError: AppError | null;
|
|
@@ -26,6 +28,8 @@ export interface TanstackFormOverlay<TValues extends object> {
|
|
|
26
28
|
readonly getState: () => TanstackOverlayState<TValues>;
|
|
27
29
|
/** Marks a field touched (wired onto the control's blur). */
|
|
28
30
|
readonly markBlurred: (path: string) => void;
|
|
31
|
+
/** Marks a path written (`setValue` / array operation) — drives error display under `validateOn: 'change'`. */
|
|
32
|
+
readonly markChanged: (path: string) => void;
|
|
29
33
|
/** Server messages clear on the next change to the field (contract JSDoc). */
|
|
30
34
|
readonly clearServerErrorsAt: (path: string) => void;
|
|
31
35
|
/** Row-scoped server errors + touched marks follow their rows through array ops. */
|
|
@@ -14,6 +14,7 @@ function createTanstackFormOverlay(initialBaseline) {
|
|
|
14
14
|
isScopeValidating: false,
|
|
15
15
|
serverErrors: EmptyMap,
|
|
16
16
|
touched: /* @__PURE__ */ new Set(),
|
|
17
|
+
changed: /* @__PURE__ */ new Set(),
|
|
17
18
|
submitCount: 0,
|
|
18
19
|
isSubmitting: false,
|
|
19
20
|
submitError: null,
|
|
@@ -34,6 +35,12 @@ function createTanstackFormOverlay(initialBaseline) {
|
|
|
34
35
|
touched.add(path);
|
|
35
36
|
patch({ touched });
|
|
36
37
|
},
|
|
38
|
+
markChanged: (path) => {
|
|
39
|
+
if (store.value.changed.has(path)) return;
|
|
40
|
+
const changed = new Set(store.value.changed);
|
|
41
|
+
changed.add(path);
|
|
42
|
+
patch({ changed });
|
|
43
|
+
},
|
|
37
44
|
clearServerErrorsAt: (path) => {
|
|
38
45
|
if (!Object.prototype.hasOwnProperty.call(store.value.serverErrors, path)) return;
|
|
39
46
|
patch({
|
|
@@ -43,7 +50,8 @@ function createTanstackFormOverlay(initialBaseline) {
|
|
|
43
50
|
remapForArrayOperation: (arrayPath, operation) => {
|
|
44
51
|
patch({
|
|
45
52
|
serverErrors: remapPathMap(store.value.serverErrors, arrayPath, operation),
|
|
46
|
-
touched: remapPathSet(store.value.touched, arrayPath, operation)
|
|
53
|
+
touched: remapPathSet(store.value.touched, arrayPath, operation),
|
|
54
|
+
changed: remapPathSet(store.value.changed, arrayPath, operation)
|
|
47
55
|
});
|
|
48
56
|
},
|
|
49
57
|
beginSubmitAttempt: () => {
|
|
@@ -86,6 +94,7 @@ function createTanstackFormOverlay(initialBaseline) {
|
|
|
86
94
|
isScopeValidating: false,
|
|
87
95
|
serverErrors: EmptyMap,
|
|
88
96
|
touched: /* @__PURE__ */ new Set(),
|
|
97
|
+
changed: /* @__PURE__ */ new Set(),
|
|
89
98
|
submitCount: 0,
|
|
90
99
|
isSubmitting: false,
|
|
91
100
|
submitError: null,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TanstackFormOverlay.js","sources":["../../../../src/formsEngine/adapters/tanstack/TanstackFormOverlay.ts"],"sourcesContent":["import { shallowRef, type ShallowRef } from 'vue';\n\nimport type { AppError } from '../../../foundation/results';\n\nimport { remapPathMap, remapPathSet, type ArrayOperation } from '../../Paths';\nimport type { SubmitFailureResolution } from '../../SubmitErrors';\n\n/*\n * The adapter-owned overlay store — the contract state TanStack Form does not model\n * (docs/analysis/forms-engine.md §4/§5). TanStack has no client/server error merge, its\n * touched marks on change (contract: blur OR submit attempt), its dirty is sticky\n * per-field (contract: deep-compared against a resettable baseline), and its array\n * reindexing of field meta differs from the contract's remap rules. All four live here,\n * outside TanStack state, exactly like the house engine keeps them:\n * - `serverErrors` — the server-error overlay, cleared per-path on the next change,\n * replaced wholesale by `setFieldErrors`, remapped through array ops.\n * - `baseline` — the dirty baseline `reset(next)` re-seeds.\n * - `touched` — blur marks; `submitCount > 0` touches everything.\n * - `isSubmitting` / `submitError` — the contract submit pipeline flags: `isSubmitting`\n * wraps only the app's `onSubmit` call (not TanStack's validation window), and\n * `submitError` holds the failure remainder no field could represent.\n *\n * The overlay is one immutable object in a `shallowRef`, so a read of `state.value` is the\n * subscription. TanStack's own store stays a `@tanstack/store` `Store` — the adapter bridges it\n * separately.\n */\n\ntype ErrorMap = Readonly<Record<string, ReadonlyArray<string>>>;\n\nconst EmptyMap: ErrorMap = Object.freeze(Object.create(null) as Record<string, ReadonlyArray<string>>);\n\n/** The adapter-owned slice merged with TanStack state into the contract's form/field state. */\nexport interface TanstackOverlayState<TValues extends object> {\n /** The dirty baseline — `reset(next)` re-seeds it. */\n readonly baseline: TValues;\n readonly scopedErrors: ErrorMap | null;\n readonly scopedFields: ReadonlyArray<string> | undefined;\n readonly isScopeValidating: boolean;\n /** The server-error overlay, keyed by form path (`rules[0].destination`). */\n readonly serverErrors: ErrorMap;\n readonly touched: ReadonlySet<string>;\n readonly submitCount: number;\n readonly isSubmitting: boolean;\n readonly submitError: AppError | null;\n /** The last completed submit's verdict — `null` until the first attempt completes and after `reset()`. */\n readonly isSubmitSuccessful: boolean | null;\n}\n\n/** The overlay store the tanstack adapter combines with the TanStack form store. */\nexport interface TanstackFormOverlay<TValues extends object> {\n /** The reactive seam; reading `state.value` subscribes. */\n readonly state: Readonly<ShallowRef<TanstackOverlayState<TValues>>>;\n readonly getState: () => TanstackOverlayState<TValues>;\n /** Marks a field touched (wired onto the control's blur). */\n readonly markBlurred: (path: string) => void;\n /** Server messages clear on the next change to the field (contract JSDoc). */\n readonly clearServerErrorsAt: (path: string) => void;\n /** Row-scoped server errors + touched marks follow their rows through array ops. */\n readonly remapForArrayOperation: (arrayPath: string, operation: ArrayOperation) => void;\n /** A new attempt clears prior server errors, re-arms the verdict, and counts as touching every field. */\n readonly beginSubmitAttempt: () => void;\n /** Marks every field touched without clearing errors or the verdict — `validate()`'s display gate. */\n readonly touchAll: () => void;\n /** Brackets the app's `onSubmit` call — the contract's `isSubmitting` window. */\n readonly setSubmitting: (isSubmitting: boolean) => void;\n /** Settles the last completed submit's verdict (`handleSubmit` mirrors it into `isSubmitSuccessful`). */\n readonly setSubmitSuccessful: (value: boolean | null) => void;\n /** Lands a resolved submit failure: matches as the server overlay, remainder as `submitError`. */\n readonly applySubmitFailure: (resolution: SubmitFailureResolution) => void;\n /** Replaces the server-error overlay (`setFieldErrors`). */\n readonly replaceServerErrors: (errors: Record<string, ReadonlyArray<string>>) => void;\n /** Clears the form-level `submitError` without touching field errors (`clearSubmitError`). */\n readonly clearSubmitError: () => void;\n /** Clears everything and re-seeds the dirty baseline. */\n readonly reset: (baseline: TValues) => void;\n /** Advances the saved baseline without replacing newer editing values. */\n readonly setScope: (errors: ErrorMap | null, fields?: ReadonlyArray<string>) => void;\n readonly setScopeValidating: (value: boolean) => void;\n readonly setBaseline: (baseline: TValues) => void;\n}\n\nfunction normalizeErrorMap(errors: Record<string, ReadonlyArray<string>>): ErrorMap {\n const normalized: Record<string, ReadonlyArray<string>> = Object.create(null);\n for (const [path, messages] of Object.entries(errors)) normalized[path] = [...messages];\n return normalized;\n}\n\n/** Creates the adapter-owned overlay store seeded with the initial dirty baseline. */\nexport function createTanstackFormOverlay<TValues extends object>(\n initialBaseline: TValues,\n): TanstackFormOverlay<TValues> {\n const store = shallowRef<TanstackOverlayState<TValues>>({\n baseline: initialBaseline,\n scopedErrors: null,\n scopedFields: undefined,\n isScopeValidating: false,\n serverErrors: EmptyMap,\n touched: new Set<string>(),\n submitCount: 0,\n isSubmitting: false,\n submitError: null,\n isSubmitSuccessful: null,\n });\n\n function commit(next: TanstackOverlayState<TValues>): void {\n store.value = next;\n }\n\n function patch(partial: Partial<TanstackOverlayState<TValues>>): void {\n commit({ ...store.value, ...partial });\n }\n\n return {\n state: store,\n getState: () => store.value,\n markBlurred: (path) => {\n if (store.value.touched.has(path)) return;\n const touched = new Set(store.value.touched);\n touched.add(path);\n patch({ touched });\n },\n clearServerErrorsAt: (path) => {\n if (!Object.prototype.hasOwnProperty.call(store.value.serverErrors, path)) return;\n patch({\n serverErrors: Object.fromEntries(Object.entries(store.value.serverErrors).filter(([key]) => key !== path)),\n });\n },\n remapForArrayOperation: (arrayPath, operation) => {\n patch({\n serverErrors: remapPathMap(store.value.serverErrors, arrayPath, operation),\n touched: remapPathSet(store.value.touched, arrayPath, operation),\n });\n },\n beginSubmitAttempt: () => {\n patch({\n submitCount: store.value.submitCount + 1,\n serverErrors: EmptyMap,\n submitError: null,\n isSubmitSuccessful: null,\n });\n },\n touchAll: () => {\n if (store.value.submitCount === 0) patch({ submitCount: 1 });\n },\n setSubmitting: (isSubmitting) => {\n if (store.value.isSubmitting !== isSubmitting) patch({ isSubmitting });\n },\n setSubmitSuccessful: (value) => {\n if (store.value.isSubmitSuccessful !== value) patch({ isSubmitSuccessful: value });\n },\n applySubmitFailure: (resolution) => {\n patch({\n serverErrors: normalizeErrorMap(resolution.fieldErrors),\n submitError: resolution.submitError,\n });\n },\n replaceServerErrors: (errors) => {\n patch({ serverErrors: normalizeErrorMap(errors) });\n },\n clearSubmitError: () => {\n if (store.value.submitError !== null) patch({ submitError: null });\n },\n setScope: (scopedErrors, scopedFields) => patch({ scopedErrors, scopedFields }),\n setScopeValidating: (isScopeValidating) => patch({ isScopeValidating }),\n setBaseline: (baseline) => patch({ baseline }),\n reset: (baseline) => {\n commit({\n baseline,\n scopedErrors: null,\n scopedFields: undefined,\n isScopeValidating: false,\n serverErrors: EmptyMap,\n touched: new Set<string>(),\n submitCount: 0,\n isSubmitting: false,\n submitError: null,\n isSubmitSuccessful: null,\n });\n },\n };\n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AAA,QACb,cAAc;AAAA,QACd,aAAa;AAAA,QACb,oBAAoB;AAAA,MAAA,CACrB;AAAA,IACH;AAAA,EAAA;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"TanstackFormOverlay.js","sources":["../../../../src/formsEngine/adapters/tanstack/TanstackFormOverlay.ts"],"sourcesContent":["import { shallowRef, type ShallowRef } from 'vue';\n\nimport type { AppError } from '../../../foundation/results';\n\nimport { remapPathMap, remapPathSet, type ArrayOperation } from '../../Paths';\nimport type { SubmitFailureResolution } from '../../SubmitErrors';\n\n/*\n * The adapter-owned overlay store — the contract state TanStack Form does not model\n * (docs/analysis/forms-engine.md §4/§5). TanStack has no client/server error merge, its\n * touched marks on change (contract: blur OR submit attempt), its dirty is sticky\n * per-field (contract: deep-compared against a resettable baseline), and its array\n * reindexing of field meta differs from the contract's remap rules. All four live here,\n * outside TanStack state, exactly like the house engine keeps them:\n * - `serverErrors` — the server-error overlay, cleared per-path on the next change,\n * replaced wholesale by `setFieldErrors`, remapped through array ops.\n * - `baseline` — the dirty baseline `reset(next)` re-seeds.\n * - `touched` — blur marks; `submitCount > 0` touches everything.\n * - `changed` — paths a write reached; with `validateOn: 'change'` a changed field shows its\n * client error (see `AppForm.spec.md` § Error display).\n * - `isSubmitting` / `submitError` — the contract submit pipeline flags: `isSubmitting`\n * wraps only the app's `onSubmit` call (not TanStack's validation window), and\n * `submitError` holds the failure remainder no field could represent.\n *\n * The overlay is one immutable object in a `shallowRef`, so a read of `state.value` is the\n * subscription. TanStack's own store stays a `@tanstack/store` `Store` — the adapter bridges it\n * separately.\n */\n\ntype ErrorMap = Readonly<Record<string, ReadonlyArray<string>>>;\n\nconst EmptyMap: ErrorMap = Object.freeze(Object.create(null) as Record<string, ReadonlyArray<string>>);\n\n/** The adapter-owned slice merged with TanStack state into the contract's form/field state. */\nexport interface TanstackOverlayState<TValues extends object> {\n /** The dirty baseline — `reset(next)` re-seeds it. */\n readonly baseline: TValues;\n readonly scopedErrors: ErrorMap | null;\n readonly scopedFields: ReadonlyArray<string> | undefined;\n readonly isScopeValidating: boolean;\n /** The server-error overlay, keyed by form path (`rules[0].destination`). */\n readonly serverErrors: ErrorMap;\n readonly touched: ReadonlySet<string>;\n /** Paths a write reached (`setValue`, array operations) — never the blur mark `touched` holds. */\n readonly changed: ReadonlySet<string>;\n readonly submitCount: number;\n readonly isSubmitting: boolean;\n readonly submitError: AppError | null;\n /** The last completed submit's verdict — `null` until the first attempt completes and after `reset()`. */\n readonly isSubmitSuccessful: boolean | null;\n}\n\n/** The overlay store the tanstack adapter combines with the TanStack form store. */\nexport interface TanstackFormOverlay<TValues extends object> {\n /** The reactive seam; reading `state.value` subscribes. */\n readonly state: Readonly<ShallowRef<TanstackOverlayState<TValues>>>;\n readonly getState: () => TanstackOverlayState<TValues>;\n /** Marks a field touched (wired onto the control's blur). */\n readonly markBlurred: (path: string) => void;\n /** Marks a path written (`setValue` / array operation) — drives error display under `validateOn: 'change'`. */\n readonly markChanged: (path: string) => void;\n /** Server messages clear on the next change to the field (contract JSDoc). */\n readonly clearServerErrorsAt: (path: string) => void;\n /** Row-scoped server errors + touched marks follow their rows through array ops. */\n readonly remapForArrayOperation: (arrayPath: string, operation: ArrayOperation) => void;\n /** A new attempt clears prior server errors, re-arms the verdict, and counts as touching every field. */\n readonly beginSubmitAttempt: () => void;\n /** Marks every field touched without clearing errors or the verdict — `validate()`'s display gate. */\n readonly touchAll: () => void;\n /** Brackets the app's `onSubmit` call — the contract's `isSubmitting` window. */\n readonly setSubmitting: (isSubmitting: boolean) => void;\n /** Settles the last completed submit's verdict (`handleSubmit` mirrors it into `isSubmitSuccessful`). */\n readonly setSubmitSuccessful: (value: boolean | null) => void;\n /** Lands a resolved submit failure: matches as the server overlay, remainder as `submitError`. */\n readonly applySubmitFailure: (resolution: SubmitFailureResolution) => void;\n /** Replaces the server-error overlay (`setFieldErrors`). */\n readonly replaceServerErrors: (errors: Record<string, ReadonlyArray<string>>) => void;\n /** Clears the form-level `submitError` without touching field errors (`clearSubmitError`). */\n readonly clearSubmitError: () => void;\n /** Clears everything and re-seeds the dirty baseline. */\n readonly reset: (baseline: TValues) => void;\n /** Advances the saved baseline without replacing newer editing values. */\n readonly setScope: (errors: ErrorMap | null, fields?: ReadonlyArray<string>) => void;\n readonly setScopeValidating: (value: boolean) => void;\n readonly setBaseline: (baseline: TValues) => void;\n}\n\nfunction normalizeErrorMap(errors: Record<string, ReadonlyArray<string>>): ErrorMap {\n const normalized: Record<string, ReadonlyArray<string>> = Object.create(null);\n for (const [path, messages] of Object.entries(errors)) normalized[path] = [...messages];\n return normalized;\n}\n\n/** Creates the adapter-owned overlay store seeded with the initial dirty baseline. */\nexport function createTanstackFormOverlay<TValues extends object>(\n initialBaseline: TValues,\n): TanstackFormOverlay<TValues> {\n const store = shallowRef<TanstackOverlayState<TValues>>({\n baseline: initialBaseline,\n scopedErrors: null,\n scopedFields: undefined,\n isScopeValidating: false,\n serverErrors: EmptyMap,\n touched: new Set<string>(),\n changed: new Set<string>(),\n submitCount: 0,\n isSubmitting: false,\n submitError: null,\n isSubmitSuccessful: null,\n });\n\n function commit(next: TanstackOverlayState<TValues>): void {\n store.value = next;\n }\n\n function patch(partial: Partial<TanstackOverlayState<TValues>>): void {\n commit({ ...store.value, ...partial });\n }\n\n return {\n state: store,\n getState: () => store.value,\n markBlurred: (path) => {\n if (store.value.touched.has(path)) return;\n const touched = new Set(store.value.touched);\n touched.add(path);\n patch({ touched });\n },\n markChanged: (path) => {\n if (store.value.changed.has(path)) return;\n const changed = new Set(store.value.changed);\n changed.add(path);\n patch({ changed });\n },\n clearServerErrorsAt: (path) => {\n if (!Object.prototype.hasOwnProperty.call(store.value.serverErrors, path)) return;\n patch({\n serverErrors: Object.fromEntries(Object.entries(store.value.serverErrors).filter(([key]) => key !== path)),\n });\n },\n remapForArrayOperation: (arrayPath, operation) => {\n patch({\n serverErrors: remapPathMap(store.value.serverErrors, arrayPath, operation),\n touched: remapPathSet(store.value.touched, arrayPath, operation),\n changed: remapPathSet(store.value.changed, arrayPath, operation),\n });\n },\n beginSubmitAttempt: () => {\n patch({\n submitCount: store.value.submitCount + 1,\n serverErrors: EmptyMap,\n submitError: null,\n isSubmitSuccessful: null,\n });\n },\n touchAll: () => {\n if (store.value.submitCount === 0) patch({ submitCount: 1 });\n },\n setSubmitting: (isSubmitting) => {\n if (store.value.isSubmitting !== isSubmitting) patch({ isSubmitting });\n },\n setSubmitSuccessful: (value) => {\n if (store.value.isSubmitSuccessful !== value) patch({ isSubmitSuccessful: value });\n },\n applySubmitFailure: (resolution) => {\n patch({\n serverErrors: normalizeErrorMap(resolution.fieldErrors),\n submitError: resolution.submitError,\n });\n },\n replaceServerErrors: (errors) => {\n patch({ serverErrors: normalizeErrorMap(errors) });\n },\n clearSubmitError: () => {\n if (store.value.submitError !== null) patch({ submitError: null });\n },\n setScope: (scopedErrors, scopedFields) => patch({ scopedErrors, scopedFields }),\n setScopeValidating: (isScopeValidating) => patch({ isScopeValidating }),\n setBaseline: (baseline) => patch({ baseline }),\n reset: (baseline) => {\n commit({\n baseline,\n scopedErrors: null,\n scopedFields: undefined,\n isScopeValidating: false,\n serverErrors: EmptyMap,\n touched: new Set<string>(),\n changed: new Set<string>(),\n submitCount: 0,\n isSubmitting: false,\n submitError: null,\n isSubmitSuccessful: null,\n });\n },\n };\n}\n"],"names":[],"mappings":";;AA+BA,MAAM,WAAqB,OAAO,OAAO,uBAAO,OAAO,IAAI,CAA0C;AAwDrG,SAAS,kBAAkB,QAAyD;AAClF,QAAM,aAAoD,uBAAO,OAAO,IAAI;AAC5E,aAAW,CAAC,MAAM,QAAQ,KAAK,OAAO,QAAQ,MAAM,EAAG,YAAW,IAAI,IAAI,CAAC,GAAG,QAAQ;AACtF,SAAO;AACT;AAGO,SAAS,0BACd,iBAC8B;AAC9B,QAAM,QAAQ,WAA0C;AAAA,IACtD,UAAU;AAAA,IACV,cAAc;AAAA,IACd,cAAc;AAAA,IACd,mBAAmB;AAAA,IACnB,cAAc;AAA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,7 @@ import { useForm, revalidateLogic } from "@tanstack/vue-form";
|
|
|
4
4
|
import { fieldIssues } from "../../../foundation/http/FieldErrors.js";
|
|
5
5
|
import { AppErrorFactory } from "../../../foundation/results/AppErrorFactory.js";
|
|
6
6
|
import { deepEqual } from "../../DeepEqual.js";
|
|
7
|
-
import { untilFormAbort, includesValidationPath, submitWithFocus, validateFormScope } from "../../FormOperations.js";
|
|
7
|
+
import { untilFormAbort, resolveFieldDisplay, includesValidationPath, submitWithFocus, validateFormScope } from "../../FormOperations.js";
|
|
8
8
|
import { snapshotFormValues } from "../../FormSnapshot.js";
|
|
9
9
|
import { createFormStateView, createFieldComponent, createFieldApi, createUseFormState } from "../../FormGlue.js";
|
|
10
10
|
import { getPath, hasPath } from "../../Paths.js";
|
|
@@ -57,7 +57,7 @@ function bridgeStore(engine) {
|
|
|
57
57
|
onScopeDispose(() => subscription.unsubscribe(), true);
|
|
58
58
|
return snapshot;
|
|
59
59
|
}
|
|
60
|
-
function createCombinedReader(snapshot, overlay) {
|
|
60
|
+
function createCombinedReader(snapshot, overlay, getValidateOn) {
|
|
61
61
|
let generation = null;
|
|
62
62
|
let formState = null;
|
|
63
63
|
let fieldCache = /* @__PURE__ */ new Map();
|
|
@@ -96,15 +96,15 @@ function createCombinedReader(snapshot, overlay) {
|
|
|
96
96
|
const cached = fieldCache.get(path);
|
|
97
97
|
if (cached) return cached;
|
|
98
98
|
const value = getPath(tan.values, path);
|
|
99
|
-
const
|
|
99
|
+
const { isTouched, showsClientErrors } = resolveFieldDisplay(path, ov, getValidateOn());
|
|
100
|
+
const clientMessages = !showsClientErrors ? EmptyMessages : ov.scopedErrors !== null && includesValidationPath(path, ov.scopedFields) ? ov.scopedErrors[path] ?? EmptyMessages : toMessages(tan.fieldMeta[path]?.errors);
|
|
100
101
|
const serverMessages = ov.serverErrors[path] ?? EmptyMessages;
|
|
101
102
|
const computed = {
|
|
102
103
|
value,
|
|
103
104
|
// Client + server messages merged, client first (contract JSDoc).
|
|
104
105
|
errors: serverMessages.length === 0 ? clientMessages : clientMessages.length === 0 ? serverMessages : [...clientMessages, ...serverMessages],
|
|
105
106
|
isDirty: !deepEqual(value, getPath(ov.baseline, path)),
|
|
106
|
-
|
|
107
|
-
isTouched: [...ov.touched].some((selected) => includesValidationPath(path, [selected])) || ov.submitCount > 0
|
|
107
|
+
isTouched
|
|
108
108
|
};
|
|
109
109
|
const previous = previousFieldCache.get(path);
|
|
110
110
|
const stable = previous && fieldStatesEqual(previous, computed) ? previous : computed;
|
|
@@ -180,7 +180,7 @@ function buildAppForm(engine, prelude) {
|
|
|
180
180
|
let disposed = false;
|
|
181
181
|
let trailingSubmit = false;
|
|
182
182
|
let submittingValues = null;
|
|
183
|
-
const reader = createCombinedReader(bridgeStore(engine), overlay);
|
|
183
|
+
const reader = createCombinedReader(bridgeStore(engine), overlay, () => getOptions().validateOn);
|
|
184
184
|
const identity = createFormArrayIdentity(() => engine.store.state.values);
|
|
185
185
|
function applySubmitFailure(error, submittedValues = engine.store.state.values) {
|
|
186
186
|
const options = getOptions();
|
|
@@ -320,6 +320,7 @@ function buildAppForm(engine, prelude) {
|
|
|
320
320
|
getState: (path) => reader.getFieldState(path),
|
|
321
321
|
setValue: (path, value) => {
|
|
322
322
|
overlay.clearServerErrorsAt(path);
|
|
323
|
+
overlay.markChanged(path);
|
|
323
324
|
engine.setFieldValue(path, snapshotFormValues(value));
|
|
324
325
|
identity.replace(path);
|
|
325
326
|
scheduleAutoSubmit();
|
|
@@ -357,6 +358,7 @@ function buildAppForm(engine, prelude) {
|
|
|
357
358
|
engine.moveFieldValues(field, operation.fromIndex, operation.toIndex);
|
|
358
359
|
break;
|
|
359
360
|
}
|
|
361
|
+
overlay.markChanged(path);
|
|
360
362
|
overlay.remapForArrayOperation(path, operation);
|
|
361
363
|
});
|
|
362
364
|
scheduleAutoSubmit();
|
|
@@ -396,6 +398,7 @@ function buildAppForm(engine, prelude) {
|
|
|
396
398
|
invalidateSession: (next) => form.reset(next),
|
|
397
399
|
setValue: (path, value) => {
|
|
398
400
|
overlay.clearServerErrorsAt(path);
|
|
401
|
+
overlay.markChanged(path);
|
|
399
402
|
engine.setFieldValue(path, snapshotFormValues(value));
|
|
400
403
|
identity.replace(path);
|
|
401
404
|
scheduleAutoSubmit();
|