diff --git a/components/form/Form.tsx b/components/form/Form.tsx index 5c8221fc9..73f5e85f2 100755 --- a/components/form/Form.tsx +++ b/components/form/Form.tsx @@ -24,6 +24,7 @@ import type { Callbacks, ValidateMessages, Rule, + FormLabelAlign, } from './interface'; import { useInjectSize } from '../_util/hooks/useSize'; import useConfigInject from '../_util/hooks/useConfigInject'; @@ -35,15 +36,12 @@ import { useInjectGlobalForm } from '../config-provider/context'; export type RequiredMark = boolean | 'optional'; export type FormLayout = 'horizontal' | 'inline' | 'vertical'; -/** @deprecated Will warning in future branch. Pls use `Rule` instead. */ -export type ValidationRule = Rule; - export const formProps = () => ({ - layout: PropTypes.oneOf(tuple('horizontal', 'inline', 'vertical')), + layout: PropTypes.oneOf(tuple('horizontal', 'inline', 'vertical') as FormLayout[]), labelCol: { type: Object as PropType }, wrapperCol: { type: Object as PropType }, colon: { type: Boolean, default: undefined }, - labelAlign: PropTypes.oneOf(tuple('left', 'right')), + labelAlign: PropTypes.oneOf(tuple('left', 'right') as FormLabelAlign[]), labelWrap: { type: Boolean, default: undefined }, prefixCls: String, requiredMark: { type: [String, Boolean] as PropType, default: undefined }, diff --git a/components/form/FormItem.tsx b/components/form/FormItem.tsx index dd49c1e85..64b2fa29b 100644 --- a/components/form/FormItem.tsx +++ b/components/form/FormItem.tsx @@ -32,12 +32,11 @@ import useConfigInject from '../_util/hooks/useConfigInject'; import { useInjectForm } from './context'; import FormItemLabel from './FormItemLabel'; import FormItemInput from './FormItemInput'; -import type { ValidationRule } from './Form'; import { useProvideFormItemContext } from './FormItemContext'; import useDebounce from './utils/useDebounce'; const ValidateStatuses = tuple('success', 'warning', 'error', 'validating', ''); -export type ValidateStatus = typeof ValidateStatuses[number]; +export type ValidateStatus = (typeof ValidateStatuses)[number]; export interface FieldExpose { fieldValue: Ref; @@ -46,7 +45,7 @@ export interface FieldExpose { resetField: () => void; clearValidate: () => void; namePath: ComputedRef; - rules?: ComputedRef; + rules?: ComputedRef; validateRules: (options: ValidateOptions) => Promise | Promise; } @@ -169,7 +168,7 @@ export default defineComponent({ validateTrigger = validateTrigger === undefined ? 'change' : validateTrigger; return toArray(validateTrigger); }); - const rulesRef = computed(() => { + const rulesRef = computed(() => { let formRules = formContext.rules.value; const selfRules = props.rules; const requiredRule =