You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
1.5 KiB
38 lines
1.5 KiB
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;
|
|
};
|
|
} |