attaform 0.21.1 → 0.21.2
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/dist/chunks/dev-key-collision-warnings.cjs +1 -1
- package/dist/chunks/dev-key-collision-warnings.mjs +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/chunks/indexeddb.cjs +1 -1
- package/dist/chunks/indexeddb.mjs +1 -1
- package/dist/chunks/local-storage.cjs +1 -1
- package/dist/chunks/local-storage.mjs +1 -1
- package/dist/chunks/multi-tab-sync.cjs +2 -2
- package/dist/chunks/multi-tab-sync.mjs +2 -2
- package/dist/chunks/session-storage.cjs +1 -1
- package/dist/chunks/session-storage.mjs +1 -1
- package/dist/chunks/wire-persistence.cjs +2 -2
- package/dist/chunks/wire-persistence.mjs +2 -2
- package/dist/index.cjs +37 -24
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +20 -18
- package/dist/index.d.mts +20 -18
- package/dist/index.d.ts +20 -18
- package/dist/index.mjs +38 -25
- 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 +396 -216
- package/dist/runtime/components/DevtoolsValueTree.vue +176 -114
- package/dist/runtime/plugins/attaform.cjs +2 -2
- package/dist/runtime/plugins/attaform.mjs +2 -2
- package/dist/shared/{attaform.D32WwKk6.cjs → attaform.B5LNzqQh.cjs} +243 -352
- package/dist/shared/attaform.B5LNzqQh.cjs.map +1 -0
- package/dist/shared/{attaform.S-pYLSo4.cjs → attaform.BBDIKtKY.cjs} +13 -16
- package/dist/shared/attaform.BBDIKtKY.cjs.map +1 -0
- package/dist/shared/{attaform.Bv7dRDWK.d.ts → attaform.BCcrLApm.d.mts} +54 -63
- package/dist/shared/{attaform.BupwXkj_.mjs → attaform.BFWb6hDk.mjs} +29 -23
- package/dist/shared/attaform.BFWb6hDk.mjs.map +1 -0
- package/dist/shared/{attaform.BWfliRIK.d.cts → attaform.BGf_J22U.d.ts} +54 -63
- package/dist/shared/{attaform.DMEP_ENr.mjs → attaform.BVeLgfEh.mjs} +14 -17
- package/dist/shared/attaform.BVeLgfEh.mjs.map +1 -0
- package/dist/shared/{attaform.MtrpT6Ki.d.ts → attaform.BYgioWLF.d.ts} +1 -1
- package/dist/shared/{attaform.NQ8mybyW.d.mts → attaform.BkjJfMvJ.d.cts} +54 -63
- package/dist/shared/{attaform.Duecg2NO.d.mts → attaform.BoY6RZUl.d.cts} +1 -1
- package/dist/shared/{attaform.Bq5sX7TF.cjs → attaform.BwLp9KM7.cjs} +2 -2
- package/dist/shared/{attaform.Bq5sX7TF.cjs.map → attaform.BwLp9KM7.cjs.map} +1 -1
- package/dist/shared/{attaform.CICFZ1iS.cjs → attaform.BwrowMp2.cjs} +19 -45
- package/dist/shared/attaform.BwrowMp2.cjs.map +1 -0
- package/dist/shared/{attaform.Y1ZGhM4k.mjs → attaform.C41gjp-a.mjs} +2 -2
- package/dist/shared/{attaform.Y1ZGhM4k.mjs.map → attaform.C41gjp-a.mjs.map} +1 -1
- package/dist/shared/{attaform.BM6YD9kZ.cjs → attaform.CR6wGvNu.cjs} +29 -23
- package/dist/shared/attaform.CR6wGvNu.cjs.map +1 -0
- package/dist/shared/{attaform.DR6RmxWZ.mjs → attaform.CTheKoTc.mjs} +341 -221
- package/dist/shared/attaform.CTheKoTc.mjs.map +1 -0
- package/dist/shared/{attaform.BSkvn43g.cjs → attaform.CcnF1AKJ.cjs} +4 -4
- package/dist/shared/attaform.CcnF1AKJ.cjs.map +1 -0
- package/dist/shared/{attaform.FudOcHaa.d.cts → attaform.CnEl--PF.d.mts} +1 -1
- package/dist/shared/{attaform.DozgVlCE.mjs → attaform.CrD73S4m.mjs} +4 -4
- package/dist/shared/attaform.CrD73S4m.mjs.map +1 -0
- package/dist/shared/{attaform.ClXwitZj.cjs → attaform.D2ZuIOCf.cjs} +347 -226
- package/dist/shared/attaform.D2ZuIOCf.cjs.map +1 -0
- package/dist/shared/{attaform.Be8NZG9M.mjs → attaform.D6GYGshL.mjs} +19 -45
- package/dist/shared/attaform.D6GYGshL.mjs.map +1 -0
- package/dist/shared/{attaform.pmtahXKy.mjs → attaform.DP-u7_tk.mjs} +243 -352
- package/dist/shared/attaform.DP-u7_tk.mjs.map +1 -0
- package/dist/shared/{attaform.D0dWZsJt.d.mts → attaform.ory-3WhV.d.cts} +128 -129
- package/dist/shared/{attaform.D0dWZsJt.d.cts → attaform.ory-3WhV.d.mts} +128 -129
- package/dist/shared/{attaform.D0dWZsJt.d.ts → attaform.ory-3WhV.d.ts} +128 -129
- 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 +3 -4
- package/dist/zod-v3.cjs.map +1 -1
- package/dist/zod-v3.d.cts +4 -4
- package/dist/zod-v3.d.mts +4 -4
- package/dist/zod-v3.d.ts +4 -4
- package/dist/zod-v3.mjs +2 -3
- package/dist/zod-v3.mjs.map +1 -1
- package/dist/zod-v4.cjs +3 -4
- package/dist/zod-v4.cjs.map +1 -1
- package/dist/zod-v4.d.cts +4 -4
- package/dist/zod-v4.d.mts +4 -4
- package/dist/zod-v4.d.ts +4 -4
- package/dist/zod-v4.mjs +2 -3
- package/dist/zod-v4.mjs.map +1 -1
- package/dist/zod.cjs +6 -6
- package/dist/zod.cjs.map +1 -1
- package/dist/zod.d.cts +31 -22
- package/dist/zod.d.mts +31 -22
- package/dist/zod.d.ts +31 -22
- package/dist/zod.mjs +5 -6
- package/dist/zod.mjs.map +1 -1
- package/package.json +3 -11
- package/dist/shared/attaform.BM6YD9kZ.cjs.map +0 -1
- package/dist/shared/attaform.BSkvn43g.cjs.map +0 -1
- package/dist/shared/attaform.Be8NZG9M.mjs.map +0 -1
- package/dist/shared/attaform.BupwXkj_.mjs.map +0 -1
- package/dist/shared/attaform.CICFZ1iS.cjs.map +0 -1
- package/dist/shared/attaform.ClXwitZj.cjs.map +0 -1
- package/dist/shared/attaform.D32WwKk6.cjs.map +0 -1
- package/dist/shared/attaform.DMEP_ENr.mjs.map +0 -1
- package/dist/shared/attaform.DR6RmxWZ.mjs.map +0 -1
- package/dist/shared/attaform.DozgVlCE.mjs.map +0 -1
- package/dist/shared/attaform.S-pYLSo4.cjs.map +0 -1
- package/dist/shared/attaform.pmtahXKy.mjs.map +0 -1
- package/dist/shared/{attaform.DSD85fHb.d.cts → attaform.nf83TIR5.d.cts} +10 -10
- package/dist/shared/{attaform.DSD85fHb.d.mts → attaform.nf83TIR5.d.mts} +10 -10
- package/dist/shared/{attaform.DSD85fHb.d.ts → attaform.nf83TIR5.d.ts} +10 -10
|
@@ -73,6 +73,123 @@ type ResolvedFieldMeta = {
|
|
|
73
73
|
readonly meta: Readonly<FieldMetaPayload>;
|
|
74
74
|
};
|
|
75
75
|
|
|
76
|
+
/**
|
|
77
|
+
* Path primitives for advanced integrations. The form library accepts
|
|
78
|
+
* paths in dotted-string form (`'user.email'`) at every public API.
|
|
79
|
+
* These primitives are exposed for adapter authors who need to
|
|
80
|
+
* canonicalise user-provided paths.
|
|
81
|
+
*/
|
|
82
|
+
declare const pathKeyBrand: unique symbol;
|
|
83
|
+
/**
|
|
84
|
+
* Branded string identifier for a canonicalised path. Useful as a
|
|
85
|
+
* `Map` key — two paths that resolve to the same canonical form
|
|
86
|
+
* produce the same `PathKey`. Treat as opaque; don't try to parse.
|
|
87
|
+
*/
|
|
88
|
+
type PathKey = string & {
|
|
89
|
+
readonly [pathKeyBrand]: 'PathKey';
|
|
90
|
+
};
|
|
91
|
+
/** A single path segment — a property name or array index. */
|
|
92
|
+
type Segment = string | number;
|
|
93
|
+
/** A structured path as a read-only sequence of segments. */
|
|
94
|
+
type Path = readonly Segment[];
|
|
95
|
+
/**
|
|
96
|
+
* Parse a dotted-string path into structured segments.
|
|
97
|
+
*
|
|
98
|
+
* ```ts
|
|
99
|
+
* parseDottedPath('user.address.line1') // ['user', 'address', 'line1']
|
|
100
|
+
* parseDottedPath('items.0.name') // ['items', 0, 'name']
|
|
101
|
+
* parseDottedPath('') // [''] (the empty-string key)
|
|
102
|
+
* ```
|
|
103
|
+
*
|
|
104
|
+
* The empty-string input `''` is the **literal empty-key path**, not
|
|
105
|
+
* the root. Use the array form `[]` for root. Form-level errors
|
|
106
|
+
* (root `.refine()`) live at the empty-string path bucket so
|
|
107
|
+
* `errors('')` returns them without sweeping every field error too.
|
|
108
|
+
*
|
|
109
|
+
* Throws `InvalidPathError` for paths with empty INTERNAL segments
|
|
110
|
+
* (`'a..b'`, leading or trailing dots). For keys containing literal
|
|
111
|
+
* dots, pass an array form (`['user.name']`) instead.
|
|
112
|
+
*/
|
|
113
|
+
declare function parseDottedPath(path: string): Segment[];
|
|
114
|
+
/**
|
|
115
|
+
* Canonicalise a path into structured segments plus a stable string
|
|
116
|
+
* key. Accepts either dotted-string or array form; integer-looking
|
|
117
|
+
* segments normalise to numbers.
|
|
118
|
+
*
|
|
119
|
+
* ```ts
|
|
120
|
+
* canonicalizePath('items.0.name')
|
|
121
|
+
* // { segments: ['items', 0, 'name'], key: '["items",0,"name"]' as PathKey }
|
|
122
|
+
*
|
|
123
|
+
* canonicalizePath(['items', 0, 'name'])
|
|
124
|
+
* // → same result
|
|
125
|
+
* ```
|
|
126
|
+
*
|
|
127
|
+
* The returned `key` is suitable as a `Map`/`Set` key — equal paths
|
|
128
|
+
* produce equal keys regardless of input form.
|
|
129
|
+
*/
|
|
130
|
+
declare function canonicalizePath(input: string | Path): {
|
|
131
|
+
segments: readonly Segment[];
|
|
132
|
+
key: PathKey;
|
|
133
|
+
};
|
|
134
|
+
/**
|
|
135
|
+
* The root path — an empty segment tuple. Pass to APIs that accept
|
|
136
|
+
* a `Path` to address the form value as a whole.
|
|
137
|
+
*/
|
|
138
|
+
declare const ROOT_PATH: Path;
|
|
139
|
+
/** Stable string key for the root path. */
|
|
140
|
+
declare const ROOT_PATH_KEY: PathKey;
|
|
141
|
+
/**
|
|
142
|
+
* `true` when `path` starts with every segment of `prefix` (in order).
|
|
143
|
+
* The empty `prefix` matches every path — ROOT prefix is universal.
|
|
144
|
+
*
|
|
145
|
+
* Walks segments rather than `PathKey` strings because the data this
|
|
146
|
+
* helper operates on (e.g. `meta.errors[].path`) carries segment
|
|
147
|
+
* arrays directly.
|
|
148
|
+
*
|
|
149
|
+
* ```ts
|
|
150
|
+
* isPathPrefix(['cargo'], ['cargo', 'items', 0, 'sku']) // true
|
|
151
|
+
* isPathPrefix(['cargo', 'items'], ['cargo']) // false (path shorter)
|
|
152
|
+
* isPathPrefix([], ['anything']) // true (root prefix)
|
|
153
|
+
* ```
|
|
154
|
+
*/
|
|
155
|
+
declare function isPathPrefix(prefix: readonly Segment[], path: readonly Segment[]): boolean;
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Per-FormStore registry tracking which DOM elements have opted into
|
|
159
|
+
* persistence for which paths. Lives on the FormStore so that two SFCs
|
|
160
|
+
* sharing a key share the registry — opt-ins are per-element, not
|
|
161
|
+
* per-component.
|
|
162
|
+
*
|
|
163
|
+
* The directive's input handler computes `meta.persist` for each write
|
|
164
|
+
* by calling `hasOptIn(elementId, path)` — only THIS element's writes
|
|
165
|
+
* persist if THIS element opted in. Other call sites that aren't tied
|
|
166
|
+
* to a single element (history undo/redo, field-array helpers, devtools
|
|
167
|
+
* edits) use `hasAnyOptInForPath(path)` — persist if any element has
|
|
168
|
+
* opted into that path.
|
|
169
|
+
*
|
|
170
|
+
* Internal data structure: `Map<PathKey, Set<elementId>>`. Small forms
|
|
171
|
+
* have ~10-50 paths; iteration is cheap. All operations are O(1) given
|
|
172
|
+
* (id, path).
|
|
173
|
+
*/
|
|
174
|
+
type PersistOptInRegistry = {
|
|
175
|
+
/** Add an opt-in entry; idempotent. */
|
|
176
|
+
add(elementId: string, path: PathKey): void;
|
|
177
|
+
/** Remove a single (element, path) entry. */
|
|
178
|
+
remove(elementId: string, path: PathKey): void;
|
|
179
|
+
/** Remove every opt-in for `elementId`. Called from directive's beforeUnmount. */
|
|
180
|
+
removeAllFor(elementId: string): void;
|
|
181
|
+
/** Check whether THIS element has opted into THIS path. */
|
|
182
|
+
hasOptIn(elementId: string, path: PathKey): boolean;
|
|
183
|
+
/** Check whether ANY element has opted into this path. */
|
|
184
|
+
hasAnyOptInForPath(path: PathKey): boolean;
|
|
185
|
+
/** Iterate every path that currently has at least one opt-in. */
|
|
186
|
+
optedInPaths(): IterableIterator<PathKey>;
|
|
187
|
+
/** True iff no element has opted into any path. */
|
|
188
|
+
isEmpty(): boolean;
|
|
189
|
+
/** Drop every entry. Called from FormStore.dispose. */
|
|
190
|
+
clear(): void;
|
|
191
|
+
};
|
|
192
|
+
|
|
76
193
|
/** Internal brand for the `Unset` type. Never exposed at runtime. */
|
|
77
194
|
declare const _unsetBrand: unique symbol;
|
|
78
195
|
/**
|
|
@@ -545,6 +662,15 @@ type DefaultValuesInput<T> = T extends string ? string | Unset : T extends numbe
|
|
|
545
662
|
[K in keyof T]?: DefaultValuesInput<T[K]>;
|
|
546
663
|
} | Unset : T;
|
|
547
664
|
|
|
665
|
+
/**
|
|
666
|
+
* Identifier for a form. A `FormKey` is the string passed via
|
|
667
|
+
* `useForm({ key })`, used to look up a form by name from a distant
|
|
668
|
+
* component, namespace persisted drafts, and label errors and
|
|
669
|
+
* DevTools entries. Anonymous `useForm` calls allocate one
|
|
670
|
+
* automatically; you only need to pick one when the form needs
|
|
671
|
+
* stable identity.
|
|
672
|
+
*/
|
|
673
|
+
type FormKey = string;
|
|
548
674
|
/**
|
|
549
675
|
* Per-form options threaded from `useForm` into the adapter factory.
|
|
550
676
|
* Today carries the resolved `maxRecursionDepth` so adapter walks can
|
|
@@ -555,133 +681,6 @@ interface SchemaFactoryOptions {
|
|
|
555
681
|
/** Resolved recursion ceiling (per-form > app-default > library default). */
|
|
556
682
|
maxRecursionDepth: number;
|
|
557
683
|
}
|
|
558
|
-
|
|
559
|
-
/**
|
|
560
|
-
* Path primitives for advanced integrations. The form library accepts
|
|
561
|
-
* paths in dotted-string form (`'user.email'`) at every public API.
|
|
562
|
-
* These primitives are exposed for adapter authors who need to
|
|
563
|
-
* canonicalise user-provided paths.
|
|
564
|
-
*/
|
|
565
|
-
declare const pathKeyBrand: unique symbol;
|
|
566
|
-
/**
|
|
567
|
-
* Branded string identifier for a canonicalised path. Useful as a
|
|
568
|
-
* `Map` key — two paths that resolve to the same canonical form
|
|
569
|
-
* produce the same `PathKey`. Treat as opaque; don't try to parse.
|
|
570
|
-
*/
|
|
571
|
-
type PathKey = string & {
|
|
572
|
-
readonly [pathKeyBrand]: 'PathKey';
|
|
573
|
-
};
|
|
574
|
-
/** A single path segment — a property name or array index. */
|
|
575
|
-
type Segment = string | number;
|
|
576
|
-
/** A structured path as a read-only sequence of segments. */
|
|
577
|
-
type Path = readonly Segment[];
|
|
578
|
-
/**
|
|
579
|
-
* Parse a dotted-string path into structured segments.
|
|
580
|
-
*
|
|
581
|
-
* ```ts
|
|
582
|
-
* parseDottedPath('user.address.line1') // ['user', 'address', 'line1']
|
|
583
|
-
* parseDottedPath('items.0.name') // ['items', 0, 'name']
|
|
584
|
-
* parseDottedPath('') // [''] (the empty-string key)
|
|
585
|
-
* ```
|
|
586
|
-
*
|
|
587
|
-
* The empty-string input `''` is the **literal empty-key path**, not
|
|
588
|
-
* the root. Use the array form `[]` for root. Form-level errors
|
|
589
|
-
* (root `.refine()`) live at the empty-string path bucket so
|
|
590
|
-
* `errors('')` returns them without sweeping every field error too.
|
|
591
|
-
*
|
|
592
|
-
* Throws `InvalidPathError` for paths with empty INTERNAL segments
|
|
593
|
-
* (`'a..b'`, leading or trailing dots). For keys containing literal
|
|
594
|
-
* dots, pass an array form (`['user.name']`) instead.
|
|
595
|
-
*/
|
|
596
|
-
declare function parseDottedPath(path: string): Segment[];
|
|
597
|
-
/**
|
|
598
|
-
* Canonicalise a path into structured segments plus a stable string
|
|
599
|
-
* key. Accepts either dotted-string or array form; integer-looking
|
|
600
|
-
* segments normalise to numbers.
|
|
601
|
-
*
|
|
602
|
-
* ```ts
|
|
603
|
-
* canonicalizePath('items.0.name')
|
|
604
|
-
* // { segments: ['items', 0, 'name'], key: '["items",0,"name"]' as PathKey }
|
|
605
|
-
*
|
|
606
|
-
* canonicalizePath(['items', 0, 'name'])
|
|
607
|
-
* // → same result
|
|
608
|
-
* ```
|
|
609
|
-
*
|
|
610
|
-
* The returned `key` is suitable as a `Map`/`Set` key — equal paths
|
|
611
|
-
* produce equal keys regardless of input form.
|
|
612
|
-
*/
|
|
613
|
-
declare function canonicalizePath(input: string | Path): {
|
|
614
|
-
segments: readonly Segment[];
|
|
615
|
-
key: PathKey;
|
|
616
|
-
};
|
|
617
|
-
/**
|
|
618
|
-
* The root path — an empty segment tuple. Pass to APIs that accept
|
|
619
|
-
* a `Path` to address the form value as a whole.
|
|
620
|
-
*/
|
|
621
|
-
declare const ROOT_PATH: Path;
|
|
622
|
-
/** Stable string key for the root path. */
|
|
623
|
-
declare const ROOT_PATH_KEY: PathKey;
|
|
624
|
-
/**
|
|
625
|
-
* `true` when `path` starts with every segment of `prefix` (in order).
|
|
626
|
-
* The empty `prefix` matches every path — ROOT prefix is universal.
|
|
627
|
-
*
|
|
628
|
-
* Walks segments rather than `PathKey` strings because the data this
|
|
629
|
-
* helper operates on (e.g. `meta.errors[].path`) carries segment
|
|
630
|
-
* arrays directly.
|
|
631
|
-
*
|
|
632
|
-
* ```ts
|
|
633
|
-
* isPathPrefix(['cargo'], ['cargo', 'items', 0, 'sku']) // true
|
|
634
|
-
* isPathPrefix(['cargo', 'items'], ['cargo']) // false (path shorter)
|
|
635
|
-
* isPathPrefix([], ['anything']) // true (root prefix)
|
|
636
|
-
* ```
|
|
637
|
-
*/
|
|
638
|
-
declare function isPathPrefix(prefix: readonly Segment[], path: readonly Segment[]): boolean;
|
|
639
|
-
|
|
640
|
-
/**
|
|
641
|
-
* Per-FormStore registry tracking which DOM elements have opted into
|
|
642
|
-
* persistence for which paths. Lives on the FormStore so that two SFCs
|
|
643
|
-
* sharing a key share the registry — opt-ins are per-element, not
|
|
644
|
-
* per-component.
|
|
645
|
-
*
|
|
646
|
-
* The directive's input handler computes `meta.persist` for each write
|
|
647
|
-
* by calling `hasOptIn(elementId, path)` — only THIS element's writes
|
|
648
|
-
* persist if THIS element opted in. Other call sites that aren't tied
|
|
649
|
-
* to a single element (history undo/redo, field-array helpers, devtools
|
|
650
|
-
* edits) use `hasAnyOptInForPath(path)` — persist if any element has
|
|
651
|
-
* opted into that path.
|
|
652
|
-
*
|
|
653
|
-
* Internal data structure: `Map<PathKey, Set<elementId>>`. Small forms
|
|
654
|
-
* have ~10-50 paths; iteration is cheap. All operations are O(1) given
|
|
655
|
-
* (id, path).
|
|
656
|
-
*/
|
|
657
|
-
type PersistOptInRegistry = {
|
|
658
|
-
/** Add an opt-in entry; idempotent. */
|
|
659
|
-
add(elementId: string, path: PathKey): void;
|
|
660
|
-
/** Remove a single (element, path) entry. */
|
|
661
|
-
remove(elementId: string, path: PathKey): void;
|
|
662
|
-
/** Remove every opt-in for `elementId`. Called from directive's beforeUnmount. */
|
|
663
|
-
removeAllFor(elementId: string): void;
|
|
664
|
-
/** Check whether THIS element has opted into THIS path. */
|
|
665
|
-
hasOptIn(elementId: string, path: PathKey): boolean;
|
|
666
|
-
/** Check whether ANY element has opted into this path. */
|
|
667
|
-
hasAnyOptInForPath(path: PathKey): boolean;
|
|
668
|
-
/** Iterate every path that currently has at least one opt-in. */
|
|
669
|
-
optedInPaths(): IterableIterator<PathKey>;
|
|
670
|
-
/** True iff no element has opted into any path. */
|
|
671
|
-
isEmpty(): boolean;
|
|
672
|
-
/** Drop every entry. Called from FormStore.dispose. */
|
|
673
|
-
clear(): void;
|
|
674
|
-
};
|
|
675
|
-
|
|
676
|
-
/**
|
|
677
|
-
* Identifier for a form. A `FormKey` is the string passed via
|
|
678
|
-
* `useForm({ key })`, used to look up a form by name from a distant
|
|
679
|
-
* component, namespace persisted drafts, and label errors and
|
|
680
|
-
* DevTools entries. Anonymous `useForm` calls allocate one
|
|
681
|
-
* automatically; you only need to pick one when the form needs
|
|
682
|
-
* stable identity.
|
|
683
|
-
*/
|
|
684
|
-
type FormKey = string;
|
|
685
684
|
/**
|
|
686
685
|
* One validation failure. `path` points at the offending field as a
|
|
687
686
|
* structured array — `['user', 'address', 0, 'line1']` for a nested
|
|
@@ -4916,5 +4915,5 @@ type UseFormReturnType<Form extends GenericForm, GetValueFormType extends Generi
|
|
|
4916
4915
|
blankPaths: ComputedRef<BlankPathsView>;
|
|
4917
4916
|
};
|
|
4918
4917
|
|
|
4919
|
-
export { ROOT_PATH as
|
|
4920
|
-
export type {
|
|
4918
|
+
export { ROOT_PATH as a4, ROOT_PATH_KEY as a5, canonicalizePath as as, isPathPrefix as at, isUnset as au, parseDottedPath as av, unset as aw };
|
|
4919
|
+
export type { PendingValidationStatus as $, AttaformDefaults as A, FormStorage as B, CoercionEntry as C, DefaultValuesInput as D, ErrorsProxyShape as E, FormKey as F, GenericForm as G, FormStorageKind as H, HandleSubmit as I, HistoryConfig as J, IsTuple as K, IsUnion as L, JoinSegments as M, KeyofUnion as N, LiftedValueShape as O, MetaTrackerValue as P, NestedReadType as Q, RegisterModelDynamicCustomDirective as R, NestedType as S, OnError as T, UseFormConfiguration as U, ValidationError as V, OnInvalidSubmitPolicy as W, OnSubmit as X, PartialFlatPath as Y, Path as Z, PathKey as _, AbstractSchema as a, PersistConfig as a0, PersistConfigOptions as a1, PersistIncludeMode as a2, Primitive as a3, ReactiveValidationStatus as a6, RegisterDirective as a7, RegisterFlatPath as a8, RegisterOptions as a9, RegisterSelectModifier as aa, RegisterTextModifier as ab, RegisterTransform as ac, Segment as ad, SetValueCallback as ae, SetValuePayload as af, SettledValidationStatus as ag, SlimPrimitiveKind as ah, SlimRuntimeOf as ai, SubmitHandler as aj, Unset as ak, ValidateOn as al, ValidateOnConfig as am, ValidationResponse as an, ValidationResponseWithoutValue as ao, ValueOfUnion as ap, WriteMeta as aq, WriteShape as ar, SchemaFactoryOptions as ax, TransformAbortHolder as ay, PersistOptInRegistry as az, UseFormReturnType as b, RegisterValue as c, GetDisplayState as d, ApiErrorEnvelope as e, ApiErrorDetails as f, ApiErrorEntry as g, ArrayItem as h, ArrayPath as i, CoercionRegistry as j, CoercionResult as k, CustomDirectiveRegisterAssignerFn as l, DeepPartial as m, DefaultValuesResponse as n, DefaultValuesShape as o, DisplayCtx as p, DisplayMachine as q, DisplayState as r, FieldMetaPayload as s, FieldState as t, FieldStateMap as u, FieldStateMapEntry as v, FlatPath as w, FormErrorRecord as x, FormErrorsSurface as y, FormMeta as z };
|
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.BFWb6hDk.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.CR6wGvNu.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.BFWb6hDk.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,8 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const useForm = require('./shared/attaform.
|
|
4
|
-
const injectWizard = require('./shared/attaform.
|
|
5
|
-
const paths = require('./shared/attaform.D32WwKk6.cjs');
|
|
3
|
+
const useForm = require('./shared/attaform.CcnF1AKJ.cjs');
|
|
4
|
+
const injectWizard = require('./shared/attaform.D2ZuIOCf.cjs');
|
|
6
5
|
|
|
7
6
|
|
|
8
7
|
|
|
@@ -17,6 +16,6 @@ exports.injectWizard = injectWizard.injectWizard;
|
|
|
17
16
|
exports.isUnset = injectWizard.isUnset;
|
|
18
17
|
exports.lazy = injectWizard.lazy;
|
|
19
18
|
exports.unset = injectWizard.unset;
|
|
19
|
+
exports.useRegister = injectWizard.useRegister;
|
|
20
20
|
exports.useWizard = injectWizard.useWizard;
|
|
21
|
-
exports.useRegister = paths.useRegister;
|
|
22
21
|
//# sourceMappingURL=zod-v3.cjs.map
|
package/dist/zod-v3.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zod-v3.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"zod-v3.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;"}
|
package/dist/zod-v3.d.cts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { G as GenericForm,
|
|
3
|
-
export { ak as Unset,
|
|
4
|
-
import { U as UnwrapZodObject, S as StorageShape } from './shared/attaform.
|
|
5
|
-
export {
|
|
2
|
+
import { G as GenericForm, F as FormKey, U as UseFormConfiguration, a as AbstractSchema, D as DefaultValuesInput, b as UseFormReturnType, am as ValidateOnConfig, ax as SchemaFactoryOptions, s as FieldMetaPayload } from './shared/attaform.ory-3WhV.cjs';
|
|
3
|
+
export { ak as Unset, au as isUnset, aw as unset } from './shared/attaform.ory-3WhV.cjs';
|
|
4
|
+
import { U as UnwrapZodObject, S as StorageShape } from './shared/attaform.nf83TIR5.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.BkjJfMvJ.cjs';
|
|
6
6
|
import 'vue';
|
|
7
7
|
|
|
8
8
|
/**
|
package/dist/zod-v3.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { G as GenericForm,
|
|
3
|
-
export { ak as Unset,
|
|
4
|
-
import { U as UnwrapZodObject, S as StorageShape } from './shared/attaform.
|
|
5
|
-
export {
|
|
2
|
+
import { G as GenericForm, F as FormKey, U as UseFormConfiguration, a as AbstractSchema, D as DefaultValuesInput, b as UseFormReturnType, am as ValidateOnConfig, ax as SchemaFactoryOptions, s as FieldMetaPayload } from './shared/attaform.ory-3WhV.mjs';
|
|
3
|
+
export { ak as Unset, au as isUnset, aw as unset } from './shared/attaform.ory-3WhV.mjs';
|
|
4
|
+
import { U as UnwrapZodObject, S as StorageShape } from './shared/attaform.nf83TIR5.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.BCcrLApm.mjs';
|
|
6
6
|
import 'vue';
|
|
7
7
|
|
|
8
8
|
/**
|
package/dist/zod-v3.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { G as GenericForm,
|
|
3
|
-
export { ak as Unset,
|
|
4
|
-
import { U as UnwrapZodObject, S as StorageShape } from './shared/attaform.
|
|
5
|
-
export {
|
|
2
|
+
import { G as GenericForm, F as FormKey, U as UseFormConfiguration, a as AbstractSchema, D as DefaultValuesInput, b as UseFormReturnType, am as ValidateOnConfig, ax as SchemaFactoryOptions, s as FieldMetaPayload } from './shared/attaform.ory-3WhV.js';
|
|
3
|
+
export { ak as Unset, au as isUnset, aw as unset } from './shared/attaform.ory-3WhV.js';
|
|
4
|
+
import { U as UnwrapZodObject, S as StorageShape } from './shared/attaform.nf83TIR5.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.BGf_J22U.js';
|
|
6
6
|
import 'vue';
|
|
7
7
|
|
|
8
8
|
/**
|
package/dist/zod-v3.mjs
CHANGED
|
@@ -1,4 +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,
|
|
3
|
-
export { J as useRegister } from './shared/attaform.pmtahXKy.mjs';
|
|
1
|
+
export { f as fieldMeta, i as isZodSchemaType, u as useForm, w as withMeta, z as zodAdapter } from './shared/attaform.CrD73S4m.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.CTheKoTc.mjs';
|
|
4
3
|
//# sourceMappingURL=zod-v3.mjs.map
|
package/dist/zod-v3.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zod-v3.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"zod-v3.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
package/dist/zod-v4.cjs
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const index = require('./shared/attaform.
|
|
4
|
-
const injectWizard = require('./shared/attaform.
|
|
5
|
-
const paths = require('./shared/attaform.D32WwKk6.cjs');
|
|
3
|
+
const index = require('./shared/attaform.BBDIKtKY.cjs');
|
|
4
|
+
const injectWizard = require('./shared/attaform.D2ZuIOCf.cjs');
|
|
6
5
|
|
|
7
6
|
|
|
8
7
|
|
|
@@ -19,6 +18,6 @@ exports.injectWizard = injectWizard.injectWizard;
|
|
|
19
18
|
exports.isUnset = injectWizard.isUnset;
|
|
20
19
|
exports.lazy = injectWizard.lazy;
|
|
21
20
|
exports.unset = injectWizard.unset;
|
|
21
|
+
exports.useRegister = injectWizard.useRegister;
|
|
22
22
|
exports.useWizard = injectWizard.useWizard;
|
|
23
|
-
exports.useRegister = paths.useRegister;
|
|
24
23
|
//# sourceMappingURL=zod-v4.cjs.map
|
package/dist/zod-v4.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zod-v4.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"zod-v4.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/zod-v4.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { P as PathInput, a as PathOutput, u as useForm } from './shared/attaform.
|
|
2
|
-
export {
|
|
3
|
-
import {
|
|
4
|
-
export { ak as Unset,
|
|
1
|
+
export { P as PathInput, a as PathOutput, u as useForm } from './shared/attaform.BoY6RZUl.cjs';
|
|
2
|
+
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.BkjJfMvJ.cjs';
|
|
3
|
+
import { F as FormKey, ax as SchemaFactoryOptions, a as AbstractSchema, s as FieldMetaPayload } from './shared/attaform.ory-3WhV.cjs';
|
|
4
|
+
export { ak as Unset, au as isUnset, aw as unset } from './shared/attaform.ory-3WhV.cjs';
|
|
5
5
|
import { z } from 'zod';
|
|
6
6
|
import { a as AttaformError } from './shared/attaform.DkA5J8NW.cjs';
|
|
7
7
|
import 'vue';
|
package/dist/zod-v4.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { P as PathInput, a as PathOutput, u as useForm } from './shared/attaform.
|
|
2
|
-
export {
|
|
3
|
-
import {
|
|
4
|
-
export { ak as Unset,
|
|
1
|
+
export { P as PathInput, a as PathOutput, u as useForm } from './shared/attaform.CnEl--PF.mjs';
|
|
2
|
+
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.BCcrLApm.mjs';
|
|
3
|
+
import { F as FormKey, ax as SchemaFactoryOptions, a as AbstractSchema, s as FieldMetaPayload } from './shared/attaform.ory-3WhV.mjs';
|
|
4
|
+
export { ak as Unset, au as isUnset, aw as unset } from './shared/attaform.ory-3WhV.mjs';
|
|
5
5
|
import { z } from 'zod';
|
|
6
6
|
import { a as AttaformError } from './shared/attaform.DkA5J8NW.mjs';
|
|
7
7
|
import 'vue';
|
package/dist/zod-v4.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { P as PathInput, a as PathOutput, u as useForm } from './shared/attaform.
|
|
2
|
-
export {
|
|
3
|
-
import {
|
|
4
|
-
export { ak as Unset,
|
|
1
|
+
export { P as PathInput, a as PathOutput, u as useForm } from './shared/attaform.BYgioWLF.js';
|
|
2
|
+
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.BGf_J22U.js';
|
|
3
|
+
import { F as FormKey, ax as SchemaFactoryOptions, a as AbstractSchema, s as FieldMetaPayload } from './shared/attaform.ory-3WhV.js';
|
|
4
|
+
export { ak as Unset, au as isUnset, aw as unset } from './shared/attaform.ory-3WhV.js';
|
|
5
5
|
import { z } from 'zod';
|
|
6
6
|
import { a as AttaformError } from './shared/attaform.DkA5J8NW.js';
|
|
7
7
|
import 'vue';
|
package/dist/zod-v4.mjs
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export { U as UnsupportedSchemaError, a as assertZodVersion, f as fieldMeta,
|
|
2
|
-
export { A as AttaformErrorCode,
|
|
3
|
-
export { J as useRegister } from './shared/attaform.pmtahXKy.mjs';
|
|
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.BVeLgfEh.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.CTheKoTc.mjs';
|
|
4
3
|
//# sourceMappingURL=zod-v4.mjs.map
|
package/dist/zod-v4.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zod-v4.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"zod-v4.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
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.B5LNzqQh.cjs');
|
|
4
|
+
const useForm$1 = require('./shared/attaform.CcnF1AKJ.cjs');
|
|
5
|
+
const index = require('./shared/attaform.BBDIKtKY.cjs');
|
|
6
|
+
const walkFieldMeta = require('./shared/attaform.BwrowMp2.cjs');
|
|
7
|
+
const injectWizard = require('./shared/attaform.D2ZuIOCf.cjs');
|
|
8
8
|
|
|
9
9
|
function isZodV4SchemaShape(value) {
|
|
10
10
|
if (typeof value !== "object" || value === null) return false;
|
|
@@ -41,13 +41,13 @@ function cloneSchema(schema) {
|
|
|
41
41
|
return new Ctor(candidate._def);
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
exports.useRegister = paths.useRegister;
|
|
45
44
|
exports.AttaformErrorCode = injectWizard.AttaformErrorCode;
|
|
46
45
|
exports.injectForm = injectWizard.injectForm;
|
|
47
46
|
exports.injectWizard = injectWizard.injectWizard;
|
|
48
47
|
exports.isUnset = injectWizard.isUnset;
|
|
49
48
|
exports.lazy = injectWizard.lazy;
|
|
50
49
|
exports.unset = injectWizard.unset;
|
|
50
|
+
exports.useRegister = injectWizard.useRegister;
|
|
51
51
|
exports.useWizard = injectWizard.useWizard;
|
|
52
52
|
exports.fieldMeta = fieldMeta;
|
|
53
53
|
exports.useForm = useForm;
|
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 { StorageShape as StorageShapeV4 } from '../zod-v4/types-storage-shape'\nimport type { StorageShape as StorageShapeV3 } from '../zod-v3/types-storage-shape'\nimport type { UnwrapZodObject } from '../zod-v3/types-zod-adapter'\nimport type {\n AbstractSchema,\n FormKey,\n ValidateOnConfig,\n UseFormReturnType,\n UseFormConfiguration,\n} from '../../types/types-api'\nimport type { DefaultValuesInput, GenericForm } from '../../types/types-core'\n\n// ───────────────────────────────────────────────────────────────────\n// Per-major projection helpers. Each overload's constraint scopes the\n// Schema to one Zod major, so the projection is a direct read — no\n// dispatch in the type body. Mirrors the direct adapter shapes so the\n// unified entry pays the same per-call depth cost as a direct import.\n// ───────────────────────────────────────────────────────────────────\n\ntype V4FormOf<S extends z.ZodObject> = z.input<S> extends GenericForm ? z.input<S> : never\ntype V4OutOf<S extends z.ZodObject> = z.output<S> extends GenericForm ? z.output<S> : never\ntype V4ReadOf<S extends z.ZodObject> =\n StorageShapeV4<S> extends GenericForm ? StorageShapeV4<S> : never\n\ntype V3FormOf<S extends zV3.ZodObject<zV3.ZodRawShape>> =\n zV3.input<UnwrapZodObject<S>> extends GenericForm ? zV3.input<UnwrapZodObject<S>> : never\ntype V3OutOf<S extends zV3.ZodObject<zV3.ZodRawShape>> =\n zV3.output<UnwrapZodObject<S>> extends GenericForm ? zV3.output<UnwrapZodObject<S>> : never\ntype V3ReadOf<S extends zV3.ZodObject<zV3.ZodRawShape>> =\n StorageShapeV3<UnwrapZodObject<S>> extends GenericForm\n ? StorageShapeV3<UnwrapZodObject<S>>\n : never\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;;AC8FO,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;;ACpHO,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 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;;;;;;;;;;;;;;"}
|