mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-02 03:59:01 +08:00
refactor: split form context (#43023)
This commit is contained in:
parent
e9bbc588cd
commit
96a93260d3
@ -7,8 +7,8 @@ import type { ReactElement } from 'react';
|
||||
import * as React from 'react';
|
||||
import type { Options } from 'scroll-into-view-if-needed';
|
||||
import warning from '../_util/warning';
|
||||
import { ValidateMessagesContext } from '../form/context';
|
||||
import type { RequiredMark } from '../form/Form';
|
||||
import ValidateMessagesContext from '../form/validateMessagesContext';
|
||||
import type { Locale } from '../locale';
|
||||
import LocaleProvider, { ANT_MARK } from '../locale';
|
||||
import type { LocaleContextProps } from '../locale/context';
|
||||
|
@ -12,11 +12,12 @@ import { SizeContextProvider } from '../config-provider/SizeContext';
|
||||
import useSize from '../config-provider/hooks/useSize';
|
||||
import type { ColProps } from '../grid/col';
|
||||
import type { FormContextProps } from './context';
|
||||
import { FormContext, FormProvider, ValidateMessagesContext } from './context';
|
||||
import { FormContext, FormProvider } from './context';
|
||||
import useForm, { type FormInstance } from './hooks/useForm';
|
||||
import useFormWarning from './hooks/useFormWarning';
|
||||
import type { FormLabelAlign } from './interface';
|
||||
import useStyle from './style';
|
||||
import ValidateMessagesContext from './validateMessagesContext';
|
||||
|
||||
export type RequiredMark = boolean | 'optional';
|
||||
export type FormLayout = 'horizontal' | 'inline' | 'vertical';
|
||||
@ -186,6 +187,6 @@ const Form = React.forwardRef<FormInstance, FormProps>(InternalForm) as <Values
|
||||
props: React.PropsWithChildren<FormProps<Values>> & { ref?: React.Ref<FormInstance<Values>> },
|
||||
) => React.ReactElement;
|
||||
|
||||
export { useForm, List, type FormInstance, useWatch };
|
||||
export { List, useForm, useWatch, type FormInstance };
|
||||
|
||||
export default Form;
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { FormProvider as RcFormProvider } from 'rc-field-form';
|
||||
import type { FormProviderProps as RcFormProviderProps } from 'rc-field-form/lib/FormContext';
|
||||
import type { Meta, ValidateMessages } from 'rc-field-form/lib/interface';
|
||||
import type { Meta } from 'rc-field-form/lib/interface';
|
||||
import omit from 'rc-util/lib/omit';
|
||||
import type { FC, PropsWithChildren, ReactNode } from 'react';
|
||||
import * as React from 'react';
|
||||
@ -92,5 +92,3 @@ export const NoFormStyle: FC<NoFormStyleProps> = ({ children, status, override }
|
||||
</FormItemInputContext.Provider>
|
||||
);
|
||||
};
|
||||
|
||||
export const ValidateMessagesContext = React.createContext<ValidateMessages | undefined>(undefined);
|
||||
|
7
components/form/validateMessagesContext.tsx
Normal file
7
components/form/validateMessagesContext.tsx
Normal file
@ -0,0 +1,7 @@
|
||||
import type { ValidateMessages } from 'rc-field-form/lib/interface';
|
||||
import { createContext } from 'react';
|
||||
|
||||
// ZombieJ: We export single file here since
|
||||
// ConfigProvider use this which will make loop deps
|
||||
// to import whole `rc-field-form`
|
||||
export default createContext<ValidateMessages | undefined>(undefined);
|
Loading…
Reference in New Issue
Block a user