attaform 0.23.0 → 0.24.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/chunks/devtools.cjs +1 -1
- package/dist/chunks/devtools.mjs +1 -1
- package/dist/chunks/fingerprint2.cjs +1 -1
- package/dist/chunks/fingerprint2.mjs +1 -1
- package/dist/index.cjs +5 -150
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -132
- package/dist/index.d.mts +6 -132
- package/dist/index.d.ts +6 -132
- package/dist/index.mjs +5 -150
- package/dist/index.mjs.map +1 -1
- package/dist/nuxt.d.cts +1 -1
- package/dist/nuxt.d.mts +1 -1
- package/dist/nuxt.d.ts +1 -1
- package/dist/runtime/components/AttaformDevtoolsPanel.vue +2 -2
- package/dist/runtime/plugins/attaform.cjs +2 -2
- package/dist/runtime/plugins/attaform.mjs +2 -2
- package/dist/shared/{attaform.Dx9-QQE2.mjs → attaform.0-00cYGw.mjs} +2 -2
- package/dist/shared/{attaform.Dx9-QQE2.mjs.map → attaform.0-00cYGw.mjs.map} +1 -1
- package/dist/shared/{attaform.D52oJiYC.d.cts → attaform.4zesozTg.d.mts} +38 -6
- package/dist/shared/{attaform.Db4E4IW6.cjs → attaform.B7UdTs_o.cjs} +79 -79
- package/dist/shared/attaform.B7UdTs_o.cjs.map +1 -0
- package/dist/shared/{attaform.BibT5AS_.cjs → attaform.BOi6n2Pn.cjs} +2 -2
- package/dist/shared/{attaform.BibT5AS_.cjs.map → attaform.BOi6n2Pn.cjs.map} +1 -1
- package/dist/shared/{attaform.DCkSNnPr.d.mts → attaform.Bk7vnQhG.d.cts} +38 -6
- package/dist/shared/{attaform.BGMRvckW.d.ts → attaform.Bq6Copxn.d.cts} +41 -25
- package/dist/shared/{attaform.DuPneYR0.d.cts → attaform.BrFPMFgi.d.ts} +41 -25
- package/dist/shared/{attaform.alpG7rT7.mjs → attaform.BunnTiTw.mjs} +4 -4
- package/dist/shared/attaform.BunnTiTw.mjs.map +1 -0
- package/dist/shared/{attaform.DrY8srOp.d.mts → attaform.BwAcpoRw.d.mts} +41 -25
- package/dist/shared/{attaform.CaYj3ZfY.cjs → attaform.C-1W0T1n.cjs} +6 -4
- package/dist/shared/attaform.C-1W0T1n.cjs.map +1 -0
- package/dist/shared/{attaform.Dd1Kmmaj.mjs → attaform.C-tQKknW.mjs} +6 -4
- package/dist/shared/attaform.C-tQKknW.mjs.map +1 -0
- package/dist/shared/{attaform.BhI9Icek.mjs → attaform.C0au8oXd.mjs} +36 -31
- package/dist/shared/attaform.C0au8oXd.mjs.map +1 -0
- package/dist/shared/attaform.CjdepGnw.cjs +27 -0
- package/dist/shared/attaform.CjdepGnw.cjs.map +1 -0
- package/dist/shared/{attaform.DbyTD8N2.cjs → attaform.Cn6JoG9o.cjs} +8 -6
- package/dist/shared/attaform.Cn6JoG9o.cjs.map +1 -0
- package/dist/shared/{attaform.Cmb_LCie.cjs → attaform.CrrIaHM8.cjs} +4 -4
- package/dist/shared/attaform.CrrIaHM8.cjs.map +1 -0
- package/dist/shared/{attaform.BJnNK75Y.d.mts → attaform.DBhrKb2j.d.cts} +206 -168
- package/dist/shared/{attaform.BJnNK75Y.d.ts → attaform.DBhrKb2j.d.mts} +206 -168
- package/dist/shared/{attaform.BJnNK75Y.d.cts → attaform.DBhrKb2j.d.ts} +206 -168
- package/dist/shared/{attaform.DsQkXE3o.cjs → attaform.DRQjF16I.cjs} +248 -195
- package/dist/shared/attaform.DRQjF16I.cjs.map +1 -0
- package/dist/shared/attaform.DdjDqTah.d.cts +56 -0
- package/dist/shared/attaform.DdjDqTah.d.mts +56 -0
- package/dist/shared/attaform.DdjDqTah.d.ts +56 -0
- package/dist/shared/{attaform.WEwfXcHq.d.ts → attaform.Df4xXKbE.d.ts} +38 -6
- package/dist/shared/{attaform.BFWb6hDk.mjs → attaform.DhXl0Kdr.mjs} +7 -1
- package/dist/shared/attaform.DhXl0Kdr.mjs.map +1 -0
- package/dist/shared/{attaform.CR6wGvNu.cjs → attaform.DwLw3Kzv.cjs} +7 -1
- package/dist/shared/attaform.DwLw3Kzv.cjs.map +1 -0
- package/dist/shared/{attaform.CzVta5o2.mjs → attaform.FY5r1BpA.mjs} +8 -6
- package/dist/shared/attaform.FY5r1BpA.mjs.map +1 -0
- package/dist/shared/{attaform.CtJOd7ox.mjs → attaform.NWrEGrNo.mjs} +247 -193
- package/dist/shared/attaform.NWrEGrNo.mjs.map +1 -0
- package/dist/shared/attaform.WvcckZMD.mjs +21 -0
- package/dist/shared/attaform.WvcckZMD.mjs.map +1 -0
- package/dist/transforms.cjs +1 -1
- package/dist/transforms.mjs +1 -1
- package/dist/vite.cjs +1 -1
- package/dist/vite.mjs +1 -1
- package/dist/zod-v3.cjs +2 -2
- package/dist/zod-v3.d.cts +12 -11
- package/dist/zod-v3.d.mts +12 -11
- package/dist/zod-v3.d.ts +12 -11
- package/dist/zod-v3.mjs +2 -2
- package/dist/zod-v4.cjs +2 -2
- package/dist/zod-v4.d.cts +6 -5
- package/dist/zod-v4.d.mts +6 -5
- package/dist/zod-v4.d.ts +6 -5
- package/dist/zod-v4.mjs +2 -2
- package/dist/zod.cjs +5 -5
- package/dist/zod.cjs.map +1 -1
- package/dist/zod.d.cts +21 -52
- package/dist/zod.d.mts +21 -52
- package/dist/zod.d.ts +21 -52
- package/dist/zod.mjs +5 -5
- package/dist/zod.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/shared/attaform.BFWb6hDk.mjs.map +0 -1
- package/dist/shared/attaform.BhI9Icek.mjs.map +0 -1
- package/dist/shared/attaform.CR6wGvNu.cjs.map +0 -1
- package/dist/shared/attaform.CaYj3ZfY.cjs.map +0 -1
- package/dist/shared/attaform.Cmb_LCie.cjs.map +0 -1
- package/dist/shared/attaform.CtJOd7ox.mjs.map +0 -1
- package/dist/shared/attaform.CzVta5o2.mjs.map +0 -1
- package/dist/shared/attaform.Db4E4IW6.cjs.map +0 -1
- package/dist/shared/attaform.DbyTD8N2.cjs.map +0 -1
- package/dist/shared/attaform.Dd1Kmmaj.mjs.map +0 -1
- package/dist/shared/attaform.DsQkXE3o.cjs.map +0 -1
- package/dist/shared/attaform.alpG7rT7.mjs.map +0 -1
- package/dist/shared/attaform.nf83TIR5.d.cts +0 -35
- package/dist/shared/attaform.nf83TIR5.d.mts +0 -35
- package/dist/shared/attaform.nf83TIR5.d.ts +0 -35
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attaform.
|
|
1
|
+
{"version":3,"file":"attaform.BOi6n2Pn.cjs","sources":["../../src/runtime/core/serialize.ts","../../src/runtime/core/devtools-shared.ts"],"sourcesContent":["import type { App } from 'vue'\nimport type { FormKey } from '../types/types-api'\nimport { pathKeyToDotted, type PathKey } from './paths'\nimport { getRegistryFromApp, type SerializedFormData } from './registry'\n\n/**\n * Serialised snapshot of every form in a Vue app, produced by\n * `renderAttaformState` and consumed by `hydrateAttaformState`.\n *\n * JSON-safe — pass to `JSON.stringify`, `devalue`, or any other\n * serialiser before embedding in your SSR payload.\n */\nexport type SerializedAttaformState = {\n /** Tuples of `[formKey, snapshot]` for every form in the app. */\n readonly forms: ReadonlyArray<readonly [FormKey, SerializedFormData]>\n}\n\n/**\n * Snapshot every form on a Vue app for SSR. Call from your server\n * entry after rendering the app:\n *\n * ```ts\n * import { renderToString } from '@vue/server-renderer'\n * import { renderAttaformState, escapeForInlineScript } from 'attaform'\n *\n * const html = await renderToString(app)\n * const state = renderAttaformState(app)\n * const payload = escapeForInlineScript(JSON.stringify(state))\n *\n * return `\n * ${html}\n * <script>window.__ATTAFORM_STATE__ = ${payload}</script>\n * `\n * ```\n *\n * Pair with `hydrateAttaformState` on the client to restore the\n * forms in their server-rendered state. Nuxt users don't need this —\n * `attaform/nuxt` wires SSR automatically.\n */\nexport function renderAttaformState(app: App): SerializedAttaformState {\n const registry = getRegistryFromApp(app)\n const forms: Array<readonly [FormKey, SerializedFormData]> = []\n for (const [key, state] of registry.forms) {\n // Skip the blank field when the set is empty so the\n // wire payload stays minimal for forms that don't use it. The\n // optional shape on the consuming side handles the absence\n // cleanly (defaults to \"no blank paths\"). PathKey → dotted at\n // the boundary so the wire shape matches the rest of the\n // public path notation.\n const transientList: string[] = []\n for (const pk of state.blankPaths) {\n const d = pathKeyToDotted(pk as PathKey)\n if (d !== null) transientList.push(d)\n }\n forms.push([\n key,\n {\n form: state.form.value,\n schemaErrors: Array.from(state.schemaErrors.entries()),\n userErrors: Array.from(state.userErrors.entries()),\n fields: Array.from(state.fields.entries()),\n ...(transientList.length > 0 ? { blankPaths: transientList } : {}),\n },\n ])\n }\n return { forms }\n}\n\n/**\n * Restore forms from a server-rendered snapshot on the client. Call\n * from your client entry before mounting:\n *\n * ```ts\n * import { createApp } from 'vue'\n * import { createAttaform, hydrateAttaformState } from 'attaform'\n *\n * const app = createApp(App).use(createAttaform())\n * hydrateAttaformState(app, window.__ATTAFORM_STATE__)\n * app.mount('#app')\n * ```\n *\n * The next `useForm({ key })` call for each serialised form picks up\n * the snapshot transparently — no further action is required.\n */\nexport function hydrateAttaformState(app: App, payload: SerializedAttaformState): void {\n const registry = getRegistryFromApp(app)\n for (const [key, data] of payload.forms) {\n registry.pendingHydration.set(key, data)\n }\n}\n","/**\n * Shared building blocks for Attaform's two devtools surfaces — the Vue\n * DevTools (Chrome-extension) inspector wired up in `./devtools.ts`, and\n * the Nuxt DevTools (overlay) panel wired up via `../../nuxt.ts` +\n * `../pages/_attaform_devtools.vue`.\n *\n * Houses the window-bridge contract both surfaces consume so a new\n * bridge field lands in one file. Both surfaces render RAW form values\n * by design — DevTools is a dev-only surface, and redaction across every\n * place a value surfaces is impractical security theater rather than a\n * real safeguard.\n */\nimport type { AttaformRegistry } from './registry'\n\n/**\n * Property key on `window` that the Nuxt-side dev plugin attaches the\n * bridge object to. The iframe-mounted overlay panel reads\n * `window.parent[DEVTOOLS_WINDOW_KEY]` to reach the host app's registry.\n *\n * Underscored + namespaced to make accidental collision with consumer\n * globals vanishingly unlikely. Stable across versions — bumping it\n * would silently disconnect older library builds from newer overlay\n * panels in the same browser tab during a library upgrade.\n */\nexport const DEVTOOLS_WINDOW_KEY = '__attaform_devtools__'\n\n/**\n * Shape of the object the host plugin attaches to `window` in dev mode.\n * The iframe overlay panel reads this to discover the live registry and\n * render its forms.\n *\n * Single-registry assumption: the latest `createAttaform()` install\n * wins. Multi-app pages (rare; typically only seen in micro-frontend\n * setups) will only see one app's forms in the panel. Documented but\n * not actively supported — the alternative (a Set of registries with\n * union-rendering) is a future call if a real consumer hits it.\n */\nexport interface AttaformDevtoolsBridge {\n registry: AttaformRegistry\n /**\n * The library version, surfaced in the panel's footer for support /\n * bug-report context. Read from `package.json` at host-plugin init.\n */\n version: string\n}\n\ndeclare global {\n interface Window {\n [DEVTOOLS_WINDOW_KEY]?: AttaformDevtoolsBridge\n }\n}\n"],"names":["getRegistryFromApp","pathKeyToDotted"],"mappings":";;;;AAuCO,SAAS,oBAAoB,GAAA,EAAmC;AACrE,EAAA,MAAM,QAAA,GAAWA,yBAAmB,GAAG,CAAA;AACvC,EAAA,MAAM,QAAuD,EAAC;AAC9D,EAAA,KAAA,MAAW,CAAC,GAAA,EAAK,KAAK,CAAA,IAAK,SAAS,KAAA,EAAO;AAOzC,IAAA,MAAM,gBAA0B,EAAC;AACjC,IAAA,KAAA,MAAW,EAAA,IAAM,MAAM,UAAA,EAAY;AACjC,MAAA,MAAM,CAAA,GAAIC,sBAAgB,EAAa,CAAA;AACvC,MAAA,IAAI,CAAA,KAAM,IAAA,EAAM,aAAA,CAAc,IAAA,CAAK,CAAC,CAAA;AAAA,IACtC;AACA,IAAA,KAAA,CAAM,IAAA,CAAK;AAAA,MACT,GAAA;AAAA,MACA;AAAA,QACE,IAAA,EAAM,MAAM,IAAA,CAAK,KAAA;AAAA,QACjB,cAAc,KAAA,CAAM,IAAA,CAAK,KAAA,CAAM,YAAA,CAAa,SAAS,CAAA;AAAA,QACrD,YAAY,KAAA,CAAM,IAAA,CAAK,KAAA,CAAM,UAAA,CAAW,SAAS,CAAA;AAAA,QACjD,QAAQ,KAAA,CAAM,IAAA,CAAK,KAAA,CAAM,MAAA,CAAO,SAAS,CAAA;AAAA,QACzC,GAAI,cAAc,MAAA,GAAS,CAAA,GAAI,EAAE,UAAA,EAAY,aAAA,KAAkB;AAAC;AAClE,KACD,CAAA;AAAA,EACH;AACA,EAAA,OAAO,EAAE,KAAA,EAAM;AACjB;AAkBO,SAAS,oBAAA,CAAqB,KAAU,OAAA,EAAwC;AACrF,EAAA,MAAM,QAAA,GAAWD,yBAAmB,GAAG,CAAA;AACvC,EAAA,KAAA,MAAW,CAAC,GAAA,EAAK,IAAI,CAAA,IAAK,QAAQ,KAAA,EAAO;AACvC,IAAA,QAAA,CAAS,gBAAA,CAAiB,GAAA,CAAI,GAAA,EAAK,IAAI,CAAA;AAAA,EACzC;AACF;;ACjEO,MAAM,mBAAA,GAAsB;;;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { G as GenericForm,
|
|
2
|
+
import { G as GenericForm, u as FlatPath, O as NestedType, F as FormKey, U as UseFormConfiguration, a as AbstractSchema, D as DefaultValuesInput, af as ValidateOnConfig, b as UseFormReturnType } from './attaform.DBhrKb2j.cjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* The shape `form.values.<key>` returns at runtime.
|
|
@@ -120,6 +120,38 @@ type StorageLeaf<L> = InputIsUnknown<L> extends true ? unknown : L extends {
|
|
|
120
120
|
};
|
|
121
121
|
} ? Out : never;
|
|
122
122
|
|
|
123
|
+
/**
|
|
124
|
+
* The Zod v4 schema roots `useForm` accepts. A fixed-shape
|
|
125
|
+
* `z.object({ … })` is the common case; `z.record(K, V)` admits a
|
|
126
|
+
* dictionary form (a homogeneous map with runtime-known keys);
|
|
127
|
+
* `z.discriminatedUnion(disc, [...])` admits a variant form (one of
|
|
128
|
+
* several object shapes, picked by a discriminator). Each projects to
|
|
129
|
+
* a `GenericForm`-shaped value the form engine drives: an object root
|
|
130
|
+
* descends into its fixed keys, a record root treats its entries as an
|
|
131
|
+
* open live-keyed container, a variant root lifts the active variant's
|
|
132
|
+
* keys into one addressable surface.
|
|
133
|
+
*
|
|
134
|
+
* Other roots (a bare `z.union`, a root `z.array`, primitives,
|
|
135
|
+
* `z.map` / `z.set`) are not form roots; wrap them under a key. The
|
|
136
|
+
* adapter's runtime construction rejects them with a legible error.
|
|
137
|
+
*
|
|
138
|
+
* `z.ZodObject` MUST keep its `z.ZodRawShape` argument, and the
|
|
139
|
+
* discriminated-union arm MUST stay fully applied. The unified entry's
|
|
140
|
+
* v4 overload constrains on `SupportedRootSchema & ZodV4Internals` to
|
|
141
|
+
* keep v3 schemas out (see `../unified/types-zod-major.ts`). In a
|
|
142
|
+
* single-major (v3-only) consumer install, the published `.d.mts`
|
|
143
|
+
* resolves this `z` to v3, where a bare or under-applied Zod class is
|
|
144
|
+
* missing its required arguments and degrades to an `any`-like error
|
|
145
|
+
* type; `any` then absorbs the union and `any & ZodV4Internals`
|
|
146
|
+
* collapses back to `any`, so the marker stops excluding v3 schemas and
|
|
147
|
+
* the read slot poisons to `never`. `z.ZodRecord` carries defaults for
|
|
148
|
+
* both arguments, so it stays concrete in either major.
|
|
149
|
+
* `z.ZodDiscriminatedUnion` does NOT (v3 requires both arguments, and
|
|
150
|
+
* its parameter order is the reverse of v4's), so the arm is written
|
|
151
|
+
* fully applied; the v3-only bundled-types fixture guards it.
|
|
152
|
+
*/
|
|
153
|
+
type SupportedRootSchema = z.ZodObject<z.ZodRawShape> | z.ZodRecord | z.ZodDiscriminatedUnion<readonly z.ZodObject<z.ZodRawShape>[], string>;
|
|
154
|
+
|
|
123
155
|
/**
|
|
124
156
|
* Zod v4 adapter entry point. Re-exports the adapter + the useForm
|
|
125
157
|
* wrapper that threads zod-v4-specific schema types through
|
|
@@ -188,12 +220,12 @@ type PathOutput<Schema extends z.ZodType, Path extends string> = z.output<Schema
|
|
|
188
220
|
* generics ride on the alias rather than re-evaluating the
|
|
189
221
|
* conditional from scratch.
|
|
190
222
|
*/
|
|
191
|
-
type FormOf<Schema extends
|
|
192
|
-
type OutOf<Schema extends
|
|
193
|
-
type ReadOf<Schema extends
|
|
194
|
-
declare function useForm<Schema extends
|
|
223
|
+
type FormOf<Schema extends SupportedRootSchema> = z.input<Schema> extends GenericForm ? z.input<Schema> : never;
|
|
224
|
+
type OutOf<Schema extends SupportedRootSchema> = z.output<Schema> extends GenericForm ? z.output<Schema> : never;
|
|
225
|
+
type ReadOf<Schema extends SupportedRootSchema> = StorageShape<Schema> extends GenericForm ? StorageShape<Schema> : never;
|
|
226
|
+
declare function useForm<Schema extends SupportedRootSchema, K extends FormKey = FormKey>(configuration: Omit<UseFormConfiguration<FormOf<Schema>, OutOf<Schema>, AbstractSchema<FormOf<Schema>, OutOf<Schema>>, DefaultValuesInput<FormOf<Schema>>, K>, 'schema' | 'validateOn' | 'debounceMs'> & {
|
|
195
227
|
schema: Schema;
|
|
196
228
|
} & ValidateOnConfig): UseFormReturnType<FormOf<Schema>, OutOf<Schema>, ReadOf<Schema>, K>;
|
|
197
229
|
|
|
198
230
|
export { useForm as u };
|
|
199
|
-
export type { PathInput as P,
|
|
231
|
+
export type { PathInput as P, SupportedRootSchema as S, PathOutput as a, StorageShape as b };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { F as FormKey,
|
|
1
|
+
import { F as FormKey, W as PathKey, m as DisplayCtx, d as GetDisplayState, n as DisplayMachine, V as Path, aa as SlimPrimitiveKind, C as CoercionEntry, g as CoercionRegistry, G as GenericForm, ag as ValidationError, a as AbstractSchema, ak as WriteMeta, j as DeepPartial, al as WriteShape, as as TransformAbortHolder, ae as ValidateOn, A as AttaformDefaults, b as UseFormReturnType, c as RegisterValue } from './attaform.DBhrKb2j.cjs';
|
|
2
2
|
import { Ref, ComputedRef, App, InjectionKey } from 'vue';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -209,9 +209,11 @@ type WizardSubmitContext = {
|
|
|
209
209
|
type WizardOnSubmit = (ctx: WizardSubmitContext) => void | Promise<void>;
|
|
210
210
|
/**
|
|
211
211
|
* Optional `onError` callback registered via `wizard.handleSubmit`.
|
|
212
|
-
* Receives the aggregate error list
|
|
213
|
-
* validation
|
|
214
|
-
*
|
|
212
|
+
* Receives the aggregate error list. Entries originate from per-form
|
|
213
|
+
* validation, activation failures (`atta:activation-failed`), and a
|
|
214
|
+
* submit callback that left errors on a processed step (the
|
|
215
|
+
* `setErrors(...); return` server-rejection path). Sync or async; the
|
|
216
|
+
* returned promise gates `wizard.submitting`.
|
|
215
217
|
*/
|
|
216
218
|
type WizardOnError = (errors: readonly WizardAggregateError[]) => void | Promise<void>;
|
|
217
219
|
/**
|
|
@@ -402,25 +404,32 @@ type WizardForms<S> = FormsRecordOf<S> & Readonly<Record<FormKey, AnyForm>>;
|
|
|
402
404
|
* Forward-looking; reactive to current form
|
|
403
405
|
* validity. Gates "Finish button enable" style UI.
|
|
404
406
|
* - `done` — monotonic latch: flips `true` the first time a
|
|
405
|
-
* final-step `handleSubmit` resolves without
|
|
406
|
-
*
|
|
407
|
-
* edits or invalidations.
|
|
408
|
-
*
|
|
409
|
-
*
|
|
410
|
-
*
|
|
407
|
+
* final-step `handleSubmit` resolves without throwing
|
|
408
|
+
* AND leaves no errors set on any step, and stays
|
|
409
|
+
* `true` through subsequent edits or invalidations. A
|
|
410
|
+
* callback that calls `setErrors` and returns (the
|
|
411
|
+
* documented server-rejection path) is a failed submit,
|
|
412
|
+
* so it does not flip `done`. Only `reset()` flips it
|
|
413
|
+
* back. Gates "show success card" style UI that should
|
|
414
|
+
* reflect submission history rather than current
|
|
415
|
+
* validity.
|
|
411
416
|
* - `submitting` — `true` while a `wizard.handleSubmit` call is in
|
|
412
417
|
* flight. Global re-entrance guard: every
|
|
413
418
|
* navigation method also refuses while this is on.
|
|
414
419
|
* - `submissionAttempts` — count of `wizard.handleSubmit` invocations
|
|
415
420
|
* (success or failure). Always bumps, including on
|
|
416
421
|
* noop-form steps.
|
|
417
|
-
* - `submitError` — the error
|
|
422
|
+
* - `submitError` — the error THROWN by the most recent
|
|
418
423
|
* `wizard.handleSubmit` callback (or its `onError`),
|
|
419
424
|
* coerced to a real `Error`. Mirrors
|
|
420
|
-
* `form.meta.submitError`:
|
|
421
|
-
*
|
|
422
|
-
*
|
|
423
|
-
* `
|
|
425
|
+
* `form.meta.submitError`: this is the unexpected-throw
|
|
426
|
+
* channel, so an expected rejection handled via
|
|
427
|
+
* `setErrors` (no throw) surfaces through the error
|
|
428
|
+
* surface and `onError` instead, leaving this `null`.
|
|
429
|
+
* Cleared at submit entry and by `reset()`, parked here
|
|
430
|
+
* rather than re-thrown, so the handler resolves and
|
|
431
|
+
* never manufactures a `window` unhandledrejection.
|
|
432
|
+
* `null` on success.
|
|
424
433
|
* - `visited` — append-only breadcrumb of navigated step keys.
|
|
425
434
|
* `back()` does not pop; the trail is the audit
|
|
426
435
|
* log, not the back-stack.
|
|
@@ -643,12 +652,12 @@ type FormStore<F extends GenericForm, G extends GenericForm = F> = {
|
|
|
643
652
|
* Schema-driven errors. Written ONLY by the schema validation pipeline:
|
|
644
653
|
* `scheduleFieldValidation`, `handleSubmit`, the construction-time seed,
|
|
645
654
|
* history restore, and hydration. Cleared by `reset` / `resetField` and by
|
|
646
|
-
* a successful submit. `
|
|
655
|
+
* a successful submit. `setErrors` / `clearErrors` do NOT touch this Map.
|
|
647
656
|
*/
|
|
648
657
|
readonly schemaErrors: Map<PathKey, ValidationError[]>;
|
|
649
658
|
/**
|
|
650
|
-
* User-injected errors. Written ONLY by the `
|
|
651
|
-
* (and history / hydration replay). Survives schema revalidation and
|
|
659
|
+
* User-injected errors. Written ONLY by the `setErrors` / `clearErrors`
|
|
660
|
+
* API surface (and history / hydration replay). Survives schema revalidation and
|
|
652
661
|
* successful submits — the consumer owns its lifetime explicitly.
|
|
653
662
|
*/
|
|
654
663
|
readonly userErrors: Map<PathKey, ValidationError[]>;
|
|
@@ -1005,7 +1014,7 @@ type FormStore<F extends GenericForm, G extends GenericForm = F> = {
|
|
|
1005
1014
|
*/
|
|
1006
1015
|
applySchemaErrorsForSubtree(path: Path, errors: ValidationError[]): void;
|
|
1007
1016
|
setAllUserErrors(errors: readonly ValidationError[]): void;
|
|
1008
|
-
|
|
1017
|
+
setUserErrorsForPath(path: Path, errors: readonly ValidationError[]): void;
|
|
1009
1018
|
clearUserErrors(path?: Path): void;
|
|
1010
1019
|
/**
|
|
1011
1020
|
* Merged read — returns `[...schemaErrors[path], ...userErrors[path]]`.
|
|
@@ -1311,9 +1320,8 @@ type SerializedFormData = {
|
|
|
1311
1320
|
*/
|
|
1312
1321
|
readonly schemaErrors: ReadonlyArray<readonly [string, unknown]>;
|
|
1313
1322
|
/**
|
|
1314
|
-
* Errors set explicitly via `
|
|
1315
|
-
*
|
|
1316
|
-
* at snapshot time. Replayed at hydration; persists across
|
|
1323
|
+
* Errors set explicitly via `setErrors` (typically a server
|
|
1324
|
+
* response) at snapshot time. Replayed at hydration; persists across
|
|
1317
1325
|
* client-side re-validation.
|
|
1318
1326
|
*/
|
|
1319
1327
|
readonly userErrors: ReadonlyArray<readonly [string, unknown]>;
|
|
@@ -1741,9 +1749,9 @@ declare function lazy<Ctx = WizardCtx>(resolve: (ctx: Ctx) => AnyForm | string |
|
|
|
1741
1749
|
* `issue.code` (e.g. `zod:too_small`). No enum here because
|
|
1742
1750
|
* Zod's code list evolves.
|
|
1743
1751
|
* - consumer-defined — anything the consumer's backend / app stamps
|
|
1744
|
-
* onto a `ValidationError` (
|
|
1745
|
-
* or
|
|
1746
|
-
*
|
|
1752
|
+
* onto a `ValidationError` (a server response handed to `setErrors`,
|
|
1753
|
+
* or a code passed inline). Pick a scope (`api:`, `auth:`, etc.) and
|
|
1754
|
+
* stay consistent.
|
|
1747
1755
|
*
|
|
1748
1756
|
* Use these constants in tests and error-routing UI:
|
|
1749
1757
|
*
|
|
@@ -1787,6 +1795,14 @@ declare const AttaformErrorCode: {
|
|
|
1787
1795
|
* `form.hydrateError` for retry UX.
|
|
1788
1796
|
*/
|
|
1789
1797
|
readonly ActivationFailed: "atta:activation-failed";
|
|
1798
|
+
/**
|
|
1799
|
+
* Default code stamped on a manual error set through `form.setErrors`
|
|
1800
|
+
* when the caller omits an explicit `code`. The `setErrors` input is
|
|
1801
|
+
* lenient (`code` optional), so this is the fallback that keeps every
|
|
1802
|
+
* produced `ValidationError` carrying a stable, branchable identifier.
|
|
1803
|
+
* Override it per error by passing your own `code` (`api:…`, `auth:…`).
|
|
1804
|
+
*/
|
|
1805
|
+
readonly UserError: "atta:user-error";
|
|
1790
1806
|
};
|
|
1791
1807
|
type AttaformErrorCode = (typeof AttaformErrorCode)[keyof typeof AttaformErrorCode];
|
|
1792
1808
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { F as FormKey,
|
|
1
|
+
import { F as FormKey, W as PathKey, m as DisplayCtx, d as GetDisplayState, n as DisplayMachine, V as Path, aa as SlimPrimitiveKind, C as CoercionEntry, g as CoercionRegistry, G as GenericForm, ag as ValidationError, a as AbstractSchema, ak as WriteMeta, j as DeepPartial, al as WriteShape, as as TransformAbortHolder, ae as ValidateOn, A as AttaformDefaults, b as UseFormReturnType, c as RegisterValue } from './attaform.DBhrKb2j.js';
|
|
2
2
|
import { Ref, ComputedRef, App, InjectionKey } from 'vue';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -209,9 +209,11 @@ type WizardSubmitContext = {
|
|
|
209
209
|
type WizardOnSubmit = (ctx: WizardSubmitContext) => void | Promise<void>;
|
|
210
210
|
/**
|
|
211
211
|
* Optional `onError` callback registered via `wizard.handleSubmit`.
|
|
212
|
-
* Receives the aggregate error list
|
|
213
|
-
* validation
|
|
214
|
-
*
|
|
212
|
+
* Receives the aggregate error list. Entries originate from per-form
|
|
213
|
+
* validation, activation failures (`atta:activation-failed`), and a
|
|
214
|
+
* submit callback that left errors on a processed step (the
|
|
215
|
+
* `setErrors(...); return` server-rejection path). Sync or async; the
|
|
216
|
+
* returned promise gates `wizard.submitting`.
|
|
215
217
|
*/
|
|
216
218
|
type WizardOnError = (errors: readonly WizardAggregateError[]) => void | Promise<void>;
|
|
217
219
|
/**
|
|
@@ -402,25 +404,32 @@ type WizardForms<S> = FormsRecordOf<S> & Readonly<Record<FormKey, AnyForm>>;
|
|
|
402
404
|
* Forward-looking; reactive to current form
|
|
403
405
|
* validity. Gates "Finish button enable" style UI.
|
|
404
406
|
* - `done` — monotonic latch: flips `true` the first time a
|
|
405
|
-
* final-step `handleSubmit` resolves without
|
|
406
|
-
*
|
|
407
|
-
* edits or invalidations.
|
|
408
|
-
*
|
|
409
|
-
*
|
|
410
|
-
*
|
|
407
|
+
* final-step `handleSubmit` resolves without throwing
|
|
408
|
+
* AND leaves no errors set on any step, and stays
|
|
409
|
+
* `true` through subsequent edits or invalidations. A
|
|
410
|
+
* callback that calls `setErrors` and returns (the
|
|
411
|
+
* documented server-rejection path) is a failed submit,
|
|
412
|
+
* so it does not flip `done`. Only `reset()` flips it
|
|
413
|
+
* back. Gates "show success card" style UI that should
|
|
414
|
+
* reflect submission history rather than current
|
|
415
|
+
* validity.
|
|
411
416
|
* - `submitting` — `true` while a `wizard.handleSubmit` call is in
|
|
412
417
|
* flight. Global re-entrance guard: every
|
|
413
418
|
* navigation method also refuses while this is on.
|
|
414
419
|
* - `submissionAttempts` — count of `wizard.handleSubmit` invocations
|
|
415
420
|
* (success or failure). Always bumps, including on
|
|
416
421
|
* noop-form steps.
|
|
417
|
-
* - `submitError` — the error
|
|
422
|
+
* - `submitError` — the error THROWN by the most recent
|
|
418
423
|
* `wizard.handleSubmit` callback (or its `onError`),
|
|
419
424
|
* coerced to a real `Error`. Mirrors
|
|
420
|
-
* `form.meta.submitError`:
|
|
421
|
-
*
|
|
422
|
-
*
|
|
423
|
-
* `
|
|
425
|
+
* `form.meta.submitError`: this is the unexpected-throw
|
|
426
|
+
* channel, so an expected rejection handled via
|
|
427
|
+
* `setErrors` (no throw) surfaces through the error
|
|
428
|
+
* surface and `onError` instead, leaving this `null`.
|
|
429
|
+
* Cleared at submit entry and by `reset()`, parked here
|
|
430
|
+
* rather than re-thrown, so the handler resolves and
|
|
431
|
+
* never manufactures a `window` unhandledrejection.
|
|
432
|
+
* `null` on success.
|
|
424
433
|
* - `visited` — append-only breadcrumb of navigated step keys.
|
|
425
434
|
* `back()` does not pop; the trail is the audit
|
|
426
435
|
* log, not the back-stack.
|
|
@@ -643,12 +652,12 @@ type FormStore<F extends GenericForm, G extends GenericForm = F> = {
|
|
|
643
652
|
* Schema-driven errors. Written ONLY by the schema validation pipeline:
|
|
644
653
|
* `scheduleFieldValidation`, `handleSubmit`, the construction-time seed,
|
|
645
654
|
* history restore, and hydration. Cleared by `reset` / `resetField` and by
|
|
646
|
-
* a successful submit. `
|
|
655
|
+
* a successful submit. `setErrors` / `clearErrors` do NOT touch this Map.
|
|
647
656
|
*/
|
|
648
657
|
readonly schemaErrors: Map<PathKey, ValidationError[]>;
|
|
649
658
|
/**
|
|
650
|
-
* User-injected errors. Written ONLY by the `
|
|
651
|
-
* (and history / hydration replay). Survives schema revalidation and
|
|
659
|
+
* User-injected errors. Written ONLY by the `setErrors` / `clearErrors`
|
|
660
|
+
* API surface (and history / hydration replay). Survives schema revalidation and
|
|
652
661
|
* successful submits — the consumer owns its lifetime explicitly.
|
|
653
662
|
*/
|
|
654
663
|
readonly userErrors: Map<PathKey, ValidationError[]>;
|
|
@@ -1005,7 +1014,7 @@ type FormStore<F extends GenericForm, G extends GenericForm = F> = {
|
|
|
1005
1014
|
*/
|
|
1006
1015
|
applySchemaErrorsForSubtree(path: Path, errors: ValidationError[]): void;
|
|
1007
1016
|
setAllUserErrors(errors: readonly ValidationError[]): void;
|
|
1008
|
-
|
|
1017
|
+
setUserErrorsForPath(path: Path, errors: readonly ValidationError[]): void;
|
|
1009
1018
|
clearUserErrors(path?: Path): void;
|
|
1010
1019
|
/**
|
|
1011
1020
|
* Merged read — returns `[...schemaErrors[path], ...userErrors[path]]`.
|
|
@@ -1311,9 +1320,8 @@ type SerializedFormData = {
|
|
|
1311
1320
|
*/
|
|
1312
1321
|
readonly schemaErrors: ReadonlyArray<readonly [string, unknown]>;
|
|
1313
1322
|
/**
|
|
1314
|
-
* Errors set explicitly via `
|
|
1315
|
-
*
|
|
1316
|
-
* at snapshot time. Replayed at hydration; persists across
|
|
1323
|
+
* Errors set explicitly via `setErrors` (typically a server
|
|
1324
|
+
* response) at snapshot time. Replayed at hydration; persists across
|
|
1317
1325
|
* client-side re-validation.
|
|
1318
1326
|
*/
|
|
1319
1327
|
readonly userErrors: ReadonlyArray<readonly [string, unknown]>;
|
|
@@ -1741,9 +1749,9 @@ declare function lazy<Ctx = WizardCtx>(resolve: (ctx: Ctx) => AnyForm | string |
|
|
|
1741
1749
|
* `issue.code` (e.g. `zod:too_small`). No enum here because
|
|
1742
1750
|
* Zod's code list evolves.
|
|
1743
1751
|
* - consumer-defined — anything the consumer's backend / app stamps
|
|
1744
|
-
* onto a `ValidationError` (
|
|
1745
|
-
* or
|
|
1746
|
-
*
|
|
1752
|
+
* onto a `ValidationError` (a server response handed to `setErrors`,
|
|
1753
|
+
* or a code passed inline). Pick a scope (`api:`, `auth:`, etc.) and
|
|
1754
|
+
* stay consistent.
|
|
1747
1755
|
*
|
|
1748
1756
|
* Use these constants in tests and error-routing UI:
|
|
1749
1757
|
*
|
|
@@ -1787,6 +1795,14 @@ declare const AttaformErrorCode: {
|
|
|
1787
1795
|
* `form.hydrateError` for retry UX.
|
|
1788
1796
|
*/
|
|
1789
1797
|
readonly ActivationFailed: "atta:activation-failed";
|
|
1798
|
+
/**
|
|
1799
|
+
* Default code stamped on a manual error set through `form.setErrors`
|
|
1800
|
+
* when the caller omits an explicit `code`. The `setErrors` input is
|
|
1801
|
+
* lenient (`code` optional), so this is the fallback that keeps every
|
|
1802
|
+
* produced `ValidationError` carrying a stable, branchable identifier.
|
|
1803
|
+
* Override it per error by passing your own `code` (`api:…`, `auth:…`).
|
|
1804
|
+
*/
|
|
1805
|
+
readonly UserError: "atta:user-error";
|
|
1790
1806
|
};
|
|
1791
1807
|
type AttaformErrorCode = (typeof AttaformErrorCode)[keyof typeof AttaformErrorCode];
|
|
1792
1808
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { A as AttaformError, _ as __DEV__,
|
|
3
|
-
import { f as fieldMetaStore, g as getFieldMetaForSchema, a as getFieldMetaListForSchema, s as slimPrimitivesWalk, w as walkPathSegments, d as deriveDefaultWalk, m as mergeDeep, c as createAbstractSchema, b as getFieldMetaPathMap } from './attaform.
|
|
1
|
+
import { p as getAtPath, n as slimKindOf, q as setAtPath, o as humanize, h as useAbstractForm } from './attaform.NWrEGrNo.mjs';
|
|
2
|
+
import { A as AttaformError, _ as __DEV__, f as canonicalizePath, a as InvalidUseFormConfigError } from './attaform.C0au8oXd.mjs';
|
|
3
|
+
import { f as fieldMetaStore, g as getFieldMetaForSchema, a as getFieldMetaListForSchema, s as slimPrimitivesWalk, w as walkPathSegments, d as deriveDefaultWalk, m as mergeDeep, c as createAbstractSchema, b as getFieldMetaPathMap } from './attaform.C-tQKknW.mjs';
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
|
|
6
6
|
const fieldMeta = fieldMetaStore;
|
|
@@ -1272,4 +1272,4 @@ function useForm(configuration) {
|
|
|
1272
1272
|
}
|
|
1273
1273
|
|
|
1274
1274
|
export { UnsupportedSchemaError as U, assertZodVersion as a, getIntersectionRight as b, unwrapLazy as c, unwrapInner as d, unwrapPipe as e, fieldMeta as f, getIntersectionLeft as g, getDiscriminator as h, getDiscriminatedOptions as i, getUnionOptions as j, kindOf as k, getRecordKeyType as l, getRecordValueType as m, getTupleItems as n, getSetValueType as o, getArrayElement as p, getObjectShape as q, getEnumValues as r, getLiteralValues as s, getChecks as t, useForm as u, getCatchDefault as v, withMeta as w, getDefaultValue as x, zodV4Adapter as z };
|
|
1275
|
-
//# sourceMappingURL=attaform.
|
|
1275
|
+
//# sourceMappingURL=attaform.BunnTiTw.mjs.map
|