@wow-two-beta/fe 0.0.39 → 0.0.41

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/dist/auth/BffSession.d.ts +3 -3
  2. package/dist/auth/BffSession.js +3 -3
  3. package/dist/auth/BffSession.js.map +1 -1
  4. package/dist/auth/BffSessionSync.d.ts +2 -2
  5. package/dist/auth/BffSessionSync.js.map +1 -1
  6. package/dist/auth/BffStrategy.d.ts +7 -7
  7. package/dist/auth/BffStrategy.js +7 -7
  8. package/dist/auth/BffStrategy.js.map +1 -1
  9. package/dist/auth/index.d.ts +1 -1
  10. package/dist/auth/index.js +2 -2
  11. package/dist/formsEngine/AppForm.d.ts +12 -3
  12. package/dist/formsEngine/FormOperations.d.ts +18 -0
  13. package/dist/formsEngine/FormOperations.js +9 -0
  14. package/dist/formsEngine/FormOperations.js.map +1 -1
  15. package/dist/formsEngine/adapters/house/HouseFormCore.js +15 -6
  16. package/dist/formsEngine/adapters/house/HouseFormCore.js.map +1 -1
  17. package/dist/formsEngine/adapters/tanstack/TanstackFormOverlay.d.ts +4 -0
  18. package/dist/formsEngine/adapters/tanstack/TanstackFormOverlay.js +10 -1
  19. package/dist/formsEngine/adapters/tanstack/TanstackFormOverlay.js.map +1 -1
  20. package/dist/formsEngine/adapters/tanstack/UseAppForm.js +9 -6
  21. package/dist/formsEngine/adapters/tanstack/UseAppForm.js.map +1 -1
  22. package/dist/foundation/animation/animatedLayout/AnimatedLayout.d.ts +3 -3
  23. package/dist/foundation/dom/FocusTarget.d.ts +13 -0
  24. package/dist/foundation/dom/FocusTarget.js +12 -0
  25. package/dist/foundation/dom/FocusTarget.js.map +1 -0
  26. package/dist/foundation/dom/index.d.ts +1 -0
  27. package/dist/foundation/dom/index.js +3 -0
  28. package/dist/foundation/dom/index.js.map +1 -1
  29. package/dist/foundation/primitives/index.d.ts +1 -0
  30. package/dist/foundation/primitives/index.js +3 -0
  31. package/dist/foundation/primitives/index.js.map +1 -1
  32. package/dist/foundation/primitives/swapTransition/SwapTransition.d.ts +76 -0
  33. package/dist/foundation/primitives/swapTransition/SwapTransition.js +240 -0
  34. package/dist/foundation/primitives/swapTransition/SwapTransition.js.map +1 -0
  35. package/dist/foundation/primitives/swapTransition/index.d.ts +1 -0
  36. package/dist/index.css +11 -0
  37. package/dist/presentation/actions/refreshButton/RefreshButton.vue.js.map +1 -1
  38. package/dist/presentation/display/animatedNumberText/AnimatedNumberText.vue.d.ts +1 -1
  39. package/dist/presentation/display/carousel/Carousel.vue.d.ts +1 -1
  40. package/dist/presentation/display/countUpText/CountUpText.vue.d.ts +1 -1
  41. package/dist/presentation/display/scrollRevealGroup/ScrollRevealGroup.vue.d.ts +2 -2
  42. package/dist/presentation/forms/imageCropEditor/ImageCropEditor.vue.d.ts +1 -1
  43. package/dist/presentation/forms/imageEditor/ImageEditor.vue.d.ts +1 -1
  44. package/dist/presentation/forms/phoneInput/PhoneInput.vue.d.ts +4 -0
  45. package/dist/presentation/forms/phoneInput/PhoneInput.vue.js +19 -6
  46. package/dist/presentation/forms/phoneInput/PhoneInput.vue.js.map +1 -1
  47. package/dist/router/adapters/vueRouter/routeAnnouncer/RouteAnnouncer.vue.js +17 -5
  48. package/dist/router/adapters/vueRouter/routeAnnouncer/RouteAnnouncer.vue.js.map +1 -1
  49. package/package.json +1 -1
@@ -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;AA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kBAAkB,QAAQ,IAAI;AAC1G,WACE,CAAC,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,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AA,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;"}
@@ -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}\n"],"names":[],"mappings":";;AA6BA,MAAM,WAAqB,OAAO,OAAO,uBAAO,OAAO,IAAI,CAA0C;AAoDrG,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;AA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GAAG;AAAA,IAC7D;AAAA,IACA,eAAe,CAAC,iBAAiB;AAC/B,UAAI,MAAM,MAAM,iBAAiB,aAAc,OAAM,EAAE,cAAc;AAAA,IACvE;AAAA,IACA,qBAAqB,CAAC,UAAU;AAC9B,UAAI,MAAM,MAAM,uBAAuB,aAAa,EAAE,oBAAoB,OAAO;AAAA,IACnF;AAAA,IACA,oBAAoB,CAAC,eAAe;AAClC,YAAM;AAAA,QACJ,cAAc,kBAAkB,WAAW,WAAW;AAAA,QACtD,aAAa,WAAW;AAAA,MAAA,CACzB;AAAA,IACH;AAAA,IACA,qBAAqB,CAAC,WAAW;AAC/B,YAAM,EAAE,cAAc,kBAAkB,MAAM,GAAG;AAAA,IACnD;AAAA,IACA,kBAAkB,MAAM;AACtB,UAAI,MAAM,MAAM,gBAAgB,YAAY,EAAE,aAAa,MAAM;AAAA,IACnE;AAAA,IACA,UAAU,CAAC,cAAc,iBAAiB,MAAM,EAAE,cAAc,cAAc;AAAA,IAC9E,oBAAoB,CAAC,sBAAsB,MAAM,EAAE,mBAAmB;AAAA,IACtE,aAAa,CAAC,aAAa,MAAM,EAAE,UAAU;AAAA,IAC7C,OAAO,CAAC,aAAa;AACnB,aAAO;AAAA,QACL;AAAA,QACA,cAAc;AAAA,QACd,cAAc;AAAA,QACd,mBAAmB;AAAA,QACnB,cAAc;AAAA,QACd,6BAAa,IAAA;AAAA,QACb,aAAa;AAAA,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;AAAA,IACd,6BAAa,IAAA;AAAA,IACb,6BAAa,IAAA;AAAA,IACb,aAAa;AAAA,IACb,cAAc;AAAA,IACd,aAAa;AAAA,IACb,oBAAoB;AAAA,EAAA,CACrB;AAED,WAAS,OAAO,MAA2C;AACzD,UAAM,QAAQ;AAAA,EAChB;AAEA,WAAS,MAAM,SAAuD;AACpE,WAAO,EAAE,GAAG,MAAM,OAAO,GAAG,SAAS;AAAA,EACvC;AAEA,SAAO;AAAA,IACL,OAAO;AAAA,IACP,UAAU,MAAM,MAAM;AAAA,IACtB,aAAa,CAAC,SAAS;AACr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AAC9B,UAAI,MAAM,MAAM,uBAAuB,aAAa,EAAE,oBAAoB,OAAO;AAAA,IACnF;AAAA,IACA,oBAAoB,CAAC,eAAe;AAClC,YAAM;AAAA,QACJ,cAAc,kBAAkB,WAAW,WAAW;AAAA,QACtD,aAAa,WAAW;AAAA,MAAA,CACzB;AAAA,IACH;AAAA,IACA,qBAAqB,CAAC,WAAW;AAC/B,YAAM,EAAE,cAAc,kBAAkB,MAAM,GAAG;AAAA,IACnD;AAAA,IACA,kBAAkB,MAAM;AACtB,UAAI,MAAM,MAAM,gBAAgB,YAAY,EAAE,aAAa,MAAM;AAAA,IACnE;AAAA,IACA,UAAU,CAAC,cAAc,iBAAiB,MAAM,EAAE,cAAc,cAAc;AAAA,IAC9E,oBAAoB,CAAC,sBAAsB,MAAM,EAAE,mBAAmB;AAAA,IACtE,aAAa,CAAC,aAAa,MAAM,EAAE,UAAU;AAAA,IAC7C,OAAO,CAAC,aAAa;AACnB,aAAO;AAAA,QACL;AAAA,QACA,cAAc;AAAA,QACd,cAAc;AAAA,QACd,mBAAmB;AAAA,QACnB,cAAc;AAAA,QACd,6BAAa,IAAA;AAAA,QACb,6BAAa,IAAA;AAAA,QACb,aAAa;AAAA,QACb,cAAc;AAAA,QACd,aAAa;AAAA,QACb,oBAAoB;AAAA,MAAA,CACrB;AAAA,IACH;AAAA,EAAA;AAEJ;"}
@@ -4,7 +4,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 clientMessages = ov.scopedErrors !== null && includesValidationPath(path, ov.scopedFields) ? ov.scopedErrors[path] ?? EmptyMessages : toMessages(tan.fieldMeta[path]?.errors);
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
- // A submit attempt counts as touching everything — error-display gating works post-attempt.
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();
@@ -1 +1 @@
1
- {"version":3,"file":"UseAppForm.js","sources":["../../../../src/formsEngine/adapters/tanstack/UseAppForm.ts"],"sourcesContent":["import { createFormArrayIdentity } from '../../FormArrayIdentity';\nimport { onMounted, onScopeDispose, shallowRef, toValue, type ShallowRef } from 'vue';\n\nimport {\n revalidateLogic,\n useForm,\n type DeepKeys,\n type FormApi,\n type FormAsyncValidateOrFn,\n type FormOptions,\n type FormValidateAsyncFn,\n type VueFormApi,\n} from '@tanstack/vue-form';\n\nimport { fieldIssues } from '../../../foundation/http';\nimport { AppErrorFactory, type AppError } from '../../../foundation/results';\nimport type { ResolveValidationMessage } from '../../../foundation/validators';\n\nimport type {\n AppFieldApi,\n AppForm,\n AppFormOptions,\n AppFormOptionsSource,\n AppFormState,\n AppFormValidationOptions,\n} from '../../AppForm';\nimport { deepEqual } from '../../DeepEqual';\nimport { includesValidationPath, submitWithFocus, untilFormAbort, validateFormScope } from '../../FormOperations';\nimport { snapshotFormValues } from '../../FormSnapshot';\nimport { createFieldApi, createFieldComponent, createFormStateView, createUseFormState } from '../../FormGlue';\nimport { getPath, hasPath } from '../../Paths';\nimport {\n createOptionsMessageResolver,\n parseStandardSchema,\n formParseFailure,\n type FormParseResult,\n} from '../../SchemaValidation';\nimport { defaultMapFieldPath, resolveSubmitFailure, toSubmitError } from '../../SubmitErrors';\n\nimport { createTanstackFormOverlay, type TanstackFormOverlay, type TanstackOverlayState } from './TanstackFormOverlay';\n\n/*\n * The tanstack adapter — the facade contract over `@tanstack/vue-form` (optional peer).\n * TanStack owns values, validation scheduling, and the submit lifecycle; the overlay\n * (`TanstackFormOverlay`) owns everything the contract pins that TanStack models\n * differently — server-error merge/clearing, baseline-compared dirty, blur-or-submit\n * touched, contract array reindexing, `submitError` (see the overlay's module doc).\n *\n * Validation wiring: the whole-form Standard Schema runs as a TanStack form-level\n * `onDynamicAsync` validator under `revalidateLogic` — `validateOn` maps 1:1 onto its\n * pre-submission `mode` ('submit' default / 'blur' / 'change'), and `modeAfterSubmission:\n * 'change'` gives the pinned post-attempt change-revalidation. The validator returns\n * TanStack's global `{ form?, fields }` error shape, so client errors land in TanStack\n * field meta (created on demand — no TanStack `Field` mounts needed) and `state.isValid`\n * stays engine-native. Adapter notes (both mirror the contract's static options intent):\n * - `validateOn` is creation-pinned; schema and message values are read per run.\n * Schema presence may change through the options getter.\n * - Escape-hatch writes (`engine.setFieldValue`) bypass the overlay — server-error\n * clearing and touched semantics then follow TanStack, not the contract.\n *\n * HOW STATE IS READ. `@tanstack/vue-form` is `form-core` under a Vue host binding.\n * - The returned instance is `FormApi & VueFormApi`.\n * - TanStack's store is a `@tanstack/store` `Store`, invisible to Vue's tracker. It is bridged\n * ONCE, here, into a `shallowRef` (`bridgeStore`); every contract read then flows through\n * Vue reactivity. `form.useSelector` would do the same per slice, but it wraps its ref in\n * `readonly()`, which would hand values back through a proxy and break the identity compares\n * the reader and `deepEqual` rely on.\n * - `useForm` applies its options ONCE (Vue's `setup` runs once), so the options object must\n * stay stable: `reset()` keeps `tanstackOptions.defaultValues` in step with TanStack's own\n * copy.\n */\n\n/** The native TanStack form instance the adapter builds — what `form.engine` exposes. */\nexport type TanstackFormEngine<TValues extends object> = FormApi<\n TValues,\n undefined, // onMount\n undefined, // onChange\n undefined, // onChangeAsync\n undefined, // onBlur\n undefined, // onBlurAsync\n undefined, // onSubmit\n undefined, // onSubmitAsync\n undefined, // onDynamic\n FormAsyncValidateOrFn<TValues>, // onDynamicAsync — the adapter's schema bridge\n undefined, // onServer\n never // submitMeta\n> &\n VueFormApi<\n TValues,\n undefined,\n undefined,\n undefined,\n undefined,\n undefined,\n undefined,\n undefined,\n undefined,\n FormAsyncValidateOrFn<TValues>,\n undefined,\n never\n >;\n\ntype TanstackFormOptions<TValues extends object> = FormOptions<\n TValues,\n undefined,\n undefined,\n undefined,\n undefined,\n undefined,\n undefined,\n undefined,\n undefined,\n FormAsyncValidateOrFn<TValues>,\n undefined,\n never\n>;\n\nconst EmptyMessages: ReadonlyArray<string> = Object.freeze([]);\n\n/**\n * Folds the shared schema-error map into TanStack's global form error shape:\n * root-path (`''`) issues become the form-level error, the rest per-field errors.\n */\nfunction toEngineValidationError(errors: Record<string, ReadonlyArray<string>>): unknown {\n const paths = Object.keys(errors);\n if (paths.length === 0) return undefined;\n const fields: Record<string, ReadonlyArray<string>> = Object.create(null);\n let form: ReadonlyArray<string> | undefined;\n for (const path of paths) {\n if (path === '') form = errors[path];\n else fields[path] = errors[path] ?? [];\n }\n return form ? { form, fields } : { fields };\n}\n\n/**\n * Normalizes TanStack field-meta errors to plain messages. The adapter's own validator\n * yields `string[]`, but escape-hatch validators may add strings, nested arrays, or\n * Standard Schema issue objects — all are accepted.\n */\nfunction toMessages(errors: ReadonlyArray<unknown> | undefined): ReadonlyArray<string> {\n if (!errors || errors.length === 0) return EmptyMessages;\n const messages: string[] = [];\n const visit = (error: unknown): void => {\n if (error === null || error === undefined) return;\n if (typeof error === 'string') {\n messages.push(error);\n return;\n }\n if (Array.isArray(error)) {\n for (const entry of error) visit(entry);\n return;\n }\n if (typeof error === 'object' && typeof (error as { message?: unknown }).message === 'string') {\n messages.push((error as { message: string }).message);\n }\n };\n for (const error of errors) visit(error);\n return messages.length > 0 ? messages : EmptyMessages;\n}\n\n/** The per-field slice the `Field` glue reads — identity-stable while its members are unchanged. */\ninterface TanstackFieldState {\n readonly value: unknown;\n readonly errors: ReadonlyArray<string>;\n readonly isDirty: boolean;\n readonly isTouched: boolean;\n}\n\n/** The minimal structural view of TanStack form state the reader consumes (loose string paths). */\ninterface EngineStateView {\n readonly values: unknown;\n readonly isValid: boolean;\n readonly isValidating: boolean;\n readonly isFormValidating: boolean;\n readonly fieldMeta: Partial<Record<string, { readonly errors: ReadonlyArray<unknown> }>>;\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: TanstackFieldState, b: TanstackFieldState): 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\n/**\n * Mirrors the `@tanstack/store` store into a `shallowRef` — the ONE seam that puts TanStack\n * state inside Vue's tracker. Deliberately not `useSelector`/`useStore` from\n * `@tanstack/vue-store`: those wrap the ref in `readonly()`, which would hand every read back\n * through a deep proxy and defeat the `Object.is` identity compares the reader, `deepEqual`, and\n * TanStack's own writes all depend on.\n */\nfunction bridgeStore<TValues extends object>(engine: TanstackFormEngine<TValues>): ShallowRef<EngineStateView> {\n const snapshot = shallowRef(engine.store.state as unknown as EngineStateView);\n const subscription = engine.store.subscribe((next) => {\n snapshot.value = next as unknown as EngineStateView;\n });\n onScopeDispose(() => subscription.unsubscribe(), true);\n return snapshot;\n}\n\ninterface CombinedReader<TValues extends object> {\n readonly getFormState: () => AppFormState<TValues>;\n readonly getFieldState: (path: string) => TanstackFieldState;\n}\n\n/**\n * Derives the contract state from the (TanStack store state, overlay state) pair with\n * generation caching: snapshots are rebuilt only when either source commits, and per-path\n * field slices reuse the previous generation's identity when unchanged — so a read stays\n * referentially stable between commits. Both sources are `shallowRef`s, so every read below\n * is also the subscription.\n */\nfunction createCombinedReader<TValues extends object>(\n snapshot: ShallowRef<EngineStateView>,\n overlay: TanstackFormOverlay<TValues>,\n): CombinedReader<TValues> {\n let generation: { tan: EngineStateView; ov: TanstackOverlayState<TValues> } | null = null;\n let formState: AppFormState<TValues> | null = null;\n let fieldCache = new Map<string, TanstackFieldState>();\n let previousFieldCache = new Map<string, TanstackFieldState>();\n\n function currentGeneration(): { tan: EngineStateView; ov: TanstackOverlayState<TValues> } {\n const tan = snapshot.value;\n const ov = overlay.state.value;\n if (generation && generation.tan === tan && generation.ov === ov) return generation;\n generation = { tan, ov };\n formState = null;\n previousFieldCache = fieldCache;\n fieldCache = new Map();\n return generation;\n }\n\n return {\n getFormState: () => {\n const { tan, ov } = currentGeneration();\n formState ??= {\n values: tan.values as TValues,\n isDirty: !deepEqual(tan.values, ov.baseline),\n // Client validity is engine-native; the server-error overlay holds it false too.\n isValid:\n (ov.scopedErrors === null\n ? tan.isValid\n : Object.keys(ov.scopedErrors).length === 0 &&\n Object.entries(tan.fieldMeta).every(\n ([path, meta]) => includesValidationPath(path, ov.scopedFields) || !meta?.errors.length,\n )) && Object.keys(ov.serverErrors).length === 0,\n isSubmitting: ov.isSubmitting,\n // Whole-schema validation is a FORM-level validator — TanStack's derived\n // `isValidating` counts field-level validators only, so merge both flags.\n isValidating: tan.isFormValidating || tan.isValidating || ov.isScopeValidating,\n submitError: ov.submitError,\n isSubmitSuccessful: ov.isSubmitSuccessful,\n };\n return formState;\n },\n getFieldState: (path) => {\n const { tan, ov } = currentGeneration();\n const cached = fieldCache.get(path);\n if (cached) return cached;\n const value = getPath(tan.values, path);\n const clientMessages =\n ov.scopedErrors !== null && includesValidationPath(path, ov.scopedFields)\n ? (ov.scopedErrors[path] ?? EmptyMessages)\n : toMessages(tan.fieldMeta[path]?.errors);\n const serverMessages = ov.serverErrors[path] ?? EmptyMessages;\n const computed: TanstackFieldState = {\n value,\n // Client + server messages merged, client first (contract JSDoc).\n errors:\n serverMessages.length === 0\n ? clientMessages\n : clientMessages.length === 0\n ? serverMessages\n : [...clientMessages, ...serverMessages],\n isDirty: !deepEqual(value, getPath(ov.baseline, path)),\n // A submit attempt counts as touching everything — error-display gating works post-attempt.\n isTouched: [...ov.touched].some((selected) => includesValidationPath(path, [selected])) || ov.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}\n\ninterface AdapterPrelude<TValues extends object, TOutput> {\n readonly getOptions: () => AppFormOptions<TValues, TOutput>;\n readonly overlay: TanstackFormOverlay<TValues>;\n readonly tanstackOptions: TanstackFormOptions<TValues>;\n readonly parseValues: (values: TValues, fresh?: boolean) => Promise<FormParseResult<TOutput>>;\n /** The form's message resolver, memoized against the `messages` / `labels` option identities. */\n readonly messageResolver: () => ResolveValidationMessage;\n readonly bindValues: (read: () => TValues) => void;\n}\n\n/** Builds the overlay + the stable TanStack options (all callbacks read the latest options through `getOptions`). */\nfunction createAdapterPrelude<TValues extends object, TOutput>(\n getOptions: () => AppFormOptions<TValues, TOutput>,\n): AdapterPrelude<TValues, TOutput> {\n let readCurrentValues: (() => TValues) | null = null;\n const initialOptions = getOptions();\n const initialValues = snapshotFormValues(initialOptions.defaultValues);\n const overlay = createTanstackFormOverlay<TValues>(snapshotFormValues(initialValues));\n const messageResolver = createOptionsMessageResolver(getOptions);\n\n let cached: {\n values: TValues;\n schema: AppFormOptions<TValues, TOutput>['schema'];\n resolver: ResolveValidationMessage;\n result: Promise<FormParseResult<TOutput>>;\n } | null = null;\n const parseValues = (values: TValues, fresh = false): Promise<FormParseResult<TOutput>> => {\n const schema = getOptions().schema;\n const resolver = messageResolver();\n if (\n !fresh &&\n cached !== null &&\n deepEqual(cached.values, values) &&\n cached.schema === schema &&\n cached.resolver === resolver\n )\n return cached.result;\n const snapshot = snapshotFormValues(values);\n const result = Promise.resolve()\n .then(() =>\n schema\n ? parseStandardSchema(schema, snapshot, resolver)\n : { ok: true as const, value: snapshot as unknown as TOutput },\n )\n .catch((): FormParseResult<TOutput> =>\n formParseFailure({ '': [getOptions().fallbackErrorMessage ?? 'Validation failed'] }),\n );\n cached = { values: snapshotFormValues(values), schema, resolver, result };\n return result;\n };\n\n const tanstackOptions: TanstackFormOptions<TValues> = {\n defaultValues: initialValues,\n onSubmit: async ({ value }) => {\n // The contract's `isSubmitting` brackets ONLY the app submit call (house-identical),\n // not TanStack's validation window. Failures propagate to the adapter's\n // `handleSubmit` catch, so TanStack's own submit lifecycle stays truthful.\n overlay.setSubmitting(true);\n try {\n const parsed = await parseValues(value, true);\n if (!parsed.ok) return;\n const result = await getOptions().onSubmit(parsed.value, { signal: new AbortController().signal });\n // Reached only when validation passed AND the app submit resolved — the verdict's\n // sole success signal (the invalid path never runs this; a throw skips it).\n overlay.setSubmitSuccessful(result.ok);\n } finally {\n overlay.setSubmitting(false);\n }\n },\n };\n\n const validateWithSchema: FormValidateAsyncFn<TValues> = async ({ value, signal }) => {\n overlay.setScope(null);\n const snapshot = snapshotFormValues(value);\n const result = await untilFormAbort(parseValues(snapshot), signal, null);\n if (!result || (readCurrentValues && !deepEqual(snapshot, readCurrentValues()))) return undefined;\n return toEngineValidationError(result.ok ? {} : result.failure.fieldErrors);\n };\n tanstackOptions.validators = { onDynamicAsync: validateWithSchema };\n tanstackOptions.validationLogic = (props) =>\n revalidateLogic({\n mode:\n overlay.getState().submitCount > 0 || overlay.getState().touched.size > 0\n ? 'change'\n : (initialOptions.validateOn ?? 'submit'),\n modeAfterSubmission: 'change',\n })(props);\n\n return {\n getOptions,\n overlay,\n tanstackOptions,\n messageResolver,\n parseValues,\n bindValues: (read) => {\n readCurrentValues = read;\n },\n };\n}\n\n/** What `buildAppForm` returns — the contract surface plus the teardown the adapter's own timer needs. */\ninterface BuiltForm<TValues extends object> {\n readonly form: AppForm<TValues, TanstackFormEngine<TValues>>;\n /** Releases the pending `submitOn: 'change'` debounce timer on scope teardown. */\n readonly dispose: () => void;\n}\n\n/** Builds the stable contract surface over the TanStack engine + overlay pair. */\nfunction buildAppForm<TValues extends object, TOutput>(\n engine: TanstackFormEngine<TValues>,\n prelude: AdapterPrelude<TValues, TOutput>,\n): BuiltForm<TValues> {\n const { getOptions, overlay, tanstackOptions, messageResolver, parseValues } = prelude;\n let lifecycleEpoch = 0;\n let validationEpoch = 0;\n let focusEpoch = 0;\n let requestController = new AbortController();\n let disposed = false;\n let trailingSubmit = false;\n let submittingValues: TValues | null = null;\n const reader = createCombinedReader(bridgeStore(engine), overlay);\n const identity = createFormArrayIdentity(() => engine.store.state.values);\n\n // ── Submit path shared by `handleSubmit` + auto-submit (validate → onSubmit → map failure) ─────\n /** Resolves a thrown submit failure onto the overlay (matched paths → fields, remainder → banner). */\n function applySubmitFailure(error: AppError, submittedValues = engine.store.state.values): void {\n const options = getOptions();\n const values = engine.store.state.values;\n overlay.applySubmitFailure(\n resolveSubmitFailure(\n error,\n options.mapSubmitError ?? fieldIssues,\n options.mapFieldPath ?? defaultMapFieldPath,\n (path) => hasPath(submittedValues, path) && deepEqual(getPath(submittedValues, path), getPath(values, path)),\n options.fallbackErrorMessage,\n messageResolver(),\n ),\n );\n }\n\n async function performSubmit(values: TValues): Promise<boolean> {\n if (disposed || getOptions().isDisabled) return false;\n const epoch = lifecycleEpoch;\n const signal = requestController.signal;\n const isCurrent = (): boolean => !disposed && epoch === lifecycleEpoch;\n validationEpoch += 1;\n overlay.setScope(null);\n overlay.beginSubmitAttempt();\n // The facade owns submission snapshots; TanStack still owns field validation and metadata.\n // Its validator reuses this parse, so transforming/async schemas run once for this input.\n const parsing = parseValues(values, true);\n await engine.validate('submit');\n const parsed = await parsing;\n if (!isCurrent()) return false;\n if (!parsed.ok) {\n overlay.setSubmitSuccessful(false);\n return false;\n }\n overlay.setSubmitting(true);\n let successful = false;\n try {\n const result = await untilFormAbort(getOptions().onSubmit(parsed.value, { signal }), signal, {\n ok: false,\n failure: AppErrorFactory.cancelled(),\n });\n successful = result.ok;\n if (isCurrent() && result.ok) overlay.setBaseline(values);\n else if (isCurrent() && !result.ok) applySubmitFailure(result.failure, values);\n } catch (error) {\n if (isCurrent()) applySubmitFailure(toSubmitError(error, getOptions().fallbackErrorMessage), values);\n } finally {\n if (isCurrent()) overlay.setSubmitting(false);\n if (isCurrent()) overlay.setSubmitSuccessful(successful);\n }\n return successful && isCurrent();\n }\n\n /** Serializes submissions and coalesces newer edits into one trailing snapshot. */\n let inFlight: Promise<boolean> | null = null;\n async function guardedSubmit(): Promise<boolean> {\n if (disposed) return false;\n if (inFlight) {\n if (!deepEqual(engine.store.state.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(engine.store.state.values);\n successful = await untilFormAbort(performSubmit(submittingValues), requestController.signal, false);\n } while (\n !disposed &&\n trailingSubmit &&\n !deepEqual(engine.store.state.values, submittingValues) &&\n !deepEqual(engine.store.state.values, overlay.getState().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 /** Validate without submitting — marks touched, runs the whole-form schema, resolves client validity. */\n async function validate(options?: AppFormValidationOptions<TValues>): Promise<boolean> {\n if (disposed) return false;\n const epoch = ++validationEpoch;\n const lifecycle = lifecycleEpoch;\n if (options) {\n for (const meta of Object.values(engine.state.validationMetaMap)) meta?.lastAbortController.abort();\n const values = snapshotFormValues(engine.store.state.values);\n for (const path of options.fields ?? Object.keys(values)) overlay.markBlurred(path);\n overlay.setScopeValidating(true);\n const errors = await untilFormAbort(\n validateFormScope(\n values,\n options,\n getOptions().schema,\n messageResolver(),\n getOptions().fallbackErrorMessage ?? 'Validation failed',\n ),\n requestController.signal,\n {},\n );\n if (disposed || epoch !== validationEpoch || lifecycle !== lifecycleEpoch) return false;\n overlay.setScopeValidating(false);\n if (!deepEqual(values, engine.store.state.values)) return false;\n const previous = overlay.getState();\n const retained = Object.fromEntries(\n Object.entries(previous.scopedErrors ?? {}).filter(([path]) => !includesValidationPath(path, options.fields)),\n );\n const fields =\n options.fields &&\n (previous.scopedErrors === null\n ? options.fields\n : previous.scopedFields && [...previous.scopedFields, ...options.fields]);\n overlay.setScope({ ...retained, ...errors }, fields);\n return Object.keys(errors).length === 0;\n }\n overlay.setScope(null);\n overlay.touchAll();\n const values = snapshotFormValues(engine.store.state.values);\n const parsing = parseValues(values, true);\n const result = await untilFormAbort(\n Promise.all([engine.validate('submit'), parsing]),\n requestController.signal,\n null,\n );\n return (\n !disposed &&\n lifecycle === lifecycleEpoch &&\n epoch === validationEpoch &&\n result !== null &&\n result[1].ok &&\n deepEqual(values, engine.store.state.values)\n );\n }\n\n // ── Auto-submit (`submitOn`) — routes through the SAME `guardedSubmit` as manual submit ────────\n let autoSubmitTimer: ReturnType<typeof setTimeout> | null = null;\n const clearAutoSubmitTimer = (): void => {\n if (autoSubmitTimer !== null) {\n clearTimeout(autoSubmitTimer);\n autoSubmitTimer = null;\n }\n };\n const scheduleAutoSubmit = (): void => {\n if ((getOptions().submitOn ?? 'manual') !== 'change') return;\n clearAutoSubmitTimer();\n const delay = getOptions().submitDebounceMs ?? 0;\n autoSubmitTimer = setTimeout(() => {\n autoSubmitTimer = null;\n void guardedSubmit();\n }, delay);\n };\n const autoSubmitOnBlur = (): void => {\n if ((getOptions().submitOn ?? 'manual') === 'blur') void guardedSubmit();\n };\n\n // One API object per path — memoized, so the identity a slot payload sees is stable.\n const fieldApis = new Map<string, AppFieldApi<unknown>>();\n const fieldOps = {\n getState: (path: string) => reader.getFieldState(path),\n setValue: (path: string, value: unknown) => {\n // Server messages clear on the next change to the field (contract JSDoc).\n overlay.clearServerErrorsAt(path);\n // Triggers TanStack 'change'-cause validation, gated by `revalidateLogic`.\n engine.setFieldValue(path as DeepKeys<TValues>, snapshotFormValues(value) as never);\n identity.replace(path);\n // `submitOn: 'change'` — a user-origin write schedules the debounced auto-submit.\n scheduleAutoSubmit();\n },\n blur: (path: string) => {\n overlay.markBlurred(path);\n // 'blur'-cause validation — runs the schema only in `validateOn: 'blur'` mode.\n void engine.validateField(path as DeepKeys<TValues>, 'blur');\n // `submitOn: 'blur'` — save-on-blur.\n autoSubmitOnBlur();\n },\n };\n const getFieldApi = (path: string): AppFieldApi<unknown> => {\n const existing = fieldApis.get(path);\n if (existing) return existing;\n const api = createFieldApi(path, fieldOps);\n fieldApis.set(path, api);\n return api;\n };\n\n const arrayOperation = (path: string, operation: Parameters<typeof overlay.remapForArrayOperation>[1]): void => {\n // TanStack's array ops are constrained to its typed array paths (`DeepKeysOfType`); the\n // contract's paths are loose strings, so the vendor's path algebra is opted out of with\n // `never` rather than reimplemented here.\n identity.operation(path, operation, () => {\n const field = path as never;\n switch (operation.kind) {\n case 'push':\n engine.pushFieldValue(field, snapshotFormValues(operation.value) as never);\n break;\n case 'insert':\n void engine.insertFieldValue(field, operation.index, snapshotFormValues(operation.value) as never);\n break;\n case 'remove':\n void engine.removeFieldValue(field, operation.index);\n break;\n case 'swap':\n engine.swapFieldValues(field, operation.indexA, operation.indexB);\n break;\n case 'move':\n engine.moveFieldValues(field, operation.fromIndex, operation.toIndex);\n break;\n }\n // Contract reindexing for the overlay: row-scoped server errors + touched marks\n // follow their rows. TanStack shifts its OWN field meta by its rules; where they\n // differ, the contract wins because errors/touched surface from the overlay and\n // client errors are recomputed by the op's change-revalidation.\n overlay.remapForArrayOperation(path, operation);\n });\n scheduleAutoSubmit();\n };\n\n function invalidateWork(): void {\n lifecycleEpoch += 1;\n validationEpoch += 1;\n focusEpoch += 1;\n requestController.abort();\n requestController = new AbortController();\n for (const meta of Object.values(engine.state.validationMetaMap)) meta?.lastAbortController.abort();\n engine.baseStore.setState((previous) => ({ ...previous, isFormValidating: false }));\n overlay.setSubmitting(false);\n overlay.setScopeValidating(false);\n trailingSubmit = false;\n clearAutoSubmitTimer();\n }\n\n const state = createFormStateView<TValues>(reader.getFormState);\n\n const form: AppForm<TValues, TanstackFormEngine<TValues>> = {\n Field: createFieldComponent<TValues>(getFieldApi, () => getOptions().isDisabled ?? false),\n state,\n // The same computed `state.values` reads — `form.values` is a shorthand, never a second source.\n get values() {\n return state.values;\n },\n useFormState: createUseFormState<TValues>(reader.getFormState),\n handleSubmit: async (event?: Event) => {\n const epoch = ++focusEpoch;\n return submitWithFocus(guardedSubmit, () => epoch === focusEpoch, event, getOptions().focusRoot?.());\n },\n validate,\n cancelSubmit: () => {\n invalidateWork();\n overlay.applySubmitFailure({ fieldErrors: {}, submitError: AppErrorFactory.cancelled() });\n overlay.setSubmitSuccessful(false);\n },\n invalidateSession: (next) => form.reset(next),\n setValue: (path, value) => {\n // Server messages clear on the next change to the field (contract JSDoc) — mirror the\n // in-field `setValue`; TanStack's 'change'-cause validation runs under `revalidateLogic`.\n overlay.clearServerErrorsAt(path);\n engine.setFieldValue(path as DeepKeys<TValues>, snapshotFormValues(value) as never);\n identity.replace(path);\n scheduleAutoSubmit();\n },\n array: (path: string) => ({\n get keys() {\n return identity.keys(path);\n },\n push: (value: unknown) => arrayOperation(path, { kind: 'push', value }),\n insert: (index: number, value: unknown) => arrayOperation(path, { kind: 'insert', index, value }),\n remove: (index: number) => arrayOperation(path, { kind: 'remove', index }),\n swap: (indexA: number, indexB: number) => arrayOperation(path, { kind: 'swap', indexA, indexB }),\n move: (fromIndex: number, toIndex: number) => arrayOperation(path, { kind: 'move', fromIndex, toIndex }),\n }),\n reset: (next?: TValues) => {\n invalidateWork();\n const values = snapshotFormValues(next ?? overlay.getState().baseline);\n // Keep the options object TanStack was created with in sync: its own `reset(values)`\n // rewrites `options.defaultValues`, and any later `update()` would otherwise clobber the\n // re-seeded values back from the stale copy.\n tanstackOptions.defaultValues = values;\n overlay.reset(snapshotFormValues(values));\n engine.reset(values);\n identity.reset();\n clearAutoSubmitTimer(); // a reset/prefill never auto-submits — drop any pending trailing submit\n },\n setFieldErrors: (errors: Record<string, ReadonlyArray<string>>) => overlay.replaceServerErrors(errors),\n clearSubmitError: () => overlay.clearSubmitError(),\n engine,\n };\n\n return {\n form,\n dispose: () => {\n invalidateWork();\n disposed = true;\n },\n };\n}\n\n/**\n * The tanstack adapter's `useAppForm` — the facade contract over `@tanstack/vue-form`.\n * The returned form object is stable for the owning scope's lifetime and every state member on\n * it is a live getter, so `form.values.title` / `form.state.isSubmitting` read in a template ARE\n * the subscription; `form.engine` exposes the native {@link TanstackFormEngine} (the 90/10\n * escape hatch — typed here, `unknown` on the shared contract), including TanStack's typed\n * deep-path `Field`/`Subscribe` and per-field validator graph.\n *\n * Call it in `setup()`: `useForm` registers an `onMounted` of its own, and the store bridge +\n * the pending `submitOn: 'change'` timer release on scope teardown.\n */\nexport function useAppForm<TValues extends object, TOutput = TValues>(\n options: AppFormOptionsSource<TValues, TOutput>,\n): AppForm<TValues, TanstackFormEngine<TValues>> {\n const prelude = createAdapterPrelude<TValues, TOutput>(() => toValue(options));\n const engine = useForm(prelude.tanstackOptions) as TanstackFormEngine<TValues>;\n prelude.bindValues(() => engine.store.state.values);\n const built = buildAppForm<TValues, TOutput>(engine, prelude);\n\n // Validate once on mount when flagged — seeds `isValid` / field errors WITHOUT marking touched\n // (the mount pass shows validity without asserting the user interacted).\n onMounted(() => {\n if (toValue(options).validateOnMount) void engine.validate('submit');\n });\n onScopeDispose(built.dispose, true);\n\n return built.form;\n}\n"],"names":["values"],"mappings":";;;;;;;;;;;;;AAqHA,MAAM,gBAAuC,OAAO,OAAO,EAAE;AAM7D,SAAS,wBAAwB,QAAwD;AACvF,QAAM,QAAQ,OAAO,KAAK,MAAM;AAChC,MA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AAQ,MAAM,mBAAmB,MAAM,CAAC;AACxC,aAAO,MAAM,MAAM;AACnB,eAAS,MAAA;AACT,2BAAA;AAAA,IACF;AAAA,IACA,gBAAgB,CAAC,WAAkD,QAAQ,oBAAoB,MAAM;AAAA,IACrG,kBAAkB,MAAM,QAAQ,iBAAA;AAAA,IAChC;AAAA,EAAA;AAGF,SAAO;AAAA,IACL;AAAA,IACA,SAAS,MAAM;AACb,qBAAA;AACA,iBAAW;AAAA,IACb;AAAA,EAAA;AAEJ;AAaO,SAAS,WACd,SAC+C;AAC/C,QAAM,UAAU,qBAAuC,MAAM,QAAQ,OAAO,CAAC;AAC7E,QAAM,SAAS,QAAQ,QAAQ,eAAe;AAC9C,UAAQ,WAAW,MAAM,OAAO,MAAM,MAAM,MAAM;AAClD,QAAM,QAAQ,aAA+B,QAAQ,OAAO;AAI5D,YAAU,MAAM;AACd,QAAI,QAAQ,OAAO,EAAE,gBAAiB,MAAK,OAAO,SAAS,QAAQ;AAAA,EACrE,CAAC;AACD,iBAAe,MAAM,SAAS,IAAI;AAElC,SAAO,MAAM;AACf;"}
1
+ {"version":3,"file":"UseAppForm.js","sources":["../../../../src/formsEngine/adapters/tanstack/UseAppForm.ts"],"sourcesContent":["import { createFormArrayIdentity } from '../../FormArrayIdentity';\nimport { onMounted, onScopeDispose, shallowRef, toValue, type ShallowRef } from 'vue';\n\nimport {\n revalidateLogic,\n useForm,\n type DeepKeys,\n type FormApi,\n type FormAsyncValidateOrFn,\n type FormOptions,\n type FormValidateAsyncFn,\n type VueFormApi,\n} from '@tanstack/vue-form';\n\nimport { fieldIssues } from '../../../foundation/http';\nimport { AppErrorFactory, type AppError } from '../../../foundation/results';\nimport type { ResolveValidationMessage } from '../../../foundation/validators';\n\nimport type {\n AppFieldApi,\n AppForm,\n AppFormOptions,\n AppFormOptionsSource,\n AppFormState,\n AppFormValidationOptions,\n} from '../../AppForm';\nimport { deepEqual } from '../../DeepEqual';\nimport {\n includesValidationPath,\n resolveFieldDisplay,\n submitWithFocus,\n untilFormAbort,\n validateFormScope,\n} from '../../FormOperations';\nimport { snapshotFormValues } from '../../FormSnapshot';\nimport { createFieldApi, createFieldComponent, createFormStateView, createUseFormState } from '../../FormGlue';\nimport { getPath, hasPath } from '../../Paths';\nimport {\n createOptionsMessageResolver,\n parseStandardSchema,\n formParseFailure,\n type FormParseResult,\n} from '../../SchemaValidation';\nimport { defaultMapFieldPath, resolveSubmitFailure, toSubmitError } from '../../SubmitErrors';\n\nimport { createTanstackFormOverlay, type TanstackFormOverlay, type TanstackOverlayState } from './TanstackFormOverlay';\n\n/*\n * The tanstack adapter — the facade contract over `@tanstack/vue-form` (optional peer).\n * TanStack owns values, validation scheduling, and the submit lifecycle; the overlay\n * (`TanstackFormOverlay`) owns everything the contract pins that TanStack models\n * differently — server-error merge/clearing, baseline-compared dirty, blur-or-submit\n * touched, contract array reindexing, `submitError` (see the overlay's module doc).\n *\n * Validation wiring: the whole-form Standard Schema runs as a TanStack form-level\n * `onDynamicAsync` validator under `revalidateLogic` — `validateOn` maps 1:1 onto its\n * pre-submission `mode` ('submit' default / 'blur' / 'change'), and `modeAfterSubmission:\n * 'change'` gives the pinned post-attempt change-revalidation. The validator returns\n * TanStack's global `{ form?, fields }` error shape, so client errors land in TanStack\n * field meta (created on demand — no TanStack `Field` mounts needed) and `state.isValid`\n * stays engine-native. Adapter notes (both mirror the contract's static options intent):\n * - `validateOn` is creation-pinned; schema and message values are read per run.\n * Schema presence may change through the options getter.\n * - Escape-hatch writes (`engine.setFieldValue`) bypass the overlay — server-error\n * clearing and touched semantics then follow TanStack, not the contract.\n *\n * HOW STATE IS READ. `@tanstack/vue-form` is `form-core` under a Vue host binding.\n * - The returned instance is `FormApi & VueFormApi`.\n * - TanStack's store is a `@tanstack/store` `Store`, invisible to Vue's tracker. It is bridged\n * ONCE, here, into a `shallowRef` (`bridgeStore`); every contract read then flows through\n * Vue reactivity. `form.useSelector` would do the same per slice, but it wraps its ref in\n * `readonly()`, which would hand values back through a proxy and break the identity compares\n * the reader and `deepEqual` rely on.\n * - `useForm` applies its options ONCE (Vue's `setup` runs once), so the options object must\n * stay stable: `reset()` keeps `tanstackOptions.defaultValues` in step with TanStack's own\n * copy.\n */\n\n/** The native TanStack form instance the adapter builds — what `form.engine` exposes. */\nexport type TanstackFormEngine<TValues extends object> = FormApi<\n TValues,\n undefined, // onMount\n undefined, // onChange\n undefined, // onChangeAsync\n undefined, // onBlur\n undefined, // onBlurAsync\n undefined, // onSubmit\n undefined, // onSubmitAsync\n undefined, // onDynamic\n FormAsyncValidateOrFn<TValues>, // onDynamicAsync — the adapter's schema bridge\n undefined, // onServer\n never // submitMeta\n> &\n VueFormApi<\n TValues,\n undefined,\n undefined,\n undefined,\n undefined,\n undefined,\n undefined,\n undefined,\n undefined,\n FormAsyncValidateOrFn<TValues>,\n undefined,\n never\n >;\n\ntype TanstackFormOptions<TValues extends object> = FormOptions<\n TValues,\n undefined,\n undefined,\n undefined,\n undefined,\n undefined,\n undefined,\n undefined,\n undefined,\n FormAsyncValidateOrFn<TValues>,\n undefined,\n never\n>;\n\nconst EmptyMessages: ReadonlyArray<string> = Object.freeze([]);\n\n/**\n * Folds the shared schema-error map into TanStack's global form error shape:\n * root-path (`''`) issues become the form-level error, the rest per-field errors.\n */\nfunction toEngineValidationError(errors: Record<string, ReadonlyArray<string>>): unknown {\n const paths = Object.keys(errors);\n if (paths.length === 0) return undefined;\n const fields: Record<string, ReadonlyArray<string>> = Object.create(null);\n let form: ReadonlyArray<string> | undefined;\n for (const path of paths) {\n if (path === '') form = errors[path];\n else fields[path] = errors[path] ?? [];\n }\n return form ? { form, fields } : { fields };\n}\n\n/**\n * Normalizes TanStack field-meta errors to plain messages. The adapter's own validator\n * yields `string[]`, but escape-hatch validators may add strings, nested arrays, or\n * Standard Schema issue objects — all are accepted.\n */\nfunction toMessages(errors: ReadonlyArray<unknown> | undefined): ReadonlyArray<string> {\n if (!errors || errors.length === 0) return EmptyMessages;\n const messages: string[] = [];\n const visit = (error: unknown): void => {\n if (error === null || error === undefined) return;\n if (typeof error === 'string') {\n messages.push(error);\n return;\n }\n if (Array.isArray(error)) {\n for (const entry of error) visit(entry);\n return;\n }\n if (typeof error === 'object' && typeof (error as { message?: unknown }).message === 'string') {\n messages.push((error as { message: string }).message);\n }\n };\n for (const error of errors) visit(error);\n return messages.length > 0 ? messages : EmptyMessages;\n}\n\n/** The per-field slice the `Field` glue reads — identity-stable while its members are unchanged. */\ninterface TanstackFieldState {\n readonly value: unknown;\n readonly errors: ReadonlyArray<string>;\n readonly isDirty: boolean;\n readonly isTouched: boolean;\n}\n\n/** The minimal structural view of TanStack form state the reader consumes (loose string paths). */\ninterface EngineStateView {\n readonly values: unknown;\n readonly isValid: boolean;\n readonly isValidating: boolean;\n readonly isFormValidating: boolean;\n readonly fieldMeta: Partial<Record<string, { readonly errors: ReadonlyArray<unknown> }>>;\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: TanstackFieldState, b: TanstackFieldState): 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\n/**\n * Mirrors the `@tanstack/store` store into a `shallowRef` — the ONE seam that puts TanStack\n * state inside Vue's tracker. Deliberately not `useSelector`/`useStore` from\n * `@tanstack/vue-store`: those wrap the ref in `readonly()`, which would hand every read back\n * through a deep proxy and defeat the `Object.is` identity compares the reader, `deepEqual`, and\n * TanStack's own writes all depend on.\n */\nfunction bridgeStore<TValues extends object>(engine: TanstackFormEngine<TValues>): ShallowRef<EngineStateView> {\n const snapshot = shallowRef(engine.store.state as unknown as EngineStateView);\n const subscription = engine.store.subscribe((next) => {\n snapshot.value = next as unknown as EngineStateView;\n });\n onScopeDispose(() => subscription.unsubscribe(), true);\n return snapshot;\n}\n\ninterface CombinedReader<TValues extends object> {\n readonly getFormState: () => AppFormState<TValues>;\n readonly getFieldState: (path: string) => TanstackFieldState;\n}\n\n/**\n * Derives the contract state from the (TanStack store state, overlay state) pair with\n * generation caching: snapshots are rebuilt only when either source commits, and per-path\n * field slices reuse the previous generation's identity when unchanged — so a read stays\n * referentially stable between commits. Both sources are `shallowRef`s, so every read below\n * is also the subscription.\n */\nfunction createCombinedReader<TValues extends object>(\n snapshot: ShallowRef<EngineStateView>,\n overlay: TanstackFormOverlay<TValues>,\n getValidateOn: () => AppFormOptions<TValues>['validateOn'],\n): CombinedReader<TValues> {\n let generation: { tan: EngineStateView; ov: TanstackOverlayState<TValues> } | null = null;\n let formState: AppFormState<TValues> | null = null;\n let fieldCache = new Map<string, TanstackFieldState>();\n let previousFieldCache = new Map<string, TanstackFieldState>();\n\n function currentGeneration(): { tan: EngineStateView; ov: TanstackOverlayState<TValues> } {\n const tan = snapshot.value;\n const ov = overlay.state.value;\n if (generation && generation.tan === tan && generation.ov === ov) return generation;\n generation = { tan, ov };\n formState = null;\n previousFieldCache = fieldCache;\n fieldCache = new Map();\n return generation;\n }\n\n return {\n getFormState: () => {\n const { tan, ov } = currentGeneration();\n formState ??= {\n values: tan.values as TValues,\n isDirty: !deepEqual(tan.values, ov.baseline),\n // Client validity is engine-native; the server-error overlay holds it false too.\n isValid:\n (ov.scopedErrors === null\n ? tan.isValid\n : Object.keys(ov.scopedErrors).length === 0 &&\n Object.entries(tan.fieldMeta).every(\n ([path, meta]) => includesValidationPath(path, ov.scopedFields) || !meta?.errors.length,\n )) && Object.keys(ov.serverErrors).length === 0,\n isSubmitting: ov.isSubmitting,\n // Whole-schema validation is a FORM-level validator — TanStack's derived\n // `isValidating` counts field-level validators only, so merge both flags.\n isValidating: tan.isFormValidating || tan.isValidating || ov.isScopeValidating,\n submitError: ov.submitError,\n isSubmitSuccessful: ov.isSubmitSuccessful,\n };\n return formState;\n },\n getFieldState: (path) => {\n const { tan, ov } = currentGeneration();\n const cached = fieldCache.get(path);\n if (cached) return cached;\n const value = getPath(tan.values, path);\n const { isTouched, showsClientErrors } = resolveFieldDisplay(path, ov, getValidateOn());\n // Validation is form-wide; display follows the field's own marks. Server messages always display.\n const clientMessages = !showsClientErrors\n ? EmptyMessages\n : ov.scopedErrors !== null && includesValidationPath(path, ov.scopedFields)\n ? (ov.scopedErrors[path] ?? EmptyMessages)\n : toMessages(tan.fieldMeta[path]?.errors);\n const serverMessages = ov.serverErrors[path] ?? EmptyMessages;\n const computed: TanstackFieldState = {\n value,\n // Client + server messages merged, client first (contract JSDoc).\n errors:\n serverMessages.length === 0\n ? clientMessages\n : clientMessages.length === 0\n ? serverMessages\n : [...clientMessages, ...serverMessages],\n isDirty: !deepEqual(value, getPath(ov.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}\n\ninterface AdapterPrelude<TValues extends object, TOutput> {\n readonly getOptions: () => AppFormOptions<TValues, TOutput>;\n readonly overlay: TanstackFormOverlay<TValues>;\n readonly tanstackOptions: TanstackFormOptions<TValues>;\n readonly parseValues: (values: TValues, fresh?: boolean) => Promise<FormParseResult<TOutput>>;\n /** The form's message resolver, memoized against the `messages` / `labels` option identities. */\n readonly messageResolver: () => ResolveValidationMessage;\n readonly bindValues: (read: () => TValues) => void;\n}\n\n/** Builds the overlay + the stable TanStack options (all callbacks read the latest options through `getOptions`). */\nfunction createAdapterPrelude<TValues extends object, TOutput>(\n getOptions: () => AppFormOptions<TValues, TOutput>,\n): AdapterPrelude<TValues, TOutput> {\n let readCurrentValues: (() => TValues) | null = null;\n const initialOptions = getOptions();\n const initialValues = snapshotFormValues(initialOptions.defaultValues);\n const overlay = createTanstackFormOverlay<TValues>(snapshotFormValues(initialValues));\n const messageResolver = createOptionsMessageResolver(getOptions);\n\n let cached: {\n values: TValues;\n schema: AppFormOptions<TValues, TOutput>['schema'];\n resolver: ResolveValidationMessage;\n result: Promise<FormParseResult<TOutput>>;\n } | null = null;\n const parseValues = (values: TValues, fresh = false): Promise<FormParseResult<TOutput>> => {\n const schema = getOptions().schema;\n const resolver = messageResolver();\n if (\n !fresh &&\n cached !== null &&\n deepEqual(cached.values, values) &&\n cached.schema === schema &&\n cached.resolver === resolver\n )\n return cached.result;\n const snapshot = snapshotFormValues(values);\n const result = Promise.resolve()\n .then(() =>\n schema\n ? parseStandardSchema(schema, snapshot, resolver)\n : { ok: true as const, value: snapshot as unknown as TOutput },\n )\n .catch((): FormParseResult<TOutput> =>\n formParseFailure({ '': [getOptions().fallbackErrorMessage ?? 'Validation failed'] }),\n );\n cached = { values: snapshotFormValues(values), schema, resolver, result };\n return result;\n };\n\n const tanstackOptions: TanstackFormOptions<TValues> = {\n defaultValues: initialValues,\n onSubmit: async ({ value }) => {\n // The contract's `isSubmitting` brackets ONLY the app submit call (house-identical),\n // not TanStack's validation window. Failures propagate to the adapter's\n // `handleSubmit` catch, so TanStack's own submit lifecycle stays truthful.\n overlay.setSubmitting(true);\n try {\n const parsed = await parseValues(value, true);\n if (!parsed.ok) return;\n const result = await getOptions().onSubmit(parsed.value, { signal: new AbortController().signal });\n // Reached only when validation passed AND the app submit resolved — the verdict's\n // sole success signal (the invalid path never runs this; a throw skips it).\n overlay.setSubmitSuccessful(result.ok);\n } finally {\n overlay.setSubmitting(false);\n }\n },\n };\n\n const validateWithSchema: FormValidateAsyncFn<TValues> = async ({ value, signal }) => {\n overlay.setScope(null);\n const snapshot = snapshotFormValues(value);\n const result = await untilFormAbort(parseValues(snapshot), signal, null);\n if (!result || (readCurrentValues && !deepEqual(snapshot, readCurrentValues()))) return undefined;\n return toEngineValidationError(result.ok ? {} : result.failure.fieldErrors);\n };\n tanstackOptions.validators = { onDynamicAsync: validateWithSchema };\n tanstackOptions.validationLogic = (props) =>\n revalidateLogic({\n mode:\n overlay.getState().submitCount > 0 || overlay.getState().touched.size > 0\n ? 'change'\n : (initialOptions.validateOn ?? 'submit'),\n modeAfterSubmission: 'change',\n })(props);\n\n return {\n getOptions,\n overlay,\n tanstackOptions,\n messageResolver,\n parseValues,\n bindValues: (read) => {\n readCurrentValues = read;\n },\n };\n}\n\n/** What `buildAppForm` returns — the contract surface plus the teardown the adapter's own timer needs. */\ninterface BuiltForm<TValues extends object> {\n readonly form: AppForm<TValues, TanstackFormEngine<TValues>>;\n /** Releases the pending `submitOn: 'change'` debounce timer on scope teardown. */\n readonly dispose: () => void;\n}\n\n/** Builds the stable contract surface over the TanStack engine + overlay pair. */\nfunction buildAppForm<TValues extends object, TOutput>(\n engine: TanstackFormEngine<TValues>,\n prelude: AdapterPrelude<TValues, TOutput>,\n): BuiltForm<TValues> {\n const { getOptions, overlay, tanstackOptions, messageResolver, parseValues } = prelude;\n let lifecycleEpoch = 0;\n let validationEpoch = 0;\n let focusEpoch = 0;\n let requestController = new AbortController();\n let disposed = false;\n let trailingSubmit = false;\n let submittingValues: TValues | null = null;\n const reader = createCombinedReader(bridgeStore(engine), overlay, () => getOptions().validateOn);\n const identity = createFormArrayIdentity(() => engine.store.state.values);\n\n // ── Submit path shared by `handleSubmit` + auto-submit (validate → onSubmit → map failure) ─────\n /** Resolves a thrown submit failure onto the overlay (matched paths → fields, remainder → banner). */\n function applySubmitFailure(error: AppError, submittedValues = engine.store.state.values): void {\n const options = getOptions();\n const values = engine.store.state.values;\n overlay.applySubmitFailure(\n resolveSubmitFailure(\n error,\n options.mapSubmitError ?? fieldIssues,\n options.mapFieldPath ?? defaultMapFieldPath,\n (path) => hasPath(submittedValues, path) && deepEqual(getPath(submittedValues, path), getPath(values, path)),\n options.fallbackErrorMessage,\n messageResolver(),\n ),\n );\n }\n\n async function performSubmit(values: TValues): Promise<boolean> {\n if (disposed || getOptions().isDisabled) return false;\n const epoch = lifecycleEpoch;\n const signal = requestController.signal;\n const isCurrent = (): boolean => !disposed && epoch === lifecycleEpoch;\n validationEpoch += 1;\n overlay.setScope(null);\n overlay.beginSubmitAttempt();\n // The facade owns submission snapshots; TanStack still owns field validation and metadata.\n // Its validator reuses this parse, so transforming/async schemas run once for this input.\n const parsing = parseValues(values, true);\n await engine.validate('submit');\n const parsed = await parsing;\n if (!isCurrent()) return false;\n if (!parsed.ok) {\n overlay.setSubmitSuccessful(false);\n return false;\n }\n overlay.setSubmitting(true);\n let successful = false;\n try {\n const result = await untilFormAbort(getOptions().onSubmit(parsed.value, { signal }), signal, {\n ok: false,\n failure: AppErrorFactory.cancelled(),\n });\n successful = result.ok;\n if (isCurrent() && result.ok) overlay.setBaseline(values);\n else if (isCurrent() && !result.ok) applySubmitFailure(result.failure, values);\n } catch (error) {\n if (isCurrent()) applySubmitFailure(toSubmitError(error, getOptions().fallbackErrorMessage), values);\n } finally {\n if (isCurrent()) overlay.setSubmitting(false);\n if (isCurrent()) overlay.setSubmitSuccessful(successful);\n }\n return successful && isCurrent();\n }\n\n /** Serializes submissions and coalesces newer edits into one trailing snapshot. */\n let inFlight: Promise<boolean> | null = null;\n async function guardedSubmit(): Promise<boolean> {\n if (disposed) return false;\n if (inFlight) {\n if (!deepEqual(engine.store.state.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(engine.store.state.values);\n successful = await untilFormAbort(performSubmit(submittingValues), requestController.signal, false);\n } while (\n !disposed &&\n trailingSubmit &&\n !deepEqual(engine.store.state.values, submittingValues) &&\n !deepEqual(engine.store.state.values, overlay.getState().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 /** Validate without submitting — marks touched, runs the whole-form schema, resolves client validity. */\n async function validate(options?: AppFormValidationOptions<TValues>): Promise<boolean> {\n if (disposed) return false;\n const epoch = ++validationEpoch;\n const lifecycle = lifecycleEpoch;\n if (options) {\n for (const meta of Object.values(engine.state.validationMetaMap)) meta?.lastAbortController.abort();\n const values = snapshotFormValues(engine.store.state.values);\n for (const path of options.fields ?? Object.keys(values)) overlay.markBlurred(path);\n overlay.setScopeValidating(true);\n const errors = await untilFormAbort(\n validateFormScope(\n values,\n options,\n getOptions().schema,\n messageResolver(),\n getOptions().fallbackErrorMessage ?? 'Validation failed',\n ),\n requestController.signal,\n {},\n );\n if (disposed || epoch !== validationEpoch || lifecycle !== lifecycleEpoch) return false;\n overlay.setScopeValidating(false);\n if (!deepEqual(values, engine.store.state.values)) return false;\n const previous = overlay.getState();\n const retained = Object.fromEntries(\n Object.entries(previous.scopedErrors ?? {}).filter(([path]) => !includesValidationPath(path, options.fields)),\n );\n const fields =\n options.fields &&\n (previous.scopedErrors === null\n ? options.fields\n : previous.scopedFields && [...previous.scopedFields, ...options.fields]);\n overlay.setScope({ ...retained, ...errors }, fields);\n return Object.keys(errors).length === 0;\n }\n overlay.setScope(null);\n overlay.touchAll();\n const values = snapshotFormValues(engine.store.state.values);\n const parsing = parseValues(values, true);\n const result = await untilFormAbort(\n Promise.all([engine.validate('submit'), parsing]),\n requestController.signal,\n null,\n );\n return (\n !disposed &&\n lifecycle === lifecycleEpoch &&\n epoch === validationEpoch &&\n result !== null &&\n result[1].ok &&\n deepEqual(values, engine.store.state.values)\n );\n }\n\n // ── Auto-submit (`submitOn`) — routes through the SAME `guardedSubmit` as manual submit ────────\n let autoSubmitTimer: ReturnType<typeof setTimeout> | null = null;\n const clearAutoSubmitTimer = (): void => {\n if (autoSubmitTimer !== null) {\n clearTimeout(autoSubmitTimer);\n autoSubmitTimer = null;\n }\n };\n const scheduleAutoSubmit = (): void => {\n if ((getOptions().submitOn ?? 'manual') !== 'change') return;\n clearAutoSubmitTimer();\n const delay = getOptions().submitDebounceMs ?? 0;\n autoSubmitTimer = setTimeout(() => {\n autoSubmitTimer = null;\n void guardedSubmit();\n }, delay);\n };\n const autoSubmitOnBlur = (): void => {\n if ((getOptions().submitOn ?? 'manual') === 'blur') void guardedSubmit();\n };\n\n // One API object per path — memoized, so the identity a slot payload sees is stable.\n const fieldApis = new Map<string, AppFieldApi<unknown>>();\n const fieldOps = {\n getState: (path: string) => reader.getFieldState(path),\n setValue: (path: string, value: unknown) => {\n // Server messages clear on the next change to the field (contract JSDoc).\n overlay.clearServerErrorsAt(path);\n overlay.markChanged(path);\n // Triggers TanStack 'change'-cause validation, gated by `revalidateLogic`.\n engine.setFieldValue(path as DeepKeys<TValues>, snapshotFormValues(value) as never);\n identity.replace(path);\n // `submitOn: 'change'` — a user-origin write schedules the debounced auto-submit.\n scheduleAutoSubmit();\n },\n blur: (path: string) => {\n overlay.markBlurred(path);\n // 'blur'-cause validation — runs the schema only in `validateOn: 'blur'` mode.\n void engine.validateField(path as DeepKeys<TValues>, 'blur');\n // `submitOn: 'blur'` — save-on-blur.\n autoSubmitOnBlur();\n },\n };\n const getFieldApi = (path: string): AppFieldApi<unknown> => {\n const existing = fieldApis.get(path);\n if (existing) return existing;\n const api = createFieldApi(path, fieldOps);\n fieldApis.set(path, api);\n return api;\n };\n\n const arrayOperation = (path: string, operation: Parameters<typeof overlay.remapForArrayOperation>[1]): void => {\n // TanStack's array ops are constrained to its typed array paths (`DeepKeysOfType`); the\n // contract's paths are loose strings, so the vendor's path algebra is opted out of with\n // `never` rather than reimplemented here.\n identity.operation(path, operation, () => {\n const field = path as never;\n switch (operation.kind) {\n case 'push':\n engine.pushFieldValue(field, snapshotFormValues(operation.value) as never);\n break;\n case 'insert':\n void engine.insertFieldValue(field, operation.index, snapshotFormValues(operation.value) as never);\n break;\n case 'remove':\n void engine.removeFieldValue(field, operation.index);\n break;\n case 'swap':\n engine.swapFieldValues(field, operation.indexA, operation.indexB);\n break;\n case 'move':\n engine.moveFieldValues(field, operation.fromIndex, operation.toIndex);\n break;\n }\n // Contract reindexing for the overlay: row-scoped server errors + touched marks\n // follow their rows. TanStack shifts its OWN field meta by its rules; where they\n // differ, the contract wins because errors/touched surface from the overlay and\n // client errors are recomputed by the op's change-revalidation.\n overlay.markChanged(path);\n overlay.remapForArrayOperation(path, operation);\n });\n scheduleAutoSubmit();\n };\n\n function invalidateWork(): void {\n lifecycleEpoch += 1;\n validationEpoch += 1;\n focusEpoch += 1;\n requestController.abort();\n requestController = new AbortController();\n for (const meta of Object.values(engine.state.validationMetaMap)) meta?.lastAbortController.abort();\n engine.baseStore.setState((previous) => ({ ...previous, isFormValidating: false }));\n overlay.setSubmitting(false);\n overlay.setScopeValidating(false);\n trailingSubmit = false;\n clearAutoSubmitTimer();\n }\n\n const state = createFormStateView<TValues>(reader.getFormState);\n\n const form: AppForm<TValues, TanstackFormEngine<TValues>> = {\n Field: createFieldComponent<TValues>(getFieldApi, () => getOptions().isDisabled ?? false),\n state,\n // The same computed `state.values` reads — `form.values` is a shorthand, never a second source.\n get values() {\n return state.values;\n },\n useFormState: createUseFormState<TValues>(reader.getFormState),\n handleSubmit: async (event?: Event) => {\n const epoch = ++focusEpoch;\n return submitWithFocus(guardedSubmit, () => epoch === focusEpoch, event, getOptions().focusRoot?.());\n },\n validate,\n cancelSubmit: () => {\n invalidateWork();\n overlay.applySubmitFailure({ fieldErrors: {}, submitError: AppErrorFactory.cancelled() });\n overlay.setSubmitSuccessful(false);\n },\n invalidateSession: (next) => form.reset(next),\n setValue: (path, value) => {\n // Server messages clear on the next change to the field (contract JSDoc) — mirror the\n // in-field `setValue`; TanStack's 'change'-cause validation runs under `revalidateLogic`.\n overlay.clearServerErrorsAt(path);\n overlay.markChanged(path);\n engine.setFieldValue(path as DeepKeys<TValues>, snapshotFormValues(value) as never);\n identity.replace(path);\n scheduleAutoSubmit();\n },\n array: (path: string) => ({\n get keys() {\n return identity.keys(path);\n },\n push: (value: unknown) => arrayOperation(path, { kind: 'push', value }),\n insert: (index: number, value: unknown) => arrayOperation(path, { kind: 'insert', index, value }),\n remove: (index: number) => arrayOperation(path, { kind: 'remove', index }),\n swap: (indexA: number, indexB: number) => arrayOperation(path, { kind: 'swap', indexA, indexB }),\n move: (fromIndex: number, toIndex: number) => arrayOperation(path, { kind: 'move', fromIndex, toIndex }),\n }),\n reset: (next?: TValues) => {\n invalidateWork();\n const values = snapshotFormValues(next ?? overlay.getState().baseline);\n // Keep the options object TanStack was created with in sync: its own `reset(values)`\n // rewrites `options.defaultValues`, and any later `update()` would otherwise clobber the\n // re-seeded values back from the stale copy.\n tanstackOptions.defaultValues = values;\n overlay.reset(snapshotFormValues(values));\n engine.reset(values);\n identity.reset();\n clearAutoSubmitTimer(); // a reset/prefill never auto-submits — drop any pending trailing submit\n },\n setFieldErrors: (errors: Record<string, ReadonlyArray<string>>) => overlay.replaceServerErrors(errors),\n clearSubmitError: () => overlay.clearSubmitError(),\n engine,\n };\n\n return {\n form,\n dispose: () => {\n invalidateWork();\n disposed = true;\n },\n };\n}\n\n/**\n * The tanstack adapter's `useAppForm` — the facade contract over `@tanstack/vue-form`.\n * The returned form object is stable for the owning scope's lifetime and every state member on\n * it is a live getter, so `form.values.title` / `form.state.isSubmitting` read in a template ARE\n * the subscription; `form.engine` exposes the native {@link TanstackFormEngine} (the 90/10\n * escape hatch — typed here, `unknown` on the shared contract), including TanStack's typed\n * deep-path `Field`/`Subscribe` and per-field validator graph.\n *\n * Call it in `setup()`: `useForm` registers an `onMounted` of its own, and the store bridge +\n * the pending `submitOn: 'change'` timer release on scope teardown.\n */\nexport function useAppForm<TValues extends object, TOutput = TValues>(\n options: AppFormOptionsSource<TValues, TOutput>,\n): AppForm<TValues, TanstackFormEngine<TValues>> {\n const prelude = createAdapterPrelude<TValues, TOutput>(() => toValue(options));\n const engine = useForm(prelude.tanstackOptions) as TanstackFormEngine<TValues>;\n prelude.bindValues(() => engine.store.state.values);\n const built = buildAppForm<TValues, TOutput>(engine, prelude);\n\n // Validate once on mount when flagged — seeds `isValid` / field errors WITHOUT marking touched\n // (the mount pass shows validity without asserting the user interacted).\n onMounted(() => {\n if (toValue(options).validateOnMount) void engine.validate('submit');\n });\n onScopeDispose(built.dispose, true);\n\n return built.form;\n}\n"],"names":["values"],"mappings":";;;;;;;;;;;;;AA2HA,MAAM,gBAAu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,WAAW,QAAA,CAAS;AAAA,IAAA;AAAA,IAEzG,OAAO,CAAC,SAAmB;AACzB,qBAAA;AACA,YAAM,SAAS,mBAAmB,QAAQ,QAAQ,SAAA,EAAW,QAAQ;AAIrE,sBAAgB,gBAAgB;AAChC,cAAQ,MAAM,mBAAmB,MAAM,CAAC;AACxC,aAAO,MAAM,MAAM;AACnB,eAAS,MAAA;AACT,2BAAA;AAAA,IACF;AAAA,IACA,gBAAgB,CAAC,WAAkD,QAAQ,oBAAoB,MAAM;AAAA,IACrG,kBAAkB,MAAM,QAAQ,iBAAA;AAAA,IAChC;AAAA,EAAA;AAGF,SAAO;AAAA,IACL;AAAA,IACA,SAAS,MAAM;AACb,qBAAA;AACA,iBAAW;AAAA,IACb;AAAA,EAAA;AAEJ;AAaO,SAAS,WACd,SAC+C;AAC/C,QAAM,UAAU,qBAAuC,MAAM,QAAQ,OAAO,CAAC;AAC7E,QAAM,SAAS,QAAQ,QAAQ,eAAe;AAC9C,UAAQ,WAAW,MAAM,OAAO,MAAM,MAAM,MAAM;AAClD,QAAM,QAAQ,aAA+B,QAAQ,OAAO;AAI5D,YAAU,MAAM;AACd,QAAI,QAAQ,OAAO,EAAE,gBAAiB,MAAK,OAAO,SAAS,QAAQ;AAAA,EACrE,CAAC;AACD,iBAAe,MAAM,SAAS,IAAI;AAElC,SAAO,MAAM;AACf;"}
@@ -76,10 +76,10 @@ export declare const AnimatedLayout: import('vue').DefineComponent<import('vue')
76
76
  };
77
77
  }>> & Readonly<{}>, {
78
78
  enabled: boolean;
79
- isEnabled: boolean;
80
- reducedMotion: boolean | undefined;
81
- duration: number;
82
79
  easing: string;
80
+ duration: number;
81
+ reducedMotion: boolean | undefined;
82
+ isEnabled: boolean;
83
83
  }, SlotsType<{
84
84
  default?: () => VNode[];
85
85
  }>, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Marks an element that script focuses without it being a control — a page's `main` after a route change, a
3
+ * heading, a region that holds focus while its content swaps. The base styles (`index.css`) draw no focus ring on
4
+ * a marked element: a ring around a whole page or card points at nothing the reader can operate, and a screen
5
+ * reader still lands on it and reads it.
6
+ */
7
+ export declare const FocusTargetAttribute = "data-focus-target";
8
+ /**
9
+ * Focuses `element` as a programmatic focus target: gives it `tabindex="-1"` when it has no tabindex of its own
10
+ * (focusable by script, never a Tab stop), marks it with {@link FocusTargetAttribute} and focuses it without
11
+ * scrolling. Returns whether the element now holds focus.
12
+ */
13
+ export declare function focusTarget(element: HTMLElement): boolean;
@@ -0,0 +1,12 @@
1
+ const FocusTargetAttribute = "data-focus-target";
2
+ function focusTarget(element) {
3
+ if (!element.hasAttribute("tabindex")) element.tabIndex = -1;
4
+ element.setAttribute(FocusTargetAttribute, "");
5
+ element.focus({ preventScroll: true });
6
+ return element.ownerDocument.activeElement === element;
7
+ }
8
+ export {
9
+ FocusTargetAttribute,
10
+ focusTarget
11
+ };
12
+ //# sourceMappingURL=FocusTarget.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FocusTarget.js","sources":["../../../src/foundation/dom/FocusTarget.ts"],"sourcesContent":["/**\n * Marks an element that script focuses without it being a control — a page's `main` after a route change, a\n * heading, a region that holds focus while its content swaps. The base styles (`index.css`) draw no focus ring on\n * a marked element: a ring around a whole page or card points at nothing the reader can operate, and a screen\n * reader still lands on it and reads it.\n */\nexport const FocusTargetAttribute = 'data-focus-target';\n\n/**\n * Focuses `element` as a programmatic focus target: gives it `tabindex=\"-1\"` when it has no tabindex of its own\n * (focusable by script, never a Tab stop), marks it with {@link FocusTargetAttribute} and focuses it without\n * scrolling. Returns whether the element now holds focus.\n */\nexport function focusTarget(element: HTMLElement): boolean {\n if (!element.hasAttribute('tabindex')) element.tabIndex = -1;\n element.setAttribute(FocusTargetAttribute, '');\n element.focus({ preventScroll: true });\n return element.ownerDocument.activeElement === element;\n}\n"],"names":[],"mappings":"AAMO,MAAM,uBAAuB;AAO7B,SAAS,YAAY,SAA+B;AACzD,MAAI,CAAC,QAAQ,aAAa,UAAU,WAAW,WAAW;AAC1D,UAAQ,aAAa,sBAAsB,EAAE;AAC7C,UAAQ,MAAM,EAAE,eAAe,KAAA,CAAM;AACrC,SAAO,QAAQ,cAAc,kBAAkB;AACjD;"}