1 | "use client";
|
2 |
|
3 | import * as React from 'react';
|
4 | import { createContext, useContext, useMemo } from 'react';
|
5 | import { FormProvider as RcFormProvider } from 'rc-field-form';
|
6 | import omit from "rc-util/es/omit";
|
7 | export const FormContext = React.createContext({
|
8 | labelAlign: 'right',
|
9 | vertical: false,
|
10 | itemRef: () => {}
|
11 | });
|
12 | export const NoStyleItemContext = React.createContext(null);
|
13 | export const FormProvider = props => {
|
14 | const providerProps = omit(props, ['prefixCls']);
|
15 | return React.createElement(RcFormProvider, Object.assign({}, providerProps));
|
16 | };
|
17 | export const FormItemPrefixContext = React.createContext({
|
18 | prefixCls: ''
|
19 | });
|
20 | export const FormItemInputContext = React.createContext({});
|
21 | if (process.env.NODE_ENV !== 'production') {
|
22 | FormItemInputContext.displayName = 'FormItemInputContext';
|
23 | }
|
24 | export const NoFormStyle = _ref => {
|
25 | let {
|
26 | children,
|
27 | status,
|
28 | override
|
29 | } = _ref;
|
30 | const formItemInputContext = useContext(FormItemInputContext);
|
31 | const newFormItemInputContext = useMemo(() => {
|
32 | const newContext = Object.assign({}, formItemInputContext);
|
33 | if (override) {
|
34 | delete newContext.isFormItemInput;
|
35 | }
|
36 | if (status) {
|
37 | delete newContext.status;
|
38 | delete newContext.hasFeedback;
|
39 | delete newContext.feedbackIcon;
|
40 | }
|
41 | return newContext;
|
42 | }, [status, override, formItemInputContext]);
|
43 | return React.createElement(FormItemInputContext.Provider, {
|
44 | value: newFormItemInputContext
|
45 | }, children);
|
46 | };
|
47 | export const VariantContext = createContext(undefined); |
\ | No newline at end of file |