attaform 0.24.1 → 0.24.3
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 +27 -122
- 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 +3 -3
- package/dist/index.d.cts +4 -4
- package/dist/index.d.mts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.mjs +3 -3
- package/dist/nuxt.cjs +1 -1
- package/dist/nuxt.cjs.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/nuxt.mjs +1 -1
- package/dist/nuxt.mjs.map +1 -1
- package/dist/runtime/plugins/attaform.cjs +2 -2
- package/dist/runtime/plugins/attaform.mjs +2 -2
- package/dist/shared/{attaform.Bq6Copxn.d.cts → attaform.0zueP54D.d.mts} +10 -1
- package/dist/shared/{attaform.C-1W0T1n.cjs → attaform.BVjueUPu.cjs} +3 -3
- package/dist/shared/{attaform.C-1W0T1n.cjs.map → attaform.BVjueUPu.cjs.map} +1 -1
- package/dist/shared/{attaform.NWrEGrNo.mjs → attaform.B_F61Rx1.mjs} +37 -2
- package/dist/shared/attaform.B_F61Rx1.mjs.map +1 -0
- package/dist/shared/{attaform.Df4xXKbE.d.ts → attaform.BjiHiYAZ.d.ts} +3 -2
- package/dist/shared/{attaform.4zesozTg.d.mts → attaform.Bx6pgrIy.d.cts} +3 -2
- package/dist/shared/{attaform.FY5r1BpA.mjs → attaform.ByIB7i15.mjs} +4 -4
- package/dist/shared/{attaform.Cn6JoG9o.cjs.map → attaform.ByIB7i15.mjs.map} +1 -1
- package/dist/shared/{attaform.C0au8oXd.mjs → attaform.C5qkSN6t.mjs} +2 -2
- package/dist/shared/attaform.C5qkSN6t.mjs.map +1 -0
- package/dist/shared/{attaform.DRQjF16I.cjs → attaform.CB1kYKUB.cjs} +37 -2
- package/dist/shared/attaform.CB1kYKUB.cjs.map +1 -0
- package/dist/shared/{attaform.CrrIaHM8.cjs → attaform.CqlLImc1.cjs} +4 -4
- package/dist/shared/{attaform.BunnTiTw.mjs.map → attaform.CqlLImc1.cjs.map} +1 -1
- package/dist/shared/{attaform.C-tQKknW.mjs → attaform.D4ebpNbS.mjs} +3 -3
- package/dist/shared/{attaform.C-tQKknW.mjs.map → attaform.D4ebpNbS.mjs.map} +1 -1
- package/dist/shared/{attaform.BrFPMFgi.d.ts → attaform.DHjRN5JP.d.cts} +10 -1
- package/dist/shared/{attaform.DwLw3Kzv.cjs → attaform.DK6_Ctv7.cjs} +4 -4
- package/dist/shared/attaform.DK6_Ctv7.cjs.map +1 -0
- package/dist/shared/{attaform.B7UdTs_o.cjs → attaform.DQcdvxKZ.cjs} +2 -2
- package/dist/shared/attaform.DQcdvxKZ.cjs.map +1 -0
- package/dist/shared/{attaform.BOi6n2Pn.cjs → attaform.DRWrVSkH.cjs} +2 -2
- package/dist/shared/{attaform.BOi6n2Pn.cjs.map → attaform.DRWrVSkH.cjs.map} +1 -1
- package/dist/shared/{attaform.DBhrKb2j.d.ts → attaform.DUc6cetN.d.cts} +37 -1
- package/dist/shared/{attaform.DBhrKb2j.d.mts → attaform.DUc6cetN.d.mts} +37 -1
- package/dist/shared/{attaform.DBhrKb2j.d.cts → attaform.DUc6cetN.d.ts} +37 -1
- package/dist/shared/{attaform.BunnTiTw.mjs → attaform.Dbzwtn4g.mjs} +4 -4
- package/dist/shared/{attaform.CrrIaHM8.cjs.map → attaform.Dbzwtn4g.mjs.map} +1 -1
- package/dist/shared/{attaform.Cn6JoG9o.cjs → attaform.DfnwaGW2.cjs} +4 -4
- package/dist/shared/{attaform.FY5r1BpA.mjs.map → attaform.DfnwaGW2.cjs.map} +1 -1
- package/dist/shared/{attaform.0-00cYGw.mjs → attaform.DgbHNLf_.mjs} +2 -2
- package/dist/shared/{attaform.0-00cYGw.mjs.map → attaform.DgbHNLf_.mjs.map} +1 -1
- package/dist/shared/{attaform.Bk7vnQhG.d.cts → attaform.DvqdxvNU.d.mts} +3 -2
- package/dist/shared/{attaform.DhXl0Kdr.mjs → attaform.DwCtxauq.mjs} +4 -4
- package/dist/shared/attaform.DwCtxauq.mjs.map +1 -0
- package/dist/shared/{attaform.BwAcpoRw.d.mts → attaform.yqcYwt0d.d.ts} +10 -1
- package/dist/transforms.cjs +1 -1
- package/dist/transforms.d.cts +4 -1
- package/dist/transforms.d.mts +4 -1
- package/dist/transforms.d.ts +4 -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 +8 -5
- package/dist/zod-v3.d.mts +8 -5
- package/dist/zod-v3.d.ts +8 -5
- package/dist/zod-v3.mjs +2 -2
- package/dist/zod-v4.cjs +2 -2
- package/dist/zod-v4.d.cts +5 -5
- package/dist/zod-v4.d.mts +5 -5
- package/dist/zod-v4.d.ts +5 -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 +23 -7
- package/dist/zod.d.mts +23 -7
- package/dist/zod.d.ts +23 -7
- package/dist/zod.mjs +5 -5
- package/dist/zod.mjs.map +1 -1
- package/package.json +2 -2
- package/dist/shared/attaform.B7UdTs_o.cjs.map +0 -1
- package/dist/shared/attaform.C0au8oXd.mjs.map +0 -1
- package/dist/shared/attaform.DRQjF16I.cjs.map +0 -1
- package/dist/shared/attaform.DhXl0Kdr.mjs.map +0 -1
- package/dist/shared/attaform.DwLw3Kzv.cjs.map +0 -1
- package/dist/shared/attaform.NWrEGrNo.mjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attaform.
|
|
1
|
+
{"version":3,"file":"attaform.DRWrVSkH.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;;;;;;"}
|
|
@@ -644,6 +644,42 @@ type DefaultValuesInput<T> = T extends string ? string | Unset : T extends numbe
|
|
|
644
644
|
} | Unset : Array<DefaultValuesInput<U>> | Unset : T extends object ? {
|
|
645
645
|
[K in keyof T]?: DefaultValuesInput<T[K]>;
|
|
646
646
|
} | Unset : T;
|
|
647
|
+
/**
|
|
648
|
+
* The type accepted at a `useForm` overload's `defaultValues` slot.
|
|
649
|
+
*
|
|
650
|
+
* `Form` is the schema's input projection; `SchemaInput` is the schema's
|
|
651
|
+
* own input type (`z.input<Schema>`). A `defaultValues` value is one of:
|
|
652
|
+
* - `DefaultValuesInput<Form>` — the partial, `Unset`-widened in-progress
|
|
653
|
+
* shape. `defaultValues` deliberately accepts a form mid-completion: a
|
|
654
|
+
* leaf may be blank or hold a not-yet-valid value (a `z.email()` field
|
|
655
|
+
* accepts any `string`, not only valid emails). Sharp, fully-validated
|
|
656
|
+
* types are produced only at `handleSubmit`.
|
|
657
|
+
* - `SchemaInput` — the schema's full input shape.
|
|
658
|
+
* - a sync or async factory returning either of the above.
|
|
659
|
+
*
|
|
660
|
+
* `SchemaInput` is REDUNDANT at a concrete call site: a schema's input is
|
|
661
|
+
* always assignable to its own `DefaultValuesInput`, so this arm adds
|
|
662
|
+
* nothing a concrete caller could not already pass and does not weaken the
|
|
663
|
+
* per-field checking (`number` is still rejected where `string` is
|
|
664
|
+
* expected). It earns its place for the generic form-wrapper case (#422):
|
|
665
|
+
* when the schema is a free type parameter `S`, a forwarded `z.input<S>`
|
|
666
|
+
* is REFLEXIVELY assignable to the `SchemaInput` arm — a relation TS can
|
|
667
|
+
* decide even under a generic — whereas `DefaultValuesInput<Form>` alone
|
|
668
|
+
* stays a deferred conditional cascade that is not provably assignable,
|
|
669
|
+
* tripping TS2589 / TS2769. No runtime effect; the slot only governs what
|
|
670
|
+
* the type checker accepts.
|
|
671
|
+
*
|
|
672
|
+
* `DefaultValuesInput<Form>` is computed ONCE — passed as the `DVI` type
|
|
673
|
+
* argument to `AcceptableDefaultsOf` and referenced across the value and
|
|
674
|
+
* factory arms — rather than inlined in each arm, which would
|
|
675
|
+
* re-instantiate the (deep) cascade three times per overload and, across
|
|
676
|
+
* the unified entry's two overloads at a concrete call site, tip the
|
|
677
|
+
* bundled `.d.ts` into TS2589. The arms stay a DIRECT union (not a
|
|
678
|
+
* conditional over the cascade) so the `SchemaInput` arm remains
|
|
679
|
+
* reflexively matchable under a generic.
|
|
680
|
+
*/
|
|
681
|
+
type AcceptableDefaults<Form, SchemaInput> = AcceptableDefaultsOf<DefaultValuesInput<Form>, SchemaInput>;
|
|
682
|
+
type AcceptableDefaultsOf<DVI, SchemaInput> = DVI | SchemaInput | (() => DVI | SchemaInput) | (() => Promise<DVI | SchemaInput>);
|
|
647
683
|
|
|
648
684
|
/**
|
|
649
685
|
* Identifier for a form. A `FormKey` is the string passed via
|
|
@@ -4504,4 +4540,4 @@ type UseFormReturnType<Form extends GenericForm, GetValueFormType extends Generi
|
|
|
4504
4540
|
};
|
|
4505
4541
|
|
|
4506
4542
|
export { ROOT_PATH as Z, ROOT_PATH_KEY as _, canonicalizePath as am, isPathPrefix as an, isUnset as ao, parseDottedPath as ap, unset as aq };
|
|
4507
|
-
export type { ReactiveValidationStatus as $, AttaformDefaults as A, Json as B, CoercionEntry as C, DefaultValuesInput as D, ErrorInput as E, FormKey as F, GenericForm as G, HandleSubmit as H, IsTuple as I, JoinSegments as J, KeyofUnion as K, LiftedValueShape as L, MetaTrackerValue as M, NestedReadType as N, NestedType as O, OnError as P, OnInvalidSubmitPolicy as Q, RegisterModelDynamicCustomDirective as R, OnSubmit as S, PartialFlatPath as T, UseFormConfiguration as U, Path as V, PathKey as W, PendingValidationStatus as X, Primitive as Y, AbstractSchema as a, RegisterDirective as a0, RegisterFlatPath as a1, RegisterOptions as a2, RegisterSelectModifier as a3, RegisterTextModifier as a4, RegisterTransform as a5, Segment as a6, SetValueCallback as a7, SetValuePayload as a8, SettledValidationStatus as a9, SlimPrimitiveKind as aa, SlimRuntimeOf as ab, SubmitHandler as ac, Unset as ad, ValidateOn as ae, ValidateOnConfig as af, ValidationError as ag, ValidationResponse as ah, ValidationResponseWithoutValue as ai, ValueOfUnion as aj, WriteMeta as ak, WriteShape as al,
|
|
4543
|
+
export type { ReactiveValidationStatus as $, AttaformDefaults as A, Json as B, CoercionEntry as C, DefaultValuesInput as D, ErrorInput as E, FormKey as F, GenericForm as G, HandleSubmit as H, IsTuple as I, JoinSegments as J, KeyofUnion as K, LiftedValueShape as L, MetaTrackerValue as M, NestedReadType as N, NestedType as O, OnError as P, OnInvalidSubmitPolicy as Q, RegisterModelDynamicCustomDirective as R, OnSubmit as S, PartialFlatPath as T, UseFormConfiguration as U, Path as V, PathKey as W, PendingValidationStatus as X, Primitive as Y, AbstractSchema as a, RegisterDirective as a0, RegisterFlatPath as a1, RegisterOptions as a2, RegisterSelectModifier as a3, RegisterTextModifier as a4, RegisterTransform as a5, Segment as a6, SetValueCallback as a7, SetValuePayload as a8, SettledValidationStatus as a9, SlimPrimitiveKind as aa, SlimRuntimeOf as ab, SubmitHandler as ac, Unset as ad, ValidateOn as ae, ValidateOnConfig as af, ValidationError as ag, ValidationResponse as ah, ValidationResponseWithoutValue as ai, ValueOfUnion as aj, WriteMeta as ak, WriteShape as al, AcceptableDefaults as ar, SchemaFactoryOptions as as, TransformAbortHolder as at, UseFormReturnType as b, RegisterValue as c, GetDisplayState as d, ArrayItem as e, ArrayPath as f, CoercionRegistry as g, CoercionResult as h, CustomDirectiveRegisterAssignerFn as i, DeepPartial as j, DefaultValuesResponse as k, DefaultValuesShape as l, DisplayCtx as m, DisplayMachine as n, DisplayState as o, ErrorsProxyShape as p, FieldMetaPayload as q, FieldState as r, FieldStateMap as s, FieldStateMapEntry as t, FlatPath as u, FormErrorRecord as v, FormErrorsSurface as w, FormMeta as x, HistoryConfig as y, IsUnion as z };
|
|
@@ -644,6 +644,42 @@ type DefaultValuesInput<T> = T extends string ? string | Unset : T extends numbe
|
|
|
644
644
|
} | Unset : Array<DefaultValuesInput<U>> | Unset : T extends object ? {
|
|
645
645
|
[K in keyof T]?: DefaultValuesInput<T[K]>;
|
|
646
646
|
} | Unset : T;
|
|
647
|
+
/**
|
|
648
|
+
* The type accepted at a `useForm` overload's `defaultValues` slot.
|
|
649
|
+
*
|
|
650
|
+
* `Form` is the schema's input projection; `SchemaInput` is the schema's
|
|
651
|
+
* own input type (`z.input<Schema>`). A `defaultValues` value is one of:
|
|
652
|
+
* - `DefaultValuesInput<Form>` — the partial, `Unset`-widened in-progress
|
|
653
|
+
* shape. `defaultValues` deliberately accepts a form mid-completion: a
|
|
654
|
+
* leaf may be blank or hold a not-yet-valid value (a `z.email()` field
|
|
655
|
+
* accepts any `string`, not only valid emails). Sharp, fully-validated
|
|
656
|
+
* types are produced only at `handleSubmit`.
|
|
657
|
+
* - `SchemaInput` — the schema's full input shape.
|
|
658
|
+
* - a sync or async factory returning either of the above.
|
|
659
|
+
*
|
|
660
|
+
* `SchemaInput` is REDUNDANT at a concrete call site: a schema's input is
|
|
661
|
+
* always assignable to its own `DefaultValuesInput`, so this arm adds
|
|
662
|
+
* nothing a concrete caller could not already pass and does not weaken the
|
|
663
|
+
* per-field checking (`number` is still rejected where `string` is
|
|
664
|
+
* expected). It earns its place for the generic form-wrapper case (#422):
|
|
665
|
+
* when the schema is a free type parameter `S`, a forwarded `z.input<S>`
|
|
666
|
+
* is REFLEXIVELY assignable to the `SchemaInput` arm — a relation TS can
|
|
667
|
+
* decide even under a generic — whereas `DefaultValuesInput<Form>` alone
|
|
668
|
+
* stays a deferred conditional cascade that is not provably assignable,
|
|
669
|
+
* tripping TS2589 / TS2769. No runtime effect; the slot only governs what
|
|
670
|
+
* the type checker accepts.
|
|
671
|
+
*
|
|
672
|
+
* `DefaultValuesInput<Form>` is computed ONCE — passed as the `DVI` type
|
|
673
|
+
* argument to `AcceptableDefaultsOf` and referenced across the value and
|
|
674
|
+
* factory arms — rather than inlined in each arm, which would
|
|
675
|
+
* re-instantiate the (deep) cascade three times per overload and, across
|
|
676
|
+
* the unified entry's two overloads at a concrete call site, tip the
|
|
677
|
+
* bundled `.d.ts` into TS2589. The arms stay a DIRECT union (not a
|
|
678
|
+
* conditional over the cascade) so the `SchemaInput` arm remains
|
|
679
|
+
* reflexively matchable under a generic.
|
|
680
|
+
*/
|
|
681
|
+
type AcceptableDefaults<Form, SchemaInput> = AcceptableDefaultsOf<DefaultValuesInput<Form>, SchemaInput>;
|
|
682
|
+
type AcceptableDefaultsOf<DVI, SchemaInput> = DVI | SchemaInput | (() => DVI | SchemaInput) | (() => Promise<DVI | SchemaInput>);
|
|
647
683
|
|
|
648
684
|
/**
|
|
649
685
|
* Identifier for a form. A `FormKey` is the string passed via
|
|
@@ -4504,4 +4540,4 @@ type UseFormReturnType<Form extends GenericForm, GetValueFormType extends Generi
|
|
|
4504
4540
|
};
|
|
4505
4541
|
|
|
4506
4542
|
export { ROOT_PATH as Z, ROOT_PATH_KEY as _, canonicalizePath as am, isPathPrefix as an, isUnset as ao, parseDottedPath as ap, unset as aq };
|
|
4507
|
-
export type { ReactiveValidationStatus as $, AttaformDefaults as A, Json as B, CoercionEntry as C, DefaultValuesInput as D, ErrorInput as E, FormKey as F, GenericForm as G, HandleSubmit as H, IsTuple as I, JoinSegments as J, KeyofUnion as K, LiftedValueShape as L, MetaTrackerValue as M, NestedReadType as N, NestedType as O, OnError as P, OnInvalidSubmitPolicy as Q, RegisterModelDynamicCustomDirective as R, OnSubmit as S, PartialFlatPath as T, UseFormConfiguration as U, Path as V, PathKey as W, PendingValidationStatus as X, Primitive as Y, AbstractSchema as a, RegisterDirective as a0, RegisterFlatPath as a1, RegisterOptions as a2, RegisterSelectModifier as a3, RegisterTextModifier as a4, RegisterTransform as a5, Segment as a6, SetValueCallback as a7, SetValuePayload as a8, SettledValidationStatus as a9, SlimPrimitiveKind as aa, SlimRuntimeOf as ab, SubmitHandler as ac, Unset as ad, ValidateOn as ae, ValidateOnConfig as af, ValidationError as ag, ValidationResponse as ah, ValidationResponseWithoutValue as ai, ValueOfUnion as aj, WriteMeta as ak, WriteShape as al,
|
|
4543
|
+
export type { ReactiveValidationStatus as $, AttaformDefaults as A, Json as B, CoercionEntry as C, DefaultValuesInput as D, ErrorInput as E, FormKey as F, GenericForm as G, HandleSubmit as H, IsTuple as I, JoinSegments as J, KeyofUnion as K, LiftedValueShape as L, MetaTrackerValue as M, NestedReadType as N, NestedType as O, OnError as P, OnInvalidSubmitPolicy as Q, RegisterModelDynamicCustomDirective as R, OnSubmit as S, PartialFlatPath as T, UseFormConfiguration as U, Path as V, PathKey as W, PendingValidationStatus as X, Primitive as Y, AbstractSchema as a, RegisterDirective as a0, RegisterFlatPath as a1, RegisterOptions as a2, RegisterSelectModifier as a3, RegisterTextModifier as a4, RegisterTransform as a5, Segment as a6, SetValueCallback as a7, SetValuePayload as a8, SettledValidationStatus as a9, SlimPrimitiveKind as aa, SlimRuntimeOf as ab, SubmitHandler as ac, Unset as ad, ValidateOn as ae, ValidateOnConfig as af, ValidationError as ag, ValidationResponse as ah, ValidationResponseWithoutValue as ai, ValueOfUnion as aj, WriteMeta as ak, WriteShape as al, AcceptableDefaults as ar, SchemaFactoryOptions as as, TransformAbortHolder as at, UseFormReturnType as b, RegisterValue as c, GetDisplayState as d, ArrayItem as e, ArrayPath as f, CoercionRegistry as g, CoercionResult as h, CustomDirectiveRegisterAssignerFn as i, DeepPartial as j, DefaultValuesResponse as k, DefaultValuesShape as l, DisplayCtx as m, DisplayMachine as n, DisplayState as o, ErrorsProxyShape as p, FieldMetaPayload as q, FieldState as r, FieldStateMap as s, FieldStateMapEntry as t, FlatPath as u, FormErrorRecord as v, FormErrorsSurface as w, FormMeta as x, HistoryConfig as y, IsUnion as z };
|
|
@@ -644,6 +644,42 @@ type DefaultValuesInput<T> = T extends string ? string | Unset : T extends numbe
|
|
|
644
644
|
} | Unset : Array<DefaultValuesInput<U>> | Unset : T extends object ? {
|
|
645
645
|
[K in keyof T]?: DefaultValuesInput<T[K]>;
|
|
646
646
|
} | Unset : T;
|
|
647
|
+
/**
|
|
648
|
+
* The type accepted at a `useForm` overload's `defaultValues` slot.
|
|
649
|
+
*
|
|
650
|
+
* `Form` is the schema's input projection; `SchemaInput` is the schema's
|
|
651
|
+
* own input type (`z.input<Schema>`). A `defaultValues` value is one of:
|
|
652
|
+
* - `DefaultValuesInput<Form>` — the partial, `Unset`-widened in-progress
|
|
653
|
+
* shape. `defaultValues` deliberately accepts a form mid-completion: a
|
|
654
|
+
* leaf may be blank or hold a not-yet-valid value (a `z.email()` field
|
|
655
|
+
* accepts any `string`, not only valid emails). Sharp, fully-validated
|
|
656
|
+
* types are produced only at `handleSubmit`.
|
|
657
|
+
* - `SchemaInput` — the schema's full input shape.
|
|
658
|
+
* - a sync or async factory returning either of the above.
|
|
659
|
+
*
|
|
660
|
+
* `SchemaInput` is REDUNDANT at a concrete call site: a schema's input is
|
|
661
|
+
* always assignable to its own `DefaultValuesInput`, so this arm adds
|
|
662
|
+
* nothing a concrete caller could not already pass and does not weaken the
|
|
663
|
+
* per-field checking (`number` is still rejected where `string` is
|
|
664
|
+
* expected). It earns its place for the generic form-wrapper case (#422):
|
|
665
|
+
* when the schema is a free type parameter `S`, a forwarded `z.input<S>`
|
|
666
|
+
* is REFLEXIVELY assignable to the `SchemaInput` arm — a relation TS can
|
|
667
|
+
* decide even under a generic — whereas `DefaultValuesInput<Form>` alone
|
|
668
|
+
* stays a deferred conditional cascade that is not provably assignable,
|
|
669
|
+
* tripping TS2589 / TS2769. No runtime effect; the slot only governs what
|
|
670
|
+
* the type checker accepts.
|
|
671
|
+
*
|
|
672
|
+
* `DefaultValuesInput<Form>` is computed ONCE — passed as the `DVI` type
|
|
673
|
+
* argument to `AcceptableDefaultsOf` and referenced across the value and
|
|
674
|
+
* factory arms — rather than inlined in each arm, which would
|
|
675
|
+
* re-instantiate the (deep) cascade three times per overload and, across
|
|
676
|
+
* the unified entry's two overloads at a concrete call site, tip the
|
|
677
|
+
* bundled `.d.ts` into TS2589. The arms stay a DIRECT union (not a
|
|
678
|
+
* conditional over the cascade) so the `SchemaInput` arm remains
|
|
679
|
+
* reflexively matchable under a generic.
|
|
680
|
+
*/
|
|
681
|
+
type AcceptableDefaults<Form, SchemaInput> = AcceptableDefaultsOf<DefaultValuesInput<Form>, SchemaInput>;
|
|
682
|
+
type AcceptableDefaultsOf<DVI, SchemaInput> = DVI | SchemaInput | (() => DVI | SchemaInput) | (() => Promise<DVI | SchemaInput>);
|
|
647
683
|
|
|
648
684
|
/**
|
|
649
685
|
* Identifier for a form. A `FormKey` is the string passed via
|
|
@@ -4504,4 +4540,4 @@ type UseFormReturnType<Form extends GenericForm, GetValueFormType extends Generi
|
|
|
4504
4540
|
};
|
|
4505
4541
|
|
|
4506
4542
|
export { ROOT_PATH as Z, ROOT_PATH_KEY as _, canonicalizePath as am, isPathPrefix as an, isUnset as ao, parseDottedPath as ap, unset as aq };
|
|
4507
|
-
export type { ReactiveValidationStatus as $, AttaformDefaults as A, Json as B, CoercionEntry as C, DefaultValuesInput as D, ErrorInput as E, FormKey as F, GenericForm as G, HandleSubmit as H, IsTuple as I, JoinSegments as J, KeyofUnion as K, LiftedValueShape as L, MetaTrackerValue as M, NestedReadType as N, NestedType as O, OnError as P, OnInvalidSubmitPolicy as Q, RegisterModelDynamicCustomDirective as R, OnSubmit as S, PartialFlatPath as T, UseFormConfiguration as U, Path as V, PathKey as W, PendingValidationStatus as X, Primitive as Y, AbstractSchema as a, RegisterDirective as a0, RegisterFlatPath as a1, RegisterOptions as a2, RegisterSelectModifier as a3, RegisterTextModifier as a4, RegisterTransform as a5, Segment as a6, SetValueCallback as a7, SetValuePayload as a8, SettledValidationStatus as a9, SlimPrimitiveKind as aa, SlimRuntimeOf as ab, SubmitHandler as ac, Unset as ad, ValidateOn as ae, ValidateOnConfig as af, ValidationError as ag, ValidationResponse as ah, ValidationResponseWithoutValue as ai, ValueOfUnion as aj, WriteMeta as ak, WriteShape as al,
|
|
4543
|
+
export type { ReactiveValidationStatus as $, AttaformDefaults as A, Json as B, CoercionEntry as C, DefaultValuesInput as D, ErrorInput as E, FormKey as F, GenericForm as G, HandleSubmit as H, IsTuple as I, JoinSegments as J, KeyofUnion as K, LiftedValueShape as L, MetaTrackerValue as M, NestedReadType as N, NestedType as O, OnError as P, OnInvalidSubmitPolicy as Q, RegisterModelDynamicCustomDirective as R, OnSubmit as S, PartialFlatPath as T, UseFormConfiguration as U, Path as V, PathKey as W, PendingValidationStatus as X, Primitive as Y, AbstractSchema as a, RegisterDirective as a0, RegisterFlatPath as a1, RegisterOptions as a2, RegisterSelectModifier as a3, RegisterTextModifier as a4, RegisterTransform as a5, Segment as a6, SetValueCallback as a7, SetValuePayload as a8, SettledValidationStatus as a9, SlimPrimitiveKind as aa, SlimRuntimeOf as ab, SubmitHandler as ac, Unset as ad, ValidateOn as ae, ValidateOnConfig as af, ValidationError as ag, ValidationResponse as ah, ValidationResponseWithoutValue as ai, ValueOfUnion as aj, WriteMeta as ak, WriteShape as al, AcceptableDefaults as ar, SchemaFactoryOptions as as, TransformAbortHolder as at, UseFormReturnType as b, RegisterValue as c, GetDisplayState as d, ArrayItem as e, ArrayPath as f, CoercionRegistry as g, CoercionResult as h, CustomDirectiveRegisterAssignerFn as i, DeepPartial as j, DefaultValuesResponse as k, DefaultValuesShape as l, DisplayCtx as m, DisplayMachine as n, DisplayState as o, ErrorsProxyShape as p, FieldMetaPayload as q, FieldState as r, FieldStateMap as s, FieldStateMapEntry as t, FlatPath as u, FormErrorRecord as v, FormErrorsSurface as w, FormMeta as x, HistoryConfig as y, IsUnion as z };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { p as getAtPath, n as slimKindOf, q as setAtPath, o as humanize, h as useAbstractForm } from './attaform.
|
|
2
|
-
import { A as AttaformError, _ as __DEV__, f as canonicalizePath, a as InvalidUseFormConfigError } from './attaform.
|
|
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.B_F61Rx1.mjs';
|
|
2
|
+
import { A as AttaformError, _ as __DEV__, f as canonicalizePath, a as InvalidUseFormConfigError } from './attaform.C5qkSN6t.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.D4ebpNbS.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.Dbzwtn4g.mjs.map
|