Skip to content

Commit

Permalink
fix: TreeShaking (#19115)
Browse files Browse the repository at this point in the history
  • Loading branch information
zombieJ committed Oct 8, 2019
1 parent b0c90f4 commit 7922090
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 30 deletions.
30 changes: 30 additions & 0 deletions components/config-provider/context.ts
@@ -0,0 +1,30 @@
import createReactContext from '@ant-design/create-react-context';
import defaultRenderEmpty, { RenderEmptyHandler } from './renderEmpty';
import { Locale } from '../locale-provider';

export interface CSPConfig {
nonce?: string;
}

export interface ConfigConsumerProps {
getPopupContainer?: (triggerNode: HTMLElement) => HTMLElement;
rootPrefixCls?: string;
getPrefixCls: (suffixCls: string, customizePrefixCls?: string) => string;
renderEmpty: RenderEmptyHandler;
csp?: CSPConfig;
autoInsertSpaceInButton?: boolean;
locale?: Locale;
}

export const ConfigContext = createReactContext<ConfigConsumerProps>({
// We provide a default function for Context without provider
getPrefixCls: (suffixCls: string, customizePrefixCls?: string) => {
if (customizePrefixCls) return customizePrefixCls;

return `ant-${suffixCls}`;
},

renderEmpty: defaultRenderEmpty,
});

export const ConfigConsumer = ConfigContext.Consumer;
33 changes: 3 additions & 30 deletions components/config-provider/index.tsx
Expand Up @@ -2,27 +2,13 @@
// SFC has specified a displayName, but not worked.
/* eslint-disable react/display-name */
import * as React from 'react';
import createReactContext from '@ant-design/create-react-context';

import defaultRenderEmpty, { RenderEmptyHandler } from './renderEmpty';
import { RenderEmptyHandler } from './renderEmpty';
import LocaleProvider, { Locale, ANT_MARK } from '../locale-provider';
import LocaleReceiver from '../locale-provider/LocaleReceiver';
import { ConfigConsumer, ConfigContext, CSPConfig, ConfigConsumerProps } from './context';

export { RenderEmptyHandler };

export interface CSPConfig {
nonce?: string;
}

export interface ConfigConsumerProps {
getPopupContainer?: (triggerNode: HTMLElement) => HTMLElement;
rootPrefixCls?: string;
getPrefixCls: (suffixCls: string, customizePrefixCls?: string) => string;
renderEmpty: RenderEmptyHandler;
csp?: CSPConfig;
autoInsertSpaceInButton?: boolean;
locale?: Locale;
}
export { RenderEmptyHandler, ConfigConsumer, CSPConfig, ConfigConsumerProps };

export const configConsumerProps = [
'getPopupContainer',
Expand All @@ -44,19 +30,6 @@ export interface ConfigProviderProps {
locale?: Locale;
}

const ConfigContext = createReactContext<ConfigConsumerProps>({
// We provide a default function for Context without provider
getPrefixCls: (suffixCls: string, customizePrefixCls?: string) => {
if (customizePrefixCls) return customizePrefixCls;

return `ant-${suffixCls}`;
},

renderEmpty: defaultRenderEmpty,
});

export const ConfigConsumer = ConfigContext.Consumer;

class ConfigProvider extends React.Component<ConfigProviderProps> {
getPrefixCls = (suffixCls: string, customizePrefixCls?: string) => {
const { prefixCls = 'ant' } = this.props;
Expand Down

0 comments on commit 7922090

Please sign in to comment.