attaform 0.16.1 → 0.16.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/README.md +11 -13
  2. package/dist/index.d.cts +3 -3
  3. package/dist/index.d.mts +3 -3
  4. package/dist/index.d.ts +3 -3
  5. package/dist/nuxt.d.cts +1 -1
  6. package/dist/nuxt.d.mts +1 -1
  7. package/dist/nuxt.d.ts +1 -1
  8. package/dist/shared/{attaform.CVv9Oh0a.d.mts → attaform.Bls_kFR6.d.mts} +1 -1
  9. package/dist/shared/attaform.C8CyvYa_.cjs +36 -0
  10. package/dist/shared/attaform.C8CyvYa_.cjs.map +1 -0
  11. package/dist/shared/attaform.C9Ph2SMx.cjs.map +1 -1
  12. package/dist/shared/{attaform.DdnithOf.mjs → attaform.CFA6y0KF.mjs} +6 -17
  13. package/dist/shared/attaform.CFA6y0KF.mjs.map +1 -0
  14. package/dist/shared/attaform.D13GMFgK.mjs +32 -0
  15. package/dist/shared/attaform.D13GMFgK.mjs.map +1 -0
  16. package/dist/shared/{attaform.DfrYByDj.cjs → attaform.DGuGGNg9.cjs} +8 -15
  17. package/dist/shared/attaform.DGuGGNg9.cjs.map +1 -0
  18. package/dist/shared/attaform.DILbdvfo.mjs.map +1 -1
  19. package/dist/shared/{attaform.Dq5BabH1.d.cts → attaform.DLnKT7wk.d.cts} +1 -1
  20. package/dist/shared/{attaform.Bp1c-uGF.cjs → attaform.KrNw10aW.cjs} +6 -17
  21. package/dist/shared/attaform.KrNw10aW.cjs.map +1 -0
  22. package/dist/shared/{attaform.CvOXSpCb.mjs → attaform.XYOMTvuO.mjs} +8 -15
  23. package/dist/shared/attaform.XYOMTvuO.mjs.map +1 -0
  24. package/dist/shared/{attaform.0Gxd_OOx.d.cts → attaform._EqYNPYF.d.cts} +21 -13
  25. package/dist/shared/{attaform.0Gxd_OOx.d.mts → attaform._EqYNPYF.d.mts} +21 -13
  26. package/dist/shared/{attaform.0Gxd_OOx.d.ts → attaform._EqYNPYF.d.ts} +21 -13
  27. package/dist/shared/{attaform.CWCx2r0x.d.ts → attaform.lFNwBcA3.d.ts} +1 -1
  28. package/dist/zod-v3.cjs +1 -1
  29. package/dist/zod-v3.d.cts +19 -14
  30. package/dist/zod-v3.d.mts +19 -14
  31. package/dist/zod-v3.d.ts +19 -14
  32. package/dist/zod-v3.mjs +1 -1
  33. package/dist/zod-v4.cjs +1 -1
  34. package/dist/zod-v4.d.cts +94 -5
  35. package/dist/zod-v4.d.mts +94 -5
  36. package/dist/zod-v4.d.ts +94 -5
  37. package/dist/zod-v4.mjs +1 -1
  38. package/dist/zod.cjs +22 -4
  39. package/dist/zod.cjs.map +1 -1
  40. package/dist/zod.d.cts +51 -7
  41. package/dist/zod.d.mts +51 -7
  42. package/dist/zod.d.ts +51 -7
  43. package/dist/zod.mjs +21 -4
  44. package/dist/zod.mjs.map +1 -1
  45. package/package.json +1 -1
  46. package/dist/shared/attaform.BAuJTWuT.d.mts +0 -84
  47. package/dist/shared/attaform.Bp1c-uGF.cjs.map +0 -1
  48. package/dist/shared/attaform.CvOXSpCb.mjs.map +0 -1
  49. package/dist/shared/attaform.DdnithOf.mjs.map +0 -1
  50. package/dist/shared/attaform.DfrYByDj.cjs.map +0 -1
  51. package/dist/shared/attaform.ls_7jBYc.d.ts +0 -84
  52. package/dist/shared/attaform.xIcmqscx.d.cts +0 -84
@@ -2,14 +2,22 @@ import { Ref, ObjectDirective, ComputedRef } from 'vue';
2
2
 
3
3
  /**
4
4
  * Schema-attached field metadata — the shared types used by both Zod
5
- * adapters (`attaform/zod` for v4 and `attaform/zod-v3` for v3) so a
6
- * consumer's data flow reads the same shape regardless of adapter.
7
- *
8
- * The Zod 4 adapter creates a typed `z.registry<FieldMetaPayload>()`
9
- * and writes through `schema.register(fieldMeta, payload)` (native) or
10
- * the `withMeta(schema, payload)` helper. The Zod 3 adapter has no
11
- * native registry it shims a `WeakMap<ZodTypeAny, FieldMetaPayload>`
12
- * with the same write API via `withMeta`.
5
+ * adapters and the unified `attaform/zod` entry so a consumer's data
6
+ * flow reads the same shape regardless of which path runs at lookup.
7
+ *
8
+ * Storage lives in the cross-adapter `field-meta-store` core: a pair
9
+ * of WeakMaps (single-payload for last-write-wins reads, list-of-
10
+ * payloads for shared-schema disambiguation). Every entry's
11
+ * `fieldMeta` re-exports the same registry-shaped object, so
12
+ * `withMeta`/`fieldMeta.add` writes from one entry surface at lookup
13
+ * through any other.
14
+ *
15
+ * `withMeta(schema, payload)` clones the schema before registering,
16
+ * so each call gets fresh identity (the WeakMap keys on reference).
17
+ * The cloning strategy depends on the major: Zod 4 schemas use the
18
+ * native `.clone()`, Zod 3 schemas reconstruct via constructor +
19
+ * `_def`. The unified entry's `withMeta` runtime-branches on which
20
+ * one is in play.
13
21
  *
14
22
  * Reads are unified through `AbstractSchema.getFieldMetaAtPath(path)`,
15
23
  * which returns a fully-resolved `ResolvedFieldMeta` (label /
@@ -844,8 +852,8 @@ type AbstractSchema<Form, GetValueFormType> = {
844
852
  * Return the resolved field metadata for the schema node at `path`
845
853
  * — label, description, placeholder, plus the full registered
846
854
  * payload as `meta` for consumer-augmented keys. Reads through the
847
- * adapter's metadata mechanism (Zod 4: `z.registry()`; Zod 3:
848
- * a WeakMap shim) and applies these one-way fallbacks:
855
+ * shared cross-adapter field-meta store and applies these one-way
856
+ * fallbacks:
849
857
  *
850
858
  * - `label`: registry payload → `humanize(lastSegment)`
851
859
  * - `description`: registry payload → `schema.description`
@@ -2071,9 +2079,9 @@ type FieldState<Value = unknown> = {
2071
2079
  readonly blank: boolean;
2072
2080
  /**
2073
2081
  * Presentational label for this field. Resolves through the
2074
- * adapter's metadata mechanismZod 4's `z.registry()` (typed
2075
- * payload via `schema.register(fieldMeta, {...})` or the
2076
- * `withMeta()` helper); Zod 3's WeakMap shim — and falls back to
2082
+ * shared cross-adapter field-meta storewritten via
2083
+ * `schema.register(fieldMeta, {...})` (Zod 4 native chain) or the
2084
+ * `withMeta()` helper (works on both majors) — and falls back to
2077
2085
  * a humanized form of the path's last segment when nothing has
2078
2086
  * been registered. Always a string.
2079
2087
  *
@@ -1,4 +1,4 @@
1
- import { G as GenericForm, F as FormKey, d as UseFormReturnType, R as RegisterValue } from './attaform.0Gxd_OOx.js';
1
+ import { G as GenericForm, F as FormKey, d as UseFormReturnType, R as RegisterValue } from './attaform._EqYNPYF.js';
2
2
  import { Ref } from 'vue';
3
3
 
4
4
  /**
package/dist/zod-v3.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const useForm = require('./shared/attaform.Bp1c-uGF.cjs');
3
+ const useForm = require('./shared/attaform.KrNw10aW.cjs');
4
4
  const useFormContext = require('./shared/attaform.C9Ph2SMx.cjs');
5
5
  const plugin = require('./shared/attaform.rIRYSUI1.cjs');
6
6
 
package/dist/zod-v3.d.cts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { z } from 'zod';
2
- import { ae as ValidateOnConfig, F as FormKey, B as OnInvalidSubmitPolicy, W as PersistConfig, x as HistoryConfig, C as CoercionRegistry, G as GenericForm, U as UseFormConfiguration, b as AbstractSchema, D as DeepPartial, c as DefaultValuesShape, d as UseFormReturnType, n as FieldMetaPayload } from './shared/attaform.0Gxd_OOx.cjs';
3
- export { ac as Unset, am as isUnset, ao as unset } from './shared/attaform.0Gxd_OOx.cjs';
4
- export { A as AttaformErrorCode, i as injectForm, u as useRegister } from './shared/attaform.Dq5BabH1.cjs';
2
+ import { ae as ValidateOnConfig, F as FormKey, B as OnInvalidSubmitPolicy, W as PersistConfig, x as HistoryConfig, C as CoercionRegistry, G as GenericForm, U as UseFormConfiguration, b as AbstractSchema, D as DeepPartial, c as DefaultValuesShape, d as UseFormReturnType, n as FieldMetaPayload } from './shared/attaform._EqYNPYF.cjs';
3
+ export { ac as Unset, am as isUnset, ao as unset } from './shared/attaform._EqYNPYF.cjs';
4
+ export { A as AttaformErrorCode, i as injectForm, u as useRegister } from './shared/attaform.DLnKT7wk.cjs';
5
5
  import 'vue';
6
6
 
7
7
  /**
@@ -163,11 +163,16 @@ declare function isZodSchemaType<K extends keyof ZodTypeMap>(schema: unknown, ex
163
163
  /**
164
164
  * Field-metadata write/read API for the Zod v3 adapter.
165
165
  *
166
- * Zod 3 has no `z.registry()` mechanism, so we shim one with a
167
- * module-scoped `WeakMap<ZodTypeAny, FieldMetaPayload>` plus a
168
- * registry-shaped object exposing `add` / `get` / `has`. The public
169
- * `withMeta(schema, payload)` write API matches `attaform/zod` so
170
- * schema authoring reads identically across the two adapters.
166
+ * Storage lives in the shared `field-meta-store` core every entry
167
+ * (`attaform/zod`, `attaform/zod-v3`, `attaform/zod-v4`) writes to and
168
+ * reads from the same `WeakMap`s, so a payload registered via any
169
+ * entry surfaces at lookup regardless of which adapter actually runs.
170
+ *
171
+ * Zod 3 has no `z.registry()` mechanism, so `fieldMeta` is the
172
+ * shared registry-shaped object exposing `add` / `get` / `has` /
173
+ * `remove`. The public `withMeta(schema, payload)` write API matches
174
+ * `attaform/zod`'s so schema authoring reads identically across the
175
+ * two adapters.
171
176
  *
172
177
  * **Registration patterns:** both styles work — register on whatever
173
178
  * schema reference you assign into the parent's shape, OR on the
@@ -186,9 +191,9 @@ declare function isZodSchemaType<K extends keyof ZodTypeMap>(schema: unknown, ex
186
191
 
187
192
  /**
188
193
  * The shared registry every Attaform-aware Zod 3 schema can register
189
- * field metadata against. Exposes a registry-shaped surface so that
190
- * v3 user code can use the same idiom v4 users do (`fieldMeta.add(schema,
191
- * payload)`); under the hood it's just a `WeakMap`.
194
+ * field metadata against. Backed by the cross-adapter
195
+ * `fieldMetaStore` a payload registered here is visible to the v4
196
+ * adapter and the unified `attaform/zod` entry, and vice versa.
192
197
  */
193
198
  type FieldMetaRegistryV3 = {
194
199
  /**
@@ -210,7 +215,7 @@ declare const fieldMeta: FieldMetaRegistryV3;
210
215
  * and return a clone of `schema` (chainable, with the new metadata).
211
216
  * Cross-version with `attaform/zod`'s `withMeta()`.
212
217
  *
213
- * **Why clone, not mutate.** The WeakMap shim keys metadata on the
218
+ * **Why clone, not mutate.** The shared store keys metadata on the
214
219
  * schema reference. Calling `withMeta` twice on the same instance
215
220
  * would overwrite (last-write-wins) — so a sub-schema reused at
216
221
  * multiple form paths (e.g. an address schema shared between pickup
@@ -228,8 +233,8 @@ declare const fieldMeta: FieldMetaRegistryV3;
228
233
  * registers once and surfaces at every path.
229
234
  *
230
235
  * `schema.register()` does NOT exist on Zod 3 — `withMeta` is the
231
- * only write API. Register on the inner schema before wrapping;
232
- * see the "Registration rule" note in this file's header.
236
+ * only fluent write API. Register on the inner schema before
237
+ * wrapping; see the "Registration rule" note in this file's header.
233
238
  */
234
239
  declare function withMeta<S extends z.ZodTypeAny>(schema: S, payload: FieldMetaPayload): S;
235
240
 
package/dist/zod-v3.d.mts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { z } from 'zod';
2
- import { ae as ValidateOnConfig, F as FormKey, B as OnInvalidSubmitPolicy, W as PersistConfig, x as HistoryConfig, C as CoercionRegistry, G as GenericForm, U as UseFormConfiguration, b as AbstractSchema, D as DeepPartial, c as DefaultValuesShape, d as UseFormReturnType, n as FieldMetaPayload } from './shared/attaform.0Gxd_OOx.mjs';
3
- export { ac as Unset, am as isUnset, ao as unset } from './shared/attaform.0Gxd_OOx.mjs';
4
- export { A as AttaformErrorCode, i as injectForm, u as useRegister } from './shared/attaform.CVv9Oh0a.mjs';
2
+ import { ae as ValidateOnConfig, F as FormKey, B as OnInvalidSubmitPolicy, W as PersistConfig, x as HistoryConfig, C as CoercionRegistry, G as GenericForm, U as UseFormConfiguration, b as AbstractSchema, D as DeepPartial, c as DefaultValuesShape, d as UseFormReturnType, n as FieldMetaPayload } from './shared/attaform._EqYNPYF.mjs';
3
+ export { ac as Unset, am as isUnset, ao as unset } from './shared/attaform._EqYNPYF.mjs';
4
+ export { A as AttaformErrorCode, i as injectForm, u as useRegister } from './shared/attaform.Bls_kFR6.mjs';
5
5
  import 'vue';
6
6
 
7
7
  /**
@@ -163,11 +163,16 @@ declare function isZodSchemaType<K extends keyof ZodTypeMap>(schema: unknown, ex
163
163
  /**
164
164
  * Field-metadata write/read API for the Zod v3 adapter.
165
165
  *
166
- * Zod 3 has no `z.registry()` mechanism, so we shim one with a
167
- * module-scoped `WeakMap<ZodTypeAny, FieldMetaPayload>` plus a
168
- * registry-shaped object exposing `add` / `get` / `has`. The public
169
- * `withMeta(schema, payload)` write API matches `attaform/zod` so
170
- * schema authoring reads identically across the two adapters.
166
+ * Storage lives in the shared `field-meta-store` core every entry
167
+ * (`attaform/zod`, `attaform/zod-v3`, `attaform/zod-v4`) writes to and
168
+ * reads from the same `WeakMap`s, so a payload registered via any
169
+ * entry surfaces at lookup regardless of which adapter actually runs.
170
+ *
171
+ * Zod 3 has no `z.registry()` mechanism, so `fieldMeta` is the
172
+ * shared registry-shaped object exposing `add` / `get` / `has` /
173
+ * `remove`. The public `withMeta(schema, payload)` write API matches
174
+ * `attaform/zod`'s so schema authoring reads identically across the
175
+ * two adapters.
171
176
  *
172
177
  * **Registration patterns:** both styles work — register on whatever
173
178
  * schema reference you assign into the parent's shape, OR on the
@@ -186,9 +191,9 @@ declare function isZodSchemaType<K extends keyof ZodTypeMap>(schema: unknown, ex
186
191
 
187
192
  /**
188
193
  * The shared registry every Attaform-aware Zod 3 schema can register
189
- * field metadata against. Exposes a registry-shaped surface so that
190
- * v3 user code can use the same idiom v4 users do (`fieldMeta.add(schema,
191
- * payload)`); under the hood it's just a `WeakMap`.
194
+ * field metadata against. Backed by the cross-adapter
195
+ * `fieldMetaStore` a payload registered here is visible to the v4
196
+ * adapter and the unified `attaform/zod` entry, and vice versa.
192
197
  */
193
198
  type FieldMetaRegistryV3 = {
194
199
  /**
@@ -210,7 +215,7 @@ declare const fieldMeta: FieldMetaRegistryV3;
210
215
  * and return a clone of `schema` (chainable, with the new metadata).
211
216
  * Cross-version with `attaform/zod`'s `withMeta()`.
212
217
  *
213
- * **Why clone, not mutate.** The WeakMap shim keys metadata on the
218
+ * **Why clone, not mutate.** The shared store keys metadata on the
214
219
  * schema reference. Calling `withMeta` twice on the same instance
215
220
  * would overwrite (last-write-wins) — so a sub-schema reused at
216
221
  * multiple form paths (e.g. an address schema shared between pickup
@@ -228,8 +233,8 @@ declare const fieldMeta: FieldMetaRegistryV3;
228
233
  * registers once and surfaces at every path.
229
234
  *
230
235
  * `schema.register()` does NOT exist on Zod 3 — `withMeta` is the
231
- * only write API. Register on the inner schema before wrapping;
232
- * see the "Registration rule" note in this file's header.
236
+ * only fluent write API. Register on the inner schema before
237
+ * wrapping; see the "Registration rule" note in this file's header.
233
238
  */
234
239
  declare function withMeta<S extends z.ZodTypeAny>(schema: S, payload: FieldMetaPayload): S;
235
240
 
package/dist/zod-v3.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { z } from 'zod';
2
- import { ae as ValidateOnConfig, F as FormKey, B as OnInvalidSubmitPolicy, W as PersistConfig, x as HistoryConfig, C as CoercionRegistry, G as GenericForm, U as UseFormConfiguration, b as AbstractSchema, D as DeepPartial, c as DefaultValuesShape, d as UseFormReturnType, n as FieldMetaPayload } from './shared/attaform.0Gxd_OOx.js';
3
- export { ac as Unset, am as isUnset, ao as unset } from './shared/attaform.0Gxd_OOx.js';
4
- export { A as AttaformErrorCode, i as injectForm, u as useRegister } from './shared/attaform.CWCx2r0x.js';
2
+ import { ae as ValidateOnConfig, F as FormKey, B as OnInvalidSubmitPolicy, W as PersistConfig, x as HistoryConfig, C as CoercionRegistry, G as GenericForm, U as UseFormConfiguration, b as AbstractSchema, D as DeepPartial, c as DefaultValuesShape, d as UseFormReturnType, n as FieldMetaPayload } from './shared/attaform._EqYNPYF.js';
3
+ export { ac as Unset, am as isUnset, ao as unset } from './shared/attaform._EqYNPYF.js';
4
+ export { A as AttaformErrorCode, i as injectForm, u as useRegister } from './shared/attaform.lFNwBcA3.js';
5
5
  import 'vue';
6
6
 
7
7
  /**
@@ -163,11 +163,16 @@ declare function isZodSchemaType<K extends keyof ZodTypeMap>(schema: unknown, ex
163
163
  /**
164
164
  * Field-metadata write/read API for the Zod v3 adapter.
165
165
  *
166
- * Zod 3 has no `z.registry()` mechanism, so we shim one with a
167
- * module-scoped `WeakMap<ZodTypeAny, FieldMetaPayload>` plus a
168
- * registry-shaped object exposing `add` / `get` / `has`. The public
169
- * `withMeta(schema, payload)` write API matches `attaform/zod` so
170
- * schema authoring reads identically across the two adapters.
166
+ * Storage lives in the shared `field-meta-store` core every entry
167
+ * (`attaform/zod`, `attaform/zod-v3`, `attaform/zod-v4`) writes to and
168
+ * reads from the same `WeakMap`s, so a payload registered via any
169
+ * entry surfaces at lookup regardless of which adapter actually runs.
170
+ *
171
+ * Zod 3 has no `z.registry()` mechanism, so `fieldMeta` is the
172
+ * shared registry-shaped object exposing `add` / `get` / `has` /
173
+ * `remove`. The public `withMeta(schema, payload)` write API matches
174
+ * `attaform/zod`'s so schema authoring reads identically across the
175
+ * two adapters.
171
176
  *
172
177
  * **Registration patterns:** both styles work — register on whatever
173
178
  * schema reference you assign into the parent's shape, OR on the
@@ -186,9 +191,9 @@ declare function isZodSchemaType<K extends keyof ZodTypeMap>(schema: unknown, ex
186
191
 
187
192
  /**
188
193
  * The shared registry every Attaform-aware Zod 3 schema can register
189
- * field metadata against. Exposes a registry-shaped surface so that
190
- * v3 user code can use the same idiom v4 users do (`fieldMeta.add(schema,
191
- * payload)`); under the hood it's just a `WeakMap`.
194
+ * field metadata against. Backed by the cross-adapter
195
+ * `fieldMetaStore` a payload registered here is visible to the v4
196
+ * adapter and the unified `attaform/zod` entry, and vice versa.
192
197
  */
193
198
  type FieldMetaRegistryV3 = {
194
199
  /**
@@ -210,7 +215,7 @@ declare const fieldMeta: FieldMetaRegistryV3;
210
215
  * and return a clone of `schema` (chainable, with the new metadata).
211
216
  * Cross-version with `attaform/zod`'s `withMeta()`.
212
217
  *
213
- * **Why clone, not mutate.** The WeakMap shim keys metadata on the
218
+ * **Why clone, not mutate.** The shared store keys metadata on the
214
219
  * schema reference. Calling `withMeta` twice on the same instance
215
220
  * would overwrite (last-write-wins) — so a sub-schema reused at
216
221
  * multiple form paths (e.g. an address schema shared between pickup
@@ -228,8 +233,8 @@ declare const fieldMeta: FieldMetaRegistryV3;
228
233
  * registers once and surfaces at every path.
229
234
  *
230
235
  * `schema.register()` does NOT exist on Zod 3 — `withMeta` is the
231
- * only write API. Register on the inner schema before wrapping;
232
- * see the "Registration rule" note in this file's header.
236
+ * only fluent write API. Register on the inner schema before
237
+ * wrapping; see the "Registration rule" note in this file's header.
233
238
  */
234
239
  declare function withMeta<S extends z.ZodTypeAny>(schema: S, payload: FieldMetaPayload): S;
235
240
 
package/dist/zod-v3.mjs CHANGED
@@ -1,4 +1,4 @@
1
- export { f as fieldMeta, i as isZodSchemaType, u as useForm, w as withMeta, z as zodAdapter } from './shared/attaform.DdnithOf.mjs';
1
+ export { f as fieldMeta, i as isZodSchemaType, u as useForm, w as withMeta, z as zodAdapter } from './shared/attaform.CFA6y0KF.mjs';
2
2
  export { A as AttaformErrorCode, i as injectForm, a as isUnset, u as unset } from './shared/attaform.DILbdvfo.mjs';
3
3
  export { u as useRegister } from './shared/attaform.BfMxsfmE.mjs';
4
4
  //# sourceMappingURL=zod-v3.mjs.map
package/dist/zod-v4.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const index = require('./shared/attaform.DfrYByDj.cjs');
3
+ const index = require('./shared/attaform.DGuGGNg9.cjs');
4
4
  const useFormContext = require('./shared/attaform.C9Ph2SMx.cjs');
5
5
  const plugin = require('./shared/attaform.rIRYSUI1.cjs');
6
6
 
package/dist/zod-v4.d.cts CHANGED
@@ -1,8 +1,7 @@
1
1
  import { z } from 'zod';
2
- import { F as FormKey, b as AbstractSchema, U as UseFormConfiguration, G as GenericForm, D as DeepPartial, c as DefaultValuesShape, ae as ValidateOnConfig, d as UseFormReturnType } from './shared/attaform.0Gxd_OOx.cjs';
3
- export { n as FieldMetaPayload, ac as Unset, am as isUnset, ao as unset } from './shared/attaform.0Gxd_OOx.cjs';
4
- export { A as AttaformErrorCode, i as injectForm, u as useRegister } from './shared/attaform.Dq5BabH1.cjs';
5
- export { f as fieldMeta, w as withMeta } from './shared/attaform.xIcmqscx.cjs';
2
+ import { F as FormKey, b as AbstractSchema, U as UseFormConfiguration, G as GenericForm, D as DeepPartial, c as DefaultValuesShape, ae as ValidateOnConfig, d as UseFormReturnType, n as FieldMetaPayload } from './shared/attaform._EqYNPYF.cjs';
3
+ export { ac as Unset, am as isUnset, ao as unset } from './shared/attaform._EqYNPYF.cjs';
4
+ export { A as AttaformErrorCode, i as injectForm, u as useRegister } from './shared/attaform.DLnKT7wk.cjs';
6
5
  import { a as AttaformError } from './shared/attaform.B7rzpK1U.cjs';
7
6
  import 'vue';
8
7
 
@@ -100,5 +99,95 @@ declare function useForm<Schema extends z.ZodObject>(configuration: Omit<UseForm
100
99
  schema: Schema;
101
100
  } & ValidateOnConfig): UseFormReturnType<z.output<Schema> extends GenericForm ? z.output<Schema> : never, z.output<Schema> extends GenericForm ? z.output<Schema> : never>;
102
101
 
103
- export { UnsupportedSchemaError, assertZodVersion, kindOf, useForm, zodV4Adapter as zodAdapter };
102
+ /**
103
+ * Field-metadata write/read API for the Zod v4 adapter.
104
+ *
105
+ * Storage lives in the shared `field-meta-store` core — every entry
106
+ * (`attaform/zod`, `attaform/zod-v3`, `attaform/zod-v4`) writes to and
107
+ * reads from the same `WeakMap`s, so a payload registered via any
108
+ * entry surfaces at lookup regardless of which adapter actually runs.
109
+ *
110
+ * The native chain `schema.register(fieldMeta, payload)` still works
111
+ * — Zod 4's `.register` calls `registry.add(this, payload)` and
112
+ * returns the schema; the shared store satisfies that structurally.
113
+ *
114
+ * **Registration patterns:** both styles work — register on whatever
115
+ * schema reference you assign into the parent's shape, OR on the
116
+ * inner schema before wrapping. The adapter's resolver tries the
117
+ * walker-returned schema first, then falls back to the peeled
118
+ * inner so either ordering hits:
119
+ *
120
+ * // both equivalent — registry hits at lookup time
121
+ * withMeta(z.string(), { label: 'Email' }).optional()
122
+ * withMeta(z.string().optional(), { label: 'Email' })
123
+ * z.string().optional().register(fieldMeta, { label: 'Email' })
124
+ * z.string().register(fieldMeta, { label: 'Email' }).optional()
125
+ *
126
+ * The path walker returns the wrapper at terminal positions
127
+ * (`['email']` against `{ email: z.string().optional() }` resolves
128
+ * to `ZodOptional<ZodString>`) and peels at intermediate descent
129
+ * (`['address', 'street']` peels through `address`'s wrapper to
130
+ * reach the inner object). The two-stage lookup covers both leaf
131
+ * and container registrations symmetrically.
132
+ */
133
+
134
+ type ZodFieldMetaRegistry = ReturnType<typeof z.registry<FieldMetaPayload>>;
135
+ /**
136
+ * The shared registry every Attaform-aware Zod 4 schema can register
137
+ * field metadata against. Backed by the cross-adapter
138
+ * `fieldMetaStore` — one module-scoped instance, shared with the v3
139
+ * adapter and the unified `attaform/zod` entry, so a `.register()`
140
+ * chain in one place is read by adapters in another.
141
+ *
142
+ * Consumers extending `FieldMetaPayload` via declaration merging
143
+ * automatically get the richer payload type at every `register` /
144
+ * `add` / `get` call site.
145
+ *
146
+ * **Shared-instance disambiguation.** A single schema instance reused
147
+ * at multiple form paths (e.g. one address schema bound to both
148
+ * `pickup` and `delivery`) can carry distinct metadata per path —
149
+ * even via the canonical `schema.register(fieldMeta, payload)` chain.
150
+ * The shared store keeps a parallel list of every registration; the
151
+ * path-resolver walks the form's schema tree counting per-schema
152
+ * occurrences to pick the right payload for each path. Object
153
+ * literals evaluate left-to-right, so registration order matches
154
+ * tree-walk order, and shared schemas pair their two registrations
155
+ * to the two paths correctly:
156
+ *
157
+ * z.object({
158
+ * pickup: addressSchema.register(fieldMeta, { label: 'Pickup address' }),
159
+ * delivery: addressSchema.register(fieldMeta, { label: 'Delivery address' }),
160
+ * })
161
+ * // form.fields('pickup').label → 'Pickup address'
162
+ * // form.fields('delivery').label → 'Delivery address'
163
+ *
164
+ * Schemas reused via `withMeta()` get a fresh clone per call (see
165
+ * `withMeta` below), so they never share a registry slot in the
166
+ * first place.
167
+ *
168
+ * Cast to `z.$ZodRegistry<FieldMetaPayload>` so that
169
+ * `schema.register(fieldMeta, payload)` chains type-check at the call
170
+ * site — Zod 4's `.register()` only calls `.add(this, payload)`
171
+ * structurally, so the cast is sound at runtime.
172
+ */
173
+ declare const fieldMeta: ZodFieldMetaRegistry;
174
+ /**
175
+ * Attach `payload` to `schema` in the shared `fieldMeta` registry
176
+ * and return `schema` (chainable). Cross-version with `attaform/zod-v3`'s
177
+ * `withMeta()`; user code that uses this helper reads the same on
178
+ * either adapter.
179
+ *
180
+ * Equivalent to `schema.register(fieldMeta, payload)` on Zod 4.
181
+ * Prefer the native chain for v4-only code; reach for `withMeta`
182
+ * when authoring schema modules that may need to compile under both
183
+ * adapters.
184
+ *
185
+ * Registers on the schema reference passed in. See the
186
+ * "Registration rule" note in this file's header — register on the
187
+ * inner schema before wrapping with `.optional()` / `.nullable()` /
188
+ * `.default()` / etc.
189
+ */
190
+ declare function withMeta<S extends z.ZodType>(schema: S, payload: FieldMetaPayload): S;
191
+
192
+ export { FieldMetaPayload, UnsupportedSchemaError, assertZodVersion, fieldMeta, kindOf, useForm, withMeta, zodV4Adapter as zodAdapter };
104
193
  export type { ZodKind };
package/dist/zod-v4.d.mts CHANGED
@@ -1,8 +1,7 @@
1
1
  import { z } from 'zod';
2
- import { F as FormKey, b as AbstractSchema, U as UseFormConfiguration, G as GenericForm, D as DeepPartial, c as DefaultValuesShape, ae as ValidateOnConfig, d as UseFormReturnType } from './shared/attaform.0Gxd_OOx.mjs';
3
- export { n as FieldMetaPayload, ac as Unset, am as isUnset, ao as unset } from './shared/attaform.0Gxd_OOx.mjs';
4
- export { A as AttaformErrorCode, i as injectForm, u as useRegister } from './shared/attaform.CVv9Oh0a.mjs';
5
- export { f as fieldMeta, w as withMeta } from './shared/attaform.BAuJTWuT.mjs';
2
+ import { F as FormKey, b as AbstractSchema, U as UseFormConfiguration, G as GenericForm, D as DeepPartial, c as DefaultValuesShape, ae as ValidateOnConfig, d as UseFormReturnType, n as FieldMetaPayload } from './shared/attaform._EqYNPYF.mjs';
3
+ export { ac as Unset, am as isUnset, ao as unset } from './shared/attaform._EqYNPYF.mjs';
4
+ export { A as AttaformErrorCode, i as injectForm, u as useRegister } from './shared/attaform.Bls_kFR6.mjs';
6
5
  import { a as AttaformError } from './shared/attaform.B7rzpK1U.mjs';
7
6
  import 'vue';
8
7
 
@@ -100,5 +99,95 @@ declare function useForm<Schema extends z.ZodObject>(configuration: Omit<UseForm
100
99
  schema: Schema;
101
100
  } & ValidateOnConfig): UseFormReturnType<z.output<Schema> extends GenericForm ? z.output<Schema> : never, z.output<Schema> extends GenericForm ? z.output<Schema> : never>;
102
101
 
103
- export { UnsupportedSchemaError, assertZodVersion, kindOf, useForm, zodV4Adapter as zodAdapter };
102
+ /**
103
+ * Field-metadata write/read API for the Zod v4 adapter.
104
+ *
105
+ * Storage lives in the shared `field-meta-store` core — every entry
106
+ * (`attaform/zod`, `attaform/zod-v3`, `attaform/zod-v4`) writes to and
107
+ * reads from the same `WeakMap`s, so a payload registered via any
108
+ * entry surfaces at lookup regardless of which adapter actually runs.
109
+ *
110
+ * The native chain `schema.register(fieldMeta, payload)` still works
111
+ * — Zod 4's `.register` calls `registry.add(this, payload)` and
112
+ * returns the schema; the shared store satisfies that structurally.
113
+ *
114
+ * **Registration patterns:** both styles work — register on whatever
115
+ * schema reference you assign into the parent's shape, OR on the
116
+ * inner schema before wrapping. The adapter's resolver tries the
117
+ * walker-returned schema first, then falls back to the peeled
118
+ * inner so either ordering hits:
119
+ *
120
+ * // both equivalent — registry hits at lookup time
121
+ * withMeta(z.string(), { label: 'Email' }).optional()
122
+ * withMeta(z.string().optional(), { label: 'Email' })
123
+ * z.string().optional().register(fieldMeta, { label: 'Email' })
124
+ * z.string().register(fieldMeta, { label: 'Email' }).optional()
125
+ *
126
+ * The path walker returns the wrapper at terminal positions
127
+ * (`['email']` against `{ email: z.string().optional() }` resolves
128
+ * to `ZodOptional<ZodString>`) and peels at intermediate descent
129
+ * (`['address', 'street']` peels through `address`'s wrapper to
130
+ * reach the inner object). The two-stage lookup covers both leaf
131
+ * and container registrations symmetrically.
132
+ */
133
+
134
+ type ZodFieldMetaRegistry = ReturnType<typeof z.registry<FieldMetaPayload>>;
135
+ /**
136
+ * The shared registry every Attaform-aware Zod 4 schema can register
137
+ * field metadata against. Backed by the cross-adapter
138
+ * `fieldMetaStore` — one module-scoped instance, shared with the v3
139
+ * adapter and the unified `attaform/zod` entry, so a `.register()`
140
+ * chain in one place is read by adapters in another.
141
+ *
142
+ * Consumers extending `FieldMetaPayload` via declaration merging
143
+ * automatically get the richer payload type at every `register` /
144
+ * `add` / `get` call site.
145
+ *
146
+ * **Shared-instance disambiguation.** A single schema instance reused
147
+ * at multiple form paths (e.g. one address schema bound to both
148
+ * `pickup` and `delivery`) can carry distinct metadata per path —
149
+ * even via the canonical `schema.register(fieldMeta, payload)` chain.
150
+ * The shared store keeps a parallel list of every registration; the
151
+ * path-resolver walks the form's schema tree counting per-schema
152
+ * occurrences to pick the right payload for each path. Object
153
+ * literals evaluate left-to-right, so registration order matches
154
+ * tree-walk order, and shared schemas pair their two registrations
155
+ * to the two paths correctly:
156
+ *
157
+ * z.object({
158
+ * pickup: addressSchema.register(fieldMeta, { label: 'Pickup address' }),
159
+ * delivery: addressSchema.register(fieldMeta, { label: 'Delivery address' }),
160
+ * })
161
+ * // form.fields('pickup').label → 'Pickup address'
162
+ * // form.fields('delivery').label → 'Delivery address'
163
+ *
164
+ * Schemas reused via `withMeta()` get a fresh clone per call (see
165
+ * `withMeta` below), so they never share a registry slot in the
166
+ * first place.
167
+ *
168
+ * Cast to `z.$ZodRegistry<FieldMetaPayload>` so that
169
+ * `schema.register(fieldMeta, payload)` chains type-check at the call
170
+ * site — Zod 4's `.register()` only calls `.add(this, payload)`
171
+ * structurally, so the cast is sound at runtime.
172
+ */
173
+ declare const fieldMeta: ZodFieldMetaRegistry;
174
+ /**
175
+ * Attach `payload` to `schema` in the shared `fieldMeta` registry
176
+ * and return `schema` (chainable). Cross-version with `attaform/zod-v3`'s
177
+ * `withMeta()`; user code that uses this helper reads the same on
178
+ * either adapter.
179
+ *
180
+ * Equivalent to `schema.register(fieldMeta, payload)` on Zod 4.
181
+ * Prefer the native chain for v4-only code; reach for `withMeta`
182
+ * when authoring schema modules that may need to compile under both
183
+ * adapters.
184
+ *
185
+ * Registers on the schema reference passed in. See the
186
+ * "Registration rule" note in this file's header — register on the
187
+ * inner schema before wrapping with `.optional()` / `.nullable()` /
188
+ * `.default()` / etc.
189
+ */
190
+ declare function withMeta<S extends z.ZodType>(schema: S, payload: FieldMetaPayload): S;
191
+
192
+ export { FieldMetaPayload, UnsupportedSchemaError, assertZodVersion, fieldMeta, kindOf, useForm, withMeta, zodV4Adapter as zodAdapter };
104
193
  export type { ZodKind };
package/dist/zod-v4.d.ts CHANGED
@@ -1,8 +1,7 @@
1
1
  import { z } from 'zod';
2
- import { F as FormKey, b as AbstractSchema, U as UseFormConfiguration, G as GenericForm, D as DeepPartial, c as DefaultValuesShape, ae as ValidateOnConfig, d as UseFormReturnType } from './shared/attaform.0Gxd_OOx.js';
3
- export { n as FieldMetaPayload, ac as Unset, am as isUnset, ao as unset } from './shared/attaform.0Gxd_OOx.js';
4
- export { A as AttaformErrorCode, i as injectForm, u as useRegister } from './shared/attaform.CWCx2r0x.js';
5
- export { f as fieldMeta, w as withMeta } from './shared/attaform.ls_7jBYc.js';
2
+ import { F as FormKey, b as AbstractSchema, U as UseFormConfiguration, G as GenericForm, D as DeepPartial, c as DefaultValuesShape, ae as ValidateOnConfig, d as UseFormReturnType, n as FieldMetaPayload } from './shared/attaform._EqYNPYF.js';
3
+ export { ac as Unset, am as isUnset, ao as unset } from './shared/attaform._EqYNPYF.js';
4
+ export { A as AttaformErrorCode, i as injectForm, u as useRegister } from './shared/attaform.lFNwBcA3.js';
6
5
  import { a as AttaformError } from './shared/attaform.B7rzpK1U.js';
7
6
  import 'vue';
8
7
 
@@ -100,5 +99,95 @@ declare function useForm<Schema extends z.ZodObject>(configuration: Omit<UseForm
100
99
  schema: Schema;
101
100
  } & ValidateOnConfig): UseFormReturnType<z.output<Schema> extends GenericForm ? z.output<Schema> : never, z.output<Schema> extends GenericForm ? z.output<Schema> : never>;
102
101
 
103
- export { UnsupportedSchemaError, assertZodVersion, kindOf, useForm, zodV4Adapter as zodAdapter };
102
+ /**
103
+ * Field-metadata write/read API for the Zod v4 adapter.
104
+ *
105
+ * Storage lives in the shared `field-meta-store` core — every entry
106
+ * (`attaform/zod`, `attaform/zod-v3`, `attaform/zod-v4`) writes to and
107
+ * reads from the same `WeakMap`s, so a payload registered via any
108
+ * entry surfaces at lookup regardless of which adapter actually runs.
109
+ *
110
+ * The native chain `schema.register(fieldMeta, payload)` still works
111
+ * — Zod 4's `.register` calls `registry.add(this, payload)` and
112
+ * returns the schema; the shared store satisfies that structurally.
113
+ *
114
+ * **Registration patterns:** both styles work — register on whatever
115
+ * schema reference you assign into the parent's shape, OR on the
116
+ * inner schema before wrapping. The adapter's resolver tries the
117
+ * walker-returned schema first, then falls back to the peeled
118
+ * inner so either ordering hits:
119
+ *
120
+ * // both equivalent — registry hits at lookup time
121
+ * withMeta(z.string(), { label: 'Email' }).optional()
122
+ * withMeta(z.string().optional(), { label: 'Email' })
123
+ * z.string().optional().register(fieldMeta, { label: 'Email' })
124
+ * z.string().register(fieldMeta, { label: 'Email' }).optional()
125
+ *
126
+ * The path walker returns the wrapper at terminal positions
127
+ * (`['email']` against `{ email: z.string().optional() }` resolves
128
+ * to `ZodOptional<ZodString>`) and peels at intermediate descent
129
+ * (`['address', 'street']` peels through `address`'s wrapper to
130
+ * reach the inner object). The two-stage lookup covers both leaf
131
+ * and container registrations symmetrically.
132
+ */
133
+
134
+ type ZodFieldMetaRegistry = ReturnType<typeof z.registry<FieldMetaPayload>>;
135
+ /**
136
+ * The shared registry every Attaform-aware Zod 4 schema can register
137
+ * field metadata against. Backed by the cross-adapter
138
+ * `fieldMetaStore` — one module-scoped instance, shared with the v3
139
+ * adapter and the unified `attaform/zod` entry, so a `.register()`
140
+ * chain in one place is read by adapters in another.
141
+ *
142
+ * Consumers extending `FieldMetaPayload` via declaration merging
143
+ * automatically get the richer payload type at every `register` /
144
+ * `add` / `get` call site.
145
+ *
146
+ * **Shared-instance disambiguation.** A single schema instance reused
147
+ * at multiple form paths (e.g. one address schema bound to both
148
+ * `pickup` and `delivery`) can carry distinct metadata per path —
149
+ * even via the canonical `schema.register(fieldMeta, payload)` chain.
150
+ * The shared store keeps a parallel list of every registration; the
151
+ * path-resolver walks the form's schema tree counting per-schema
152
+ * occurrences to pick the right payload for each path. Object
153
+ * literals evaluate left-to-right, so registration order matches
154
+ * tree-walk order, and shared schemas pair their two registrations
155
+ * to the two paths correctly:
156
+ *
157
+ * z.object({
158
+ * pickup: addressSchema.register(fieldMeta, { label: 'Pickup address' }),
159
+ * delivery: addressSchema.register(fieldMeta, { label: 'Delivery address' }),
160
+ * })
161
+ * // form.fields('pickup').label → 'Pickup address'
162
+ * // form.fields('delivery').label → 'Delivery address'
163
+ *
164
+ * Schemas reused via `withMeta()` get a fresh clone per call (see
165
+ * `withMeta` below), so they never share a registry slot in the
166
+ * first place.
167
+ *
168
+ * Cast to `z.$ZodRegistry<FieldMetaPayload>` so that
169
+ * `schema.register(fieldMeta, payload)` chains type-check at the call
170
+ * site — Zod 4's `.register()` only calls `.add(this, payload)`
171
+ * structurally, so the cast is sound at runtime.
172
+ */
173
+ declare const fieldMeta: ZodFieldMetaRegistry;
174
+ /**
175
+ * Attach `payload` to `schema` in the shared `fieldMeta` registry
176
+ * and return `schema` (chainable). Cross-version with `attaform/zod-v3`'s
177
+ * `withMeta()`; user code that uses this helper reads the same on
178
+ * either adapter.
179
+ *
180
+ * Equivalent to `schema.register(fieldMeta, payload)` on Zod 4.
181
+ * Prefer the native chain for v4-only code; reach for `withMeta`
182
+ * when authoring schema modules that may need to compile under both
183
+ * adapters.
184
+ *
185
+ * Registers on the schema reference passed in. See the
186
+ * "Registration rule" note in this file's header — register on the
187
+ * inner schema before wrapping with `.optional()` / `.nullable()` /
188
+ * `.default()` / etc.
189
+ */
190
+ declare function withMeta<S extends z.ZodType>(schema: S, payload: FieldMetaPayload): S;
191
+
192
+ export { FieldMetaPayload, UnsupportedSchemaError, assertZodVersion, fieldMeta, kindOf, useForm, withMeta, zodV4Adapter as zodAdapter };
104
193
  export type { ZodKind };
package/dist/zod-v4.mjs CHANGED
@@ -1,4 +1,4 @@
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.CvOXSpCb.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.XYOMTvuO.mjs';
2
2
  export { A as AttaformErrorCode, i as injectForm, a as isUnset, u as unset } from './shared/attaform.DILbdvfo.mjs';
3
3
  export { u as useRegister } from './shared/attaform.BfMxsfmE.mjs';
4
4
  //# sourceMappingURL=zod-v4.mjs.map