@dazhicheng/ui 1.5.13 → 1.5.15
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/components/tt-modal-form/hooks/useModalFormSlot.d.ts +6 -0
- package/dist/components/tt-modal-form/index.d.ts +2 -0
- package/dist/components/tt-modal-form/index.vue.d.ts +43 -0
- package/dist/components/tt-modal-form/props.d.ts +38 -0
- package/dist/components/tt-modal-form/useModalForm.d.ts +6 -0
- package/dist/components/tt-upload/index.d.ts +450 -0
- package/dist/components/tt-upload/src/TtUpload.d.ts +471 -0
- package/dist/components/tt-upload/src/typing.d.ts +240 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +8413 -7892
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/dist/components/tt-validate/index.d.ts +0 -1
- package/dist/components/tt-validate/src/ErrorMessage.d.ts +0 -61
- package/dist/components/tt-validate/src/Field.d.ts +0 -430
- package/dist/components/tt-validate/src/FieldArray.d.ts +0 -47
- package/dist/components/tt-validate/src/Form.d.ts +0 -271
- package/dist/components/tt-validate/src/config.d.ts +0 -14
- package/dist/components/tt-validate/src/defineRule.d.ts +0 -9
- package/dist/components/tt-validate/src/index.d.ts +0 -36
- package/dist/components/tt-validate/src/symbols.d.ts +0 -6
- package/dist/components/tt-validate/src/types/common.d.ts +0 -11
- package/dist/components/tt-validate/src/types/forms.d.ts +0 -280
- package/dist/components/tt-validate/src/types/index.d.ts +0 -3
- package/dist/components/tt-validate/src/types/paths.d.ts +0 -142
- package/dist/components/tt-validate/src/types/shared.d.ts +0 -19
- package/dist/components/tt-validate/src/useField.d.ts +0 -30
- package/dist/components/tt-validate/src/useFieldArray.d.ts +0 -3
- package/dist/components/tt-validate/src/useFieldError.d.ts +0 -5
- package/dist/components/tt-validate/src/useFieldState.d.ts +0 -47
- package/dist/components/tt-validate/src/useFieldValue.d.ts +0 -5
- package/dist/components/tt-validate/src/useForm.d.ts +0 -23
- package/dist/components/tt-validate/src/useFormErrors.d.ts +0 -4
- package/dist/components/tt-validate/src/useFormValues.d.ts +0 -4
- package/dist/components/tt-validate/src/useIsFieldDirty.d.ts +0 -5
- package/dist/components/tt-validate/src/useIsFieldTouched.d.ts +0 -5
- package/dist/components/tt-validate/src/useIsFieldValid.d.ts +0 -5
- package/dist/components/tt-validate/src/useIsFormDirty.d.ts +0 -4
- package/dist/components/tt-validate/src/useIsFormTouched.d.ts +0 -4
- package/dist/components/tt-validate/src/useIsFormValid.d.ts +0 -4
- package/dist/components/tt-validate/src/useIsSubmitting.d.ts +0 -4
- package/dist/components/tt-validate/src/useIsValidating.d.ts +0 -4
- package/dist/components/tt-validate/src/useResetForm.d.ts +0 -2
- package/dist/components/tt-validate/src/useSetFieldError.d.ts +0 -5
- package/dist/components/tt-validate/src/useSetFieldTouched.d.ts +0 -5
- package/dist/components/tt-validate/src/useSetFieldValue.d.ts +0 -5
- package/dist/components/tt-validate/src/useSetFormErrors.d.ts +0 -4
- package/dist/components/tt-validate/src/useSetFormTouched.d.ts +0 -4
- package/dist/components/tt-validate/src/useSetFormValues.d.ts +0 -4
- package/dist/components/tt-validate/src/useSubmitCount.d.ts +0 -4
- package/dist/components/tt-validate/src/useSubmitForm.d.ts +0 -2
- package/dist/components/tt-validate/src/useValidateField.d.ts +0 -6
- package/dist/components/tt-validate/src/useValidateForm.d.ts +0 -5
- package/dist/components/tt-validate/src/utils/assertions.d.ts +0 -54
- package/dist/components/tt-validate/src/utils/common.d.ts +0 -48
- package/dist/components/tt-validate/src/utils/events.d.ts +0 -1
- package/dist/components/tt-validate/src/utils/index.d.ts +0 -5
- package/dist/components/tt-validate/src/utils/rules.d.ts +0 -13
- package/dist/components/tt-validate/src/utils/shared.d.ts +0 -19
- package/dist/components/tt-validate/src/utils/vnode.d.ts +0 -22
- package/dist/components/tt-validate/src/validate.d.ts +0 -21
- package/dist/components/tt-validate/zod/index.d.ts +0 -1
|
@@ -1,271 +0,0 @@
|
|
|
1
|
-
import { PropType, UnwrapRef, VNode } from 'vue';
|
|
2
|
-
import { FormContext, FormErrors, FormMeta, GenericObject, InvalidSubmissionHandler, SubmissionHandler } from './types';
|
|
3
|
-
export type FormSlotProps = UnwrapRef<Pick<FormContext, 'meta' | 'errors' | 'errorBag' | 'values' | 'isSubmitting' | 'isValidating' | 'submitCount' | 'validate' | 'validateField' | 'handleReset' | 'setErrors' | 'setFieldError' | 'setFieldValue' | 'setValues' | 'setFieldTouched' | 'setTouched' | 'resetForm' | 'resetField' | 'controlledValues'>> & {
|
|
4
|
-
handleSubmit: (evt: Event | SubmissionHandler, onSubmit?: SubmissionHandler) => Promise<unknown>;
|
|
5
|
-
submitForm: (evt?: Event) => void;
|
|
6
|
-
getValues: <TValues extends GenericObject = GenericObject>() => TValues;
|
|
7
|
-
getMeta: <TValues extends GenericObject = GenericObject>() => FormMeta<TValues>;
|
|
8
|
-
getErrors: <TValues extends GenericObject = GenericObject>() => FormErrors<TValues>;
|
|
9
|
-
};
|
|
10
|
-
declare const FormImpl: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
|
|
11
|
-
/**
|
|
12
|
-
* 指定表单组件渲染时使用的标签或组件名称。
|
|
13
|
-
* 默认为 'form',表示渲染为 HTML 的 form 标签。
|
|
14
|
-
* @type {string | null}
|
|
15
|
-
* @default 'form'
|
|
16
|
-
*/
|
|
17
|
-
as: {
|
|
18
|
-
type: PropType<string | null>;
|
|
19
|
-
default: string;
|
|
20
|
-
};
|
|
21
|
-
/**
|
|
22
|
-
* 表单验证的规则模式。
|
|
23
|
-
* 该对象定义了表单字段的验证规则。
|
|
24
|
-
* 默认值为 undefined,表示不使用验证模式。
|
|
25
|
-
* @type {object}
|
|
26
|
-
* @default undefined
|
|
27
|
-
*/
|
|
28
|
-
validationSchema: {
|
|
29
|
-
type: ObjectConstructor;
|
|
30
|
-
default: undefined;
|
|
31
|
-
};
|
|
32
|
-
/**
|
|
33
|
-
* 表单的初始值。
|
|
34
|
-
* 该对象包含表单字段的初始值。
|
|
35
|
-
* 默认值为 undefined,表示没有初始值。
|
|
36
|
-
* @type {object}
|
|
37
|
-
* @default undefined
|
|
38
|
-
*/
|
|
39
|
-
initialValues: {
|
|
40
|
-
type: ObjectConstructor;
|
|
41
|
-
default: undefined;
|
|
42
|
-
};
|
|
43
|
-
/**
|
|
44
|
-
* 表单的初始错误信息。
|
|
45
|
-
* 该对象包含表单字段的初始错误信息。
|
|
46
|
-
* 默认值为 undefined,表示没有初始错误。
|
|
47
|
-
* @type {object}
|
|
48
|
-
* @default undefined
|
|
49
|
-
*/
|
|
50
|
-
initialErrors: {
|
|
51
|
-
type: ObjectConstructor;
|
|
52
|
-
default: undefined;
|
|
53
|
-
};
|
|
54
|
-
/**
|
|
55
|
-
* 表单字段的初始触碰状态。
|
|
56
|
-
* 该对象包含表单字段的初始触碰状态。
|
|
57
|
-
* 默认值为 undefined,表示没有初始触碰状态。
|
|
58
|
-
* @type {object}
|
|
59
|
-
* @default undefined
|
|
60
|
-
*/
|
|
61
|
-
initialTouched: {
|
|
62
|
-
type: ObjectConstructor;
|
|
63
|
-
default: undefined;
|
|
64
|
-
};
|
|
65
|
-
/**
|
|
66
|
-
* 指示是否在表单挂载时进行验证。
|
|
67
|
-
* 如果设置为 true,则在表单挂载时立即验证表单。
|
|
68
|
-
* 默认值为 false。
|
|
69
|
-
* @type {boolean}
|
|
70
|
-
* @default false
|
|
71
|
-
*/
|
|
72
|
-
validateOnMount: {
|
|
73
|
-
type: BooleanConstructor;
|
|
74
|
-
default: boolean;
|
|
75
|
-
};
|
|
76
|
-
/**
|
|
77
|
-
* 表单提交时的回调函数。
|
|
78
|
-
* 该函数在表单提交且验证通过时调用。
|
|
79
|
-
* 默认值为 undefined,表示没有提交回调。
|
|
80
|
-
* @type {Function}
|
|
81
|
-
* @default undefined
|
|
82
|
-
*/
|
|
83
|
-
onSubmit: {
|
|
84
|
-
type: PropType<SubmissionHandler<GenericObject>>;
|
|
85
|
-
default: undefined;
|
|
86
|
-
};
|
|
87
|
-
/**
|
|
88
|
-
* 表单提交验证失败时的回调函数。
|
|
89
|
-
* 该函数在表单提交但验证不通过时调用。
|
|
90
|
-
* 默认值为 undefined,表示没有无效提交回调。
|
|
91
|
-
* @type {Function}
|
|
92
|
-
* @default undefined
|
|
93
|
-
*/
|
|
94
|
-
onInvalidSubmit: {
|
|
95
|
-
type: PropType<InvalidSubmissionHandler>;
|
|
96
|
-
default: undefined;
|
|
97
|
-
};
|
|
98
|
-
/**
|
|
99
|
-
* 指示是否在表单卸载时保留表单值。
|
|
100
|
-
* 如果设置为 true,则在表单卸载时保留表单值。
|
|
101
|
-
* 默认值为 false。
|
|
102
|
-
* @type {boolean}
|
|
103
|
-
* @default false
|
|
104
|
-
*/
|
|
105
|
-
keepValues: {
|
|
106
|
-
type: BooleanConstructor;
|
|
107
|
-
default: boolean;
|
|
108
|
-
};
|
|
109
|
-
/**
|
|
110
|
-
* 表单的名称。
|
|
111
|
-
* 用于标识表单,默认为 'Form'。
|
|
112
|
-
* @type {string}
|
|
113
|
-
* @default 'Form'
|
|
114
|
-
*/
|
|
115
|
-
name: {
|
|
116
|
-
type: StringConstructor;
|
|
117
|
-
default: string;
|
|
118
|
-
};
|
|
119
|
-
}>, () => VNode<import('vue').RendererNode, import('vue').RendererElement, {
|
|
120
|
-
[key: string]: any;
|
|
121
|
-
}> | VNode<import('vue').RendererNode, import('vue').RendererElement, {
|
|
122
|
-
[key: string]: any;
|
|
123
|
-
}>[] | {
|
|
124
|
-
default: () => VNode<import('vue').RendererNode, import('vue').RendererElement, {
|
|
125
|
-
[key: string]: any;
|
|
126
|
-
}>[] | undefined;
|
|
127
|
-
} | undefined, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
|
|
128
|
-
/**
|
|
129
|
-
* 指定表单组件渲染时使用的标签或组件名称。
|
|
130
|
-
* 默认为 'form',表示渲染为 HTML 的 form 标签。
|
|
131
|
-
* @type {string | null}
|
|
132
|
-
* @default 'form'
|
|
133
|
-
*/
|
|
134
|
-
as: {
|
|
135
|
-
type: PropType<string | null>;
|
|
136
|
-
default: string;
|
|
137
|
-
};
|
|
138
|
-
/**
|
|
139
|
-
* 表单验证的规则模式。
|
|
140
|
-
* 该对象定义了表单字段的验证规则。
|
|
141
|
-
* 默认值为 undefined,表示不使用验证模式。
|
|
142
|
-
* @type {object}
|
|
143
|
-
* @default undefined
|
|
144
|
-
*/
|
|
145
|
-
validationSchema: {
|
|
146
|
-
type: ObjectConstructor;
|
|
147
|
-
default: undefined;
|
|
148
|
-
};
|
|
149
|
-
/**
|
|
150
|
-
* 表单的初始值。
|
|
151
|
-
* 该对象包含表单字段的初始值。
|
|
152
|
-
* 默认值为 undefined,表示没有初始值。
|
|
153
|
-
* @type {object}
|
|
154
|
-
* @default undefined
|
|
155
|
-
*/
|
|
156
|
-
initialValues: {
|
|
157
|
-
type: ObjectConstructor;
|
|
158
|
-
default: undefined;
|
|
159
|
-
};
|
|
160
|
-
/**
|
|
161
|
-
* 表单的初始错误信息。
|
|
162
|
-
* 该对象包含表单字段的初始错误信息。
|
|
163
|
-
* 默认值为 undefined,表示没有初始错误。
|
|
164
|
-
* @type {object}
|
|
165
|
-
* @default undefined
|
|
166
|
-
*/
|
|
167
|
-
initialErrors: {
|
|
168
|
-
type: ObjectConstructor;
|
|
169
|
-
default: undefined;
|
|
170
|
-
};
|
|
171
|
-
/**
|
|
172
|
-
* 表单字段的初始触碰状态。
|
|
173
|
-
* 该对象包含表单字段的初始触碰状态。
|
|
174
|
-
* 默认值为 undefined,表示没有初始触碰状态。
|
|
175
|
-
* @type {object}
|
|
176
|
-
* @default undefined
|
|
177
|
-
*/
|
|
178
|
-
initialTouched: {
|
|
179
|
-
type: ObjectConstructor;
|
|
180
|
-
default: undefined;
|
|
181
|
-
};
|
|
182
|
-
/**
|
|
183
|
-
* 指示是否在表单挂载时进行验证。
|
|
184
|
-
* 如果设置为 true,则在表单挂载时立即验证表单。
|
|
185
|
-
* 默认值为 false。
|
|
186
|
-
* @type {boolean}
|
|
187
|
-
* @default false
|
|
188
|
-
*/
|
|
189
|
-
validateOnMount: {
|
|
190
|
-
type: BooleanConstructor;
|
|
191
|
-
default: boolean;
|
|
192
|
-
};
|
|
193
|
-
/**
|
|
194
|
-
* 表单提交时的回调函数。
|
|
195
|
-
* 该函数在表单提交且验证通过时调用。
|
|
196
|
-
* 默认值为 undefined,表示没有提交回调。
|
|
197
|
-
* @type {Function}
|
|
198
|
-
* @default undefined
|
|
199
|
-
*/
|
|
200
|
-
onSubmit: {
|
|
201
|
-
type: PropType<SubmissionHandler<GenericObject>>;
|
|
202
|
-
default: undefined;
|
|
203
|
-
};
|
|
204
|
-
/**
|
|
205
|
-
* 表单提交验证失败时的回调函数。
|
|
206
|
-
* 该函数在表单提交但验证不通过时调用。
|
|
207
|
-
* 默认值为 undefined,表示没有无效提交回调。
|
|
208
|
-
* @type {Function}
|
|
209
|
-
* @default undefined
|
|
210
|
-
*/
|
|
211
|
-
onInvalidSubmit: {
|
|
212
|
-
type: PropType<InvalidSubmissionHandler>;
|
|
213
|
-
default: undefined;
|
|
214
|
-
};
|
|
215
|
-
/**
|
|
216
|
-
* 指示是否在表单卸载时保留表单值。
|
|
217
|
-
* 如果设置为 true,则在表单卸载时保留表单值。
|
|
218
|
-
* 默认值为 false。
|
|
219
|
-
* @type {boolean}
|
|
220
|
-
* @default false
|
|
221
|
-
*/
|
|
222
|
-
keepValues: {
|
|
223
|
-
type: BooleanConstructor;
|
|
224
|
-
default: boolean;
|
|
225
|
-
};
|
|
226
|
-
/**
|
|
227
|
-
* 表单的名称。
|
|
228
|
-
* 用于标识表单,默认为 'Form'。
|
|
229
|
-
* @type {string}
|
|
230
|
-
* @default 'Form'
|
|
231
|
-
*/
|
|
232
|
-
name: {
|
|
233
|
-
type: StringConstructor;
|
|
234
|
-
default: string;
|
|
235
|
-
};
|
|
236
|
-
}>> & Readonly<{}>, {
|
|
237
|
-
onSubmit: SubmissionHandler<GenericObject>;
|
|
238
|
-
name: string;
|
|
239
|
-
initialValues: Record<string, any>;
|
|
240
|
-
as: string | null;
|
|
241
|
-
validateOnMount: boolean;
|
|
242
|
-
validationSchema: Record<string, any>;
|
|
243
|
-
initialErrors: Record<string, any>;
|
|
244
|
-
initialTouched: Record<string, any>;
|
|
245
|
-
onInvalidSubmit: InvalidSubmissionHandler;
|
|
246
|
-
keepValues: boolean;
|
|
247
|
-
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
248
|
-
export declare const Form: typeof FormImpl & {
|
|
249
|
-
new (): {
|
|
250
|
-
setFieldError: FormContext["setFieldError"];
|
|
251
|
-
setErrors: FormContext["setErrors"];
|
|
252
|
-
setFieldValue: FormContext["setFieldValue"];
|
|
253
|
-
setValues: FormContext["setValues"];
|
|
254
|
-
setFieldTouched: FormContext["setFieldTouched"];
|
|
255
|
-
setTouched: FormContext["setTouched"];
|
|
256
|
-
resetForm: FormContext["resetForm"];
|
|
257
|
-
resetField: FormContext["resetField"];
|
|
258
|
-
validate: FormContext["validate"];
|
|
259
|
-
validateField: FormContext["validateField"];
|
|
260
|
-
getValues: FormSlotProps["getValues"];
|
|
261
|
-
getMeta: FormSlotProps["getMeta"];
|
|
262
|
-
getErrors: FormSlotProps["getErrors"];
|
|
263
|
-
meta: FormSlotProps["meta"];
|
|
264
|
-
values: FormSlotProps["values"];
|
|
265
|
-
errors: FormSlotProps["errors"];
|
|
266
|
-
$slots: {
|
|
267
|
-
default: (arg: FormSlotProps) => VNode[];
|
|
268
|
-
};
|
|
269
|
-
};
|
|
270
|
-
};
|
|
271
|
-
export {};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { ValidationMessageGenerator } from './types/shared';
|
|
2
|
-
export type VeeValidateConfig = {
|
|
3
|
-
bails: boolean;
|
|
4
|
-
generateMessage: ValidationMessageGenerator;
|
|
5
|
-
validateOnInput: boolean;
|
|
6
|
-
validateOnChange: boolean;
|
|
7
|
-
validateOnBlur: boolean;
|
|
8
|
-
validateOnModelUpdate: boolean;
|
|
9
|
-
};
|
|
10
|
-
export declare let currentConfig: VeeValidateConfig;
|
|
11
|
-
export declare const getConfig: () => VeeValidateConfig;
|
|
12
|
-
declare function setConfig(newConf: Partial<VeeValidateConfig>): void;
|
|
13
|
-
export declare const configure: typeof setConfig;
|
|
14
|
-
export {};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { SimpleValidationRuleFunction, ValidationRuleFunction } from './types/shared';
|
|
2
|
-
/**
|
|
3
|
-
* Adds a custom validator to the list of validation rules.
|
|
4
|
-
*/
|
|
5
|
-
export declare function defineRule<TValue = unknown, TParams = any[] | Record<string, any>>(id: string, validator: ValidationRuleFunction<TValue, TParams> | SimpleValidationRuleFunction<TValue, TParams>): void;
|
|
6
|
-
/**
|
|
7
|
-
* Gets an already defined rule
|
|
8
|
-
*/
|
|
9
|
-
export declare function resolveRule(id: string): ValidationRuleFunction | SimpleValidationRuleFunction | undefined;
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
export { configure } from './config';
|
|
2
|
-
export { defineRule } from './defineRule';
|
|
3
|
-
export { ErrorMessage } from './ErrorMessage';
|
|
4
|
-
export { type ComponentFieldBindingObject, Field, type FieldBindingObject, type FieldSlotProps, } from './Field';
|
|
5
|
-
export { FieldArray } from './FieldArray';
|
|
6
|
-
export { Form, type FormSlotProps } from './Form';
|
|
7
|
-
export * from './symbols';
|
|
8
|
-
export * from './types';
|
|
9
|
-
export { type FieldOptions, type RuleExpression, useField } from './useField';
|
|
10
|
-
export { useFieldArray } from './useFieldArray';
|
|
11
|
-
export { useFieldError } from './useFieldError';
|
|
12
|
-
export { useFieldValue } from './useFieldValue';
|
|
13
|
-
export { type FormOptions, useForm, useFormContext } from './useForm';
|
|
14
|
-
export { useFormErrors } from './useFormErrors';
|
|
15
|
-
export { useFormValues } from './useFormValues';
|
|
16
|
-
export { useIsFieldDirty } from './useIsFieldDirty';
|
|
17
|
-
export { useIsFieldTouched } from './useIsFieldTouched';
|
|
18
|
-
export { useIsFieldValid } from './useIsFieldValid';
|
|
19
|
-
export { useIsFormDirty } from './useIsFormDirty';
|
|
20
|
-
export { useIsFormTouched } from './useIsFormTouched';
|
|
21
|
-
export { useIsFormValid } from './useIsFormValid';
|
|
22
|
-
export { useIsSubmitting } from './useIsSubmitting';
|
|
23
|
-
export { useIsValidating } from './useIsValidating';
|
|
24
|
-
export { useResetForm } from './useResetForm';
|
|
25
|
-
export { useSetFieldError } from './useSetFieldError';
|
|
26
|
-
export { useSetFieldTouched } from './useSetFieldTouched';
|
|
27
|
-
export { useSetFieldValue } from './useSetFieldValue';
|
|
28
|
-
export { useSetFormErrors } from './useSetFormErrors';
|
|
29
|
-
export { useSetFormTouched } from './useSetFormTouched';
|
|
30
|
-
export { useSetFormValues } from './useSetFormValues';
|
|
31
|
-
export { useSubmitCount } from './useSubmitCount';
|
|
32
|
-
export { useSubmitForm } from './useSubmitForm';
|
|
33
|
-
export { useValidateField } from './useValidateField';
|
|
34
|
-
export { useValidateForm } from './useValidateForm';
|
|
35
|
-
export { cleanupNonNestedPath, isNotNestedPath, normalizeRules } from './utils';
|
|
36
|
-
export { validate, validateObjectSchema as validateObject } from './validate';
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { InjectionKey } from 'vue';
|
|
2
|
-
import { FormContext, PrivateFieldContext, PrivateFormContext } from './types';
|
|
3
|
-
export declare const FormContextKey: InjectionKey<PrivateFormContext>;
|
|
4
|
-
export declare const PublicFormContextKey: InjectionKey<FormContext>;
|
|
5
|
-
export declare const FieldContextKey: InjectionKey<PrivateFieldContext<unknown>>;
|
|
6
|
-
export declare const IS_ABSENT: unique symbol;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { MaybeRef, Ref } from 'vue';
|
|
2
|
-
import { Path, PathValue } from './paths';
|
|
3
|
-
export type GenericObject = Record<string, any>;
|
|
4
|
-
export type MaybeArray<T> = T | T[];
|
|
5
|
-
export type MaybePromise<T> = T | Promise<T>;
|
|
6
|
-
export type FlattenAndSetPathsType<TRecord, TType> = {
|
|
7
|
-
[K in Path<TRecord>]: TType;
|
|
8
|
-
};
|
|
9
|
-
export type MapValuesPathsToRefs<TValues extends GenericObject, TPaths extends readonly [...MaybeRef<Path<TValues>>[]]> = {
|
|
10
|
-
readonly [K in keyof TPaths]: TPaths[K] extends MaybeRef<infer TKey> ? TKey extends Path<TValues> ? Ref<PathValue<TValues, TKey>> : Ref<unknown> : Ref<unknown>;
|
|
11
|
-
};
|
|
@@ -1,280 +0,0 @@
|
|
|
1
|
-
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
2
|
-
import { PartialDeep } from 'type-fest';
|
|
3
|
-
import { ComputedRef, MaybeRef, MaybeRefOrGetter, Ref } from 'vue';
|
|
4
|
-
import { FlattenAndSetPathsType, GenericObject, MapValuesPathsToRefs, MaybeArray, MaybePromise } from './common';
|
|
5
|
-
import { Path, PathValue } from './paths';
|
|
6
|
-
import { FieldValidationMetaInfo } from './shared';
|
|
7
|
-
export type ValidationResult<TValue = unknown> = {
|
|
8
|
-
errors: string[];
|
|
9
|
-
valid: boolean;
|
|
10
|
-
value?: TValue;
|
|
11
|
-
};
|
|
12
|
-
export type FlattenAndMapPathsValidationResult<TInput extends GenericObject, TOutput extends GenericObject> = {
|
|
13
|
-
[K in Path<TInput>]: ValidationResult<TOutput[K]>;
|
|
14
|
-
};
|
|
15
|
-
export type Locator = {
|
|
16
|
-
__locatorRef: string;
|
|
17
|
-
} & ((values: GenericObject) => unknown);
|
|
18
|
-
export interface FieldMeta<TValue> {
|
|
19
|
-
touched: boolean;
|
|
20
|
-
dirty: boolean;
|
|
21
|
-
valid: boolean;
|
|
22
|
-
validated: boolean;
|
|
23
|
-
pending: boolean;
|
|
24
|
-
initialValue?: TValue;
|
|
25
|
-
}
|
|
26
|
-
export interface FormMeta<TValues extends GenericObject> {
|
|
27
|
-
touched: boolean;
|
|
28
|
-
dirty: boolean;
|
|
29
|
-
valid: boolean;
|
|
30
|
-
pending: boolean;
|
|
31
|
-
initialValues?: Partial<TValues>;
|
|
32
|
-
}
|
|
33
|
-
export interface FieldState<TValue = unknown> {
|
|
34
|
-
value: TValue;
|
|
35
|
-
touched: boolean;
|
|
36
|
-
errors: string[];
|
|
37
|
-
}
|
|
38
|
-
export type InputType = 'checkbox' | 'radio' | 'default';
|
|
39
|
-
/**
|
|
40
|
-
* validated-only: only mutate the previously validated fields
|
|
41
|
-
* silent: do not mutate any field
|
|
42
|
-
* force: validate all fields and mutate their state
|
|
43
|
-
*/
|
|
44
|
-
export type SchemaValidationMode = 'validated-only' | 'silent' | 'force' | 'no-validated';
|
|
45
|
-
export type ValidationOptions = {
|
|
46
|
-
mode: SchemaValidationMode;
|
|
47
|
-
warn: boolean;
|
|
48
|
-
};
|
|
49
|
-
export type FieldValidator<TOutput> = (opts?: Partial<ValidationOptions>) => Promise<ValidationResult<TOutput>>;
|
|
50
|
-
export type PathStateConfig<TOutput> = {
|
|
51
|
-
bails: boolean;
|
|
52
|
-
label: MaybeRefOrGetter<string | undefined>;
|
|
53
|
-
type: InputType;
|
|
54
|
-
validate: FieldValidator<TOutput>;
|
|
55
|
-
schema?: MaybeRefOrGetter<StandardSchemaV1 | undefined>;
|
|
56
|
-
/**
|
|
57
|
-
* 在判断 dirty 状态时需要排除的字段列表(仅对对象类型有效)
|
|
58
|
-
* @example
|
|
59
|
-
* excludeKeys: ['_timestamp']
|
|
60
|
-
*/
|
|
61
|
-
excludeKeys?: string[];
|
|
62
|
-
};
|
|
63
|
-
export type IssueCollection<TPath = string> = {
|
|
64
|
-
path: TPath;
|
|
65
|
-
messages: string[];
|
|
66
|
-
};
|
|
67
|
-
export type PathState<TInput = unknown, TOutput = TInput> = {
|
|
68
|
-
id: number | number[];
|
|
69
|
-
path: string;
|
|
70
|
-
touched: boolean;
|
|
71
|
-
dirty: boolean;
|
|
72
|
-
valid: boolean;
|
|
73
|
-
validated: boolean;
|
|
74
|
-
pending: boolean;
|
|
75
|
-
initialValue: TInput | undefined;
|
|
76
|
-
value: TInput | undefined;
|
|
77
|
-
errors: string[];
|
|
78
|
-
bails: boolean;
|
|
79
|
-
label: string | undefined;
|
|
80
|
-
type: InputType;
|
|
81
|
-
multiple: boolean;
|
|
82
|
-
fieldsCount: number;
|
|
83
|
-
__flags: {
|
|
84
|
-
pendingUnmount: Record<string, boolean>;
|
|
85
|
-
pendingReset: boolean;
|
|
86
|
-
};
|
|
87
|
-
validate?: FieldValidator<TOutput>;
|
|
88
|
-
};
|
|
89
|
-
export type FieldEntry<TValue = unknown> = {
|
|
90
|
-
value: TValue;
|
|
91
|
-
key: string | number;
|
|
92
|
-
isFirst: boolean;
|
|
93
|
-
isLast: boolean;
|
|
94
|
-
};
|
|
95
|
-
export type FieldArrayContext<TValue = unknown> = {
|
|
96
|
-
fields: Ref<FieldEntry<TValue>[]>;
|
|
97
|
-
remove: (idx: number) => void;
|
|
98
|
-
replace: (newArray: TValue[]) => void;
|
|
99
|
-
update: (idx: number, value: TValue) => void;
|
|
100
|
-
push: (value: TValue) => void;
|
|
101
|
-
swap: (indexA: number, indexB: number) => void;
|
|
102
|
-
insert: (idx: number, value: TValue) => void;
|
|
103
|
-
prepend: (value: TValue) => void;
|
|
104
|
-
move: (oldIdx: number, newIdx: number) => void;
|
|
105
|
-
};
|
|
106
|
-
export type PrivateFieldArrayContext<TValue = unknown> = {
|
|
107
|
-
reset: () => void;
|
|
108
|
-
path: MaybeRefOrGetter<string>;
|
|
109
|
-
} & FieldArrayContext<TValue>;
|
|
110
|
-
export type PrivateFieldContext<TInput = unknown, TOutput = TInput> = {
|
|
111
|
-
id: number;
|
|
112
|
-
name: MaybeRef<string>;
|
|
113
|
-
value: Ref<TInput>;
|
|
114
|
-
meta: FieldMeta<TInput>;
|
|
115
|
-
errors: Ref<string[]>;
|
|
116
|
-
errorMessage: Ref<string | undefined>;
|
|
117
|
-
label?: MaybeRefOrGetter<string | undefined>;
|
|
118
|
-
type?: string;
|
|
119
|
-
bails?: boolean;
|
|
120
|
-
keepValueOnUnmount?: MaybeRefOrGetter<boolean | undefined>;
|
|
121
|
-
checkedValue?: MaybeRefOrGetter<TInput>;
|
|
122
|
-
uncheckedValue?: MaybeRefOrGetter<TInput>;
|
|
123
|
-
checked?: Ref<boolean>;
|
|
124
|
-
resetField: (state?: Partial<FieldState<TInput>>) => void;
|
|
125
|
-
handleReset: () => void;
|
|
126
|
-
validate: FieldValidator<TOutput>;
|
|
127
|
-
handleChange: (e: Event | unknown, shouldValidate?: boolean) => void;
|
|
128
|
-
handleBlur: (e?: Event, shouldValidate?: boolean) => void;
|
|
129
|
-
handleFocus: (e?: Event) => void;
|
|
130
|
-
setState: (state: Partial<FieldState<TInput>>) => void;
|
|
131
|
-
setTouched: (isTouched: boolean) => void;
|
|
132
|
-
setErrors: (message: string | string[]) => void;
|
|
133
|
-
setValue: (value: TInput, shouldValidate?: boolean) => void;
|
|
134
|
-
};
|
|
135
|
-
export type FieldContext<TValue = unknown> = Omit<PrivateFieldContext<TValue>, 'id' | 'instances'>;
|
|
136
|
-
export type GenericValidateFunction<TValue = unknown> = (value: TValue, ctx: FieldValidationMetaInfo) => MaybePromise<boolean | MaybeArray<string>>;
|
|
137
|
-
export interface FormState<TValues> {
|
|
138
|
-
values: PartialDeep<TValues>;
|
|
139
|
-
errors: Partial<Record<Path<TValues>, string | undefined>>;
|
|
140
|
-
touched: Partial<Record<Path<TValues>, boolean>>;
|
|
141
|
-
submitCount: number;
|
|
142
|
-
}
|
|
143
|
-
export type FormErrors<TValues extends GenericObject> = Partial<Record<Path<TValues> | '', string | undefined>>;
|
|
144
|
-
export type FormErrorBag<TValues extends GenericObject> = Partial<Record<Path<TValues> | '', string[]>>;
|
|
145
|
-
export interface ResetFormOpts {
|
|
146
|
-
force?: boolean;
|
|
147
|
-
}
|
|
148
|
-
export interface FormActions<TValues extends GenericObject, _TOutput = TValues> {
|
|
149
|
-
setFieldValue: <T extends Path<TValues>>(field: T, value: PathValue<TValues, T>, shouldValidate?: boolean) => void;
|
|
150
|
-
setFieldError: (field: Path<TValues>, message: string | string[] | undefined) => void;
|
|
151
|
-
setErrors: (fields: Partial<FlattenAndSetPathsType<TValues, string | string[] | undefined>>) => void;
|
|
152
|
-
setValues: (fields: Partial<TValues>, shouldValidate?: boolean) => void;
|
|
153
|
-
setFieldTouched: (field: Path<TValues>, isTouched: boolean) => void;
|
|
154
|
-
setTouched: (fields: Partial<Record<Path<TValues>, boolean>> | boolean) => void;
|
|
155
|
-
resetForm: (state?: Partial<FormState<TValues>>, opts?: Partial<ResetFormOpts>) => void;
|
|
156
|
-
resetField: (field: Path<TValues>, state?: Partial<FieldState>) => void;
|
|
157
|
-
}
|
|
158
|
-
export interface FormValidationResult<TInput extends GenericObject, TOutput extends GenericObject = TInput> {
|
|
159
|
-
valid: boolean;
|
|
160
|
-
results: Partial<FlattenAndMapPathsValidationResult<TInput, TOutput>>;
|
|
161
|
-
errors: Partial<Record<Path<TInput>, string>>;
|
|
162
|
-
values?: Partial<TOutput>;
|
|
163
|
-
source: 'schema' | 'fields' | 'none';
|
|
164
|
-
}
|
|
165
|
-
export interface SubmissionContext<TInput extends GenericObject = GenericObject> extends FormActions<TInput> {
|
|
166
|
-
evt?: Event;
|
|
167
|
-
controlledValues: Partial<TInput>;
|
|
168
|
-
}
|
|
169
|
-
export type SubmissionHandler<TInput extends GenericObject = GenericObject, TOutput = TInput, TReturn = unknown> = (values: TOutput, ctx: SubmissionContext<TInput>) => TReturn;
|
|
170
|
-
export interface InvalidSubmissionContext<TInput extends GenericObject = GenericObject, TOutput extends GenericObject = TInput> {
|
|
171
|
-
values: TInput;
|
|
172
|
-
evt?: Event;
|
|
173
|
-
errors: Partial<Record<Path<TInput>, string>>;
|
|
174
|
-
results: FormValidationResult<TInput, TOutput>['results'];
|
|
175
|
-
}
|
|
176
|
-
export type InvalidSubmissionHandler<TInput extends GenericObject = GenericObject, TOutput extends GenericObject = TInput> = (ctx: InvalidSubmissionContext<TInput, TOutput>) => void;
|
|
177
|
-
export type RawFormSchema<TValues> = Record<Path<TValues>, string | GenericValidateFunction | GenericObject>;
|
|
178
|
-
export type FieldPathLookup<TValues extends GenericObject = GenericObject> = Partial<Record<Path<TValues>, PrivateFieldContext | PrivateFieldContext[]>>;
|
|
179
|
-
type HandleSubmitFactory<TValues extends GenericObject, TOutput extends GenericObject = TValues> = <TReturn = unknown>(cb: SubmissionHandler<TValues, TOutput, TReturn>, onSubmitValidationErrorCb?: InvalidSubmissionHandler<TValues, TOutput>) => (e?: Event) => Promise<TReturn | undefined>;
|
|
180
|
-
export type PublicPathState<TValue = unknown> = Omit<PathState<TValue>, 'bails' | 'label' | 'multiple' | 'fieldsCount' | 'validate' | 'id' | 'type' | '__flags'>;
|
|
181
|
-
export interface BaseFieldProps {
|
|
182
|
-
onBlur: () => void;
|
|
183
|
-
onChange: () => void;
|
|
184
|
-
onInput: () => void;
|
|
185
|
-
}
|
|
186
|
-
export interface InputBindsConfig<TValue = unknown, TExtraProps extends GenericObject = GenericObject> {
|
|
187
|
-
props: (state: PublicPathState<TValue>) => TExtraProps;
|
|
188
|
-
validateOnBlur: boolean;
|
|
189
|
-
label: MaybeRefOrGetter<string>;
|
|
190
|
-
validateOnChange: boolean;
|
|
191
|
-
validateOnInput: boolean;
|
|
192
|
-
validateOnModelUpdate: boolean;
|
|
193
|
-
}
|
|
194
|
-
export type LazyInputBindsConfig<TValue = unknown, TExtraProps extends GenericObject = GenericObject> = (state: PublicPathState<TValue>) => Partial<{
|
|
195
|
-
props: TExtraProps;
|
|
196
|
-
validateOnBlur: boolean;
|
|
197
|
-
validateOnChange: boolean;
|
|
198
|
-
validateOnInput: boolean;
|
|
199
|
-
validateOnModelUpdate: boolean;
|
|
200
|
-
}>;
|
|
201
|
-
export interface ComponentBindsConfig<TValue = unknown, TExtraProps extends GenericObject = GenericObject, TModel extends string = 'modelValue'> {
|
|
202
|
-
mapProps: (state: PublicPathState<TValue>) => TExtraProps;
|
|
203
|
-
validateOnBlur: boolean;
|
|
204
|
-
validateOnModelUpdate: boolean;
|
|
205
|
-
model: TModel;
|
|
206
|
-
}
|
|
207
|
-
export type LazyComponentBindsConfig<TValue = unknown, TExtraProps extends GenericObject = GenericObject, TModel extends string = 'modelValue'> = (state: PublicPathState<TValue>) => Partial<{
|
|
208
|
-
props: TExtraProps;
|
|
209
|
-
validateOnBlur: boolean;
|
|
210
|
-
validateOnModelUpdate: boolean;
|
|
211
|
-
model: TModel;
|
|
212
|
-
}>;
|
|
213
|
-
export interface ComponentModellessBinds {
|
|
214
|
-
onBlur: () => void;
|
|
215
|
-
}
|
|
216
|
-
export type ComponentModelBinds<TValue = any, TModel extends string = 'modelValue'> = ComponentModellessBinds & {
|
|
217
|
-
[TKey in `onUpdate:${TModel}`]: (value: TValue) => void;
|
|
218
|
-
};
|
|
219
|
-
export type BaseComponentBinds<TValue = any, TModel extends string = 'modelValue'> = ComponentModelBinds<TValue, TModel> & {
|
|
220
|
-
[k in TModel]: TValue;
|
|
221
|
-
};
|
|
222
|
-
export interface BaseInputBinds<TValue = unknown> {
|
|
223
|
-
value: TValue | undefined;
|
|
224
|
-
onBlur: (e: Event) => void;
|
|
225
|
-
onChange: (e: Event) => void;
|
|
226
|
-
onInput: (e: Event) => void;
|
|
227
|
-
}
|
|
228
|
-
export interface PrivateFormContext<TValues extends GenericObject = GenericObject, TOutput extends GenericObject = TValues> extends FormActions<TValues> {
|
|
229
|
-
name: string;
|
|
230
|
-
formId: number;
|
|
231
|
-
values: TValues;
|
|
232
|
-
initialValues: Ref<Partial<TValues>>;
|
|
233
|
-
controlledValues: Ref<TValues>;
|
|
234
|
-
fieldArrays: PrivateFieldArrayContext[];
|
|
235
|
-
submitCount: Ref<number>;
|
|
236
|
-
schema?: MaybeRef<RawFormSchema<TValues> | StandardSchemaV1<TValues, TOutput> | undefined>;
|
|
237
|
-
errorBag: Ref<FormErrorBag<TValues>>;
|
|
238
|
-
errors: ComputedRef<FormErrors<TValues>>;
|
|
239
|
-
meta: ComputedRef<FormMeta<TValues>>;
|
|
240
|
-
isSubmitting: Ref<boolean>;
|
|
241
|
-
isValidating: Ref<boolean>;
|
|
242
|
-
keepValuesOnUnmount: MaybeRef<boolean>;
|
|
243
|
-
validateSchema?: (mode: SchemaValidationMode) => Promise<FormValidationResult<TValues, TOutput>>;
|
|
244
|
-
validate: (opts?: Partial<ValidationOptions>) => Promise<FormValidationResult<TValues, TOutput>>;
|
|
245
|
-
validateField: <TPath extends Path<TValues>>(field: TPath, opts?: Partial<ValidationOptions>) => Promise<ValidationResult<TOutput[TPath]>>;
|
|
246
|
-
stageInitialValue: (path: string, value: unknown, updateOriginal?: boolean) => void;
|
|
247
|
-
unsetInitialValue: (path: string) => void;
|
|
248
|
-
handleSubmit: HandleSubmitFactory<TValues, TOutput> & {
|
|
249
|
-
withControlled: HandleSubmitFactory<TValues, TOutput>;
|
|
250
|
-
};
|
|
251
|
-
setFieldInitialValue: (path: string, value: unknown, updateOriginal?: boolean) => void;
|
|
252
|
-
createPathState: <TPath extends Path<TValues>>(path: MaybeRef<TPath>, config?: Partial<PathStateConfig<TOutput[TPath]>>) => PathState<PathValue<TValues, TPath>>;
|
|
253
|
-
getPathState: <TPath extends Path<TValues>>(path: TPath) => PathState<PathValue<TValues, TPath>> | undefined;
|
|
254
|
-
getAllPathStates: () => PathState[];
|
|
255
|
-
removePathState: <TPath extends Path<TValues>>(path: TPath, id: number) => void;
|
|
256
|
-
unsetPathValue: <TPath extends Path<TValues>>(path: TPath) => void;
|
|
257
|
-
destroyPath: (path: string) => void;
|
|
258
|
-
isFieldTouched: <TPath extends Path<TValues>>(path: TPath) => boolean;
|
|
259
|
-
isFieldDirty: <TPath extends Path<TValues>>(path: TPath) => boolean;
|
|
260
|
-
isFieldValid: <TPath extends Path<TValues>>(path: TPath) => boolean;
|
|
261
|
-
defineField: <TPath extends Path<TValues>, TValue = PathValue<TValues, TPath>, TExtras extends GenericObject = GenericObject>(path: MaybeRefOrGetter<TPath>, config?: Partial<InputBindsConfig<TValue, TExtras>> | LazyInputBindsConfig<TValue, TExtras>) => [Ref<TValue>, Ref<BaseFieldProps & TExtras>];
|
|
262
|
-
/**
|
|
263
|
-
* @deprecated use defineField instead
|
|
264
|
-
*/
|
|
265
|
-
useFieldModel: (<TPath extends Path<TValues>>(path: TPath) => Ref<PathValue<TValues, TPath>>) & (<TPaths extends readonly [...MaybeRef<Path<TValues>>[]]>(paths: TPaths) => MapValuesPathsToRefs<TValues, TPaths>);
|
|
266
|
-
/**
|
|
267
|
-
* @deprecated use defineField instead
|
|
268
|
-
*/
|
|
269
|
-
defineComponentBinds: <TPath extends Path<TValues>, TValue = PathValue<TValues, TPath>, TModel extends string = 'modelValue', TExtras extends GenericObject = GenericObject>(path: MaybeRefOrGetter<TPath>, config?: Partial<ComponentBindsConfig<TValue, TExtras, TModel>> | LazyComponentBindsConfig<TValue, TExtras, TModel>) => Ref<BaseComponentBinds<TValue, TModel> & TExtras>;
|
|
270
|
-
/**
|
|
271
|
-
* @deprecated use defineField instead
|
|
272
|
-
*/
|
|
273
|
-
defineInputBinds: <TPath extends Path<TValues>, TValue = PathValue<TValues, TPath>, TExtras extends GenericObject = GenericObject>(path: MaybeRefOrGetter<TPath>, config?: Partial<InputBindsConfig<TValue, TExtras>> | LazyInputBindsConfig<TValue, TExtras>) => Ref<BaseInputBinds<TValue> & TExtras>;
|
|
274
|
-
}
|
|
275
|
-
export interface FormContext<TValues extends GenericObject = GenericObject, TOutput extends GenericObject = TValues> extends Omit<PrivateFormContext<TValues, TOutput>, 'formId' | 'schema' | 'initialValues' | 'getPathState' | 'getAllPathStates' | 'removePathState' | 'unsetPathValue' | 'validateSchema' | 'stageInitialValue' | 'setFieldInitialValue' | 'unsetInitialValue' | 'fieldArrays' | 'markForUnmount' | 'keepValuesOnUnmount' | 'values'> {
|
|
276
|
-
values: TValues;
|
|
277
|
-
handleReset: () => void;
|
|
278
|
-
submitForm: (e?: unknown) => Promise<void>;
|
|
279
|
-
}
|
|
280
|
-
export {};
|