1 | import _extends from "@babel/runtime/helpers/esm/extends";
|
2 | import * as React from 'react';
|
3 | export var defaultIconPrefixCls = 'anticon';
|
4 | var defaultGetPrefixCls = function defaultGetPrefixCls(suffixCls, customizePrefixCls) {
|
5 | if (customizePrefixCls) return customizePrefixCls;
|
6 | return suffixCls ? "ant-" + suffixCls : 'ant';
|
7 | };
|
8 |
|
9 | export var ConfigContext = React.createContext({
|
10 |
|
11 | getPrefixCls: defaultGetPrefixCls,
|
12 | iconPrefixCls: defaultIconPrefixCls
|
13 | });
|
14 | export var ConfigConsumer = ConfigContext.Consumer;
|
15 |
|
16 | export function withConfigConsumer(config) {
|
17 | return function withConfigConsumerFunc(Component) {
|
18 |
|
19 | var SFC = function SFC(props) {
|
20 | return 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 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 |