diff --git a/packages/vant/src/checkbox/types.ts b/packages/vant/src/checkbox/types.ts index fa8d7bf20..d12ed20a8 100644 --- a/packages/vant/src/checkbox/types.ts +++ b/packages/vant/src/checkbox/types.ts @@ -7,13 +7,9 @@ export type CheckboxLabelPosition = CheckerLabelPosition; export type CheckboxExpose = { toggle: (newValue?: boolean) => void; - /** - * @private - */ + /** @private */ props: CheckboxProps; - /** - * @private - */ + /** @private */ checked: ComputedRef; }; diff --git a/packages/vant/src/field/README.md b/packages/vant/src/field/README.md index 36e7b914d..9f1f96f98 100644 --- a/packages/vant/src/field/README.md +++ b/packages/vant/src/field/README.md @@ -318,8 +318,11 @@ import type { FieldProps, FieldInstance, FieldTextAlign, + FieldRuleMessage, FieldClearTrigger, FieldFormatTrigger, + FieldRuleValidator, + FiledRuleFormatter, FieldValidateError, FieldAutosizeConfig, FieldValidateTrigger, diff --git a/packages/vant/src/field/README.zh-CN.md b/packages/vant/src/field/README.zh-CN.md index cc7c45102..e4d3f8f73 100644 --- a/packages/vant/src/field/README.zh-CN.md +++ b/packages/vant/src/field/README.zh-CN.md @@ -337,8 +337,11 @@ import type { FieldProps, FieldInstance, FieldTextAlign, + FieldRuleMessage, FieldClearTrigger, FieldFormatTrigger, + FieldRuleValidator, + FiledRuleFormatter, FieldValidateError, FieldAutosizeConfig, FieldValidateTrigger, diff --git a/packages/vant/src/field/index.ts b/packages/vant/src/field/index.ts index 9b0c7610b..f1570c01e 100644 --- a/packages/vant/src/field/index.ts +++ b/packages/vant/src/field/index.ts @@ -9,8 +9,11 @@ export type { FieldRule, FieldInstance, FieldTextAlign, + FieldRuleMessage, FieldClearTrigger, FieldFormatTrigger, + FieldRuleValidator, + FiledRuleFormatter, FieldValidateError, FieldAutosizeConfig, FieldValidateTrigger, diff --git a/packages/vant/src/field/types.ts b/packages/vant/src/field/types.ts index 9fbe122d2..95cd23e0b 100644 --- a/packages/vant/src/field/types.ts +++ b/packages/vant/src/field/types.ts @@ -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; + +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; - 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; resetValidation: () => void; - /** - * @private - */ + /** @private */ formValue: ComputedRef; }; diff --git a/packages/vant/src/swipe/types.ts b/packages/vant/src/swipe/types.ts index 41dfebf48..261b3d1d0 100644 --- a/packages/vant/src/swipe/types.ts +++ b/packages/vant/src/swipe/types.ts @@ -19,9 +19,7 @@ export type SwipeExpose = { next: () => void; resize: () => void; swipeTo: (index: number, options?: SwipeToOptions) => void; - /** - * @private - */ + /** @private */ state: SwipeState; };