@wow-two-beta/fe 0.0.39 → 0.0.40

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/dist/formsEngine/AppForm.d.ts +12 -3
  2. package/dist/formsEngine/FormOperations.d.ts +18 -0
  3. package/dist/formsEngine/FormOperations.js +9 -0
  4. package/dist/formsEngine/FormOperations.js.map +1 -1
  5. package/dist/formsEngine/adapters/house/HouseFormCore.js +15 -6
  6. package/dist/formsEngine/adapters/house/HouseFormCore.js.map +1 -1
  7. package/dist/formsEngine/adapters/tanstack/TanstackFormOverlay.d.ts +4 -0
  8. package/dist/formsEngine/adapters/tanstack/TanstackFormOverlay.js +10 -1
  9. package/dist/formsEngine/adapters/tanstack/TanstackFormOverlay.js.map +1 -1
  10. package/dist/formsEngine/adapters/tanstack/UseAppForm.js +9 -6
  11. package/dist/formsEngine/adapters/tanstack/UseAppForm.js.map +1 -1
  12. package/dist/foundation/animation/animatedLayout/AnimatedLayout.d.ts +3 -3
  13. package/dist/foundation/dom/FocusTarget.d.ts +13 -0
  14. package/dist/foundation/dom/FocusTarget.js +12 -0
  15. package/dist/foundation/dom/FocusTarget.js.map +1 -0
  16. package/dist/foundation/dom/index.d.ts +1 -0
  17. package/dist/foundation/dom/index.js +3 -0
  18. package/dist/foundation/dom/index.js.map +1 -1
  19. package/dist/foundation/primitives/index.d.ts +1 -0
  20. package/dist/foundation/primitives/index.js +3 -0
  21. package/dist/foundation/primitives/index.js.map +1 -1
  22. package/dist/foundation/primitives/swapTransition/SwapTransition.d.ts +76 -0
  23. package/dist/foundation/primitives/swapTransition/SwapTransition.js +240 -0
  24. package/dist/foundation/primitives/swapTransition/SwapTransition.js.map +1 -0
  25. package/dist/foundation/primitives/swapTransition/index.d.ts +1 -0
  26. package/dist/index.css +11 -0
  27. package/dist/presentation/display/animatedNumberText/AnimatedNumberText.vue.d.ts +1 -1
  28. package/dist/presentation/display/carousel/Carousel.vue.d.ts +1 -1
  29. package/dist/presentation/display/countUpText/CountUpText.vue.d.ts +1 -1
  30. package/dist/presentation/display/scrollRevealGroup/ScrollRevealGroup.vue.d.ts +2 -2
  31. package/dist/presentation/forms/imageCropEditor/ImageCropEditor.vue.d.ts +1 -1
  32. package/dist/presentation/forms/imageEditor/ImageEditor.vue.d.ts +1 -1
  33. package/dist/presentation/forms/phoneInput/PhoneInput.vue.d.ts +4 -0
  34. package/dist/presentation/forms/phoneInput/PhoneInput.vue.js +19 -6
  35. package/dist/presentation/forms/phoneInput/PhoneInput.vue.js.map +1 -1
  36. package/dist/router/adapters/vueRouter/routeAnnouncer/RouteAnnouncer.vue.js +17 -5
  37. package/dist/router/adapters/vueRouter/routeAnnouncer/RouteAnnouncer.vue.js.map +1 -1
  38. package/package.json +1 -1
@@ -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,MAAI,MAAM,WAAW,EAAG,QAAO;AAC/B,QAAM,SAAgD,uBAAO,OAAO,IAAI;AACxE,MAAI;AACJ,aAAW,QAAQ,OAAO;AACxB,QAAI,SAAS,GAAI,QAAO,OAAO,IAAI;AAAA,gBACvB,IAAI,IAAI,OAAO,IAAI,KAAK,CAAA;AAAA,EACtC;AACA,SAAO,OAAO,E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O;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,gBAAuC,OAAO,OAAO,EAAE;AAM7D,SAAS,wBAAwB,QAAwD;AACvF,QAAM,QAAQ,OAAO,KAAK,MAAM;AAChC,MAAI,MAAM,WAAW,EAAG,QAAO;AAC/B,QAAM,SAAgD,uBAAO,OAAO,IAAI;AACxE,MAAI;AACJ,aAAW,QAAQ,OAAO;AACxB,QAAI,SAAS,GAAI,QA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nB,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;"}
@@ -17,3 +17,4 @@ export * from './hooks/UseScrollActivity';
17
17
  export { DomOrderExtensions } from './DomOrderExtensions';
18
18
  export { resolveElement } from './ResolveElement';
19
19
  export { ScrollRegionAttribute, findScrollRegions } from './ScrollRegion';
20
+ export { FocusTargetAttribute, focusTarget } from './FocusTarget';
@@ -16,6 +16,7 @@ import { ScrollIdleDelay, ScrollingAttribute, useScrollActivity } from "./hooks/
16
16
  import { DomOrderExtensions } from "./DomOrderExtensions.js";
17
17
  import { resolveElement } from "./ResolveElement.js";
18
18
  import { ScrollRegionAttribute, findScrollRegions } from "./ScrollRegion.js";
19
+ import { FocusTargetAttribute, focusTarget } from "./FocusTarget.js";
19
20
  export {
20
21
  AriaAttribute,
21
22
  AttributeValue,
@@ -23,6 +24,7 @@ export {
23
24
  DomEvent,
24
25
  DomOrderExtensions,
25
26
  ElementTag,
27
+ FocusTargetAttribute,
26
28
  HtmlElement,
27
29
  Key,
28
30
  PressExtensions,
@@ -33,6 +35,7 @@ export {
33
35
  composeEventHandlers,
34
36
  dataAttr,
35
37
  findScrollRegions,
38
+ focusTarget,
36
39
  resolveElement,
37
40
  useEventListener,
38
41
  useFocusTrap,
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;"}
@@ -2,6 +2,7 @@ export * from './slot';
2
2
  export * from './portal';
3
3
  export * from './visuallyHidden';
4
4
  export * from './presence';
5
+ export * from './swapTransition';
5
6
  export * from './directionProvider';
6
7
  export * from './accessibleIcon';
7
8
  export * from './focusScope';
@@ -20,6 +20,7 @@ import { Orientation, RovingFocusKey, useRovingFocusItem } from "./rovingFocusGr
20
20
  import { Presence } from "./presence/Presence.js";
21
21
  import { Primitive } from "./slot/Primitive.js";
22
22
  import { Slottable, mergeProps, renderSlotClone, renderableChildren } from "./slot/Slot.js";
23
+ import { SwapTransition, SwapTransitionAttribute } from "./swapTransition/SwapTransition.js";
23
24
  import { createCollection } from "./collection/Collection.js";
24
25
  export {
25
26
  AccessibleIcon,
@@ -48,6 +49,8 @@ export {
48
49
  default12 as ScrollLockProvider,
49
50
  default13 as ScrollViewport,
50
51
  Slottable,
52
+ SwapTransition,
53
+ SwapTransitionAttribute,
51
54
  default14 as VisuallyHidden,
52
55
  colorModeScript,
53
56
  createCollection,
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,76 @@
1
+ import { SlotsType, VNode } from 'vue';
2
+ /** Present on the box while a swap runs — from the old content's fade-out to the new content's fade-in. */
3
+ export declare const SwapTransitionAttribute = "data-swapping";
4
+ /** Props for `SwapTransition`. */
5
+ export interface SwapTransitionProps {
6
+ /** Whether swaps and height changes animate. Defaults to `true`; `false` swaps instantly. */
7
+ readonly isEnabled?: boolean;
8
+ /** The height phase in milliseconds. Defaults to `200`. */
9
+ readonly duration?: number;
10
+ /** Each fade phase in milliseconds. Defaults to `120`. */
11
+ readonly fadeDuration?: number;
12
+ /** The easing curve of every phase. Defaults to the house ease-out curve. */
13
+ readonly easing?: string;
14
+ }
15
+ /**
16
+ * Swaps its content with a fade and a height animation: on a change of the single child's key or type, the old
17
+ * content fades out, the box animates to the new content's height, and the new content fades in. While shown, the box
18
+ * follows its content's own height changes the same way. The first render, `:is-enabled="false"` and
19
+ * `prefers-reduced-motion` swap and resize instantly.
20
+ *
21
+ * Renders a `div` box (caller `class`, `style` and attributes fall through to it) around a `flow-root` content
22
+ * wrapper. The leaving content is `inert`; focus inside it moves to the box as a programmatic focus target, so it
23
+ * never falls back to the document body.
24
+ */
25
+ export declare const SwapTransition: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
26
+ /** Whether swaps and height changes animate. Defaults to `true`. */
27
+ isEnabled: {
28
+ type: BooleanConstructor;
29
+ default: undefined;
30
+ };
31
+ /** The height phase in milliseconds. Defaults to `200`. */
32
+ duration: {
33
+ type: NumberConstructor;
34
+ default: undefined;
35
+ };
36
+ /** Each fade phase in milliseconds. Defaults to `120`. */
37
+ fadeDuration: {
38
+ type: NumberConstructor;
39
+ default: undefined;
40
+ };
41
+ /** The easing curve of every phase. Defaults to the house ease-out curve. */
42
+ easing: {
43
+ type: StringConstructor;
44
+ default: undefined;
45
+ };
46
+ }>, () => VNode<import('vue').RendererNode, import('vue').RendererElement, {
47
+ [key: string]: any;
48
+ }>, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
49
+ /** Whether swaps and height changes animate. Defaults to `true`. */
50
+ isEnabled: {
51
+ type: BooleanConstructor;
52
+ default: undefined;
53
+ };
54
+ /** The height phase in milliseconds. Defaults to `200`. */
55
+ duration: {
56
+ type: NumberConstructor;
57
+ default: undefined;
58
+ };
59
+ /** Each fade phase in milliseconds. Defaults to `120`. */
60
+ fadeDuration: {
61
+ type: NumberConstructor;
62
+ default: undefined;
63
+ };
64
+ /** The easing curve of every phase. Defaults to the house ease-out curve. */
65
+ easing: {
66
+ type: StringConstructor;
67
+ default: undefined;
68
+ };
69
+ }>> & Readonly<{}>, {
70
+ easing: string;
71
+ duration: number;
72
+ isEnabled: boolean;
73
+ fadeDuration: number;
74
+ }, SlotsType<{
75
+ default?: () => VNode[];
76
+ }>, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
@@ -0,0 +1,240 @@
1
+ import { defineComponent, shallowRef, onMounted, onBeforeUnmount, h, Transition } from "vue";
2
+ import { animate, AnimationDefaults } from "../../animation/Animate.js";
3
+ import { useReducedMotion } from "../../device/hooks/UseReducedMotion.js";
4
+ import { FocusTargetAttribute, focusTarget } from "../../dom/FocusTarget.js";
5
+ const SwapTransitionAttribute = "data-swapping";
6
+ const FadeDurationMs = 120;
7
+ const SettleSlackMs = 250;
8
+ const ContentStyle = { display: "flow-root" };
9
+ function settle(handle, ms) {
10
+ return new Promise((resolve) => {
11
+ const timer = setTimeout(() => {
12
+ handle.finish();
13
+ resolve();
14
+ }, ms + SettleSlackMs);
15
+ void handle.finished.then(() => {
16
+ clearTimeout(timer);
17
+ resolve();
18
+ });
19
+ });
20
+ }
21
+ const SwapTransition = defineComponent({
22
+ name: "SwapTransition",
23
+ props: {
24
+ /** Whether swaps and height changes animate. Defaults to `true`. */
25
+ isEnabled: { type: Boolean, default: void 0 },
26
+ /** The height phase in milliseconds. Defaults to `200`. */
27
+ duration: { type: Number, default: void 0 },
28
+ /** Each fade phase in milliseconds. Defaults to `120`. */
29
+ fadeDuration: { type: Number, default: void 0 },
30
+ /** The easing curve of every phase. Defaults to the house ease-out curve. */
31
+ easing: { type: String, default: void 0 }
32
+ },
33
+ slots: Object,
34
+ setup(props, { slots }) {
35
+ const box = shallowRef(null);
36
+ const content = shallowRef(null);
37
+ const prefersReducedMotion = useReducedMotion();
38
+ let phase = 0;
39
+ let handle = null;
40
+ let isSwapping = false;
41
+ let isEntering = false;
42
+ let isFollowing = false;
43
+ let isDisposed = false;
44
+ let lastHeight = null;
45
+ let observer = null;
46
+ const heightDuration = () => props.duration ?? AnimationDefaults.duration;
47
+ const fadeDuration = () => props.fadeDuration ?? FadeDurationMs;
48
+ const isAnimated = () => (props.isEnabled ?? true) && !prefersReducedMotion.value && document.visibilityState !== "hidden";
49
+ function stop() {
50
+ phase += 1;
51
+ handle?.cancel();
52
+ handle = null;
53
+ }
54
+ async function play(element, keyframes, duration) {
55
+ stop();
56
+ const token = phase;
57
+ const current = animate(element, keyframes, { duration, easing: props.easing });
58
+ handle = current;
59
+ await settle(current, duration);
60
+ if (token !== phase || isDisposed) return false;
61
+ handle = null;
62
+ return true;
63
+ }
64
+ async function resizeTo(boxElement, to) {
65
+ const from = boxElement.getBoundingClientRect().height;
66
+ boxElement.style.height = `${to}px`;
67
+ if (from === to) return true;
68
+ return play(boxElement, [{ height: `${from}px` }, { height: `${to}px` }], heightDuration());
69
+ }
70
+ function pin(boxElement) {
71
+ const height = boxElement.getBoundingClientRect().height;
72
+ stop();
73
+ isFollowing = false;
74
+ isSwapping = true;
75
+ boxElement.setAttribute(SwapTransitionAttribute, "");
76
+ boxElement.style.height = `${height}px`;
77
+ boxElement.style.overflow = "hidden";
78
+ }
79
+ function release() {
80
+ isSwapping = false;
81
+ isFollowing = false;
82
+ const boxElement = box.value;
83
+ if (boxElement) {
84
+ boxElement.style.height = "";
85
+ boxElement.style.overflow = "";
86
+ boxElement.removeAttribute(SwapTransitionAttribute);
87
+ }
88
+ const inner = content.value;
89
+ if (inner) {
90
+ inner.style.opacity = "";
91
+ inner.inert = false;
92
+ lastHeight = inner.getBoundingClientRect().height;
93
+ }
94
+ }
95
+ function parkFocus(boxElement, inner) {
96
+ const active = boxElement.ownerDocument.activeElement;
97
+ if (!active || !inner.contains(active)) return;
98
+ const hadTabIndex = boxElement.hasAttribute("tabindex");
99
+ const hadMarker = boxElement.hasAttribute(FocusTargetAttribute);
100
+ if (!focusTarget(boxElement)) return;
101
+ boxElement.addEventListener(
102
+ "blur",
103
+ () => {
104
+ if (!hadTabIndex) boxElement.removeAttribute("tabindex");
105
+ if (!hadMarker) boxElement.removeAttribute(FocusTargetAttribute);
106
+ },
107
+ { once: true }
108
+ );
109
+ }
110
+ function onBeforeLeave() {
111
+ const boxElement = box.value;
112
+ const inner = content.value;
113
+ if (!boxElement || !inner) return;
114
+ parkFocus(boxElement, inner);
115
+ if (!isAnimated()) return;
116
+ const opacity = getComputedStyle(inner).opacity;
117
+ pin(boxElement);
118
+ inner.style.opacity = opacity;
119
+ inner.inert = true;
120
+ }
121
+ function onLeave(_element, done) {
122
+ const inner = content.value;
123
+ if (!inner || !isSwapping) {
124
+ queueMicrotask(done);
125
+ return;
126
+ }
127
+ const from = inner.style.opacity || "1";
128
+ inner.style.opacity = "0";
129
+ if (Number(from) === 0) {
130
+ queueMicrotask(done);
131
+ return;
132
+ }
133
+ void play(inner, [{ opacity: from }, { opacity: "0" }], fadeDuration()).then(() => {
134
+ if (!isDisposed) done();
135
+ });
136
+ }
137
+ function onAfterLeave() {
138
+ const boxElement = box.value;
139
+ const inner = content.value;
140
+ if (inner) inner.inert = false;
141
+ if (!boxElement || !inner || !isSwapping || isEntering) return;
142
+ void resizeTo(boxElement, inner.getBoundingClientRect().height).then((isComplete) => {
143
+ if (isComplete) release();
144
+ });
145
+ }
146
+ function onBeforeEnter() {
147
+ isEntering = true;
148
+ const boxElement = box.value;
149
+ const inner = content.value;
150
+ if (!boxElement || !inner) return;
151
+ inner.inert = false;
152
+ if (!isAnimated()) {
153
+ if (isSwapping) {
154
+ stop();
155
+ release();
156
+ }
157
+ return;
158
+ }
159
+ pin(boxElement);
160
+ inner.style.opacity = "0";
161
+ }
162
+ function onEnter(_element, done) {
163
+ const boxElement = box.value;
164
+ const inner = content.value;
165
+ if (!boxElement || !inner || !isSwapping) {
166
+ done();
167
+ return;
168
+ }
169
+ void (async () => {
170
+ if (!await resizeTo(boxElement, inner.getBoundingClientRect().height)) return;
171
+ inner.style.opacity = "";
172
+ if (!await play(inner, [{ opacity: "0" }, { opacity: "1" }], fadeDuration())) return;
173
+ done();
174
+ })();
175
+ }
176
+ function onAfterEnter() {
177
+ isEntering = false;
178
+ release();
179
+ }
180
+ function onEnterCancelled() {
181
+ isEntering = false;
182
+ }
183
+ function onResize() {
184
+ const boxElement = box.value;
185
+ const inner = content.value;
186
+ if (!boxElement || !inner) return;
187
+ const height = inner.getBoundingClientRect().height;
188
+ const previous = lastHeight;
189
+ lastHeight = height;
190
+ if (isSwapping || previous === null || previous === height || !isAnimated()) return;
191
+ const from = isFollowing ? boxElement.getBoundingClientRect().height : previous;
192
+ stop();
193
+ isFollowing = true;
194
+ boxElement.style.height = `${height}px`;
195
+ boxElement.style.overflow = "hidden";
196
+ void play(boxElement, [{ height: `${from}px` }, { height: `${height}px` }], heightDuration()).then(
197
+ (isComplete) => {
198
+ if (isComplete && !isSwapping) release();
199
+ }
200
+ );
201
+ }
202
+ onMounted(() => {
203
+ const inner = content.value;
204
+ if (!inner || typeof ResizeObserver === "undefined") return;
205
+ lastHeight = inner.getBoundingClientRect().height;
206
+ observer = new ResizeObserver(onResize);
207
+ observer.observe(inner);
208
+ });
209
+ onBeforeUnmount(() => {
210
+ isDisposed = true;
211
+ stop();
212
+ observer?.disconnect();
213
+ observer = null;
214
+ });
215
+ return () => h("div", { ref: box }, [
216
+ h("div", { ref: content, style: ContentStyle }, [
217
+ h(
218
+ Transition,
219
+ {
220
+ mode: "out-in",
221
+ css: false,
222
+ onBeforeLeave,
223
+ onLeave,
224
+ onAfterLeave,
225
+ onBeforeEnter,
226
+ onEnter,
227
+ onAfterEnter,
228
+ onEnterCancelled
229
+ },
230
+ () => slots.default?.()
231
+ )
232
+ ])
233
+ ]);
234
+ }
235
+ });
236
+ export {
237
+ SwapTransition,
238
+ SwapTransitionAttribute
239
+ };
240
+ //# sourceMappingURL=SwapTransition.js.map