Skip to content

Commit

Permalink
chore: Compatible old antd v4
Browse files Browse the repository at this point in the history
  • Loading branch information
zombieJ committed Sep 16, 2020
1 parent 2b40c47 commit fdc26ce
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 20 deletions.
9 changes: 9 additions & 0 deletions src/CompatibleConsumer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { ConfigProvider } from 'antd';
import { ConfigConsumer, ConfigConsumerProps } from 'antd/lib/config-provider';

export { ConfigConsumerProps };

const MergedConfigConsumer =
ConfigProvider?.ConfigContext?.Consumer || ConfigConsumer;

export default MergedConfigConsumer;
7 changes: 2 additions & 5 deletions src/form/Form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import classNames from 'classnames';
import createDOMForm from 'rc-form/lib/createDOMForm';
import createFormField from 'rc-form/lib/createFormField';
import omit from 'omit.js';
import { ConfigProvider } from 'antd';
import { ConfigConsumerProps } from 'antd/lib/config-provider';
import { ColProps } from 'antd/lib/grid/col';
import { tuple } from '../_util/types';
import warning from '../_util/warning';
Expand All @@ -13,6 +11,7 @@ import { FIELD_META_PROP, FIELD_DATA_PROP } from './constants';
import FormContext from './context';
import { FormWrappedProps } from './interface';
import upgradeMessage from '../_util/upgradeMessage';
import CompatibleConsumer, { ConfigConsumerProps } from '../CompatibleConsumer';

type FormCreateOptionMessagesCallback = (...args: any[]) => string;

Expand Down Expand Up @@ -320,9 +319,7 @@ export default class Form extends React.Component<FormProps, any> {
colon,
}}
>
<ConfigProvider.ConfigContext.Consumer>
{this.renderForm}
</ConfigProvider.ConfigContext.Consumer>
<CompatibleConsumer>{this.renderForm}</CompatibleConsumer>
</FormContext.Provider>
);
}
Expand Down
18 changes: 9 additions & 9 deletions src/form/FormItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ import * as ReactDOM from 'react-dom';
import classNames from 'classnames';
import Animate from 'rc-animate';
import omit from 'omit.js';
import { Row, Col, ConfigProvider } from 'antd';
import { ColProps } from 'antd/lib/grid/col';
import { ConfigConsumerProps } from 'antd/lib/config-provider';
import warning from '../_util/warning';
import { tuple } from '../_util/types';
import { FIELD_META_PROP, FIELD_DATA_PROP } from './constants';
import FormContext, { FormContextProps } from './context';
import { Row, Col } from 'antd';
import {
CheckCircleFilled,
CloseCircleFilled,
ExclamationCircleFilled,
LoadingOutlined,
} from '@ant-design/icons';
import { ColProps } from 'antd/lib/grid/col';
import CompatibleConsumer, { ConfigConsumerProps } from '../CompatibleConsumer';
import warning from '../_util/warning';
import { tuple } from '../_util/types';
import { FIELD_META_PROP, FIELD_DATA_PROP } from './constants';
import FormContext, { FormContextProps } from './context';

const ValidateStatuses = tuple('success', 'warning', 'error', 'validating', '');

Expand Down Expand Up @@ -444,9 +444,9 @@ export default class FormItem extends React.Component<FormItemProps, any> {

render() {
return (
<ConfigProvider.ConfigContext.Consumer>
<CompatibleConsumer>
{this.renderFormItem}
</ConfigProvider.ConfigContext.Consumer>
</CompatibleConsumer>
);
}
}
11 changes: 5 additions & 6 deletions src/mention/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,18 @@ import RcMention, {
getMentions,
} from 'rc-editor-mention';
import classNames from 'classnames';
import { ConfigProvider } from 'antd';
import { ConfigConsumerProps } from 'antd/lib/config-provider';
import Icon from '../icon';
import upgradeMessage from '../_util/upgradeMessage';
import CompatibleConsumer, { ConfigConsumerProps } from '../CompatibleConsumer';

export type MentionPlacement = 'top' | 'bottom';

type SuggestionItme = React.ReactElement<{ value?: string }> | string;
type SuggestionItem = React.ReactElement<{ value?: string }> | string;

export interface MentionProps {
prefixCls?: string;
suggestionStyle?: React.CSSProperties;
defaultSuggestions?: Array<SuggestionItme>;
defaultSuggestions?: Array<SuggestionItem>;
suggestions?: Array<React.ReactElement<any>>;
onSearchChange?: (value: string, trigger: string) => any;
onChange?: (contentState: any) => void;
Expand Down Expand Up @@ -171,9 +170,9 @@ class Mention extends React.Component<MentionProps, MentionState> {

render() {
return (
<ConfigProvider.ConfigContext.Consumer>
<CompatibleConsumer>
{this.renderMention}
</ConfigProvider.ConfigContext.Consumer>
</CompatibleConsumer>
);
}
}
Expand Down

1 comment on commit fdc26ce

@vercel
Copy link

@vercel vercel bot commented on fdc26ce Sep 16, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deployment failed with the following error:

The most recent charge for your active payment method has failed. Please update it here: https://vercel.com/teams/pro-components/settings/billing

Please sign in to comment.