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
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { isRef } from 'vue';
|
|
2
|
+
|
|
3
|
+
const V_REGISTER_MARKER = Symbol.for("attaform:v-register-directive");
|
|
4
|
+
const REGISTER_OWNER_MARKER = Symbol.for("attaform:register-owner-marker");
|
|
5
|
+
const SSR_COMPONENT_HOST_MODIFIER = "attaformComponentHost";
|
|
6
|
+
function isRegisterValue(val) {
|
|
7
|
+
if (typeof val !== "object" || val === null) return false;
|
|
8
|
+
if (!("innerRef" in val)) return false;
|
|
9
|
+
if (!isRef(val.innerRef)) return false;
|
|
10
|
+
if (!("registerElement" in val)) return false;
|
|
11
|
+
if (typeof val.registerElement !== "function") return false;
|
|
12
|
+
if (!("setValueWithInternalPath" in val)) return false;
|
|
13
|
+
if (typeof val.setValueWithInternalPath !== "function") return false;
|
|
14
|
+
return true;
|
|
15
|
+
}
|
|
16
|
+
function isTransforming(value) {
|
|
17
|
+
return isRegisterValue(value) && value.transforming;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export { REGISTER_OWNER_MARKER as R, SSR_COMPONENT_HOST_MODIFIER as S, V_REGISTER_MARKER as V, isTransforming as a, isRegisterValue as i };
|
|
21
|
+
//# sourceMappingURL=attaform.WvcckZMD.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attaform.WvcckZMD.mjs","sources":["../../src/runtime/core/register-protocol.ts"],"sourcesContent":["import { isRef } from 'vue'\nimport type { InternalRegisterValue, RegisterValue } from '../types/types-api'\n\n// Shared register-protocol primitives: the markers and value guards that\n// the v-register directive, its file / lifecycle satellites, and\n// useRegister all build on. They live in this leaf (depending only on vue\n// and the types module) so those modules don't import directive.ts back,\n// which would form an import cycle.\n\n/**\n * Marker installed on the v-register directive object so consumers\n * (notably `useRegister`) can identify it in a child vnode's\n * directive list even when the consumer's bundler hasn't installed\n * attaform's compile-time transforms. `Symbol.for(...)` round-trips\n * across duplicate bundle copies: `attaform` and `attaform/zod` can\n * land on different `vRegister` references in the playground or\n * under pnpm-hoist edge cases, but both carry the same marker.\n */\nexport const V_REGISTER_MARKER: unique symbol = Symbol.for('attaform:v-register-directive')\n\n/**\n * Marker on the rendered root DOM element. Set by `useRegister`'s\n * `onMounted` hook; read by the directive's deferred warn check to\n * skip the \"is a no-op\" warn for components that handle binding via\n * an inner v-register.\n *\n * `Symbol.for(...)` so the marker round-trips across duplicate copies\n * of attaform — see `assignKey` in core/directive.ts for the same\n * reasoning. `useRegister` and the directive are typically loaded\n * from the same module copy, but a consumer importing from\n * `attaform/zod` (Vite-optimized bundle) and the Nuxt\n * plugin's relative-path import (live ESM) can land on different\n * copies; a global symbol means the marker check still works.\n */\nexport const REGISTER_OWNER_MARKER: unique symbol = Symbol.for('attaform:register-owner-marker')\n\n/**\n * Directive modifier the `componentBridgeTransform` stamps onto a\n * `v-register` that lands on a component host (or kebab custom element).\n * It is the compile-time -> runtime signal the directive's `getSSRProps`\n * reads under compiled SSR, where Vue passes a `null` vnode and the host\n * is otherwise indistinguishable from a native control. autoAria then\n * suppresses its attrs on the host root (the inner control the component\n * re-binds via useRegister carries them). Namespaced to avoid collision\n * with any author-written modifier. (#404)\n */\nexport const SSR_COMPONENT_HOST_MODIFIER = 'attaformComponentHost'\n\n/**\n * Type guard for a `RegisterValue`. Returns `true` when `val` looks\n * like the object returned from `form.register(path)`.\n *\n * ```ts\n * if (isRegisterValue(slotValue)) {\n * // slotValue.innerRef is now a Ref<unknown>\n * }\n * ```\n *\n * Useful when building wrapper components that accept either a\n * `RegisterValue` or a plain ref via the same prop.\n */\nexport function isRegisterValue<Value = unknown>(val: unknown): val is RegisterValue<Value> {\n if (typeof val !== 'object' || val === null) return false\n if (!('innerRef' in val)) return false\n if (!isRef(val.innerRef)) return false\n if (!('registerElement' in val)) return false\n if (typeof val.registerElement !== 'function') return false\n if (!('setValueWithInternalPath' in val)) return false\n if (typeof val.setValueWithInternalPath !== 'function') return false\n return true\n}\n\n/**\n * `true` while a deferred async transform is in flight at this path.\n * `beginTransform` flips it synchronously inside the assigner, so a\n * listener's post-write force-sync block reads it (right after the\n * assigner returns) to skip snapping the DOM back to stale storage —\n * the resolved value is painted in by the orchestrator's `syncDom`\n * once the run lands.\n */\nexport function isTransforming(value: unknown): boolean {\n return isRegisterValue(value) && (value as InternalRegisterValue).transforming\n}\n"],"names":[],"mappings":";;AAkBO,MAAM,iBAAA,GAAmC,MAAA,CAAO,GAAA,CAAI,+BAA+B;AAgBnF,MAAM,qBAAA,GAAuC,MAAA,CAAO,GAAA,CAAI,gCAAgC;AAYxF,MAAM,2BAAA,GAA8B;AAepC,SAAS,gBAAiC,GAAA,EAA2C;AAC1F,EAAA,IAAI,OAAO,GAAA,KAAQ,QAAA,IAAY,GAAA,KAAQ,MAAM,OAAO,KAAA;AACpD,EAAA,IAAI,EAAE,UAAA,IAAc,GAAA,CAAA,EAAM,OAAO,KAAA;AACjC,EAAA,IAAI,CAAC,KAAA,CAAM,GAAA,CAAI,QAAQ,GAAG,OAAO,KAAA;AACjC,EAAA,IAAI,EAAE,iBAAA,IAAqB,GAAA,CAAA,EAAM,OAAO,KAAA;AACxC,EAAA,IAAI,OAAO,GAAA,CAAI,eAAA,KAAoB,UAAA,EAAY,OAAO,KAAA;AACtD,EAAA,IAAI,EAAE,0BAAA,IAA8B,GAAA,CAAA,EAAM,OAAO,KAAA;AACjD,EAAA,IAAI,OAAO,GAAA,CAAI,wBAAA,KAA6B,UAAA,EAAY,OAAO,KAAA;AAC/D,EAAA,OAAO,IAAA;AACT;AAUO,SAAS,eAAe,KAAA,EAAyB;AACtD,EAAA,OAAO,eAAA,CAAgB,KAAK,CAAA,IAAM,KAAA,CAAgC,YAAA;AACpE;;;;"}
|
package/dist/transforms.cjs
CHANGED
package/dist/transforms.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { c as componentBridgeTransform, i as inputTextAreaNodeTransform, v as vRegisterHintTransform, a as vRegisterPreambleTransform } from './shared/attaform.
|
|
1
|
+
export { c as componentBridgeTransform, i as inputTextAreaNodeTransform, v as vRegisterHintTransform, a as vRegisterPreambleTransform } from './shared/attaform.DhXl0Kdr.mjs';
|
|
2
2
|
//# sourceMappingURL=transforms.mjs.map
|
package/dist/vite.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const detectZodMajor = require('./shared/attaform.LEWUFqUw.cjs');
|
|
4
|
-
const vRegisterPreambleTransform = require('./shared/attaform.
|
|
4
|
+
const vRegisterPreambleTransform = require('./shared/attaform.DwLw3Kzv.cjs');
|
|
5
5
|
const compilerSfc = require('@vue/compiler-sfc');
|
|
6
6
|
const compilerCore = require('@vue/compiler-core');
|
|
7
7
|
|
package/dist/vite.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { r as resolveZodAliasTarget, Z as ZOD_UNIFIED_SPECIFIER } from './shared/attaform.sHkHv_98.mjs';
|
|
2
|
-
import { a as vRegisterPreambleTransform, c as componentBridgeTransform, i as inputTextAreaNodeTransform, v as vRegisterHintTransform } from './shared/attaform.
|
|
2
|
+
import { a as vRegisterPreambleTransform, c as componentBridgeTransform, i as inputTextAreaNodeTransform, v as vRegisterHintTransform } from './shared/attaform.DhXl0Kdr.mjs';
|
|
3
3
|
import { parse, babelParse } from '@vue/compiler-sfc';
|
|
4
4
|
import { NodeTypes } from '@vue/compiler-core';
|
|
5
5
|
|
package/dist/zod-v3.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const useForm = require('./shared/attaform.
|
|
4
|
-
const injectWizard = require('./shared/attaform.
|
|
3
|
+
const useForm = require('./shared/attaform.Cn6JoG9o.cjs');
|
|
4
|
+
const injectWizard = require('./shared/attaform.DRQjF16I.cjs');
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
package/dist/zod-v3.d.cts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { G as GenericForm, F as FormKey, U as UseFormConfiguration, a as AbstractSchema, D as DefaultValuesInput, b as UseFormReturnType,
|
|
3
|
-
export {
|
|
4
|
-
import { U as
|
|
5
|
-
export { b as AnyForm, c as AttaformErrorCode, C as CompiledStep, F as FormStatus, I as InjectWizardInput, L as LazyMarker, d as StepSlot, U as UseRegisterReturn, e as UseWizardReturnType, W as WizardAggregateError, f as WizardCtx, g as WizardCtxForm, h as WizardOnError, i as WizardOnSubmit, j as WizardOptions, k as WizardPersistFn, l as WizardRestoreFn, m as WizardRestoreState, n as WizardStatusesProxy, o as WizardSubmitContext, t as injectForm, u as injectWizard, w as lazy, x as useRegister, z as useWizard } from './shared/attaform.
|
|
2
|
+
import { G as GenericForm, F as FormKey, U as UseFormConfiguration, a as AbstractSchema, D as DefaultValuesInput, b as UseFormReturnType, af as ValidateOnConfig, ar as SchemaFactoryOptions, q as FieldMetaPayload } from './shared/attaform.DBhrKb2j.cjs';
|
|
3
|
+
export { ad as Unset, ao as isUnset, aq as unset } from './shared/attaform.DBhrKb2j.cjs';
|
|
4
|
+
import { S as SupportedRootSchema, U as UnwrapZodRoot, a as StorageShape } from './shared/attaform.DdjDqTah.cjs';
|
|
5
|
+
export { b as AnyForm, c as AttaformErrorCode, C as CompiledStep, F as FormStatus, I as InjectWizardInput, L as LazyMarker, d as StepSlot, U as UseRegisterReturn, e as UseWizardReturnType, W as WizardAggregateError, f as WizardCtx, g as WizardCtxForm, h as WizardOnError, i as WizardOnSubmit, j as WizardOptions, k as WizardPersistFn, l as WizardRestoreFn, m as WizardRestoreState, n as WizardStatusesProxy, o as WizardSubmitContext, t as injectForm, u as injectWizard, w as lazy, x as useRegister, z as useWizard } from './shared/attaform.Bq6Copxn.cjs';
|
|
6
6
|
import 'vue';
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -16,9 +16,9 @@ import 'vue';
|
|
|
16
16
|
* the v4 adapter's own `FormOf`/`OutOf`/`ReadOf` aliases verbatim so
|
|
17
17
|
* v3 and v4 carry the same per-call depth cost.
|
|
18
18
|
*/
|
|
19
|
-
type FormOf<Schema extends
|
|
20
|
-
type OutOf<Schema extends
|
|
21
|
-
type ReadOf<Schema extends
|
|
19
|
+
type FormOf<Schema extends SupportedRootSchema> = z.input<UnwrapZodRoot<Schema>> extends GenericForm ? z.input<UnwrapZodRoot<Schema>> : never;
|
|
20
|
+
type OutOf<Schema extends SupportedRootSchema> = z.output<UnwrapZodRoot<Schema>> extends GenericForm ? z.output<UnwrapZodRoot<Schema>> : never;
|
|
21
|
+
type ReadOf<Schema extends SupportedRootSchema> = StorageShape<UnwrapZodRoot<Schema>> extends GenericForm ? StorageShape<UnwrapZodRoot<Schema>> : never;
|
|
22
22
|
/**
|
|
23
23
|
* Create a form bound to a custom `AbstractSchema` adapter.
|
|
24
24
|
*
|
|
@@ -57,7 +57,7 @@ declare function useForm<Form extends GenericForm, GetValueFormType extends Gene
|
|
|
57
57
|
*
|
|
58
58
|
* For Zod v4, import from `attaform/zod` instead.
|
|
59
59
|
*/
|
|
60
|
-
declare function useForm<Schema extends
|
|
60
|
+
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'> & {
|
|
61
61
|
schema: Schema;
|
|
62
62
|
} & ValidateOnConfig): UseFormReturnType<FormOf<Schema>, OutOf<Schema>, ReadOf<Schema>, K>;
|
|
63
63
|
|
|
@@ -90,14 +90,15 @@ type TypeWithNullableDynamicKeys<Schema extends z.ZodSchema, CrossedBoundary ext
|
|
|
90
90
|
z.infer<Schema> | (CrossedBoundary extends true ? undefined : never);
|
|
91
91
|
|
|
92
92
|
/**
|
|
93
|
-
* Wrap a Zod v3 `ZodObject`
|
|
93
|
+
* Wrap a Zod v3 form-root schema (`ZodObject` or `ZodRecord`) in an
|
|
94
|
+
* `AbstractSchema` factory.
|
|
94
95
|
*
|
|
95
96
|
* Most consumers never call this directly — `useForm` from
|
|
96
97
|
* `attaform/zod-v3` does the wrapping automatically. Reach
|
|
97
98
|
* for it only when integrating with a custom code path that needs
|
|
98
99
|
* the adapter outside of `useForm`.
|
|
99
100
|
*
|
|
100
|
-
* Throws if the underlying schema isn't a
|
|
101
|
+
* Throws if the underlying schema isn't a supported form root.
|
|
101
102
|
*/
|
|
102
103
|
declare function zodAdapter<FormSchema extends z.ZodSchema, Form extends z.input<FormSchema>, GetValueFormType extends TypeWithNullableDynamicKeys<FormSchema>>(zodSchema: FormSchema): (formKey: FormKey, options: SchemaFactoryOptions) => AbstractSchema<Form, GetValueFormType>;
|
|
103
104
|
|
|
@@ -238,5 +239,5 @@ declare const fieldMeta: FieldMetaRegistryV3;
|
|
|
238
239
|
*/
|
|
239
240
|
declare function withMeta<S extends z.ZodTypeAny>(schema: S, payload: FieldMetaPayload): S;
|
|
240
241
|
|
|
241
|
-
export { FieldMetaPayload,
|
|
242
|
+
export { FieldMetaPayload, UnwrapZodRoot, fieldMeta, isZodSchemaType, useForm, withMeta, zodAdapter };
|
|
242
243
|
export type { TypeWithNullableDynamicKeys, ZodTypeWithInnerType };
|
package/dist/zod-v3.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { G as GenericForm, F as FormKey, U as UseFormConfiguration, a as AbstractSchema, D as DefaultValuesInput, b as UseFormReturnType,
|
|
3
|
-
export {
|
|
4
|
-
import { U as
|
|
5
|
-
export { b as AnyForm, c as AttaformErrorCode, C as CompiledStep, F as FormStatus, I as InjectWizardInput, L as LazyMarker, d as StepSlot, U as UseRegisterReturn, e as UseWizardReturnType, W as WizardAggregateError, f as WizardCtx, g as WizardCtxForm, h as WizardOnError, i as WizardOnSubmit, j as WizardOptions, k as WizardPersistFn, l as WizardRestoreFn, m as WizardRestoreState, n as WizardStatusesProxy, o as WizardSubmitContext, t as injectForm, u as injectWizard, w as lazy, x as useRegister, z as useWizard } from './shared/attaform.
|
|
2
|
+
import { G as GenericForm, F as FormKey, U as UseFormConfiguration, a as AbstractSchema, D as DefaultValuesInput, b as UseFormReturnType, af as ValidateOnConfig, ar as SchemaFactoryOptions, q as FieldMetaPayload } from './shared/attaform.DBhrKb2j.mjs';
|
|
3
|
+
export { ad as Unset, ao as isUnset, aq as unset } from './shared/attaform.DBhrKb2j.mjs';
|
|
4
|
+
import { S as SupportedRootSchema, U as UnwrapZodRoot, a as StorageShape } from './shared/attaform.DdjDqTah.mjs';
|
|
5
|
+
export { b as AnyForm, c as AttaformErrorCode, C as CompiledStep, F as FormStatus, I as InjectWizardInput, L as LazyMarker, d as StepSlot, U as UseRegisterReturn, e as UseWizardReturnType, W as WizardAggregateError, f as WizardCtx, g as WizardCtxForm, h as WizardOnError, i as WizardOnSubmit, j as WizardOptions, k as WizardPersistFn, l as WizardRestoreFn, m as WizardRestoreState, n as WizardStatusesProxy, o as WizardSubmitContext, t as injectForm, u as injectWizard, w as lazy, x as useRegister, z as useWizard } from './shared/attaform.BwAcpoRw.mjs';
|
|
6
6
|
import 'vue';
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -16,9 +16,9 @@ import 'vue';
|
|
|
16
16
|
* the v4 adapter's own `FormOf`/`OutOf`/`ReadOf` aliases verbatim so
|
|
17
17
|
* v3 and v4 carry the same per-call depth cost.
|
|
18
18
|
*/
|
|
19
|
-
type FormOf<Schema extends
|
|
20
|
-
type OutOf<Schema extends
|
|
21
|
-
type ReadOf<Schema extends
|
|
19
|
+
type FormOf<Schema extends SupportedRootSchema> = z.input<UnwrapZodRoot<Schema>> extends GenericForm ? z.input<UnwrapZodRoot<Schema>> : never;
|
|
20
|
+
type OutOf<Schema extends SupportedRootSchema> = z.output<UnwrapZodRoot<Schema>> extends GenericForm ? z.output<UnwrapZodRoot<Schema>> : never;
|
|
21
|
+
type ReadOf<Schema extends SupportedRootSchema> = StorageShape<UnwrapZodRoot<Schema>> extends GenericForm ? StorageShape<UnwrapZodRoot<Schema>> : never;
|
|
22
22
|
/**
|
|
23
23
|
* Create a form bound to a custom `AbstractSchema` adapter.
|
|
24
24
|
*
|
|
@@ -57,7 +57,7 @@ declare function useForm<Form extends GenericForm, GetValueFormType extends Gene
|
|
|
57
57
|
*
|
|
58
58
|
* For Zod v4, import from `attaform/zod` instead.
|
|
59
59
|
*/
|
|
60
|
-
declare function useForm<Schema extends
|
|
60
|
+
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'> & {
|
|
61
61
|
schema: Schema;
|
|
62
62
|
} & ValidateOnConfig): UseFormReturnType<FormOf<Schema>, OutOf<Schema>, ReadOf<Schema>, K>;
|
|
63
63
|
|
|
@@ -90,14 +90,15 @@ type TypeWithNullableDynamicKeys<Schema extends z.ZodSchema, CrossedBoundary ext
|
|
|
90
90
|
z.infer<Schema> | (CrossedBoundary extends true ? undefined : never);
|
|
91
91
|
|
|
92
92
|
/**
|
|
93
|
-
* Wrap a Zod v3 `ZodObject`
|
|
93
|
+
* Wrap a Zod v3 form-root schema (`ZodObject` or `ZodRecord`) in an
|
|
94
|
+
* `AbstractSchema` factory.
|
|
94
95
|
*
|
|
95
96
|
* Most consumers never call this directly — `useForm` from
|
|
96
97
|
* `attaform/zod-v3` does the wrapping automatically. Reach
|
|
97
98
|
* for it only when integrating with a custom code path that needs
|
|
98
99
|
* the adapter outside of `useForm`.
|
|
99
100
|
*
|
|
100
|
-
* Throws if the underlying schema isn't a
|
|
101
|
+
* Throws if the underlying schema isn't a supported form root.
|
|
101
102
|
*/
|
|
102
103
|
declare function zodAdapter<FormSchema extends z.ZodSchema, Form extends z.input<FormSchema>, GetValueFormType extends TypeWithNullableDynamicKeys<FormSchema>>(zodSchema: FormSchema): (formKey: FormKey, options: SchemaFactoryOptions) => AbstractSchema<Form, GetValueFormType>;
|
|
103
104
|
|
|
@@ -238,5 +239,5 @@ declare const fieldMeta: FieldMetaRegistryV3;
|
|
|
238
239
|
*/
|
|
239
240
|
declare function withMeta<S extends z.ZodTypeAny>(schema: S, payload: FieldMetaPayload): S;
|
|
240
241
|
|
|
241
|
-
export { FieldMetaPayload,
|
|
242
|
+
export { FieldMetaPayload, UnwrapZodRoot, fieldMeta, isZodSchemaType, useForm, withMeta, zodAdapter };
|
|
242
243
|
export type { TypeWithNullableDynamicKeys, ZodTypeWithInnerType };
|
package/dist/zod-v3.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { G as GenericForm, F as FormKey, U as UseFormConfiguration, a as AbstractSchema, D as DefaultValuesInput, b as UseFormReturnType,
|
|
3
|
-
export {
|
|
4
|
-
import { U as
|
|
5
|
-
export { b as AnyForm, c as AttaformErrorCode, C as CompiledStep, F as FormStatus, I as InjectWizardInput, L as LazyMarker, d as StepSlot, U as UseRegisterReturn, e as UseWizardReturnType, W as WizardAggregateError, f as WizardCtx, g as WizardCtxForm, h as WizardOnError, i as WizardOnSubmit, j as WizardOptions, k as WizardPersistFn, l as WizardRestoreFn, m as WizardRestoreState, n as WizardStatusesProxy, o as WizardSubmitContext, t as injectForm, u as injectWizard, w as lazy, x as useRegister, z as useWizard } from './shared/attaform.
|
|
2
|
+
import { G as GenericForm, F as FormKey, U as UseFormConfiguration, a as AbstractSchema, D as DefaultValuesInput, b as UseFormReturnType, af as ValidateOnConfig, ar as SchemaFactoryOptions, q as FieldMetaPayload } from './shared/attaform.DBhrKb2j.js';
|
|
3
|
+
export { ad as Unset, ao as isUnset, aq as unset } from './shared/attaform.DBhrKb2j.js';
|
|
4
|
+
import { S as SupportedRootSchema, U as UnwrapZodRoot, a as StorageShape } from './shared/attaform.DdjDqTah.js';
|
|
5
|
+
export { b as AnyForm, c as AttaformErrorCode, C as CompiledStep, F as FormStatus, I as InjectWizardInput, L as LazyMarker, d as StepSlot, U as UseRegisterReturn, e as UseWizardReturnType, W as WizardAggregateError, f as WizardCtx, g as WizardCtxForm, h as WizardOnError, i as WizardOnSubmit, j as WizardOptions, k as WizardPersistFn, l as WizardRestoreFn, m as WizardRestoreState, n as WizardStatusesProxy, o as WizardSubmitContext, t as injectForm, u as injectWizard, w as lazy, x as useRegister, z as useWizard } from './shared/attaform.BrFPMFgi.js';
|
|
6
6
|
import 'vue';
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -16,9 +16,9 @@ import 'vue';
|
|
|
16
16
|
* the v4 adapter's own `FormOf`/`OutOf`/`ReadOf` aliases verbatim so
|
|
17
17
|
* v3 and v4 carry the same per-call depth cost.
|
|
18
18
|
*/
|
|
19
|
-
type FormOf<Schema extends
|
|
20
|
-
type OutOf<Schema extends
|
|
21
|
-
type ReadOf<Schema extends
|
|
19
|
+
type FormOf<Schema extends SupportedRootSchema> = z.input<UnwrapZodRoot<Schema>> extends GenericForm ? z.input<UnwrapZodRoot<Schema>> : never;
|
|
20
|
+
type OutOf<Schema extends SupportedRootSchema> = z.output<UnwrapZodRoot<Schema>> extends GenericForm ? z.output<UnwrapZodRoot<Schema>> : never;
|
|
21
|
+
type ReadOf<Schema extends SupportedRootSchema> = StorageShape<UnwrapZodRoot<Schema>> extends GenericForm ? StorageShape<UnwrapZodRoot<Schema>> : never;
|
|
22
22
|
/**
|
|
23
23
|
* Create a form bound to a custom `AbstractSchema` adapter.
|
|
24
24
|
*
|
|
@@ -57,7 +57,7 @@ declare function useForm<Form extends GenericForm, GetValueFormType extends Gene
|
|
|
57
57
|
*
|
|
58
58
|
* For Zod v4, import from `attaform/zod` instead.
|
|
59
59
|
*/
|
|
60
|
-
declare function useForm<Schema extends
|
|
60
|
+
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'> & {
|
|
61
61
|
schema: Schema;
|
|
62
62
|
} & ValidateOnConfig): UseFormReturnType<FormOf<Schema>, OutOf<Schema>, ReadOf<Schema>, K>;
|
|
63
63
|
|
|
@@ -90,14 +90,15 @@ type TypeWithNullableDynamicKeys<Schema extends z.ZodSchema, CrossedBoundary ext
|
|
|
90
90
|
z.infer<Schema> | (CrossedBoundary extends true ? undefined : never);
|
|
91
91
|
|
|
92
92
|
/**
|
|
93
|
-
* Wrap a Zod v3 `ZodObject`
|
|
93
|
+
* Wrap a Zod v3 form-root schema (`ZodObject` or `ZodRecord`) in an
|
|
94
|
+
* `AbstractSchema` factory.
|
|
94
95
|
*
|
|
95
96
|
* Most consumers never call this directly — `useForm` from
|
|
96
97
|
* `attaform/zod-v3` does the wrapping automatically. Reach
|
|
97
98
|
* for it only when integrating with a custom code path that needs
|
|
98
99
|
* the adapter outside of `useForm`.
|
|
99
100
|
*
|
|
100
|
-
* Throws if the underlying schema isn't a
|
|
101
|
+
* Throws if the underlying schema isn't a supported form root.
|
|
101
102
|
*/
|
|
102
103
|
declare function zodAdapter<FormSchema extends z.ZodSchema, Form extends z.input<FormSchema>, GetValueFormType extends TypeWithNullableDynamicKeys<FormSchema>>(zodSchema: FormSchema): (formKey: FormKey, options: SchemaFactoryOptions) => AbstractSchema<Form, GetValueFormType>;
|
|
103
104
|
|
|
@@ -238,5 +239,5 @@ declare const fieldMeta: FieldMetaRegistryV3;
|
|
|
238
239
|
*/
|
|
239
240
|
declare function withMeta<S extends z.ZodTypeAny>(schema: S, payload: FieldMetaPayload): S;
|
|
240
241
|
|
|
241
|
-
export { FieldMetaPayload,
|
|
242
|
+
export { FieldMetaPayload, UnwrapZodRoot, fieldMeta, isZodSchemaType, useForm, withMeta, zodAdapter };
|
|
242
243
|
export type { TypeWithNullableDynamicKeys, ZodTypeWithInnerType };
|
package/dist/zod-v3.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { f as fieldMeta, i as isZodSchemaType, u as useForm, w as withMeta, z as zodAdapter } from './shared/attaform.
|
|
2
|
-
export { A as AttaformErrorCode, i as injectForm, a as injectWizard, b as isUnset, l as lazy, u as unset, c as useRegister, d as useWizard } from './shared/attaform.
|
|
1
|
+
export { f as fieldMeta, i as isZodSchemaType, u as useForm, w as withMeta, z as zodAdapter } from './shared/attaform.FY5r1BpA.mjs';
|
|
2
|
+
export { A as AttaformErrorCode, i as injectForm, a as injectWizard, b as isUnset, l as lazy, u as unset, c as useRegister, d as useWizard } from './shared/attaform.NWrEGrNo.mjs';
|
|
3
3
|
//# sourceMappingURL=zod-v3.mjs.map
|
package/dist/zod-v4.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const index = require('./shared/attaform.
|
|
4
|
-
const injectWizard = require('./shared/attaform.
|
|
3
|
+
const index = require('./shared/attaform.CrrIaHM8.cjs');
|
|
4
|
+
const injectWizard = require('./shared/attaform.DRQjF16I.cjs');
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
package/dist/zod-v4.d.cts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
export {
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { S as SupportedRootSchema } from './shared/attaform.Bk7vnQhG.cjs';
|
|
2
|
+
export { P as PathInput, a as PathOutput, u as useForm } from './shared/attaform.Bk7vnQhG.cjs';
|
|
3
|
+
export { b as AnyForm, c as AttaformErrorCode, C as CompiledStep, F as FormStatus, I as InjectWizardInput, L as LazyMarker, d as StepSlot, U as UseRegisterReturn, e as UseWizardReturnType, W as WizardAggregateError, f as WizardCtx, g as WizardCtxForm, h as WizardOnError, i as WizardOnSubmit, j as WizardOptions, k as WizardPersistFn, l as WizardRestoreFn, m as WizardRestoreState, n as WizardStatusesProxy, o as WizardSubmitContext, t as injectForm, u as injectWizard, w as lazy, x as useRegister, z as useWizard } from './shared/attaform.Bq6Copxn.cjs';
|
|
4
|
+
import { F as FormKey, ar as SchemaFactoryOptions, a as AbstractSchema, q as FieldMetaPayload } from './shared/attaform.DBhrKb2j.cjs';
|
|
5
|
+
export { ad as Unset, ao as isUnset, aq as unset } from './shared/attaform.DBhrKb2j.cjs';
|
|
5
6
|
import { z } from 'zod';
|
|
6
7
|
import { A as AttaformError } from './shared/attaform.CO0e7YVY.cjs';
|
|
7
8
|
import 'vue';
|
|
@@ -25,7 +26,7 @@ import 'vue';
|
|
|
25
26
|
* Recursive `z.lazy(...)` is supported — the runtime walks bound their
|
|
26
27
|
* descent via `maxRecursionDepth`.
|
|
27
28
|
*/
|
|
28
|
-
declare function zodV4Adapter<FormSchema extends
|
|
29
|
+
declare function zodV4Adapter<FormSchema extends SupportedRootSchema, Form extends z.input<FormSchema>, GetValueFormType extends z.output<FormSchema> = z.output<FormSchema>>(rootSchema: FormSchema): (formKey: FormKey, options: SchemaFactoryOptions) => AbstractSchema<Form, GetValueFormType>;
|
|
29
30
|
|
|
30
31
|
/**
|
|
31
32
|
* Thrown when a Zod schema includes a kind the form library cannot
|
package/dist/zod-v4.d.mts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
export {
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { S as SupportedRootSchema } from './shared/attaform.4zesozTg.mjs';
|
|
2
|
+
export { P as PathInput, a as PathOutput, u as useForm } from './shared/attaform.4zesozTg.mjs';
|
|
3
|
+
export { b as AnyForm, c as AttaformErrorCode, C as CompiledStep, F as FormStatus, I as InjectWizardInput, L as LazyMarker, d as StepSlot, U as UseRegisterReturn, e as UseWizardReturnType, W as WizardAggregateError, f as WizardCtx, g as WizardCtxForm, h as WizardOnError, i as WizardOnSubmit, j as WizardOptions, k as WizardPersistFn, l as WizardRestoreFn, m as WizardRestoreState, n as WizardStatusesProxy, o as WizardSubmitContext, t as injectForm, u as injectWizard, w as lazy, x as useRegister, z as useWizard } from './shared/attaform.BwAcpoRw.mjs';
|
|
4
|
+
import { F as FormKey, ar as SchemaFactoryOptions, a as AbstractSchema, q as FieldMetaPayload } from './shared/attaform.DBhrKb2j.mjs';
|
|
5
|
+
export { ad as Unset, ao as isUnset, aq as unset } from './shared/attaform.DBhrKb2j.mjs';
|
|
5
6
|
import { z } from 'zod';
|
|
6
7
|
import { A as AttaformError } from './shared/attaform.CO0e7YVY.mjs';
|
|
7
8
|
import 'vue';
|
|
@@ -25,7 +26,7 @@ import 'vue';
|
|
|
25
26
|
* Recursive `z.lazy(...)` is supported — the runtime walks bound their
|
|
26
27
|
* descent via `maxRecursionDepth`.
|
|
27
28
|
*/
|
|
28
|
-
declare function zodV4Adapter<FormSchema extends
|
|
29
|
+
declare function zodV4Adapter<FormSchema extends SupportedRootSchema, Form extends z.input<FormSchema>, GetValueFormType extends z.output<FormSchema> = z.output<FormSchema>>(rootSchema: FormSchema): (formKey: FormKey, options: SchemaFactoryOptions) => AbstractSchema<Form, GetValueFormType>;
|
|
29
30
|
|
|
30
31
|
/**
|
|
31
32
|
* Thrown when a Zod schema includes a kind the form library cannot
|
package/dist/zod-v4.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
export {
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { S as SupportedRootSchema } from './shared/attaform.Df4xXKbE.js';
|
|
2
|
+
export { P as PathInput, a as PathOutput, u as useForm } from './shared/attaform.Df4xXKbE.js';
|
|
3
|
+
export { b as AnyForm, c as AttaformErrorCode, C as CompiledStep, F as FormStatus, I as InjectWizardInput, L as LazyMarker, d as StepSlot, U as UseRegisterReturn, e as UseWizardReturnType, W as WizardAggregateError, f as WizardCtx, g as WizardCtxForm, h as WizardOnError, i as WizardOnSubmit, j as WizardOptions, k as WizardPersistFn, l as WizardRestoreFn, m as WizardRestoreState, n as WizardStatusesProxy, o as WizardSubmitContext, t as injectForm, u as injectWizard, w as lazy, x as useRegister, z as useWizard } from './shared/attaform.BrFPMFgi.js';
|
|
4
|
+
import { F as FormKey, ar as SchemaFactoryOptions, a as AbstractSchema, q as FieldMetaPayload } from './shared/attaform.DBhrKb2j.js';
|
|
5
|
+
export { ad as Unset, ao as isUnset, aq as unset } from './shared/attaform.DBhrKb2j.js';
|
|
5
6
|
import { z } from 'zod';
|
|
6
7
|
import { A as AttaformError } from './shared/attaform.CO0e7YVY.js';
|
|
7
8
|
import 'vue';
|
|
@@ -25,7 +26,7 @@ import 'vue';
|
|
|
25
26
|
* Recursive `z.lazy(...)` is supported — the runtime walks bound their
|
|
26
27
|
* descent via `maxRecursionDepth`.
|
|
27
28
|
*/
|
|
28
|
-
declare function zodV4Adapter<FormSchema extends
|
|
29
|
+
declare function zodV4Adapter<FormSchema extends SupportedRootSchema, Form extends z.input<FormSchema>, GetValueFormType extends z.output<FormSchema> = z.output<FormSchema>>(rootSchema: FormSchema): (formKey: FormKey, options: SchemaFactoryOptions) => AbstractSchema<Form, GetValueFormType>;
|
|
29
30
|
|
|
30
31
|
/**
|
|
31
32
|
* Thrown when a Zod schema includes a kind the form library cannot
|
package/dist/zod-v4.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { U as UnsupportedSchemaError, a as assertZodVersion, f as fieldMeta, k as kindOf, u as useForm, w as withMeta, z as zodAdapter } from './shared/attaform.
|
|
2
|
-
export { A as AttaformErrorCode, i as injectForm, a as injectWizard, b as isUnset, l as lazy, u as unset, c as useRegister, d as useWizard } from './shared/attaform.
|
|
1
|
+
export { U as UnsupportedSchemaError, a as assertZodVersion, f as fieldMeta, k as kindOf, u as useForm, w as withMeta, z as zodAdapter } from './shared/attaform.BunnTiTw.mjs';
|
|
2
|
+
export { A as AttaformErrorCode, i as injectForm, a as injectWizard, b as isUnset, l as lazy, u as unset, c as useRegister, d as useWizard } from './shared/attaform.NWrEGrNo.mjs';
|
|
3
3
|
//# sourceMappingURL=zod-v4.mjs.map
|
package/dist/zod.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const paths = require('./shared/attaform.
|
|
4
|
-
const useForm$1 = require('./shared/attaform.
|
|
5
|
-
const index = require('./shared/attaform.
|
|
6
|
-
const walkFieldMeta = require('./shared/attaform.
|
|
7
|
-
const injectWizard = require('./shared/attaform.
|
|
3
|
+
const paths = require('./shared/attaform.B7UdTs_o.cjs');
|
|
4
|
+
const useForm$1 = require('./shared/attaform.Cn6JoG9o.cjs');
|
|
5
|
+
const index = require('./shared/attaform.CrrIaHM8.cjs');
|
|
6
|
+
const walkFieldMeta = require('./shared/attaform.C-1W0T1n.cjs');
|
|
7
|
+
const injectWizard = require('./shared/attaform.DRQjF16I.cjs');
|
|
8
8
|
|
|
9
9
|
function isZodV4SchemaShape(value) {
|
|
10
10
|
if (typeof value !== "object" || value === null) return false;
|
package/dist/zod.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zod.cjs","sources":["../src/runtime/core/zod-shape.ts","../src/runtime/adapters/unified/use-form.ts","../src/runtime/adapters/unified/field-meta.ts"],"sourcesContent":["/**\n * Shape detectors for Zod schemas. Used by the unified `attaform/zod`\n * entry's runtime dispatch (`runtime/adapters/unified/use-form.ts`)\n * to route to the v3 or v4 adapter based on the schema's runtime\n * shape. Mirrors the discrimination already used by the v4\n * introspection helper (`adapters/zod-v4/introspect.ts`'s\n * `assertZodVersion`, which reads `def.type`) and the v3 wrapper's\n * legitimate-input branch (`composables/use-form.ts`'s `isZodType`,\n * which reads `_def`).\n *\n * Why this discriminator and not `_zod` / `_def`:\n * - Zod v4 retained `_def` for backward compat — reading `_def` alone\n * misclassifies v4 schemas as v3.\n * - Zod v4's stable shape is `def.type: string` (lowercase tag like\n * `'object'`); Zod v3's is `_def.typeName: string` (capitalised tag\n * like `'ZodObject'`). Both are checked structurally so consumers\n * who alias one Zod major to a non-standard import path still work.\n */\n\ninterface ZodV4Shape {\n def: { type: unknown }\n}\n\ninterface ZodV3Shape {\n _def: { typeName: unknown }\n}\n\n/**\n * Returns true when `value` looks like a Zod schema of either major\n * version. Convenience wrapper around the v3 / v4 detectors.\n */\nexport function isZodSchemaShape(value: unknown): boolean {\n return isZodV4SchemaShape(value) || isZodV3SchemaShape(value)\n}\n\n/**\n * Returns true when `value` looks like a Zod v4 schema (has\n * `def.type: string`). Used by the unified entry's runtime-dispatch\n * to route to the v4 adapter.\n */\nexport function isZodV4SchemaShape(value: unknown): value is ZodV4Shape {\n if (typeof value !== 'object' || value === null) return false\n const def = (value as { def?: unknown }).def\n if (typeof def !== 'object' || def === null) return false\n return typeof (def as { type?: unknown }).type === 'string'\n}\n\n/**\n * Returns true when `value` looks like a Zod v3 schema (has\n * `_def.typeName: string`). Kept distinct from `isZodV4SchemaShape`\n * because some v4 schemas also expose `_def` for backward compat —\n * the v4 detector wins first in `isZodSchemaShape`.\n */\nexport function isZodV3SchemaShape(value: unknown): value is ZodV3Shape {\n if (typeof value !== 'object' || value === null) return false\n const def = (value as { _def?: unknown })._def\n if (typeof def !== 'object' || def === null) return false\n return typeof (def as { typeName?: unknown }).typeName === 'string'\n}\n","/**\n * Unified `useForm` for the `attaform/zod` entry. Runtime-dispatches\n * on schema shape: a Zod v4 schema (`def.type` truthy) routes to the\n * v4 adapter; a Zod v3 schema (or any other `AbstractSchema`) routes\n * to the v3 wrapper, which already accepts both Zod v3 input and\n * `AbstractSchema` directly via its built-in shape branch.\n *\n * Type-level dispatch happens via TWO typed overloads — v4 first, v3\n * second — plus an untyped impl. Each overload mirrors the matching\n * direct adapter's signature exactly, so a v4-schema call site pays\n * the same per-call depth cost as importing from `attaform/zod-v4`\n * directly. Overload resolution at concrete call sites commits to one\n * overload immediately on argument shape — no type-level dispatch tax.\n *\n * Tests and other call sites that need the equivalent of\n * `typeof useForm<X>` should reach for the `UseFormReturn<X>` /\n * `UseFormConfig<X>` helpers in `types-api.ts` — instantiation\n * expressions on overloaded functions follow brittle resolution rules,\n * and the helper types give a deterministic projection.\n *\n * This module is the FALLBACK path. Vite consumers see the\n * `attaform/vite` plugin's `resolveId` hook rewrite `attaform/zod`\n * imports to either `attaform/zod-v3` or `attaform/zod-v4` at build\n * time — in that case this dispatch never runs and the consumer\n * bundle ships only the matching adapter. Other bundlers (and\n * non-bundled ESM consumption) hit this dispatch instead, paying a\n * modest size cost for the convenience of a single hello-world import.\n *\n * Power users who want a guaranteed lean bundle on non-Vite tooling\n * can import directly from `attaform/zod-v3` or `attaform/zod-v4` —\n * those subpaths are never rewritten and never load the other\n * adapter.\n */\nimport type { z } from 'zod'\nimport type { z as zV3 } from 'zod-v3'\nimport { InvalidUseFormConfigError } from '../../core/errors'\nimport { isZodV4SchemaShape } from '../../core/zod-shape'\nimport type { ZodV4Internals } from './types-zod-major'\nimport { useForm as useFormV3 } from '../../composables/use-form'\nimport { useForm as useFormV4 } from '../zod-v4'\nimport type {\n AbstractSchema,\n FormKey,\n ValidateOnConfig,\n UseFormReturnType,\n UseFormConfiguration,\n} from '../../types/types-api'\nimport type { DefaultValuesInput } from '../../types/types-core'\nimport type { V3FormOf, V3OutOf, V3ReadOf, V4FormOf, V4OutOf, V4ReadOf } from './types-projections'\n\n/**\n * Create a form bound to a Zod v4 schema.\n *\n * ```ts\n * import { useForm } from 'attaform/zod'\n * import { z } from 'zod'\n *\n * const form = useForm({\n * schema: z.object({\n * username: z.string().min(2, 'At least 2 characters'),\n * password: z.string().min(8, 'At least 8 characters'),\n * }),\n * })\n * ```\n *\n * The constraint intersects `ZodV4Internals` (the v4-only `_zod`\n * brand) so a v3 schema can't bind this overload even when `z`\n * resolves to v3 in a single-major consumer install; v3 schemas fall\n * through to the v3 overload below. See `types-zod-major.ts`.\n */\nexport function useForm<\n Schema extends z.ZodObject<z.ZodRawShape> & ZodV4Internals,\n K extends FormKey = FormKey,\n>(\n configuration: Omit<\n UseFormConfiguration<\n V4FormOf<Schema>,\n V4OutOf<Schema>,\n AbstractSchema<V4FormOf<Schema>, V4OutOf<Schema>>,\n DefaultValuesInput<V4FormOf<Schema>>,\n K\n >,\n 'schema' | 'validateOn' | 'debounceMs'\n > & { schema: Schema } & ValidateOnConfig\n): UseFormReturnType<V4FormOf<Schema>, V4OutOf<Schema>, V4ReadOf<Schema>, K>\n/**\n * Create a form bound to a Zod v3 schema.\n *\n * ```ts\n * import { useForm } from 'attaform/zod'\n * import { z } from 'zod-v3'\n *\n * const form = useForm({\n * schema: z.object({\n * username: z.string().min(2, 'At least 2 characters'),\n * password: z.string().min(8, 'At least 8 characters'),\n * }),\n * })\n * ```\n *\n * v3 schemas match this overload; v4 schemas hit the v4 overload\n * above first and never reach here.\n */\nexport function useForm<Schema extends zV3.ZodObject<zV3.ZodRawShape>, K extends FormKey = FormKey>(\n configuration: Omit<\n UseFormConfiguration<\n V3FormOf<Schema>,\n V3OutOf<Schema>,\n AbstractSchema<V3FormOf<Schema>, V3OutOf<Schema>>,\n DefaultValuesInput<V3FormOf<Schema>>,\n K\n >,\n 'schema' | 'validateOn' | 'debounceMs'\n > & { schema: Schema } & ValidateOnConfig\n): UseFormReturnType<V3FormOf<Schema>, V3OutOf<Schema>, V3ReadOf<Schema>, K>\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function useForm(configuration: any): any {\n if (\n configuration === undefined ||\n configuration === null ||\n (configuration as { schema?: unknown }).schema === undefined\n ) {\n throw new InvalidUseFormConfigError()\n }\n const { schema } = configuration as { schema: unknown }\n if (isZodV4SchemaShape(schema)) {\n return useFormV4(configuration as Parameters<typeof useFormV4>[0])\n }\n return useFormV3(configuration as Parameters<typeof useFormV3>[0])\n}\n","/**\n * Field-metadata write/read API for the unified `attaform/zod` entry.\n *\n * Storage is shared with both adapters via `field-meta-store` — a\n * payload written here is visible to whichever adapter the unified\n * `useForm` dispatches to at runtime, regardless of Zod major. No\n * `zod` runtime import; the type-only `import type` is erased at\n * build, so `attaform/zod` carries no `z.registry` reference even\n * when consumed by a Zod 3 project without the Vite plugin alias.\n *\n * The native v4 chain `schema.register(fieldMeta, payload)` continues\n * to work — Zod 4's `.register()` only calls `.add(this, payload)`\n * structurally, satisfied by the shared store.\n */\nimport type { z } from 'zod'\nimport type { FieldMetaPayload } from '../../core/field-meta'\nimport { fieldMetaStore, getFieldMetaForSchema } from '../../core/field-meta-store'\n\n// Zod v4's `$ZodRegistry` class isn't surfaced under the `z` namespace\n// of the classic external entry, but `z.registry()` returns one — so\n// `ReturnType<typeof z.registry<T>>` resolves to the registry type\n// without needing a direct import. The `import type` keeps the\n// reference type-only; nothing about `z.registry` lands in the bundle.\ntype ZodFieldMetaRegistry = ReturnType<typeof z.registry<FieldMetaPayload>>\n\n/**\n * The shared registry every Attaform-aware Zod schema can register\n * field metadata against, regardless of major. Same instance the v3\n * and v4 adapter entries expose — write in one place, read from\n * any.\n *\n * Cast to Zod 4's `$ZodRegistry<FieldMetaPayload>` so the native\n * `schema.register(fieldMeta, payload)` chain type-checks for v4\n * users; the runtime call only needs `.add` structurally, which the\n * shared store provides.\n */\nexport const fieldMeta = fieldMetaStore as unknown as ZodFieldMetaRegistry\n\n/**\n * Attach `payload` to `schema` in the shared registry and return a\n * clone of `schema` so each call gets its own identity (the registry\n * keys on schema reference, so cloning prevents last-write-wins\n * collisions for sub-schemas reused at multiple paths).\n *\n * Works on both Zod 3 and Zod 4 schemas — branches on the runtime\n * shape of the schema:\n * - Zod 4 schemas expose a public `.clone()` method; we call it.\n * - Zod 3 schemas don't, so we reconstruct via\n * `new schema.constructor(schema._def)`.\n *\n * Both forms produce a fresh schema with the same effective\n * structure, so the registry slot is unique to this call site.\n */\nexport function withMeta<S>(schema: S, payload: FieldMetaPayload): S {\n const target = schema as object\n const existing = getFieldMetaForSchema(target) ?? {}\n const cloned = cloneSchema(schema)\n fieldMetaStore.add(cloned as object, { ...existing, ...payload })\n return cloned\n}\n\nfunction cloneSchema<S>(schema: S): S {\n const candidate = schema as { clone?: unknown; constructor: unknown; _def: unknown }\n if (typeof candidate.clone === 'function') {\n return (candidate.clone as () => S)()\n }\n // Zod 3 path: reconstruct via constructor + _def (no public\n // `.clone()` on v3).\n const Ctor = candidate.constructor as new (def: unknown) => S\n return new Ctor(candidate._def)\n}\n"],"names":["InvalidUseFormConfigError","useFormV4","useFormV3","fieldMetaStore","getFieldMetaForSchema"],"mappings":";;;;;;;;AAwCO,SAAS,mBAAmB,KAAA,EAAqC;AACtE,EAAA,IAAI,OAAO,KAAA,KAAU,QAAA,IAAY,KAAA,KAAU,MAAM,OAAO,KAAA;AACxD,EAAA,MAAM,MAAO,KAAA,CAA4B,GAAA;AACzC,EAAA,IAAI,OAAO,GAAA,KAAQ,QAAA,IAAY,GAAA,KAAQ,MAAM,OAAO,KAAA;AACpD,EAAA,OAAO,OAAQ,IAA2B,IAAA,KAAS,QAAA;AACrD;;ACuEO,SAAS,QAAQ,aAAA,EAAyB;AAC/C,EAAA,IACE,kBAAkB,MAAA,IAClB,aAAA,KAAkB,IAAA,IACjB,aAAA,CAAuC,WAAW,MAAA,EACnD;AACA,IAAA,MAAM,IAAIA,+BAAA,EAA0B;AAAA,EACtC;AACA,EAAA,MAAM,EAAE,QAAO,GAAI,aAAA;AACnB,EAAA,IAAI,kBAAA,CAAmB,MAAM,CAAA,EAAG;AAC9B,IAAA,OAAOC,cAAU,aAAgD,CAAA;AAAA,EACnE;AACA,EAAA,OAAOC,kBAAU,aAAgD,CAAA;AACnE;;AC7FO,MAAM,SAAA,GAAYC;AAiBlB,SAAS,QAAA,CAAY,QAAW,OAAA,EAA8B;AACnE,EAAA,MAAM,MAAA,GAAS,MAAA;AACf,EAAA,MAAM,QAAA,GAAWC,mCAAA,CAAsB,MAAM,CAAA,IAAK,EAAC;AACnD,EAAA,MAAM,MAAA,GAAS,YAAY,MAAM,CAAA;AACjC,EAAAD,4BAAA,CAAe,IAAI,MAAA,EAAkB,EAAE,GAAG,QAAA,EAAU,GAAG,SAAS,CAAA;AAChE,EAAA,OAAO,MAAA;AACT;AAEA,SAAS,YAAe,MAAA,EAAc;AACpC,EAAA,MAAM,SAAA,GAAY,MAAA;AAClB,EAAA,IAAI,OAAO,SAAA,CAAU,KAAA,KAAU,UAAA,EAAY;AACzC,IAAA,OAAQ,UAAU,KAAA,EAAkB;AAAA,EACtC;AAGA,EAAA,MAAM,OAAO,SAAA,CAAU,WAAA;AACvB,EAAA,OAAO,IAAI,IAAA,CAAK,SAAA,CAAU,IAAI,CAAA;AAChC;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"zod.cjs","sources":["../src/runtime/core/zod-shape.ts","../src/runtime/adapters/unified/use-form.ts","../src/runtime/adapters/unified/field-meta.ts"],"sourcesContent":["/**\n * Shape detectors for Zod schemas. Used by the unified `attaform/zod`\n * entry's runtime dispatch (`runtime/adapters/unified/use-form.ts`)\n * to route to the v3 or v4 adapter based on the schema's runtime\n * shape. Mirrors the discrimination already used by the v4\n * introspection helper (`adapters/zod-v4/introspect.ts`'s\n * `assertZodVersion`, which reads `def.type`) and the v3 wrapper's\n * legitimate-input branch (`composables/use-form.ts`'s `isZodType`,\n * which reads `_def`).\n *\n * Why this discriminator and not `_zod` / `_def`:\n * - Zod v4 retained `_def` for backward compat — reading `_def` alone\n * misclassifies v4 schemas as v3.\n * - Zod v4's stable shape is `def.type: string` (lowercase tag like\n * `'object'`); Zod v3's is `_def.typeName: string` (capitalised tag\n * like `'ZodObject'`). Both are checked structurally so consumers\n * who alias one Zod major to a non-standard import path still work.\n */\n\ninterface ZodV4Shape {\n def: { type: unknown }\n}\n\ninterface ZodV3Shape {\n _def: { typeName: unknown }\n}\n\n/**\n * Returns true when `value` looks like a Zod schema of either major\n * version. Convenience wrapper around the v3 / v4 detectors.\n */\nexport function isZodSchemaShape(value: unknown): boolean {\n return isZodV4SchemaShape(value) || isZodV3SchemaShape(value)\n}\n\n/**\n * Returns true when `value` looks like a Zod v4 schema (has\n * `def.type: string`). Used by the unified entry's runtime-dispatch\n * to route to the v4 adapter.\n */\nexport function isZodV4SchemaShape(value: unknown): value is ZodV4Shape {\n if (typeof value !== 'object' || value === null) return false\n const def = (value as { def?: unknown }).def\n if (typeof def !== 'object' || def === null) return false\n return typeof (def as { type?: unknown }).type === 'string'\n}\n\n/**\n * Returns true when `value` looks like a Zod v3 schema (has\n * `_def.typeName: string`). Kept distinct from `isZodV4SchemaShape`\n * because some v4 schemas also expose `_def` for backward compat —\n * the v4 detector wins first in `isZodSchemaShape`.\n */\nexport function isZodV3SchemaShape(value: unknown): value is ZodV3Shape {\n if (typeof value !== 'object' || value === null) return false\n const def = (value as { _def?: unknown })._def\n if (typeof def !== 'object' || def === null) return false\n return typeof (def as { typeName?: unknown }).typeName === 'string'\n}\n","/**\n * Unified `useForm` for the `attaform/zod` entry. Runtime-dispatches\n * on schema shape: a Zod v4 schema (`def.type` truthy) routes to the\n * v4 adapter; a Zod v3 schema (or any other `AbstractSchema`) routes\n * to the v3 wrapper, which already accepts both Zod v3 input and\n * `AbstractSchema` directly via its built-in shape branch.\n *\n * Type-level dispatch happens via TWO typed overloads — v4 first, v3\n * second — plus an untyped impl. Each overload mirrors the matching\n * direct adapter's signature exactly, so a v4-schema call site pays\n * the same per-call depth cost as importing from `attaform/zod-v4`\n * directly. Overload resolution at concrete call sites commits to one\n * overload immediately on argument shape — no type-level dispatch tax.\n *\n * Tests and other call sites that need the equivalent of\n * `typeof useForm<X>` should reach for the `UseFormReturn<X>` /\n * `UseFormConfig<X>` helpers in `types-api.ts` — instantiation\n * expressions on overloaded functions follow brittle resolution rules,\n * and the helper types give a deterministic projection.\n *\n * This module is the FALLBACK path. Vite consumers see the\n * `attaform/vite` plugin's `resolveId` hook rewrite `attaform/zod`\n * imports to either `attaform/zod-v3` or `attaform/zod-v4` at build\n * time — in that case this dispatch never runs and the consumer\n * bundle ships only the matching adapter. Other bundlers (and\n * non-bundled ESM consumption) hit this dispatch instead, paying a\n * modest size cost for the convenience of a single hello-world import.\n *\n * Power users who want a guaranteed lean bundle on non-Vite tooling\n * can import directly from `attaform/zod-v3` or `attaform/zod-v4` —\n * those subpaths are never rewritten and never load the other\n * adapter.\n */\nimport { InvalidUseFormConfigError } from '../../core/errors'\nimport { isZodV4SchemaShape } from '../../core/zod-shape'\nimport type { ZodV4Internals } from './types-zod-major'\nimport { useForm as useFormV3 } from '../../composables/use-form'\nimport { useForm as useFormV4 } from '../zod-v4'\nimport type {\n AbstractSchema,\n FormKey,\n ValidateOnConfig,\n UseFormReturnType,\n UseFormConfiguration,\n} from '../../types/types-api'\nimport type { DefaultValuesInput } from '../../types/types-core'\nimport type { SupportedRootSchema as SupportedRootSchemaV4 } from '../zod-v4/types-root'\nimport type { SupportedRootSchema as SupportedRootSchemaV3 } from '../zod-v3/types-root'\nimport type { V3FormOf, V3OutOf, V3ReadOf, V4FormOf, V4OutOf, V4ReadOf } from './types-projections'\n\n/**\n * Create a form bound to a Zod v4 schema.\n *\n * ```ts\n * import { useForm } from 'attaform/zod'\n * import { z } from 'zod'\n *\n * const form = useForm({\n * schema: z.object({\n * username: z.string().min(2, 'At least 2 characters'),\n * password: z.string().min(8, 'At least 8 characters'),\n * }),\n * })\n * ```\n *\n * The constraint intersects `ZodV4Internals` (the v4-only `_zod`\n * brand) so a v3 schema can't bind this overload even when `z`\n * resolves to v3 in a single-major consumer install; v3 schemas fall\n * through to the v3 overload below. See `types-zod-major.ts`.\n */\nexport function useForm<\n Schema extends SupportedRootSchemaV4 & ZodV4Internals,\n K extends FormKey = FormKey,\n>(\n configuration: Omit<\n UseFormConfiguration<\n V4FormOf<Schema>,\n V4OutOf<Schema>,\n AbstractSchema<V4FormOf<Schema>, V4OutOf<Schema>>,\n DefaultValuesInput<V4FormOf<Schema>>,\n K\n >,\n 'schema' | 'validateOn' | 'debounceMs'\n > & { schema: Schema } & ValidateOnConfig\n): UseFormReturnType<V4FormOf<Schema>, V4OutOf<Schema>, V4ReadOf<Schema>, K>\n/**\n * Create a form bound to a Zod v3 schema.\n *\n * ```ts\n * import { useForm } from 'attaform/zod'\n * import { z } from 'zod-v3'\n *\n * const form = useForm({\n * schema: z.object({\n * username: z.string().min(2, 'At least 2 characters'),\n * password: z.string().min(8, 'At least 8 characters'),\n * }),\n * })\n * ```\n *\n * v3 schemas match this overload; v4 schemas hit the v4 overload\n * above first and never reach here.\n */\nexport function useForm<Schema extends SupportedRootSchemaV3, K extends FormKey = FormKey>(\n configuration: Omit<\n UseFormConfiguration<\n V3FormOf<Schema>,\n V3OutOf<Schema>,\n AbstractSchema<V3FormOf<Schema>, V3OutOf<Schema>>,\n DefaultValuesInput<V3FormOf<Schema>>,\n K\n >,\n 'schema' | 'validateOn' | 'debounceMs'\n > & { schema: Schema } & ValidateOnConfig\n): UseFormReturnType<V3FormOf<Schema>, V3OutOf<Schema>, V3ReadOf<Schema>, K>\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function useForm(configuration: any): any {\n if (\n configuration === undefined ||\n configuration === null ||\n (configuration as { schema?: unknown }).schema === undefined\n ) {\n throw new InvalidUseFormConfigError()\n }\n const { schema } = configuration as { schema: unknown }\n if (isZodV4SchemaShape(schema)) {\n return useFormV4(configuration as Parameters<typeof useFormV4>[0])\n }\n return useFormV3(configuration as Parameters<typeof useFormV3>[0])\n}\n","/**\n * Field-metadata write/read API for the unified `attaform/zod` entry.\n *\n * Storage is shared with both adapters via `field-meta-store` — a\n * payload written here is visible to whichever adapter the unified\n * `useForm` dispatches to at runtime, regardless of Zod major. No\n * `zod` runtime import; the type-only `import type` is erased at\n * build, so `attaform/zod` carries no `z.registry` reference even\n * when consumed by a Zod 3 project without the Vite plugin alias.\n *\n * The native v4 chain `schema.register(fieldMeta, payload)` continues\n * to work — Zod 4's `.register()` only calls `.add(this, payload)`\n * structurally, satisfied by the shared store.\n */\nimport type { z } from 'zod'\nimport type { FieldMetaPayload } from '../../core/field-meta'\nimport { fieldMetaStore, getFieldMetaForSchema } from '../../core/field-meta-store'\n\n// Zod v4's `$ZodRegistry` class isn't surfaced under the `z` namespace\n// of the classic external entry, but `z.registry()` returns one — so\n// `ReturnType<typeof z.registry<T>>` resolves to the registry type\n// without needing a direct import. The `import type` keeps the\n// reference type-only; nothing about `z.registry` lands in the bundle.\ntype ZodFieldMetaRegistry = ReturnType<typeof z.registry<FieldMetaPayload>>\n\n/**\n * The shared registry every Attaform-aware Zod schema can register\n * field metadata against, regardless of major. Same instance the v3\n * and v4 adapter entries expose — write in one place, read from\n * any.\n *\n * Cast to Zod 4's `$ZodRegistry<FieldMetaPayload>` so the native\n * `schema.register(fieldMeta, payload)` chain type-checks for v4\n * users; the runtime call only needs `.add` structurally, which the\n * shared store provides.\n */\nexport const fieldMeta = fieldMetaStore as unknown as ZodFieldMetaRegistry\n\n/**\n * Attach `payload` to `schema` in the shared registry and return a\n * clone of `schema` so each call gets its own identity (the registry\n * keys on schema reference, so cloning prevents last-write-wins\n * collisions for sub-schemas reused at multiple paths).\n *\n * Works on both Zod 3 and Zod 4 schemas — branches on the runtime\n * shape of the schema:\n * - Zod 4 schemas expose a public `.clone()` method; we call it.\n * - Zod 3 schemas don't, so we reconstruct via\n * `new schema.constructor(schema._def)`.\n *\n * Both forms produce a fresh schema with the same effective\n * structure, so the registry slot is unique to this call site.\n */\nexport function withMeta<S>(schema: S, payload: FieldMetaPayload): S {\n const target = schema as object\n const existing = getFieldMetaForSchema(target) ?? {}\n const cloned = cloneSchema(schema)\n fieldMetaStore.add(cloned as object, { ...existing, ...payload })\n return cloned\n}\n\nfunction cloneSchema<S>(schema: S): S {\n const candidate = schema as { clone?: unknown; constructor: unknown; _def: unknown }\n if (typeof candidate.clone === 'function') {\n return (candidate.clone as () => S)()\n }\n // Zod 3 path: reconstruct via constructor + _def (no public\n // `.clone()` on v3).\n const Ctor = candidate.constructor as new (def: unknown) => S\n return new Ctor(candidate._def)\n}\n"],"names":["InvalidUseFormConfigError","useFormV4","useFormV3","fieldMetaStore","getFieldMetaForSchema"],"mappings":";;;;;;;;AAwCO,SAAS,mBAAmB,KAAA,EAAqC;AACtE,EAAA,IAAI,OAAO,KAAA,KAAU,QAAA,IAAY,KAAA,KAAU,MAAM,OAAO,KAAA;AACxD,EAAA,MAAM,MAAO,KAAA,CAA4B,GAAA;AACzC,EAAA,IAAI,OAAO,GAAA,KAAQ,QAAA,IAAY,GAAA,KAAQ,MAAM,OAAO,KAAA;AACpD,EAAA,OAAO,OAAQ,IAA2B,IAAA,KAAS,QAAA;AACrD;;ACuEO,SAAS,QAAQ,aAAA,EAAyB;AAC/C,EAAA,IACE,kBAAkB,MAAA,IAClB,aAAA,KAAkB,IAAA,IACjB,aAAA,CAAuC,WAAW,MAAA,EACnD;AACA,IAAA,MAAM,IAAIA,+BAAA,EAA0B;AAAA,EACtC;AACA,EAAA,MAAM,EAAE,QAAO,GAAI,aAAA;AACnB,EAAA,IAAI,kBAAA,CAAmB,MAAM,CAAA,EAAG;AAC9B,IAAA,OAAOC,cAAU,aAAgD,CAAA;AAAA,EACnE;AACA,EAAA,OAAOC,kBAAU,aAAgD,CAAA;AACnE;;AC7FO,MAAM,SAAA,GAAYC;AAiBlB,SAAS,QAAA,CAAY,QAAW,OAAA,EAA8B;AACnE,EAAA,MAAM,MAAA,GAAS,MAAA;AACf,EAAA,MAAM,QAAA,GAAWC,mCAAA,CAAsB,MAAM,CAAA,IAAK,EAAC;AACnD,EAAA,MAAM,MAAA,GAAS,YAAY,MAAM,CAAA;AACjC,EAAAD,4BAAA,CAAe,IAAI,MAAA,EAAkB,EAAE,GAAG,QAAA,EAAU,GAAG,SAAS,CAAA;AAChE,EAAA,OAAO,MAAA;AACT;AAEA,SAAS,YAAe,MAAA,EAAc;AACpC,EAAA,MAAM,SAAA,GAAY,MAAA;AAClB,EAAA,IAAI,OAAO,SAAA,CAAU,KAAA,KAAU,UAAA,EAAY;AACzC,IAAA,OAAQ,UAAU,KAAA,EAAkB;AAAA,EACtC;AAGA,EAAA,MAAM,OAAO,SAAA,CAAU,WAAA;AACvB,EAAA,OAAO,IAAI,IAAA,CAAK,SAAA,CAAU,IAAI,CAAA;AAChC;;;;;;;;;;;;;;"}
|
package/dist/zod.d.cts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import { G as GenericForm, F as FormKey, U as UseFormConfiguration, a as AbstractSchema, D as DefaultValuesInput, af as ValidateOnConfig, b as UseFormReturnType, q as FieldMetaPayload } from './shared/attaform.DBhrKb2j.cjs';
|
|
2
|
+
export { ad as Unset, ao as isUnset, aq as unset } from './shared/attaform.DBhrKb2j.cjs';
|
|
3
|
+
import { S as SupportedRootSchema, b as StorageShape } from './shared/attaform.Bk7vnQhG.cjs';
|
|
4
|
+
export { P as PathInput, a as PathOutput } from './shared/attaform.Bk7vnQhG.cjs';
|
|
5
|
+
import { S as SupportedRootSchema$1, U as UnwrapZodRoot, a as StorageShape$1 } from './shared/attaform.DdjDqTah.cjs';
|
|
1
6
|
import { z } from 'zod';
|
|
2
|
-
|
|
3
|
-
export { af as Unset, ap as isUnset, ar as unset } from './shared/attaform.BJnNK75Y.cjs';
|
|
4
|
-
import { S as StorageShape } from './shared/attaform.D52oJiYC.cjs';
|
|
5
|
-
export { P as PathInput, a as PathOutput } from './shared/attaform.D52oJiYC.cjs';
|
|
6
|
-
import { U as UnwrapZodObject, S as StorageShape$1 } from './shared/attaform.nf83TIR5.cjs';
|
|
7
|
-
export { b as AnyForm, c as AttaformErrorCode, C as CompiledStep, F as FormStatus, I as InjectWizardInput, L as LazyMarker, d as StepSlot, U as UseRegisterReturn, e as UseWizardReturnType, W as WizardAggregateError, f as WizardCtx, g as WizardCtxForm, h as WizardOnError, i as WizardOnSubmit, j as WizardOptions, k as WizardPersistFn, l as WizardRestoreFn, m as WizardRestoreState, n as WizardStatusesProxy, o as WizardSubmitContext, t as injectForm, u as injectWizard, w as lazy, x as useRegister, z as useWizard } from './shared/attaform.DuPneYR0.cjs';
|
|
7
|
+
export { b as AnyForm, c as AttaformErrorCode, C as CompiledStep, F as FormStatus, I as InjectWizardInput, L as LazyMarker, d as StepSlot, U as UseRegisterReturn, e as UseWizardReturnType, W as WizardAggregateError, f as WizardCtx, g as WizardCtxForm, h as WizardOnError, i as WizardOnSubmit, j as WizardOptions, k as WizardPersistFn, l as WizardRestoreFn, m as WizardRestoreState, n as WizardStatusesProxy, o as WizardSubmitContext, t as injectForm, u as injectWizard, w as lazy, x as useRegister, z as useWizard } from './shared/attaform.Bq6Copxn.cjs';
|
|
8
8
|
import 'vue';
|
|
9
9
|
|
|
10
10
|
/**
|
|
@@ -61,46 +61,12 @@ type ZodV4Internals = {
|
|
|
61
61
|
* call sites.
|
|
62
62
|
*/
|
|
63
63
|
|
|
64
|
-
type V4FormOf<S extends
|
|
65
|
-
type V4OutOf<S extends
|
|
66
|
-
type V4ReadOf<S extends
|
|
67
|
-
type V3FormOf<S extends
|
|
68
|
-
type V3OutOf<S extends
|
|
69
|
-
type V3ReadOf<S extends
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* Unified `useForm` for the `attaform/zod` entry. Runtime-dispatches
|
|
73
|
-
* on schema shape: a Zod v4 schema (`def.type` truthy) routes to the
|
|
74
|
-
* v4 adapter; a Zod v3 schema (or any other `AbstractSchema`) routes
|
|
75
|
-
* to the v3 wrapper, which already accepts both Zod v3 input and
|
|
76
|
-
* `AbstractSchema` directly via its built-in shape branch.
|
|
77
|
-
*
|
|
78
|
-
* Type-level dispatch happens via TWO typed overloads — v4 first, v3
|
|
79
|
-
* second — plus an untyped impl. Each overload mirrors the matching
|
|
80
|
-
* direct adapter's signature exactly, so a v4-schema call site pays
|
|
81
|
-
* the same per-call depth cost as importing from `attaform/zod-v4`
|
|
82
|
-
* directly. Overload resolution at concrete call sites commits to one
|
|
83
|
-
* overload immediately on argument shape — no type-level dispatch tax.
|
|
84
|
-
*
|
|
85
|
-
* Tests and other call sites that need the equivalent of
|
|
86
|
-
* `typeof useForm<X>` should reach for the `UseFormReturn<X>` /
|
|
87
|
-
* `UseFormConfig<X>` helpers in `types-api.ts` — instantiation
|
|
88
|
-
* expressions on overloaded functions follow brittle resolution rules,
|
|
89
|
-
* and the helper types give a deterministic projection.
|
|
90
|
-
*
|
|
91
|
-
* This module is the FALLBACK path. Vite consumers see the
|
|
92
|
-
* `attaform/vite` plugin's `resolveId` hook rewrite `attaform/zod`
|
|
93
|
-
* imports to either `attaform/zod-v3` or `attaform/zod-v4` at build
|
|
94
|
-
* time — in that case this dispatch never runs and the consumer
|
|
95
|
-
* bundle ships only the matching adapter. Other bundlers (and
|
|
96
|
-
* non-bundled ESM consumption) hit this dispatch instead, paying a
|
|
97
|
-
* modest size cost for the convenience of a single hello-world import.
|
|
98
|
-
*
|
|
99
|
-
* Power users who want a guaranteed lean bundle on non-Vite tooling
|
|
100
|
-
* can import directly from `attaform/zod-v3` or `attaform/zod-v4` —
|
|
101
|
-
* those subpaths are never rewritten and never load the other
|
|
102
|
-
* adapter.
|
|
103
|
-
*/
|
|
64
|
+
type V4FormOf<S extends SupportedRootSchema> = z.input<S> extends GenericForm ? z.input<S> : never;
|
|
65
|
+
type V4OutOf<S extends SupportedRootSchema> = z.output<S> extends GenericForm ? z.output<S> : never;
|
|
66
|
+
type V4ReadOf<S extends SupportedRootSchema> = StorageShape<S> extends GenericForm ? StorageShape<S> : never;
|
|
67
|
+
type V3FormOf<S extends SupportedRootSchema$1> = z.input<UnwrapZodRoot<S>> extends GenericForm ? z.input<UnwrapZodRoot<S>> : never;
|
|
68
|
+
type V3OutOf<S extends SupportedRootSchema$1> = z.output<UnwrapZodRoot<S>> extends GenericForm ? z.output<UnwrapZodRoot<S>> : never;
|
|
69
|
+
type V3ReadOf<S extends SupportedRootSchema$1> = StorageShape$1<UnwrapZodRoot<S>> extends GenericForm ? StorageShape$1<UnwrapZodRoot<S>> : never;
|
|
104
70
|
|
|
105
71
|
/**
|
|
106
72
|
* Create a form bound to a Zod v4 schema.
|
|
@@ -122,7 +88,7 @@ type V3ReadOf<S extends z.ZodObject<z.ZodRawShape>> = StorageShape$1<UnwrapZodOb
|
|
|
122
88
|
* resolves to v3 in a single-major consumer install; v3 schemas fall
|
|
123
89
|
* through to the v3 overload below. See `types-zod-major.ts`.
|
|
124
90
|
*/
|
|
125
|
-
declare function useForm<Schema extends
|
|
91
|
+
declare function useForm<Schema extends SupportedRootSchema & ZodV4Internals, K extends FormKey = FormKey>(configuration: Omit<UseFormConfiguration<V4FormOf<Schema>, V4OutOf<Schema>, AbstractSchema<V4FormOf<Schema>, V4OutOf<Schema>>, DefaultValuesInput<V4FormOf<Schema>>, K>, 'schema' | 'validateOn' | 'debounceMs'> & {
|
|
126
92
|
schema: Schema;
|
|
127
93
|
} & ValidateOnConfig): UseFormReturnType<V4FormOf<Schema>, V4OutOf<Schema>, V4ReadOf<Schema>, K>;
|
|
128
94
|
/**
|
|
@@ -143,7 +109,7 @@ declare function useForm<Schema extends z.ZodObject<z.ZodRawShape> & ZodV4Intern
|
|
|
143
109
|
* v3 schemas match this overload; v4 schemas hit the v4 overload
|
|
144
110
|
* above first and never reach here.
|
|
145
111
|
*/
|
|
146
|
-
declare function useForm<Schema extends
|
|
112
|
+
declare function useForm<Schema extends SupportedRootSchema$1, K extends FormKey = FormKey>(configuration: Omit<UseFormConfiguration<V3FormOf<Schema>, V3OutOf<Schema>, AbstractSchema<V3FormOf<Schema>, V3OutOf<Schema>>, DefaultValuesInput<V3FormOf<Schema>>, K>, 'schema' | 'validateOn' | 'debounceMs'> & {
|
|
147
113
|
schema: Schema;
|
|
148
114
|
} & ValidateOnConfig): UseFormReturnType<V3FormOf<Schema>, V3OutOf<Schema>, V3ReadOf<Schema>, K>;
|
|
149
115
|
|
|
@@ -194,7 +160,10 @@ type UseFormConfigV3<Schema extends z.ZodObject<z.ZodRawShape>, K extends FormKe
|
|
|
194
160
|
/**
|
|
195
161
|
* The return shape of `useForm` for a given Zod schema. Dispatches
|
|
196
162
|
* once on the schema's major version and projects to the matching
|
|
197
|
-
* adapter's `Form` / `Out` / `Read` slots.
|
|
163
|
+
* adapter's `Form` / `Out` / `Read` slots. The dispatch matches the
|
|
164
|
+
* full `SupportedRootSchema` per major, so an object, record, or
|
|
165
|
+
* discriminated-union root all resolve here exactly as the runtime
|
|
166
|
+
* `useForm` overloads accept them.
|
|
198
167
|
*
|
|
199
168
|
* Replaces `ReturnType<typeof useForm<Schema, K>>` in test code with
|
|
200
169
|
* concrete schemas. For generic helpers (`<S extends z.ZodObject>`),
|
|
@@ -203,15 +172,15 @@ type UseFormConfigV3<Schema extends z.ZodObject<z.ZodRawShape>, K extends FormKe
|
|
|
203
172
|
* this helper stays deferred and TS can't prove return-type
|
|
204
173
|
* compatibility.
|
|
205
174
|
*/
|
|
206
|
-
type UseFormReturn<Schema, K extends FormKey = FormKey> = Schema extends
|
|
175
|
+
type UseFormReturn<Schema, K extends FormKey = FormKey> = Schema extends SupportedRootSchema & ZodV4Internals ? UseFormReturnType<V4FormOf<Schema>, V4OutOf<Schema>, V4ReadOf<Schema>, K> : Schema extends SupportedRootSchema$1 ? UseFormReturnType<V3FormOf<Schema>, V3OutOf<Schema>, V3ReadOf<Schema>, K> : never;
|
|
207
176
|
/**
|
|
208
177
|
* The configuration parameter shape of `useForm` for a given Zod
|
|
209
178
|
* schema. Mirrors `UseFormReturn`'s dispatch — replaces
|
|
210
179
|
* `Parameters<typeof useForm<Schema, K>>[0]` in test code.
|
|
211
180
|
*/
|
|
212
|
-
type UseFormConfig<Schema, K extends FormKey = FormKey> = Schema extends
|
|
181
|
+
type UseFormConfig<Schema, K extends FormKey = FormKey> = Schema extends SupportedRootSchema & ZodV4Internals ? Omit<UseFormConfiguration<V4FormOf<Schema>, V4OutOf<Schema>, AbstractSchema<V4FormOf<Schema>, V4OutOf<Schema>>, DefaultValuesInput<V4FormOf<Schema>>, K>, 'schema' | 'validateOn' | 'debounceMs'> & {
|
|
213
182
|
schema: Schema;
|
|
214
|
-
} & ValidateOnConfig : Schema extends
|
|
183
|
+
} & ValidateOnConfig : Schema extends SupportedRootSchema$1 ? Omit<UseFormConfiguration<V3FormOf<Schema>, V3OutOf<Schema>, AbstractSchema<V3FormOf<Schema>, V3OutOf<Schema>>, DefaultValuesInput<V3FormOf<Schema>>, K>, 'schema' | 'validateOn' | 'debounceMs'> & {
|
|
215
184
|
schema: Schema;
|
|
216
185
|
} & ValidateOnConfig : never;
|
|
217
186
|
|