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.
- package/README.md +21 -11
- package/dist/chunks/devtools.cjs +4 -4
- package/dist/chunks/devtools.cjs.map +1 -1
- package/dist/chunks/devtools.mjs +2 -2
- package/dist/chunks/indexeddb.cjs +4 -4
- package/dist/chunks/indexeddb.cjs.map +1 -1
- package/dist/chunks/indexeddb.mjs +1 -1
- package/dist/chunks/local-storage.cjs +2 -2
- package/dist/chunks/local-storage.cjs.map +1 -1
- package/dist/chunks/local-storage.mjs +1 -1
- package/dist/chunks/session-storage.cjs +2 -2
- package/dist/chunks/session-storage.cjs.map +1 -1
- package/dist/chunks/session-storage.mjs +1 -1
- package/dist/index.cjs +23 -22
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +76 -71
- package/dist/index.d.mts +76 -71
- package/dist/index.d.ts +76 -71
- package/dist/index.mjs +6 -6
- package/dist/nuxt.cjs +5 -11
- package/dist/nuxt.cjs.map +1 -1
- package/dist/nuxt.d.cts +8 -0
- package/dist/nuxt.d.mts +8 -0
- package/dist/nuxt.d.ts +8 -0
- package/dist/nuxt.mjs +6 -12
- package/dist/nuxt.mjs.map +1 -1
- package/dist/runtime/plugins/attaform.cjs +3 -2
- package/dist/runtime/plugins/attaform.cjs.map +1 -1
- package/dist/runtime/plugins/attaform.mjs +2 -1
- package/dist/runtime/plugins/attaform.mjs.map +1 -1
- package/dist/shared/{attaform.BwaYWtMs.d.cts → attaform.B7rzpK1U.d.cts} +34 -5
- package/dist/shared/{attaform.BwaYWtMs.d.mts → attaform.B7rzpK1U.d.mts} +34 -5
- package/dist/shared/{attaform.BwaYWtMs.d.ts → attaform.B7rzpK1U.d.ts} +34 -5
- package/dist/shared/attaform.BAuJTWuT.d.mts +84 -0
- package/dist/shared/{attaform.CRk8NhlD.mjs → attaform.BfMxsfmE.mjs} +428 -49
- package/dist/shared/attaform.BfMxsfmE.mjs.map +1 -0
- package/dist/shared/attaform.Bp1c-uGF.cjs +1561 -0
- package/dist/shared/attaform.Bp1c-uGF.cjs.map +1 -0
- package/dist/shared/{attaform.CDJVeoJU.cjs → attaform.C9Ph2SMx.cjs} +49 -42
- package/dist/shared/{attaform.qxyip_aN.mjs.map → attaform.C9Ph2SMx.cjs.map} +1 -1
- package/dist/shared/attaform.CINUMjPq.mjs +29 -0
- package/dist/shared/attaform.CINUMjPq.mjs.map +1 -0
- package/dist/shared/attaform.CJttVxRj.cjs +32 -0
- package/dist/shared/attaform.CJttVxRj.cjs.map +1 -0
- package/dist/shared/{attaform.CPx7zTgS.d.mts → attaform.CVv9Oh0a.d.mts} +9 -7
- package/dist/shared/{attaform.riAENZQM.d.ts → attaform.CWCx2r0x.d.ts} +9 -7
- package/dist/shared/attaform.CvOXSpCb.mjs +1908 -0
- package/dist/shared/attaform.CvOXSpCb.mjs.map +1 -0
- package/dist/shared/{attaform.qxyip_aN.mjs → attaform.DILbdvfo.mjs} +12 -5
- package/dist/shared/{attaform.CDJVeoJU.cjs.map → attaform.DILbdvfo.mjs.map} +1 -1
- package/dist/shared/attaform.DdnithOf.mjs +1555 -0
- package/dist/shared/attaform.DdnithOf.mjs.map +1 -0
- package/dist/shared/attaform.DfrYByDj.cjs +1916 -0
- package/dist/shared/attaform.DfrYByDj.cjs.map +1 -0
- package/dist/shared/{attaform.D-eHWfVx.d.cts → attaform.Dq5BabH1.d.cts} +9 -7
- package/dist/shared/{attaform.BOi138GE.cjs → attaform.c_NzdRyc.cjs} +4 -4
- package/dist/shared/{attaform.BOi138GE.cjs.map → attaform.c_NzdRyc.cjs.map} +1 -1
- package/dist/shared/{attaform.DXye3JKf.mjs → attaform.jrxE_xZw.mjs} +2 -2
- package/dist/shared/{attaform.DXye3JKf.mjs.map → attaform.jrxE_xZw.mjs.map} +1 -1
- package/dist/shared/attaform.ls_7jBYc.d.ts +84 -0
- package/dist/shared/{attaform.BgYBU8gV.cjs → attaform.rIRYSUI1.cjs} +461 -61
- package/dist/shared/attaform.rIRYSUI1.cjs.map +1 -0
- package/dist/shared/attaform.xIcmqscx.d.cts +84 -0
- package/dist/vite.cjs +62 -9
- package/dist/vite.cjs.map +1 -1
- package/dist/vite.d.cts +23 -32
- package/dist/vite.d.mts +23 -32
- package/dist/vite.d.ts +23 -32
- package/dist/vite.mjs +62 -9
- package/dist/vite.mjs.map +1 -1
- package/dist/zod-v3.cjs +9 -1553
- package/dist/zod-v3.cjs.map +1 -1
- package/dist/zod-v3.d.cts +1 -1
- package/dist/zod-v3.d.mts +1 -1
- package/dist/zod-v3.d.ts +1 -1
- package/dist/zod-v3.mjs +3 -1553
- package/dist/zod-v3.mjs.map +1 -1
- package/dist/zod-v4.cjs +21 -0
- package/dist/zod-v4.cjs.map +1 -0
- package/dist/zod-v4.d.cts +104 -0
- package/dist/zod-v4.d.mts +104 -0
- package/dist/zod-v4.d.ts +104 -0
- package/dist/zod-v4.mjs +4 -0
- package/dist/zod-v4.mjs.map +1 -0
- package/dist/zod.cjs +19 -1900
- package/dist/zod.cjs.map +1 -1
- package/dist/zod.d.cts +28 -156
- package/dist/zod.d.mts +28 -156
- package/dist/zod.d.ts +28 -156
- package/dist/zod.mjs +19 -1896
- package/dist/zod.mjs.map +1 -1
- package/package.json +6 -2
- package/dist/shared/attaform.BgYBU8gV.cjs.map +0 -1
- package/dist/shared/attaform.CRk8NhlD.mjs.map +0 -1
- package/dist/shared/attaform.RypIkgVy.cjs +0 -417
- package/dist/shared/attaform.RypIkgVy.cjs.map +0 -1
- package/dist/shared/attaform.a99dQV7Q.mjs +0 -392
- 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 };
|
package/dist/zod-v4.d.ts
ADDED
|
@@ -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 };
|
package/dist/zod-v4.mjs
ADDED
|
@@ -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":";;"}
|