mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
types(Field): expose sub-types of FieldRule (#9843)
* types(Field): expose sub-types of FieldRule * types: update
This commit is contained in:
parent
ca41a57f30
commit
c65e336bf6
@ -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>;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -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,
|
||||||
|
@ -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,
|
||||||
|
@ -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,
|
||||||
|
@ -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 FieldRule = {
|
export type FieldRuleMessage =
|
||||||
pattern?: RegExp;
|
| string
|
||||||
trigger?: FieldValidateTrigger;
|
| ((value: any, rule: FieldRule) => string);
|
||||||
message?: string | ((value: any, rule: FieldRule) => string);
|
|
||||||
required?: boolean;
|
export type FieldRuleValidator = (
|
||||||
validator?: (
|
|
||||||
value: any,
|
value: any,
|
||||||
rule: FieldRule
|
rule: FieldRule
|
||||||
) => boolean | string | Promise<boolean | string>;
|
) => boolean | string | Promise<boolean | string>;
|
||||||
formatter?: (value: any, rule: FieldRule) => string;
|
|
||||||
|
export type FiledRuleFormatter = (value: any, rule: FieldRule) => string;
|
||||||
|
|
||||||
|
export type FieldRule = {
|
||||||
|
pattern?: RegExp;
|
||||||
|
trigger?: FieldValidateTrigger;
|
||||||
|
message?: FieldRuleMessage;
|
||||||
|
required?: boolean;
|
||||||
|
validator?: FieldRuleValidator;
|
||||||
|
formatter?: FiledRuleFormatter;
|
||||||
};
|
};
|
||||||
|
|
||||||
// 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>;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -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;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user