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