Fix form type prompt (#6375)
* fix(FormITem): Change from ValidationRule to Rule * fix(FormI): from props typepull/6378/head
parent
e5e20cca5b
commit
d956eed086
|
@ -24,6 +24,7 @@ import type {
|
||||||
Callbacks,
|
Callbacks,
|
||||||
ValidateMessages,
|
ValidateMessages,
|
||||||
Rule,
|
Rule,
|
||||||
|
FormLabelAlign,
|
||||||
} from './interface';
|
} from './interface';
|
||||||
import { useInjectSize } from '../_util/hooks/useSize';
|
import { useInjectSize } from '../_util/hooks/useSize';
|
||||||
import useConfigInject from '../_util/hooks/useConfigInject';
|
import useConfigInject from '../_util/hooks/useConfigInject';
|
||||||
|
@ -35,15 +36,12 @@ import { useInjectGlobalForm } from '../config-provider/context';
|
||||||
export type RequiredMark = boolean | 'optional';
|
export type RequiredMark = boolean | 'optional';
|
||||||
export type FormLayout = 'horizontal' | 'inline' | 'vertical';
|
export type FormLayout = 'horizontal' | 'inline' | 'vertical';
|
||||||
|
|
||||||
/** @deprecated Will warning in future branch. Pls use `Rule` instead. */
|
|
||||||
export type ValidationRule = Rule;
|
|
||||||
|
|
||||||
export const formProps = () => ({
|
export const formProps = () => ({
|
||||||
layout: PropTypes.oneOf(tuple('horizontal', 'inline', 'vertical')),
|
layout: PropTypes.oneOf(tuple('horizontal', 'inline', 'vertical') as FormLayout[]),
|
||||||
labelCol: { type: Object as PropType<ColProps & HTMLAttributes> },
|
labelCol: { type: Object as PropType<ColProps & HTMLAttributes> },
|
||||||
wrapperCol: { type: Object as PropType<ColProps & HTMLAttributes> },
|
wrapperCol: { type: Object as PropType<ColProps & HTMLAttributes> },
|
||||||
colon: { type: Boolean, default: undefined },
|
colon: { type: Boolean, default: undefined },
|
||||||
labelAlign: PropTypes.oneOf(tuple('left', 'right')),
|
labelAlign: PropTypes.oneOf(tuple('left', 'right') as FormLabelAlign[]),
|
||||||
labelWrap: { type: Boolean, default: undefined },
|
labelWrap: { type: Boolean, default: undefined },
|
||||||
prefixCls: String,
|
prefixCls: String,
|
||||||
requiredMark: { type: [String, Boolean] as PropType<RequiredMark | ''>, default: undefined },
|
requiredMark: { type: [String, Boolean] as PropType<RequiredMark | ''>, default: undefined },
|
||||||
|
|
|
@ -32,12 +32,11 @@ import useConfigInject from '../_util/hooks/useConfigInject';
|
||||||
import { useInjectForm } from './context';
|
import { useInjectForm } from './context';
|
||||||
import FormItemLabel from './FormItemLabel';
|
import FormItemLabel from './FormItemLabel';
|
||||||
import FormItemInput from './FormItemInput';
|
import FormItemInput from './FormItemInput';
|
||||||
import type { ValidationRule } from './Form';
|
|
||||||
import { useProvideFormItemContext } from './FormItemContext';
|
import { useProvideFormItemContext } from './FormItemContext';
|
||||||
import useDebounce from './utils/useDebounce';
|
import useDebounce from './utils/useDebounce';
|
||||||
|
|
||||||
const ValidateStatuses = tuple('success', 'warning', 'error', 'validating', '');
|
const ValidateStatuses = tuple('success', 'warning', 'error', 'validating', '');
|
||||||
export type ValidateStatus = typeof ValidateStatuses[number];
|
export type ValidateStatus = (typeof ValidateStatuses)[number];
|
||||||
|
|
||||||
export interface FieldExpose {
|
export interface FieldExpose {
|
||||||
fieldValue: Ref<any>;
|
fieldValue: Ref<any>;
|
||||||
|
@ -46,7 +45,7 @@ export interface FieldExpose {
|
||||||
resetField: () => void;
|
resetField: () => void;
|
||||||
clearValidate: () => void;
|
clearValidate: () => void;
|
||||||
namePath: ComputedRef<InternalNamePath>;
|
namePath: ComputedRef<InternalNamePath>;
|
||||||
rules?: ComputedRef<ValidationRule[]>;
|
rules?: ComputedRef<Rule[]>;
|
||||||
validateRules: (options: ValidateOptions) => Promise<void> | Promise<RuleError[]>;
|
validateRules: (options: ValidateOptions) => Promise<void> | Promise<RuleError[]>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -169,7 +168,7 @@ export default defineComponent({
|
||||||
validateTrigger = validateTrigger === undefined ? 'change' : validateTrigger;
|
validateTrigger = validateTrigger === undefined ? 'change' : validateTrigger;
|
||||||
return toArray(validateTrigger);
|
return toArray(validateTrigger);
|
||||||
});
|
});
|
||||||
const rulesRef = computed<ValidationRule[]>(() => {
|
const rulesRef = computed<Rule[]>(() => {
|
||||||
let formRules = formContext.rules.value;
|
let formRules = formContext.rules.value;
|
||||||
const selfRules = props.rules;
|
const selfRules = props.rules;
|
||||||
const requiredRule =
|
const requiredRule =
|
||||||
|
|
Loading…
Reference in New Issue