@volverjs/form-vue 1.0.0-beta.3 → 1.0.0-beta.31
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/LICENSE +1 -1
- package/README.md +414 -247
- package/dist/VvForm.d.ts +102 -0
- package/dist/VvFormField.d.ts +130 -0
- package/dist/VvFormFieldsGroup.d.ts +109 -0
- package/dist/VvFormTemplate.d.ts +40 -0
- package/dist/VvFormWrapper.d.ts +51 -0
- package/dist/{src/enums.d.ts → enums.d.ts} +1 -0
- package/dist/index.d.ts +854 -1
- package/dist/index.es.js +945 -559
- package/dist/index.umd.js +1 -1
- package/dist/types.d.ts +89 -0
- package/dist/utils.d.ts +3 -0
- package/package.json +56 -60
- package/src/VvForm.ts +339 -246
- package/src/VvFormField.ts +366 -317
- package/src/VvFormFieldsGroup.ts +386 -0
- package/src/VvFormTemplate.ts +189 -170
- package/src/VvFormWrapper.ts +184 -159
- package/src/enums.ts +27 -26
- package/src/index.ts +157 -132
- package/src/types.ts +160 -122
- package/src/utils.ts +122 -98
- package/dist/src/VvForm.d.ts +0 -230
- package/dist/src/VvFormField.d.ts +0 -106
- package/dist/src/VvFormTemplate.d.ts +0 -131
- package/dist/src/VvFormWrapper.d.ts +0 -172
- package/dist/src/index.d.ts +0 -1960
- package/dist/src/types.d.ts +0 -68
- package/dist/src/utils.d.ts +0 -3
- package/dist/test-playwright/VvForm.spec.d.ts +0 -1
- package/dist/test-playwright/VvFormField.spec.d.ts +0 -1
- package/dist/test-playwright/VvFormWrapper.spec.d.ts +0 -1
- package/dist/test-vitest/defaultObjectBySchema.test.d.ts +0 -1
- package/dist/test-vitest/useForm.test.d.ts +0 -1
package/dist/VvForm.d.ts
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { Component, InjectionKey, PropType, SlotsType, UnwrapRef } from 'vue';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { FormComponentOptions, FormSchema, FormTemplate, InjectedFormData, InjectedFormWrapperData } from './types';
|
|
4
|
+
import { FormStatus } from './enums';
|
|
5
|
+
export declare function defineForm<Schema extends FormSchema, Type, FormTemplateComponent extends Component>(schema: Schema, provideKey: InjectionKey<InjectedFormData<Schema, Type>>, options: FormComponentOptions<Schema, Type>, VvFormTemplate: FormTemplateComponent, wrappers: Map<string, InjectedFormWrapperData<Schema>>): {
|
|
6
|
+
clear: () => void;
|
|
7
|
+
errors: import('vue').Ref<z.inferFormattedError<Schema, string> | undefined, z.inferFormattedError<Schema, string> | undefined>;
|
|
8
|
+
formData: import('vue').Ref<(undefined extends Type ? Partial<z.TypeOf<Schema>> : Type) | undefined, (undefined extends Type ? Partial<z.TypeOf<Schema>> : Type) | undefined>;
|
|
9
|
+
ignoreUpdates: import('@vueuse/core').IgnoredUpdater;
|
|
10
|
+
invalid: import('vue').ComputedRef<boolean>;
|
|
11
|
+
readonly: import('vue').Ref<boolean, boolean>;
|
|
12
|
+
reset: () => void;
|
|
13
|
+
status: import('vue').Ref<FormStatus | undefined, FormStatus | undefined>;
|
|
14
|
+
wrappers: Map<string, InjectedFormWrapperData<Schema>>;
|
|
15
|
+
stopUpdatesWatch: import('@vue/reactivity').WatchStopHandle;
|
|
16
|
+
submit: () => Promise<boolean>;
|
|
17
|
+
validate: (value?: (undefined extends Type ? Partial<z.TypeOf<Schema>> : Type) | undefined, fields?: Set<string>) => Promise<boolean>;
|
|
18
|
+
VvForm: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
|
|
19
|
+
continuousValidation: {
|
|
20
|
+
type: BooleanConstructor;
|
|
21
|
+
default: boolean;
|
|
22
|
+
};
|
|
23
|
+
modelValue: {
|
|
24
|
+
type: ObjectConstructor;
|
|
25
|
+
default: () => {};
|
|
26
|
+
};
|
|
27
|
+
readonly: {
|
|
28
|
+
type: BooleanConstructor;
|
|
29
|
+
default: boolean;
|
|
30
|
+
};
|
|
31
|
+
tag: {
|
|
32
|
+
type: StringConstructor;
|
|
33
|
+
default: string;
|
|
34
|
+
};
|
|
35
|
+
template: {
|
|
36
|
+
type: PropType<FormTemplate<Schema, Type>>;
|
|
37
|
+
default: undefined;
|
|
38
|
+
};
|
|
39
|
+
}>, {
|
|
40
|
+
clear: () => void;
|
|
41
|
+
errors: Readonly<import('vue').Ref<import('vue').DeepReadonly<z.inferFormattedError<Schema, string>> | undefined, import('vue').DeepReadonly<z.inferFormattedError<Schema, string>> | undefined>>;
|
|
42
|
+
formData: import('vue').Ref<(undefined extends Type ? Partial<z.TypeOf<Schema>> : Type) | undefined, (undefined extends Type ? Partial<z.TypeOf<Schema>> : Type) | undefined>;
|
|
43
|
+
ignoreUpdates: import('@vueuse/core').IgnoredUpdater;
|
|
44
|
+
invalid: import('vue').ComputedRef<boolean>;
|
|
45
|
+
isReadonly: import('vue').Ref<boolean, boolean>;
|
|
46
|
+
reset: () => void;
|
|
47
|
+
status: Readonly<import('vue').Ref<FormStatus | undefined, FormStatus | undefined>>;
|
|
48
|
+
stopUpdatesWatch: import('@vue/reactivity').WatchStopHandle;
|
|
49
|
+
submit: () => Promise<boolean>;
|
|
50
|
+
validate: (value?: (undefined extends Type ? Partial<z.TypeOf<Schema>> : Type) | undefined, fields?: Set<string>) => Promise<boolean>;
|
|
51
|
+
wrappers: Map<string, InjectedFormWrapperData<Schema>>;
|
|
52
|
+
}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, ("invalid" | "valid" | "reset" | "submit" | "update:modelValue" | "update:readonly")[], "invalid" | "valid" | "reset" | "submit" | "update:modelValue" | "update:readonly", import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
|
|
53
|
+
continuousValidation: {
|
|
54
|
+
type: BooleanConstructor;
|
|
55
|
+
default: boolean;
|
|
56
|
+
};
|
|
57
|
+
modelValue: {
|
|
58
|
+
type: ObjectConstructor;
|
|
59
|
+
default: () => {};
|
|
60
|
+
};
|
|
61
|
+
readonly: {
|
|
62
|
+
type: BooleanConstructor;
|
|
63
|
+
default: boolean;
|
|
64
|
+
};
|
|
65
|
+
tag: {
|
|
66
|
+
type: StringConstructor;
|
|
67
|
+
default: string;
|
|
68
|
+
};
|
|
69
|
+
template: {
|
|
70
|
+
type: PropType<FormTemplate<Schema, Type>>;
|
|
71
|
+
default: undefined;
|
|
72
|
+
};
|
|
73
|
+
}>> & Readonly<{
|
|
74
|
+
onInvalid?: ((...args: any[]) => any) | undefined;
|
|
75
|
+
onValid?: ((...args: any[]) => any) | undefined;
|
|
76
|
+
onReset?: ((...args: any[]) => any) | undefined;
|
|
77
|
+
onSubmit?: ((...args: any[]) => any) | undefined;
|
|
78
|
+
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
79
|
+
"onUpdate:readonly"?: ((...args: any[]) => any) | undefined;
|
|
80
|
+
}>, {
|
|
81
|
+
readonly: boolean;
|
|
82
|
+
tag: string;
|
|
83
|
+
template: FormTemplate<Schema, Type>;
|
|
84
|
+
continuousValidation: boolean;
|
|
85
|
+
modelValue: Record<string, any>;
|
|
86
|
+
}, SlotsType<{
|
|
87
|
+
default: {
|
|
88
|
+
errors: import('vue').DeepReadonly<z.inferFormattedError<Schema, string>> | undefined;
|
|
89
|
+
formData: (undefined extends Type ? Partial<z.TypeOf<Schema>> : Type) | undefined;
|
|
90
|
+
invalid: boolean;
|
|
91
|
+
readonly: boolean;
|
|
92
|
+
status: FormStatus | undefined;
|
|
93
|
+
wrappers: typeof wrappers;
|
|
94
|
+
clear: () => void;
|
|
95
|
+
ignoreUpdates: import('@vueuse/core').IgnoredUpdater;
|
|
96
|
+
reset: () => void;
|
|
97
|
+
stopUpdatesWatch: import('@vue/reactivity').WatchStopHandle;
|
|
98
|
+
submit: () => Promise<boolean>;
|
|
99
|
+
validate: (value?: (undefined extends Type ? Partial<z.TypeOf<Schema>> : Type) | undefined, fields?: Set<string>) => Promise<boolean>;
|
|
100
|
+
};
|
|
101
|
+
}>, {}, {}, "invalid" | "valid" | "reset" | "status" | "readonly" | "clear" | "submit" | "errors" | "tag" | "template" | "validate", import('vue').ComponentProvideOptions, true, {}, any>;
|
|
102
|
+
};
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { Component, ConcreteComponent, DeepReadonly, InjectionKey, PropType, Ref, SlotsType, readonly } from 'vue';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { FormFieldType } from './enums';
|
|
4
|
+
import { FormFieldComponentOptions, FormSchema, InjectedFormData, InjectedFormFieldData, InjectedFormWrapperData, Path } from './types';
|
|
5
|
+
export declare function defineFormField<Schema extends FormSchema, Type = undefined>(formProvideKey: InjectionKey<InjectedFormData<Schema, Type>>, wrapperProvideKey: InjectionKey<InjectedFormWrapperData<Schema>>, formFieldInjectionKey: InjectionKey<InjectedFormFieldData<Schema>>, options?: FormFieldComponentOptions): import('vue').DefineComponent<import('vue').ExtractPropTypes<{
|
|
6
|
+
type: {
|
|
7
|
+
type: PropType<"number" | "text" | "email" | "password" | "tel" | "url" | "search" | "date" | "time" | "datetime-local" | "month" | "week" | "color" | "select" | "checkbox" | "radio" | "textarea" | "radioGroup" | "checkboxGroup" | "combobox" | "custom">;
|
|
8
|
+
validator: (value: FormFieldType) => boolean;
|
|
9
|
+
default: FormFieldType;
|
|
10
|
+
};
|
|
11
|
+
is: {
|
|
12
|
+
type: PropType<string | Component>;
|
|
13
|
+
default: undefined;
|
|
14
|
+
};
|
|
15
|
+
name: {
|
|
16
|
+
type: PropType<Path<z.TypeOf<Schema>>>;
|
|
17
|
+
required: true;
|
|
18
|
+
};
|
|
19
|
+
props: {
|
|
20
|
+
type: PropType<Partial<z.TypeOf<Schema> | ((formData?: Ref<ObjectConstructor>) => Partial<z.infer<Schema>> | undefined) | undefined>>;
|
|
21
|
+
default: () => {};
|
|
22
|
+
};
|
|
23
|
+
showValid: {
|
|
24
|
+
type: BooleanConstructor;
|
|
25
|
+
default: boolean;
|
|
26
|
+
};
|
|
27
|
+
defaultValue: {
|
|
28
|
+
type: (ObjectConstructor | ArrayConstructor | BooleanConstructor | StringConstructor | NumberConstructor)[];
|
|
29
|
+
default: undefined;
|
|
30
|
+
};
|
|
31
|
+
lazyLoad: {
|
|
32
|
+
type: BooleanConstructor;
|
|
33
|
+
default: boolean;
|
|
34
|
+
};
|
|
35
|
+
readonly: {
|
|
36
|
+
type: BooleanConstructor;
|
|
37
|
+
default: undefined;
|
|
38
|
+
};
|
|
39
|
+
}>, {
|
|
40
|
+
component: import('vue').ComputedRef<{
|
|
41
|
+
new (...args: any[]): any;
|
|
42
|
+
__isFragment?: undefined;
|
|
43
|
+
__isTeleport?: undefined;
|
|
44
|
+
__isSuspense?: undefined;
|
|
45
|
+
} | ConcreteComponent>;
|
|
46
|
+
hasProps: import('vue').ComputedRef<{
|
|
47
|
+
name: {} | ([{
|
|
48
|
+
type: PropType<Path<z.TypeOf<Schema>>>;
|
|
49
|
+
required: true;
|
|
50
|
+
}] extends [import('vue').Prop<infer V, infer D>] ? unknown extends V ? keyof V extends never ? import('@vue/shared').IfAny<V, V, D> : V : V : {
|
|
51
|
+
type: PropType<Path<z.TypeOf<Schema>>>;
|
|
52
|
+
required: true;
|
|
53
|
+
});
|
|
54
|
+
invalid: boolean;
|
|
55
|
+
valid: boolean | undefined;
|
|
56
|
+
type: FormFieldType | undefined;
|
|
57
|
+
invalidLabel: any;
|
|
58
|
+
modelValue: any;
|
|
59
|
+
readonly: boolean;
|
|
60
|
+
'onUpdate:modelValue': (value: unknown) => void;
|
|
61
|
+
}>;
|
|
62
|
+
invalid: import('vue').ComputedRef<boolean>;
|
|
63
|
+
}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, ("invalid" | "valid" | "update:modelValue" | "update:formData")[], "invalid" | "valid" | "update:modelValue" | "update:formData", import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
|
|
64
|
+
type: {
|
|
65
|
+
type: PropType<"number" | "text" | "email" | "password" | "tel" | "url" | "search" | "date" | "time" | "datetime-local" | "month" | "week" | "color" | "select" | "checkbox" | "radio" | "textarea" | "radioGroup" | "checkboxGroup" | "combobox" | "custom">;
|
|
66
|
+
validator: (value: FormFieldType) => boolean;
|
|
67
|
+
default: FormFieldType;
|
|
68
|
+
};
|
|
69
|
+
is: {
|
|
70
|
+
type: PropType<string | Component>;
|
|
71
|
+
default: undefined;
|
|
72
|
+
};
|
|
73
|
+
name: {
|
|
74
|
+
type: PropType<Path<z.TypeOf<Schema>>>;
|
|
75
|
+
required: true;
|
|
76
|
+
};
|
|
77
|
+
props: {
|
|
78
|
+
type: PropType<Partial<z.TypeOf<Schema> | ((formData?: Ref<ObjectConstructor>) => Partial<z.infer<Schema>> | undefined) | undefined>>;
|
|
79
|
+
default: () => {};
|
|
80
|
+
};
|
|
81
|
+
showValid: {
|
|
82
|
+
type: BooleanConstructor;
|
|
83
|
+
default: boolean;
|
|
84
|
+
};
|
|
85
|
+
defaultValue: {
|
|
86
|
+
type: (ObjectConstructor | ArrayConstructor | BooleanConstructor | StringConstructor | NumberConstructor)[];
|
|
87
|
+
default: undefined;
|
|
88
|
+
};
|
|
89
|
+
lazyLoad: {
|
|
90
|
+
type: BooleanConstructor;
|
|
91
|
+
default: boolean;
|
|
92
|
+
};
|
|
93
|
+
readonly: {
|
|
94
|
+
type: BooleanConstructor;
|
|
95
|
+
default: undefined;
|
|
96
|
+
};
|
|
97
|
+
}>> & Readonly<{
|
|
98
|
+
onInvalid?: ((...args: any[]) => any) | undefined;
|
|
99
|
+
onValid?: ((...args: any[]) => any) | undefined;
|
|
100
|
+
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
101
|
+
"onUpdate:formData"?: ((...args: any[]) => any) | undefined;
|
|
102
|
+
}>, {
|
|
103
|
+
type: "number" | "text" | "email" | "password" | "tel" | "url" | "search" | "date" | "time" | "datetime-local" | "month" | "week" | "color" | "select" | "checkbox" | "radio" | "textarea" | "radioGroup" | "checkboxGroup" | "combobox" | "custom";
|
|
104
|
+
readonly: boolean;
|
|
105
|
+
props: [{
|
|
106
|
+
type: PropType<Partial<z.TypeOf<Schema> | ((formData?: Ref<ObjectConstructor>) => Partial<z.infer<Schema>> | undefined) | undefined>>;
|
|
107
|
+
default: () => {};
|
|
108
|
+
}] extends [import('vue').Prop<infer V, infer D>] ? unknown extends V ? keyof V extends never ? import('@vue/shared').IfAny<V, V, D> : V : V : {
|
|
109
|
+
type: PropType<Partial<z.TypeOf<Schema> | ((formData?: Ref<ObjectConstructor>) => Partial<z.infer<Schema>> | undefined) | undefined>>;
|
|
110
|
+
default: () => {};
|
|
111
|
+
};
|
|
112
|
+
is: string | Component;
|
|
113
|
+
showValid: boolean;
|
|
114
|
+
defaultValue: string | number | boolean | unknown[] | Record<string, any>;
|
|
115
|
+
lazyLoad: boolean;
|
|
116
|
+
}, SlotsType<{
|
|
117
|
+
[key: string]: any;
|
|
118
|
+
default: {
|
|
119
|
+
errors: DeepReadonly<z.inferFormattedError<Schema>>;
|
|
120
|
+
formData?: (undefined extends Type ? Partial<z.TypeOf<Schema>> : Type) | undefined;
|
|
121
|
+
formErrors?: DeepReadonly<z.inferFormattedError<Schema, string>> | undefined;
|
|
122
|
+
invalid: boolean;
|
|
123
|
+
invalidLabel?: string[] | undefined;
|
|
124
|
+
modelValue: any;
|
|
125
|
+
readonly: boolean;
|
|
126
|
+
onUpdate: (value: unknown) => void;
|
|
127
|
+
submit?: (() => Promise<boolean>) | undefined;
|
|
128
|
+
validate?: ((formData?: (undefined extends Type ? Partial<z.TypeOf<Schema>> : Type) | undefined, fields?: Set<string> | undefined) => Promise<boolean>) | undefined;
|
|
129
|
+
};
|
|
130
|
+
}>, {}, {}, "invalid" | "type" | "errors" | "component" | "hasProps" | "invalidLabel" | "is", import('vue').ComponentProvideOptions, true, {}, any>;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { Component, DeepReadonly, InjectionKey, PropType, Ref, SlotsType, readonly } from 'vue';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { FormSchema, InjectedFormData, InjectedFormFieldsGroupData, InjectedFormWrapperData, Path } from './types';
|
|
4
|
+
export declare function defineFormFieldsGroup<Schema extends FormSchema, Type = undefined>(formProvideKey: InjectionKey<InjectedFormData<Schema, Type>>, wrapperProvideKey: InjectionKey<InjectedFormWrapperData<Schema>>, formFieldsGroupInjectionKey: InjectionKey<InjectedFormFieldsGroupData<Schema>>): import('vue').DefineComponent<import('vue').ExtractPropTypes<{
|
|
5
|
+
is: {
|
|
6
|
+
type: PropType<string | Component>;
|
|
7
|
+
default: undefined;
|
|
8
|
+
};
|
|
9
|
+
names: {
|
|
10
|
+
type: PropType<Path<z.TypeOf<Schema>>[] | Record<string, Path<z.TypeOf<Schema>>>>;
|
|
11
|
+
required: true;
|
|
12
|
+
};
|
|
13
|
+
props: {
|
|
14
|
+
type: PropType<Partial<z.TypeOf<Schema> | ((formData?: Ref<ObjectConstructor>) => Partial<z.infer<Schema>> | undefined) | undefined>>;
|
|
15
|
+
default: () => {};
|
|
16
|
+
};
|
|
17
|
+
showValid: {
|
|
18
|
+
type: BooleanConstructor;
|
|
19
|
+
default: boolean;
|
|
20
|
+
};
|
|
21
|
+
defaultValues: {
|
|
22
|
+
type: PropType<Record<Path<z.TypeOf<Schema>>, any>>;
|
|
23
|
+
default: undefined;
|
|
24
|
+
};
|
|
25
|
+
readonly: {
|
|
26
|
+
type: BooleanConstructor;
|
|
27
|
+
default: undefined;
|
|
28
|
+
};
|
|
29
|
+
}>, {
|
|
30
|
+
component: import('vue').ComputedRef<{
|
|
31
|
+
render(): import('vue').VNode<import('vue').RendererNode, import('vue').RendererElement, {
|
|
32
|
+
[key: string]: any;
|
|
33
|
+
}>[];
|
|
34
|
+
}>;
|
|
35
|
+
hasProps: import('vue').ComputedRef<{
|
|
36
|
+
names: {};
|
|
37
|
+
invalid: boolean;
|
|
38
|
+
invalids: Record<string, boolean>;
|
|
39
|
+
valid: boolean | undefined;
|
|
40
|
+
invalidLabels: Record<string, string[]> | undefined;
|
|
41
|
+
modelValue: Record<string, any>;
|
|
42
|
+
readonly: boolean;
|
|
43
|
+
}>;
|
|
44
|
+
invalid: import('vue').ComputedRef<boolean>;
|
|
45
|
+
}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, ("invalid" | "valid" | "update:modelValue" | "update:formData")[], "invalid" | "valid" | "update:modelValue" | "update:formData", import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
|
|
46
|
+
is: {
|
|
47
|
+
type: PropType<string | Component>;
|
|
48
|
+
default: undefined;
|
|
49
|
+
};
|
|
50
|
+
names: {
|
|
51
|
+
type: PropType<Path<z.TypeOf<Schema>>[] | Record<string, Path<z.TypeOf<Schema>>>>;
|
|
52
|
+
required: true;
|
|
53
|
+
};
|
|
54
|
+
props: {
|
|
55
|
+
type: PropType<Partial<z.TypeOf<Schema> | ((formData?: Ref<ObjectConstructor>) => Partial<z.infer<Schema>> | undefined) | undefined>>;
|
|
56
|
+
default: () => {};
|
|
57
|
+
};
|
|
58
|
+
showValid: {
|
|
59
|
+
type: BooleanConstructor;
|
|
60
|
+
default: boolean;
|
|
61
|
+
};
|
|
62
|
+
defaultValues: {
|
|
63
|
+
type: PropType<Record<Path<z.TypeOf<Schema>>, any>>;
|
|
64
|
+
default: undefined;
|
|
65
|
+
};
|
|
66
|
+
readonly: {
|
|
67
|
+
type: BooleanConstructor;
|
|
68
|
+
default: undefined;
|
|
69
|
+
};
|
|
70
|
+
}>> & Readonly<{
|
|
71
|
+
onInvalid?: ((...args: any[]) => any) | undefined;
|
|
72
|
+
onValid?: ((...args: any[]) => any) | undefined;
|
|
73
|
+
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
74
|
+
"onUpdate:formData"?: ((...args: any[]) => any) | undefined;
|
|
75
|
+
}>, {
|
|
76
|
+
readonly: boolean;
|
|
77
|
+
props: [{
|
|
78
|
+
type: PropType<Partial<z.TypeOf<Schema> | ((formData?: Ref<ObjectConstructor>) => Partial<z.infer<Schema>> | undefined) | undefined>>;
|
|
79
|
+
default: () => {};
|
|
80
|
+
}] extends [import('vue').Prop<infer V, infer D>] ? unknown extends V ? keyof V extends never ? import('@vue/shared').IfAny<V, V, D> : V : V : {
|
|
81
|
+
type: PropType<Partial<z.TypeOf<Schema> | ((formData?: Ref<ObjectConstructor>) => Partial<z.infer<Schema>> | undefined) | undefined>>;
|
|
82
|
+
default: () => {};
|
|
83
|
+
};
|
|
84
|
+
is: string | Component;
|
|
85
|
+
showValid: boolean;
|
|
86
|
+
defaultValues: [{
|
|
87
|
+
type: PropType<Record<Path<z.TypeOf<Schema>>, any>>;
|
|
88
|
+
default: undefined;
|
|
89
|
+
}] extends [import('vue').Prop<infer V, infer D>] ? unknown extends V ? keyof V extends never ? import('@vue/shared').IfAny<V, V, D> : V : V : {
|
|
90
|
+
type: PropType<Record<Path<z.TypeOf<Schema>>, any>>;
|
|
91
|
+
default: undefined;
|
|
92
|
+
};
|
|
93
|
+
}, SlotsType<{
|
|
94
|
+
[key: string]: any;
|
|
95
|
+
default: {
|
|
96
|
+
errors?: Record<Path<z.TypeOf<Schema>>, z.inferFormattedError<Schema, string>> | undefined;
|
|
97
|
+
formData?: (undefined extends Type ? Partial<z.TypeOf<Schema>> : Type) | undefined;
|
|
98
|
+
formErrors?: DeepReadonly<z.inferFormattedError<Schema, string>> | undefined;
|
|
99
|
+
invalid: boolean;
|
|
100
|
+
invalids: Record<string, boolean>;
|
|
101
|
+
invalidLabels?: Record<string, string[]> | undefined;
|
|
102
|
+
modelValue: Record<string, any>;
|
|
103
|
+
onUpdate: (value: Record<string, any>) => void;
|
|
104
|
+
onUpdateField: (name: string, value: any) => void;
|
|
105
|
+
readonly: boolean;
|
|
106
|
+
submit?: (() => Promise<boolean>) | undefined;
|
|
107
|
+
validate?: ((formData?: (undefined extends Type ? Partial<z.TypeOf<Schema>> : Type) | undefined, fields?: Set<string> | undefined) => Promise<boolean>) | undefined;
|
|
108
|
+
};
|
|
109
|
+
}>, {}, {}, "invalid" | "errors" | "component" | "hasProps" | "is" | "invalidLabels", import('vue').ComponentProvideOptions, true, {}, any>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Component, DeepReadonly, InjectionKey, PropType, SlotsType, VNode } from 'vue';
|
|
2
|
+
import { FormSchema, InjectedFormData, FormTemplate } from './types';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
import { FormStatus } from './enums';
|
|
5
|
+
export declare function defineFormTemplate<Schema extends FormSchema, Type = undefined>(formProvideKey: InjectionKey<InjectedFormData<Schema, Type>>, VvFormField: Component): import('vue').DefineComponent<import('vue').ExtractPropTypes<{
|
|
6
|
+
schema: {
|
|
7
|
+
type: PropType<FormTemplate<Schema, Type>>;
|
|
8
|
+
required: true;
|
|
9
|
+
};
|
|
10
|
+
scope: {
|
|
11
|
+
type: PropType<Record<string, unknown>>;
|
|
12
|
+
default: () => {};
|
|
13
|
+
};
|
|
14
|
+
}>, (() => (VNode<import('vue').RendererNode, import('vue').RendererElement, {
|
|
15
|
+
[key: string]: any;
|
|
16
|
+
}> | VNode<import('vue').RendererNode, import('vue').RendererElement, {
|
|
17
|
+
[key: string]: any;
|
|
18
|
+
}>[] | undefined)[]) | undefined, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
|
|
19
|
+
schema: {
|
|
20
|
+
type: PropType<FormTemplate<Schema, Type>>;
|
|
21
|
+
required: true;
|
|
22
|
+
};
|
|
23
|
+
scope: {
|
|
24
|
+
type: PropType<Record<string, unknown>>;
|
|
25
|
+
default: () => {};
|
|
26
|
+
};
|
|
27
|
+
}>> & Readonly<{}>, {
|
|
28
|
+
scope: Record<string, unknown>;
|
|
29
|
+
}, SlotsType<{
|
|
30
|
+
default: {
|
|
31
|
+
errors?: DeepReadonly<z.inferFormattedError<Schema>>;
|
|
32
|
+
formData?: undefined extends Type ? Partial<z.infer<Schema>> : Type;
|
|
33
|
+
invalid: boolean;
|
|
34
|
+
status?: FormStatus;
|
|
35
|
+
submit?: InjectedFormData<Schema, Type>['submit'];
|
|
36
|
+
validate?: InjectedFormData<Schema, Type>['validate'];
|
|
37
|
+
clear?: InjectedFormData<Schema, Type>['clear'];
|
|
38
|
+
reset?: InjectedFormData<Schema, Type>['reset'];
|
|
39
|
+
};
|
|
40
|
+
}>, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { DeepReadonly, InjectionKey, Ref, SlotsType } from 'vue';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { FormSchema, InjectedFormData, InjectedFormWrapperData } from './types';
|
|
4
|
+
export declare function defineFormWrapper<Schema extends FormSchema, Type = undefined>(formProvideKey: InjectionKey<InjectedFormData<Schema, Type>>, wrapperProvideKey: InjectionKey<InjectedFormWrapperData<Schema>>): import('vue').DefineComponent<import('vue').ExtractPropTypes<{
|
|
5
|
+
name: {
|
|
6
|
+
type: StringConstructor;
|
|
7
|
+
required: true;
|
|
8
|
+
};
|
|
9
|
+
tag: {
|
|
10
|
+
type: StringConstructor;
|
|
11
|
+
default: undefined;
|
|
12
|
+
};
|
|
13
|
+
}>, {
|
|
14
|
+
errors: Readonly<Ref<DeepReadonly<z.inferFormattedError<Schema, string>> | undefined, DeepReadonly<z.inferFormattedError<Schema, string>> | undefined>> | undefined;
|
|
15
|
+
fields: Ref<Map<string, string> & Omit<Map<string, string>, keyof Map<any, any>>, Map<string, string> | (Map<string, string> & Omit<Map<string, string>, keyof Map<any, any>>)>;
|
|
16
|
+
fieldsErrors: Ref<Map<string, z.inferFormattedError<Schema, string>>, Map<string, z.inferFormattedError<Schema, string>>>;
|
|
17
|
+
formData: Ref<(undefined extends Type ? Partial<z.TypeOf<Schema>> : Type) | undefined, (undefined extends Type ? Partial<z.TypeOf<Schema>> : Type) | undefined> | undefined;
|
|
18
|
+
invalid: import('vue').ComputedRef<boolean>;
|
|
19
|
+
clear: (() => void) | undefined;
|
|
20
|
+
reset: (() => void) | undefined;
|
|
21
|
+
submit: (() => Promise<boolean>) | undefined;
|
|
22
|
+
validate: ((formData?: (undefined extends Type ? Partial<z.TypeOf<Schema>> : Type) | undefined, fields?: Set<string> | undefined) => Promise<boolean>) | undefined;
|
|
23
|
+
validateWrapper: () => Promise<boolean>;
|
|
24
|
+
}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, ("invalid" | "valid")[], "invalid" | "valid", import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
|
|
25
|
+
name: {
|
|
26
|
+
type: StringConstructor;
|
|
27
|
+
required: true;
|
|
28
|
+
};
|
|
29
|
+
tag: {
|
|
30
|
+
type: StringConstructor;
|
|
31
|
+
default: undefined;
|
|
32
|
+
};
|
|
33
|
+
}>> & Readonly<{
|
|
34
|
+
onInvalid?: ((...args: any[]) => any) | undefined;
|
|
35
|
+
onValid?: ((...args: any[]) => any) | undefined;
|
|
36
|
+
}>, {
|
|
37
|
+
tag: string;
|
|
38
|
+
}, SlotsType<{
|
|
39
|
+
default: {
|
|
40
|
+
errors?: DeepReadonly<z.inferFormattedError<Schema>>;
|
|
41
|
+
fieldsErrors: Map<string, z.inferFormattedError<Schema>>;
|
|
42
|
+
formData?: undefined extends Type ? Partial<z.infer<Schema>> : Type;
|
|
43
|
+
formErrors?: DeepReadonly<z.inferFormattedError<Schema>>;
|
|
44
|
+
invalid: boolean;
|
|
45
|
+
clear?: InjectedFormData<Schema, Type>['clear'];
|
|
46
|
+
reset?: InjectedFormData<Schema, Type>['reset'];
|
|
47
|
+
submit?: InjectedFormData<Schema, Type>['submit'];
|
|
48
|
+
validate?: InjectedFormData<Schema, Type>['validate'];
|
|
49
|
+
validateWrapper?: () => Promise<boolean>;
|
|
50
|
+
};
|
|
51
|
+
}>, {}, {}, "invalid" | "reset" | "clear" | "submit" | "errors" | "tag" | "validate" | "formData" | "fields" | "fieldsErrors" | "validateWrapper", import('vue').ComponentProvideOptions, true, {}, any>;
|