attaform 0.15.0 → 0.16.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 (98) hide show
  1. package/README.md +21 -11
  2. package/dist/chunks/devtools.cjs +4 -4
  3. package/dist/chunks/devtools.cjs.map +1 -1
  4. package/dist/chunks/devtools.mjs +2 -2
  5. package/dist/chunks/indexeddb.cjs +4 -4
  6. package/dist/chunks/indexeddb.cjs.map +1 -1
  7. package/dist/chunks/indexeddb.mjs +1 -1
  8. package/dist/chunks/local-storage.cjs +2 -2
  9. package/dist/chunks/local-storage.cjs.map +1 -1
  10. package/dist/chunks/local-storage.mjs +1 -1
  11. package/dist/chunks/session-storage.cjs +2 -2
  12. package/dist/chunks/session-storage.cjs.map +1 -1
  13. package/dist/chunks/session-storage.mjs +1 -1
  14. package/dist/index.cjs +23 -22
  15. package/dist/index.cjs.map +1 -1
  16. package/dist/index.d.cts +76 -71
  17. package/dist/index.d.mts +76 -71
  18. package/dist/index.d.ts +76 -71
  19. package/dist/index.mjs +6 -6
  20. package/dist/nuxt.cjs +5 -11
  21. package/dist/nuxt.cjs.map +1 -1
  22. package/dist/nuxt.d.cts +8 -0
  23. package/dist/nuxt.d.mts +8 -0
  24. package/dist/nuxt.d.ts +8 -0
  25. package/dist/nuxt.mjs +6 -12
  26. package/dist/nuxt.mjs.map +1 -1
  27. package/dist/runtime/plugins/attaform.cjs +3 -2
  28. package/dist/runtime/plugins/attaform.cjs.map +1 -1
  29. package/dist/runtime/plugins/attaform.mjs +2 -1
  30. package/dist/runtime/plugins/attaform.mjs.map +1 -1
  31. package/dist/shared/{attaform.BwaYWtMs.d.cts → attaform.B7rzpK1U.d.cts} +34 -5
  32. package/dist/shared/{attaform.BwaYWtMs.d.mts → attaform.B7rzpK1U.d.mts} +34 -5
  33. package/dist/shared/{attaform.BwaYWtMs.d.ts → attaform.B7rzpK1U.d.ts} +34 -5
  34. package/dist/shared/attaform.BAuJTWuT.d.mts +84 -0
  35. package/dist/shared/{attaform.CRk8NhlD.mjs → attaform.BfMxsfmE.mjs} +428 -49
  36. package/dist/shared/attaform.BfMxsfmE.mjs.map +1 -0
  37. package/dist/shared/attaform.Bp1c-uGF.cjs +1561 -0
  38. package/dist/shared/attaform.Bp1c-uGF.cjs.map +1 -0
  39. package/dist/shared/{attaform.CDJVeoJU.cjs → attaform.C9Ph2SMx.cjs} +49 -42
  40. package/dist/shared/{attaform.qxyip_aN.mjs.map → attaform.C9Ph2SMx.cjs.map} +1 -1
  41. package/dist/shared/attaform.CINUMjPq.mjs +29 -0
  42. package/dist/shared/attaform.CINUMjPq.mjs.map +1 -0
  43. package/dist/shared/attaform.CJttVxRj.cjs +32 -0
  44. package/dist/shared/attaform.CJttVxRj.cjs.map +1 -0
  45. package/dist/shared/{attaform.CPx7zTgS.d.mts → attaform.CVv9Oh0a.d.mts} +9 -7
  46. package/dist/shared/{attaform.riAENZQM.d.ts → attaform.CWCx2r0x.d.ts} +9 -7
  47. package/dist/shared/attaform.CvOXSpCb.mjs +1908 -0
  48. package/dist/shared/attaform.CvOXSpCb.mjs.map +1 -0
  49. package/dist/shared/{attaform.qxyip_aN.mjs → attaform.DILbdvfo.mjs} +12 -5
  50. package/dist/shared/{attaform.CDJVeoJU.cjs.map → attaform.DILbdvfo.mjs.map} +1 -1
  51. package/dist/shared/attaform.DdnithOf.mjs +1555 -0
  52. package/dist/shared/attaform.DdnithOf.mjs.map +1 -0
  53. package/dist/shared/attaform.DfrYByDj.cjs +1916 -0
  54. package/dist/shared/attaform.DfrYByDj.cjs.map +1 -0
  55. package/dist/shared/{attaform.D-eHWfVx.d.cts → attaform.Dq5BabH1.d.cts} +9 -7
  56. package/dist/shared/{attaform.BOi138GE.cjs → attaform.c_NzdRyc.cjs} +4 -4
  57. package/dist/shared/{attaform.BOi138GE.cjs.map → attaform.c_NzdRyc.cjs.map} +1 -1
  58. package/dist/shared/{attaform.DXye3JKf.mjs → attaform.jrxE_xZw.mjs} +2 -2
  59. package/dist/shared/{attaform.DXye3JKf.mjs.map → attaform.jrxE_xZw.mjs.map} +1 -1
  60. package/dist/shared/attaform.ls_7jBYc.d.ts +84 -0
  61. package/dist/shared/{attaform.BgYBU8gV.cjs → attaform.rIRYSUI1.cjs} +461 -61
  62. package/dist/shared/attaform.rIRYSUI1.cjs.map +1 -0
  63. package/dist/shared/attaform.xIcmqscx.d.cts +84 -0
  64. package/dist/vite.cjs +62 -9
  65. package/dist/vite.cjs.map +1 -1
  66. package/dist/vite.d.cts +23 -32
  67. package/dist/vite.d.mts +23 -32
  68. package/dist/vite.d.ts +23 -32
  69. package/dist/vite.mjs +62 -9
  70. package/dist/vite.mjs.map +1 -1
  71. package/dist/zod-v3.cjs +9 -1553
  72. package/dist/zod-v3.cjs.map +1 -1
  73. package/dist/zod-v3.d.cts +1 -1
  74. package/dist/zod-v3.d.mts +1 -1
  75. package/dist/zod-v3.d.ts +1 -1
  76. package/dist/zod-v3.mjs +3 -1553
  77. package/dist/zod-v3.mjs.map +1 -1
  78. package/dist/zod-v4.cjs +21 -0
  79. package/dist/zod-v4.cjs.map +1 -0
  80. package/dist/zod-v4.d.cts +104 -0
  81. package/dist/zod-v4.d.mts +104 -0
  82. package/dist/zod-v4.d.ts +104 -0
  83. package/dist/zod-v4.mjs +4 -0
  84. package/dist/zod-v4.mjs.map +1 -0
  85. package/dist/zod.cjs +19 -1900
  86. package/dist/zod.cjs.map +1 -1
  87. package/dist/zod.d.cts +28 -156
  88. package/dist/zod.d.mts +28 -156
  89. package/dist/zod.d.ts +28 -156
  90. package/dist/zod.mjs +19 -1896
  91. package/dist/zod.mjs.map +1 -1
  92. package/package.json +6 -2
  93. package/dist/shared/attaform.BgYBU8gV.cjs.map +0 -1
  94. package/dist/shared/attaform.CRk8NhlD.mjs.map +0 -1
  95. package/dist/shared/attaform.RypIkgVy.cjs +0 -417
  96. package/dist/shared/attaform.RypIkgVy.cjs.map +0 -1
  97. package/dist/shared/attaform.a99dQV7Q.mjs +0 -392
  98. package/dist/shared/attaform.a99dQV7Q.mjs.map +0 -1
@@ -0,0 +1,104 @@
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';
6
+ import { a as AttaformError } from './shared/attaform.B7rzpK1U.mjs';
7
+ import 'vue';
8
+
9
+ /**
10
+ * Wrap a Zod v4 `ZodObject` schema in an `AbstractSchema` factory.
11
+ *
12
+ * Most consumers never call this directly — `useForm` from
13
+ * `attaform/zod` does the wrapping automatically. Reach for
14
+ * it when you need an adapter outside of `useForm` (e.g. validating
15
+ * data with the same library used elsewhere in the form runtime, or
16
+ * exposing the adapter to a custom integration).
17
+ *
18
+ * Throws if the schema isn't Zod v4, or contains kinds the adapter
19
+ * cannot represent (`z.promise`, `z.custom`, `z.templateLiteral`,
20
+ * recursive `z.lazy(...)`).
21
+ */
22
+ declare function zodV4Adapter<FormSchema extends z.ZodObject, Form extends z.infer<FormSchema>>(rootSchema: FormSchema): (formKey: FormKey) => AbstractSchema<Form, Form>;
23
+
24
+ /**
25
+ * Thrown when a Zod schema includes a kind the form library cannot
26
+ * represent: `z.promise`, `z.custom`, `z.templateLiteral`, or a
27
+ * recursive `z.lazy(...)` that loops back into itself.
28
+ *
29
+ * The error message includes the dotted path of the offending node
30
+ * so you can locate it without traversing the whole schema.
31
+ */
32
+ declare class UnsupportedSchemaError extends AttaformError {
33
+ }
34
+
35
+ /**
36
+ * The single file that reads Zod v4's internal `def` shape. Every other
37
+ * file in the zod-v4 adapter uses these public-shaped accessors — future
38
+ * Zod minor bumps that reshape internals touch only this file.
39
+ *
40
+ * Design principle: treat `schema.def.*` as an unstable surface, even when
41
+ * Zod's docs say otherwise. Each helper returns a narrow, well-typed slice;
42
+ * no adapter code outside this file does shape-based pattern matching on
43
+ * `def`.
44
+ */
45
+
46
+ /**
47
+ * Stable kind discriminant for a Zod v4 schema. Returned by
48
+ * `kindOf(schema)`. Use when building a custom integration that
49
+ * needs to branch on schema shape — most consumers don't need this.
50
+ */
51
+ type ZodKind = 'object' | 'array' | 'set' | 'record' | 'tuple' | 'union' | 'discriminated-union' | 'string' | 'number' | 'boolean' | 'bigint' | 'date' | 'enum' | 'literal' | 'null' | 'undefined' | 'any' | 'unknown' | 'optional' | 'nullable' | 'default' | 'pipe' | 'readonly' | 'nan' | 'void' | 'never' | 'lazy' | 'intersection' | 'catch' | 'promise' | 'custom' | 'template-literal';
52
+ /**
53
+ * Inspect a Zod v4 schema and return its `ZodKind`. Returns
54
+ * `'unknown'` for non-Zod inputs and unrecognised shapes.
55
+ *
56
+ * Useful when writing introspection helpers that branch on schema
57
+ * structure (e.g. custom error formatters or doc generators).
58
+ */
59
+ declare function kindOf(schema: unknown): ZodKind;
60
+ /**
61
+ * Verify a schema is Zod v4. Throws a clear error if it's a v3
62
+ * schema mistakenly imported through `attaform/zod`.
63
+ *
64
+ * Most consumers never call this directly — the v4 adapter calls it
65
+ * internally on every schema. Reach for it only when wiring a custom
66
+ * adapter that needs the same guard.
67
+ */
68
+ declare function assertZodVersion(schema: unknown): void;
69
+
70
+ /**
71
+ * Zod v4 adapter entry point. Re-exports the adapter + the useForm
72
+ * wrapper that threads zod-v4-specific schema types through
73
+ * useAbstractForm.
74
+ */
75
+
76
+ /**
77
+ * Create a form bound to a Zod v4 schema.
78
+ *
79
+ * ```ts
80
+ * import { useForm } from 'attaform/zod'
81
+ * import { z } from 'zod'
82
+ *
83
+ * const form = useForm({
84
+ * schema: z.object({
85
+ * email: z.email(),
86
+ * password: z.string().min(8),
87
+ * }),
88
+ * defaultValues: { email: '' },
89
+ * })
90
+ * ```
91
+ *
92
+ * Returns a form API exposing `register`, `values`, `errors`,
93
+ * `fields`, `setValue`, `handleSubmit`, `meta`, field-array
94
+ * helpers, and more. See `UseFormReturnType` for the full
95
+ * surface.
96
+ *
97
+ * For Zod v3, import from `attaform/zod-v3` instead.
98
+ */
99
+ declare function useForm<Schema extends z.ZodObject>(configuration: Omit<UseFormConfiguration<z.output<Schema> extends GenericForm ? z.output<Schema> : never, z.output<Schema> extends GenericForm ? z.output<Schema> : never, AbstractSchema<z.output<Schema> extends GenericForm ? z.output<Schema> : never, z.output<Schema> extends GenericForm ? z.output<Schema> : never>, DeepPartial<DefaultValuesShape<z.output<Schema> extends GenericForm ? z.output<Schema> : never>>>, 'schema' | 'validateOn' | 'debounceMs'> & {
100
+ schema: Schema;
101
+ } & ValidateOnConfig): UseFormReturnType<z.output<Schema> extends GenericForm ? z.output<Schema> : never, z.output<Schema> extends GenericForm ? z.output<Schema> : never>;
102
+
103
+ export { UnsupportedSchemaError, assertZodVersion, kindOf, useForm, zodV4Adapter as zodAdapter };
104
+ export type { ZodKind };
@@ -0,0 +1,104 @@
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';
6
+ import { a as AttaformError } from './shared/attaform.B7rzpK1U.js';
7
+ import 'vue';
8
+
9
+ /**
10
+ * Wrap a Zod v4 `ZodObject` schema in an `AbstractSchema` factory.
11
+ *
12
+ * Most consumers never call this directly — `useForm` from
13
+ * `attaform/zod` does the wrapping automatically. Reach for
14
+ * it when you need an adapter outside of `useForm` (e.g. validating
15
+ * data with the same library used elsewhere in the form runtime, or
16
+ * exposing the adapter to a custom integration).
17
+ *
18
+ * Throws if the schema isn't Zod v4, or contains kinds the adapter
19
+ * cannot represent (`z.promise`, `z.custom`, `z.templateLiteral`,
20
+ * recursive `z.lazy(...)`).
21
+ */
22
+ declare function zodV4Adapter<FormSchema extends z.ZodObject, Form extends z.infer<FormSchema>>(rootSchema: FormSchema): (formKey: FormKey) => AbstractSchema<Form, Form>;
23
+
24
+ /**
25
+ * Thrown when a Zod schema includes a kind the form library cannot
26
+ * represent: `z.promise`, `z.custom`, `z.templateLiteral`, or a
27
+ * recursive `z.lazy(...)` that loops back into itself.
28
+ *
29
+ * The error message includes the dotted path of the offending node
30
+ * so you can locate it without traversing the whole schema.
31
+ */
32
+ declare class UnsupportedSchemaError extends AttaformError {
33
+ }
34
+
35
+ /**
36
+ * The single file that reads Zod v4's internal `def` shape. Every other
37
+ * file in the zod-v4 adapter uses these public-shaped accessors — future
38
+ * Zod minor bumps that reshape internals touch only this file.
39
+ *
40
+ * Design principle: treat `schema.def.*` as an unstable surface, even when
41
+ * Zod's docs say otherwise. Each helper returns a narrow, well-typed slice;
42
+ * no adapter code outside this file does shape-based pattern matching on
43
+ * `def`.
44
+ */
45
+
46
+ /**
47
+ * Stable kind discriminant for a Zod v4 schema. Returned by
48
+ * `kindOf(schema)`. Use when building a custom integration that
49
+ * needs to branch on schema shape — most consumers don't need this.
50
+ */
51
+ type ZodKind = 'object' | 'array' | 'set' | 'record' | 'tuple' | 'union' | 'discriminated-union' | 'string' | 'number' | 'boolean' | 'bigint' | 'date' | 'enum' | 'literal' | 'null' | 'undefined' | 'any' | 'unknown' | 'optional' | 'nullable' | 'default' | 'pipe' | 'readonly' | 'nan' | 'void' | 'never' | 'lazy' | 'intersection' | 'catch' | 'promise' | 'custom' | 'template-literal';
52
+ /**
53
+ * Inspect a Zod v4 schema and return its `ZodKind`. Returns
54
+ * `'unknown'` for non-Zod inputs and unrecognised shapes.
55
+ *
56
+ * Useful when writing introspection helpers that branch on schema
57
+ * structure (e.g. custom error formatters or doc generators).
58
+ */
59
+ declare function kindOf(schema: unknown): ZodKind;
60
+ /**
61
+ * Verify a schema is Zod v4. Throws a clear error if it's a v3
62
+ * schema mistakenly imported through `attaform/zod`.
63
+ *
64
+ * Most consumers never call this directly — the v4 adapter calls it
65
+ * internally on every schema. Reach for it only when wiring a custom
66
+ * adapter that needs the same guard.
67
+ */
68
+ declare function assertZodVersion(schema: unknown): void;
69
+
70
+ /**
71
+ * Zod v4 adapter entry point. Re-exports the adapter + the useForm
72
+ * wrapper that threads zod-v4-specific schema types through
73
+ * useAbstractForm.
74
+ */
75
+
76
+ /**
77
+ * Create a form bound to a Zod v4 schema.
78
+ *
79
+ * ```ts
80
+ * import { useForm } from 'attaform/zod'
81
+ * import { z } from 'zod'
82
+ *
83
+ * const form = useForm({
84
+ * schema: z.object({
85
+ * email: z.email(),
86
+ * password: z.string().min(8),
87
+ * }),
88
+ * defaultValues: { email: '' },
89
+ * })
90
+ * ```
91
+ *
92
+ * Returns a form API exposing `register`, `values`, `errors`,
93
+ * `fields`, `setValue`, `handleSubmit`, `meta`, field-array
94
+ * helpers, and more. See `UseFormReturnType` for the full
95
+ * surface.
96
+ *
97
+ * For Zod v3, import from `attaform/zod-v3` instead.
98
+ */
99
+ declare function useForm<Schema extends z.ZodObject>(configuration: Omit<UseFormConfiguration<z.output<Schema> extends GenericForm ? z.output<Schema> : never, z.output<Schema> extends GenericForm ? z.output<Schema> : never, AbstractSchema<z.output<Schema> extends GenericForm ? z.output<Schema> : never, z.output<Schema> extends GenericForm ? z.output<Schema> : never>, DeepPartial<DefaultValuesShape<z.output<Schema> extends GenericForm ? z.output<Schema> : never>>>, 'schema' | 'validateOn' | 'debounceMs'> & {
100
+ schema: Schema;
101
+ } & ValidateOnConfig): UseFormReturnType<z.output<Schema> extends GenericForm ? z.output<Schema> : never, z.output<Schema> extends GenericForm ? z.output<Schema> : never>;
102
+
103
+ export { UnsupportedSchemaError, assertZodVersion, kindOf, useForm, zodV4Adapter as zodAdapter };
104
+ export type { ZodKind };
@@ -0,0 +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';
2
+ export { A as AttaformErrorCode, i as injectForm, a as isUnset, u as unset } from './shared/attaform.DILbdvfo.mjs';
3
+ export { u as useRegister } from './shared/attaform.BfMxsfmE.mjs';
4
+ //# sourceMappingURL=zod-v4.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"zod-v4.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}