antd
Version:
An enterprise-class UI design language and React components implementation
37 lines • 1.71 kB
JavaScript
import _extends from "@babel/runtime/helpers/esm/extends";
import * as React from 'react';
export var defaultIconPrefixCls = 'anticon';
var defaultGetPrefixCls = function defaultGetPrefixCls(suffixCls, customizePrefixCls) {
if (customizePrefixCls) return customizePrefixCls;
return suffixCls ? "ant-" + suffixCls : 'ant';
};
// zombieJ: 🚨 Do not pass `defaultRenderEmpty` here since it will case circular dependency.
export var ConfigContext = /*#__PURE__*/React.createContext({
// We provide a default function for Context without provider
getPrefixCls: defaultGetPrefixCls,
iconPrefixCls: defaultIconPrefixCls
});
export var ConfigConsumer = ConfigContext.Consumer;
/** @deprecated Use hooks instead. This is a legacy function */
export function withConfigConsumer(config) {
return function withConfigConsumerFunc(Component) {
// Wrap with ConfigConsumer. Since we need compatible with react 15, be care when using ref methods
var SFC = function SFC(props) {
return /*#__PURE__*/React.createElement(ConfigConsumer, null, function (configProps) {
var basicPrefixCls = config.prefixCls;
var getPrefixCls = configProps.getPrefixCls;
var customizePrefixCls = props.prefixCls;
var prefixCls = getPrefixCls(basicPrefixCls, customizePrefixCls);
return /*#__PURE__*/React.createElement(Component, _extends({}, configProps, props, {
prefixCls: prefixCls
}));
});
};
var cons = Component.constructor;
var name = cons && cons.displayName || Component.name || 'Component';
if (process.env.NODE_ENV !== 'production') {
SFC.displayName = "withConfigConsumer(" + name + ")";
}
return SFC;
};
}