attaform 0.27.6 → 0.28.0

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 (184) hide show
  1. package/dist/abstract.d.mts +5 -4
  2. package/dist/abstract.mjs +4 -3
  3. package/dist/chunks/fingerprint.mjs +0 -1
  4. package/dist/chunks/fingerprint2.mjs +1 -2
  5. package/dist/dev/abstract.mjs +4 -0
  6. package/dist/{chunks → dev/chunks}/dev-key-collision-warnings.mjs +0 -1
  7. package/dist/{chunks → dev/chunks}/devtools.mjs +5 -6
  8. package/dist/{chunks/fingerprint.cjs → dev/chunks/fingerprint.mjs} +7 -10
  9. package/dist/{chunks/fingerprint2.cjs → dev/chunks/fingerprint2.mjs} +32 -35
  10. package/dist/dev/directive.mjs +1 -0
  11. package/dist/dev/history.mjs +89 -0
  12. package/dist/dev/index.mjs +5 -0
  13. package/dist/dev/runtime/plugins/attaform.mjs +40 -0
  14. package/dist/{shared/attaform.D6tk90Rc.cjs → dev/shared/attaform-dev.6qxD-Yqo.mjs} +187 -43
  15. package/dist/{shared/attaform.CQN9R62B.cjs → dev/shared/attaform-dev.BJGA_UOS.mjs} +1 -4
  16. package/dist/{shared/attaform.DYEr28Pt.mjs → dev/shared/attaform-dev.BR8u0YOZ.mjs} +6 -7
  17. package/dist/dev/shared/attaform-dev.BXE2cr0L.mjs +220 -0
  18. package/dist/dev/shared/attaform-dev.By4PRjt0.mjs +248 -0
  19. package/dist/{shared/attaform.B1ZYt2Li.mjs → dev/shared/attaform-dev.D2I8e_Mm.mjs} +132 -568
  20. package/dist/dev/shared/attaform-dev.Dr2YzS5B.mjs +197 -0
  21. package/dist/{shared/attaform.nMaz2C5P.mjs → dev/shared/attaform-dev.P7cseiEG.mjs} +178 -397
  22. package/dist/{shared/attaform.CKH2lGdL.mjs → dev/shared/attaform-dev.WmuhD_CZ.mjs} +3944 -5056
  23. package/dist/{shared/attaform.DMxM2kol.mjs → dev/shared/attaform-dev.oYrkP9dj.mjs} +160 -508
  24. package/dist/dev/zod-v3.mjs +17 -0
  25. package/dist/dev/zod-v4.mjs +16 -0
  26. package/dist/dev/zod.mjs +5 -0
  27. package/dist/directive.d.mts +20 -0
  28. package/dist/directive.mjs +1 -0
  29. package/dist/esbuild.mjs +0 -1
  30. package/dist/history.d.mts +59 -0
  31. package/dist/history.mjs +89 -0
  32. package/dist/index.d.mts +11 -5
  33. package/dist/index.mjs +5 -4
  34. package/dist/nuxt.d.mts +1 -1
  35. package/dist/nuxt.mjs +5 -2
  36. package/dist/rollup.mjs +0 -1
  37. package/dist/rspack.d.mts +6 -1
  38. package/dist/rspack.mjs +0 -1
  39. package/dist/runtime/components/AttaformDevtoolsPanel.vue +9 -8
  40. package/dist/runtime/plugins/attaform.mjs +1 -2
  41. package/dist/shared/{attaform.Fp3sCrVs.d.ts → attaform.B4VkS43-.d.mts} +2 -2
  42. package/dist/shared/{attaform.DrvMscNX.cjs → attaform.B8k8JrmK.mjs} +4073 -5630
  43. package/dist/shared/attaform.BJGA_UOS.mjs +0 -1
  44. package/dist/shared/{attaform.CoR4mWfv.mjs → attaform.C09fpdLS.mjs} +172 -16
  45. package/dist/shared/{attaform.D8kliaKw.cjs → attaform.CJP3RkGa.mjs} +141 -590
  46. package/dist/shared/{attaform.DniawQLP.d.cts → attaform.Cgu-hdSb.d.mts} +268 -68
  47. package/dist/shared/attaform.Cs2Rbdlo.mjs +0 -1
  48. package/dist/shared/{attaform.CHlJLAiv.d.mts → attaform.D5V4tZWq.d.mts} +69 -179
  49. package/dist/shared/{attaform.B9Wyhfro.cjs → attaform.D6DCnnQu.mjs} +11 -16
  50. package/dist/shared/attaform.DhnPb6nK.mjs +0 -1
  51. package/dist/shared/attaform.Dq4vWxuG.mjs +197 -0
  52. package/dist/shared/attaform.JfSWdEcb.d.mts +44 -0
  53. package/dist/shared/attaform.KvlEedlF.mjs +0 -1
  54. package/dist/shared/{attaform.DdQN7sgN.cjs → attaform.NLmerepI.mjs} +175 -557
  55. package/dist/shared/attaform.h0i6LijT.mjs +242 -0
  56. package/dist/shared/{attaform.Biytrv0-.cjs → attaform.uLbun31C.mjs} +204 -544
  57. package/dist/shared/attaform.v0fQtWyA.mjs +0 -1
  58. package/dist/shared/attaform.wfY8XFvm.mjs +197 -0
  59. package/dist/transforms.mjs +0 -1
  60. package/dist/vite.d.mts +17 -5
  61. package/dist/vite.mjs +24 -2
  62. package/dist/webpack.d.mts +6 -1
  63. package/dist/webpack.mjs +0 -1
  64. package/dist/zod-v3.d.mts +11 -6
  65. package/dist/zod-v3.mjs +17 -4
  66. package/dist/zod-v4.d.mts +12 -6
  67. package/dist/zod-v4.mjs +16 -4
  68. package/dist/zod.d.mts +4 -3
  69. package/dist/zod.mjs +5 -4
  70. package/package.json +23 -8
  71. package/skills/attaform/SKILL.md +2 -1
  72. package/dist/abstract.cjs +0 -48
  73. package/dist/abstract.cjs.map +0 -1
  74. package/dist/abstract.d.cts +0 -42
  75. package/dist/abstract.d.ts +0 -42
  76. package/dist/abstract.mjs.map +0 -1
  77. package/dist/chunks/dev-key-collision-warnings.cjs +0 -25
  78. package/dist/chunks/dev-key-collision-warnings.cjs.map +0 -1
  79. package/dist/chunks/dev-key-collision-warnings.mjs.map +0 -1
  80. package/dist/chunks/devtools.cjs +0 -157
  81. package/dist/chunks/devtools.cjs.map +0 -1
  82. package/dist/chunks/devtools.mjs.map +0 -1
  83. package/dist/chunks/fingerprint.cjs.map +0 -1
  84. package/dist/chunks/fingerprint.mjs.map +0 -1
  85. package/dist/chunks/fingerprint2.cjs.map +0 -1
  86. package/dist/chunks/fingerprint2.mjs.map +0 -1
  87. package/dist/esbuild.cjs +0 -28
  88. package/dist/esbuild.cjs.map +0 -1
  89. package/dist/esbuild.d.cts +0 -56
  90. package/dist/esbuild.d.ts +0 -56
  91. package/dist/esbuild.mjs.map +0 -1
  92. package/dist/index.cjs +0 -51
  93. package/dist/index.cjs.map +0 -1
  94. package/dist/index.d.cts +0 -249
  95. package/dist/index.d.ts +0 -249
  96. package/dist/index.mjs.map +0 -1
  97. package/dist/nuxt.cjs +0 -84
  98. package/dist/nuxt.cjs.map +0 -1
  99. package/dist/nuxt.d.cts +0 -66
  100. package/dist/nuxt.d.ts +0 -66
  101. package/dist/nuxt.mjs.map +0 -1
  102. package/dist/rollup.cjs +0 -24
  103. package/dist/rollup.cjs.map +0 -1
  104. package/dist/rollup.d.cts +0 -35
  105. package/dist/rollup.d.ts +0 -35
  106. package/dist/rollup.mjs.map +0 -1
  107. package/dist/rspack.cjs +0 -10
  108. package/dist/rspack.cjs.map +0 -1
  109. package/dist/rspack.d.cts +0 -40
  110. package/dist/rspack.d.ts +0 -40
  111. package/dist/rspack.mjs.map +0 -1
  112. package/dist/runtime/components/AttaformDevtoolsPanel.vue.d.ts +0 -7
  113. package/dist/runtime/components/DevtoolsValueTree.vue.d.ts +0 -35
  114. package/dist/runtime/plugins/attaform.cjs +0 -43
  115. package/dist/runtime/plugins/attaform.cjs.map +0 -1
  116. package/dist/runtime/plugins/attaform.d.cts +0 -5
  117. package/dist/runtime/plugins/attaform.d.ts +0 -5
  118. package/dist/runtime/plugins/attaform.mjs.map +0 -1
  119. package/dist/shared/attaform.B1ZYt2Li.mjs.map +0 -1
  120. package/dist/shared/attaform.B9Wyhfro.cjs.map +0 -1
  121. package/dist/shared/attaform.BGDV42hI.d.cts +0 -232
  122. package/dist/shared/attaform.BJGA_UOS.mjs.map +0 -1
  123. package/dist/shared/attaform.Biytrv0-.cjs.map +0 -1
  124. package/dist/shared/attaform.Bn0IzhD_.cjs +0 -800
  125. package/dist/shared/attaform.Bn0IzhD_.cjs.map +0 -1
  126. package/dist/shared/attaform.C9fPTxjB.d.cts +0 -41
  127. package/dist/shared/attaform.C9fPTxjB.d.ts +0 -41
  128. package/dist/shared/attaform.CKH2lGdL.mjs.map +0 -1
  129. package/dist/shared/attaform.CQN9R62B.cjs.map +0 -1
  130. package/dist/shared/attaform.CoR4mWfv.mjs.map +0 -1
  131. package/dist/shared/attaform.Cs2Rbdlo.mjs.map +0 -1
  132. package/dist/shared/attaform.D6tk90Rc.cjs.map +0 -1
  133. package/dist/shared/attaform.D8kliaKw.cjs.map +0 -1
  134. package/dist/shared/attaform.DLknk9nF.d.mts +0 -232
  135. package/dist/shared/attaform.DMxM2kol.mjs.map +0 -1
  136. package/dist/shared/attaform.DRUT703x.d.cts +0 -56
  137. package/dist/shared/attaform.DRUT703x.d.ts +0 -56
  138. package/dist/shared/attaform.DYEr28Pt.mjs.map +0 -1
  139. package/dist/shared/attaform.DdQN7sgN.cjs.map +0 -1
  140. package/dist/shared/attaform.DhnPb6nK.mjs.map +0 -1
  141. package/dist/shared/attaform.DniawQLP.d.mts +0 -4763
  142. package/dist/shared/attaform.DniawQLP.d.ts +0 -4763
  143. package/dist/shared/attaform.DoQm_Vkd.cjs +0 -58
  144. package/dist/shared/attaform.DoQm_Vkd.cjs.map +0 -1
  145. package/dist/shared/attaform.DrvMscNX.cjs.map +0 -1
  146. package/dist/shared/attaform.F2Q8iv38.d.ts +0 -2494
  147. package/dist/shared/attaform.FmqKO1Ex.d.cts +0 -2494
  148. package/dist/shared/attaform.KvlEedlF.mjs.map +0 -1
  149. package/dist/shared/attaform.RaTzp1WF.cjs +0 -26
  150. package/dist/shared/attaform.RaTzp1WF.cjs.map +0 -1
  151. package/dist/shared/attaform.nMaz2C5P.mjs.map +0 -1
  152. package/dist/shared/attaform.v0fQtWyA.mjs.map +0 -1
  153. package/dist/shared/attaform.yUrz7C2z.cjs +0 -29
  154. package/dist/shared/attaform.yUrz7C2z.cjs.map +0 -1
  155. package/dist/transforms.cjs +0 -12
  156. package/dist/transforms.cjs.map +0 -1
  157. package/dist/transforms.d.cts +0 -73
  158. package/dist/transforms.d.ts +0 -73
  159. package/dist/transforms.mjs.map +0 -1
  160. package/dist/vite.cjs +0 -363
  161. package/dist/vite.cjs.map +0 -1
  162. package/dist/vite.d.cts +0 -133
  163. package/dist/vite.d.ts +0 -133
  164. package/dist/vite.mjs.map +0 -1
  165. package/dist/webpack.cjs +0 -10
  166. package/dist/webpack.cjs.map +0 -1
  167. package/dist/webpack.d.cts +0 -37
  168. package/dist/webpack.d.ts +0 -37
  169. package/dist/webpack.mjs.map +0 -1
  170. package/dist/zod-v3.cjs +0 -53
  171. package/dist/zod-v3.cjs.map +0 -1
  172. package/dist/zod-v3.d.cts +0 -246
  173. package/dist/zod-v3.d.ts +0 -246
  174. package/dist/zod-v3.mjs.map +0 -1
  175. package/dist/zod-v4.cjs +0 -55
  176. package/dist/zod-v4.cjs.map +0 -1
  177. package/dist/zod-v4.d.cts +0 -172
  178. package/dist/zod-v4.d.ts +0 -172
  179. package/dist/zod-v4.mjs.map +0 -1
  180. package/dist/zod.cjs +0 -51
  181. package/dist/zod.cjs.map +0 -1
  182. package/dist/zod.d.cts +0 -7
  183. package/dist/zod.d.ts +0 -7
  184. package/dist/zod.mjs.map +0 -1
package/dist/zod-v3.cjs DELETED
@@ -1,53 +0,0 @@
1
- 'use strict';
2
-
3
- const useForm = require('./shared/attaform.D8kliaKw.cjs');
4
- const devtoolsShared = require('./shared/attaform.Biytrv0-.cjs');
5
- const serializeScript = require('./shared/attaform.DrvMscNX.cjs');
6
- const registerProtocol = require('./shared/attaform.yUrz7C2z.cjs');
7
-
8
-
9
-
10
- exports.fieldMeta = useForm.fieldMeta;
11
- exports.isZodSchemaType = useForm.isZodSchemaType;
12
- exports.useForm = useForm.useForm;
13
- exports.withMeta = useForm.withMeta;
14
- exports.zodAdapter = useForm.zodAdapter;
15
- exports.AttaformError = devtoolsShared.AttaformError;
16
- exports.DEVTOOLS_WINDOW_KEY = devtoolsShared.DEVTOOLS_WINDOW_KEY;
17
- exports.InvalidPathError = devtoolsShared.InvalidPathError;
18
- exports.InvalidUseFormConfigError = devtoolsShared.InvalidUseFormConfigError;
19
- exports.OutsideSetupError = devtoolsShared.OutsideSetupError;
20
- exports.ROOT_PATH = devtoolsShared.ROOT_PATH;
21
- exports.ROOT_PATH_KEY = devtoolsShared.ROOT_PATH_KEY;
22
- exports.RegistryNotInstalledError = devtoolsShared.RegistryNotInstalledError;
23
- exports.ReservedFormKeyError = devtoolsShared.ReservedFormKeyError;
24
- exports.SubmitErrorHandlerError = devtoolsShared.SubmitErrorHandlerError;
25
- exports.assignKey = devtoolsShared.assignKey;
26
- exports.canonicalizePath = devtoolsShared.canonicalizePath;
27
- exports.createAttaform = devtoolsShared.createAttaform;
28
- exports.createRegistry = devtoolsShared.createRegistry;
29
- exports.getRegistryFromApp = devtoolsShared.getRegistryFromApp;
30
- exports.hydrateAttaformState = devtoolsShared.hydrateAttaformState;
31
- exports.isPathPrefix = devtoolsShared.isPathPrefix;
32
- exports.kAttaformRegistry = devtoolsShared.kAttaformRegistry;
33
- exports.parseDottedPath = devtoolsShared.parseDottedPath;
34
- exports.renderAttaformState = devtoolsShared.renderAttaformState;
35
- exports.useRegistry = devtoolsShared.useRegistry;
36
- exports.vRegister = devtoolsShared.vRegister;
37
- exports.AttaformErrorCode = serializeScript.AttaformErrorCode;
38
- exports.DEFAULT_TIMINGS = serializeScript.DEFAULT_TIMINGS;
39
- exports.defaultCoercionRules = serializeScript.defaultCoercionRules;
40
- exports.defaultDisplayState = serializeScript.defaultDisplayState;
41
- exports.defineCoercion = serializeScript.defineCoercion;
42
- exports.escapeForInlineScript = serializeScript.escapeForInlineScript;
43
- exports.gate = serializeScript.gate;
44
- exports.injectForm = serializeScript.injectForm;
45
- exports.injectWizard = serializeScript.injectWizard;
46
- exports.isUnset = serializeScript.isUnset;
47
- exports.lazy = serializeScript.lazy;
48
- exports.makeDefaultDisplayState = serializeScript.makeDefaultDisplayState;
49
- exports.unset = serializeScript.unset;
50
- exports.useRegister = serializeScript.useRegister;
51
- exports.useWizard = serializeScript.useWizard;
52
- exports.isRegisterValue = registerProtocol.isRegisterValue;
53
- //# sourceMappingURL=zod-v3.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"zod-v3.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/dist/zod-v3.d.cts DELETED
@@ -1,246 +0,0 @@
1
- import { z } from 'zod';
2
- import { G as GenericForm, F as FormKey, U as UseFormConfiguration, A as AbstractSchema, aq as AcceptableDefaults, a as UseFormReturnType, ae as ValidateOnConfig, ar as SchemaFactoryOptions, o as FieldMetaPayload } from './shared/attaform.DniawQLP.cjs';
3
- export { b as ArrayItem, c as ArrayPath, d as AttaformDefaults, C as CoercionEntry, e as CoercionRegistry, f as CoercionResult, g as CustomDirectiveRegisterAssignerFn, h as DeepPartial, D as DefaultValuesInput, i as DefaultValuesResponse, j as DefaultValuesShape, k as DisplayCtx, l as DisplayMachine, m as DisplayState, E as ErrorInput, n as ErrorsProxyShape, p as FieldState, q as FieldStateMap, r as FieldStateMapEntry, s as FlatPath, t as FormErrorRecord, u as FormErrorsSurface, v as FormMeta, w as GetDisplayState, H as HandleSubmit, x as HistoryConfig, I as IsTuple, y as IsUnion, J as JoinSegments, z as Json, K as KeyofUnion, L as LiftedValueShape, M as MetaTrackerValue, N as NestedReadType, B as NestedType, O as OnError, P as OnInvalidSubmitPolicy, Q as OnSubmit, R as PartialFlatPath, S as Path, T as PathKey, V as PendingValidationStatus, W as Primitive, X as ROOT_PATH, Y as ROOT_PATH_KEY, Z as ReactiveValidationStatus, _ as RegisterDirective, $ as RegisterFlatPath, a0 as RegisterOptions, a1 as RegisterSelectModifier, a2 as RegisterTextModifier, a3 as RegisterTransform, a4 as RegisterValue, a5 as Segment, a6 as SetValueCallback, a7 as SetValuePayload, a8 as SettledValidationStatus, a9 as SlimPrimitiveKind, aa as SlimRuntimeOf, ab as SubmitHandler, ac as Unset, ad as ValidateOn, af as ValidationError, ag as ValidationResponse, ah as ValidationResponseWithoutValue, ai as ValueOfUnion, aj as WriteMeta, ak as WriteShape, al as canonicalizePath, am as isPathPrefix, an as isUnset, ao as parseDottedPath, ap as unset } from './shared/attaform.DniawQLP.cjs';
4
- import { S as SupportedRootSchema, U as UnwrapZodRoot, a as StorageShape } from './shared/attaform.DRUT703x.cjs';
5
- export { a as AnyForm, b as AttaformDevtoolsBridge, c as AttaformError, d as AttaformErrorCode, e as AttaformPluginOptions, A as AttaformRegistry, C as CompiledStep, D as DEFAULT_TIMINGS, f as DEVTOOLS_WINDOW_KEY, g as DisplayTimings, F as FormStatus, h as FormStatusSeed, G as GateMarker, I as InjectWizardInput, i as InvalidPathError, j as InvalidUseFormConfigError, L as LazyMarker, O as OutsideSetupError, R as RegistryNotInstalledError, k as ReservedFormKeyError, S as SerializedAttaformState, l as SerializedFormData, m as StepSlot, n as SubmitErrorHandlerError, U as UseRegisterReturn, o as UseWizardReturnType, W as WizardAggregateError, p as WizardCtx, q as WizardCtxForm, r as WizardOnError, s as WizardOnSubmit, t as WizardOptions, u as WizardPersistFn, v as WizardRestoreFn, w as WizardRestoreState, x as WizardStatusesProxy, y as WizardSubmitContext, z as assignKey, B as createAttaform, E as createRegistry, H as defaultCoercionRules, J as defaultDisplayState, K as defineCoercion, M as escapeForInlineScript, N as gate, P as getRegistryFromApp, Q as hydrateAttaformState, T as injectForm, V as injectWizard, X as isRegisterValue, Y as kAttaformRegistry, Z as lazy, _ as makeDefaultDisplayState, $ as renderAttaformState, a0 as useRegister, a1 as useRegistry, a2 as useWizard, a3 as vRegister } from './shared/attaform.FmqKO1Ex.cjs';
6
- import 'vue';
7
-
8
- /**
9
- * `FormOf` / `OutOf` / `ReadOf` factor the three identical-shape
10
- * conditionals out of the zod-typed `useForm` signature. The bundled
11
- * `.d.ts` then carries one alias per shape rather than re-inlining
12
- * `z.input<UnwrapZodObject<Schema>> extends GenericForm ? … : never`
13
- * four times — the pattern that produces TS2589 ("Type instantiation
14
- * is excessively deep") on consumer call sites with complex schemas
15
- * (discriminated unions, refines, deep `.register()` chains). Mirrors
16
- * the v4 adapter's own `FormOf`/`OutOf`/`ReadOf` aliases verbatim so
17
- * v3 and v4 carry the same per-call depth cost.
18
- */
19
- type FormOf<Schema extends SupportedRootSchema> = z.input<UnwrapZodRoot<Schema>> extends GenericForm ? z.input<UnwrapZodRoot<Schema>> : never;
20
- type OutOf<Schema extends SupportedRootSchema> = z.output<UnwrapZodRoot<Schema>> extends GenericForm ? z.output<UnwrapZodRoot<Schema>> : never;
21
- type ReadOf<Schema extends SupportedRootSchema> = StorageShape<UnwrapZodRoot<Schema>> extends GenericForm ? StorageShape<UnwrapZodRoot<Schema>> : never;
22
- /**
23
- * Create a form bound to a custom `AbstractSchema` adapter.
24
- *
25
- * ```ts
26
- * import { useForm } from 'attaform/zod-v3'
27
- *
28
- * const form = useForm({ schema: myAdapter, defaultValues: { … } })
29
- * ```
30
- *
31
- * For Zod schemas, prefer the overload that accepts a `ZodObject`
32
- * directly — it wraps the adapter automatically. For Zod v4, import
33
- * from `attaform/zod` instead.
34
- */
35
- declare function useForm<Form extends GenericForm, GetValueFormType extends GenericForm = Form, K extends FormKey = FormKey>(configuration: Omit<UseFormConfiguration<Form, GetValueFormType, AbstractSchema<Form, GetValueFormType>, never, K>, 'defaultValues'> & {
36
- defaultValues?: AcceptableDefaults<Form, Form>;
37
- }): UseFormReturnType<Form, GetValueFormType, Form, K>;
38
- /**
39
- * Create a form bound to a Zod v3 `ZodObject` schema.
40
- *
41
- * ```ts
42
- * import { useForm } from 'attaform/zod-v3'
43
- * import { z } from 'zod'
44
- *
45
- * const form = useForm({
46
- * schema: z.object({
47
- * email: z.string().email(),
48
- * password: z.string().min(8),
49
- * }),
50
- * defaultValues: { email: '' },
51
- * validateOn: 'blur',
52
- * })
53
- * ```
54
- *
55
- * Returns a form API exposing `register`, `values`, `errors`,
56
- * `fields`, `setValue`, `handleSubmit`, `meta`, field-array
57
- * helpers, and more. See `UseFormReturnType` for the full
58
- * surface.
59
- *
60
- * For Zod v4, import from `attaform/zod` instead.
61
- */
62
- declare function useForm<Schema extends SupportedRootSchema, K extends FormKey = FormKey>(configuration: Omit<UseFormConfiguration<FormOf<Schema>, OutOf<Schema>, AbstractSchema<FormOf<Schema>, OutOf<Schema>>, never, K>, 'schema' | 'validateOn' | 'debounceMs' | 'defaultValues'> & {
63
- schema: Schema;
64
- defaultValues?: AcceptableDefaults<FormOf<Schema>, z.input<Schema>>;
65
- } & ValidateOnConfig): UseFormReturnType<FormOf<Schema>, OutOf<Schema>, ReadOf<Schema>, K>;
66
-
67
- /**
68
- * Narrow accessor type for Zod v3's internal `_def`. Only useful
69
- * when writing a custom adapter that needs to read internals
70
- * directly. Most consumers should never reach for this.
71
- */
72
- interface ZodTypeWithInnerType extends z.ZodTypeAny {
73
- _def: {
74
- typeName: string;
75
- innerType: z.ZodTypeAny;
76
- };
77
- }
78
- /**
79
- * The "honest read shape" of a Zod v3 schema — fields under records,
80
- * arrays, and dynamic boundaries are tagged optional/undefined to
81
- * reflect the runtime reality that those slots may be missing.
82
- *
83
- * Used internally by the v3 adapter as the read-side type for
84
- * `getValue` / `getFieldState`. Not commonly needed in consumer code.
85
- */
86
- type TypeWithNullableDynamicKeys<Schema extends z.ZodSchema, CrossedBoundary extends boolean = false> = Schema extends z.ZodRecord<infer KeySchema extends z.ZodTypeAny, infer ValueSchema extends z.ZodTypeAny> ? {
87
- [Key in z.infer<KeySchema>]?: TypeWithNullableDynamicKeys<ValueSchema, true>;
88
- } : Schema extends z.ZodArray<infer ItemSchema extends z.ZodTypeAny> ? (TypeWithNullableDynamicKeys<ItemSchema, true> | undefined)[] : Schema extends z.ZodObject<infer Shape> ? {
89
- [Key in keyof Shape]: TypeWithNullableDynamicKeys<Shape[Key], CrossedBoundary> | (CrossedBoundary extends true ? undefined : never);
90
- } : Schema extends z.ZodDiscriminatedUnion<string, infer Options> ? {
91
- [Key in keyof Options]: TypeWithNullableDynamicKeys<Options[Key], true>;
92
- }[keyof Options & number] : // Fallback to z.infer for all other schemas
93
- z.infer<Schema> | (CrossedBoundary extends true ? undefined : never);
94
-
95
- /**
96
- * Wrap a Zod v3 form-root schema (`ZodObject` or `ZodRecord`) in an
97
- * `AbstractSchema` factory.
98
- *
99
- * Most consumers never call this directly — `useForm` from
100
- * `attaform/zod-v3` does the wrapping automatically. Reach
101
- * for it only when integrating with a custom code path that needs
102
- * the adapter outside of `useForm`.
103
- *
104
- * Throws if the underlying schema isn't a supported form root.
105
- */
106
- declare function zodAdapter<FormSchema extends z.ZodSchema, Form extends z.input<FormSchema>, GetValueFormType extends TypeWithNullableDynamicKeys<FormSchema>>(zodSchema: FormSchema): (formKey: FormKey, options: SchemaFactoryOptions) => AbstractSchema<Form, GetValueFormType>;
107
-
108
- type ZodTypeMap = {
109
- ZodObject: z.AnyZodObject;
110
- ZodDiscriminatedUnion: z.ZodDiscriminatedUnion<string, [
111
- z.ZodDiscriminatedUnionOption<string>,
112
- ...z.ZodDiscriminatedUnionOption<string>[]
113
- ]>;
114
- ZodArray: z.ZodArray<z.ZodTypeAny>;
115
- ZodSet: z.ZodSet<z.ZodTypeAny>;
116
- ZodRecord: z.ZodRecord<z.ZodTypeAny, z.ZodTypeAny>;
117
- ZodDefault: z.ZodDefault<z.ZodTypeAny>;
118
- ZodOptional: z.ZodOptional<z.ZodTypeAny>;
119
- ZodNullable: z.ZodNullable<z.ZodTypeAny>;
120
- ZodType: z.ZodTypeAny;
121
- ZodEffects: z.ZodEffects<z.ZodTypeAny>;
122
- ZodBoolean: z.ZodBoolean;
123
- ZodEnum: z.ZodEnum<[string, ...string[]]>;
124
- ZodNull: z.ZodNull;
125
- ZodUndefined: z.ZodUndefined;
126
- ZodLiteral: z.ZodLiteral<unknown>;
127
- ZodUnion: z.ZodUnion<[z.ZodTypeAny, z.ZodTypeAny, ...z.ZodTypeAny[]]>;
128
- ZodTuple: z.ZodTuple<[z.ZodTypeAny, ...z.ZodTypeAny[]]>;
129
- ZodString: z.ZodString;
130
- ZodNumber: z.ZodNumber;
131
- ZodBigInt: z.ZodBigInt;
132
- ZodDate: z.ZodDate;
133
- ZodPipeline: z.ZodPipeline<z.ZodTypeAny, z.ZodTypeAny>;
134
- ZodReadonly: z.ZodReadonly<z.ZodTypeAny>;
135
- ZodBranded: z.ZodBranded<z.ZodTypeAny, string | number | symbol>;
136
- ZodCatch: z.ZodCatch<z.ZodTypeAny>;
137
- ZodIntersection: z.ZodIntersection<z.ZodTypeAny, z.ZodTypeAny>;
138
- ZodLazy: z.ZodLazy<z.ZodTypeAny>;
139
- ZodNativeEnum: z.ZodNativeEnum<z.EnumLike>;
140
- ZodNaN: z.ZodNaN;
141
- ZodVoid: z.ZodVoid;
142
- ZodAny: z.ZodAny;
143
- ZodUnknown: z.ZodUnknown;
144
- ZodNever: z.ZodNever;
145
- };
146
- /**
147
- * Type guard for a Zod v3 schema kind. Returns `true` when `schema`
148
- * is a Zod v3 instance of the named kind (`ZodString`, `ZodObject`,
149
- * etc.) and narrows the type accordingly.
150
- *
151
- * ```ts
152
- * if (isZodSchemaType(schema, 'ZodObject')) {
153
- * // schema is now typed as z.AnyZodObject
154
- * }
155
- * ```
156
- *
157
- * Useful when building adapters or introspection helpers that branch
158
- * on schema shape. Most consumers don't need this.
159
- */
160
- declare function isZodSchemaType<K extends keyof ZodTypeMap>(schema: unknown, expectedType: K): schema is ZodTypeMap[K];
161
-
162
- /**
163
- * Field-metadata write/read API for the Zod v3 adapter.
164
- *
165
- * Storage lives in the shared `field-meta-store` core — every entry
166
- * (`attaform/zod`, `attaform/zod-v3`, `attaform/zod-v4`) writes to and
167
- * reads from the same `WeakMap`s, so a payload registered via any
168
- * entry surfaces at lookup regardless of which adapter actually runs.
169
- *
170
- * Zod 3 has no `z.registry()` mechanism, so `fieldMeta` is the
171
- * shared registry-shaped object exposing `add` / `get` / `has` /
172
- * `remove`. The public `withMeta(schema, payload)` write API matches
173
- * `attaform/zod`'s so schema authoring reads identically across the
174
- * two adapters.
175
- *
176
- * **Registration patterns:** both styles work — register on whatever
177
- * schema reference you assign into the parent's shape, OR on the
178
- * inner schema before wrapping. The adapter's resolver tries the
179
- * walker-returned schema first, then falls back to the peeled
180
- * inner so either ordering hits:
181
- *
182
- * // both equivalent — registry hits at lookup time
183
- * withMeta(z.string(), { label: 'Email' }).optional()
184
- * withMeta(z.string().optional(), { label: 'Email' })
185
- *
186
- * The path walker returns the wrapper at terminal positions and
187
- * peels at intermediate descent. The two-stage lookup covers both
188
- * leaf and container registrations symmetrically.
189
- */
190
-
191
- /**
192
- * The shared registry every Attaform-aware Zod 3 schema can register
193
- * field metadata against. Backed by the cross-adapter
194
- * `fieldMetaStore` — a payload registered here is visible to the v4
195
- * adapter and the unified `attaform/zod` entry, and vice versa.
196
- */
197
- type FieldMetaRegistryV3 = {
198
- /**
199
- * Register `payload` against `schema`. Returns the registry to
200
- * mirror Zod 4's `$ZodRegistry.add` chain shape.
201
- */
202
- add<S extends z.ZodTypeAny>(schema: S, payload: FieldMetaPayload): FieldMetaRegistryV3;
203
- /**
204
- * Read the registered payload for a schema, or `undefined` if
205
- * nothing has been registered.
206
- */
207
- get(schema: z.ZodTypeAny): FieldMetaPayload | undefined;
208
- /** True iff a payload has been registered for the schema. */
209
- has(schema: z.ZodTypeAny): boolean;
210
- /**
211
- * Drop every registered payload for `schema`. Returns the registry
212
- * for chaining; idempotent on a never-registered schema.
213
- */
214
- remove(schema: z.ZodTypeAny): FieldMetaRegistryV3;
215
- };
216
- declare const fieldMeta: FieldMetaRegistryV3;
217
- /**
218
- * Attach `payload` to `schema` in the shared `fieldMeta` registry
219
- * and return a clone of `schema` (chainable, with the new metadata).
220
- * Cross-version with `attaform/zod`'s `withMeta()`.
221
- *
222
- * **Why clone, not mutate.** The shared store keys metadata on the
223
- * schema reference. Calling `withMeta` twice on the same instance
224
- * would overwrite (last-write-wins) — so a sub-schema reused at
225
- * multiple form paths (e.g. an address schema shared between pickup
226
- * and delivery) couldn't carry distinct metadata per path.
227
- *
228
- * `withMeta` sidesteps the footgun by reconstructing `schema` via
229
- * its constructor + `_def` — Zod 3 schemas don't expose `.clone()`,
230
- * but `new schema.constructor(schema._def)` is the equivalent. Each
231
- * call gets a fresh identity and a fresh registry slot. Existing
232
- * metadata on the original is merged through, so chaining
233
- * `withMeta` accumulates payload fields rather than replacing.
234
- *
235
- * Inner field schemas (e.g. an object's `.shape.city`) are shared
236
- * across clones — the def is held by reference — so leaf metadata
237
- * registers once and surfaces at every path.
238
- *
239
- * `schema.register()` does NOT exist on Zod 3 — `withMeta` is the
240
- * only fluent write API. Register on the inner schema before
241
- * wrapping; see the "Registration rule" note in this file's header.
242
- */
243
- declare function withMeta<S extends z.ZodTypeAny>(schema: S, payload: FieldMetaPayload): S;
244
-
245
- export { FieldMetaPayload, FormKey, GenericForm, UnwrapZodRoot, UseFormConfiguration, UseFormReturnType, ValidateOnConfig, fieldMeta, isZodSchemaType, useForm, withMeta, zodAdapter };
246
- export type { TypeWithNullableDynamicKeys, ZodTypeWithInnerType };
package/dist/zod-v3.d.ts DELETED
@@ -1,246 +0,0 @@
1
- import { z } from 'zod';
2
- import { G as GenericForm, F as FormKey, U as UseFormConfiguration, A as AbstractSchema, aq as AcceptableDefaults, a as UseFormReturnType, ae as ValidateOnConfig, ar as SchemaFactoryOptions, o as FieldMetaPayload } from './shared/attaform.DniawQLP.js';
3
- export { b as ArrayItem, c as ArrayPath, d as AttaformDefaults, C as CoercionEntry, e as CoercionRegistry, f as CoercionResult, g as CustomDirectiveRegisterAssignerFn, h as DeepPartial, D as DefaultValuesInput, i as DefaultValuesResponse, j as DefaultValuesShape, k as DisplayCtx, l as DisplayMachine, m as DisplayState, E as ErrorInput, n as ErrorsProxyShape, p as FieldState, q as FieldStateMap, r as FieldStateMapEntry, s as FlatPath, t as FormErrorRecord, u as FormErrorsSurface, v as FormMeta, w as GetDisplayState, H as HandleSubmit, x as HistoryConfig, I as IsTuple, y as IsUnion, J as JoinSegments, z as Json, K as KeyofUnion, L as LiftedValueShape, M as MetaTrackerValue, N as NestedReadType, B as NestedType, O as OnError, P as OnInvalidSubmitPolicy, Q as OnSubmit, R as PartialFlatPath, S as Path, T as PathKey, V as PendingValidationStatus, W as Primitive, X as ROOT_PATH, Y as ROOT_PATH_KEY, Z as ReactiveValidationStatus, _ as RegisterDirective, $ as RegisterFlatPath, a0 as RegisterOptions, a1 as RegisterSelectModifier, a2 as RegisterTextModifier, a3 as RegisterTransform, a4 as RegisterValue, a5 as Segment, a6 as SetValueCallback, a7 as SetValuePayload, a8 as SettledValidationStatus, a9 as SlimPrimitiveKind, aa as SlimRuntimeOf, ab as SubmitHandler, ac as Unset, ad as ValidateOn, af as ValidationError, ag as ValidationResponse, ah as ValidationResponseWithoutValue, ai as ValueOfUnion, aj as WriteMeta, ak as WriteShape, al as canonicalizePath, am as isPathPrefix, an as isUnset, ao as parseDottedPath, ap as unset } from './shared/attaform.DniawQLP.js';
4
- import { S as SupportedRootSchema, U as UnwrapZodRoot, a as StorageShape } from './shared/attaform.DRUT703x.js';
5
- export { a as AnyForm, b as AttaformDevtoolsBridge, c as AttaformError, d as AttaformErrorCode, e as AttaformPluginOptions, A as AttaformRegistry, C as CompiledStep, D as DEFAULT_TIMINGS, f as DEVTOOLS_WINDOW_KEY, g as DisplayTimings, F as FormStatus, h as FormStatusSeed, G as GateMarker, I as InjectWizardInput, i as InvalidPathError, j as InvalidUseFormConfigError, L as LazyMarker, O as OutsideSetupError, R as RegistryNotInstalledError, k as ReservedFormKeyError, S as SerializedAttaformState, l as SerializedFormData, m as StepSlot, n as SubmitErrorHandlerError, U as UseRegisterReturn, o as UseWizardReturnType, W as WizardAggregateError, p as WizardCtx, q as WizardCtxForm, r as WizardOnError, s as WizardOnSubmit, t as WizardOptions, u as WizardPersistFn, v as WizardRestoreFn, w as WizardRestoreState, x as WizardStatusesProxy, y as WizardSubmitContext, z as assignKey, B as createAttaform, E as createRegistry, H as defaultCoercionRules, J as defaultDisplayState, K as defineCoercion, M as escapeForInlineScript, N as gate, P as getRegistryFromApp, Q as hydrateAttaformState, T as injectForm, V as injectWizard, X as isRegisterValue, Y as kAttaformRegistry, Z as lazy, _ as makeDefaultDisplayState, $ as renderAttaformState, a0 as useRegister, a1 as useRegistry, a2 as useWizard, a3 as vRegister } from './shared/attaform.F2Q8iv38.js';
6
- import 'vue';
7
-
8
- /**
9
- * `FormOf` / `OutOf` / `ReadOf` factor the three identical-shape
10
- * conditionals out of the zod-typed `useForm` signature. The bundled
11
- * `.d.ts` then carries one alias per shape rather than re-inlining
12
- * `z.input<UnwrapZodObject<Schema>> extends GenericForm ? … : never`
13
- * four times — the pattern that produces TS2589 ("Type instantiation
14
- * is excessively deep") on consumer call sites with complex schemas
15
- * (discriminated unions, refines, deep `.register()` chains). Mirrors
16
- * the v4 adapter's own `FormOf`/`OutOf`/`ReadOf` aliases verbatim so
17
- * v3 and v4 carry the same per-call depth cost.
18
- */
19
- type FormOf<Schema extends SupportedRootSchema> = z.input<UnwrapZodRoot<Schema>> extends GenericForm ? z.input<UnwrapZodRoot<Schema>> : never;
20
- type OutOf<Schema extends SupportedRootSchema> = z.output<UnwrapZodRoot<Schema>> extends GenericForm ? z.output<UnwrapZodRoot<Schema>> : never;
21
- type ReadOf<Schema extends SupportedRootSchema> = StorageShape<UnwrapZodRoot<Schema>> extends GenericForm ? StorageShape<UnwrapZodRoot<Schema>> : never;
22
- /**
23
- * Create a form bound to a custom `AbstractSchema` adapter.
24
- *
25
- * ```ts
26
- * import { useForm } from 'attaform/zod-v3'
27
- *
28
- * const form = useForm({ schema: myAdapter, defaultValues: { … } })
29
- * ```
30
- *
31
- * For Zod schemas, prefer the overload that accepts a `ZodObject`
32
- * directly — it wraps the adapter automatically. For Zod v4, import
33
- * from `attaform/zod` instead.
34
- */
35
- declare function useForm<Form extends GenericForm, GetValueFormType extends GenericForm = Form, K extends FormKey = FormKey>(configuration: Omit<UseFormConfiguration<Form, GetValueFormType, AbstractSchema<Form, GetValueFormType>, never, K>, 'defaultValues'> & {
36
- defaultValues?: AcceptableDefaults<Form, Form>;
37
- }): UseFormReturnType<Form, GetValueFormType, Form, K>;
38
- /**
39
- * Create a form bound to a Zod v3 `ZodObject` schema.
40
- *
41
- * ```ts
42
- * import { useForm } from 'attaform/zod-v3'
43
- * import { z } from 'zod'
44
- *
45
- * const form = useForm({
46
- * schema: z.object({
47
- * email: z.string().email(),
48
- * password: z.string().min(8),
49
- * }),
50
- * defaultValues: { email: '' },
51
- * validateOn: 'blur',
52
- * })
53
- * ```
54
- *
55
- * Returns a form API exposing `register`, `values`, `errors`,
56
- * `fields`, `setValue`, `handleSubmit`, `meta`, field-array
57
- * helpers, and more. See `UseFormReturnType` for the full
58
- * surface.
59
- *
60
- * For Zod v4, import from `attaform/zod` instead.
61
- */
62
- declare function useForm<Schema extends SupportedRootSchema, K extends FormKey = FormKey>(configuration: Omit<UseFormConfiguration<FormOf<Schema>, OutOf<Schema>, AbstractSchema<FormOf<Schema>, OutOf<Schema>>, never, K>, 'schema' | 'validateOn' | 'debounceMs' | 'defaultValues'> & {
63
- schema: Schema;
64
- defaultValues?: AcceptableDefaults<FormOf<Schema>, z.input<Schema>>;
65
- } & ValidateOnConfig): UseFormReturnType<FormOf<Schema>, OutOf<Schema>, ReadOf<Schema>, K>;
66
-
67
- /**
68
- * Narrow accessor type for Zod v3's internal `_def`. Only useful
69
- * when writing a custom adapter that needs to read internals
70
- * directly. Most consumers should never reach for this.
71
- */
72
- interface ZodTypeWithInnerType extends z.ZodTypeAny {
73
- _def: {
74
- typeName: string;
75
- innerType: z.ZodTypeAny;
76
- };
77
- }
78
- /**
79
- * The "honest read shape" of a Zod v3 schema — fields under records,
80
- * arrays, and dynamic boundaries are tagged optional/undefined to
81
- * reflect the runtime reality that those slots may be missing.
82
- *
83
- * Used internally by the v3 adapter as the read-side type for
84
- * `getValue` / `getFieldState`. Not commonly needed in consumer code.
85
- */
86
- type TypeWithNullableDynamicKeys<Schema extends z.ZodSchema, CrossedBoundary extends boolean = false> = Schema extends z.ZodRecord<infer KeySchema extends z.ZodTypeAny, infer ValueSchema extends z.ZodTypeAny> ? {
87
- [Key in z.infer<KeySchema>]?: TypeWithNullableDynamicKeys<ValueSchema, true>;
88
- } : Schema extends z.ZodArray<infer ItemSchema extends z.ZodTypeAny> ? (TypeWithNullableDynamicKeys<ItemSchema, true> | undefined)[] : Schema extends z.ZodObject<infer Shape> ? {
89
- [Key in keyof Shape]: TypeWithNullableDynamicKeys<Shape[Key], CrossedBoundary> | (CrossedBoundary extends true ? undefined : never);
90
- } : Schema extends z.ZodDiscriminatedUnion<string, infer Options> ? {
91
- [Key in keyof Options]: TypeWithNullableDynamicKeys<Options[Key], true>;
92
- }[keyof Options & number] : // Fallback to z.infer for all other schemas
93
- z.infer<Schema> | (CrossedBoundary extends true ? undefined : never);
94
-
95
- /**
96
- * Wrap a Zod v3 form-root schema (`ZodObject` or `ZodRecord`) in an
97
- * `AbstractSchema` factory.
98
- *
99
- * Most consumers never call this directly — `useForm` from
100
- * `attaform/zod-v3` does the wrapping automatically. Reach
101
- * for it only when integrating with a custom code path that needs
102
- * the adapter outside of `useForm`.
103
- *
104
- * Throws if the underlying schema isn't a supported form root.
105
- */
106
- declare function zodAdapter<FormSchema extends z.ZodSchema, Form extends z.input<FormSchema>, GetValueFormType extends TypeWithNullableDynamicKeys<FormSchema>>(zodSchema: FormSchema): (formKey: FormKey, options: SchemaFactoryOptions) => AbstractSchema<Form, GetValueFormType>;
107
-
108
- type ZodTypeMap = {
109
- ZodObject: z.AnyZodObject;
110
- ZodDiscriminatedUnion: z.ZodDiscriminatedUnion<string, [
111
- z.ZodDiscriminatedUnionOption<string>,
112
- ...z.ZodDiscriminatedUnionOption<string>[]
113
- ]>;
114
- ZodArray: z.ZodArray<z.ZodTypeAny>;
115
- ZodSet: z.ZodSet<z.ZodTypeAny>;
116
- ZodRecord: z.ZodRecord<z.ZodTypeAny, z.ZodTypeAny>;
117
- ZodDefault: z.ZodDefault<z.ZodTypeAny>;
118
- ZodOptional: z.ZodOptional<z.ZodTypeAny>;
119
- ZodNullable: z.ZodNullable<z.ZodTypeAny>;
120
- ZodType: z.ZodTypeAny;
121
- ZodEffects: z.ZodEffects<z.ZodTypeAny>;
122
- ZodBoolean: z.ZodBoolean;
123
- ZodEnum: z.ZodEnum<[string, ...string[]]>;
124
- ZodNull: z.ZodNull;
125
- ZodUndefined: z.ZodUndefined;
126
- ZodLiteral: z.ZodLiteral<unknown>;
127
- ZodUnion: z.ZodUnion<[z.ZodTypeAny, z.ZodTypeAny, ...z.ZodTypeAny[]]>;
128
- ZodTuple: z.ZodTuple<[z.ZodTypeAny, ...z.ZodTypeAny[]]>;
129
- ZodString: z.ZodString;
130
- ZodNumber: z.ZodNumber;
131
- ZodBigInt: z.ZodBigInt;
132
- ZodDate: z.ZodDate;
133
- ZodPipeline: z.ZodPipeline<z.ZodTypeAny, z.ZodTypeAny>;
134
- ZodReadonly: z.ZodReadonly<z.ZodTypeAny>;
135
- ZodBranded: z.ZodBranded<z.ZodTypeAny, string | number | symbol>;
136
- ZodCatch: z.ZodCatch<z.ZodTypeAny>;
137
- ZodIntersection: z.ZodIntersection<z.ZodTypeAny, z.ZodTypeAny>;
138
- ZodLazy: z.ZodLazy<z.ZodTypeAny>;
139
- ZodNativeEnum: z.ZodNativeEnum<z.EnumLike>;
140
- ZodNaN: z.ZodNaN;
141
- ZodVoid: z.ZodVoid;
142
- ZodAny: z.ZodAny;
143
- ZodUnknown: z.ZodUnknown;
144
- ZodNever: z.ZodNever;
145
- };
146
- /**
147
- * Type guard for a Zod v3 schema kind. Returns `true` when `schema`
148
- * is a Zod v3 instance of the named kind (`ZodString`, `ZodObject`,
149
- * etc.) and narrows the type accordingly.
150
- *
151
- * ```ts
152
- * if (isZodSchemaType(schema, 'ZodObject')) {
153
- * // schema is now typed as z.AnyZodObject
154
- * }
155
- * ```
156
- *
157
- * Useful when building adapters or introspection helpers that branch
158
- * on schema shape. Most consumers don't need this.
159
- */
160
- declare function isZodSchemaType<K extends keyof ZodTypeMap>(schema: unknown, expectedType: K): schema is ZodTypeMap[K];
161
-
162
- /**
163
- * Field-metadata write/read API for the Zod v3 adapter.
164
- *
165
- * Storage lives in the shared `field-meta-store` core — every entry
166
- * (`attaform/zod`, `attaform/zod-v3`, `attaform/zod-v4`) writes to and
167
- * reads from the same `WeakMap`s, so a payload registered via any
168
- * entry surfaces at lookup regardless of which adapter actually runs.
169
- *
170
- * Zod 3 has no `z.registry()` mechanism, so `fieldMeta` is the
171
- * shared registry-shaped object exposing `add` / `get` / `has` /
172
- * `remove`. The public `withMeta(schema, payload)` write API matches
173
- * `attaform/zod`'s so schema authoring reads identically across the
174
- * two adapters.
175
- *
176
- * **Registration patterns:** both styles work — register on whatever
177
- * schema reference you assign into the parent's shape, OR on the
178
- * inner schema before wrapping. The adapter's resolver tries the
179
- * walker-returned schema first, then falls back to the peeled
180
- * inner so either ordering hits:
181
- *
182
- * // both equivalent — registry hits at lookup time
183
- * withMeta(z.string(), { label: 'Email' }).optional()
184
- * withMeta(z.string().optional(), { label: 'Email' })
185
- *
186
- * The path walker returns the wrapper at terminal positions and
187
- * peels at intermediate descent. The two-stage lookup covers both
188
- * leaf and container registrations symmetrically.
189
- */
190
-
191
- /**
192
- * The shared registry every Attaform-aware Zod 3 schema can register
193
- * field metadata against. Backed by the cross-adapter
194
- * `fieldMetaStore` — a payload registered here is visible to the v4
195
- * adapter and the unified `attaform/zod` entry, and vice versa.
196
- */
197
- type FieldMetaRegistryV3 = {
198
- /**
199
- * Register `payload` against `schema`. Returns the registry to
200
- * mirror Zod 4's `$ZodRegistry.add` chain shape.
201
- */
202
- add<S extends z.ZodTypeAny>(schema: S, payload: FieldMetaPayload): FieldMetaRegistryV3;
203
- /**
204
- * Read the registered payload for a schema, or `undefined` if
205
- * nothing has been registered.
206
- */
207
- get(schema: z.ZodTypeAny): FieldMetaPayload | undefined;
208
- /** True iff a payload has been registered for the schema. */
209
- has(schema: z.ZodTypeAny): boolean;
210
- /**
211
- * Drop every registered payload for `schema`. Returns the registry
212
- * for chaining; idempotent on a never-registered schema.
213
- */
214
- remove(schema: z.ZodTypeAny): FieldMetaRegistryV3;
215
- };
216
- declare const fieldMeta: FieldMetaRegistryV3;
217
- /**
218
- * Attach `payload` to `schema` in the shared `fieldMeta` registry
219
- * and return a clone of `schema` (chainable, with the new metadata).
220
- * Cross-version with `attaform/zod`'s `withMeta()`.
221
- *
222
- * **Why clone, not mutate.** The shared store keys metadata on the
223
- * schema reference. Calling `withMeta` twice on the same instance
224
- * would overwrite (last-write-wins) — so a sub-schema reused at
225
- * multiple form paths (e.g. an address schema shared between pickup
226
- * and delivery) couldn't carry distinct metadata per path.
227
- *
228
- * `withMeta` sidesteps the footgun by reconstructing `schema` via
229
- * its constructor + `_def` — Zod 3 schemas don't expose `.clone()`,
230
- * but `new schema.constructor(schema._def)` is the equivalent. Each
231
- * call gets a fresh identity and a fresh registry slot. Existing
232
- * metadata on the original is merged through, so chaining
233
- * `withMeta` accumulates payload fields rather than replacing.
234
- *
235
- * Inner field schemas (e.g. an object's `.shape.city`) are shared
236
- * across clones — the def is held by reference — so leaf metadata
237
- * registers once and surfaces at every path.
238
- *
239
- * `schema.register()` does NOT exist on Zod 3 — `withMeta` is the
240
- * only fluent write API. Register on the inner schema before
241
- * wrapping; see the "Registration rule" note in this file's header.
242
- */
243
- declare function withMeta<S extends z.ZodTypeAny>(schema: S, payload: FieldMetaPayload): S;
244
-
245
- export { FieldMetaPayload, FormKey, GenericForm, UnwrapZodRoot, UseFormConfiguration, UseFormReturnType, ValidateOnConfig, fieldMeta, isZodSchemaType, useForm, withMeta, zodAdapter };
246
- export type { TypeWithNullableDynamicKeys, ZodTypeWithInnerType };
@@ -1 +0,0 @@
1
- {"version":3,"file":"zod-v3.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;"}
package/dist/zod-v4.cjs DELETED
@@ -1,55 +0,0 @@
1
- 'use strict';
2
-
3
- const index = require('./shared/attaform.DdQN7sgN.cjs');
4
- const devtoolsShared = require('./shared/attaform.Biytrv0-.cjs');
5
- const serializeScript = require('./shared/attaform.DrvMscNX.cjs');
6
- const registerProtocol = require('./shared/attaform.yUrz7C2z.cjs');
7
-
8
-
9
-
10
- exports.UnsupportedSchemaError = index.UnsupportedSchemaError;
11
- exports.assertZodVersion = index.assertZodVersion;
12
- exports.fieldMeta = index.fieldMeta;
13
- exports.kindOf = index.kindOf;
14
- exports.useForm = index.useForm;
15
- exports.withMeta = index.withMeta;
16
- exports.zodAdapter = index.zodV4Adapter;
17
- exports.AttaformError = devtoolsShared.AttaformError;
18
- exports.DEVTOOLS_WINDOW_KEY = devtoolsShared.DEVTOOLS_WINDOW_KEY;
19
- exports.InvalidPathError = devtoolsShared.InvalidPathError;
20
- exports.InvalidUseFormConfigError = devtoolsShared.InvalidUseFormConfigError;
21
- exports.OutsideSetupError = devtoolsShared.OutsideSetupError;
22
- exports.ROOT_PATH = devtoolsShared.ROOT_PATH;
23
- exports.ROOT_PATH_KEY = devtoolsShared.ROOT_PATH_KEY;
24
- exports.RegistryNotInstalledError = devtoolsShared.RegistryNotInstalledError;
25
- exports.ReservedFormKeyError = devtoolsShared.ReservedFormKeyError;
26
- exports.SubmitErrorHandlerError = devtoolsShared.SubmitErrorHandlerError;
27
- exports.assignKey = devtoolsShared.assignKey;
28
- exports.canonicalizePath = devtoolsShared.canonicalizePath;
29
- exports.createAttaform = devtoolsShared.createAttaform;
30
- exports.createRegistry = devtoolsShared.createRegistry;
31
- exports.getRegistryFromApp = devtoolsShared.getRegistryFromApp;
32
- exports.hydrateAttaformState = devtoolsShared.hydrateAttaformState;
33
- exports.isPathPrefix = devtoolsShared.isPathPrefix;
34
- exports.kAttaformRegistry = devtoolsShared.kAttaformRegistry;
35
- exports.parseDottedPath = devtoolsShared.parseDottedPath;
36
- exports.renderAttaformState = devtoolsShared.renderAttaformState;
37
- exports.useRegistry = devtoolsShared.useRegistry;
38
- exports.vRegister = devtoolsShared.vRegister;
39
- exports.AttaformErrorCode = serializeScript.AttaformErrorCode;
40
- exports.DEFAULT_TIMINGS = serializeScript.DEFAULT_TIMINGS;
41
- exports.defaultCoercionRules = serializeScript.defaultCoercionRules;
42
- exports.defaultDisplayState = serializeScript.defaultDisplayState;
43
- exports.defineCoercion = serializeScript.defineCoercion;
44
- exports.escapeForInlineScript = serializeScript.escapeForInlineScript;
45
- exports.gate = serializeScript.gate;
46
- exports.injectForm = serializeScript.injectForm;
47
- exports.injectWizard = serializeScript.injectWizard;
48
- exports.isUnset = serializeScript.isUnset;
49
- exports.lazy = serializeScript.lazy;
50
- exports.makeDefaultDisplayState = serializeScript.makeDefaultDisplayState;
51
- exports.unset = serializeScript.unset;
52
- exports.useRegister = serializeScript.useRegister;
53
- exports.useWizard = serializeScript.useWizard;
54
- exports.isRegisterValue = registerProtocol.isRegisterValue;
55
- //# sourceMappingURL=zod-v4.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"zod-v4.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}