UNPKG

antd

Version:

An enterprise-class UI design language and React components implementation

38 lines (34 loc) 1.57 kB
import _extends from "@babel/runtime/helpers/esm/extends"; import * as React from 'react'; import defaultRenderEmpty from './renderEmpty'; var defaultGetPrefixCls = function defaultGetPrefixCls(suffixCls, customizePrefixCls) { if (customizePrefixCls) return customizePrefixCls; return suffixCls ? "ant-".concat(suffixCls) : 'ant'; }; export var ConfigContext = /*#__PURE__*/React.createContext({ // We provide a default function for Context without provider getPrefixCls: defaultGetPrefixCls, renderEmpty: defaultRenderEmpty }); 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'; SFC.displayName = "withConfigConsumer(".concat(name, ")"); return SFC; }; }