feat: export useInjectFormItemContext
parent
59e0985f5d
commit
4914864313
|
@ -22,6 +22,7 @@ import type {
|
|||
RuleError,
|
||||
ValidateErrorEntity,
|
||||
ValidateOptions,
|
||||
Callbacks,
|
||||
} from './interface';
|
||||
import { useInjectSize } from '../_util/hooks/useSize';
|
||||
import useConfigInject from '../_util/hooks/useConfigInject';
|
||||
|
@ -76,11 +77,13 @@ export const formProps = {
|
|||
// 提交失败自动滚动到第一个错误字段
|
||||
scrollToFirstError: { type: [Boolean, Object] as PropType<boolean | Options> },
|
||||
onSubmit: PropTypes.func,
|
||||
onFinish: PropTypes.func,
|
||||
onFinishFailed: PropTypes.func,
|
||||
name: PropTypes.string,
|
||||
validateTrigger: { type: [String, Array] as PropType<string | string[]> },
|
||||
size: { type: String as PropType<SizeType> },
|
||||
onValuesChange: { type: Function as PropType<Callbacks['onValuesChange']> },
|
||||
onFieldsChange: { type: Function as PropType<Callbacks['onFieldsChange']> },
|
||||
onFinish: { type: Function as PropType<Callbacks['onFinish']> },
|
||||
onFinishFailed: { type: Function as PropType<Callbacks['onFinishFailed']> },
|
||||
};
|
||||
|
||||
export type FormProps = Partial<ExtractPropTypes<typeof formProps>>;
|
||||
|
|
|
@ -274,8 +274,16 @@ export default defineComponent({
|
|||
|
||||
useProvideFormItemContext({
|
||||
id: fieldId,
|
||||
onFieldBlur,
|
||||
onFieldChange,
|
||||
onFieldBlur: () => {
|
||||
if (props.autoLink) {
|
||||
onFieldBlur();
|
||||
}
|
||||
},
|
||||
onFieldChange: () => {
|
||||
if (props.autoLink) {
|
||||
onFieldChange();
|
||||
}
|
||||
},
|
||||
clearValidate,
|
||||
});
|
||||
let registered = false;
|
||||
|
|
|
@ -3,10 +3,12 @@ import Form, { formProps } from './Form';
|
|||
import FormItem, { formItemProps } from './FormItem';
|
||||
import useForm from './useForm';
|
||||
import { useInjectFormItemContext } from './FormItemContext';
|
||||
export type { Rule, RuleObject } from './interface';
|
||||
|
||||
export type { FormProps } from './Form';
|
||||
export type { FormItemProps } from './FormItem';
|
||||
|
||||
Form.useInjectFormItemContext = useInjectFormItemContext;
|
||||
/* istanbul ignore next */
|
||||
Form.install = function (app: App) {
|
||||
app.component(Form.name, Form);
|
||||
|
|
Loading…
Reference in New Issue