@volverjs/form-vue 0.0.10-beta.4 → 0.0.10-beta.5
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/VvFormWrapper.d.ts +119 -19
- package/dist/index.d.ts +230 -30
- package/dist/index.es.js +163 -163
- package/dist/index.umd.js +1 -1
- package/package.json +6 -6
- package/src/VvFormWrapper.ts +33 -2
package/dist/VvFormWrapper.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type InjectionKey, type Ref } from 'vue';
|
|
2
|
-
import type { AnyZodObject, ZodEffects } from 'zod';
|
|
1
|
+
import { type InjectionKey, type Ref, type DeepReadonly } from 'vue';
|
|
2
|
+
import type { AnyZodObject, TypeOf, ZodEffects, z } from 'zod';
|
|
3
3
|
import type { InjectedFormData, InjectedFormWrapperData } from './types';
|
|
4
4
|
export declare const defineFormWrapper: <Schema extends AnyZodObject | ZodEffects<AnyZodObject, {
|
|
5
5
|
[x: string]: any;
|
|
@@ -13,7 +13,105 @@ export declare const defineFormWrapper: <Schema extends AnyZodObject | ZodEffect
|
|
|
13
13
|
[x: string]: any;
|
|
14
14
|
}, {
|
|
15
15
|
[x: string]: any;
|
|
16
|
-
}>>(formProvideKey: InjectionKey<InjectedFormData<Schema>>, wrapperProvideKey: InjectionKey<InjectedFormWrapperData<Schema>>) =>
|
|
16
|
+
}>>(formProvideKey: InjectionKey<InjectedFormData<Schema>>, wrapperProvideKey: InjectionKey<InjectedFormWrapperData<Schema>>) => {
|
|
17
|
+
new (...args: any[]): {
|
|
18
|
+
$: import("vue").ComponentInternalInstance;
|
|
19
|
+
$data: {};
|
|
20
|
+
$props: Partial<{
|
|
21
|
+
tag: string;
|
|
22
|
+
}> & Omit<Readonly<import("vue").ExtractPropTypes<{
|
|
23
|
+
name: {
|
|
24
|
+
type: StringConstructor;
|
|
25
|
+
required: true;
|
|
26
|
+
};
|
|
27
|
+
tag: {
|
|
28
|
+
type: StringConstructor;
|
|
29
|
+
default: undefined;
|
|
30
|
+
};
|
|
31
|
+
}>> & {
|
|
32
|
+
onValid?: ((...args: any[]) => any) | undefined;
|
|
33
|
+
onInvalid?: ((...args: any[]) => any) | undefined;
|
|
34
|
+
} & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, "tag">;
|
|
35
|
+
$attrs: {
|
|
36
|
+
[x: string]: unknown;
|
|
37
|
+
};
|
|
38
|
+
$refs: {
|
|
39
|
+
[x: string]: unknown;
|
|
40
|
+
};
|
|
41
|
+
$slots: Readonly<{
|
|
42
|
+
[name: string]: import("vue").Slot | undefined;
|
|
43
|
+
}>;
|
|
44
|
+
$root: import("vue").ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, import("vue").ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}, {}, string>, {}> | null;
|
|
45
|
+
$parent: import("vue").ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, import("vue").ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}, {}, string>, {}> | null;
|
|
46
|
+
$emit: (event: "valid" | "invalid", ...args: any[]) => void;
|
|
47
|
+
$el: any;
|
|
48
|
+
$options: import("vue").ComponentOptionsBase<Readonly<import("vue").ExtractPropTypes<{
|
|
49
|
+
name: {
|
|
50
|
+
type: StringConstructor;
|
|
51
|
+
required: true;
|
|
52
|
+
};
|
|
53
|
+
tag: {
|
|
54
|
+
type: StringConstructor;
|
|
55
|
+
default: undefined;
|
|
56
|
+
};
|
|
57
|
+
}>> & {
|
|
58
|
+
onValid?: ((...args: any[]) => any) | undefined;
|
|
59
|
+
onInvalid?: ((...args: any[]) => any) | undefined;
|
|
60
|
+
}, {
|
|
61
|
+
formData: Ref<Partial<TypeOf<Schema>> | undefined> | undefined;
|
|
62
|
+
errors: Readonly<Ref<DeepReadonly<z.inferFormattedError<Schema_1, string>>>> | undefined;
|
|
63
|
+
invalid: import("vue").ComputedRef<boolean>;
|
|
64
|
+
fields: Ref<Set<string>>;
|
|
65
|
+
fieldsErrors: Ref<Map<string, Record<string, {
|
|
66
|
+
_errors: string[];
|
|
67
|
+
}>>>;
|
|
68
|
+
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("valid" | "invalid")[], string, {
|
|
69
|
+
tag: string;
|
|
70
|
+
}, {}, string> & {
|
|
71
|
+
beforeCreate?: ((() => void) | (() => void)[]) | undefined;
|
|
72
|
+
created?: ((() => void) | (() => void)[]) | undefined;
|
|
73
|
+
beforeMount?: ((() => void) | (() => void)[]) | undefined;
|
|
74
|
+
mounted?: ((() => void) | (() => void)[]) | undefined;
|
|
75
|
+
beforeUpdate?: ((() => void) | (() => void)[]) | undefined;
|
|
76
|
+
updated?: ((() => void) | (() => void)[]) | undefined;
|
|
77
|
+
activated?: ((() => void) | (() => void)[]) | undefined;
|
|
78
|
+
deactivated?: ((() => void) | (() => void)[]) | undefined;
|
|
79
|
+
beforeDestroy?: ((() => void) | (() => void)[]) | undefined;
|
|
80
|
+
beforeUnmount?: ((() => void) | (() => void)[]) | undefined;
|
|
81
|
+
destroyed?: ((() => void) | (() => void)[]) | undefined;
|
|
82
|
+
unmounted?: ((() => void) | (() => void)[]) | undefined;
|
|
83
|
+
renderTracked?: (((e: import("vue").DebuggerEvent) => void) | ((e: import("vue").DebuggerEvent) => void)[]) | undefined;
|
|
84
|
+
renderTriggered?: (((e: import("vue").DebuggerEvent) => void) | ((e: import("vue").DebuggerEvent) => void)[]) | undefined;
|
|
85
|
+
errorCaptured?: (((err: unknown, instance: import("vue").ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, import("vue").ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}, {}, string>, {}> | null, info: string) => boolean | void) | ((err: unknown, instance: import("vue").ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, import("vue").ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}, {}, string>, {}> | null, info: string) => boolean | void)[]) | undefined;
|
|
86
|
+
};
|
|
87
|
+
$forceUpdate: () => void;
|
|
88
|
+
$nextTick: typeof import("vue").nextTick;
|
|
89
|
+
$watch<T extends string | ((...args: any) => any)>(source: T, cb: T extends (...args: any) => infer R ? (args_0: R, args_1: R) => any : (...args: any) => any, options?: import("vue").WatchOptions<boolean> | undefined): import("vue").WatchStopHandle;
|
|
90
|
+
} & Readonly<import("vue").ExtractPropTypes<{
|
|
91
|
+
name: {
|
|
92
|
+
type: StringConstructor;
|
|
93
|
+
required: true;
|
|
94
|
+
};
|
|
95
|
+
tag: {
|
|
96
|
+
type: StringConstructor;
|
|
97
|
+
default: undefined;
|
|
98
|
+
};
|
|
99
|
+
}>> & {
|
|
100
|
+
onValid?: ((...args: any[]) => any) | undefined;
|
|
101
|
+
onInvalid?: ((...args: any[]) => any) | undefined;
|
|
102
|
+
} & import("vue").ShallowUnwrapRef<{
|
|
103
|
+
formData: Ref<Partial<TypeOf<Schema>> | undefined> | undefined;
|
|
104
|
+
errors: Readonly<Ref<DeepReadonly<z.inferFormattedError<Schema_1, string>>>> | undefined;
|
|
105
|
+
invalid: import("vue").ComputedRef<boolean>;
|
|
106
|
+
fields: Ref<Set<string>>;
|
|
107
|
+
fieldsErrors: Ref<Map<string, Record<string, {
|
|
108
|
+
_errors: string[];
|
|
109
|
+
}>>>;
|
|
110
|
+
}> & {} & import("vue").ComponentCustomProperties & {};
|
|
111
|
+
__isFragment?: undefined;
|
|
112
|
+
__isTeleport?: undefined;
|
|
113
|
+
__isSuspense?: undefined;
|
|
114
|
+
} & import("vue").ComponentOptionsBase<Readonly<import("vue").ExtractPropTypes<{
|
|
17
115
|
name: {
|
|
18
116
|
type: StringConstructor;
|
|
19
117
|
required: true;
|
|
@@ -22,26 +120,28 @@ export declare const defineFormWrapper: <Schema extends AnyZodObject | ZodEffect
|
|
|
22
120
|
type: StringConstructor;
|
|
23
121
|
default: undefined;
|
|
24
122
|
};
|
|
123
|
+
}>> & {
|
|
124
|
+
onValid?: ((...args: any[]) => any) | undefined;
|
|
125
|
+
onInvalid?: ((...args: any[]) => any) | undefined;
|
|
25
126
|
}, {
|
|
26
|
-
formData: Ref<Partial<
|
|
27
|
-
errors: Readonly<Ref<DeepReadonly<
|
|
127
|
+
formData: Ref<Partial<TypeOf<Schema>> | undefined> | undefined;
|
|
128
|
+
errors: Readonly<Ref<DeepReadonly<z.inferFormattedError<Schema_1, string>>>> | undefined;
|
|
28
129
|
invalid: import("vue").ComputedRef<boolean>;
|
|
29
130
|
fields: Ref<Set<string>>;
|
|
30
131
|
fieldsErrors: Ref<Map<string, Record<string, {
|
|
31
132
|
_errors: string[];
|
|
32
133
|
}>>>;
|
|
33
|
-
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("valid" | "invalid")[], "valid" | "invalid",
|
|
34
|
-
name: {
|
|
35
|
-
type: StringConstructor;
|
|
36
|
-
required: true;
|
|
37
|
-
};
|
|
38
|
-
tag: {
|
|
39
|
-
type: StringConstructor;
|
|
40
|
-
default: undefined;
|
|
41
|
-
};
|
|
42
|
-
}>> & {
|
|
43
|
-
onValid?: ((...args: any[]) => any) | undefined;
|
|
44
|
-
onInvalid?: ((...args: any[]) => any) | undefined;
|
|
45
|
-
}, {
|
|
134
|
+
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("valid" | "invalid")[], "valid" | "invalid", {
|
|
46
135
|
tag: string;
|
|
47
|
-
}
|
|
136
|
+
}, {}, string> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps & (new () => {
|
|
137
|
+
$slots: {
|
|
138
|
+
default: (_: {
|
|
139
|
+
invalid: boolean;
|
|
140
|
+
formData: unknown extends Partial<TypeOf<Schema>> | undefined ? undefined : Partial<TypeOf<Schema>> | undefined;
|
|
141
|
+
errors: Readonly<Ref<DeepReadonly<z.inferFormattedError<Schema, string>>>>;
|
|
142
|
+
fieldsErrors: Map<string, Record<string, {
|
|
143
|
+
_errors: string[];
|
|
144
|
+
}>>;
|
|
145
|
+
}) => any;
|
|
146
|
+
};
|
|
147
|
+
});
|
package/dist/index.d.ts
CHANGED
|
@@ -46,7 +46,105 @@ export declare const formFactory: <Schema extends AnyZodObject | ZodEffects<AnyZ
|
|
|
46
46
|
modelValue: Record<string, any>;
|
|
47
47
|
continuosValidation: boolean;
|
|
48
48
|
}>;
|
|
49
|
-
VvFormWrapper:
|
|
49
|
+
VvFormWrapper: {
|
|
50
|
+
new (...args: any[]): {
|
|
51
|
+
$: import("vue").ComponentInternalInstance;
|
|
52
|
+
$data: {};
|
|
53
|
+
$props: Partial<{
|
|
54
|
+
tag: string;
|
|
55
|
+
}> & Omit<Readonly<import("vue").ExtractPropTypes<{
|
|
56
|
+
name: {
|
|
57
|
+
type: StringConstructor;
|
|
58
|
+
required: true;
|
|
59
|
+
};
|
|
60
|
+
tag: {
|
|
61
|
+
type: StringConstructor;
|
|
62
|
+
default: undefined;
|
|
63
|
+
};
|
|
64
|
+
}>> & {
|
|
65
|
+
onValid?: ((...args: any[]) => any) | undefined;
|
|
66
|
+
onInvalid?: ((...args: any[]) => any) | undefined;
|
|
67
|
+
} & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, "tag">;
|
|
68
|
+
$attrs: {
|
|
69
|
+
[x: string]: unknown;
|
|
70
|
+
};
|
|
71
|
+
$refs: {
|
|
72
|
+
[x: string]: unknown;
|
|
73
|
+
};
|
|
74
|
+
$slots: Readonly<{
|
|
75
|
+
[name: string]: import("vue").Slot | undefined;
|
|
76
|
+
}>;
|
|
77
|
+
$root: import("vue").ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, import("vue").ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}, {}, string>, {}> | null;
|
|
78
|
+
$parent: import("vue").ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, import("vue").ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}, {}, string>, {}> | null;
|
|
79
|
+
$emit: (event: "valid" | "invalid", ...args: any[]) => void;
|
|
80
|
+
$el: any;
|
|
81
|
+
$options: import("vue").ComponentOptionsBase<Readonly<import("vue").ExtractPropTypes<{
|
|
82
|
+
name: {
|
|
83
|
+
type: StringConstructor;
|
|
84
|
+
required: true;
|
|
85
|
+
};
|
|
86
|
+
tag: {
|
|
87
|
+
type: StringConstructor;
|
|
88
|
+
default: undefined;
|
|
89
|
+
};
|
|
90
|
+
}>> & {
|
|
91
|
+
onValid?: ((...args: any[]) => any) | undefined;
|
|
92
|
+
onInvalid?: ((...args: any[]) => any) | undefined;
|
|
93
|
+
}, {
|
|
94
|
+
formData: import("vue").Ref<Partial<import("zod").TypeOf<Schema>> | undefined> | undefined;
|
|
95
|
+
errors: Readonly<import("vue").Ref<DeepReadonly<import("zod").inferFormattedError<Schema_1, string>>>> | undefined;
|
|
96
|
+
invalid: import("vue").ComputedRef<boolean>;
|
|
97
|
+
fields: import("vue").Ref<Set<string>>;
|
|
98
|
+
fieldsErrors: import("vue").Ref<Map<string, Record<string, {
|
|
99
|
+
_errors: string[];
|
|
100
|
+
}>>>;
|
|
101
|
+
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("valid" | "invalid")[], string, {
|
|
102
|
+
tag: string;
|
|
103
|
+
}, {}, string> & {
|
|
104
|
+
beforeCreate?: ((() => void) | (() => void)[]) | undefined;
|
|
105
|
+
created?: ((() => void) | (() => void)[]) | undefined;
|
|
106
|
+
beforeMount?: ((() => void) | (() => void)[]) | undefined;
|
|
107
|
+
mounted?: ((() => void) | (() => void)[]) | undefined;
|
|
108
|
+
beforeUpdate?: ((() => void) | (() => void)[]) | undefined;
|
|
109
|
+
updated?: ((() => void) | (() => void)[]) | undefined;
|
|
110
|
+
activated?: ((() => void) | (() => void)[]) | undefined;
|
|
111
|
+
deactivated?: ((() => void) | (() => void)[]) | undefined;
|
|
112
|
+
beforeDestroy?: ((() => void) | (() => void)[]) | undefined;
|
|
113
|
+
beforeUnmount?: ((() => void) | (() => void)[]) | undefined;
|
|
114
|
+
destroyed?: ((() => void) | (() => void)[]) | undefined;
|
|
115
|
+
unmounted?: ((() => void) | (() => void)[]) | undefined;
|
|
116
|
+
renderTracked?: (((e: import("vue").DebuggerEvent) => void) | ((e: import("vue").DebuggerEvent) => void)[]) | undefined;
|
|
117
|
+
renderTriggered?: (((e: import("vue").DebuggerEvent) => void) | ((e: import("vue").DebuggerEvent) => void)[]) | undefined;
|
|
118
|
+
errorCaptured?: (((err: unknown, instance: import("vue").ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, import("vue").ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}, {}, string>, {}> | null, info: string) => boolean | void) | ((err: unknown, instance: import("vue").ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, import("vue").ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}, {}, string>, {}> | null, info: string) => boolean | void)[]) | undefined;
|
|
119
|
+
};
|
|
120
|
+
$forceUpdate: () => void;
|
|
121
|
+
$nextTick: typeof import("vue").nextTick;
|
|
122
|
+
$watch<T extends string | ((...args: any) => any)>(source: T, cb: T extends (...args: any) => infer R ? (args_0: R, args_1: R) => any : (...args: any) => any, options?: import("vue").WatchOptions<boolean> | undefined): import("vue").WatchStopHandle;
|
|
123
|
+
} & Readonly<import("vue").ExtractPropTypes<{
|
|
124
|
+
name: {
|
|
125
|
+
type: StringConstructor;
|
|
126
|
+
required: true;
|
|
127
|
+
};
|
|
128
|
+
tag: {
|
|
129
|
+
type: StringConstructor;
|
|
130
|
+
default: undefined;
|
|
131
|
+
};
|
|
132
|
+
}>> & {
|
|
133
|
+
onValid?: ((...args: any[]) => any) | undefined;
|
|
134
|
+
onInvalid?: ((...args: any[]) => any) | undefined;
|
|
135
|
+
} & import("vue").ShallowUnwrapRef<{
|
|
136
|
+
formData: import("vue").Ref<Partial<import("zod").TypeOf<Schema>> | undefined> | undefined;
|
|
137
|
+
errors: Readonly<import("vue").Ref<DeepReadonly<import("zod").inferFormattedError<Schema_1, string>>>> | undefined;
|
|
138
|
+
invalid: import("vue").ComputedRef<boolean>;
|
|
139
|
+
fields: import("vue").Ref<Set<string>>;
|
|
140
|
+
fieldsErrors: import("vue").Ref<Map<string, Record<string, {
|
|
141
|
+
_errors: string[];
|
|
142
|
+
}>>>;
|
|
143
|
+
}> & {} & import("vue").ComponentCustomProperties & {};
|
|
144
|
+
__isFragment?: undefined;
|
|
145
|
+
__isTeleport?: undefined;
|
|
146
|
+
__isSuspense?: undefined;
|
|
147
|
+
} & import("vue").ComponentOptionsBase<Readonly<import("vue").ExtractPropTypes<{
|
|
50
148
|
name: {
|
|
51
149
|
type: StringConstructor;
|
|
52
150
|
required: true;
|
|
@@ -55,6 +153,9 @@ export declare const formFactory: <Schema extends AnyZodObject | ZodEffects<AnyZ
|
|
|
55
153
|
type: StringConstructor;
|
|
56
154
|
default: undefined;
|
|
57
155
|
};
|
|
156
|
+
}>> & {
|
|
157
|
+
onValid?: ((...args: any[]) => any) | undefined;
|
|
158
|
+
onInvalid?: ((...args: any[]) => any) | undefined;
|
|
58
159
|
}, {
|
|
59
160
|
formData: import("vue").Ref<Partial<import("zod").TypeOf<Schema>> | undefined> | undefined;
|
|
60
161
|
errors: Readonly<import("vue").Ref<DeepReadonly<import("zod").inferFormattedError<Schema_1, string>>>> | undefined;
|
|
@@ -63,21 +164,20 @@ export declare const formFactory: <Schema extends AnyZodObject | ZodEffects<AnyZ
|
|
|
63
164
|
fieldsErrors: import("vue").Ref<Map<string, Record<string, {
|
|
64
165
|
_errors: string[];
|
|
65
166
|
}>>>;
|
|
66
|
-
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("valid" | "invalid")[], "valid" | "invalid",
|
|
67
|
-
name: {
|
|
68
|
-
type: StringConstructor;
|
|
69
|
-
required: true;
|
|
70
|
-
};
|
|
71
|
-
tag: {
|
|
72
|
-
type: StringConstructor;
|
|
73
|
-
default: undefined;
|
|
74
|
-
};
|
|
75
|
-
}>> & {
|
|
76
|
-
onValid?: ((...args: any[]) => any) | undefined;
|
|
77
|
-
onInvalid?: ((...args: any[]) => any) | undefined;
|
|
78
|
-
}, {
|
|
167
|
+
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("valid" | "invalid")[], "valid" | "invalid", {
|
|
79
168
|
tag: string;
|
|
80
|
-
}
|
|
169
|
+
}, {}, string> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps & (new () => {
|
|
170
|
+
$slots: {
|
|
171
|
+
default: (_: {
|
|
172
|
+
invalid: boolean;
|
|
173
|
+
formData: unknown extends Partial<import("zod").TypeOf<Schema>> | undefined ? undefined : Partial<import("zod").TypeOf<Schema>> | undefined;
|
|
174
|
+
errors: Readonly<import("vue").Ref<import("vue").DeepReadonly<import("zod").inferFormattedError<Schema, string>>>>;
|
|
175
|
+
fieldsErrors: Map<string, Record<string, {
|
|
176
|
+
_errors: string[];
|
|
177
|
+
}>>;
|
|
178
|
+
}) => any;
|
|
179
|
+
};
|
|
180
|
+
});
|
|
81
181
|
VvFormField: import("vue").DefineComponent<{
|
|
82
182
|
type: {
|
|
83
183
|
type: import("vue").PropType<"number" | "text" | "email" | "password" | "tel" | "url" | "search" | "date" | "time" | "datetimeLocal" | "month" | "week" | "color" | "select" | "checkbox" | "radio" | "textarea" | "radioGroup" | "checkboxGroup" | "combobox" | "custom">;
|
|
@@ -208,7 +308,105 @@ export declare const useForm: <Schema extends AnyZodObject | ZodEffects<AnyZodOb
|
|
|
208
308
|
modelValue: Record<string, any>;
|
|
209
309
|
continuosValidation: boolean;
|
|
210
310
|
}>;
|
|
211
|
-
VvFormWrapper:
|
|
311
|
+
VvFormWrapper: {
|
|
312
|
+
new (...args: any[]): {
|
|
313
|
+
$: import("vue").ComponentInternalInstance;
|
|
314
|
+
$data: {};
|
|
315
|
+
$props: Partial<{
|
|
316
|
+
tag: string;
|
|
317
|
+
}> & Omit<Readonly<import("vue").ExtractPropTypes<{
|
|
318
|
+
name: {
|
|
319
|
+
type: StringConstructor;
|
|
320
|
+
required: true;
|
|
321
|
+
};
|
|
322
|
+
tag: {
|
|
323
|
+
type: StringConstructor;
|
|
324
|
+
default: undefined;
|
|
325
|
+
};
|
|
326
|
+
}>> & {
|
|
327
|
+
onValid?: ((...args: any[]) => any) | undefined;
|
|
328
|
+
onInvalid?: ((...args: any[]) => any) | undefined;
|
|
329
|
+
} & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, "tag">;
|
|
330
|
+
$attrs: {
|
|
331
|
+
[x: string]: unknown;
|
|
332
|
+
};
|
|
333
|
+
$refs: {
|
|
334
|
+
[x: string]: unknown;
|
|
335
|
+
};
|
|
336
|
+
$slots: Readonly<{
|
|
337
|
+
[name: string]: import("vue").Slot | undefined;
|
|
338
|
+
}>;
|
|
339
|
+
$root: import("vue").ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, import("vue").ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}, {}, string>, {}> | null;
|
|
340
|
+
$parent: import("vue").ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, import("vue").ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}, {}, string>, {}> | null;
|
|
341
|
+
$emit: (event: "valid" | "invalid", ...args: any[]) => void;
|
|
342
|
+
$el: any;
|
|
343
|
+
$options: import("vue").ComponentOptionsBase<Readonly<import("vue").ExtractPropTypes<{
|
|
344
|
+
name: {
|
|
345
|
+
type: StringConstructor;
|
|
346
|
+
required: true;
|
|
347
|
+
};
|
|
348
|
+
tag: {
|
|
349
|
+
type: StringConstructor;
|
|
350
|
+
default: undefined;
|
|
351
|
+
};
|
|
352
|
+
}>> & {
|
|
353
|
+
onValid?: ((...args: any[]) => any) | undefined;
|
|
354
|
+
onInvalid?: ((...args: any[]) => any) | undefined;
|
|
355
|
+
}, {
|
|
356
|
+
formData: import("vue").Ref<Partial<import("zod").TypeOf<Schema>> | undefined> | undefined;
|
|
357
|
+
errors: Readonly<import("vue").Ref<DeepReadonly<import("zod").inferFormattedError<Schema_1, string>>>> | undefined;
|
|
358
|
+
invalid: import("vue").ComputedRef<boolean>;
|
|
359
|
+
fields: import("vue").Ref<Set<string>>;
|
|
360
|
+
fieldsErrors: import("vue").Ref<Map<string, Record<string, {
|
|
361
|
+
_errors: string[];
|
|
362
|
+
}>>>;
|
|
363
|
+
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("valid" | "invalid")[], string, {
|
|
364
|
+
tag: string;
|
|
365
|
+
}, {}, string> & {
|
|
366
|
+
beforeCreate?: ((() => void) | (() => void)[]) | undefined;
|
|
367
|
+
created?: ((() => void) | (() => void)[]) | undefined;
|
|
368
|
+
beforeMount?: ((() => void) | (() => void)[]) | undefined;
|
|
369
|
+
mounted?: ((() => void) | (() => void)[]) | undefined;
|
|
370
|
+
beforeUpdate?: ((() => void) | (() => void)[]) | undefined;
|
|
371
|
+
updated?: ((() => void) | (() => void)[]) | undefined;
|
|
372
|
+
activated?: ((() => void) | (() => void)[]) | undefined;
|
|
373
|
+
deactivated?: ((() => void) | (() => void)[]) | undefined;
|
|
374
|
+
beforeDestroy?: ((() => void) | (() => void)[]) | undefined;
|
|
375
|
+
beforeUnmount?: ((() => void) | (() => void)[]) | undefined;
|
|
376
|
+
destroyed?: ((() => void) | (() => void)[]) | undefined;
|
|
377
|
+
unmounted?: ((() => void) | (() => void)[]) | undefined;
|
|
378
|
+
renderTracked?: (((e: import("vue").DebuggerEvent) => void) | ((e: import("vue").DebuggerEvent) => void)[]) | undefined;
|
|
379
|
+
renderTriggered?: (((e: import("vue").DebuggerEvent) => void) | ((e: import("vue").DebuggerEvent) => void)[]) | undefined;
|
|
380
|
+
errorCaptured?: (((err: unknown, instance: import("vue").ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, import("vue").ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}, {}, string>, {}> | null, info: string) => boolean | void) | ((err: unknown, instance: import("vue").ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, import("vue").ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}, {}, string>, {}> | null, info: string) => boolean | void)[]) | undefined;
|
|
381
|
+
};
|
|
382
|
+
$forceUpdate: () => void;
|
|
383
|
+
$nextTick: typeof import("vue").nextTick;
|
|
384
|
+
$watch<T extends string | ((...args: any) => any)>(source: T, cb: T extends (...args: any) => infer R ? (args_0: R, args_1: R) => any : (...args: any) => any, options?: import("vue").WatchOptions<boolean> | undefined): import("vue").WatchStopHandle;
|
|
385
|
+
} & Readonly<import("vue").ExtractPropTypes<{
|
|
386
|
+
name: {
|
|
387
|
+
type: StringConstructor;
|
|
388
|
+
required: true;
|
|
389
|
+
};
|
|
390
|
+
tag: {
|
|
391
|
+
type: StringConstructor;
|
|
392
|
+
default: undefined;
|
|
393
|
+
};
|
|
394
|
+
}>> & {
|
|
395
|
+
onValid?: ((...args: any[]) => any) | undefined;
|
|
396
|
+
onInvalid?: ((...args: any[]) => any) | undefined;
|
|
397
|
+
} & import("vue").ShallowUnwrapRef<{
|
|
398
|
+
formData: import("vue").Ref<Partial<import("zod").TypeOf<Schema>> | undefined> | undefined;
|
|
399
|
+
errors: Readonly<import("vue").Ref<DeepReadonly<import("zod").inferFormattedError<Schema_1, string>>>> | undefined;
|
|
400
|
+
invalid: import("vue").ComputedRef<boolean>;
|
|
401
|
+
fields: import("vue").Ref<Set<string>>;
|
|
402
|
+
fieldsErrors: import("vue").Ref<Map<string, Record<string, {
|
|
403
|
+
_errors: string[];
|
|
404
|
+
}>>>;
|
|
405
|
+
}> & {} & import("vue").ComponentCustomProperties & {};
|
|
406
|
+
__isFragment?: undefined;
|
|
407
|
+
__isTeleport?: undefined;
|
|
408
|
+
__isSuspense?: undefined;
|
|
409
|
+
} & import("vue").ComponentOptionsBase<Readonly<import("vue").ExtractPropTypes<{
|
|
212
410
|
name: {
|
|
213
411
|
type: StringConstructor;
|
|
214
412
|
required: true;
|
|
@@ -217,6 +415,9 @@ export declare const useForm: <Schema extends AnyZodObject | ZodEffects<AnyZodOb
|
|
|
217
415
|
type: StringConstructor;
|
|
218
416
|
default: undefined;
|
|
219
417
|
};
|
|
418
|
+
}>> & {
|
|
419
|
+
onValid?: ((...args: any[]) => any) | undefined;
|
|
420
|
+
onInvalid?: ((...args: any[]) => any) | undefined;
|
|
220
421
|
}, {
|
|
221
422
|
formData: import("vue").Ref<Partial<import("zod").TypeOf<Schema>> | undefined> | undefined;
|
|
222
423
|
errors: Readonly<import("vue").Ref<DeepReadonly<import("zod").inferFormattedError<Schema_1, string>>>> | undefined;
|
|
@@ -225,21 +426,20 @@ export declare const useForm: <Schema extends AnyZodObject | ZodEffects<AnyZodOb
|
|
|
225
426
|
fieldsErrors: import("vue").Ref<Map<string, Record<string, {
|
|
226
427
|
_errors: string[];
|
|
227
428
|
}>>>;
|
|
228
|
-
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("valid" | "invalid")[], "valid" | "invalid",
|
|
229
|
-
name: {
|
|
230
|
-
type: StringConstructor;
|
|
231
|
-
required: true;
|
|
232
|
-
};
|
|
233
|
-
tag: {
|
|
234
|
-
type: StringConstructor;
|
|
235
|
-
default: undefined;
|
|
236
|
-
};
|
|
237
|
-
}>> & {
|
|
238
|
-
onValid?: ((...args: any[]) => any) | undefined;
|
|
239
|
-
onInvalid?: ((...args: any[]) => any) | undefined;
|
|
240
|
-
}, {
|
|
429
|
+
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("valid" | "invalid")[], "valid" | "invalid", {
|
|
241
430
|
tag: string;
|
|
242
|
-
}
|
|
431
|
+
}, {}, string> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps & (new () => {
|
|
432
|
+
$slots: {
|
|
433
|
+
default: (_: {
|
|
434
|
+
invalid: boolean;
|
|
435
|
+
formData: unknown extends Partial<import("zod").TypeOf<Schema>> | undefined ? undefined : Partial<import("zod").TypeOf<Schema>> | undefined;
|
|
436
|
+
errors: Readonly<import("vue").Ref<import("vue").DeepReadonly<import("zod").inferFormattedError<Schema, string>>>>;
|
|
437
|
+
fieldsErrors: Map<string, Record<string, {
|
|
438
|
+
_errors: string[];
|
|
439
|
+
}>>;
|
|
440
|
+
}) => any;
|
|
441
|
+
};
|
|
442
|
+
});
|
|
243
443
|
VvFormField: import("vue").DefineComponent<{
|
|
244
444
|
type: {
|
|
245
445
|
type: import("vue").PropType<"number" | "text" | "email" | "password" | "tel" | "url" | "search" | "date" | "time" | "datetimeLocal" | "month" | "week" | "color" | "select" | "checkbox" | "radio" | "textarea" | "radioGroup" | "checkboxGroup" | "combobox" | "custom">;
|
package/dist/index.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineComponent as E, computed as
|
|
1
|
+
import { defineComponent as E, computed as b, onMounted as R, onBeforeUnmount as q, inject as S, toRefs as I, watch as y, provide as $, readonly as w, resolveComponent as p, defineAsyncComponent as H, h as x, ref as g, isProxy as Q, toRaw as X, withModifiers as Y } from "vue";
|
|
2
2
|
import { watchThrottled as D } from "@vueuse/core";
|
|
3
3
|
import { ZodObject as L, ZodDefault as T, ZodNullable as j, ZodSchema as F, ZodEffects as ee } from "zod";
|
|
4
4
|
function O(e) {
|
|
@@ -20,57 +20,57 @@ function k(e) {
|
|
|
20
20
|
return typeof e > "u";
|
|
21
21
|
}
|
|
22
22
|
const re = /^[0-9]+$/, ne = ["__proto__", "prototype", "constructor"];
|
|
23
|
-
function A(e, o,
|
|
24
|
-
const
|
|
23
|
+
function A(e, o, s) {
|
|
24
|
+
const u = te(s) ? s : void 0;
|
|
25
25
|
if (!W(e) || !_(o))
|
|
26
|
-
return
|
|
27
|
-
const
|
|
28
|
-
if (
|
|
29
|
-
for (const t of
|
|
26
|
+
return u;
|
|
27
|
+
const a = K(o);
|
|
28
|
+
if (a.length !== 0) {
|
|
29
|
+
for (const t of a) {
|
|
30
30
|
if (t === "*")
|
|
31
31
|
continue;
|
|
32
|
-
const
|
|
33
|
-
return
|
|
32
|
+
const r = function(c) {
|
|
33
|
+
return c.map((l) => k(l) || N(l) ? l : O(l) ? r(l) : l[t]);
|
|
34
34
|
};
|
|
35
|
-
if (O(e) && !re.test(t) ? e =
|
|
35
|
+
if (O(e) && !re.test(t) ? e = r(e) : e = e[t], k(e) || N(e))
|
|
36
36
|
break;
|
|
37
37
|
}
|
|
38
|
-
return k(e) ?
|
|
38
|
+
return k(e) ? u : e;
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
|
-
function B(e, o,
|
|
41
|
+
function B(e, o, s) {
|
|
42
42
|
if (!W(e) || !_(o))
|
|
43
43
|
return;
|
|
44
|
-
const
|
|
45
|
-
if (
|
|
44
|
+
const u = K(o);
|
|
45
|
+
if (u.length === 0)
|
|
46
46
|
return;
|
|
47
|
-
const
|
|
48
|
-
for (let t = 0; t <
|
|
49
|
-
const
|
|
50
|
-
if (t ===
|
|
51
|
-
e[
|
|
47
|
+
const a = u.length;
|
|
48
|
+
for (let t = 0; t < a; t++) {
|
|
49
|
+
const r = u[t];
|
|
50
|
+
if (t === a - 1) {
|
|
51
|
+
e[r] = s;
|
|
52
52
|
return;
|
|
53
53
|
}
|
|
54
|
-
if (
|
|
55
|
-
const
|
|
56
|
-
for (const
|
|
57
|
-
B(
|
|
54
|
+
if (r === "*" && O(e)) {
|
|
55
|
+
const c = u.slice(t + 1).join(".");
|
|
56
|
+
for (const l of e)
|
|
57
|
+
B(l, c, s);
|
|
58
58
|
return;
|
|
59
59
|
}
|
|
60
|
-
k(e[
|
|
60
|
+
k(e[r]) && (e[r] = {}), e = e[r];
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
function K(e) {
|
|
64
|
-
const o = e.split(/[.]|(?:\[(\d|\*)\])/).filter((
|
|
65
|
-
return o.some((
|
|
64
|
+
const o = e.split(/[.]|(?:\[(\d|\*)\])/).filter((s) => !!s);
|
|
65
|
+
return o.some((s) => ne.indexOf(s) !== -1) ? [] : o;
|
|
66
66
|
}
|
|
67
67
|
var i = /* @__PURE__ */ ((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 = "datetimeLocal", 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))(i || {});
|
|
68
|
-
const oe = (e, o,
|
|
68
|
+
const oe = (e, o, s, u = {}) => E({
|
|
69
69
|
name: "FieldComponent",
|
|
70
70
|
props: {
|
|
71
71
|
type: {
|
|
72
72
|
type: String,
|
|
73
|
-
validator: (
|
|
73
|
+
validator: (a) => Object.values(i).includes(a),
|
|
74
74
|
default: i.custom
|
|
75
75
|
},
|
|
76
76
|
is: {
|
|
@@ -96,61 +96,61 @@ const oe = (e, o, a, s = {}) => E({
|
|
|
96
96
|
},
|
|
97
97
|
emits: ["invalid", "valid", "update:formData", "update:modelValue"],
|
|
98
98
|
expose: ["invalid", "invalidLabel", "errors"],
|
|
99
|
-
setup(
|
|
100
|
-
const
|
|
99
|
+
setup(a, { slots: t, emit: r }) {
|
|
100
|
+
const c = b({
|
|
101
101
|
get() {
|
|
102
102
|
if (n != null && n.modelValue)
|
|
103
103
|
return A(
|
|
104
104
|
Object(n.modelValue.value),
|
|
105
|
-
String(
|
|
105
|
+
String(a.name)
|
|
106
106
|
);
|
|
107
107
|
},
|
|
108
108
|
set(f) {
|
|
109
109
|
n != null && n.modelValue && (B(
|
|
110
110
|
Object(n.modelValue.value),
|
|
111
|
-
String(
|
|
111
|
+
String(a.name),
|
|
112
112
|
f
|
|
113
|
-
),
|
|
114
|
-
newValue:
|
|
113
|
+
), r("update:modelValue", {
|
|
114
|
+
newValue: c.value,
|
|
115
115
|
formData: n == null ? void 0 : n.modelValue
|
|
116
116
|
}));
|
|
117
117
|
}
|
|
118
118
|
});
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
}),
|
|
119
|
+
R(() => {
|
|
120
|
+
c.value === void 0 && a.defaultValue !== void 0 && (c.value = a.defaultValue);
|
|
121
|
+
}), q(() => {
|
|
122
122
|
J(), U();
|
|
123
123
|
});
|
|
124
|
-
const
|
|
125
|
-
|
|
126
|
-
const n = S(e), { props:
|
|
124
|
+
const l = S(o, void 0);
|
|
125
|
+
l && l.fields.value.add(a.name);
|
|
126
|
+
const n = S(e), { props: m, name: v } = I(a), d = b(() => {
|
|
127
127
|
if (n != null && n.errors.value)
|
|
128
|
-
return A(n.errors.value, String(
|
|
129
|
-
}),
|
|
128
|
+
return A(n.errors.value, String(a.name));
|
|
129
|
+
}), h = b(() => {
|
|
130
130
|
var f;
|
|
131
131
|
return (f = d.value) == null ? void 0 : f._errors;
|
|
132
|
-
}),
|
|
133
|
-
|
|
134
|
-
|
|
132
|
+
}), V = b(() => d.value !== void 0), J = y(V, () => {
|
|
133
|
+
V.value ? (r("invalid", h.value), l && l.errors.value.set(
|
|
134
|
+
a.name,
|
|
135
135
|
{
|
|
136
|
-
_errors:
|
|
136
|
+
_errors: h.value
|
|
137
137
|
}
|
|
138
|
-
)) : (
|
|
139
|
-
|
|
138
|
+
)) : (r("valid", c.value), l && l.errors.value.delete(
|
|
139
|
+
a.name
|
|
140
140
|
));
|
|
141
141
|
}), U = y(
|
|
142
142
|
() => n == null ? void 0 : n.modelValue,
|
|
143
143
|
() => {
|
|
144
|
-
|
|
144
|
+
r("update:formData", n == null ? void 0 : n.modelValue);
|
|
145
145
|
},
|
|
146
146
|
{ deep: !0 }
|
|
147
147
|
), G = (f) => {
|
|
148
|
-
|
|
149
|
-
}, C =
|
|
148
|
+
c.value = f;
|
|
149
|
+
}, C = b(() => typeof m.value == "function" ? m.value(n == null ? void 0 : n.modelValue) : m.value), z = b(() => ({
|
|
150
150
|
...C.value,
|
|
151
|
-
name: C.value.name ??
|
|
152
|
-
invalid:
|
|
153
|
-
valid:
|
|
151
|
+
name: C.value.name ?? a.name,
|
|
152
|
+
invalid: V.value,
|
|
153
|
+
valid: a.showValid ? !!(!V.value && c.value) : void 0,
|
|
154
154
|
type: ((f) => {
|
|
155
155
|
if ([
|
|
156
156
|
i.text,
|
|
@@ -168,57 +168,57 @@ const oe = (e, o, a, s = {}) => E({
|
|
|
168
168
|
i.color
|
|
169
169
|
].includes(f))
|
|
170
170
|
return f;
|
|
171
|
-
})(
|
|
172
|
-
invalidLabel:
|
|
173
|
-
modelValue:
|
|
174
|
-
errors:
|
|
171
|
+
})(a.type),
|
|
172
|
+
invalidLabel: h.value,
|
|
173
|
+
modelValue: c.value,
|
|
174
|
+
errors: a.is ? d.value : void 0,
|
|
175
175
|
"onUpdate:modelValue": G
|
|
176
176
|
}));
|
|
177
|
-
return $(
|
|
178
|
-
name: w(
|
|
177
|
+
return $(s, {
|
|
178
|
+
name: w(v),
|
|
179
179
|
errors: w(d)
|
|
180
|
-
}), { component:
|
|
181
|
-
if (
|
|
180
|
+
}), { component: b(() => {
|
|
181
|
+
if (a.type === i.custom)
|
|
182
182
|
return {
|
|
183
183
|
render() {
|
|
184
184
|
var f;
|
|
185
185
|
return ((f = t.default) == null ? void 0 : f.call(t, {
|
|
186
|
-
modelValue:
|
|
186
|
+
modelValue: c.value,
|
|
187
187
|
onUpdate: G,
|
|
188
|
-
invalid:
|
|
189
|
-
invalidLabel:
|
|
188
|
+
invalid: V.value,
|
|
189
|
+
invalidLabel: h.value,
|
|
190
190
|
formData: n == null ? void 0 : n.modelValue.value,
|
|
191
191
|
formErrors: n == null ? void 0 : n.errors.value,
|
|
192
192
|
errors: d.value
|
|
193
193
|
})) ?? t.defalut;
|
|
194
194
|
}
|
|
195
195
|
};
|
|
196
|
-
if (!
|
|
196
|
+
if (!u.lazyLoad) {
|
|
197
197
|
let f;
|
|
198
|
-
switch (
|
|
198
|
+
switch (a.type) {
|
|
199
199
|
case i.select:
|
|
200
|
-
f =
|
|
200
|
+
f = p("VvSelect");
|
|
201
201
|
break;
|
|
202
202
|
case i.checkbox:
|
|
203
|
-
f =
|
|
203
|
+
f = p("VvCheckbox");
|
|
204
204
|
break;
|
|
205
205
|
case i.radio:
|
|
206
|
-
f =
|
|
206
|
+
f = p("VvRadio");
|
|
207
207
|
break;
|
|
208
208
|
case i.textarea:
|
|
209
|
-
f =
|
|
209
|
+
f = p("VvTextarea");
|
|
210
210
|
break;
|
|
211
211
|
case i.radioGroup:
|
|
212
|
-
f =
|
|
212
|
+
f = p("VvRadioGroup");
|
|
213
213
|
break;
|
|
214
214
|
case i.checkboxGroup:
|
|
215
|
-
f =
|
|
215
|
+
f = p("VvCheckboxGroup");
|
|
216
216
|
break;
|
|
217
217
|
case i.combobox:
|
|
218
|
-
f =
|
|
218
|
+
f = p("VvCombobox");
|
|
219
219
|
break;
|
|
220
220
|
default:
|
|
221
|
-
f =
|
|
221
|
+
f = p("VvInputText");
|
|
222
222
|
}
|
|
223
223
|
if (typeof f != "string")
|
|
224
224
|
return f;
|
|
@@ -227,7 +227,7 @@ const oe = (e, o, a, s = {}) => E({
|
|
|
227
227
|
);
|
|
228
228
|
}
|
|
229
229
|
return H(async () => {
|
|
230
|
-
switch (
|
|
230
|
+
switch (u.sideEffects && await Promise.resolve(u.sideEffects(a.type)), a.type) {
|
|
231
231
|
case i.textarea:
|
|
232
232
|
return import("@volverjs/ui-vue/vv-textarea");
|
|
233
233
|
case i.radio:
|
|
@@ -243,46 +243,46 @@ const oe = (e, o, a, s = {}) => E({
|
|
|
243
243
|
}
|
|
244
244
|
return import("@volverjs/ui-vue/vv-input-text");
|
|
245
245
|
});
|
|
246
|
-
}), hasProps: z, invalid:
|
|
246
|
+
}), hasProps: z, invalid: V };
|
|
247
247
|
},
|
|
248
248
|
render() {
|
|
249
249
|
return this.is ? x(this.is, this.hasProps, this.$slots) : this.type === i.custom ? x(this.component, null, this.$slots) : x(this.component, this.hasProps, this.$slots);
|
|
250
250
|
}
|
|
251
251
|
}), M = (e, o = {}) => {
|
|
252
|
-
const
|
|
253
|
-
let
|
|
254
|
-
for (;
|
|
255
|
-
|
|
256
|
-
return
|
|
257
|
-
},
|
|
252
|
+
const s = (t) => {
|
|
253
|
+
let r = t;
|
|
254
|
+
for (; r instanceof ee; )
|
|
255
|
+
r = r.innerType();
|
|
256
|
+
return r;
|
|
257
|
+
}, u = s(e);
|
|
258
258
|
return {
|
|
259
|
-
...(
|
|
259
|
+
...(u instanceof L ? u._def.unknownKeys === "passthrough" : !1) ? o : {},
|
|
260
260
|
...Object.fromEntries(
|
|
261
|
-
Object.entries(
|
|
262
|
-
const
|
|
261
|
+
Object.entries(u.shape).map(([t, r]) => {
|
|
262
|
+
const c = o[t], l = s(r);
|
|
263
263
|
let n;
|
|
264
|
-
if (
|
|
265
|
-
return [t,
|
|
266
|
-
if (
|
|
267
|
-
const
|
|
268
|
-
if (
|
|
269
|
-
return [t,
|
|
264
|
+
if (l instanceof T && (n = l._def.defaultValue()), c === null && l instanceof j)
|
|
265
|
+
return [t, c];
|
|
266
|
+
if (l instanceof F) {
|
|
267
|
+
const m = l.safeParse(o[t]);
|
|
268
|
+
if (m.success)
|
|
269
|
+
return [t, m.data ?? n];
|
|
270
270
|
}
|
|
271
|
-
return
|
|
271
|
+
return l instanceof L ? [
|
|
272
272
|
t,
|
|
273
273
|
M(
|
|
274
|
-
|
|
275
|
-
|
|
274
|
+
l,
|
|
275
|
+
c && typeof c == "object" ? c : {}
|
|
276
276
|
)
|
|
277
277
|
] : [t, n];
|
|
278
278
|
})
|
|
279
279
|
)
|
|
280
280
|
};
|
|
281
|
-
}, ae = (e, o,
|
|
282
|
-
const
|
|
281
|
+
}, ae = (e, o, s) => {
|
|
282
|
+
const u = g(), a = g(), t = g();
|
|
283
283
|
return {
|
|
284
|
-
errors:
|
|
285
|
-
status:
|
|
284
|
+
errors: u,
|
|
285
|
+
status: a,
|
|
286
286
|
formData: t,
|
|
287
287
|
component: E({
|
|
288
288
|
name: "FormComponent",
|
|
@@ -298,37 +298,37 @@ const oe = (e, o, a, s = {}) => E({
|
|
|
298
298
|
},
|
|
299
299
|
emits: ["invalid", "valid", "submit", "update:modelValue"],
|
|
300
300
|
expose: ["submit", "errors", "status"],
|
|
301
|
-
setup(
|
|
301
|
+
setup(r, { emit: c }) {
|
|
302
302
|
t.value = M(
|
|
303
303
|
e,
|
|
304
|
-
|
|
304
|
+
r.modelValue
|
|
305
305
|
);
|
|
306
|
-
const
|
|
306
|
+
const l = (s == null ? void 0 : s.continuosValidation) || r.continuosValidation;
|
|
307
307
|
y(
|
|
308
|
-
() =>
|
|
309
|
-
(
|
|
310
|
-
if (
|
|
311
|
-
const d = Q(
|
|
308
|
+
() => r.modelValue,
|
|
309
|
+
(v) => {
|
|
310
|
+
if (v) {
|
|
311
|
+
const d = Q(v) ? X(v) : v;
|
|
312
312
|
t.value = typeof (d == null ? void 0 : d.clone) == "function" ? d.clone() : JSON.parse(JSON.stringify(d));
|
|
313
313
|
}
|
|
314
314
|
},
|
|
315
315
|
{ deep: !0 }
|
|
316
316
|
), D(
|
|
317
317
|
t,
|
|
318
|
-
(
|
|
319
|
-
(
|
|
318
|
+
(v) => {
|
|
319
|
+
(u.value || l) && n(), (!v || !r.modelValue || JSON.stringify(v) !== JSON.stringify(r.modelValue)) && c("update:modelValue", v);
|
|
320
320
|
},
|
|
321
|
-
{ deep: !0, throttle: (
|
|
321
|
+
{ deep: !0, throttle: (s == null ? void 0 : s.updateThrottle) ?? 500 }
|
|
322
322
|
);
|
|
323
|
-
const n = (
|
|
324
|
-
const d = e.safeParse(
|
|
325
|
-
return d.success ? (
|
|
326
|
-
},
|
|
323
|
+
const n = (v = t.value) => {
|
|
324
|
+
const d = e.safeParse(v);
|
|
325
|
+
return d.success ? (u.value = void 0, a.value = "valid", t.value = d.data, c("update:modelValue", t.value), c("valid", d.data), !0) : (u.value = d.error.format(), a.value = "invalid", c("invalid", u.value), !1);
|
|
326
|
+
}, m = () => n() ? (c("submit", t.value), !0) : !1;
|
|
327
327
|
return $(o, {
|
|
328
328
|
modelValue: t,
|
|
329
|
-
submit:
|
|
330
|
-
errors: w(
|
|
331
|
-
}), { submit:
|
|
329
|
+
submit: m,
|
|
330
|
+
errors: w(u)
|
|
331
|
+
}), { submit: m };
|
|
332
332
|
},
|
|
333
333
|
render() {
|
|
334
334
|
return x(
|
|
@@ -355,55 +355,55 @@ const oe = (e, o, a, s = {}) => E({
|
|
|
355
355
|
},
|
|
356
356
|
emits: ["invalid", "valid"],
|
|
357
357
|
expose: ["fields", "invalid"],
|
|
358
|
-
setup(
|
|
359
|
-
const
|
|
358
|
+
setup(u, { emit: a }) {
|
|
359
|
+
const t = S(e), r = S(o, void 0), c = g(/* @__PURE__ */ new Set()), l = g(/* @__PURE__ */ new Map()), { name: n } = I(u);
|
|
360
360
|
$(o, {
|
|
361
|
-
name: w(
|
|
362
|
-
errors:
|
|
363
|
-
fields:
|
|
361
|
+
name: w(n),
|
|
362
|
+
errors: l,
|
|
363
|
+
fields: c
|
|
364
364
|
}), y(
|
|
365
|
-
|
|
365
|
+
c,
|
|
366
366
|
(v) => {
|
|
367
|
-
|
|
368
|
-
|
|
367
|
+
r != null && r.fields && v.forEach((d) => {
|
|
368
|
+
r == null || r.fields.value.add(d);
|
|
369
369
|
});
|
|
370
370
|
},
|
|
371
371
|
{ deep: !0 }
|
|
372
372
|
), y(
|
|
373
|
-
() => new Map(
|
|
374
|
-
(v,
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
}), Array.from(v.keys()).forEach((
|
|
378
|
-
const
|
|
379
|
-
|
|
373
|
+
() => new Map(l.value),
|
|
374
|
+
(v, d) => {
|
|
375
|
+
r != null && r.errors && (Array.from(d.keys()).forEach((h) => {
|
|
376
|
+
r.errors.value.delete(h);
|
|
377
|
+
}), Array.from(v.keys()).forEach((h) => {
|
|
378
|
+
const V = v.get(h);
|
|
379
|
+
V && r.errors.value.set(h, V);
|
|
380
380
|
}));
|
|
381
381
|
},
|
|
382
382
|
{ deep: !0 }
|
|
383
383
|
);
|
|
384
|
-
const
|
|
385
|
-
return y(
|
|
386
|
-
|
|
384
|
+
const m = b(() => t != null && t.errors.value ? l.value.size > 0 : !1);
|
|
385
|
+
return y(m, () => {
|
|
386
|
+
m.value ? a("invalid") : a("valid");
|
|
387
387
|
}), {
|
|
388
|
-
formData:
|
|
389
|
-
errors:
|
|
390
|
-
invalid:
|
|
391
|
-
fields:
|
|
392
|
-
fieldsErrors:
|
|
388
|
+
formData: t == null ? void 0 : t.modelValue,
|
|
389
|
+
errors: t == null ? void 0 : t.errors,
|
|
390
|
+
invalid: m,
|
|
391
|
+
fields: c,
|
|
392
|
+
fieldsErrors: l
|
|
393
393
|
};
|
|
394
394
|
},
|
|
395
395
|
render() {
|
|
396
|
-
var a,
|
|
396
|
+
var u, a, t, r;
|
|
397
397
|
return this.tag ? x(
|
|
398
398
|
this.tag,
|
|
399
399
|
null,
|
|
400
|
-
((
|
|
400
|
+
((a = (u = this.$slots).default) == null ? void 0 : a.call(u, {
|
|
401
401
|
invalid: this.invalid,
|
|
402
402
|
formData: this.formData,
|
|
403
403
|
errors: this.errors,
|
|
404
404
|
fieldsErrors: this.fieldsErrors
|
|
405
405
|
})) ?? this.$slots.defalut
|
|
406
|
-
) : ((
|
|
406
|
+
) : ((r = (t = this.$slots).default) == null ? void 0 : r.call(t, {
|
|
407
407
|
invalid: this.invalid,
|
|
408
408
|
formData: this.formData,
|
|
409
409
|
errors: this.errors,
|
|
@@ -411,42 +411,42 @@ const oe = (e, o, a, s = {}) => E({
|
|
|
411
411
|
})) ?? this.$slots.defalut;
|
|
412
412
|
}
|
|
413
413
|
}), P = (e, o = {}) => {
|
|
414
|
-
const
|
|
414
|
+
const s = Symbol(), u = Symbol(), a = Symbol(), {
|
|
415
415
|
component: t,
|
|
416
|
-
errors:
|
|
417
|
-
status:
|
|
418
|
-
formData:
|
|
419
|
-
} = ae(e,
|
|
420
|
-
a,
|
|
421
|
-
s
|
|
422
|
-
), v = oe(
|
|
423
|
-
a,
|
|
416
|
+
errors: r,
|
|
417
|
+
status: c,
|
|
418
|
+
formData: l
|
|
419
|
+
} = ae(e, s, o), n = se(
|
|
424
420
|
s,
|
|
425
|
-
|
|
421
|
+
u
|
|
422
|
+
), m = oe(
|
|
423
|
+
s,
|
|
424
|
+
u,
|
|
425
|
+
a,
|
|
426
426
|
o
|
|
427
427
|
);
|
|
428
428
|
return {
|
|
429
429
|
VvForm: t,
|
|
430
430
|
VvFormWrapper: n,
|
|
431
|
-
VvFormField:
|
|
432
|
-
formInjectionKey:
|
|
433
|
-
formWrapperInjectionKey:
|
|
434
|
-
formFieldInjectionKey:
|
|
435
|
-
errors:
|
|
436
|
-
status:
|
|
437
|
-
formData:
|
|
431
|
+
VvFormField: m,
|
|
432
|
+
formInjectionKey: s,
|
|
433
|
+
formWrapperInjectionKey: u,
|
|
434
|
+
formFieldInjectionKey: a,
|
|
435
|
+
errors: r,
|
|
436
|
+
status: c,
|
|
437
|
+
formData: l
|
|
438
438
|
};
|
|
439
439
|
}, Z = Symbol(), fe = (e) => {
|
|
440
440
|
let o = {};
|
|
441
441
|
return e.schema && (o = P(e.schema, e)), {
|
|
442
442
|
...o,
|
|
443
|
-
install(
|
|
444
|
-
|
|
443
|
+
install(s, { global: u = !1 } = {}) {
|
|
444
|
+
s.provide(Z, e), u && (s.config.globalProperties.$vvForm = e, o != null && o.VvForm && s.component("VvForm", o.VvForm), o != null && o.VvFormWrapper && s.component("VvFormWrapper", o.VvFormWrapper), o != null && o.VvFormField && s.component("VvFormField", o.VvFormField));
|
|
445
445
|
}
|
|
446
446
|
};
|
|
447
447
|
}, de = (e, o = {}) => {
|
|
448
|
-
const
|
|
449
|
-
return P(e,
|
|
448
|
+
const s = { ...S(Z, {}), ...o };
|
|
449
|
+
return P(e, s);
|
|
450
450
|
};
|
|
451
451
|
export {
|
|
452
452
|
i as FormFieldType,
|
package/dist/index.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(p,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("vue"),require("@vueuse/core"),require("zod")):typeof define=="function"&&define.amd?define(["exports","vue","@vueuse/core","zod"],t):(p=typeof globalThis<"u"?globalThis:p||self,t(p["@volverjs/form-vue"]={},p.Vue,p.VueUseCore,p.zod))})(this,function(p,t,A,
|
|
1
|
+
(function(p,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("vue"),require("@vueuse/core"),require("zod")):typeof define=="function"&&define.amd?define(["exports","vue","@vueuse/core","zod"],t):(p=typeof globalThis<"u"?globalThis:p||self,t(p["@volverjs/form-vue"]={},p.Vue,p.VueUseCore,p.zod))})(this,function(p,t,A,y){"use strict";function x(e){return Array.isArray(e)}function B(e){return typeof e<"u"}function O(e){return e===null}function C(e){return typeof e=="object"}function E(e){return typeof e=="string"}function g(e){return typeof e>"u"}const W=/^[0-9]+$/,_=["__proto__","prototype","constructor"];function $(e,a,l){const i=B(l)?l:void 0;if(!C(e)||!E(a))return i;const s=I(a);if(s.length!==0){for(const r of s){if(r==="*")continue;const n=function(f){return f.map(c=>g(c)||O(c)?c:x(c)?n(c):c[r])};if(x(e)&&!W.test(r)?e=n(e):e=e[r],g(e)||O(e))break}return g(e)?i:e}}function G(e,a,l){if(!C(e)||!E(a))return;const i=I(a);if(i.length===0)return;const s=i.length;for(let r=0;r<s;r++){const n=i[r];if(r===s-1){e[n]=l;return}if(n==="*"&&x(e)){const f=i.slice(r+1).join(".");for(const c of e)G(c,f,l);return}g(e[n])&&(e[n]={}),e=e[n]}}function I(e){const a=e.split(/[.]|(?:\[(\d|\*)\])/).filter(l=>!!l);return a.some(l=>_.indexOf(l)!==-1)?[]:a}var u=(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="datetimeLocal",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))(u||{});const K=(e,a,l,i={})=>t.defineComponent({name:"FieldComponent",props:{type:{type:String,validator:s=>Object.values(u).includes(s),default:u.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}},emits:["invalid","valid","update:formData","update:modelValue"],expose:["invalid","invalidLabel","errors"],setup(s,{slots:r,emit:n}){const f=t.computed({get(){if(o!=null&&o.modelValue)return $(Object(o.modelValue.value),String(s.name))},set(d){o!=null&&o.modelValue&&(G(Object(o.modelValue.value),String(s.name),d),n("update:modelValue",{newValue:f.value,formData:o==null?void 0:o.modelValue}))}});t.onMounted(()=>{f.value===void 0&&s.defaultValue!==void 0&&(f.value=s.defaultValue)}),t.onBeforeUnmount(()=>{U(),J()});const c=t.inject(a,void 0);c&&c.fields.value.add(s.name);const o=t.inject(e),{props:v,name:h}=t.toRefs(s),m=t.computed(()=>{if(o!=null&&o.errors.value)return $(o.errors.value,String(s.name))}),V=t.computed(()=>{var d;return(d=m.value)==null?void 0:d._errors}),b=t.computed(()=>m.value!==void 0),U=t.watch(b,()=>{b.value?(n("invalid",V.value),c&&c.errors.value.set(s.name,{_errors:V.value})):(n("valid",f.value),c&&c.errors.value.delete(s.name))}),J=t.watch(()=>o==null?void 0:o.modelValue,()=>{n("update:formData",o==null?void 0:o.modelValue)},{deep:!0}),L=d=>{f.value=d},N=t.computed(()=>typeof v.value=="function"?v.value(o==null?void 0:o.modelValue):v.value),R=t.computed(()=>({...N.value,name:N.value.name??s.name,invalid:b.value,valid:s.showValid?!!(!b.value&&f.value):void 0,type:(d=>{if([u.text,u.number,u.email,u.password,u.tel,u.url,u.search,u.date,u.time,u.datetimeLocal,u.month,u.week,u.color].includes(d))return d})(s.type),invalidLabel:V.value,modelValue:f.value,errors:s.is?m.value:void 0,"onUpdate:modelValue":L}));return t.provide(l,{name:t.readonly(h),errors:t.readonly(m)}),{component:t.computed(()=>{if(s.type===u.custom)return{render(){var d;return((d=r.default)==null?void 0:d.call(r,{modelValue:f.value,onUpdate:L,invalid:b.value,invalidLabel:V.value,formData:o==null?void 0:o.modelValue.value,formErrors:o==null?void 0:o.errors.value,errors:m.value}))??r.defalut}};if(!i.lazyLoad){let d;switch(s.type){case u.select:d=t.resolveComponent("VvSelect");break;case u.checkbox:d=t.resolveComponent("VvCheckbox");break;case u.radio:d=t.resolveComponent("VvRadio");break;case u.textarea:d=t.resolveComponent("VvTextarea");break;case u.radioGroup:d=t.resolveComponent("VvRadioGroup");break;case u.checkboxGroup:d=t.resolveComponent("VvCheckboxGroup");break;case u.combobox:d=t.resolveComponent("VvCombobox");break;default:d=t.resolveComponent("VvInputText")}if(typeof d!="string")return d;console.warn(`[form-vue warn]: ${d} not found, the component will be loaded asynchronously. To avoid this warning, please set "lazyLoad" option.`)}return t.defineAsyncComponent(async()=>{switch(i.sideEffects&&await Promise.resolve(i.sideEffects(s.type)),s.type){case u.textarea:return import("@volverjs/ui-vue/vv-textarea");case u.radio:return import("@volverjs/ui-vue/vv-radio");case u.radioGroup:return import("@volverjs/ui-vue/vv-radio-group");case u.checkbox:return import("@volverjs/ui-vue/vv-checkbox");case u.checkboxGroup:return import("@volverjs/ui-vue/vv-checkbox-group");case u.combobox:return import("@volverjs/ui-vue/vv-combobox")}return import("@volverjs/ui-vue/vv-input-text")})}),hasProps:R,invalid:b}},render(){return this.is?t.h(this.is,this.hasProps,this.$slots):this.type===u.custom?t.h(this.component,null,this.$slots):t.h(this.component,this.hasProps,this.$slots)}}),S=(e,a={})=>{const l=r=>{let n=r;for(;n instanceof y.ZodEffects;)n=n.innerType();return n},i=l(e);return{...(i instanceof y.ZodObject?i._def.unknownKeys==="passthrough":!1)?a:{},...Object.fromEntries(Object.entries(i.shape).map(([r,n])=>{const f=a[r],c=l(n);let o;if(c instanceof y.ZodDefault&&(o=c._def.defaultValue()),f===null&&c instanceof y.ZodNullable)return[r,f];if(c instanceof y.ZodSchema){const v=c.safeParse(a[r]);if(v.success)return[r,v.data??o]}return c instanceof y.ZodObject?[r,S(c,f&&typeof f=="object"?f:{})]:[r,o]}))}},M=(e,a,l)=>{const i=t.ref(),s=t.ref(),r=t.ref();return{errors:i,status:s,formData:r,component:t.defineComponent({name:"FormComponent",props:{modelValue:{type:Object,default:()=>({})},continuosValidation:{type:Boolean,default:!1}},emits:["invalid","valid","submit","update:modelValue"],expose:["submit","errors","status"],setup(n,{emit:f}){r.value=S(e,n.modelValue);const c=(l==null?void 0:l.continuosValidation)||n.continuosValidation;t.watch(()=>n.modelValue,h=>{if(h){const m=t.isProxy(h)?t.toRaw(h):h;r.value=typeof(m==null?void 0:m.clone)=="function"?m.clone():JSON.parse(JSON.stringify(m))}},{deep:!0}),A.watchThrottled(r,h=>{(i.value||c)&&o(),(!h||!n.modelValue||JSON.stringify(h)!==JSON.stringify(n.modelValue))&&f("update:modelValue",h)},{deep:!0,throttle:(l==null?void 0:l.updateThrottle)??500});const o=(h=r.value)=>{const m=e.safeParse(h);return m.success?(i.value=void 0,s.value="valid",r.value=m.data,f("update:modelValue",r.value),f("valid",m.data),!0):(i.value=m.error.format(),s.value="invalid",f("invalid",i.value),!1)},v=()=>o()?(f("submit",r.value),!0):!1;return t.provide(a,{modelValue:r,submit:v,errors:t.readonly(i)}),{submit:v}},render(){return t.h("form",{onSubmit:t.withModifiers(this.submit,["prevent"])},this.$slots)}})}},P=(e,a)=>t.defineComponent({name:"WrapperComponent",props:{name:{type:String,required:!0},tag:{type:String,default:void 0}},emits:["invalid","valid"],expose:["fields","invalid"],setup(i,{emit:s}){const r=t.inject(e),n=t.inject(a,void 0),f=t.ref(new Set),c=t.ref(new Map),{name:o}=t.toRefs(i);t.provide(a,{name:t.readonly(o),errors:c,fields:f}),t.watch(f,h=>{n!=null&&n.fields&&h.forEach(m=>{n==null||n.fields.value.add(m)})},{deep:!0}),t.watch(()=>new Map(c.value),(h,m)=>{n!=null&&n.errors&&(Array.from(m.keys()).forEach(V=>{n.errors.value.delete(V)}),Array.from(h.keys()).forEach(V=>{const b=h.get(V);b&&n.errors.value.set(V,b)}))},{deep:!0});const v=t.computed(()=>r!=null&&r.errors.value?c.value.size>0:!1);return t.watch(v,()=>{v.value?s("invalid"):s("valid")}),{formData:r==null?void 0:r.modelValue,errors:r==null?void 0:r.errors,invalid:v,fields:f,fieldsErrors:c}},render(){var i,s,r,n;return this.tag?t.h(this.tag,null,((s=(i=this.$slots).default)==null?void 0:s.call(i,{invalid:this.invalid,formData:this.formData,errors:this.errors,fieldsErrors:this.fieldsErrors}))??this.$slots.defalut):((n=(r=this.$slots).default)==null?void 0:n.call(r,{invalid:this.invalid,formData:this.formData,errors:this.errors,fieldsErrors:this.fieldsErrors}))??this.$slots.defalut}}),k=(e,a={})=>{const l=Symbol(),i=Symbol(),s=Symbol(),{component:r,errors:n,status:f,formData:c}=M(e,l,a),o=P(l,i),v=K(l,i,s,a);return{VvForm:r,VvFormWrapper:o,VvFormField:v,formInjectionKey:l,formWrapperInjectionKey:i,formFieldInjectionKey:s,errors:n,status:f,formData:c}},w=Symbol(),Z=e=>{let a={};return e.schema&&(a=k(e.schema,e)),{...a,install(l,{global:i=!1}={}){l.provide(w,e),i&&(l.config.globalProperties.$vvForm=e,a!=null&&a.VvForm&&l.component("VvForm",a.VvForm),a!=null&&a.VvFormWrapper&&l.component("VvFormWrapper",a.VvFormWrapper),a!=null&&a.VvFormField&&l.component("VvFormField",a.VvFormField))}}},q=(e,a={})=>{const l={...t.inject(w,{}),...a};return k(e,l)};p.FormFieldType=u,p.createForm=Z,p.defaultObjectBySchema=S,p.formFactory=k,p.pluginInjectionKey=w,p.useForm=q,Object.defineProperty(p,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"bugs": {
|
|
20
20
|
"url": "https://github.com/volverjs/form-vue/issues"
|
|
21
21
|
},
|
|
22
|
-
"version": "0.0.10-beta.
|
|
22
|
+
"version": "0.0.10-beta.5",
|
|
23
23
|
"engines": {
|
|
24
24
|
"node": ">= 16.x"
|
|
25
25
|
},
|
|
@@ -44,8 +44,8 @@
|
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@playwright/experimental-ct-vue": "^1.32.3",
|
|
46
46
|
"@testing-library/vue": "^7.0.0",
|
|
47
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
48
|
-
"@typescript-eslint/parser": "^5.
|
|
47
|
+
"@typescript-eslint/eslint-plugin": "^5.59.0",
|
|
48
|
+
"@typescript-eslint/parser": "^5.59.0",
|
|
49
49
|
"@vitejs/plugin-vue": "^4.1.0",
|
|
50
50
|
"@volverjs/style": "^0.1.8",
|
|
51
51
|
"@vue/compiler-sfc": "^3.2.47",
|
|
@@ -55,14 +55,14 @@
|
|
|
55
55
|
"eslint": "^8.38.0",
|
|
56
56
|
"eslint-config-prettier": "^8.8.0",
|
|
57
57
|
"eslint-plugin-prettier": "^4.2.1",
|
|
58
|
-
"happy-dom": "^9.
|
|
58
|
+
"happy-dom": "^9.9.2",
|
|
59
59
|
"prettier": "^2.8.7",
|
|
60
60
|
"typescript": "^5.0.4",
|
|
61
|
-
"vite": "^4.
|
|
61
|
+
"vite": "^4.3.1",
|
|
62
62
|
"vite-plugin-eslint": "^1.8.1",
|
|
63
63
|
"vite-plugin-externalize-deps": "^0.5.0",
|
|
64
64
|
"vitest": "^0.30.1",
|
|
65
|
-
"vue-tsc": "^1.2
|
|
65
|
+
"vue-tsc": "^1.4.2"
|
|
66
66
|
},
|
|
67
67
|
"typesVersions": {
|
|
68
68
|
"*": {
|
package/src/VvFormWrapper.ts
CHANGED
|
@@ -10,8 +10,9 @@ import {
|
|
|
10
10
|
toRefs,
|
|
11
11
|
watch,
|
|
12
12
|
h,
|
|
13
|
+
type DeepReadonly,
|
|
13
14
|
} from 'vue'
|
|
14
|
-
import type { AnyZodObject, ZodEffects } from 'zod'
|
|
15
|
+
import type { AnyZodObject, TypeOf, ZodEffects, z } from 'zod'
|
|
15
16
|
import type { InjectedFormData, InjectedFormWrapperData } from './types'
|
|
16
17
|
|
|
17
18
|
export const defineFormWrapper = <
|
|
@@ -23,7 +24,7 @@ export const defineFormWrapper = <
|
|
|
23
24
|
formProvideKey: InjectionKey<InjectedFormData<Schema>>,
|
|
24
25
|
wrapperProvideKey: InjectionKey<InjectedFormWrapperData<Schema>>,
|
|
25
26
|
) => {
|
|
26
|
-
|
|
27
|
+
const toReturn = defineComponent({
|
|
27
28
|
name: 'WrapperComponent',
|
|
28
29
|
props: {
|
|
29
30
|
name: {
|
|
@@ -131,4 +132,34 @@ export const defineFormWrapper = <
|
|
|
131
132
|
)
|
|
132
133
|
},
|
|
133
134
|
})
|
|
135
|
+
/**
|
|
136
|
+
* An hack to add types to the slots
|
|
137
|
+
*/
|
|
138
|
+
return toReturn as typeof toReturn & {
|
|
139
|
+
new (): {
|
|
140
|
+
$slots: {
|
|
141
|
+
default: (_: {
|
|
142
|
+
invalid: boolean
|
|
143
|
+
formData: unknown extends
|
|
144
|
+
| Partial<TypeOf<Schema>>
|
|
145
|
+
| undefined
|
|
146
|
+
? undefined
|
|
147
|
+
: Partial<TypeOf<Schema>> | undefined
|
|
148
|
+
errors: Readonly<
|
|
149
|
+
Ref<DeepReadonly<z.inferFormattedError<Schema>>>
|
|
150
|
+
>
|
|
151
|
+
fieldsErrors: Map<
|
|
152
|
+
string,
|
|
153
|
+
Record<
|
|
154
|
+
string,
|
|
155
|
+
{
|
|
156
|
+
_errors: string[]
|
|
157
|
+
}
|
|
158
|
+
>
|
|
159
|
+
>
|
|
160
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
161
|
+
}) => any
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
134
165
|
}
|