UNPKG

1.71 kBJavaScriptView Raw
1import _extends from "@babel/runtime/helpers/esm/extends";
2import * as React from 'react';
3export var defaultIconPrefixCls = 'anticon';
4var defaultGetPrefixCls = function defaultGetPrefixCls(suffixCls, customizePrefixCls) {
5 if (customizePrefixCls) return customizePrefixCls;
6 return suffixCls ? "ant-" + suffixCls : 'ant';
7};
8// zombieJ: 🚨 Do not pass `defaultRenderEmpty` here since it will case circular dependency.
9export var ConfigContext = /*#__PURE__*/React.createContext({
10 // We provide a default function for Context without provider
11 getPrefixCls: defaultGetPrefixCls,
12 iconPrefixCls: defaultIconPrefixCls
13});
14export var ConfigConsumer = ConfigContext.Consumer;
15/** @deprecated Use hooks instead. This is a legacy function */
16export function withConfigConsumer(config) {
17 return function withConfigConsumerFunc(Component) {
18 // Wrap with ConfigConsumer. Since we need compatible with react 15, be care when using ref methods
19 var SFC = function SFC(props) {
20 return /*#__PURE__*/React.createElement(ConfigConsumer, null, function (configProps) {
21 var basicPrefixCls = config.prefixCls;
22 var getPrefixCls = configProps.getPrefixCls;
23 var customizePrefixCls = props.prefixCls;
24 var prefixCls = getPrefixCls(basicPrefixCls, customizePrefixCls);
25 return /*#__PURE__*/React.createElement(Component, _extends({}, configProps, props, {
26 prefixCls: prefixCls
27 }));
28 });
29 };
30 var cons = Component.constructor;
31 var name = cons && cons.displayName || Component.name || 'Component';
32 if (process.env.NODE_ENV !== 'production') {
33 SFC.displayName = "withConfigConsumer(" + name + ")";
34 }
35 return SFC;
36 };
37}
\No newline at end of file