attaform 0.16.4 → 0.17.1
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 +4 -2
- package/dist/chunks/devtools.cjs +19 -12
- package/dist/chunks/devtools.cjs.map +1 -1
- package/dist/chunks/devtools.mjs +19 -12
- package/dist/chunks/devtools.mjs.map +1 -1
- package/dist/chunks/indexeddb.cjs +1 -1
- package/dist/chunks/indexeddb.mjs +1 -1
- package/dist/chunks/local-storage.cjs +1 -1
- package/dist/chunks/local-storage.mjs +1 -1
- package/dist/chunks/session-storage.cjs +1 -1
- package/dist/chunks/session-storage.mjs +1 -1
- package/dist/index.cjs +26 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +52 -9
- package/dist/index.d.mts +52 -9
- package/dist/index.d.ts +52 -9
- package/dist/index.mjs +28 -9
- package/dist/index.mjs.map +1 -1
- package/dist/nuxt.d.cts +1 -1
- package/dist/nuxt.d.mts +1 -1
- package/dist/nuxt.d.ts +1 -1
- package/dist/runtime/plugins/attaform.cjs +3 -3
- package/dist/runtime/plugins/attaform.cjs.map +1 -1
- package/dist/runtime/plugins/attaform.mjs +3 -3
- package/dist/runtime/plugins/attaform.mjs.map +1 -1
- package/dist/shared/{attaform.CMRmwGDt.d.cts → attaform.B1jvxsOF.d.mts} +1 -1
- package/dist/shared/{attaform.DyV1O4tI.mjs → attaform.B3ZaPIzS.mjs} +1436 -391
- package/dist/shared/attaform.B3ZaPIzS.mjs.map +1 -0
- package/dist/shared/{attaform.Dd_pWnmn.cjs → attaform.B5qiXQwN.cjs} +59 -10
- package/dist/shared/attaform.B5qiXQwN.cjs.map +1 -0
- package/dist/shared/{attaform.CIwZtbGV.cjs → attaform.BBM2muQ9.cjs} +2 -2
- package/dist/shared/{attaform.CIwZtbGV.cjs.map → attaform.BBM2muQ9.cjs.map} +1 -1
- package/dist/shared/{attaform.keLBaHB6.cjs → attaform.BV40t5y2.cjs} +240 -115
- package/dist/shared/attaform.BV40t5y2.cjs.map +1 -0
- package/dist/shared/attaform.C0iFnTN0.d.ts +165 -0
- package/dist/shared/{attaform.CXMOheyZ.d.mts → attaform.C6qzEdIM.d.cts} +1 -1
- package/dist/shared/{attaform.CJttVxRj.cjs → attaform.C8LVFVVe.cjs} +2 -2
- package/dist/shared/{attaform.CJttVxRj.cjs.map → attaform.C8LVFVVe.cjs.map} +1 -1
- package/dist/shared/attaform.CHorcsIU.d.cts +165 -0
- package/dist/shared/{attaform.BfMxsfmE.mjs → attaform.CIEQgJnM.mjs} +143 -78
- package/dist/shared/attaform.CIEQgJnM.mjs.map +1 -0
- package/dist/shared/{attaform.CCQkY4Ta.d.ts → attaform.CTwNcpLE.d.ts} +1 -1
- package/dist/shared/{attaform.UA19EF3J.mjs → attaform.CVCmBKZX.mjs} +59 -10
- package/dist/shared/attaform.CVCmBKZX.mjs.map +1 -0
- package/dist/shared/{attaform.CU3JperC.d.cts → attaform.C_5aB6EQ.d.cts} +657 -135
- package/dist/shared/{attaform.CU3JperC.d.mts → attaform.C_5aB6EQ.d.mts} +657 -135
- package/dist/shared/{attaform.CU3JperC.d.ts → attaform.C_5aB6EQ.d.ts} +657 -135
- package/dist/shared/{attaform.fegmBJaq.cjs → attaform.Cer8JO_P.cjs} +1435 -389
- package/dist/shared/attaform.Cer8JO_P.cjs.map +1 -0
- package/dist/shared/{attaform.g7rfuXdz.mjs → attaform.CpERWz3u.mjs} +240 -115
- package/dist/shared/attaform.CpERWz3u.mjs.map +1 -0
- package/dist/shared/attaform.CuE-bS1C.d.mts +165 -0
- package/dist/shared/{attaform.rIRYSUI1.cjs → attaform.Dee2rU1P.cjs} +145 -77
- package/dist/shared/attaform.Dee2rU1P.cjs.map +1 -0
- package/dist/shared/{attaform.CINUMjPq.mjs → attaform.Vo-Kft0t.mjs} +2 -2
- package/dist/shared/{attaform.CINUMjPq.mjs.map → attaform.Vo-Kft0t.mjs.map} +1 -1
- package/dist/shared/{attaform.DZRj9s0s.mjs → attaform.h1sq3BFu.mjs} +2 -2
- package/dist/shared/{attaform.DZRj9s0s.mjs.map → attaform.h1sq3BFu.mjs.map} +1 -1
- package/dist/zod-v3.cjs +3 -3
- package/dist/zod-v3.d.cts +27 -5
- package/dist/zod-v3.d.mts +27 -5
- package/dist/zod-v3.d.ts +27 -5
- package/dist/zod-v3.mjs +3 -3
- package/dist/zod-v4.cjs +3 -3
- package/dist/zod-v4.d.cts +16 -42
- package/dist/zod-v4.d.mts +16 -42
- package/dist/zod-v4.d.ts +16 -42
- package/dist/zod-v4.mjs +3 -3
- package/dist/zod.cjs +4 -4
- package/dist/zod.cjs.map +1 -1
- package/dist/zod.d.cts +7 -5
- package/dist/zod.d.mts +7 -5
- package/dist/zod.d.ts +7 -5
- package/dist/zod.mjs +5 -5
- package/dist/zod.mjs.map +1 -1
- package/package.json +6 -11
- package/dist/shared/attaform.BfMxsfmE.mjs.map +0 -1
- package/dist/shared/attaform.Dd_pWnmn.cjs.map +0 -1
- package/dist/shared/attaform.DyV1O4tI.mjs.map +0 -1
- package/dist/shared/attaform.UA19EF3J.mjs.map +0 -1
- package/dist/shared/attaform.fegmBJaq.cjs.map +0 -1
- package/dist/shared/attaform.g7rfuXdz.mjs.map +0 -1
- package/dist/shared/attaform.keLBaHB6.cjs.map +0 -1
- package/dist/shared/attaform.rIRYSUI1.cjs.map +0 -1
package/dist/zod-v3.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { ag as ValidateOnConfig, F as FormKey, E as OnInvalidSubmitPolicy, X as PersistConfig, y as HistoryConfig, C as CoercionRegistry, G as GenericForm, U as UseFormConfiguration, b as AbstractSchema, D as DeepPartial, c as DefaultValuesShape, d as UseFormReturnType, o as FieldMetaPayload } from './shared/attaform.
|
|
3
|
-
export { ae as Unset, ao as isUnset, aq as unset } from './shared/attaform.
|
|
4
|
-
export { A as AttaformErrorCode, i as injectForm, u as useRegister } from './shared/attaform.
|
|
2
|
+
import { ag as ValidateOnConfig, F as FormKey, E as OnInvalidSubmitPolicy, X as PersistConfig, y as HistoryConfig, C as CoercionRegistry, G as GenericForm, U as UseFormConfiguration, b as AbstractSchema, D as DeepPartial, c as DefaultValuesShape, d as UseFormReturnType, ar as SchemaFactoryOptions, o as FieldMetaPayload } from './shared/attaform.C_5aB6EQ.cjs';
|
|
3
|
+
export { ae as Unset, ao as isUnset, aq as unset } from './shared/attaform.C_5aB6EQ.cjs';
|
|
4
|
+
export { A as AttaformErrorCode, i as injectForm, u as useRegister } from './shared/attaform.C6qzEdIM.cjs';
|
|
5
5
|
import 'vue';
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -59,6 +59,28 @@ type UseFormConfigurationWithZod<Schema extends z.ZodType<unknown>, DefaultValue
|
|
|
59
59
|
*/
|
|
60
60
|
type UnwrapZodObject<T> = T extends z.ZodEffects<infer Inner> ? UnwrapZodObject<Inner> : T extends z.ZodOptional<infer Inner> ? UnwrapZodObject<Inner> : T extends z.ZodNullable<infer Inner> ? UnwrapZodObject<Inner> : T extends z.ZodDefault<infer Inner> ? UnwrapZodObject<Inner> : T extends z.ZodObject<infer Shape> ? z.ZodObject<Shape> : never;
|
|
61
61
|
|
|
62
|
+
/**
|
|
63
|
+
* v3 mirror of the Zod v4 `StorageShape`. Per top-level key, default
|
|
64
|
+
* to `z.output<Shape[K]>` (the post-init view — defaults have fired,
|
|
65
|
+
* Zod's own recursion peels nested defaults inside structural
|
|
66
|
+
* containers); fall back to `z.input<Shape[K]>` for transform / pipe
|
|
67
|
+
* carriers (`ZodEffects`, `ZodPipeline`) where storage holds the
|
|
68
|
+
* pre-transform input — transforms only run at submission /
|
|
69
|
+
* validation, not at the write boundary.
|
|
70
|
+
*
|
|
71
|
+
* v3 quirk: `ZodEffects` covers BOTH `.transform()` and
|
|
72
|
+
* `z.preprocess()` at the TS level — v3 doesn't carry a separate
|
|
73
|
+
* preprocess class the way v4 does. Deferring to `z.input` for
|
|
74
|
+
* `ZodEffects` means a top-level `z.preprocess(fn, T)` leaf reads as
|
|
75
|
+
* the preprocess input (commonly `unknown`); reach for the
|
|
76
|
+
* `AbstractSchema` escape hatch if a stronger type is needed.
|
|
77
|
+
* Transforms preserve their pre-transform input shape, which matches
|
|
78
|
+
* storage.
|
|
79
|
+
*/
|
|
80
|
+
type StorageShape<S extends z.ZodTypeAny> = S extends z.ZodObject<infer Shape> ? {
|
|
81
|
+
[K in keyof Shape]-?: Shape[K] extends z.ZodEffects<z.ZodTypeAny> | z.ZodPipeline<z.ZodTypeAny, z.ZodTypeAny> ? z.input<Shape[K]> : z.output<Shape[K]>;
|
|
82
|
+
} : z.input<S>;
|
|
83
|
+
|
|
62
84
|
/**
|
|
63
85
|
* Create a form bound to a custom `AbstractSchema` adapter.
|
|
64
86
|
*
|
|
@@ -97,7 +119,7 @@ declare function useForm<Form extends GenericForm, GetValueFormType extends Gene
|
|
|
97
119
|
*
|
|
98
120
|
* For Zod v4, import from `attaform/zod` instead.
|
|
99
121
|
*/
|
|
100
|
-
declare function useForm<Schema extends z.ZodObject<z.ZodRawShape>, GetValueFormType extends GenericForm = TypeWithNullableDynamicKeys<Schema>>(configuration: UseFormConfigurationWithZod<Schema, DeepPartial<DefaultValuesShape<z.
|
|
122
|
+
declare function useForm<Schema extends z.ZodObject<z.ZodRawShape>, GetValueFormType extends GenericForm = TypeWithNullableDynamicKeys<Schema>>(configuration: UseFormConfigurationWithZod<Schema, DeepPartial<DefaultValuesShape<z.input<UnwrapZodObject<Schema>>>>>): UseFormReturnType<z.input<UnwrapZodObject<Schema>>, GetValueFormType, StorageShape<UnwrapZodObject<Schema>> extends GenericForm ? StorageShape<UnwrapZodObject<Schema>> : never>;
|
|
101
123
|
|
|
102
124
|
/**
|
|
103
125
|
* Wrap a Zod v3 `ZodObject` schema in an `AbstractSchema` factory.
|
|
@@ -109,7 +131,7 @@ declare function useForm<Schema extends z.ZodObject<z.ZodRawShape>, GetValueForm
|
|
|
109
131
|
*
|
|
110
132
|
* Throws if the underlying schema isn't a `ZodObject`.
|
|
111
133
|
*/
|
|
112
|
-
declare function zodAdapter<FormSchema extends z.ZodSchema, Form extends z.
|
|
134
|
+
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>;
|
|
113
135
|
|
|
114
136
|
type ZodTypeMap = {
|
|
115
137
|
ZodObject: z.AnyZodObject;
|
package/dist/zod-v3.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { ag as ValidateOnConfig, F as FormKey, E as OnInvalidSubmitPolicy, X as PersistConfig, y as HistoryConfig, C as CoercionRegistry, G as GenericForm, U as UseFormConfiguration, b as AbstractSchema, D as DeepPartial, c as DefaultValuesShape, d as UseFormReturnType, o as FieldMetaPayload } from './shared/attaform.
|
|
3
|
-
export { ae as Unset, ao as isUnset, aq as unset } from './shared/attaform.
|
|
4
|
-
export { A as AttaformErrorCode, i as injectForm, u as useRegister } from './shared/attaform.
|
|
2
|
+
import { ag as ValidateOnConfig, F as FormKey, E as OnInvalidSubmitPolicy, X as PersistConfig, y as HistoryConfig, C as CoercionRegistry, G as GenericForm, U as UseFormConfiguration, b as AbstractSchema, D as DeepPartial, c as DefaultValuesShape, d as UseFormReturnType, ar as SchemaFactoryOptions, o as FieldMetaPayload } from './shared/attaform.C_5aB6EQ.mjs';
|
|
3
|
+
export { ae as Unset, ao as isUnset, aq as unset } from './shared/attaform.C_5aB6EQ.mjs';
|
|
4
|
+
export { A as AttaformErrorCode, i as injectForm, u as useRegister } from './shared/attaform.B1jvxsOF.mjs';
|
|
5
5
|
import 'vue';
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -59,6 +59,28 @@ type UseFormConfigurationWithZod<Schema extends z.ZodType<unknown>, DefaultValue
|
|
|
59
59
|
*/
|
|
60
60
|
type UnwrapZodObject<T> = T extends z.ZodEffects<infer Inner> ? UnwrapZodObject<Inner> : T extends z.ZodOptional<infer Inner> ? UnwrapZodObject<Inner> : T extends z.ZodNullable<infer Inner> ? UnwrapZodObject<Inner> : T extends z.ZodDefault<infer Inner> ? UnwrapZodObject<Inner> : T extends z.ZodObject<infer Shape> ? z.ZodObject<Shape> : never;
|
|
61
61
|
|
|
62
|
+
/**
|
|
63
|
+
* v3 mirror of the Zod v4 `StorageShape`. Per top-level key, default
|
|
64
|
+
* to `z.output<Shape[K]>` (the post-init view — defaults have fired,
|
|
65
|
+
* Zod's own recursion peels nested defaults inside structural
|
|
66
|
+
* containers); fall back to `z.input<Shape[K]>` for transform / pipe
|
|
67
|
+
* carriers (`ZodEffects`, `ZodPipeline`) where storage holds the
|
|
68
|
+
* pre-transform input — transforms only run at submission /
|
|
69
|
+
* validation, not at the write boundary.
|
|
70
|
+
*
|
|
71
|
+
* v3 quirk: `ZodEffects` covers BOTH `.transform()` and
|
|
72
|
+
* `z.preprocess()` at the TS level — v3 doesn't carry a separate
|
|
73
|
+
* preprocess class the way v4 does. Deferring to `z.input` for
|
|
74
|
+
* `ZodEffects` means a top-level `z.preprocess(fn, T)` leaf reads as
|
|
75
|
+
* the preprocess input (commonly `unknown`); reach for the
|
|
76
|
+
* `AbstractSchema` escape hatch if a stronger type is needed.
|
|
77
|
+
* Transforms preserve their pre-transform input shape, which matches
|
|
78
|
+
* storage.
|
|
79
|
+
*/
|
|
80
|
+
type StorageShape<S extends z.ZodTypeAny> = S extends z.ZodObject<infer Shape> ? {
|
|
81
|
+
[K in keyof Shape]-?: Shape[K] extends z.ZodEffects<z.ZodTypeAny> | z.ZodPipeline<z.ZodTypeAny, z.ZodTypeAny> ? z.input<Shape[K]> : z.output<Shape[K]>;
|
|
82
|
+
} : z.input<S>;
|
|
83
|
+
|
|
62
84
|
/**
|
|
63
85
|
* Create a form bound to a custom `AbstractSchema` adapter.
|
|
64
86
|
*
|
|
@@ -97,7 +119,7 @@ declare function useForm<Form extends GenericForm, GetValueFormType extends Gene
|
|
|
97
119
|
*
|
|
98
120
|
* For Zod v4, import from `attaform/zod` instead.
|
|
99
121
|
*/
|
|
100
|
-
declare function useForm<Schema extends z.ZodObject<z.ZodRawShape>, GetValueFormType extends GenericForm = TypeWithNullableDynamicKeys<Schema>>(configuration: UseFormConfigurationWithZod<Schema, DeepPartial<DefaultValuesShape<z.
|
|
122
|
+
declare function useForm<Schema extends z.ZodObject<z.ZodRawShape>, GetValueFormType extends GenericForm = TypeWithNullableDynamicKeys<Schema>>(configuration: UseFormConfigurationWithZod<Schema, DeepPartial<DefaultValuesShape<z.input<UnwrapZodObject<Schema>>>>>): UseFormReturnType<z.input<UnwrapZodObject<Schema>>, GetValueFormType, StorageShape<UnwrapZodObject<Schema>> extends GenericForm ? StorageShape<UnwrapZodObject<Schema>> : never>;
|
|
101
123
|
|
|
102
124
|
/**
|
|
103
125
|
* Wrap a Zod v3 `ZodObject` schema in an `AbstractSchema` factory.
|
|
@@ -109,7 +131,7 @@ declare function useForm<Schema extends z.ZodObject<z.ZodRawShape>, GetValueForm
|
|
|
109
131
|
*
|
|
110
132
|
* Throws if the underlying schema isn't a `ZodObject`.
|
|
111
133
|
*/
|
|
112
|
-
declare function zodAdapter<FormSchema extends z.ZodSchema, Form extends z.
|
|
134
|
+
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>;
|
|
113
135
|
|
|
114
136
|
type ZodTypeMap = {
|
|
115
137
|
ZodObject: z.AnyZodObject;
|
package/dist/zod-v3.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { ag as ValidateOnConfig, F as FormKey, E as OnInvalidSubmitPolicy, X as PersistConfig, y as HistoryConfig, C as CoercionRegistry, G as GenericForm, U as UseFormConfiguration, b as AbstractSchema, D as DeepPartial, c as DefaultValuesShape, d as UseFormReturnType, o as FieldMetaPayload } from './shared/attaform.
|
|
3
|
-
export { ae as Unset, ao as isUnset, aq as unset } from './shared/attaform.
|
|
4
|
-
export { A as AttaformErrorCode, i as injectForm, u as useRegister } from './shared/attaform.
|
|
2
|
+
import { ag as ValidateOnConfig, F as FormKey, E as OnInvalidSubmitPolicy, X as PersistConfig, y as HistoryConfig, C as CoercionRegistry, G as GenericForm, U as UseFormConfiguration, b as AbstractSchema, D as DeepPartial, c as DefaultValuesShape, d as UseFormReturnType, ar as SchemaFactoryOptions, o as FieldMetaPayload } from './shared/attaform.C_5aB6EQ.js';
|
|
3
|
+
export { ae as Unset, ao as isUnset, aq as unset } from './shared/attaform.C_5aB6EQ.js';
|
|
4
|
+
export { A as AttaformErrorCode, i as injectForm, u as useRegister } from './shared/attaform.CTwNcpLE.js';
|
|
5
5
|
import 'vue';
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -59,6 +59,28 @@ type UseFormConfigurationWithZod<Schema extends z.ZodType<unknown>, DefaultValue
|
|
|
59
59
|
*/
|
|
60
60
|
type UnwrapZodObject<T> = T extends z.ZodEffects<infer Inner> ? UnwrapZodObject<Inner> : T extends z.ZodOptional<infer Inner> ? UnwrapZodObject<Inner> : T extends z.ZodNullable<infer Inner> ? UnwrapZodObject<Inner> : T extends z.ZodDefault<infer Inner> ? UnwrapZodObject<Inner> : T extends z.ZodObject<infer Shape> ? z.ZodObject<Shape> : never;
|
|
61
61
|
|
|
62
|
+
/**
|
|
63
|
+
* v3 mirror of the Zod v4 `StorageShape`. Per top-level key, default
|
|
64
|
+
* to `z.output<Shape[K]>` (the post-init view — defaults have fired,
|
|
65
|
+
* Zod's own recursion peels nested defaults inside structural
|
|
66
|
+
* containers); fall back to `z.input<Shape[K]>` for transform / pipe
|
|
67
|
+
* carriers (`ZodEffects`, `ZodPipeline`) where storage holds the
|
|
68
|
+
* pre-transform input — transforms only run at submission /
|
|
69
|
+
* validation, not at the write boundary.
|
|
70
|
+
*
|
|
71
|
+
* v3 quirk: `ZodEffects` covers BOTH `.transform()` and
|
|
72
|
+
* `z.preprocess()` at the TS level — v3 doesn't carry a separate
|
|
73
|
+
* preprocess class the way v4 does. Deferring to `z.input` for
|
|
74
|
+
* `ZodEffects` means a top-level `z.preprocess(fn, T)` leaf reads as
|
|
75
|
+
* the preprocess input (commonly `unknown`); reach for the
|
|
76
|
+
* `AbstractSchema` escape hatch if a stronger type is needed.
|
|
77
|
+
* Transforms preserve their pre-transform input shape, which matches
|
|
78
|
+
* storage.
|
|
79
|
+
*/
|
|
80
|
+
type StorageShape<S extends z.ZodTypeAny> = S extends z.ZodObject<infer Shape> ? {
|
|
81
|
+
[K in keyof Shape]-?: Shape[K] extends z.ZodEffects<z.ZodTypeAny> | z.ZodPipeline<z.ZodTypeAny, z.ZodTypeAny> ? z.input<Shape[K]> : z.output<Shape[K]>;
|
|
82
|
+
} : z.input<S>;
|
|
83
|
+
|
|
62
84
|
/**
|
|
63
85
|
* Create a form bound to a custom `AbstractSchema` adapter.
|
|
64
86
|
*
|
|
@@ -97,7 +119,7 @@ declare function useForm<Form extends GenericForm, GetValueFormType extends Gene
|
|
|
97
119
|
*
|
|
98
120
|
* For Zod v4, import from `attaform/zod` instead.
|
|
99
121
|
*/
|
|
100
|
-
declare function useForm<Schema extends z.ZodObject<z.ZodRawShape>, GetValueFormType extends GenericForm = TypeWithNullableDynamicKeys<Schema>>(configuration: UseFormConfigurationWithZod<Schema, DeepPartial<DefaultValuesShape<z.
|
|
122
|
+
declare function useForm<Schema extends z.ZodObject<z.ZodRawShape>, GetValueFormType extends GenericForm = TypeWithNullableDynamicKeys<Schema>>(configuration: UseFormConfigurationWithZod<Schema, DeepPartial<DefaultValuesShape<z.input<UnwrapZodObject<Schema>>>>>): UseFormReturnType<z.input<UnwrapZodObject<Schema>>, GetValueFormType, StorageShape<UnwrapZodObject<Schema>> extends GenericForm ? StorageShape<UnwrapZodObject<Schema>> : never>;
|
|
101
123
|
|
|
102
124
|
/**
|
|
103
125
|
* Wrap a Zod v3 `ZodObject` schema in an `AbstractSchema` factory.
|
|
@@ -109,7 +131,7 @@ declare function useForm<Schema extends z.ZodObject<z.ZodRawShape>, GetValueForm
|
|
|
109
131
|
*
|
|
110
132
|
* Throws if the underlying schema isn't a `ZodObject`.
|
|
111
133
|
*/
|
|
112
|
-
declare function zodAdapter<FormSchema extends z.ZodSchema, Form extends z.
|
|
134
|
+
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>;
|
|
113
135
|
|
|
114
136
|
type ZodTypeMap = {
|
|
115
137
|
ZodObject: z.AnyZodObject;
|
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.
|
|
2
|
-
export { A as AttaformErrorCode, i as injectForm, a as isUnset, u as unset } from './shared/attaform.
|
|
3
|
-
export { u as useRegister } from './shared/attaform.
|
|
1
|
+
export { f as fieldMeta, i as isZodSchemaType, u as useForm, w as withMeta, z as zodAdapter } from './shared/attaform.CVCmBKZX.mjs';
|
|
2
|
+
export { A as AttaformErrorCode, i as injectForm, a as isUnset, u as unset } from './shared/attaform.B3ZaPIzS.mjs';
|
|
3
|
+
export { u as useRegister } from './shared/attaform.CIEQgJnM.mjs';
|
|
4
4
|
//# sourceMappingURL=zod-v3.mjs.map
|
package/dist/zod-v4.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const index = require('./shared/attaform.
|
|
4
|
-
const useFormContext = require('./shared/attaform.
|
|
5
|
-
const plugin = require('./shared/attaform.
|
|
3
|
+
const index = require('./shared/attaform.BV40t5y2.cjs');
|
|
4
|
+
const useFormContext = require('./shared/attaform.Cer8JO_P.cjs');
|
|
5
|
+
const plugin = require('./shared/attaform.Dee2rU1P.cjs');
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
package/dist/zod-v4.d.cts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
export { P as PathInput, a as PathOutput, u as useForm } from './shared/attaform.CHorcsIU.cjs';
|
|
2
|
+
export { A as AttaformErrorCode, i as injectForm, u as useRegister } from './shared/attaform.C6qzEdIM.cjs';
|
|
3
|
+
import { F as FormKey, ar as SchemaFactoryOptions, b as AbstractSchema, o as FieldMetaPayload } from './shared/attaform.C_5aB6EQ.cjs';
|
|
4
|
+
export { ae as Unset, ao as isUnset, aq as unset } from './shared/attaform.C_5aB6EQ.cjs';
|
|
1
5
|
import { z } from 'zod';
|
|
2
|
-
import { F as FormKey, b as AbstractSchema, U as UseFormConfiguration, G as GenericForm, D as DeepPartial, c as DefaultValuesShape, ag as ValidateOnConfig, d as UseFormReturnType, o as FieldMetaPayload } from './shared/attaform.CU3JperC.cjs';
|
|
3
|
-
export { ae as Unset, ao as isUnset, aq as unset } from './shared/attaform.CU3JperC.cjs';
|
|
4
|
-
export { A as AttaformErrorCode, i as injectForm, u as useRegister } from './shared/attaform.CMRmwGDt.cjs';
|
|
5
6
|
import { a as AttaformError } from './shared/attaform.B7rzpK1U.cjs';
|
|
6
7
|
import 'vue';
|
|
7
8
|
|
|
@@ -14,11 +15,17 @@ import 'vue';
|
|
|
14
15
|
* data with the same library used elsewhere in the form runtime, or
|
|
15
16
|
* exposing the adapter to a custom integration).
|
|
16
17
|
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
18
|
+
* The returned factory accepts per-form `SchemaFactoryOptions` (notably
|
|
19
|
+
* `maxRecursionDepth`); the adapter closure bakes them into every
|
|
20
|
+
* downstream walk so a per-form override can lift the cap without
|
|
21
|
+
* touching the app-level default.
|
|
22
|
+
*
|
|
23
|
+
* Throws if the schema isn't Zod v4 or contains kinds the adapter
|
|
24
|
+
* cannot represent (`z.promise`, `z.custom`, `z.templateLiteral`).
|
|
25
|
+
* Recursive `z.lazy(...)` is supported — the runtime walks bound their
|
|
26
|
+
* descent via `maxRecursionDepth`.
|
|
20
27
|
*/
|
|
21
|
-
declare function zodV4Adapter<FormSchema extends z.ZodObject, Form extends z.
|
|
28
|
+
declare function zodV4Adapter<FormSchema extends z.ZodObject, Form extends z.input<FormSchema>, GetValueFormType extends z.output<FormSchema> = z.output<FormSchema>>(rootSchema: FormSchema): (formKey: FormKey, options: SchemaFactoryOptions) => AbstractSchema<Form, GetValueFormType>;
|
|
22
29
|
|
|
23
30
|
/**
|
|
24
31
|
* Thrown when a Zod schema includes a kind the form library cannot
|
|
@@ -47,7 +54,7 @@ declare class UnsupportedSchemaError extends AttaformError {
|
|
|
47
54
|
* `kindOf(schema)`. Use when building a custom integration that
|
|
48
55
|
* needs to branch on schema shape — most consumers don't need this.
|
|
49
56
|
*/
|
|
50
|
-
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';
|
|
57
|
+
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' | 'transform';
|
|
51
58
|
/**
|
|
52
59
|
* Inspect a Zod v4 schema and return its `ZodKind`. Returns
|
|
53
60
|
* `'unknown'` for non-Zod inputs and unrecognised shapes.
|
|
@@ -66,39 +73,6 @@ declare function kindOf(schema: unknown): ZodKind;
|
|
|
66
73
|
*/
|
|
67
74
|
declare function assertZodVersion(schema: unknown): void;
|
|
68
75
|
|
|
69
|
-
/**
|
|
70
|
-
* Zod v4 adapter entry point. Re-exports the adapter + the useForm
|
|
71
|
-
* wrapper that threads zod-v4-specific schema types through
|
|
72
|
-
* useAbstractForm.
|
|
73
|
-
*/
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Create a form bound to a Zod v4 schema.
|
|
77
|
-
*
|
|
78
|
-
* ```ts
|
|
79
|
-
* import { useForm } from 'attaform/zod'
|
|
80
|
-
* import { z } from 'zod'
|
|
81
|
-
*
|
|
82
|
-
* const form = useForm({
|
|
83
|
-
* schema: z.object({
|
|
84
|
-
* email: z.email(),
|
|
85
|
-
* password: z.string().min(8),
|
|
86
|
-
* }),
|
|
87
|
-
* defaultValues: { email: '' },
|
|
88
|
-
* })
|
|
89
|
-
* ```
|
|
90
|
-
*
|
|
91
|
-
* Returns a form API exposing `register`, `values`, `errors`,
|
|
92
|
-
* `fields`, `setValue`, `handleSubmit`, `meta`, field-array
|
|
93
|
-
* helpers, and more. See `UseFormReturnType` for the full
|
|
94
|
-
* surface.
|
|
95
|
-
*
|
|
96
|
-
* For Zod v3, import from `attaform/zod-v3` instead.
|
|
97
|
-
*/
|
|
98
|
-
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'> & {
|
|
99
|
-
schema: Schema;
|
|
100
|
-
} & ValidateOnConfig): UseFormReturnType<z.output<Schema> extends GenericForm ? z.output<Schema> : never, z.output<Schema> extends GenericForm ? z.output<Schema> : never>;
|
|
101
|
-
|
|
102
76
|
/**
|
|
103
77
|
* Field-metadata write/read API for the Zod v4 adapter.
|
|
104
78
|
*
|
|
@@ -189,5 +163,5 @@ declare const fieldMeta: ZodFieldMetaRegistry;
|
|
|
189
163
|
*/
|
|
190
164
|
declare function withMeta<S extends z.ZodType>(schema: S, payload: FieldMetaPayload): S;
|
|
191
165
|
|
|
192
|
-
export { FieldMetaPayload, UnsupportedSchemaError, assertZodVersion, fieldMeta, kindOf,
|
|
166
|
+
export { FieldMetaPayload, UnsupportedSchemaError, assertZodVersion, fieldMeta, kindOf, withMeta, zodV4Adapter as zodAdapter };
|
|
193
167
|
export type { ZodKind };
|
package/dist/zod-v4.d.mts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
export { P as PathInput, a as PathOutput, u as useForm } from './shared/attaform.CuE-bS1C.mjs';
|
|
2
|
+
export { A as AttaformErrorCode, i as injectForm, u as useRegister } from './shared/attaform.B1jvxsOF.mjs';
|
|
3
|
+
import { F as FormKey, ar as SchemaFactoryOptions, b as AbstractSchema, o as FieldMetaPayload } from './shared/attaform.C_5aB6EQ.mjs';
|
|
4
|
+
export { ae as Unset, ao as isUnset, aq as unset } from './shared/attaform.C_5aB6EQ.mjs';
|
|
1
5
|
import { z } from 'zod';
|
|
2
|
-
import { F as FormKey, b as AbstractSchema, U as UseFormConfiguration, G as GenericForm, D as DeepPartial, c as DefaultValuesShape, ag as ValidateOnConfig, d as UseFormReturnType, o as FieldMetaPayload } from './shared/attaform.CU3JperC.mjs';
|
|
3
|
-
export { ae as Unset, ao as isUnset, aq as unset } from './shared/attaform.CU3JperC.mjs';
|
|
4
|
-
export { A as AttaformErrorCode, i as injectForm, u as useRegister } from './shared/attaform.CXMOheyZ.mjs';
|
|
5
6
|
import { a as AttaformError } from './shared/attaform.B7rzpK1U.mjs';
|
|
6
7
|
import 'vue';
|
|
7
8
|
|
|
@@ -14,11 +15,17 @@ import 'vue';
|
|
|
14
15
|
* data with the same library used elsewhere in the form runtime, or
|
|
15
16
|
* exposing the adapter to a custom integration).
|
|
16
17
|
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
18
|
+
* The returned factory accepts per-form `SchemaFactoryOptions` (notably
|
|
19
|
+
* `maxRecursionDepth`); the adapter closure bakes them into every
|
|
20
|
+
* downstream walk so a per-form override can lift the cap without
|
|
21
|
+
* touching the app-level default.
|
|
22
|
+
*
|
|
23
|
+
* Throws if the schema isn't Zod v4 or contains kinds the adapter
|
|
24
|
+
* cannot represent (`z.promise`, `z.custom`, `z.templateLiteral`).
|
|
25
|
+
* Recursive `z.lazy(...)` is supported — the runtime walks bound their
|
|
26
|
+
* descent via `maxRecursionDepth`.
|
|
20
27
|
*/
|
|
21
|
-
declare function zodV4Adapter<FormSchema extends z.ZodObject, Form extends z.
|
|
28
|
+
declare function zodV4Adapter<FormSchema extends z.ZodObject, Form extends z.input<FormSchema>, GetValueFormType extends z.output<FormSchema> = z.output<FormSchema>>(rootSchema: FormSchema): (formKey: FormKey, options: SchemaFactoryOptions) => AbstractSchema<Form, GetValueFormType>;
|
|
22
29
|
|
|
23
30
|
/**
|
|
24
31
|
* Thrown when a Zod schema includes a kind the form library cannot
|
|
@@ -47,7 +54,7 @@ declare class UnsupportedSchemaError extends AttaformError {
|
|
|
47
54
|
* `kindOf(schema)`. Use when building a custom integration that
|
|
48
55
|
* needs to branch on schema shape — most consumers don't need this.
|
|
49
56
|
*/
|
|
50
|
-
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';
|
|
57
|
+
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' | 'transform';
|
|
51
58
|
/**
|
|
52
59
|
* Inspect a Zod v4 schema and return its `ZodKind`. Returns
|
|
53
60
|
* `'unknown'` for non-Zod inputs and unrecognised shapes.
|
|
@@ -66,39 +73,6 @@ declare function kindOf(schema: unknown): ZodKind;
|
|
|
66
73
|
*/
|
|
67
74
|
declare function assertZodVersion(schema: unknown): void;
|
|
68
75
|
|
|
69
|
-
/**
|
|
70
|
-
* Zod v4 adapter entry point. Re-exports the adapter + the useForm
|
|
71
|
-
* wrapper that threads zod-v4-specific schema types through
|
|
72
|
-
* useAbstractForm.
|
|
73
|
-
*/
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Create a form bound to a Zod v4 schema.
|
|
77
|
-
*
|
|
78
|
-
* ```ts
|
|
79
|
-
* import { useForm } from 'attaform/zod'
|
|
80
|
-
* import { z } from 'zod'
|
|
81
|
-
*
|
|
82
|
-
* const form = useForm({
|
|
83
|
-
* schema: z.object({
|
|
84
|
-
* email: z.email(),
|
|
85
|
-
* password: z.string().min(8),
|
|
86
|
-
* }),
|
|
87
|
-
* defaultValues: { email: '' },
|
|
88
|
-
* })
|
|
89
|
-
* ```
|
|
90
|
-
*
|
|
91
|
-
* Returns a form API exposing `register`, `values`, `errors`,
|
|
92
|
-
* `fields`, `setValue`, `handleSubmit`, `meta`, field-array
|
|
93
|
-
* helpers, and more. See `UseFormReturnType` for the full
|
|
94
|
-
* surface.
|
|
95
|
-
*
|
|
96
|
-
* For Zod v3, import from `attaform/zod-v3` instead.
|
|
97
|
-
*/
|
|
98
|
-
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'> & {
|
|
99
|
-
schema: Schema;
|
|
100
|
-
} & ValidateOnConfig): UseFormReturnType<z.output<Schema> extends GenericForm ? z.output<Schema> : never, z.output<Schema> extends GenericForm ? z.output<Schema> : never>;
|
|
101
|
-
|
|
102
76
|
/**
|
|
103
77
|
* Field-metadata write/read API for the Zod v4 adapter.
|
|
104
78
|
*
|
|
@@ -189,5 +163,5 @@ declare const fieldMeta: ZodFieldMetaRegistry;
|
|
|
189
163
|
*/
|
|
190
164
|
declare function withMeta<S extends z.ZodType>(schema: S, payload: FieldMetaPayload): S;
|
|
191
165
|
|
|
192
|
-
export { FieldMetaPayload, UnsupportedSchemaError, assertZodVersion, fieldMeta, kindOf,
|
|
166
|
+
export { FieldMetaPayload, UnsupportedSchemaError, assertZodVersion, fieldMeta, kindOf, withMeta, zodV4Adapter as zodAdapter };
|
|
193
167
|
export type { ZodKind };
|
package/dist/zod-v4.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
export { P as PathInput, a as PathOutput, u as useForm } from './shared/attaform.C0iFnTN0.js';
|
|
2
|
+
export { A as AttaformErrorCode, i as injectForm, u as useRegister } from './shared/attaform.CTwNcpLE.js';
|
|
3
|
+
import { F as FormKey, ar as SchemaFactoryOptions, b as AbstractSchema, o as FieldMetaPayload } from './shared/attaform.C_5aB6EQ.js';
|
|
4
|
+
export { ae as Unset, ao as isUnset, aq as unset } from './shared/attaform.C_5aB6EQ.js';
|
|
1
5
|
import { z } from 'zod';
|
|
2
|
-
import { F as FormKey, b as AbstractSchema, U as UseFormConfiguration, G as GenericForm, D as DeepPartial, c as DefaultValuesShape, ag as ValidateOnConfig, d as UseFormReturnType, o as FieldMetaPayload } from './shared/attaform.CU3JperC.js';
|
|
3
|
-
export { ae as Unset, ao as isUnset, aq as unset } from './shared/attaform.CU3JperC.js';
|
|
4
|
-
export { A as AttaformErrorCode, i as injectForm, u as useRegister } from './shared/attaform.CCQkY4Ta.js';
|
|
5
6
|
import { a as AttaformError } from './shared/attaform.B7rzpK1U.js';
|
|
6
7
|
import 'vue';
|
|
7
8
|
|
|
@@ -14,11 +15,17 @@ import 'vue';
|
|
|
14
15
|
* data with the same library used elsewhere in the form runtime, or
|
|
15
16
|
* exposing the adapter to a custom integration).
|
|
16
17
|
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
18
|
+
* The returned factory accepts per-form `SchemaFactoryOptions` (notably
|
|
19
|
+
* `maxRecursionDepth`); the adapter closure bakes them into every
|
|
20
|
+
* downstream walk so a per-form override can lift the cap without
|
|
21
|
+
* touching the app-level default.
|
|
22
|
+
*
|
|
23
|
+
* Throws if the schema isn't Zod v4 or contains kinds the adapter
|
|
24
|
+
* cannot represent (`z.promise`, `z.custom`, `z.templateLiteral`).
|
|
25
|
+
* Recursive `z.lazy(...)` is supported — the runtime walks bound their
|
|
26
|
+
* descent via `maxRecursionDepth`.
|
|
20
27
|
*/
|
|
21
|
-
declare function zodV4Adapter<FormSchema extends z.ZodObject, Form extends z.
|
|
28
|
+
declare function zodV4Adapter<FormSchema extends z.ZodObject, Form extends z.input<FormSchema>, GetValueFormType extends z.output<FormSchema> = z.output<FormSchema>>(rootSchema: FormSchema): (formKey: FormKey, options: SchemaFactoryOptions) => AbstractSchema<Form, GetValueFormType>;
|
|
22
29
|
|
|
23
30
|
/**
|
|
24
31
|
* Thrown when a Zod schema includes a kind the form library cannot
|
|
@@ -47,7 +54,7 @@ declare class UnsupportedSchemaError extends AttaformError {
|
|
|
47
54
|
* `kindOf(schema)`. Use when building a custom integration that
|
|
48
55
|
* needs to branch on schema shape — most consumers don't need this.
|
|
49
56
|
*/
|
|
50
|
-
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';
|
|
57
|
+
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' | 'transform';
|
|
51
58
|
/**
|
|
52
59
|
* Inspect a Zod v4 schema and return its `ZodKind`. Returns
|
|
53
60
|
* `'unknown'` for non-Zod inputs and unrecognised shapes.
|
|
@@ -66,39 +73,6 @@ declare function kindOf(schema: unknown): ZodKind;
|
|
|
66
73
|
*/
|
|
67
74
|
declare function assertZodVersion(schema: unknown): void;
|
|
68
75
|
|
|
69
|
-
/**
|
|
70
|
-
* Zod v4 adapter entry point. Re-exports the adapter + the useForm
|
|
71
|
-
* wrapper that threads zod-v4-specific schema types through
|
|
72
|
-
* useAbstractForm.
|
|
73
|
-
*/
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Create a form bound to a Zod v4 schema.
|
|
77
|
-
*
|
|
78
|
-
* ```ts
|
|
79
|
-
* import { useForm } from 'attaform/zod'
|
|
80
|
-
* import { z } from 'zod'
|
|
81
|
-
*
|
|
82
|
-
* const form = useForm({
|
|
83
|
-
* schema: z.object({
|
|
84
|
-
* email: z.email(),
|
|
85
|
-
* password: z.string().min(8),
|
|
86
|
-
* }),
|
|
87
|
-
* defaultValues: { email: '' },
|
|
88
|
-
* })
|
|
89
|
-
* ```
|
|
90
|
-
*
|
|
91
|
-
* Returns a form API exposing `register`, `values`, `errors`,
|
|
92
|
-
* `fields`, `setValue`, `handleSubmit`, `meta`, field-array
|
|
93
|
-
* helpers, and more. See `UseFormReturnType` for the full
|
|
94
|
-
* surface.
|
|
95
|
-
*
|
|
96
|
-
* For Zod v3, import from `attaform/zod-v3` instead.
|
|
97
|
-
*/
|
|
98
|
-
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'> & {
|
|
99
|
-
schema: Schema;
|
|
100
|
-
} & ValidateOnConfig): UseFormReturnType<z.output<Schema> extends GenericForm ? z.output<Schema> : never, z.output<Schema> extends GenericForm ? z.output<Schema> : never>;
|
|
101
|
-
|
|
102
76
|
/**
|
|
103
77
|
* Field-metadata write/read API for the Zod v4 adapter.
|
|
104
78
|
*
|
|
@@ -189,5 +163,5 @@ declare const fieldMeta: ZodFieldMetaRegistry;
|
|
|
189
163
|
*/
|
|
190
164
|
declare function withMeta<S extends z.ZodType>(schema: S, payload: FieldMetaPayload): S;
|
|
191
165
|
|
|
192
|
-
export { FieldMetaPayload, UnsupportedSchemaError, assertZodVersion, fieldMeta, kindOf,
|
|
166
|
+
export { FieldMetaPayload, UnsupportedSchemaError, assertZodVersion, fieldMeta, kindOf, withMeta, zodV4Adapter as zodAdapter };
|
|
193
167
|
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.
|
|
2
|
-
export { A as AttaformErrorCode, i as injectForm, a as isUnset, u as unset } from './shared/attaform.
|
|
3
|
-
export { u as useRegister } from './shared/attaform.
|
|
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.CpERWz3u.mjs';
|
|
2
|
+
export { A as AttaformErrorCode, i as injectForm, a as isUnset, u as unset } from './shared/attaform.B3ZaPIzS.mjs';
|
|
3
|
+
export { u as useRegister } from './shared/attaform.CIEQgJnM.mjs';
|
|
4
4
|
//# sourceMappingURL=zod-v4.mjs.map
|
package/dist/zod.cjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const plugin = require('./shared/attaform.
|
|
4
|
-
const useForm$1 = require('./shared/attaform.
|
|
5
|
-
const index = require('./shared/attaform.
|
|
6
|
-
const useFormContext = require('./shared/attaform.
|
|
3
|
+
const plugin = require('./shared/attaform.Dee2rU1P.cjs');
|
|
4
|
+
const useForm$1 = require('./shared/attaform.B5qiXQwN.cjs');
|
|
5
|
+
const index = require('./shared/attaform.BV40t5y2.cjs');
|
|
6
|
+
const useFormContext = require('./shared/attaform.Cer8JO_P.cjs');
|
|
7
7
|
const fieldMetaStore = require('./shared/attaform.C8CyvYa_.cjs');
|
|
8
8
|
|
|
9
9
|
function isZodV4SchemaShape(value) {
|
package/dist/zod.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zod.cjs","sources":["../src/runtime/core/zod-shape.ts","../src/runtime/adapters/unified/use-form.ts","../src/runtime/adapters/unified/field-meta.ts"],"sourcesContent":["/**\n * Shape detectors for Zod schemas. Used by the unified `attaform/zod`\n * entry's runtime dispatch (`runtime/adapters/unified/use-form.ts`)\n * to route to the v3 or v4 adapter based on the schema's runtime\n * shape. Mirrors the discrimination already used by the v4\n * introspection helper (`adapters/zod-v4/introspect.ts`'s\n * `assertZodVersion`, which reads `def.type`) and the v3 wrapper's\n * legitimate-input branch (`composables/use-form.ts`'s `isZodType`,\n * which reads `_def`).\n *\n * Why this discriminator and not `_zod` / `_def`:\n * - Zod v4 retained `_def` for backward compat — reading `_def` alone\n * misclassifies v4 schemas as v3.\n * - Zod v4's stable shape is `def.type: string` (lowercase tag like\n * `'object'`); Zod v3's is `_def.typeName: string` (capitalised tag\n * like `'ZodObject'`). Both are checked structurally so consumers\n * who alias one Zod major to a non-standard import path still work.\n */\n\ninterface ZodV4Shape {\n def: { type: unknown }\n}\n\ninterface ZodV3Shape {\n _def: { typeName: unknown }\n}\n\n/**\n * Returns true when `value` looks like a Zod schema of either major\n * version. Convenience wrapper around the v3 / v4 detectors.\n */\nexport function isZodSchemaShape(value: unknown): boolean {\n return isZodV4SchemaShape(value) || isZodV3SchemaShape(value)\n}\n\n/**\n * Returns true when `value` looks like a Zod v4 schema (has\n * `def.type: string`). Used by the unified entry's runtime-dispatch\n * to route to the v4 adapter.\n */\nexport function isZodV4SchemaShape(value: unknown): value is ZodV4Shape {\n if (typeof value !== 'object' || value === null) return false\n const def = (value as { def?: unknown }).def\n if (typeof def !== 'object' || def === null) return false\n return typeof (def as { type?: unknown }).type === 'string'\n}\n\n/**\n * Returns true when `value` looks like a Zod v3 schema (has\n * `_def.typeName: string`). Kept distinct from `isZodV4SchemaShape`\n * because some v4 schemas also expose `_def` for backward compat —\n * the v4 detector wins first in `isZodSchemaShape`.\n */\nexport function isZodV3SchemaShape(value: unknown): value is ZodV3Shape {\n if (typeof value !== 'object' || value === null) return false\n const def = (value as { _def?: unknown })._def\n if (typeof def !== 'object' || def === null) return false\n return typeof (def as { typeName?: unknown }).typeName === 'string'\n}\n","/**\n * Unified `useForm` for the `attaform/zod` entry. Runtime-dispatches\n * on schema shape: a Zod v4 schema (`def.type` truthy) routes to the\n * v4 adapter; a Zod v3 schema (or any other `AbstractSchema`) routes\n * to the v3 wrapper, which already accepts both Zod v3 input and\n * `AbstractSchema` directly via its built-in shape branch.\n *\n * This module is the FALLBACK path. Vite consumers see the\n * `attaform/vite` plugin's `resolveId` hook rewrite `attaform/zod`\n * imports to either `attaform/zod-v3` or `attaform/zod-v4` at build\n * time — in that case this dispatch never runs and the consumer\n * bundle ships only the matching adapter. Other bundlers (and\n * non-bundled ESM consumption) hit this dispatch instead, paying a\n * modest size cost for the convenience of a single hello-world import.\n *\n * Power users who want a guaranteed lean bundle on non-Vite tooling\n * can import directly from `attaform/zod-v3` or `attaform/zod-v4` —\n * those subpaths are never rewritten and never load the other\n * adapter.\n */\nimport type { z } from 'zod'\nimport { InvalidUseFormConfigError } from '../../core/errors'\nimport { isZodV4SchemaShape } from '../../core/zod-shape'\nimport { useForm as useFormV3 } from '../../composables/use-form'\nimport { useForm as useFormV4 } from '../zod-v4'\nimport type {\n AbstractSchema,\n ValidateOnConfig,\n UseFormReturnType,\n UseFormConfiguration,\n} from '../../types/types-api'\nimport type { DeepPartial, DefaultValuesShape, GenericForm } from '../../types/types-core'\n\n/**\n * Create a form bound to a Zod schema. Accepts both Zod v3 and Zod v4\n * schemas; the runtime picks the right adapter from the schema's\n * shape.\n *\n * Type inference targets Zod v4 — the recommended major. Consumers\n * still on Zod v3 get correct runtime behavior here, but the strongest\n * TypeScript inference comes from importing `attaform/zod-v3`\n * directly.\n *\n * ```ts\n * import { useForm } from 'attaform/zod'\n * import { z } from 'zod'\n *\n * const form = useForm({\n * schema: z.object({\n * username: z.string().min(2, 'At least 2 characters'),\n * password: z.string().min(8, 'At least 8 characters'),\n * }),\n * })\n * ```\n */\nexport function useForm<Schema extends z.ZodObject>(\n configuration: Omit<\n UseFormConfiguration<\n z.output<Schema> extends GenericForm ? z.output<Schema> : never,\n z.output<Schema> extends GenericForm ? z.output<Schema> : never,\n AbstractSchema<\n z.output<Schema> extends GenericForm ? z.output<Schema> : never,\n z.output<Schema> extends GenericForm ? z.output<Schema> : never\n >,\n DeepPartial<\n DefaultValuesShape<z.output<Schema> extends GenericForm ? z.output<Schema> : never>\n >\n >,\n 'schema' | 'validateOn' | 'debounceMs'\n > & { schema: Schema } & ValidateOnConfig\n): UseFormReturnType<\n z.output<Schema> extends GenericForm ? z.output<Schema> : never,\n z.output<Schema> extends GenericForm ? z.output<Schema> : never\n> {\n // Foot-gun guard mirrors the typed wrappers'.\n if (\n configuration === undefined ||\n configuration === null ||\n (configuration as { schema?: unknown }).schema === undefined\n ) {\n throw new InvalidUseFormConfigError()\n }\n\n const { schema } = configuration as { schema: unknown }\n if (isZodV4SchemaShape(schema)) {\n return useFormV4(configuration as Parameters<typeof useFormV4<Schema>>[0]) as ReturnType<\n typeof useForm<Schema>\n >\n }\n // Anything else (Zod v3 schema, custom AbstractSchema, schema\n // factory) goes through the v3 wrapper, which already accepts both\n // Zod v3 input and AbstractSchema directly via its existing shape\n // branch. Cast through unknown — the unified entry's TS surface\n // tracks v4, but the runtime accepts the broader shape.\n return useFormV3(configuration as never) as unknown as ReturnType<typeof useForm<Schema>>\n}\n","/**\n * Field-metadata write/read API for the unified `attaform/zod` entry.\n *\n * Storage is shared with both adapters via `field-meta-store` — a\n * payload written here is visible to whichever adapter the unified\n * `useForm` dispatches to at runtime, regardless of Zod major. No\n * `zod` runtime import; the type-only `import type` is erased at\n * build, so `attaform/zod` carries no `z.registry` reference even\n * when consumed by a Zod 3 project without the Vite plugin alias.\n *\n * The native v4 chain `schema.register(fieldMeta, payload)` continues\n * to work — Zod 4's `.register()` only calls `.add(this, payload)`\n * structurally, satisfied by the shared store.\n */\nimport type { z } from 'zod'\nimport type { FieldMetaPayload } from '../../core/field-meta'\nimport { fieldMetaStore, getFieldMetaForSchema } from '../../core/field-meta-store'\n\n// Zod v4's `$ZodRegistry` class isn't surfaced under the `z` namespace\n// of the classic external entry, but `z.registry()` returns one — so\n// `ReturnType<typeof z.registry<T>>` resolves to the registry type\n// without needing a direct import. The `import type` keeps the\n// reference type-only; nothing about `z.registry` lands in the bundle.\ntype ZodFieldMetaRegistry = ReturnType<typeof z.registry<FieldMetaPayload>>\n\n/**\n * The shared registry every Attaform-aware Zod schema can register\n * field metadata against, regardless of major. Same instance the v3\n * and v4 adapter entries expose — write in one place, read from\n * any.\n *\n * Cast to Zod 4's `$ZodRegistry<FieldMetaPayload>` so the native\n * `schema.register(fieldMeta, payload)` chain type-checks for v4\n * users; the runtime call only needs `.add` structurally, which the\n * shared store provides.\n */\nexport const fieldMeta = fieldMetaStore as unknown as ZodFieldMetaRegistry\n\n/**\n * Attach `payload` to `schema` in the shared registry and return a\n * clone of `schema` so each call gets its own identity (the registry\n * keys on schema reference, so cloning prevents last-write-wins\n * collisions for sub-schemas reused at multiple paths).\n *\n * Works on both Zod 3 and Zod 4 schemas — branches on the runtime\n * shape of the schema:\n * - Zod 4 schemas expose a public `.clone()` method; we call it.\n * - Zod 3 schemas don't, so we reconstruct via\n * `new schema.constructor(schema._def)`.\n *\n * Both forms produce a fresh schema with the same effective\n * structure, so the registry slot is unique to this call site.\n */\nexport function withMeta<S>(schema: S, payload: FieldMetaPayload): S {\n const target = schema as object\n const existing = getFieldMetaForSchema(target) ?? {}\n const cloned = cloneSchema(schema)\n fieldMetaStore.add(cloned as object, { ...existing, ...payload })\n return cloned\n}\n\nfunction cloneSchema<S>(schema: S): S {\n const candidate = schema as { clone?: unknown; constructor: unknown; _def: unknown }\n if (typeof candidate.clone === 'function') {\n return (candidate.clone as () => S)()\n }\n // Zod 3 path: reconstruct via constructor + _def (no public\n // `.clone()` on v3).\n const Ctor = candidate.constructor as new (def: unknown) => S\n return new Ctor(candidate._def)\n}\n"],"names":["InvalidUseFormConfigError","useFormV4","useFormV3","fieldMetaStore","getFieldMetaForSchema"],"mappings":";;;;;;;;AAwCO,SAAS,mBAAmB,KAAA,EAAqC;AACtE,EAAA,IAAI,OAAO,KAAA,KAAU,QAAA,IAAY,KAAA,KAAU,MAAM,OAAO,KAAA;AACxD,EAAA,MAAM,MAAO,KAAA,CAA4B,GAAA;AACzC,EAAA,IAAI,OAAO,GAAA,KAAQ,QAAA,IAAY,GAAA,KAAQ,MAAM,OAAO,KAAA;AACpD,EAAA,OAAO,OAAQ,IAA2B,IAAA,KAAS,QAAA;AACrD;;ACUO,SAAS,QACd,aAAA,EAiBA;AAEA,EAAA,IACE,kBAAkB,MAAA,IAClB,aAAA,KAAkB,IAAA,IACjB,aAAA,CAAuC,WAAW,MAAA,EACnD;AACA,IAAA,MAAM,IAAIA,gCAAA,EAA0B;AAAA,EACtC;AAEA,EAAA,MAAM,EAAE,QAAO,GAAI,aAAA;AACnB,EAAA,IAAI,kBAAA,CAAmB,MAAM,CAAA,EAAG;AAC9B,IAAA,OAAOC,cAAU,aAAwD,CAAA;AAAA,EAG3E;AAMA,EAAA,OAAOC,kBAAU,aAAsB,CAAA;AACzC;;AC3DO,MAAM,SAAA,GAAYC;AAiBlB,SAAS,QAAA,CAAY,QAAW,OAAA,EAA8B;AACnE,EAAA,MAAM,MAAA,GAAS,MAAA;AACf,EAAA,MAAM,QAAA,GAAWC,oCAAA,CAAsB,MAAM,CAAA,IAAK,EAAC;AACnD,EAAA,MAAM,MAAA,GAAS,YAAY,MAAM,CAAA;AACjC,EAAAD,6BAAA,CAAe,IAAI,MAAA,EAAkB,EAAE,GAAG,QAAA,EAAU,GAAG,SAAS,CAAA;AAChE,EAAA,OAAO,MAAA;AACT;AAEA,SAAS,YAAe,MAAA,EAAc;AACpC,EAAA,MAAM,SAAA,GAAY,MAAA;AAClB,EAAA,IAAI,OAAO,SAAA,CAAU,KAAA,KAAU,UAAA,EAAY;AACzC,IAAA,OAAQ,UAAU,KAAA,EAAkB;AAAA,EACtC;AAGA,EAAA,MAAM,OAAO,SAAA,CAAU,WAAA;AACvB,EAAA,OAAO,IAAI,IAAA,CAAK,SAAA,CAAU,IAAI,CAAA;AAChC;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"zod.cjs","sources":["../src/runtime/core/zod-shape.ts","../src/runtime/adapters/unified/use-form.ts","../src/runtime/adapters/unified/field-meta.ts"],"sourcesContent":["/**\n * Shape detectors for Zod schemas. Used by the unified `attaform/zod`\n * entry's runtime dispatch (`runtime/adapters/unified/use-form.ts`)\n * to route to the v3 or v4 adapter based on the schema's runtime\n * shape. Mirrors the discrimination already used by the v4\n * introspection helper (`adapters/zod-v4/introspect.ts`'s\n * `assertZodVersion`, which reads `def.type`) and the v3 wrapper's\n * legitimate-input branch (`composables/use-form.ts`'s `isZodType`,\n * which reads `_def`).\n *\n * Why this discriminator and not `_zod` / `_def`:\n * - Zod v4 retained `_def` for backward compat — reading `_def` alone\n * misclassifies v4 schemas as v3.\n * - Zod v4's stable shape is `def.type: string` (lowercase tag like\n * `'object'`); Zod v3's is `_def.typeName: string` (capitalised tag\n * like `'ZodObject'`). Both are checked structurally so consumers\n * who alias one Zod major to a non-standard import path still work.\n */\n\ninterface ZodV4Shape {\n def: { type: unknown }\n}\n\ninterface ZodV3Shape {\n _def: { typeName: unknown }\n}\n\n/**\n * Returns true when `value` looks like a Zod schema of either major\n * version. Convenience wrapper around the v3 / v4 detectors.\n */\nexport function isZodSchemaShape(value: unknown): boolean {\n return isZodV4SchemaShape(value) || isZodV3SchemaShape(value)\n}\n\n/**\n * Returns true when `value` looks like a Zod v4 schema (has\n * `def.type: string`). Used by the unified entry's runtime-dispatch\n * to route to the v4 adapter.\n */\nexport function isZodV4SchemaShape(value: unknown): value is ZodV4Shape {\n if (typeof value !== 'object' || value === null) return false\n const def = (value as { def?: unknown }).def\n if (typeof def !== 'object' || def === null) return false\n return typeof (def as { type?: unknown }).type === 'string'\n}\n\n/**\n * Returns true when `value` looks like a Zod v3 schema (has\n * `_def.typeName: string`). Kept distinct from `isZodV4SchemaShape`\n * because some v4 schemas also expose `_def` for backward compat —\n * the v4 detector wins first in `isZodSchemaShape`.\n */\nexport function isZodV3SchemaShape(value: unknown): value is ZodV3Shape {\n if (typeof value !== 'object' || value === null) return false\n const def = (value as { _def?: unknown })._def\n if (typeof def !== 'object' || def === null) return false\n return typeof (def as { typeName?: unknown }).typeName === 'string'\n}\n","/**\n * Unified `useForm` for the `attaform/zod` entry. Runtime-dispatches\n * on schema shape: a Zod v4 schema (`def.type` truthy) routes to the\n * v4 adapter; a Zod v3 schema (or any other `AbstractSchema`) routes\n * to the v3 wrapper, which already accepts both Zod v3 input and\n * `AbstractSchema` directly via its built-in shape branch.\n *\n * This module is the FALLBACK path. Vite consumers see the\n * `attaform/vite` plugin's `resolveId` hook rewrite `attaform/zod`\n * imports to either `attaform/zod-v3` or `attaform/zod-v4` at build\n * time — in that case this dispatch never runs and the consumer\n * bundle ships only the matching adapter. Other bundlers (and\n * non-bundled ESM consumption) hit this dispatch instead, paying a\n * modest size cost for the convenience of a single hello-world import.\n *\n * Power users who want a guaranteed lean bundle on non-Vite tooling\n * can import directly from `attaform/zod-v3` or `attaform/zod-v4` —\n * those subpaths are never rewritten and never load the other\n * adapter.\n */\nimport type { z } from 'zod'\nimport { InvalidUseFormConfigError } from '../../core/errors'\nimport { isZodV4SchemaShape } from '../../core/zod-shape'\nimport { useForm as useFormV3 } from '../../composables/use-form'\nimport { useForm as useFormV4 } from '../zod-v4'\nimport type { StorageShape } from '../zod-v4/types-storage-shape'\nimport type {\n AbstractSchema,\n ValidateOnConfig,\n UseFormReturnType,\n UseFormConfiguration,\n} from '../../types/types-api'\nimport type { DeepPartial, DefaultValuesShape, GenericForm } from '../../types/types-core'\n\n/**\n * Create a form bound to a Zod schema. Accepts both Zod v3 and Zod v4\n * schemas; the runtime picks the right adapter from the schema's\n * shape.\n *\n * Type inference targets Zod v4 — the recommended major. Consumers\n * still on Zod v3 get correct runtime behavior here, but the strongest\n * TypeScript inference comes from importing `attaform/zod-v3`\n * directly.\n *\n * ```ts\n * import { useForm } from 'attaform/zod'\n * import { z } from 'zod'\n *\n * const form = useForm({\n * schema: z.object({\n * username: z.string().min(2, 'At least 2 characters'),\n * password: z.string().min(8, 'At least 8 characters'),\n * }),\n * })\n * ```\n */\nexport function useForm<Schema extends z.ZodObject>(\n configuration: Omit<\n UseFormConfiguration<\n z.input<Schema> extends GenericForm ? z.input<Schema> : never,\n z.output<Schema> extends GenericForm ? z.output<Schema> : never,\n AbstractSchema<\n z.input<Schema> extends GenericForm ? z.input<Schema> : never,\n z.output<Schema> extends GenericForm ? z.output<Schema> : never\n >,\n DeepPartial<DefaultValuesShape<z.input<Schema> extends GenericForm ? z.input<Schema> : never>>\n >,\n 'schema' | 'validateOn' | 'debounceMs'\n > & { schema: Schema } & ValidateOnConfig\n): UseFormReturnType<\n z.input<Schema> extends GenericForm ? z.input<Schema> : never,\n z.output<Schema> extends GenericForm ? z.output<Schema> : never,\n StorageShape<Schema> extends GenericForm ? StorageShape<Schema> : never\n> {\n // Foot-gun guard mirrors the typed wrappers'.\n if (\n configuration === undefined ||\n configuration === null ||\n (configuration as { schema?: unknown }).schema === undefined\n ) {\n throw new InvalidUseFormConfigError()\n }\n\n const { schema } = configuration as { schema: unknown }\n if (isZodV4SchemaShape(schema)) {\n return useFormV4(configuration as Parameters<typeof useFormV4<Schema>>[0]) as ReturnType<\n typeof useForm<Schema>\n >\n }\n // Anything else (Zod v3 schema, custom AbstractSchema, schema\n // factory) goes through the v3 wrapper, which already accepts both\n // Zod v3 input and AbstractSchema directly via its existing shape\n // branch. Cast through unknown — the unified entry's TS surface\n // tracks v4, but the runtime accepts the broader shape.\n return useFormV3(configuration as never) as unknown as ReturnType<typeof useForm<Schema>>\n}\n","/**\n * Field-metadata write/read API for the unified `attaform/zod` entry.\n *\n * Storage is shared with both adapters via `field-meta-store` — a\n * payload written here is visible to whichever adapter the unified\n * `useForm` dispatches to at runtime, regardless of Zod major. No\n * `zod` runtime import; the type-only `import type` is erased at\n * build, so `attaform/zod` carries no `z.registry` reference even\n * when consumed by a Zod 3 project without the Vite plugin alias.\n *\n * The native v4 chain `schema.register(fieldMeta, payload)` continues\n * to work — Zod 4's `.register()` only calls `.add(this, payload)`\n * structurally, satisfied by the shared store.\n */\nimport type { z } from 'zod'\nimport type { FieldMetaPayload } from '../../core/field-meta'\nimport { fieldMetaStore, getFieldMetaForSchema } from '../../core/field-meta-store'\n\n// Zod v4's `$ZodRegistry` class isn't surfaced under the `z` namespace\n// of the classic external entry, but `z.registry()` returns one — so\n// `ReturnType<typeof z.registry<T>>` resolves to the registry type\n// without needing a direct import. The `import type` keeps the\n// reference type-only; nothing about `z.registry` lands in the bundle.\ntype ZodFieldMetaRegistry = ReturnType<typeof z.registry<FieldMetaPayload>>\n\n/**\n * The shared registry every Attaform-aware Zod schema can register\n * field metadata against, regardless of major. Same instance the v3\n * and v4 adapter entries expose — write in one place, read from\n * any.\n *\n * Cast to Zod 4's `$ZodRegistry<FieldMetaPayload>` so the native\n * `schema.register(fieldMeta, payload)` chain type-checks for v4\n * users; the runtime call only needs `.add` structurally, which the\n * shared store provides.\n */\nexport const fieldMeta = fieldMetaStore as unknown as ZodFieldMetaRegistry\n\n/**\n * Attach `payload` to `schema` in the shared registry and return a\n * clone of `schema` so each call gets its own identity (the registry\n * keys on schema reference, so cloning prevents last-write-wins\n * collisions for sub-schemas reused at multiple paths).\n *\n * Works on both Zod 3 and Zod 4 schemas — branches on the runtime\n * shape of the schema:\n * - Zod 4 schemas expose a public `.clone()` method; we call it.\n * - Zod 3 schemas don't, so we reconstruct via\n * `new schema.constructor(schema._def)`.\n *\n * Both forms produce a fresh schema with the same effective\n * structure, so the registry slot is unique to this call site.\n */\nexport function withMeta<S>(schema: S, payload: FieldMetaPayload): S {\n const target = schema as object\n const existing = getFieldMetaForSchema(target) ?? {}\n const cloned = cloneSchema(schema)\n fieldMetaStore.add(cloned as object, { ...existing, ...payload })\n return cloned\n}\n\nfunction cloneSchema<S>(schema: S): S {\n const candidate = schema as { clone?: unknown; constructor: unknown; _def: unknown }\n if (typeof candidate.clone === 'function') {\n return (candidate.clone as () => S)()\n }\n // Zod 3 path: reconstruct via constructor + _def (no public\n // `.clone()` on v3).\n const Ctor = candidate.constructor as new (def: unknown) => S\n return new Ctor(candidate._def)\n}\n"],"names":["InvalidUseFormConfigError","useFormV4","useFormV3","fieldMetaStore","getFieldMetaForSchema"],"mappings":";;;;;;;;AAwCO,SAAS,mBAAmB,KAAA,EAAqC;AACtE,EAAA,IAAI,OAAO,KAAA,KAAU,QAAA,IAAY,KAAA,KAAU,MAAM,OAAO,KAAA;AACxD,EAAA,MAAM,MAAO,KAAA,CAA4B,GAAA;AACzC,EAAA,IAAI,OAAO,GAAA,KAAQ,QAAA,IAAY,GAAA,KAAQ,MAAM,OAAO,KAAA;AACpD,EAAA,OAAO,OAAQ,IAA2B,IAAA,KAAS,QAAA;AACrD;;ACWO,SAAS,QACd,aAAA,EAgBA;AAEA,EAAA,IACE,kBAAkB,MAAA,IAClB,aAAA,KAAkB,IAAA,IACjB,aAAA,CAAuC,WAAW,MAAA,EACnD;AACA,IAAA,MAAM,IAAIA,gCAAA,EAA0B;AAAA,EACtC;AAEA,EAAA,MAAM,EAAE,QAAO,GAAI,aAAA;AACnB,EAAA,IAAI,kBAAA,CAAmB,MAAM,CAAA,EAAG;AAC9B,IAAA,OAAOC,cAAU,aAAwD,CAAA;AAAA,EAG3E;AAMA,EAAA,OAAOC,kBAAU,aAAsB,CAAA;AACzC;;AC3DO,MAAM,SAAA,GAAYC;AAiBlB,SAAS,QAAA,CAAY,QAAW,OAAA,EAA8B;AACnE,EAAA,MAAM,MAAA,GAAS,MAAA;AACf,EAAA,MAAM,QAAA,GAAWC,oCAAA,CAAsB,MAAM,CAAA,IAAK,EAAC;AACnD,EAAA,MAAM,MAAA,GAAS,YAAY,MAAM,CAAA;AACjC,EAAAD,6BAAA,CAAe,IAAI,MAAA,EAAkB,EAAE,GAAG,QAAA,EAAU,GAAG,SAAS,CAAA;AAChE,EAAA,OAAO,MAAA;AACT;AAEA,SAAS,YAAe,MAAA,EAAc;AACpC,EAAA,MAAM,SAAA,GAAY,MAAA;AAClB,EAAA,IAAI,OAAO,SAAA,CAAU,KAAA,KAAU,UAAA,EAAY;AACzC,IAAA,OAAQ,UAAU,KAAA,EAAkB;AAAA,EACtC;AAGA,EAAA,MAAM,OAAO,SAAA,CAAU,WAAA;AACvB,EAAA,OAAO,IAAI,IAAA,CAAK,SAAA,CAAU,IAAI,CAAA;AAChC;;;;;;;;;;;"}
|
package/dist/zod.d.cts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import {
|
|
3
|
-
export {
|
|
4
|
-
|
|
2
|
+
import { S as StorageShape } from './shared/attaform.CHorcsIU.cjs';
|
|
3
|
+
export { P as PathInput, a as PathOutput } from './shared/attaform.CHorcsIU.cjs';
|
|
4
|
+
import { U as UseFormConfiguration, G as GenericForm, b as AbstractSchema, D as DeepPartial, c as DefaultValuesShape, ag as ValidateOnConfig, d as UseFormReturnType, o as FieldMetaPayload } from './shared/attaform.C_5aB6EQ.cjs';
|
|
5
|
+
export { ae as Unset, ao as isUnset, aq as unset } from './shared/attaform.C_5aB6EQ.cjs';
|
|
6
|
+
export { A as AttaformErrorCode, i as injectForm, u as useRegister } from './shared/attaform.C6qzEdIM.cjs';
|
|
5
7
|
import 'vue';
|
|
6
8
|
|
|
7
9
|
/**
|
|
@@ -47,9 +49,9 @@ import 'vue';
|
|
|
47
49
|
* })
|
|
48
50
|
* ```
|
|
49
51
|
*/
|
|
50
|
-
declare function useForm<Schema extends z.ZodObject>(configuration: Omit<UseFormConfiguration<z.
|
|
52
|
+
declare function useForm<Schema extends z.ZodObject>(configuration: Omit<UseFormConfiguration<z.input<Schema> extends GenericForm ? z.input<Schema> : never, z.output<Schema> extends GenericForm ? z.output<Schema> : never, AbstractSchema<z.input<Schema> extends GenericForm ? z.input<Schema> : never, z.output<Schema> extends GenericForm ? z.output<Schema> : never>, DeepPartial<DefaultValuesShape<z.input<Schema> extends GenericForm ? z.input<Schema> : never>>>, 'schema' | 'validateOn' | 'debounceMs'> & {
|
|
51
53
|
schema: Schema;
|
|
52
|
-
} & ValidateOnConfig): UseFormReturnType<z.
|
|
54
|
+
} & ValidateOnConfig): UseFormReturnType<z.input<Schema> extends GenericForm ? z.input<Schema> : never, z.output<Schema> extends GenericForm ? z.output<Schema> : never, StorageShape<Schema> extends GenericForm ? StorageShape<Schema> : never>;
|
|
53
55
|
|
|
54
56
|
/**
|
|
55
57
|
* Field-metadata write/read API for the unified `attaform/zod` entry.
|
package/dist/zod.d.mts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import {
|
|
3
|
-
export {
|
|
4
|
-
|
|
2
|
+
import { S as StorageShape } from './shared/attaform.CuE-bS1C.mjs';
|
|
3
|
+
export { P as PathInput, a as PathOutput } from './shared/attaform.CuE-bS1C.mjs';
|
|
4
|
+
import { U as UseFormConfiguration, G as GenericForm, b as AbstractSchema, D as DeepPartial, c as DefaultValuesShape, ag as ValidateOnConfig, d as UseFormReturnType, o as FieldMetaPayload } from './shared/attaform.C_5aB6EQ.mjs';
|
|
5
|
+
export { ae as Unset, ao as isUnset, aq as unset } from './shared/attaform.C_5aB6EQ.mjs';
|
|
6
|
+
export { A as AttaformErrorCode, i as injectForm, u as useRegister } from './shared/attaform.B1jvxsOF.mjs';
|
|
5
7
|
import 'vue';
|
|
6
8
|
|
|
7
9
|
/**
|
|
@@ -47,9 +49,9 @@ import 'vue';
|
|
|
47
49
|
* })
|
|
48
50
|
* ```
|
|
49
51
|
*/
|
|
50
|
-
declare function useForm<Schema extends z.ZodObject>(configuration: Omit<UseFormConfiguration<z.
|
|
52
|
+
declare function useForm<Schema extends z.ZodObject>(configuration: Omit<UseFormConfiguration<z.input<Schema> extends GenericForm ? z.input<Schema> : never, z.output<Schema> extends GenericForm ? z.output<Schema> : never, AbstractSchema<z.input<Schema> extends GenericForm ? z.input<Schema> : never, z.output<Schema> extends GenericForm ? z.output<Schema> : never>, DeepPartial<DefaultValuesShape<z.input<Schema> extends GenericForm ? z.input<Schema> : never>>>, 'schema' | 'validateOn' | 'debounceMs'> & {
|
|
51
53
|
schema: Schema;
|
|
52
|
-
} & ValidateOnConfig): UseFormReturnType<z.
|
|
54
|
+
} & ValidateOnConfig): UseFormReturnType<z.input<Schema> extends GenericForm ? z.input<Schema> : never, z.output<Schema> extends GenericForm ? z.output<Schema> : never, StorageShape<Schema> extends GenericForm ? StorageShape<Schema> : never>;
|
|
53
55
|
|
|
54
56
|
/**
|
|
55
57
|
* Field-metadata write/read API for the unified `attaform/zod` entry.
|