types(Field): expose sub-types of FieldRule (#9843)

* types(Field): expose sub-types of FieldRule

* types: update
This commit is contained in:
neverland 2021-11-11 20:37:13 +08:00 committed by GitHub
parent ca41a57f30
commit c65e336bf6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 28 additions and 18 deletions

View File

@ -7,13 +7,9 @@ export type CheckboxLabelPosition = CheckerLabelPosition;
export type CheckboxExpose = { export type CheckboxExpose = {
toggle: (newValue?: boolean) => void; toggle: (newValue?: boolean) => void;
/** /** @private */
* @private
*/
props: CheckboxProps; props: CheckboxProps;
/** /** @private */
* @private
*/
checked: ComputedRef<boolean>; checked: ComputedRef<boolean>;
}; };

View File

@ -318,8 +318,11 @@ import type {
FieldProps, FieldProps,
FieldInstance, FieldInstance,
FieldTextAlign, FieldTextAlign,
FieldRuleMessage,
FieldClearTrigger, FieldClearTrigger,
FieldFormatTrigger, FieldFormatTrigger,
FieldRuleValidator,
FiledRuleFormatter,
FieldValidateError, FieldValidateError,
FieldAutosizeConfig, FieldAutosizeConfig,
FieldValidateTrigger, FieldValidateTrigger,

View File

@ -337,8 +337,11 @@ import type {
FieldProps, FieldProps,
FieldInstance, FieldInstance,
FieldTextAlign, FieldTextAlign,
FieldRuleMessage,
FieldClearTrigger, FieldClearTrigger,
FieldFormatTrigger, FieldFormatTrigger,
FieldRuleValidator,
FiledRuleFormatter,
FieldValidateError, FieldValidateError,
FieldAutosizeConfig, FieldAutosizeConfig,
FieldValidateTrigger, FieldValidateTrigger,

View File

@ -9,8 +9,11 @@ export type {
FieldRule, FieldRule,
FieldInstance, FieldInstance,
FieldTextAlign, FieldTextAlign,
FieldRuleMessage,
FieldClearTrigger, FieldClearTrigger,
FieldFormatTrigger, FieldFormatTrigger,
FieldRuleValidator,
FiledRuleFormatter,
FieldValidateError, FieldValidateError,
FieldAutosizeConfig, FieldAutosizeConfig,
FieldValidateTrigger, FieldValidateTrigger,

View File

@ -1,3 +1,4 @@
/* eslint-disable no-use-before-define */
import type { ComputedRef, ComponentPublicInstance } from 'vue'; import type { ComputedRef, ComponentPublicInstance } from 'vue';
import type { FieldProps } from './Field'; import type { FieldProps } from './Field';
@ -28,16 +29,24 @@ export type FieldValidateError = {
message: string; message: string;
}; };
export type FieldRuleMessage =
| string
| ((value: any, rule: FieldRule) => string);
export type FieldRuleValidator = (
value: any,
rule: FieldRule
) => boolean | string | Promise<boolean | string>;
export type FiledRuleFormatter = (value: any, rule: FieldRule) => string;
export type FieldRule = { export type FieldRule = {
pattern?: RegExp; pattern?: RegExp;
trigger?: FieldValidateTrigger; trigger?: FieldValidateTrigger;
message?: string | ((value: any, rule: FieldRule) => string); message?: FieldRuleMessage;
required?: boolean; required?: boolean;
validator?: ( validator?: FieldRuleValidator;
value: any, formatter?: FiledRuleFormatter;
rule: FieldRule
) => boolean | string | Promise<boolean | string>;
formatter?: (value: any, rule: FieldRule) => string;
}; };
// Shared props of Field and Form // Shared props of Field and Form
@ -57,9 +66,7 @@ export type FieldExpose = {
rules?: FieldRule[] | undefined rules?: FieldRule[] | undefined
) => Promise<void | FieldValidateError>; ) => Promise<void | FieldValidateError>;
resetValidation: () => void; resetValidation: () => void;
/** /** @private */
* @private
*/
formValue: ComputedRef<unknown>; formValue: ComputedRef<unknown>;
}; };

View File

@ -19,9 +19,7 @@ export type SwipeExpose = {
next: () => void; next: () => void;
resize: () => void; resize: () => void;
swipeTo: (index: number, options?: SwipeToOptions) => void; swipeTo: (index: number, options?: SwipeToOptions) => void;
/** /** @private */
* @private
*/
state: SwipeState; state: SwipeState;
}; };