@volverjs/form-vue 1.0.0-beta.8 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +414 -247
- package/dist/VvForm.d.ts +135 -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 +65 -0
- package/dist/{src/enums.d.ts → enums.d.ts} +1 -0
- package/dist/index.d.ts +972 -1
- package/dist/index.es.js +944 -593
- package/dist/index.umd.js +1 -1
- package/dist/types.d.ts +93 -0
- package/dist/utils.d.ts +3 -0
- package/package.json +61 -60
- package/src/VvForm.ts +358 -301
- package/src/VvFormField.ts +366 -334
- package/src/VvFormFieldsGroup.ts +381 -0
- package/src/VvFormTemplate.ts +185 -171
- package/src/VvFormWrapper.ts +198 -161
- package/src/enums.ts +27 -26
- package/src/index.ts +157 -134
- package/src/types.ts +162 -125
- package/src/utils.ts +121 -100
- package/dist/src/VvForm.d.ts +0 -202
- package/dist/src/VvFormField.d.ts +0 -116
- package/dist/src/VvFormTemplate.d.ts +0 -60
- package/dist/src/VvFormWrapper.d.ts +0 -107
- package/dist/src/index.d.ts +0 -1498
- package/dist/src/types.d.ts +0 -70
- 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/src/utils.ts
CHANGED
|
@@ -1,104 +1,125 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
ZodArray,
|
|
2
|
+
|
|
3
|
+
ZodDefault,
|
|
4
|
+
ZodObject,
|
|
5
|
+
ZodEffects,
|
|
6
|
+
ZodSchema,
|
|
7
|
+
ZodNullable,
|
|
8
|
+
ZodOptional,
|
|
9
|
+
ZodRecord,
|
|
10
|
+
ZodArray,
|
|
12
11
|
} from 'zod'
|
|
13
|
-
import type {
|
|
12
|
+
import type { z, AnyZodObject, ZodTypeAny } from 'zod'
|
|
13
|
+
import type { EffectType, FormSchema } from './types'
|
|
14
14
|
|
|
15
|
-
export
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
)
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
15
|
+
export function defaultObjectBySchema<Schema extends FormSchema>(schema: Schema, original: Partial<z.infer<Schema>> & Record<string, unknown> = {}): Partial<z.infer<Schema>> {
|
|
16
|
+
const getSchemaInnerType = <Type extends ZodTypeAny>(
|
|
17
|
+
schema: EffectType<Type>,
|
|
18
|
+
) => {
|
|
19
|
+
let toReturn = schema
|
|
20
|
+
while (toReturn instanceof ZodEffects) {
|
|
21
|
+
toReturn = toReturn.innerType()
|
|
22
|
+
}
|
|
23
|
+
if (toReturn instanceof ZodOptional) {
|
|
24
|
+
toReturn = toReturn._def.innerType
|
|
25
|
+
}
|
|
26
|
+
return toReturn
|
|
27
|
+
}
|
|
28
|
+
const isSchemaOptional = <Type extends ZodTypeAny>(
|
|
29
|
+
schema:
|
|
30
|
+
| Type
|
|
31
|
+
| ZodEffects<Type>
|
|
32
|
+
| ZodEffects<ZodEffects<Type>>
|
|
33
|
+
| ZodOptional<Type>,
|
|
34
|
+
) => {
|
|
35
|
+
let toReturn = schema
|
|
36
|
+
while (toReturn instanceof ZodEffects) {
|
|
37
|
+
toReturn = toReturn.innerType()
|
|
38
|
+
}
|
|
39
|
+
if (toReturn instanceof ZodOptional) {
|
|
40
|
+
return true
|
|
41
|
+
}
|
|
42
|
+
return false
|
|
43
|
+
}
|
|
44
|
+
const innerType = getSchemaInnerType<AnyZodObject>(schema)
|
|
45
|
+
const unknownKeys
|
|
46
|
+
= innerType instanceof ZodObject
|
|
47
|
+
? innerType._def.unknownKeys === 'passthrough'
|
|
48
|
+
: false
|
|
49
|
+
return {
|
|
50
|
+
...(unknownKeys ? original : {}),
|
|
51
|
+
...Object.fromEntries(
|
|
52
|
+
(Object.entries(innerType.shape) as [string, ZodTypeAny][]).map(
|
|
53
|
+
([key, subSchema]) => {
|
|
54
|
+
const originalValue = original[key]
|
|
55
|
+
const isOptional = isSchemaOptional(subSchema)
|
|
56
|
+
let innerType = getSchemaInnerType(subSchema)
|
|
57
|
+
let defaultValue: Partial<z.infer<Schema>> | undefined
|
|
58
|
+
if (innerType instanceof ZodDefault) {
|
|
59
|
+
defaultValue = innerType._def.defaultValue()
|
|
60
|
+
innerType = innerType._def.innerType
|
|
61
|
+
}
|
|
62
|
+
if (
|
|
63
|
+
originalValue === null
|
|
64
|
+
&& innerType instanceof ZodNullable
|
|
65
|
+
) {
|
|
66
|
+
return [key, originalValue]
|
|
67
|
+
}
|
|
68
|
+
if ((originalValue === undefined || originalValue === null) && isOptional) {
|
|
69
|
+
return [key, defaultValue]
|
|
70
|
+
}
|
|
71
|
+
if (innerType instanceof ZodSchema) {
|
|
72
|
+
const parse = subSchema.safeParse(originalValue)
|
|
73
|
+
if (parse.success) {
|
|
74
|
+
return [key, parse.data ?? defaultValue]
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
if (
|
|
78
|
+
innerType instanceof ZodArray
|
|
79
|
+
&& Array.isArray(originalValue)
|
|
80
|
+
&& originalValue.length
|
|
81
|
+
) {
|
|
82
|
+
const arrayType = getSchemaInnerType(innerType._def.type)
|
|
83
|
+
if (arrayType instanceof ZodObject) {
|
|
84
|
+
return [
|
|
85
|
+
key,
|
|
86
|
+
originalValue.map((element: unknown) =>
|
|
87
|
+
defaultObjectBySchema(
|
|
88
|
+
arrayType,
|
|
89
|
+
(element && typeof element === 'object'
|
|
90
|
+
? element
|
|
91
|
+
: undefined) as Partial<
|
|
92
|
+
typeof arrayType
|
|
93
|
+
>,
|
|
94
|
+
),
|
|
95
|
+
),
|
|
96
|
+
]
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
if (innerType instanceof ZodRecord && originalValue) {
|
|
100
|
+
const valueType = getSchemaInnerType(innerType._def.valueType)
|
|
101
|
+
if (valueType instanceof ZodObject) {
|
|
102
|
+
return [key, Object.keys(originalValue).reduce((acc: Record<string, unknown>, recordKey: string) => {
|
|
103
|
+
acc[recordKey] = defaultObjectBySchema(valueType, (originalValue as Record<string, unknown>)[recordKey] as Partial<any> & Record<string, unknown>)
|
|
104
|
+
return acc
|
|
105
|
+
}, {})]
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
if (innerType instanceof ZodObject) {
|
|
109
|
+
return [
|
|
110
|
+
key,
|
|
111
|
+
defaultObjectBySchema(
|
|
112
|
+
innerType,
|
|
113
|
+
originalValue
|
|
114
|
+
&& typeof originalValue === 'object'
|
|
115
|
+
? (originalValue as Partial<z.infer<Schema>> & Record<string, unknown>)
|
|
116
|
+
: defaultValue,
|
|
117
|
+
),
|
|
118
|
+
]
|
|
119
|
+
}
|
|
120
|
+
return [key, defaultValue]
|
|
121
|
+
},
|
|
122
|
+
),
|
|
123
|
+
),
|
|
124
|
+
} as Partial<z.infer<Schema>>
|
|
104
125
|
}
|
package/dist/src/VvForm.d.ts
DELETED
|
@@ -1,202 +0,0 @@
|
|
|
1
|
-
import { type Component, type InjectionKey, type DeepReadonly, type Ref, type PropType, type WatchStopHandle } from 'vue';
|
|
2
|
-
import { type IgnoredUpdater } from '@vueuse/core';
|
|
3
|
-
import { type z, type TypeOf } from 'zod';
|
|
4
|
-
import type { FormComponentOptions, FormSchema, FormTemplate, InjectedFormData } from './types';
|
|
5
|
-
import { FormStatus } from './enums';
|
|
6
|
-
export declare const defineForm: <Schema extends FormSchema>(schema: Schema, provideKey: InjectionKey<InjectedFormData<Schema>>, options?: FormComponentOptions<Schema> | undefined, VvFormTemplate?: Component) => {
|
|
7
|
-
errors: Ref<z.inferFormattedError<Schema, string> | undefined>;
|
|
8
|
-
status: Ref<FormStatus | undefined>;
|
|
9
|
-
invalid: import("vue").ComputedRef<boolean>;
|
|
10
|
-
readonly: Ref<boolean>;
|
|
11
|
-
formData: Ref<Partial<z.TypeOf<Schema> | undefined>>;
|
|
12
|
-
validate: (value?: Partial<z.TypeOf<Schema> | undefined>) => Promise<boolean>;
|
|
13
|
-
submit: () => Promise<boolean>;
|
|
14
|
-
ignoreUpdates: IgnoredUpdater;
|
|
15
|
-
stopUpdatesWatch: WatchStopHandle;
|
|
16
|
-
/**
|
|
17
|
-
* An hack to add types to the default slot
|
|
18
|
-
*/
|
|
19
|
-
VvForm: {
|
|
20
|
-
new (...args: any[]): import("vue").CreateComponentPublicInstance<Readonly<import("vue").ExtractPropTypes<{
|
|
21
|
-
continuosValidation: {
|
|
22
|
-
type: BooleanConstructor;
|
|
23
|
-
default: boolean;
|
|
24
|
-
};
|
|
25
|
-
modelValue: {
|
|
26
|
-
type: ObjectConstructor;
|
|
27
|
-
default: () => {};
|
|
28
|
-
};
|
|
29
|
-
readonly: {
|
|
30
|
-
type: BooleanConstructor;
|
|
31
|
-
default: boolean;
|
|
32
|
-
};
|
|
33
|
-
tag: {
|
|
34
|
-
type: StringConstructor;
|
|
35
|
-
default: string;
|
|
36
|
-
};
|
|
37
|
-
template: {
|
|
38
|
-
type: PropType<FormTemplate<Schema>>;
|
|
39
|
-
default: undefined;
|
|
40
|
-
};
|
|
41
|
-
}>> & {
|
|
42
|
-
onInvalid?: ((...args: any[]) => any) | undefined;
|
|
43
|
-
onValid?: ((...args: any[]) => any) | undefined;
|
|
44
|
-
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
45
|
-
onSubmit?: ((...args: any[]) => any) | undefined;
|
|
46
|
-
"onUpdate:readonly"?: ((...args: any[]) => any) | undefined;
|
|
47
|
-
}, {
|
|
48
|
-
formData: Ref<Partial<z.TypeOf<Schema> | undefined>>;
|
|
49
|
-
submit: () => Promise<boolean>;
|
|
50
|
-
validate: (value?: Partial<z.TypeOf<Schema> | undefined>) => Promise<boolean>;
|
|
51
|
-
ignoreUpdates: IgnoredUpdater;
|
|
52
|
-
stopUpdatesWatch: WatchStopHandle;
|
|
53
|
-
errors: Readonly<Ref<DeepReadonly<z.inferFormattedError<Schema, string>> | undefined>>;
|
|
54
|
-
status: Readonly<Ref<FormStatus | undefined>>;
|
|
55
|
-
invalid: import("vue").ComputedRef<boolean>;
|
|
56
|
-
isReadonly: Ref<boolean>;
|
|
57
|
-
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("invalid" | "valid" | "update:modelValue" | "submit" | "update:readonly")[], import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps & Readonly<import("vue").ExtractPropTypes<{
|
|
58
|
-
continuosValidation: {
|
|
59
|
-
type: BooleanConstructor;
|
|
60
|
-
default: boolean;
|
|
61
|
-
};
|
|
62
|
-
modelValue: {
|
|
63
|
-
type: ObjectConstructor;
|
|
64
|
-
default: () => {};
|
|
65
|
-
};
|
|
66
|
-
readonly: {
|
|
67
|
-
type: BooleanConstructor;
|
|
68
|
-
default: boolean;
|
|
69
|
-
};
|
|
70
|
-
tag: {
|
|
71
|
-
type: StringConstructor;
|
|
72
|
-
default: string;
|
|
73
|
-
};
|
|
74
|
-
template: {
|
|
75
|
-
type: PropType<FormTemplate<Schema>>;
|
|
76
|
-
default: undefined;
|
|
77
|
-
};
|
|
78
|
-
}>> & {
|
|
79
|
-
onInvalid?: ((...args: any[]) => any) | undefined;
|
|
80
|
-
onValid?: ((...args: any[]) => any) | undefined;
|
|
81
|
-
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
82
|
-
onSubmit?: ((...args: any[]) => any) | undefined;
|
|
83
|
-
"onUpdate:readonly"?: ((...args: any[]) => any) | undefined;
|
|
84
|
-
}, {
|
|
85
|
-
readonly: boolean;
|
|
86
|
-
template: FormTemplate<Schema>;
|
|
87
|
-
modelValue: Record<string, any>;
|
|
88
|
-
continuosValidation: boolean;
|
|
89
|
-
tag: string;
|
|
90
|
-
}, true, {}, {}, {
|
|
91
|
-
P: {};
|
|
92
|
-
B: {};
|
|
93
|
-
D: {};
|
|
94
|
-
C: {};
|
|
95
|
-
M: {};
|
|
96
|
-
Defaults: {};
|
|
97
|
-
}, Readonly<import("vue").ExtractPropTypes<{
|
|
98
|
-
continuosValidation: {
|
|
99
|
-
type: BooleanConstructor;
|
|
100
|
-
default: boolean;
|
|
101
|
-
};
|
|
102
|
-
modelValue: {
|
|
103
|
-
type: ObjectConstructor;
|
|
104
|
-
default: () => {};
|
|
105
|
-
};
|
|
106
|
-
readonly: {
|
|
107
|
-
type: BooleanConstructor;
|
|
108
|
-
default: boolean;
|
|
109
|
-
};
|
|
110
|
-
tag: {
|
|
111
|
-
type: StringConstructor;
|
|
112
|
-
default: string;
|
|
113
|
-
};
|
|
114
|
-
template: {
|
|
115
|
-
type: PropType<FormTemplate<Schema>>;
|
|
116
|
-
default: undefined;
|
|
117
|
-
};
|
|
118
|
-
}>> & {
|
|
119
|
-
onInvalid?: ((...args: any[]) => any) | undefined;
|
|
120
|
-
onValid?: ((...args: any[]) => any) | undefined;
|
|
121
|
-
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
122
|
-
onSubmit?: ((...args: any[]) => any) | undefined;
|
|
123
|
-
"onUpdate:readonly"?: ((...args: any[]) => any) | undefined;
|
|
124
|
-
}, {
|
|
125
|
-
formData: Ref<Partial<z.TypeOf<Schema> | undefined>>;
|
|
126
|
-
submit: () => Promise<boolean>;
|
|
127
|
-
validate: (value?: Partial<z.TypeOf<Schema> | undefined>) => Promise<boolean>;
|
|
128
|
-
ignoreUpdates: IgnoredUpdater;
|
|
129
|
-
stopUpdatesWatch: WatchStopHandle;
|
|
130
|
-
errors: Readonly<Ref<DeepReadonly<z.inferFormattedError<Schema, string>> | undefined>>;
|
|
131
|
-
status: Readonly<Ref<FormStatus | undefined>>;
|
|
132
|
-
invalid: import("vue").ComputedRef<boolean>;
|
|
133
|
-
isReadonly: Ref<boolean>;
|
|
134
|
-
}, {}, {}, {}, {
|
|
135
|
-
readonly: boolean;
|
|
136
|
-
template: FormTemplate<Schema>;
|
|
137
|
-
modelValue: Record<string, any>;
|
|
138
|
-
continuosValidation: boolean;
|
|
139
|
-
tag: string;
|
|
140
|
-
}>;
|
|
141
|
-
__isFragment?: undefined;
|
|
142
|
-
__isTeleport?: undefined;
|
|
143
|
-
__isSuspense?: undefined;
|
|
144
|
-
} & import("vue").ComponentOptionsBase<Readonly<import("vue").ExtractPropTypes<{
|
|
145
|
-
continuosValidation: {
|
|
146
|
-
type: BooleanConstructor;
|
|
147
|
-
default: boolean;
|
|
148
|
-
};
|
|
149
|
-
modelValue: {
|
|
150
|
-
type: ObjectConstructor;
|
|
151
|
-
default: () => {};
|
|
152
|
-
};
|
|
153
|
-
readonly: {
|
|
154
|
-
type: BooleanConstructor;
|
|
155
|
-
default: boolean;
|
|
156
|
-
};
|
|
157
|
-
tag: {
|
|
158
|
-
type: StringConstructor;
|
|
159
|
-
default: string;
|
|
160
|
-
};
|
|
161
|
-
template: {
|
|
162
|
-
type: PropType<FormTemplate<Schema>>;
|
|
163
|
-
default: undefined;
|
|
164
|
-
};
|
|
165
|
-
}>> & {
|
|
166
|
-
onInvalid?: ((...args: any[]) => any) | undefined;
|
|
167
|
-
onValid?: ((...args: any[]) => any) | undefined;
|
|
168
|
-
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
169
|
-
onSubmit?: ((...args: any[]) => any) | undefined;
|
|
170
|
-
"onUpdate:readonly"?: ((...args: any[]) => any) | undefined;
|
|
171
|
-
}, {
|
|
172
|
-
formData: Ref<Partial<z.TypeOf<Schema> | undefined>>;
|
|
173
|
-
submit: () => Promise<boolean>;
|
|
174
|
-
validate: (value?: Partial<z.TypeOf<Schema> | undefined>) => Promise<boolean>;
|
|
175
|
-
ignoreUpdates: IgnoredUpdater;
|
|
176
|
-
stopUpdatesWatch: WatchStopHandle;
|
|
177
|
-
errors: Readonly<Ref<DeepReadonly<z.inferFormattedError<Schema, string>> | undefined>>;
|
|
178
|
-
status: Readonly<Ref<FormStatus | undefined>>;
|
|
179
|
-
invalid: import("vue").ComputedRef<boolean>;
|
|
180
|
-
isReadonly: Ref<boolean>;
|
|
181
|
-
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("invalid" | "valid" | "update:modelValue" | "submit" | "update:readonly")[], "invalid" | "valid" | "update:modelValue" | "submit" | "update:readonly", {
|
|
182
|
-
readonly: boolean;
|
|
183
|
-
template: FormTemplate<Schema>;
|
|
184
|
-
modelValue: Record<string, any>;
|
|
185
|
-
continuosValidation: boolean;
|
|
186
|
-
tag: string;
|
|
187
|
-
}, {}, string, {}> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps & (new () => {
|
|
188
|
-
$slots: {
|
|
189
|
-
default: (_: {
|
|
190
|
-
formData: unknown extends Partial<z.TypeOf<Schema>> | undefined ? undefined : Partial<z.TypeOf<Schema>> | undefined;
|
|
191
|
-
submit: () => Promise<boolean>;
|
|
192
|
-
validate: () => Promise<boolean>;
|
|
193
|
-
ignoreUpdates: IgnoredUpdater;
|
|
194
|
-
stopUpdatesWatch: WatchStopHandle;
|
|
195
|
-
errors: Readonly<Ref<DeepReadonly<z.inferFormattedError<Schema, string>>>>;
|
|
196
|
-
status: Ref<DeepReadonly<`${FormStatus}` | undefined>>;
|
|
197
|
-
invalid: Ref<DeepReadonly<boolean>>;
|
|
198
|
-
readonly: Ref<boolean>;
|
|
199
|
-
}) => any;
|
|
200
|
-
};
|
|
201
|
-
});
|
|
202
|
-
};
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import { type Component, type InjectionKey, type PropType, type Ref, type ConcreteComponent } from 'vue';
|
|
2
|
-
import type { z } from 'zod';
|
|
3
|
-
import { FormFieldType } from './enums';
|
|
4
|
-
import type { InjectedFormData, InjectedFormWrapperData, InjectedFormFieldData, FormFieldComponentOptions, Path, FormSchema } from './types';
|
|
5
|
-
export declare const defineFormField: <Schema extends FormSchema>(formProvideKey: InjectionKey<InjectedFormData<Schema>>, wrapperProvideKey: InjectionKey<InjectedFormWrapperData<Schema>>, formFieldInjectionKey: InjectionKey<InjectedFormFieldData<Schema>>, options?: FormFieldComponentOptions) => import("vue").DefineComponent<{
|
|
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<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.TypeOf<Schema>> | undefined) | undefined>>;
|
|
21
|
-
default: () => {};
|
|
22
|
-
};
|
|
23
|
-
showValid: {
|
|
24
|
-
type: BooleanConstructor;
|
|
25
|
-
default: boolean;
|
|
26
|
-
};
|
|
27
|
-
defaultValue: {
|
|
28
|
-
type: (StringConstructor | ObjectConstructor | NumberConstructor | BooleanConstructor | ArrayConstructor)[];
|
|
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 ? import("@vue/shared").IfAny<V, V, D> : 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: {} | undefined;
|
|
60
|
-
'onUpdate:modelValue': (value: unknown) => void;
|
|
61
|
-
}>;
|
|
62
|
-
invalid: import("vue").ComputedRef<boolean>;
|
|
63
|
-
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("invalid" | "valid" | "update:formData" | "update:modelValue")[], "invalid" | "valid" | "update:formData" | "update:modelValue", 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<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.TypeOf<Schema>> | undefined) | undefined>>;
|
|
79
|
-
default: () => {};
|
|
80
|
-
};
|
|
81
|
-
showValid: {
|
|
82
|
-
type: BooleanConstructor;
|
|
83
|
-
default: boolean;
|
|
84
|
-
};
|
|
85
|
-
defaultValue: {
|
|
86
|
-
type: (StringConstructor | ObjectConstructor | NumberConstructor | BooleanConstructor | ArrayConstructor)[];
|
|
87
|
-
default: undefined;
|
|
88
|
-
};
|
|
89
|
-
lazyLoad: {
|
|
90
|
-
type: BooleanConstructor;
|
|
91
|
-
default: boolean;
|
|
92
|
-
};
|
|
93
|
-
readonly: {
|
|
94
|
-
type: BooleanConstructor;
|
|
95
|
-
default: undefined;
|
|
96
|
-
};
|
|
97
|
-
}>> & {
|
|
98
|
-
onInvalid?: ((...args: any[]) => any) | undefined;
|
|
99
|
-
onValid?: ((...args: any[]) => any) | undefined;
|
|
100
|
-
"onUpdate:formData"?: ((...args: any[]) => any) | undefined;
|
|
101
|
-
"onUpdate:modelValue"?: ((...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
|
-
props: [{
|
|
105
|
-
type: PropType<Partial<z.TypeOf<Schema> | ((formData?: Ref<ObjectConstructor>) => Partial<z.TypeOf<Schema>> | undefined) | undefined>>;
|
|
106
|
-
default: () => {};
|
|
107
|
-
}] extends [import("vue").Prop<infer V, infer D>] ? unknown extends V ? import("@vue/shared").IfAny<V, V, D> : V : {
|
|
108
|
-
type: PropType<Partial<z.TypeOf<Schema> | ((formData?: Ref<ObjectConstructor>) => Partial<z.TypeOf<Schema>> | undefined) | undefined>>;
|
|
109
|
-
default: () => {};
|
|
110
|
-
};
|
|
111
|
-
is: Component;
|
|
112
|
-
showValid: boolean;
|
|
113
|
-
defaultValue: string | number | boolean | unknown[] | Record<string, any>;
|
|
114
|
-
lazyLoad: boolean;
|
|
115
|
-
readonly: boolean;
|
|
116
|
-
}, {}>;
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { type Component, type PropType, type InjectionKey, type DeepReadonly, type Ref, type VNode } from 'vue';
|
|
2
|
-
import type { TypeOf, z } from 'zod';
|
|
3
|
-
import type { FormSchema, InjectedFormData, FormTemplate } from './types';
|
|
4
|
-
import type { FormStatus } from './enums';
|
|
5
|
-
export declare const defineFormTemplate: <Schema extends FormSchema>(formProvideKey: InjectionKey<InjectedFormData<Schema>>, VvFormField: Component) => {
|
|
6
|
-
new (...args: any[]): import("vue").CreateComponentPublicInstance<Readonly<import("vue").ExtractPropTypes<{
|
|
7
|
-
schema: {
|
|
8
|
-
type: PropType<FormTemplate<Schema>>;
|
|
9
|
-
required: true;
|
|
10
|
-
};
|
|
11
|
-
}>>, (() => (VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
12
|
-
[key: string]: any;
|
|
13
|
-
}> | VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
14
|
-
[key: string]: any;
|
|
15
|
-
}>[] | undefined)[]) | undefined, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps & Readonly<import("vue").ExtractPropTypes<{
|
|
16
|
-
schema: {
|
|
17
|
-
type: PropType<FormTemplate<Schema>>;
|
|
18
|
-
required: true;
|
|
19
|
-
};
|
|
20
|
-
}>>, {}, true, {}, {}, {
|
|
21
|
-
P: {};
|
|
22
|
-
B: {};
|
|
23
|
-
D: {};
|
|
24
|
-
C: {};
|
|
25
|
-
M: {};
|
|
26
|
-
Defaults: {};
|
|
27
|
-
}, Readonly<import("vue").ExtractPropTypes<{
|
|
28
|
-
schema: {
|
|
29
|
-
type: PropType<FormTemplate<Schema>>;
|
|
30
|
-
required: true;
|
|
31
|
-
};
|
|
32
|
-
}>>, {} | (() => (VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
33
|
-
[key: string]: any;
|
|
34
|
-
}> | VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
35
|
-
[key: string]: any;
|
|
36
|
-
}>[] | undefined)[]), {}, {}, {}, {}>;
|
|
37
|
-
__isFragment?: undefined;
|
|
38
|
-
__isTeleport?: undefined;
|
|
39
|
-
__isSuspense?: undefined;
|
|
40
|
-
} & import("vue").ComponentOptionsBase<Readonly<import("vue").ExtractPropTypes<{
|
|
41
|
-
schema: {
|
|
42
|
-
type: PropType<FormTemplate<Schema>>;
|
|
43
|
-
required: true;
|
|
44
|
-
};
|
|
45
|
-
}>>, (() => (VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
46
|
-
[key: string]: any;
|
|
47
|
-
}> | VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
48
|
-
[key: string]: any;
|
|
49
|
-
}>[] | undefined)[]) | undefined, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, {}, {}, string, {}> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps & (new () => {
|
|
50
|
-
$slots: {
|
|
51
|
-
default: (_: {
|
|
52
|
-
formData: unknown extends Partial<TypeOf<Schema>> | undefined ? undefined : Partial<TypeOf<Schema>> | undefined;
|
|
53
|
-
submit: () => Promise<boolean>;
|
|
54
|
-
validate: () => Promise<boolean>;
|
|
55
|
-
errors: Readonly<Ref<DeepReadonly<z.inferFormattedError<Schema, string>>>>;
|
|
56
|
-
status: Ref<DeepReadonly<`${FormStatus}` | undefined>>;
|
|
57
|
-
invalid: Ref<DeepReadonly<boolean>>;
|
|
58
|
-
}) => any;
|
|
59
|
-
};
|
|
60
|
-
});
|