@volverjs/form-vue 0.0.14-beta.1 → 0.0.14-beta.2

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/dist/VvForm.d.ts CHANGED
@@ -3,7 +3,7 @@ import type { z, TypeOf } from 'zod';
3
3
  import type { FormComponentOptions, FormSchema, InjectedFormData } from './types';
4
4
  import { FormStatus } from './enums';
5
5
  export declare const defineForm: <Schema extends FormSchema>(schema: Schema, provideKey: InjectionKey<InjectedFormData<Schema>>, options?: FormComponentOptions) => {
6
- errors: Ref<z.ZodFormattedError<z.TypeOf<Schema>> | undefined>;
6
+ errors: Ref<z.inferFormattedError<Schema, string> | undefined>;
7
7
  status: Ref<FormStatus | undefined>;
8
8
  formData: Ref<Partial<z.TypeOf<Schema> | undefined>>;
9
9
  /**
@@ -17,11 +17,11 @@ export declare const defineForm: <Schema extends FormSchema>(schema: Schema, pro
17
17
  modelValue?: Record<string, any> | undefined;
18
18
  updateThrottle?: number | undefined;
19
19
  continuosValidation?: boolean | undefined;
20
- key?: string | number | symbol | undefined;
21
20
  onInvalid?: ((...args: any[]) => any) | undefined;
22
21
  onValid?: ((...args: any[]) => any) | undefined;
23
- onSubmit?: ((...args: any[]) => any) | undefined;
24
22
  "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
23
+ key?: string | number | symbol | undefined;
24
+ onSubmit?: ((...args: any[]) => any) | undefined;
25
25
  ref?: import("vue").VNodeRef | undefined;
26
26
  ref_for?: boolean | undefined;
27
27
  ref_key?: string | undefined;
@@ -77,7 +77,7 @@ export declare const defineForm: <Schema extends FormSchema>(schema: Schema, pro
77
77
  }>;
78
78
  $root: import("vue").ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, import("vue").ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}, {}, string, {}>, {}, {}> | null;
79
79
  $parent: import("vue").ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, import("vue").ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}, {}, string, {}>, {}, {}> | null;
80
- $emit: (event: "invalid" | "valid" | "submit" | "update:modelValue", ...args: any[]) => void;
80
+ $emit: (event: "invalid" | "valid" | "update:modelValue" | "submit", ...args: any[]) => void;
81
81
  $el: any;
82
82
  $options: import("vue").ComponentOptionsBase<Readonly<import("vue").ExtractPropTypes<{
83
83
  modelValue: {
@@ -95,16 +95,16 @@ export declare const defineForm: <Schema extends FormSchema>(schema: Schema, pro
95
95
  }>> & {
96
96
  onInvalid?: ((...args: any[]) => any) | undefined;
97
97
  onValid?: ((...args: any[]) => any) | undefined;
98
- onSubmit?: ((...args: any[]) => any) | undefined;
99
98
  "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
99
+ onSubmit?: ((...args: any[]) => any) | undefined;
100
100
  }, {
101
101
  formData: Ref<Partial<z.TypeOf<Schema> | undefined>>;
102
102
  submit: () => boolean;
103
103
  validate: (value?: Partial<z.TypeOf<Schema> | undefined>) => boolean;
104
- errors: Readonly<Ref<DeepReadonly<z.ZodFormattedError<z.TypeOf<Schema>>> | undefined>>;
104
+ errors: Readonly<Ref<DeepReadonly<z.inferFormattedError<Schema, string>> | undefined>>;
105
105
  status: Readonly<Ref<FormStatus | undefined>>;
106
106
  invalid: import("vue").ComputedRef<boolean>;
107
- }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("invalid" | "valid" | "submit" | "update:modelValue")[], string, {
107
+ }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("invalid" | "valid" | "update:modelValue" | "submit")[], string, {
108
108
  modelValue: Record<string, any>;
109
109
  updateThrottle: number;
110
110
  continuosValidation: boolean;
@@ -144,13 +144,13 @@ export declare const defineForm: <Schema extends FormSchema>(schema: Schema, pro
144
144
  }>> & {
145
145
  onInvalid?: ((...args: any[]) => any) | undefined;
146
146
  onValid?: ((...args: any[]) => any) | undefined;
147
- onSubmit?: ((...args: any[]) => any) | undefined;
148
147
  "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
148
+ onSubmit?: ((...args: any[]) => any) | undefined;
149
149
  } & import("vue").ShallowUnwrapRef<{
150
150
  formData: Ref<Partial<z.TypeOf<Schema> | undefined>>;
151
151
  submit: () => boolean;
152
152
  validate: (value?: Partial<z.TypeOf<Schema> | undefined>) => boolean;
153
- errors: Readonly<Ref<DeepReadonly<z.ZodFormattedError<z.TypeOf<Schema>>> | undefined>>;
153
+ errors: Readonly<Ref<DeepReadonly<z.inferFormattedError<Schema, string>> | undefined>>;
154
154
  status: Readonly<Ref<FormStatus | undefined>>;
155
155
  invalid: import("vue").ComputedRef<boolean>;
156
156
  }> & {} & import("vue").ComponentCustomProperties & {};
@@ -173,16 +173,16 @@ export declare const defineForm: <Schema extends FormSchema>(schema: Schema, pro
173
173
  }>> & {
174
174
  onInvalid?: ((...args: any[]) => any) | undefined;
175
175
  onValid?: ((...args: any[]) => any) | undefined;
176
- onSubmit?: ((...args: any[]) => any) | undefined;
177
176
  "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
177
+ onSubmit?: ((...args: any[]) => any) | undefined;
178
178
  }, {
179
179
  formData: Ref<Partial<z.TypeOf<Schema> | undefined>>;
180
180
  submit: () => boolean;
181
181
  validate: (value?: Partial<z.TypeOf<Schema> | undefined>) => boolean;
182
- errors: Readonly<Ref<DeepReadonly<z.ZodFormattedError<z.TypeOf<Schema>>> | undefined>>;
182
+ errors: Readonly<Ref<DeepReadonly<z.inferFormattedError<Schema, string>> | undefined>>;
183
183
  status: Readonly<Ref<FormStatus | undefined>>;
184
184
  invalid: import("vue").ComputedRef<boolean>;
185
- }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("invalid" | "valid" | "submit" | "update:modelValue")[], "invalid" | "valid" | "submit" | "update:modelValue", {
185
+ }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("invalid" | "valid" | "update:modelValue" | "submit")[], "invalid" | "valid" | "update:modelValue" | "submit", {
186
186
  modelValue: Record<string, any>;
187
187
  updateThrottle: number;
188
188
  continuosValidation: boolean;
@@ -25,7 +25,7 @@ export declare const defineFormField: <Schema extends FormSchema>(formProvideKey
25
25
  default: boolean;
26
26
  };
27
27
  defaultValue: {
28
- type: (ObjectConstructor | ArrayConstructor | NumberConstructor | BooleanConstructor | StringConstructor)[];
28
+ type: (StringConstructor | ObjectConstructor | NumberConstructor | BooleanConstructor | ArrayConstructor)[];
29
29
  default: undefined;
30
30
  };
31
31
  lazyLoad: {
@@ -55,7 +55,7 @@ export declare const defineFormField: <Schema extends FormSchema>(formProvideKey
55
55
  'onUpdate:modelValue': (value: unknown) => void;
56
56
  }>;
57
57
  invalid: import("vue").ComputedRef<boolean>;
58
- }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("invalid" | "valid" | "update:modelValue" | "update:formData")[], "invalid" | "valid" | "update:modelValue" | "update:formData", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
58
+ }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("invalid" | "valid" | "update:formData" | "update:modelValue")[], "invalid" | "valid" | "update:formData" | "update:modelValue", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
59
59
  type: {
60
60
  type: PropType<"number" | "text" | "email" | "password" | "tel" | "url" | "search" | "date" | "time" | "datetime-local" | "month" | "week" | "color" | "select" | "checkbox" | "radio" | "textarea" | "radioGroup" | "checkboxGroup" | "combobox" | "custom">;
61
61
  validator: (value: FormFieldType) => boolean;
@@ -78,7 +78,7 @@ export declare const defineFormField: <Schema extends FormSchema>(formProvideKey
78
78
  default: boolean;
79
79
  };
80
80
  defaultValue: {
81
- type: (ObjectConstructor | ArrayConstructor | NumberConstructor | BooleanConstructor | StringConstructor)[];
81
+ type: (StringConstructor | ObjectConstructor | NumberConstructor | BooleanConstructor | ArrayConstructor)[];
82
82
  default: undefined;
83
83
  };
84
84
  lazyLoad: {
@@ -88,8 +88,8 @@ export declare const defineFormField: <Schema extends FormSchema>(formProvideKey
88
88
  }>> & {
89
89
  onInvalid?: ((...args: any[]) => any) | undefined;
90
90
  onValid?: ((...args: any[]) => any) | undefined;
91
- "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
92
91
  "onUpdate:formData"?: ((...args: any[]) => any) | undefined;
92
+ "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
93
93
  }, {
94
94
  type: "number" | "text" | "email" | "password" | "tel" | "url" | "search" | "date" | "time" | "datetime-local" | "month" | "week" | "color" | "select" | "checkbox" | "radio" | "textarea" | "radioGroup" | "checkboxGroup" | "combobox" | "custom";
95
95
  props: [{
@@ -7,10 +7,10 @@ export declare const defineFormWrapper: <Schema extends FormSchema>(formProvideK
7
7
  $data: {};
8
8
  $props: {
9
9
  tag?: string | undefined;
10
- key?: string | number | symbol | undefined;
11
10
  readonly name: string;
12
11
  onInvalid?: ((...args: any[]) => any) | undefined;
13
12
  onValid?: ((...args: any[]) => any) | undefined;
13
+ key?: string | number | symbol | undefined;
14
14
  ref?: import("vue").VNodeRef | undefined;
15
15
  ref_for?: boolean | undefined;
16
16
  ref_key?: string | undefined;
@@ -82,14 +82,12 @@ export declare const defineFormWrapper: <Schema extends FormSchema>(formProvideK
82
82
  onValid?: ((...args: any[]) => any) | undefined;
83
83
  }, {
84
84
  formData: Ref<Partial<TypeOf<Schema>> | undefined> | undefined;
85
- errors: Readonly<Ref<DeepReadonly<z.inferFormattedError<Schema_1, string>>>> | undefined;
85
+ errors: Readonly<Ref<DeepReadonly<z.inferFormattedError<Schema, string>> | undefined>> | undefined;
86
86
  submit: (() => boolean) | undefined;
87
87
  validate: (() => boolean) | undefined;
88
88
  invalid: import("vue").ComputedRef<boolean>;
89
89
  fields: Ref<Set<string>>;
90
- fieldsErrors: Ref<Map<string, Record<string, {
91
- _errors: string[];
92
- }>>>;
90
+ fieldsErrors: Ref<Map<string, z.inferFormattedError<Schema, string>>>;
93
91
  }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("invalid" | "valid")[], string, {
94
92
  tag: string;
95
93
  }, {}, string, {}> & {
@@ -126,14 +124,12 @@ export declare const defineFormWrapper: <Schema extends FormSchema>(formProvideK
126
124
  onValid?: ((...args: any[]) => any) | undefined;
127
125
  } & import("vue").ShallowUnwrapRef<{
128
126
  formData: Ref<Partial<TypeOf<Schema>> | undefined> | undefined;
129
- errors: Readonly<Ref<DeepReadonly<z.inferFormattedError<Schema_1, string>>>> | undefined;
127
+ errors: Readonly<Ref<DeepReadonly<z.inferFormattedError<Schema, string>> | undefined>> | undefined;
130
128
  submit: (() => boolean) | undefined;
131
129
  validate: (() => boolean) | undefined;
132
130
  invalid: import("vue").ComputedRef<boolean>;
133
131
  fields: Ref<Set<string>>;
134
- fieldsErrors: Ref<Map<string, Record<string, {
135
- _errors: string[];
136
- }>>>;
132
+ fieldsErrors: Ref<Map<string, z.inferFormattedError<Schema, string>>>;
137
133
  }> & {} & import("vue").ComponentCustomProperties & {};
138
134
  __isFragment?: undefined;
139
135
  __isTeleport?: undefined;
@@ -152,14 +148,12 @@ export declare const defineFormWrapper: <Schema extends FormSchema>(formProvideK
152
148
  onValid?: ((...args: any[]) => any) | undefined;
153
149
  }, {
154
150
  formData: Ref<Partial<TypeOf<Schema>> | undefined> | undefined;
155
- errors: Readonly<Ref<DeepReadonly<z.inferFormattedError<Schema_1, string>>>> | undefined;
151
+ errors: Readonly<Ref<DeepReadonly<z.inferFormattedError<Schema, string>> | undefined>> | undefined;
156
152
  submit: (() => boolean) | undefined;
157
153
  validate: (() => boolean) | undefined;
158
154
  invalid: import("vue").ComputedRef<boolean>;
159
155
  fields: Ref<Set<string>>;
160
- fieldsErrors: Ref<Map<string, Record<string, {
161
- _errors: string[];
162
- }>>>;
156
+ fieldsErrors: Ref<Map<string, z.inferFormattedError<Schema, string>>>;
163
157
  }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("invalid" | "valid")[], "invalid" | "valid", {
164
158
  tag: string;
165
159
  }, {}, string, {}> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps & (new () => {
package/dist/index.d.ts CHANGED
@@ -15,11 +15,11 @@ export declare const useForm: <Schema extends FormSchema>(schema: Schema, option
15
15
  modelValue?: Record<string, any> | undefined;
16
16
  updateThrottle?: number | undefined;
17
17
  continuosValidation?: boolean | undefined;
18
- key?: string | number | symbol | undefined;
19
18
  onInvalid?: ((...args: any[]) => any) | undefined;
20
19
  onValid?: ((...args: any[]) => any) | undefined;
21
- onSubmit?: ((...args: any[]) => any) | undefined;
22
20
  "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
21
+ key?: string | number | symbol | undefined;
22
+ onSubmit?: ((...args: any[]) => any) | undefined;
23
23
  ref?: import("vue").VNodeRef | undefined;
24
24
  ref_for?: boolean | undefined;
25
25
  ref_key?: string | undefined;
@@ -75,7 +75,7 @@ export declare const useForm: <Schema extends FormSchema>(schema: Schema, option
75
75
  }>;
76
76
  $root: import("vue").ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, import("vue").ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}, {}, string, {}>, {}, {}> | null;
77
77
  $parent: import("vue").ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, import("vue").ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}, {}, string, {}>, {}, {}> | null;
78
- $emit: (event: "invalid" | "valid" | "submit" | "update:modelValue", ...args: any[]) => void;
78
+ $emit: (event: "invalid" | "valid" | "update:modelValue" | "submit", ...args: any[]) => void;
79
79
  $el: any;
80
80
  $options: import("vue").ComponentOptionsBase<Readonly<import("vue").ExtractPropTypes<{
81
81
  modelValue: {
@@ -93,16 +93,16 @@ export declare const useForm: <Schema extends FormSchema>(schema: Schema, option
93
93
  }>> & {
94
94
  onInvalid?: ((...args: any[]) => any) | undefined;
95
95
  onValid?: ((...args: any[]) => any) | undefined;
96
- onSubmit?: ((...args: any[]) => any) | undefined;
97
96
  "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
97
+ onSubmit?: ((...args: any[]) => any) | undefined;
98
98
  }, {
99
99
  formData: import("vue").Ref<Partial<import("zod").TypeOf<Schema> | undefined>>;
100
100
  submit: () => boolean;
101
101
  validate: (value?: Partial<import("zod").TypeOf<Schema> | undefined>) => boolean;
102
- errors: Readonly<import("vue").Ref<import("vue").DeepReadonly<import("zod").ZodFormattedError<import("zod").TypeOf<Schema>>> | undefined>>;
102
+ errors: Readonly<import("vue").Ref<import("vue").DeepReadonly<import("zod").inferFormattedError<Schema, string>> | undefined>>;
103
103
  status: Readonly<import("vue").Ref<import("./enums").FormStatus | undefined>>;
104
104
  invalid: import("vue").ComputedRef<boolean>;
105
- }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("invalid" | "valid" | "submit" | "update:modelValue")[], string, {
105
+ }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("invalid" | "valid" | "update:modelValue" | "submit")[], string, {
106
106
  modelValue: Record<string, any>;
107
107
  updateThrottle: number;
108
108
  continuosValidation: boolean;
@@ -142,13 +142,13 @@ export declare const useForm: <Schema extends FormSchema>(schema: Schema, option
142
142
  }>> & {
143
143
  onInvalid?: ((...args: any[]) => any) | undefined;
144
144
  onValid?: ((...args: any[]) => any) | undefined;
145
- onSubmit?: ((...args: any[]) => any) | undefined;
146
145
  "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
146
+ onSubmit?: ((...args: any[]) => any) | undefined;
147
147
  } & import("vue").ShallowUnwrapRef<{
148
148
  formData: import("vue").Ref<Partial<import("zod").TypeOf<Schema> | undefined>>;
149
149
  submit: () => boolean;
150
150
  validate: (value?: Partial<import("zod").TypeOf<Schema> | undefined>) => boolean;
151
- errors: Readonly<import("vue").Ref<import("vue").DeepReadonly<import("zod").ZodFormattedError<import("zod").TypeOf<Schema>>> | undefined>>;
151
+ errors: Readonly<import("vue").Ref<import("vue").DeepReadonly<import("zod").inferFormattedError<Schema, string>> | undefined>>;
152
152
  status: Readonly<import("vue").Ref<import("./enums").FormStatus | undefined>>;
153
153
  invalid: import("vue").ComputedRef<boolean>;
154
154
  }> & {} & import("vue").ComponentCustomProperties & {};
@@ -171,16 +171,16 @@ export declare const useForm: <Schema extends FormSchema>(schema: Schema, option
171
171
  }>> & {
172
172
  onInvalid?: ((...args: any[]) => any) | undefined;
173
173
  onValid?: ((...args: any[]) => any) | undefined;
174
- onSubmit?: ((...args: any[]) => any) | undefined;
175
174
  "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
175
+ onSubmit?: ((...args: any[]) => any) | undefined;
176
176
  }, {
177
177
  formData: import("vue").Ref<Partial<import("zod").TypeOf<Schema> | undefined>>;
178
178
  submit: () => boolean;
179
179
  validate: (value?: Partial<import("zod").TypeOf<Schema> | undefined>) => boolean;
180
- errors: Readonly<import("vue").Ref<import("vue").DeepReadonly<import("zod").ZodFormattedError<import("zod").TypeOf<Schema>>> | undefined>>;
180
+ errors: Readonly<import("vue").Ref<import("vue").DeepReadonly<import("zod").inferFormattedError<Schema, string>> | undefined>>;
181
181
  status: Readonly<import("vue").Ref<import("./enums").FormStatus | undefined>>;
182
182
  invalid: import("vue").ComputedRef<boolean>;
183
- }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("invalid" | "valid" | "submit" | "update:modelValue")[], "invalid" | "valid" | "submit" | "update:modelValue", {
183
+ }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("invalid" | "valid" | "update:modelValue" | "submit")[], "invalid" | "valid" | "update:modelValue" | "submit", {
184
184
  modelValue: Record<string, any>;
185
185
  updateThrottle: number;
186
186
  continuosValidation: boolean;
@@ -202,10 +202,10 @@ export declare const useForm: <Schema extends FormSchema>(schema: Schema, option
202
202
  $data: {};
203
203
  $props: {
204
204
  tag?: string | undefined;
205
- key?: string | number | symbol | undefined;
206
205
  readonly name: string;
207
206
  onInvalid?: ((...args: any[]) => any) | undefined;
208
207
  onValid?: ((...args: any[]) => any) | undefined;
208
+ key?: string | number | symbol | undefined;
209
209
  ref?: import("vue").VNodeRef | undefined;
210
210
  ref_for?: boolean | undefined;
211
211
  ref_key?: string | undefined;
@@ -277,14 +277,12 @@ export declare const useForm: <Schema extends FormSchema>(schema: Schema, option
277
277
  onValid?: ((...args: any[]) => any) | undefined;
278
278
  }, {
279
279
  formData: import("vue").Ref<Partial<import("zod").TypeOf<Schema>> | undefined> | undefined;
280
- errors: Readonly<import("vue").Ref<DeepReadonly<import("zod").inferFormattedError<Schema_1, string>>>> | undefined;
280
+ errors: Readonly<import("vue").Ref<import("vue").DeepReadonly<import("zod").inferFormattedError<Schema, string>> | undefined>> | undefined;
281
281
  submit: (() => boolean) | undefined;
282
282
  validate: (() => boolean) | undefined;
283
283
  invalid: import("vue").ComputedRef<boolean>;
284
284
  fields: import("vue").Ref<Set<string>>;
285
- fieldsErrors: import("vue").Ref<Map<string, Record<string, {
286
- _errors: string[];
287
- }>>>;
285
+ fieldsErrors: import("vue").Ref<Map<string, import("zod").inferFormattedError<Schema, string>>>;
288
286
  }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("invalid" | "valid")[], string, {
289
287
  tag: string;
290
288
  }, {}, string, {}> & {
@@ -321,14 +319,12 @@ export declare const useForm: <Schema extends FormSchema>(schema: Schema, option
321
319
  onValid?: ((...args: any[]) => any) | undefined;
322
320
  } & import("vue").ShallowUnwrapRef<{
323
321
  formData: import("vue").Ref<Partial<import("zod").TypeOf<Schema>> | undefined> | undefined;
324
- errors: Readonly<import("vue").Ref<DeepReadonly<import("zod").inferFormattedError<Schema_1, string>>>> | undefined;
322
+ errors: Readonly<import("vue").Ref<import("vue").DeepReadonly<import("zod").inferFormattedError<Schema, string>> | undefined>> | undefined;
325
323
  submit: (() => boolean) | undefined;
326
324
  validate: (() => boolean) | undefined;
327
325
  invalid: import("vue").ComputedRef<boolean>;
328
326
  fields: import("vue").Ref<Set<string>>;
329
- fieldsErrors: import("vue").Ref<Map<string, Record<string, {
330
- _errors: string[];
331
- }>>>;
327
+ fieldsErrors: import("vue").Ref<Map<string, import("zod").inferFormattedError<Schema, string>>>;
332
328
  }> & {} & import("vue").ComponentCustomProperties & {};
333
329
  __isFragment?: undefined;
334
330
  __isTeleport?: undefined;
@@ -347,14 +343,12 @@ export declare const useForm: <Schema extends FormSchema>(schema: Schema, option
347
343
  onValid?: ((...args: any[]) => any) | undefined;
348
344
  }, {
349
345
  formData: import("vue").Ref<Partial<import("zod").TypeOf<Schema>> | undefined> | undefined;
350
- errors: Readonly<import("vue").Ref<DeepReadonly<import("zod").inferFormattedError<Schema_1, string>>>> | undefined;
346
+ errors: Readonly<import("vue").Ref<import("vue").DeepReadonly<import("zod").inferFormattedError<Schema, string>> | undefined>> | undefined;
351
347
  submit: (() => boolean) | undefined;
352
348
  validate: (() => boolean) | undefined;
353
349
  invalid: import("vue").ComputedRef<boolean>;
354
350
  fields: import("vue").Ref<Set<string>>;
355
- fieldsErrors: import("vue").Ref<Map<string, Record<string, {
356
- _errors: string[];
357
- }>>>;
351
+ fieldsErrors: import("vue").Ref<Map<string, import("zod").inferFormattedError<Schema, string>>>;
358
352
  }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("invalid" | "valid")[], "invalid" | "valid", {
359
353
  tag: string;
360
354
  }, {}, string, {}> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps & (new () => {
@@ -394,7 +388,7 @@ export declare const useForm: <Schema extends FormSchema>(schema: Schema, option
394
388
  default: boolean;
395
389
  };
396
390
  defaultValue: {
397
- type: (ObjectConstructor | ArrayConstructor | NumberConstructor | BooleanConstructor | StringConstructor)[];
391
+ type: (StringConstructor | ObjectConstructor | NumberConstructor | BooleanConstructor | ArrayConstructor)[];
398
392
  default: undefined;
399
393
  };
400
394
  lazyLoad: {
@@ -424,7 +418,7 @@ export declare const useForm: <Schema extends FormSchema>(schema: Schema, option
424
418
  'onUpdate:modelValue': (value: unknown) => void;
425
419
  }>;
426
420
  invalid: import("vue").ComputedRef<boolean>;
427
- }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("invalid" | "valid" | "update:modelValue" | "update:formData")[], "invalid" | "valid" | "update:modelValue" | "update:formData", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
421
+ }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("invalid" | "valid" | "update:formData" | "update:modelValue")[], "invalid" | "valid" | "update:formData" | "update:modelValue", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
428
422
  type: {
429
423
  type: import("vue").PropType<"number" | "text" | "email" | "password" | "tel" | "url" | "search" | "date" | "time" | "datetime-local" | "month" | "week" | "color" | "select" | "checkbox" | "radio" | "textarea" | "radioGroup" | "checkboxGroup" | "combobox" | "custom">;
430
424
  validator: (value: import("./enums").FormFieldType) => boolean;
@@ -447,7 +441,7 @@ export declare const useForm: <Schema extends FormSchema>(schema: Schema, option
447
441
  default: boolean;
448
442
  };
449
443
  defaultValue: {
450
- type: (ObjectConstructor | ArrayConstructor | NumberConstructor | BooleanConstructor | StringConstructor)[];
444
+ type: (StringConstructor | ObjectConstructor | NumberConstructor | BooleanConstructor | ArrayConstructor)[];
451
445
  default: undefined;
452
446
  };
453
447
  lazyLoad: {
@@ -457,8 +451,8 @@ export declare const useForm: <Schema extends FormSchema>(schema: Schema, option
457
451
  }>> & {
458
452
  onInvalid?: ((...args: any[]) => any) | undefined;
459
453
  onValid?: ((...args: any[]) => any) | undefined;
460
- "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
461
454
  "onUpdate:formData"?: ((...args: any[]) => any) | undefined;
455
+ "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
462
456
  }, {
463
457
  type: "number" | "text" | "email" | "password" | "tel" | "url" | "search" | "date" | "time" | "datetime-local" | "month" | "week" | "color" | "select" | "checkbox" | "radio" | "textarea" | "radioGroup" | "checkboxGroup" | "combobox" | "custom";
464
458
  props: [{
@@ -493,7 +487,7 @@ export declare const useForm: <Schema extends FormSchema>(schema: Schema, option
493
487
  formInjectionKey: InjectionKey<InjectedFormData<Schema>>;
494
488
  formWrapperInjectionKey: InjectionKey<InjectedFormWrapperData<Schema>>;
495
489
  formFieldInjectionKey: InjectionKey<InjectedFormFieldData<Schema>>;
496
- errors: import("vue").Ref<import("zod").ZodFormattedError<import("zod").TypeOf<Schema>> | undefined>;
490
+ errors: import("vue").Ref<import("zod").inferFormattedError<Schema, string> | undefined>;
497
491
  status: import("vue").Ref<import("./enums").FormStatus | undefined>;
498
492
  formData: import("vue").Ref<Partial<import("zod").TypeOf<Schema> | undefined>>;
499
493
  };
@@ -516,11 +510,11 @@ export declare const formFactory: <Schema extends FormSchema>(schema: Schema, op
516
510
  modelValue?: Record<string, any> | undefined;
517
511
  updateThrottle?: number | undefined;
518
512
  continuosValidation?: boolean | undefined;
519
- key?: string | number | symbol | undefined;
520
513
  onInvalid?: ((...args: any[]) => any) | undefined;
521
514
  onValid?: ((...args: any[]) => any) | undefined;
522
- onSubmit?: ((...args: any[]) => any) | undefined;
523
515
  "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
516
+ key?: string | number | symbol | undefined;
517
+ onSubmit?: ((...args: any[]) => any) | undefined;
524
518
  ref?: import("vue").VNodeRef | undefined;
525
519
  ref_for?: boolean | undefined;
526
520
  ref_key?: string | undefined;
@@ -576,7 +570,7 @@ export declare const formFactory: <Schema extends FormSchema>(schema: Schema, op
576
570
  }>;
577
571
  $root: import("vue").ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, import("vue").ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}, {}, string, {}>, {}, {}> | null;
578
572
  $parent: import("vue").ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, import("vue").ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}, {}, string, {}>, {}, {}> | null;
579
- $emit: (event: "invalid" | "valid" | "submit" | "update:modelValue", ...args: any[]) => void;
573
+ $emit: (event: "invalid" | "valid" | "update:modelValue" | "submit", ...args: any[]) => void;
580
574
  $el: any;
581
575
  $options: import("vue").ComponentOptionsBase<Readonly<import("vue").ExtractPropTypes<{
582
576
  modelValue: {
@@ -594,16 +588,16 @@ export declare const formFactory: <Schema extends FormSchema>(schema: Schema, op
594
588
  }>> & {
595
589
  onInvalid?: ((...args: any[]) => any) | undefined;
596
590
  onValid?: ((...args: any[]) => any) | undefined;
597
- onSubmit?: ((...args: any[]) => any) | undefined;
598
591
  "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
592
+ onSubmit?: ((...args: any[]) => any) | undefined;
599
593
  }, {
600
594
  formData: import("vue").Ref<Partial<import("zod").TypeOf<Schema> | undefined>>;
601
595
  submit: () => boolean;
602
596
  validate: (value?: Partial<import("zod").TypeOf<Schema> | undefined>) => boolean;
603
- errors: Readonly<import("vue").Ref<import("vue").DeepReadonly<import("zod").ZodFormattedError<import("zod").TypeOf<Schema>>> | undefined>>;
597
+ errors: Readonly<import("vue").Ref<import("vue").DeepReadonly<import("zod").inferFormattedError<Schema, string>> | undefined>>;
604
598
  status: Readonly<import("vue").Ref<import("./enums").FormStatus | undefined>>;
605
599
  invalid: import("vue").ComputedRef<boolean>;
606
- }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("invalid" | "valid" | "submit" | "update:modelValue")[], string, {
600
+ }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("invalid" | "valid" | "update:modelValue" | "submit")[], string, {
607
601
  modelValue: Record<string, any>;
608
602
  updateThrottle: number;
609
603
  continuosValidation: boolean;
@@ -643,13 +637,13 @@ export declare const formFactory: <Schema extends FormSchema>(schema: Schema, op
643
637
  }>> & {
644
638
  onInvalid?: ((...args: any[]) => any) | undefined;
645
639
  onValid?: ((...args: any[]) => any) | undefined;
646
- onSubmit?: ((...args: any[]) => any) | undefined;
647
640
  "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
641
+ onSubmit?: ((...args: any[]) => any) | undefined;
648
642
  } & import("vue").ShallowUnwrapRef<{
649
643
  formData: import("vue").Ref<Partial<import("zod").TypeOf<Schema> | undefined>>;
650
644
  submit: () => boolean;
651
645
  validate: (value?: Partial<import("zod").TypeOf<Schema> | undefined>) => boolean;
652
- errors: Readonly<import("vue").Ref<import("vue").DeepReadonly<import("zod").ZodFormattedError<import("zod").TypeOf<Schema>>> | undefined>>;
646
+ errors: Readonly<import("vue").Ref<import("vue").DeepReadonly<import("zod").inferFormattedError<Schema, string>> | undefined>>;
653
647
  status: Readonly<import("vue").Ref<import("./enums").FormStatus | undefined>>;
654
648
  invalid: import("vue").ComputedRef<boolean>;
655
649
  }> & {} & import("vue").ComponentCustomProperties & {};
@@ -672,16 +666,16 @@ export declare const formFactory: <Schema extends FormSchema>(schema: Schema, op
672
666
  }>> & {
673
667
  onInvalid?: ((...args: any[]) => any) | undefined;
674
668
  onValid?: ((...args: any[]) => any) | undefined;
675
- onSubmit?: ((...args: any[]) => any) | undefined;
676
669
  "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
670
+ onSubmit?: ((...args: any[]) => any) | undefined;
677
671
  }, {
678
672
  formData: import("vue").Ref<Partial<import("zod").TypeOf<Schema> | undefined>>;
679
673
  submit: () => boolean;
680
674
  validate: (value?: Partial<import("zod").TypeOf<Schema> | undefined>) => boolean;
681
- errors: Readonly<import("vue").Ref<import("vue").DeepReadonly<import("zod").ZodFormattedError<import("zod").TypeOf<Schema>>> | undefined>>;
675
+ errors: Readonly<import("vue").Ref<import("vue").DeepReadonly<import("zod").inferFormattedError<Schema, string>> | undefined>>;
682
676
  status: Readonly<import("vue").Ref<import("./enums").FormStatus | undefined>>;
683
677
  invalid: import("vue").ComputedRef<boolean>;
684
- }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("invalid" | "valid" | "submit" | "update:modelValue")[], "invalid" | "valid" | "submit" | "update:modelValue", {
678
+ }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("invalid" | "valid" | "update:modelValue" | "submit")[], "invalid" | "valid" | "update:modelValue" | "submit", {
685
679
  modelValue: Record<string, any>;
686
680
  updateThrottle: number;
687
681
  continuosValidation: boolean;
@@ -703,10 +697,10 @@ export declare const formFactory: <Schema extends FormSchema>(schema: Schema, op
703
697
  $data: {};
704
698
  $props: {
705
699
  tag?: string | undefined;
706
- key?: string | number | symbol | undefined;
707
700
  readonly name: string;
708
701
  onInvalid?: ((...args: any[]) => any) | undefined;
709
702
  onValid?: ((...args: any[]) => any) | undefined;
703
+ key?: string | number | symbol | undefined;
710
704
  ref?: import("vue").VNodeRef | undefined;
711
705
  ref_for?: boolean | undefined;
712
706
  ref_key?: string | undefined;
@@ -778,14 +772,12 @@ export declare const formFactory: <Schema extends FormSchema>(schema: Schema, op
778
772
  onValid?: ((...args: any[]) => any) | undefined;
779
773
  }, {
780
774
  formData: import("vue").Ref<Partial<import("zod").TypeOf<Schema>> | undefined> | undefined;
781
- errors: Readonly<import("vue").Ref<DeepReadonly<import("zod").inferFormattedError<Schema_1, string>>>> | undefined;
775
+ errors: Readonly<import("vue").Ref<import("vue").DeepReadonly<import("zod").inferFormattedError<Schema, string>> | undefined>> | undefined;
782
776
  submit: (() => boolean) | undefined;
783
777
  validate: (() => boolean) | undefined;
784
778
  invalid: import("vue").ComputedRef<boolean>;
785
779
  fields: import("vue").Ref<Set<string>>;
786
- fieldsErrors: import("vue").Ref<Map<string, Record<string, {
787
- _errors: string[];
788
- }>>>;
780
+ fieldsErrors: import("vue").Ref<Map<string, import("zod").inferFormattedError<Schema, string>>>;
789
781
  }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("invalid" | "valid")[], string, {
790
782
  tag: string;
791
783
  }, {}, string, {}> & {
@@ -822,14 +814,12 @@ export declare const formFactory: <Schema extends FormSchema>(schema: Schema, op
822
814
  onValid?: ((...args: any[]) => any) | undefined;
823
815
  } & import("vue").ShallowUnwrapRef<{
824
816
  formData: import("vue").Ref<Partial<import("zod").TypeOf<Schema>> | undefined> | undefined;
825
- errors: Readonly<import("vue").Ref<DeepReadonly<import("zod").inferFormattedError<Schema_1, string>>>> | undefined;
817
+ errors: Readonly<import("vue").Ref<import("vue").DeepReadonly<import("zod").inferFormattedError<Schema, string>> | undefined>> | undefined;
826
818
  submit: (() => boolean) | undefined;
827
819
  validate: (() => boolean) | undefined;
828
820
  invalid: import("vue").ComputedRef<boolean>;
829
821
  fields: import("vue").Ref<Set<string>>;
830
- fieldsErrors: import("vue").Ref<Map<string, Record<string, {
831
- _errors: string[];
832
- }>>>;
822
+ fieldsErrors: import("vue").Ref<Map<string, import("zod").inferFormattedError<Schema, string>>>;
833
823
  }> & {} & import("vue").ComponentCustomProperties & {};
834
824
  __isFragment?: undefined;
835
825
  __isTeleport?: undefined;
@@ -848,14 +838,12 @@ export declare const formFactory: <Schema extends FormSchema>(schema: Schema, op
848
838
  onValid?: ((...args: any[]) => any) | undefined;
849
839
  }, {
850
840
  formData: import("vue").Ref<Partial<import("zod").TypeOf<Schema>> | undefined> | undefined;
851
- errors: Readonly<import("vue").Ref<DeepReadonly<import("zod").inferFormattedError<Schema_1, string>>>> | undefined;
841
+ errors: Readonly<import("vue").Ref<import("vue").DeepReadonly<import("zod").inferFormattedError<Schema, string>> | undefined>> | undefined;
852
842
  submit: (() => boolean) | undefined;
853
843
  validate: (() => boolean) | undefined;
854
844
  invalid: import("vue").ComputedRef<boolean>;
855
845
  fields: import("vue").Ref<Set<string>>;
856
- fieldsErrors: import("vue").Ref<Map<string, Record<string, {
857
- _errors: string[];
858
- }>>>;
846
+ fieldsErrors: import("vue").Ref<Map<string, import("zod").inferFormattedError<Schema, string>>>;
859
847
  }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("invalid" | "valid")[], "invalid" | "valid", {
860
848
  tag: string;
861
849
  }, {}, string, {}> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps & (new () => {
@@ -895,7 +883,7 @@ export declare const formFactory: <Schema extends FormSchema>(schema: Schema, op
895
883
  default: boolean;
896
884
  };
897
885
  defaultValue: {
898
- type: (ObjectConstructor | ArrayConstructor | NumberConstructor | BooleanConstructor | StringConstructor)[];
886
+ type: (StringConstructor | ObjectConstructor | NumberConstructor | BooleanConstructor | ArrayConstructor)[];
899
887
  default: undefined;
900
888
  };
901
889
  lazyLoad: {
@@ -925,7 +913,7 @@ export declare const formFactory: <Schema extends FormSchema>(schema: Schema, op
925
913
  'onUpdate:modelValue': (value: unknown) => void;
926
914
  }>;
927
915
  invalid: import("vue").ComputedRef<boolean>;
928
- }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("invalid" | "valid" | "update:modelValue" | "update:formData")[], "invalid" | "valid" | "update:modelValue" | "update:formData", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
916
+ }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("invalid" | "valid" | "update:formData" | "update:modelValue")[], "invalid" | "valid" | "update:formData" | "update:modelValue", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
929
917
  type: {
930
918
  type: import("vue").PropType<"number" | "text" | "email" | "password" | "tel" | "url" | "search" | "date" | "time" | "datetime-local" | "month" | "week" | "color" | "select" | "checkbox" | "radio" | "textarea" | "radioGroup" | "checkboxGroup" | "combobox" | "custom">;
931
919
  validator: (value: import("./enums").FormFieldType) => boolean;
@@ -948,7 +936,7 @@ export declare const formFactory: <Schema extends FormSchema>(schema: Schema, op
948
936
  default: boolean;
949
937
  };
950
938
  defaultValue: {
951
- type: (ObjectConstructor | ArrayConstructor | NumberConstructor | BooleanConstructor | StringConstructor)[];
939
+ type: (StringConstructor | ObjectConstructor | NumberConstructor | BooleanConstructor | ArrayConstructor)[];
952
940
  default: undefined;
953
941
  };
954
942
  lazyLoad: {
@@ -958,8 +946,8 @@ export declare const formFactory: <Schema extends FormSchema>(schema: Schema, op
958
946
  }>> & {
959
947
  onInvalid?: ((...args: any[]) => any) | undefined;
960
948
  onValid?: ((...args: any[]) => any) | undefined;
961
- "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
962
949
  "onUpdate:formData"?: ((...args: any[]) => any) | undefined;
950
+ "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
963
951
  }, {
964
952
  type: "number" | "text" | "email" | "password" | "tel" | "url" | "search" | "date" | "time" | "datetime-local" | "month" | "week" | "color" | "select" | "checkbox" | "radio" | "textarea" | "radioGroup" | "checkboxGroup" | "combobox" | "custom";
965
953
  props: [{
@@ -994,7 +982,7 @@ export declare const formFactory: <Schema extends FormSchema>(schema: Schema, op
994
982
  formInjectionKey: InjectionKey<InjectedFormData<Schema>>;
995
983
  formWrapperInjectionKey: InjectionKey<InjectedFormWrapperData<Schema>>;
996
984
  formFieldInjectionKey: InjectionKey<InjectedFormFieldData<Schema>>;
997
- errors: import("vue").Ref<import("zod").ZodFormattedError<import("zod").TypeOf<Schema>> | undefined>;
985
+ errors: import("vue").Ref<import("zod").inferFormattedError<Schema, string> | undefined>;
998
986
  status: import("vue").Ref<import("./enums").FormStatus | undefined>;
999
987
  formData: import("vue").Ref<Partial<import("zod").TypeOf<Schema> | undefined>>;
1000
988
  };
package/dist/index.es.js CHANGED
@@ -283,7 +283,7 @@ const de = (e, o, l, i) => G({
283
283
  return [r, m.data ?? t];
284
284
  }
285
285
  if (u instanceof se && Array.isArray(a) && a.length) {
286
- const m = u._def.type;
286
+ const m = l(u._def.type);
287
287
  if (m instanceof W)
288
288
  return [
289
289
  r,
package/dist/index.umd.js CHANGED
@@ -1 +1 @@
1
- (function(y,r){typeof exports=="object"&&typeof module<"u"?r(exports,require("vue"),require("@vueuse/core"),require("zod")):typeof define=="function"&&define.amd?define(["exports","vue","@vueuse/core","zod"],r):(y=typeof globalThis<"u"?globalThis:y||self,r(y["@volverjs/form-vue"]={},y.Vue,y.VueUseCore,y.zod))})(this,function(y,r,M,V){"use strict";function _(e){return Array.isArray(e)}function T(e){return typeof e<"u"}function N(e){return e===null}function G(e){return typeof e=="object"}function L(e){return typeof e=="string"}function C(e){return typeof e>"u"}const U=/^[0-9]+$/,J=["__proto__","prototype","constructor"];function k(e,s,f){const u=T(f)?f:void 0;if(!G(e)||!L(s))return u;const o=Z(s);if(o.length!==0){for(const t of o){if(t==="*")continue;const i=function(a){return a.map(l=>C(l)||N(l)?l:_(l)?i(l):l[t])};if(_(e)&&!U.test(t)?e=i(e):e=e[t],C(e)||N(e))break}return C(e)?u:e}}function W(e,s,f){if(!G(e)||!L(s))return;const u=Z(s);if(u.length===0)return;const o=u.length;for(let t=0;t<o;t++){const i=u[t];if(t===o-1){e[i]=f;return}if(i==="*"&&_(e)){const a=u.slice(t+1).join(".");for(const l of e)W(l,a,f);return}C(e[i])&&(e[i]={}),e=e[i]}}function Z(e){const s=e.split(/[.]|(?:\[(\d|\*)\])/).filter(f=>!!f);return s.some(f=>J.indexOf(f)!==-1)?[]:s}var d=(e=>(e.text="text",e.number="number",e.email="email",e.password="password",e.tel="tel",e.url="url",e.search="search",e.date="date",e.time="time",e.datetimeLocal="datetime-local",e.month="month",e.week="week",e.color="color",e.select="select",e.checkbox="checkbox",e.radio="radio",e.textarea="textarea",e.radioGroup="radioGroup",e.checkboxGroup="checkboxGroup",e.combobox="combobox",e.custom="custom",e))(d||{}),S=(e=>(e.invalid="invalid",e.valid="valid",e))(S||{});const P=(e,s,f,u)=>r.defineComponent({name:"FieldComponent",props:{type:{type:String,validator:o=>Object.values(d).includes(o),default:d.custom},is:{type:[Object,String],default:void 0},name:{type:[String,Number,Boolean,Symbol],required:!0},props:{type:[Object,Function],default:()=>({})},showValid:{type:Boolean,default:!1},defaultValue:{type:[String,Number,Boolean,Array,Object],default:void 0},lazyLoad:{type:Boolean,default:!1}},emits:["invalid","valid","update:formData","update:modelValue"],expose:["invalid","invalidLabel","errors"],setup(o,{slots:t,emit:i}){const a=r.computed({get(){if(n!=null&&n.formData)return k(Object(n.formData.value),String(o.name))},set(c){n!=null&&n.formData&&(W(Object(n.formData.value),String(o.name),c),i("update:modelValue",{newValue:a.value,formData:n==null?void 0:n.formData}))}});r.onMounted(()=>{a.value===void 0&&o.defaultValue!==void 0&&(a.value=o.defaultValue)}),r.onBeforeUnmount(()=>{O(),x()});const l=r.inject(s,void 0);l&&l.fields.value.add(o.name);const n=r.inject(e),{props:h,name:p}=r.toRefs(o),m=r.computed(()=>{if(n!=null&&n.errors.value)return k(n.errors.value,String(o.name))}),v=r.computed(()=>{var c;return(c=m.value)==null?void 0:c._errors}),b=r.computed(()=>m.value!==void 0),O=r.watch(b,()=>{b.value?(i("invalid",v.value),l&&l.errors.value.set(o.name,{_errors:v.value})):(i("valid",a.value),l&&l.errors.value.delete(o.name))}),x=r.watch(()=>n==null?void 0:n.formData,()=>{i("update:formData",n==null?void 0:n.formData)},{deep:!0}),g=c=>{a.value=c},A=r.computed(()=>{let c=h.value;return typeof c=="function"&&(c=c(n==null?void 0:n.formData)),Object.keys(c).reduce((w,q)=>(w[q]=r.unref(c[q]),w),{})}),B=r.computed(()=>({...A.value,name:A.value.name??o.name,invalid:b.value,valid:o.showValid?!!(!b.value&&a.value):void 0,type:(c=>{if([d.text,d.number,d.email,d.password,d.tel,d.url,d.search,d.date,d.time,d.datetimeLocal,d.month,d.week,d.color].includes(c))return c})(o.type),invalidLabel:v.value,modelValue:a.value,"onUpdate:modelValue":g}));return r.provide(f,{name:r.readonly(p),errors:r.readonly(m)}),{component:r.computed(()=>{if(o.type===d.custom)return{render(){var c;return((c=t.default)==null?void 0:c.call(t,{modelValue:a.value,onUpdate:g,submit:n==null?void 0:n.submit,validate:n==null?void 0:n.validate,invalid:b.value,invalidLabel:v.value,formData:n==null?void 0:n.formData.value,formErrors:n==null?void 0:n.errors.value,errors:m.value}))??t.defalut}};if(!((u==null?void 0:u.lazyLoad)??o.lazyLoad)){let c;switch(o.type){case d.select:c=r.resolveComponent("VvSelect");break;case d.checkbox:c=r.resolveComponent("VvCheckbox");break;case d.radio:c=r.resolveComponent("VvRadio");break;case d.textarea:c=r.resolveComponent("VvTextarea");break;case d.radioGroup:c=r.resolveComponent("VvRadioGroup");break;case d.checkboxGroup:c=r.resolveComponent("VvCheckboxGroup");break;case d.combobox:c=r.resolveComponent("VvCombobox");break;default:c=r.resolveComponent("VvInputText")}if(typeof c!="string")return c;console.warn(`[form-vue warn]: ${c} not found, the component will be loaded asynchronously. To avoid this warning, please set "lazyLoad" option.`)}return r.defineAsyncComponent(async()=>{switch(u!=null&&u.sideEffects&&await Promise.resolve(u.sideEffects(o.type)),o.type){case d.textarea:return import("@volverjs/ui-vue/vv-textarea");case d.radio:return import("@volverjs/ui-vue/vv-radio");case d.radioGroup:return import("@volverjs/ui-vue/vv-radio-group");case d.checkbox:return import("@volverjs/ui-vue/vv-checkbox");case d.checkboxGroup:return import("@volverjs/ui-vue/vv-checkbox-group");case d.select:return import("@volverjs/ui-vue/vv-select");case d.combobox:return import("@volverjs/ui-vue/vv-combobox")}return import("@volverjs/ui-vue/vv-input-text")})}),hasProps:B,invalid:b}},render(){return this.is?r.h(this.is,this.hasProps,this.$slots):this.type===d.custom?r.h(this.component,null,this.$slots):r.h(this.component,this.hasProps,this.$slots)}}),E=(e,s={})=>{const f=t=>{let i=t;for(;i instanceof V.ZodEffects;)i=i.innerType();return i instanceof V.ZodOptional&&(i=i._def.innerType),i},u=f(e);return{...(u instanceof V.ZodObject?u._def.unknownKeys==="passthrough":!1)?s:{},...Object.fromEntries(Object.entries(u.shape).map(([t,i])=>{const a=s[t];let l=f(i),n;if(l instanceof V.ZodDefault&&(n=l._def.defaultValue(),l=l._def.innerType),a===null&&l instanceof V.ZodNullable)return[t,a];if(l instanceof V.ZodSchema){const h=i.safeParse(a);if(h.success)return[t,h.data??n]}if(l instanceof V.ZodArray&&Array.isArray(a)&&a.length){const h=l._def.type;if(h instanceof V.ZodObject)return[t,a.map(p=>E(h,p&&typeof p=="object"?p:void 0))??n]}return l instanceof V.ZodObject?[t,E(l,a&&typeof a=="object"?a:n)]:[t,n]}))}},z=(e,s,f)=>{const u=r.ref(),o=r.ref(),t=r.ref(),i=r.defineComponent({name:"FormComponent",props:{modelValue:{type:Object,default:()=>({})},updateThrottle:{type:Number,default:500},continuosValidation:{type:Boolean,default:!1}},emits:["invalid","valid","submit","update:modelValue"],expose:["submit","validate","errors","status","valid","invalid"],setup(a,{emit:l}){t.value=E(e,r.toRaw(a.modelValue)),r.watch(()=>a.modelValue,m=>{if(m){const v=r.isProxy(m)?r.toRaw(m):m;t.value=typeof(v==null?void 0:v.clone)=="function"?v.clone():JSON.parse(JSON.stringify(v))}},{deep:!0}),M.watchThrottled(t,m=>{((u.value||(f==null?void 0:f.continuosValidation))??a.continuosValidation)&&n(),(!m||!a.modelValue||JSON.stringify(m)!==JSON.stringify(a.modelValue))&&l("update:modelValue",m)},{deep:!0,throttle:(f==null?void 0:f.updateThrottle)??a.updateThrottle});const n=(m=t.value)=>{const v=e.safeParse(m);return v.success?(u.value=void 0,o.value=S.valid,t.value=v.data,l("update:modelValue",t.value),l("valid",v.data),!0):(u.value=v.error.format(),o.value=S.invalid,l("invalid",u.value),!1)},h=()=>n()?(l("submit",t.value),!0):!1,p=r.computed(()=>o.value===S.invalid);return r.provide(s,{formData:t,submit:h,validate:n,errors:r.readonly(u),status:r.readonly(o),invalid:p}),{formData:t,submit:h,validate:n,errors:r.readonly(u),status:r.readonly(o),invalid:p}},render(){return r.h("form",{onSubmit:r.withModifiers(this.submit,["prevent"])},{default:()=>{var a,l;return((l=(a=this.$slots)==null?void 0:a.default)==null?void 0:l.call(a,{formData:this.formData,submit:this.submit,validate:this.validate,errors:this.errors,status:this.status,invalid:this.invalid}))??this.$slots.default}})}});return{errors:u,status:o,formData:t,VvForm:i}},R=(e,s)=>r.defineComponent({name:"WrapperComponent",props:{name:{type:String,required:!0},tag:{type:String,default:void 0}},emits:["invalid","valid"],expose:["fields","invalid"],setup(u,{emit:o}){const t=r.inject(e),i=r.inject(s,void 0),a=r.ref(new Set),l=r.ref(new Map),{name:n}=r.toRefs(u);r.provide(s,{name:r.readonly(n),errors:l,fields:a}),r.watch(a,p=>{i!=null&&i.fields&&p.forEach(m=>{i==null||i.fields.value.add(m)})},{deep:!0}),r.watch(()=>new Map(l.value),(p,m)=>{i!=null&&i.errors&&(Array.from(m.keys()).forEach(v=>{i.errors.value.delete(v)}),Array.from(p.keys()).forEach(v=>{const b=p.get(v);b&&i.errors.value.set(v,b)}))},{deep:!0});const h=r.computed(()=>t!=null&&t.invalid.value?l.value.size>0:!1);return r.watch(h,()=>{h.value?o("invalid"):o("valid")}),{formData:t==null?void 0:t.formData,errors:t==null?void 0:t.errors,submit:t==null?void 0:t.submit,validate:t==null?void 0:t.validate,invalid:h,fields:a,fieldsErrors:l}},render(){var u,o;return this.tag?r.h(this.tag,null,{default:()=>{var t,i;return((i=(t=this.$slots).default)==null?void 0:i.call(t,{invalid:this.invalid,formData:this.formData,submit:this.submit,validate:this.validate,errors:this.errors,fieldsErrors:this.fieldsErrors}))??this.$slots.defalut}}):((o=(u=this.$slots).default)==null?void 0:o.call(u,{invalid:this.invalid,formData:this.formData,submit:this.submit,validate:this.validate,errors:this.errors,fieldsErrors:this.fieldsErrors}))??this.$slots.defalut}}),H=(e,s)=>{const f=r.defineComponent({props:{schema:{type:[Array,Function],required:!0}},setup(u,{slots:o}){const t=r.inject(e);if(!(t!=null&&t.formData))return;const i=typeof u.schema=="function"?u.schema(t):u.schema;let a;return()=>{var l;return i.reduce((n,h)=>{const p=typeof h=="function"?h(t):h,{vvIs:m,vvName:v,vvSlots:b,vvChildren:O,vvIf:x,vvElseIf:g,vvType:A,vvDefaultValue:B,vvShowValid:K,...c}=p;if(x!==void 0){if(typeof x=="string"?a=!!k(Object(t.formData.value),x):typeof x=="function"?a=r.unref(x(t)):a=r.unref(x),!a)return n}else if(g!==void 0&&a!==void 0){if(a||(typeof g=="string"?a=!!k(Object(t.formData.value),g):typeof g=="function"?a=r.unref(g(t)):a=r.unref(g),!a))return n}else a=void 0;const w=O?r.h(f,{schema:O}):void 0;return v?(n.push(r.h(s,{name:v,is:m,type:A,defaultValue:B,showValid:K,props:c},b??w)),n):m?(n.push(r.h(m,c,b??w)),n):(O&&n.push(w),n)},[(l=o==null?void 0:o.default)==null?void 0:l.call(o,{formData:t==null?void 0:t.formData.value,submit:t==null?void 0:t.submit,validate:t==null?void 0:t.validate,errors:t==null?void 0:t.errors.value,status:t==null?void 0:t.status.value,invalid:t==null?void 0:t.invalid.value})])}}});return f},I=(e,s={})=>{const f=Symbol(),u=Symbol(),o=Symbol(),{VvForm:t,errors:i,status:a,formData:l}=z(e,f,s),n=R(f,u),h=P(f,u,o,s),p=H(f,h);return{VvForm:t,VvFormWrapper:n,VvFormField:h,VvFormTemplate:p,formInjectionKey:f,formWrapperInjectionKey:u,formFieldInjectionKey:o,errors:i,status:a,formData:l}},$=Symbol(),Q=e=>{let s={};return e.schema&&(s=I(e.schema,e)),{...s,install(f,{global:u=!1}={}){f.provide($,e),u&&(f.config.globalProperties.$vvForm=e,s!=null&&s.VvForm&&f.component("VvForm",s.VvForm),s!=null&&s.VvFormWrapper&&f.component("VvFormWrapper",s.VvFormWrapper),s!=null&&s.VvFormField&&f.component("VvFormField",s.VvFormField),s!=null&&s.VvFormTemplate&&f.component("VvFormTemplate",s.VvFormTemplate))}}},X=(e,s={})=>r.getCurrentInstance()?I(e,{...r.inject($,{}),...s}):I(e,s),Y=(e,s={})=>I(e,s);y.FormFieldType=d,y.createForm=Q,y.defaultObjectBySchema=E,y.formFactory=Y,y.pluginInjectionKey=$,y.useForm=X,Object.defineProperty(y,Symbol.toStringTag,{value:"Module"})});
1
+ (function(y,r){typeof exports=="object"&&typeof module<"u"?r(exports,require("vue"),require("@vueuse/core"),require("zod")):typeof define=="function"&&define.amd?define(["exports","vue","@vueuse/core","zod"],r):(y=typeof globalThis<"u"?globalThis:y||self,r(y["@volverjs/form-vue"]={},y.Vue,y.VueUseCore,y.zod))})(this,function(y,r,M,V){"use strict";function _(e){return Array.isArray(e)}function T(e){return typeof e<"u"}function N(e){return e===null}function G(e){return typeof e=="object"}function L(e){return typeof e=="string"}function C(e){return typeof e>"u"}const U=/^[0-9]+$/,J=["__proto__","prototype","constructor"];function k(e,s,f){const u=T(f)?f:void 0;if(!G(e)||!L(s))return u;const o=Z(s);if(o.length!==0){for(const t of o){if(t==="*")continue;const i=function(a){return a.map(l=>C(l)||N(l)?l:_(l)?i(l):l[t])};if(_(e)&&!U.test(t)?e=i(e):e=e[t],C(e)||N(e))break}return C(e)?u:e}}function W(e,s,f){if(!G(e)||!L(s))return;const u=Z(s);if(u.length===0)return;const o=u.length;for(let t=0;t<o;t++){const i=u[t];if(t===o-1){e[i]=f;return}if(i==="*"&&_(e)){const a=u.slice(t+1).join(".");for(const l of e)W(l,a,f);return}C(e[i])&&(e[i]={}),e=e[i]}}function Z(e){const s=e.split(/[.]|(?:\[(\d|\*)\])/).filter(f=>!!f);return s.some(f=>J.indexOf(f)!==-1)?[]:s}var d=(e=>(e.text="text",e.number="number",e.email="email",e.password="password",e.tel="tel",e.url="url",e.search="search",e.date="date",e.time="time",e.datetimeLocal="datetime-local",e.month="month",e.week="week",e.color="color",e.select="select",e.checkbox="checkbox",e.radio="radio",e.textarea="textarea",e.radioGroup="radioGroup",e.checkboxGroup="checkboxGroup",e.combobox="combobox",e.custom="custom",e))(d||{}),S=(e=>(e.invalid="invalid",e.valid="valid",e))(S||{});const P=(e,s,f,u)=>r.defineComponent({name:"FieldComponent",props:{type:{type:String,validator:o=>Object.values(d).includes(o),default:d.custom},is:{type:[Object,String],default:void 0},name:{type:[String,Number,Boolean,Symbol],required:!0},props:{type:[Object,Function],default:()=>({})},showValid:{type:Boolean,default:!1},defaultValue:{type:[String,Number,Boolean,Array,Object],default:void 0},lazyLoad:{type:Boolean,default:!1}},emits:["invalid","valid","update:formData","update:modelValue"],expose:["invalid","invalidLabel","errors"],setup(o,{slots:t,emit:i}){const a=r.computed({get(){if(n!=null&&n.formData)return k(Object(n.formData.value),String(o.name))},set(c){n!=null&&n.formData&&(W(Object(n.formData.value),String(o.name),c),i("update:modelValue",{newValue:a.value,formData:n==null?void 0:n.formData}))}});r.onMounted(()=>{a.value===void 0&&o.defaultValue!==void 0&&(a.value=o.defaultValue)}),r.onBeforeUnmount(()=>{O(),x()});const l=r.inject(s,void 0);l&&l.fields.value.add(o.name);const n=r.inject(e),{props:h,name:p}=r.toRefs(o),m=r.computed(()=>{if(n!=null&&n.errors.value)return k(n.errors.value,String(o.name))}),v=r.computed(()=>{var c;return(c=m.value)==null?void 0:c._errors}),b=r.computed(()=>m.value!==void 0),O=r.watch(b,()=>{b.value?(i("invalid",v.value),l&&l.errors.value.set(o.name,{_errors:v.value})):(i("valid",a.value),l&&l.errors.value.delete(o.name))}),x=r.watch(()=>n==null?void 0:n.formData,()=>{i("update:formData",n==null?void 0:n.formData)},{deep:!0}),g=c=>{a.value=c},A=r.computed(()=>{let c=h.value;return typeof c=="function"&&(c=c(n==null?void 0:n.formData)),Object.keys(c).reduce((w,q)=>(w[q]=r.unref(c[q]),w),{})}),B=r.computed(()=>({...A.value,name:A.value.name??o.name,invalid:b.value,valid:o.showValid?!!(!b.value&&a.value):void 0,type:(c=>{if([d.text,d.number,d.email,d.password,d.tel,d.url,d.search,d.date,d.time,d.datetimeLocal,d.month,d.week,d.color].includes(c))return c})(o.type),invalidLabel:v.value,modelValue:a.value,"onUpdate:modelValue":g}));return r.provide(f,{name:r.readonly(p),errors:r.readonly(m)}),{component:r.computed(()=>{if(o.type===d.custom)return{render(){var c;return((c=t.default)==null?void 0:c.call(t,{modelValue:a.value,onUpdate:g,submit:n==null?void 0:n.submit,validate:n==null?void 0:n.validate,invalid:b.value,invalidLabel:v.value,formData:n==null?void 0:n.formData.value,formErrors:n==null?void 0:n.errors.value,errors:m.value}))??t.defalut}};if(!((u==null?void 0:u.lazyLoad)??o.lazyLoad)){let c;switch(o.type){case d.select:c=r.resolveComponent("VvSelect");break;case d.checkbox:c=r.resolveComponent("VvCheckbox");break;case d.radio:c=r.resolveComponent("VvRadio");break;case d.textarea:c=r.resolveComponent("VvTextarea");break;case d.radioGroup:c=r.resolveComponent("VvRadioGroup");break;case d.checkboxGroup:c=r.resolveComponent("VvCheckboxGroup");break;case d.combobox:c=r.resolveComponent("VvCombobox");break;default:c=r.resolveComponent("VvInputText")}if(typeof c!="string")return c;console.warn(`[form-vue warn]: ${c} not found, the component will be loaded asynchronously. To avoid this warning, please set "lazyLoad" option.`)}return r.defineAsyncComponent(async()=>{switch(u!=null&&u.sideEffects&&await Promise.resolve(u.sideEffects(o.type)),o.type){case d.textarea:return import("@volverjs/ui-vue/vv-textarea");case d.radio:return import("@volverjs/ui-vue/vv-radio");case d.radioGroup:return import("@volverjs/ui-vue/vv-radio-group");case d.checkbox:return import("@volverjs/ui-vue/vv-checkbox");case d.checkboxGroup:return import("@volverjs/ui-vue/vv-checkbox-group");case d.select:return import("@volverjs/ui-vue/vv-select");case d.combobox:return import("@volverjs/ui-vue/vv-combobox")}return import("@volverjs/ui-vue/vv-input-text")})}),hasProps:B,invalid:b}},render(){return this.is?r.h(this.is,this.hasProps,this.$slots):this.type===d.custom?r.h(this.component,null,this.$slots):r.h(this.component,this.hasProps,this.$slots)}}),E=(e,s={})=>{const f=t=>{let i=t;for(;i instanceof V.ZodEffects;)i=i.innerType();return i instanceof V.ZodOptional&&(i=i._def.innerType),i},u=f(e);return{...(u instanceof V.ZodObject?u._def.unknownKeys==="passthrough":!1)?s:{},...Object.fromEntries(Object.entries(u.shape).map(([t,i])=>{const a=s[t];let l=f(i),n;if(l instanceof V.ZodDefault&&(n=l._def.defaultValue(),l=l._def.innerType),a===null&&l instanceof V.ZodNullable)return[t,a];if(l instanceof V.ZodSchema){const h=i.safeParse(a);if(h.success)return[t,h.data??n]}if(l instanceof V.ZodArray&&Array.isArray(a)&&a.length){const h=f(l._def.type);if(h instanceof V.ZodObject)return[t,a.map(p=>E(h,p&&typeof p=="object"?p:void 0))??n]}return l instanceof V.ZodObject?[t,E(l,a&&typeof a=="object"?a:n)]:[t,n]}))}},z=(e,s,f)=>{const u=r.ref(),o=r.ref(),t=r.ref(),i=r.defineComponent({name:"FormComponent",props:{modelValue:{type:Object,default:()=>({})},updateThrottle:{type:Number,default:500},continuosValidation:{type:Boolean,default:!1}},emits:["invalid","valid","submit","update:modelValue"],expose:["submit","validate","errors","status","valid","invalid"],setup(a,{emit:l}){t.value=E(e,r.toRaw(a.modelValue)),r.watch(()=>a.modelValue,m=>{if(m){const v=r.isProxy(m)?r.toRaw(m):m;t.value=typeof(v==null?void 0:v.clone)=="function"?v.clone():JSON.parse(JSON.stringify(v))}},{deep:!0}),M.watchThrottled(t,m=>{((u.value||(f==null?void 0:f.continuosValidation))??a.continuosValidation)&&n(),(!m||!a.modelValue||JSON.stringify(m)!==JSON.stringify(a.modelValue))&&l("update:modelValue",m)},{deep:!0,throttle:(f==null?void 0:f.updateThrottle)??a.updateThrottle});const n=(m=t.value)=>{const v=e.safeParse(m);return v.success?(u.value=void 0,o.value=S.valid,t.value=v.data,l("update:modelValue",t.value),l("valid",v.data),!0):(u.value=v.error.format(),o.value=S.invalid,l("invalid",u.value),!1)},h=()=>n()?(l("submit",t.value),!0):!1,p=r.computed(()=>o.value===S.invalid);return r.provide(s,{formData:t,submit:h,validate:n,errors:r.readonly(u),status:r.readonly(o),invalid:p}),{formData:t,submit:h,validate:n,errors:r.readonly(u),status:r.readonly(o),invalid:p}},render(){return r.h("form",{onSubmit:r.withModifiers(this.submit,["prevent"])},{default:()=>{var a,l;return((l=(a=this.$slots)==null?void 0:a.default)==null?void 0:l.call(a,{formData:this.formData,submit:this.submit,validate:this.validate,errors:this.errors,status:this.status,invalid:this.invalid}))??this.$slots.default}})}});return{errors:u,status:o,formData:t,VvForm:i}},R=(e,s)=>r.defineComponent({name:"WrapperComponent",props:{name:{type:String,required:!0},tag:{type:String,default:void 0}},emits:["invalid","valid"],expose:["fields","invalid"],setup(u,{emit:o}){const t=r.inject(e),i=r.inject(s,void 0),a=r.ref(new Set),l=r.ref(new Map),{name:n}=r.toRefs(u);r.provide(s,{name:r.readonly(n),errors:l,fields:a}),r.watch(a,p=>{i!=null&&i.fields&&p.forEach(m=>{i==null||i.fields.value.add(m)})},{deep:!0}),r.watch(()=>new Map(l.value),(p,m)=>{i!=null&&i.errors&&(Array.from(m.keys()).forEach(v=>{i.errors.value.delete(v)}),Array.from(p.keys()).forEach(v=>{const b=p.get(v);b&&i.errors.value.set(v,b)}))},{deep:!0});const h=r.computed(()=>t!=null&&t.invalid.value?l.value.size>0:!1);return r.watch(h,()=>{h.value?o("invalid"):o("valid")}),{formData:t==null?void 0:t.formData,errors:t==null?void 0:t.errors,submit:t==null?void 0:t.submit,validate:t==null?void 0:t.validate,invalid:h,fields:a,fieldsErrors:l}},render(){var u,o;return this.tag?r.h(this.tag,null,{default:()=>{var t,i;return((i=(t=this.$slots).default)==null?void 0:i.call(t,{invalid:this.invalid,formData:this.formData,submit:this.submit,validate:this.validate,errors:this.errors,fieldsErrors:this.fieldsErrors}))??this.$slots.defalut}}):((o=(u=this.$slots).default)==null?void 0:o.call(u,{invalid:this.invalid,formData:this.formData,submit:this.submit,validate:this.validate,errors:this.errors,fieldsErrors:this.fieldsErrors}))??this.$slots.defalut}}),H=(e,s)=>{const f=r.defineComponent({props:{schema:{type:[Array,Function],required:!0}},setup(u,{slots:o}){const t=r.inject(e);if(!(t!=null&&t.formData))return;const i=typeof u.schema=="function"?u.schema(t):u.schema;let a;return()=>{var l;return i.reduce((n,h)=>{const p=typeof h=="function"?h(t):h,{vvIs:m,vvName:v,vvSlots:b,vvChildren:O,vvIf:x,vvElseIf:g,vvType:A,vvDefaultValue:B,vvShowValid:K,...c}=p;if(x!==void 0){if(typeof x=="string"?a=!!k(Object(t.formData.value),x):typeof x=="function"?a=r.unref(x(t)):a=r.unref(x),!a)return n}else if(g!==void 0&&a!==void 0){if(a||(typeof g=="string"?a=!!k(Object(t.formData.value),g):typeof g=="function"?a=r.unref(g(t)):a=r.unref(g),!a))return n}else a=void 0;const w=O?r.h(f,{schema:O}):void 0;return v?(n.push(r.h(s,{name:v,is:m,type:A,defaultValue:B,showValid:K,props:c},b??w)),n):m?(n.push(r.h(m,c,b??w)),n):(O&&n.push(w),n)},[(l=o==null?void 0:o.default)==null?void 0:l.call(o,{formData:t==null?void 0:t.formData.value,submit:t==null?void 0:t.submit,validate:t==null?void 0:t.validate,errors:t==null?void 0:t.errors.value,status:t==null?void 0:t.status.value,invalid:t==null?void 0:t.invalid.value})])}}});return f},I=(e,s={})=>{const f=Symbol(),u=Symbol(),o=Symbol(),{VvForm:t,errors:i,status:a,formData:l}=z(e,f,s),n=R(f,u),h=P(f,u,o,s),p=H(f,h);return{VvForm:t,VvFormWrapper:n,VvFormField:h,VvFormTemplate:p,formInjectionKey:f,formWrapperInjectionKey:u,formFieldInjectionKey:o,errors:i,status:a,formData:l}},$=Symbol(),Q=e=>{let s={};return e.schema&&(s=I(e.schema,e)),{...s,install(f,{global:u=!1}={}){f.provide($,e),u&&(f.config.globalProperties.$vvForm=e,s!=null&&s.VvForm&&f.component("VvForm",s.VvForm),s!=null&&s.VvFormWrapper&&f.component("VvFormWrapper",s.VvFormWrapper),s!=null&&s.VvFormField&&f.component("VvFormField",s.VvFormField),s!=null&&s.VvFormTemplate&&f.component("VvFormTemplate",s.VvFormTemplate))}}},X=(e,s={})=>r.getCurrentInstance()?I(e,{...r.inject($,{}),...s}):I(e,s),Y=(e,s={})=>I(e,s);y.FormFieldType=d,y.createForm=Q,y.defaultObjectBySchema=E,y.formFactory=Y,y.pluginInjectionKey=$,y.useForm=X,Object.defineProperty(y,Symbol.toStringTag,{value:"Module"})});
package/dist/types.d.ts CHANGED
@@ -1,132 +1,58 @@
1
- import type { Ref } from 'vue'
2
- import type { z, AnyZodObject, ZodEffects } from 'zod'
3
- import type { FormFieldType, FormStatus } from './enums'
4
-
5
- export type FormSchema =
6
- | AnyZodObject
7
- | ZodEffects<AnyZodObject>
8
- | ZodEffects<ZodEffects<AnyZodObject>>
9
-
1
+ import type { Component, DeepReadonly, Ref } from 'vue';
2
+ import type { z, AnyZodObject, ZodEffects } from 'zod';
3
+ import type { FormFieldType, FormStatus } from './enums';
4
+ export type FormSchema = AnyZodObject | ZodEffects<AnyZodObject> | ZodEffects<ZodEffects<AnyZodObject>>;
10
5
  export type FormFieldComponentOptions = {
11
- lazyLoad?: boolean
12
- sideEffects?: (type: `${FormFieldType}`) => Promise | void
13
- }
14
-
6
+ lazyLoad?: boolean;
7
+ sideEffects?: (type: `${FormFieldType}`) => Promise<void> | void;
8
+ };
15
9
  export type FormComponentOptions = {
16
- updateThrottle?: number
17
- continuosValidation?: boolean
18
- }
19
-
20
- export type FormComposableOptions = FormFieldComponentOptions &
21
- FormComponentOptions
22
-
10
+ updateThrottle?: number;
11
+ continuosValidation?: boolean;
12
+ };
13
+ export type FormComposableOptions = FormFieldComponentOptions & FormComponentOptions;
23
14
  export type FormPluginOptions = {
24
- schema?: ZodSchema
25
- } & FormComposableOptions
26
-
15
+ schema?: FormSchema;
16
+ } & FormComposableOptions;
27
17
  export type InjectedFormData<Schema extends FormSchema> = {
28
- formData: Ref<Partial<z.infer<Schema>> | undefined>
29
- errors: Readonly<Ref<DeepReadonly<z.inferFormattedError<Schema>>>>
30
- submit: () => boolean
31
- validate: () => boolean
32
- status: Readonly<Ref<FormStatus | undefined>>
33
- invalid: Readonly<Ref<boolean>>
34
- }
35
-
18
+ formData: Ref<Partial<z.infer<Schema>> | undefined>;
19
+ errors: Readonly<Ref<DeepReadonly<z.inferFormattedError<Schema>> | undefined>>;
20
+ submit: () => boolean;
21
+ validate: () => boolean;
22
+ status: Readonly<Ref<FormStatus | undefined>>;
23
+ invalid: Readonly<Ref<boolean>>;
24
+ };
36
25
  export type InjectedFormWrapperData<Schema extends FormSchema> = {
37
- name: Ref<string>
38
- fields: Ref<Set<string>>
39
- errors: Readonly<Ref<DeepReadonly<z.inferFormattedError<Schema>>>>
40
- }
41
-
26
+ name: Ref<string>;
27
+ fields: Ref<Set<string>>;
28
+ errors: Ref<Map<string, z.inferFormattedError<Schema, string>>>;
29
+ };
42
30
  export type InjectedFormFieldData<Schema extends FormSchema> = {
43
- name: Ref<string>
44
- errors: Readonly<Ref<DeepReadonly<z.inferFormattedError<Schema>>>>
45
- }
46
-
47
- export type Primitive =
48
- | null
49
- | undefined
50
- | string
51
- | number
52
- | boolean
53
- | symbol
54
- | bigint
55
-
56
- type ArrayKey = number
57
-
58
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
59
- type IsTuple<T extends readonly any[]> = number extends T['length']
60
- ? false
61
- : true
62
-
63
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
64
- type TupleKeys<T extends readonly any[]> = Exclude<keyof T, keyof any[]>
65
-
66
- export type PathConcat<
67
- TKey extends string | number,
68
- TValue,
69
- > = TValue extends Primitive ? `${TKey}` : `${TKey}` | `${TKey}.${Path<TValue>}`
70
-
71
- export type Path<T> = T extends readonly (infer V)[]
72
- ? IsTuple<T> extends true
73
- ? {
74
- [K in TupleKeys<T>]-?: PathConcat<K & string, T[K]>
75
- }[TupleKeys<T>]
76
- : PathConcat<ArrayKey, V>
77
- : {
78
- [K in keyof T]-?: PathConcat<K & string, T[K]>
79
- }[keyof T]
80
-
81
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
82
- export type PathValue<T, TPath extends Path<T> | ArrayPath<T>> = T extends any
83
- ? TPath extends `${infer K}.${infer R}`
84
- ? K extends keyof T
85
- ? R extends Path<T[K]>
86
- ? undefined extends T[K]
87
- ? PathValue<T[K], R> | undefined
88
- : PathValue<T[K], R>
89
- : never
90
- : K extends `${ArrayKey}`
91
- ? T extends readonly (infer V)[]
92
- ? PathValue<V, R & Path<V>>
93
- : never
94
- : never
95
- : TPath extends keyof T
96
- ? T[TPath]
97
- : TPath extends `${ArrayKey}`
98
- ? T extends readonly (infer V)[]
99
- ? V
100
- : never
101
- : never
102
- : never
103
-
104
- export type AnyBoolean<Schema> =
105
- | boolean
106
- | Ref<boolean>
107
- | ((data?: InjectedFormData<Schema>) => boolean | Ref<boolean>)
108
-
109
- export type SimpleFormTemplateItem<Schema extends FormSchema> = Record<
110
- string,
111
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
112
- any
113
- > & {
114
- vvIs?: string | Component
115
- vvName?: Path<z.infer<Schema>>
116
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
117
- vvSlots?: Record<string, any>
118
- vvChildren?: Array<
119
- | SimpleFormTemplateItem<Schema>
120
- | ((data?: InjectedFormData<Schema>) => SimpleFormTemplateItem<Schema>)
121
- >
122
- vvIf?: AnyBoolean<Schema> | Path<z.infer<Schema>>
123
- vvElseIf?: AnyBoolean<Schema> | Path<z.infer<Schema>>
124
- vvType?: `${FormFieldType}`
125
- vvShowValid?: boolean
126
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
127
- vvDefaultValue?: any
128
- }
129
-
130
- export type FormTemplateItem<Schema extends FormSchema> =
131
- | SimpleFormTemplateItem<Schema>
132
- | ((data?: InjectedFormData<Schema>) => SimpleFormTemplateItem<Schema>)
31
+ name: Ref<string>;
32
+ errors: Readonly<Ref<DeepReadonly<z.inferFormattedError<Schema>>>>;
33
+ };
34
+ export type Primitive = null | undefined | string | number | boolean | symbol | bigint;
35
+ type ArrayKey = number;
36
+ type IsTuple<T extends readonly any[]> = number extends T['length'] ? false : true;
37
+ type TupleKeys<T extends readonly any[]> = Exclude<keyof T, keyof any[]>;
38
+ export type PathConcat<TKey extends string | number, TValue> = TValue extends Primitive ? `${TKey}` : `${TKey}` | `${TKey}.${Path<TValue>}`;
39
+ export type Path<T> = T extends readonly (infer V)[] ? IsTuple<T> extends true ? {
40
+ [K in TupleKeys<T>]-?: PathConcat<K & string, T[K]>;
41
+ }[TupleKeys<T>] : PathConcat<ArrayKey, V> : {
42
+ [K in keyof T]-?: PathConcat<K & string, T[K]>;
43
+ }[keyof T];
44
+ export type PathValue<T, TPath extends Path<T> | Path<T>[]> = T extends any ? TPath extends `${infer K}.${infer R}` ? K extends keyof T ? R extends Path<T[K]> ? undefined extends T[K] ? PathValue<T[K], R> | undefined : PathValue<T[K], R> : never : K extends `${ArrayKey}` ? T extends readonly (infer V)[] ? PathValue<V, R & Path<V>> : never : never : TPath extends keyof T ? T[TPath] : TPath extends `${ArrayKey}` ? T extends readonly (infer V)[] ? V : never : never : never;
45
+ export type AnyBoolean<Schema extends FormSchema> = boolean | Ref<boolean> | ((data?: InjectedFormData<Schema>) => boolean | Ref<boolean>);
46
+ export type SimpleFormTemplateItem<Schema extends FormSchema> = Record<string, any> & {
47
+ vvIs?: string | Component;
48
+ vvName?: Path<z.infer<Schema>>;
49
+ vvSlots?: Record<string, any>;
50
+ vvChildren?: Array<SimpleFormTemplateItem<Schema> | ((data?: InjectedFormData<Schema>) => SimpleFormTemplateItem<Schema>)>;
51
+ vvIf?: AnyBoolean<Schema> | Path<z.infer<Schema>>;
52
+ vvElseIf?: AnyBoolean<Schema> | Path<z.infer<Schema>>;
53
+ vvType?: `${FormFieldType}`;
54
+ vvShowValid?: boolean;
55
+ vvDefaultValue?: any;
56
+ };
57
+ export type FormTemplateItem<Schema extends FormSchema> = SimpleFormTemplateItem<Schema> | ((data?: InjectedFormData<Schema>) => SimpleFormTemplateItem<Schema>);
58
+ export {};
package/package.json CHANGED
@@ -19,11 +19,11 @@
19
19
  "bugs": {
20
20
  "url": "https://github.com/volverjs/form-vue/issues"
21
21
  },
22
- "version": "0.0.14-beta.1",
22
+ "version": "0.0.14-beta.2",
23
23
  "engines": {
24
24
  "node": ">= 16.x"
25
25
  },
26
- "packageManager": "pnpm@7.8.0",
26
+ "packageManager": "pnpm@8.6.12",
27
27
  "type": "module",
28
28
  "main": "./dist/index.js",
29
29
  "module": "./dist/index.js",
@@ -44,8 +44,8 @@
44
44
  "devDependencies": {
45
45
  "@playwright/experimental-ct-vue": "1.36.2",
46
46
  "@testing-library/vue": "^7.0.0",
47
- "@typescript-eslint/eslint-plugin": "^6.2.1",
48
- "@typescript-eslint/parser": "^6.2.1",
47
+ "@typescript-eslint/eslint-plugin": "^6.3.0",
48
+ "@typescript-eslint/parser": "^6.3.0",
49
49
  "@vitejs/plugin-vue": "^4.2.3",
50
50
  "@volverjs/style": "^0.1.11",
51
51
  "@vue/compiler-sfc": "^3.3.4",
@@ -53,16 +53,16 @@
53
53
  "@vue/test-utils": "^2.4.1",
54
54
  "copy": "^0.3.2",
55
55
  "eslint": "^8.46.0",
56
- "eslint-config-prettier": "^8.10.0",
56
+ "eslint-config-prettier": "^9.0.0",
57
57
  "eslint-plugin-prettier": "^5.0.0",
58
- "happy-dom": "^10.6.3",
58
+ "happy-dom": "^10.9.0",
59
59
  "prettier": "^3.0.1",
60
60
  "typescript": "^5.1.6",
61
- "vite": "^4.4.8",
61
+ "vite": "^4.4.9",
62
+ "vite-plugin-dts": "^3.5.1",
62
63
  "vite-plugin-eslint": "^1.8.1",
63
64
  "vite-plugin-externalize-deps": "^0.7.0",
64
- "vitest": "^0.34.1",
65
- "vue-tsc": "^1.8.8"
65
+ "vitest": "^0.34.1"
66
66
  },
67
67
  "typesVersions": {
68
68
  "*": {
@@ -83,7 +83,8 @@
83
83
  "scripts": {
84
84
  "lint": "eslint . --ext .js,.jsx,.ts,.tsx",
85
85
  "type-check": "tsc --noEmit",
86
- "build": "vite build && vue-tsc --declaration --emitDeclarationOnly && copy src/**/types.d.ts dist",
86
+ "build": "vite build",
87
+ "dev": "vite build --watch",
87
88
  "test": "pnpm run test-vitest && pnpm run test-playwright",
88
89
  "test-vitest": "vitest run",
89
90
  "test-vitest-watch": "vitest",
package/src/VvForm.ts CHANGED
@@ -28,7 +28,7 @@ export const defineForm = <Schema extends FormSchema>(
28
28
  provideKey: InjectionKey<InjectedFormData<Schema>>,
29
29
  options?: FormComponentOptions,
30
30
  ) => {
31
- const errors = ref<ZodFormattedError<z.infer<Schema>>>()
31
+ const errors = ref<z.inferFormattedError<Schema> | undefined>()
32
32
  const status = ref<FormStatus | undefined>()
33
33
  const formData = ref<Partial<z.infer<Schema> | undefined>>()
34
34
  const component = defineComponent({
@@ -151,7 +151,7 @@ export const defineFormField = <Schema extends FormSchema>(
151
151
  props.name as string,
152
152
  {
153
153
  _errors: invalidLabel.value,
154
- },
154
+ } as z.inferFormattedError<Schema>,
155
155
  )
156
156
  }
157
157
  } else {
@@ -42,7 +42,7 @@ export const defineFormWrapper = <Schema extends FormSchema>(
42
42
  const wrapperProvided = inject(wrapperProvideKey, undefined)
43
43
  const fields = ref(new Set<string>())
44
44
  const fieldsErrors: Ref<
45
- Map<string, Record<string, { _errors: string[] }>>
45
+ Map<string, z.inferFormattedError<Schema>>
46
46
  > = ref(new Map())
47
47
  const { name } = toRefs(props)
48
48
 
@@ -1,4 +1,4 @@
1
- import type { Ref } from 'vue'
1
+ import type { Component, DeepReadonly, Ref } from 'vue'
2
2
  import type { z, AnyZodObject, ZodEffects } from 'zod'
3
3
  import type { FormFieldType, FormStatus } from './enums'
4
4
 
@@ -9,7 +9,7 @@ export type FormSchema =
9
9
 
10
10
  export type FormFieldComponentOptions = {
11
11
  lazyLoad?: boolean
12
- sideEffects?: (type: `${FormFieldType}`) => Promise | void
12
+ sideEffects?: (type: `${FormFieldType}`) => Promise<void> | void
13
13
  }
14
14
 
15
15
  export type FormComponentOptions = {
@@ -21,12 +21,14 @@ export type FormComposableOptions = FormFieldComponentOptions &
21
21
  FormComponentOptions
22
22
 
23
23
  export type FormPluginOptions = {
24
- schema?: ZodSchema
24
+ schema?: FormSchema
25
25
  } & FormComposableOptions
26
26
 
27
27
  export type InjectedFormData<Schema extends FormSchema> = {
28
28
  formData: Ref<Partial<z.infer<Schema>> | undefined>
29
- errors: Readonly<Ref<DeepReadonly<z.inferFormattedError<Schema>>>>
29
+ errors: Readonly<
30
+ Ref<DeepReadonly<z.inferFormattedError<Schema>> | undefined>
31
+ >
30
32
  submit: () => boolean
31
33
  validate: () => boolean
32
34
  status: Readonly<Ref<FormStatus | undefined>>
@@ -36,7 +38,7 @@ export type InjectedFormData<Schema extends FormSchema> = {
36
38
  export type InjectedFormWrapperData<Schema extends FormSchema> = {
37
39
  name: Ref<string>
38
40
  fields: Ref<Set<string>>
39
- errors: Readonly<Ref<DeepReadonly<z.inferFormattedError<Schema>>>>
41
+ errors: Ref<Map<string, z.inferFormattedError<Schema, string>>>
40
42
  }
41
43
 
42
44
  export type InjectedFormFieldData<Schema extends FormSchema> = {
@@ -77,9 +79,9 @@ export type Path<T> = T extends readonly (infer V)[]
77
79
  : {
78
80
  [K in keyof T]-?: PathConcat<K & string, T[K]>
79
81
  }[keyof T]
80
-
82
+
81
83
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
82
- export type PathValue<T, TPath extends Path<T> | ArrayPath<T>> = T extends any
84
+ export type PathValue<T, TPath extends Path<T> | Path<T>[]> = T extends any
83
85
  ? TPath extends `${infer K}.${infer R}`
84
86
  ? K extends keyof T
85
87
  ? R extends Path<T[K]>
@@ -101,7 +103,7 @@ export type PathValue<T, TPath extends Path<T> | ArrayPath<T>> = T extends any
101
103
  : never
102
104
  : never
103
105
 
104
- export type AnyBoolean<Schema> =
106
+ export type AnyBoolean<Schema extends FormSchema> =
105
107
  | boolean
106
108
  | Ref<boolean>
107
109
  | ((data?: InjectedFormData<Schema>) => boolean | Ref<boolean>)
package/src/utils.ts CHANGED
@@ -67,7 +67,7 @@ export const defaultObjectBySchema = <Schema extends FormSchema>(
67
67
  Array.isArray(originalValue) &&
68
68
  originalValue.length
69
69
  ) {
70
- const arrayType = innerType._def.type
70
+ const arrayType = getInnerType(innerType._def.type)
71
71
  if (arrayType instanceof ZodObject) {
72
72
  return [
73
73
  key,