mirror of
https://github.com/ant-design/ant-design.git
synced 2025-08-04 23:16:50 +08:00
fix: TreeShaking (#19115)
This commit is contained in:
parent
b0c90f4b06
commit
7922090eaa
30
components/config-provider/context.ts
Normal file
30
components/config-provider/context.ts
Normal file
@ -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;
|
@ -2,27 +2,13 @@
|
|||||||
// SFC has specified a displayName, but not worked.
|
// SFC has specified a displayName, but not worked.
|
||||||
/* eslint-disable react/display-name */
|
/* eslint-disable react/display-name */
|
||||||
import * as React from 'react';
|
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 LocaleProvider, { Locale, ANT_MARK } from '../locale-provider';
|
||||||
import LocaleReceiver from '../locale-provider/LocaleReceiver';
|
import LocaleReceiver from '../locale-provider/LocaleReceiver';
|
||||||
|
import { ConfigConsumer, ConfigContext, CSPConfig, ConfigConsumerProps } from './context';
|
||||||
|
|
||||||
export { RenderEmptyHandler };
|
export { RenderEmptyHandler, ConfigConsumer, CSPConfig, ConfigConsumerProps };
|
||||||
|
|
||||||
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 configConsumerProps = [
|
export const configConsumerProps = [
|
||||||
'getPopupContainer',
|
'getPopupContainer',
|
||||||
@ -44,19 +30,6 @@ export interface ConfigProviderProps {
|
|||||||
locale?: Locale;
|
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> {
|
class ConfigProvider extends React.Component<ConfigProviderProps> {
|
||||||
getPrefixCls = (suffixCls: string, customizePrefixCls?: string) => {
|
getPrefixCls = (suffixCls: string, customizePrefixCls?: string) => {
|
||||||
const { prefixCls = 'ant' } = this.props;
|
const { prefixCls = 'ant' } = this.props;
|
||||||
|
Loading…
Reference in New Issue
Block a user