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 = {
toggle: (newValue?: boolean) => void;
/**
* @private
*/
/** @private */
props: CheckboxProps;
/**
* @private
*/
/** @private */
checked: ComputedRef<boolean>;
};

View File

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

View File

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

View File

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

View File

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

View File

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