@fle-ui/next 2.0.0-alpha.7 → 2.0.0-alpha.8
Sign up to get free protection for your applications and to get access to all the features.
- package/es/config-provider/DisabledContext.d.ts +9 -0
- package/es/config-provider/DisabledContext.js +11 -0
- package/es/config-provider/SizeContext.d.ts +9 -0
- package/es/config-provider/SizeContext.js +12 -0
- package/es/config-provider/context.d.ts +58 -0
- package/es/config-provider/context.js +41 -0
- package/es/config-provider/cssVariables.d.ts +3 -0
- package/es/config-provider/cssVariables.js +97 -0
- package/es/config-provider/defaultRenderEmpty.d.ts +4 -0
- package/es/config-provider/defaultRenderEmpty.js +36 -0
- package/es/config-provider/index.d.ts +61 -5
- package/es/config-provider/index.js +209 -10
- package/es/config-provider/style/css.js +1 -0
- package/es/config-provider/style/index-pure.less +2 -0
- package/es/config-provider/style/index.css +4 -0
- package/es/config-provider/style/index.d.ts +1 -0
- package/es/config-provider/style/index.js +1 -0
- package/es/config-provider/style/index.less +3 -0
- package/lib/config-provider/DisabledContext.d.ts +9 -0
- package/lib/config-provider/DisabledContext.js +25 -0
- package/lib/config-provider/SizeContext.d.ts +9 -0
- package/lib/config-provider/SizeContext.js +26 -0
- package/lib/config-provider/context.d.ts +58 -0
- package/lib/config-provider/context.js +57 -0
- package/lib/config-provider/cssVariables.d.ts +3 -0
- package/lib/config-provider/cssVariables.js +115 -0
- package/lib/config-provider/defaultRenderEmpty.d.ts +4 -0
- package/lib/config-provider/defaultRenderEmpty.js +50 -0
- package/lib/config-provider/index.d.ts +61 -5
- package/lib/config-provider/index.js +250 -10
- package/lib/config-provider/style/css.js +3 -0
- package/lib/config-provider/style/index-pure.less +2 -0
- package/lib/config-provider/style/index.css +4 -0
- package/lib/config-provider/style/index.d.ts +1 -0
- package/lib/config-provider/style/index.js +3 -0
- package/lib/config-provider/style/index.less +3 -0
- package/package.json +1 -1
@@ -0,0 +1,26 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard")["default"];
|
4
|
+
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
6
|
+
value: true
|
7
|
+
});
|
8
|
+
exports["default"] = exports.SizeContextProvider = void 0;
|
9
|
+
|
10
|
+
var React = _interopRequireWildcard(require("react"));
|
11
|
+
|
12
|
+
var SizeContext = /*#__PURE__*/React.createContext(undefined);
|
13
|
+
|
14
|
+
var SizeContextProvider = function SizeContextProvider(_ref) {
|
15
|
+
var children = _ref.children,
|
16
|
+
size = _ref.size;
|
17
|
+
return /*#__PURE__*/React.createElement(SizeContext.Consumer, null, function (originSize) {
|
18
|
+
return /*#__PURE__*/React.createElement(SizeContext.Provider, {
|
19
|
+
value: size || originSize
|
20
|
+
}, children);
|
21
|
+
});
|
22
|
+
};
|
23
|
+
|
24
|
+
exports.SizeContextProvider = SizeContextProvider;
|
25
|
+
var _default = SizeContext;
|
26
|
+
exports["default"] = _default;
|
@@ -0,0 +1,58 @@
|
|
1
|
+
import * as React from 'react';
|
2
|
+
import type { RequiredMark } from '../form/Form';
|
3
|
+
import type { Locale } from '../locale-provider';
|
4
|
+
import type { RenderEmptyHandler } from './defaultRenderEmpty';
|
5
|
+
import type { SizeType } from './SizeContext';
|
6
|
+
export interface Theme {
|
7
|
+
primaryColor?: string;
|
8
|
+
infoColor?: string;
|
9
|
+
successColor?: string;
|
10
|
+
processingColor?: string;
|
11
|
+
errorColor?: string;
|
12
|
+
warningColor?: string;
|
13
|
+
}
|
14
|
+
export interface CSPConfig {
|
15
|
+
nonce?: string;
|
16
|
+
}
|
17
|
+
export type DirectionType = 'ltr' | 'rtl' | undefined;
|
18
|
+
export interface ConfigConsumerProps {
|
19
|
+
getTargetContainer?: () => HTMLElement;
|
20
|
+
getPopupContainer?: (triggerNode?: HTMLElement) => HTMLElement;
|
21
|
+
rootPrefixCls?: string;
|
22
|
+
iconPrefixCls?: string;
|
23
|
+
getPrefixCls: (suffixCls?: string, customizePrefixCls?: string) => string;
|
24
|
+
renderEmpty?: RenderEmptyHandler;
|
25
|
+
csp?: CSPConfig;
|
26
|
+
autoInsertSpaceInButton?: boolean;
|
27
|
+
input?: {
|
28
|
+
autoComplete?: string;
|
29
|
+
};
|
30
|
+
pagination?: {
|
31
|
+
showSizeChanger?: boolean;
|
32
|
+
};
|
33
|
+
locale?: Locale;
|
34
|
+
pageHeader?: {
|
35
|
+
ghost: boolean;
|
36
|
+
};
|
37
|
+
direction?: DirectionType;
|
38
|
+
space?: {
|
39
|
+
size?: SizeType | number;
|
40
|
+
};
|
41
|
+
virtual?: boolean;
|
42
|
+
dropdownMatchSelectWidth?: boolean;
|
43
|
+
form?: {
|
44
|
+
requiredMark?: RequiredMark;
|
45
|
+
colon?: boolean;
|
46
|
+
};
|
47
|
+
}
|
48
|
+
export declare const ConfigContext: React.Context<ConfigConsumerProps>;
|
49
|
+
export declare const ConfigConsumer: React.Consumer<ConfigConsumerProps>;
|
50
|
+
interface BasicExportProps {
|
51
|
+
prefixCls?: string;
|
52
|
+
}
|
53
|
+
interface ConsumerConfig {
|
54
|
+
prefixCls: string;
|
55
|
+
}
|
56
|
+
/** @deprecated Use hooks instead. This is a legacy function */
|
57
|
+
export declare function withConfigConsumer<ExportProps extends BasicExportProps>(config: ConsumerConfig): <ComponentDef>(Component: React.ComponentType<ExportProps>) => React.FC<ExportProps> & ComponentDef;
|
58
|
+
export {};
|
@@ -0,0 +1,57 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard")["default"];
|
4
|
+
|
5
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
|
6
|
+
|
7
|
+
Object.defineProperty(exports, "__esModule", {
|
8
|
+
value: true
|
9
|
+
});
|
10
|
+
exports.ConfigContext = exports.ConfigConsumer = void 0;
|
11
|
+
exports.withConfigConsumer = withConfigConsumer;
|
12
|
+
|
13
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
14
|
+
|
15
|
+
var React = _interopRequireWildcard(require("react"));
|
16
|
+
|
17
|
+
var defaultGetPrefixCls = function defaultGetPrefixCls(suffixCls, customizePrefixCls) {
|
18
|
+
if (customizePrefixCls) return customizePrefixCls;
|
19
|
+
return suffixCls ? "ant-".concat(suffixCls) : 'ant';
|
20
|
+
}; // zombieJ: 🚨 Do not pass `defaultRenderEmpty` here since it will case circular dependency.
|
21
|
+
|
22
|
+
|
23
|
+
var ConfigContext = /*#__PURE__*/React.createContext({
|
24
|
+
// We provide a default function for Context without provider
|
25
|
+
getPrefixCls: defaultGetPrefixCls
|
26
|
+
});
|
27
|
+
exports.ConfigContext = ConfigContext;
|
28
|
+
var ConfigConsumer = ConfigContext.Consumer;
|
29
|
+
/** @deprecated Use hooks instead. This is a legacy function */
|
30
|
+
|
31
|
+
exports.ConfigConsumer = ConfigConsumer;
|
32
|
+
|
33
|
+
function withConfigConsumer(config) {
|
34
|
+
return function withConfigConsumerFunc(Component) {
|
35
|
+
// Wrap with ConfigConsumer. Since we need compatible with react 15, be care when using ref methods
|
36
|
+
var SFC = function SFC(props) {
|
37
|
+
return /*#__PURE__*/React.createElement(ConfigConsumer, null, function (configProps) {
|
38
|
+
var basicPrefixCls = config.prefixCls;
|
39
|
+
var getPrefixCls = configProps.getPrefixCls;
|
40
|
+
var customizePrefixCls = props.prefixCls;
|
41
|
+
var prefixCls = getPrefixCls(basicPrefixCls, customizePrefixCls);
|
42
|
+
return /*#__PURE__*/React.createElement(Component, (0, _extends2["default"])({}, configProps, props, {
|
43
|
+
prefixCls: prefixCls
|
44
|
+
}));
|
45
|
+
});
|
46
|
+
};
|
47
|
+
|
48
|
+
var cons = Component.constructor;
|
49
|
+
var name = cons && cons.displayName || Component.name || 'Component';
|
50
|
+
|
51
|
+
if (process.env.NODE_ENV !== 'production') {
|
52
|
+
SFC.displayName = "withConfigConsumer(".concat(name, ")");
|
53
|
+
}
|
54
|
+
|
55
|
+
return SFC;
|
56
|
+
};
|
57
|
+
}
|
@@ -0,0 +1,115 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
|
4
|
+
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
6
|
+
value: true
|
7
|
+
});
|
8
|
+
exports.getStyle = getStyle;
|
9
|
+
exports.registerTheme = registerTheme;
|
10
|
+
|
11
|
+
var _colors = require("@ant-design/colors");
|
12
|
+
|
13
|
+
var _tinycolor = require("@ctrl/tinycolor");
|
14
|
+
|
15
|
+
var _canUseDom = _interopRequireDefault(require("rc-util/lib/Dom/canUseDom"));
|
16
|
+
|
17
|
+
var _dynamicCSS = require("rc-util/lib/Dom/dynamicCSS");
|
18
|
+
|
19
|
+
var _warning = _interopRequireDefault(require("../_util/warning"));
|
20
|
+
/* eslint-disable import/prefer-default-export, prefer-destructuring */
|
21
|
+
|
22
|
+
|
23
|
+
var dynamicStyleMark = "-ant-".concat(Date.now(), "-").concat(Math.random());
|
24
|
+
|
25
|
+
function getStyle(globalPrefixCls, theme) {
|
26
|
+
var variables = {};
|
27
|
+
|
28
|
+
var formatColor = function formatColor(color, updater) {
|
29
|
+
var clone = color.clone();
|
30
|
+
clone = (updater === null || updater === void 0 ? void 0 : updater(clone)) || clone;
|
31
|
+
return clone.toRgbString();
|
32
|
+
};
|
33
|
+
|
34
|
+
var fillColor = function fillColor(colorVal, type) {
|
35
|
+
var baseColor = new _tinycolor.TinyColor(colorVal);
|
36
|
+
var colorPalettes = (0, _colors.generate)(baseColor.toRgbString());
|
37
|
+
variables["".concat(type, "-color")] = formatColor(baseColor);
|
38
|
+
variables["".concat(type, "-color-disabled")] = colorPalettes[1];
|
39
|
+
variables["".concat(type, "-color-hover")] = colorPalettes[4];
|
40
|
+
variables["".concat(type, "-color-active")] = colorPalettes[6];
|
41
|
+
variables["".concat(type, "-color-outline")] = baseColor.clone().setAlpha(0.2).toRgbString();
|
42
|
+
variables["".concat(type, "-color-deprecated-bg")] = colorPalettes[0];
|
43
|
+
variables["".concat(type, "-color-deprecated-border")] = colorPalettes[2];
|
44
|
+
}; // ================ Primary Color ================
|
45
|
+
|
46
|
+
|
47
|
+
if (theme.primaryColor) {
|
48
|
+
fillColor(theme.primaryColor, 'primary');
|
49
|
+
var primaryColor = new _tinycolor.TinyColor(theme.primaryColor);
|
50
|
+
var primaryColors = (0, _colors.generate)(primaryColor.toRgbString()); // Legacy - We should use semantic naming standard
|
51
|
+
|
52
|
+
primaryColors.forEach(function (color, index) {
|
53
|
+
variables["primary-".concat(index + 1)] = color;
|
54
|
+
}); // Deprecated
|
55
|
+
|
56
|
+
variables['primary-color-deprecated-l-35'] = formatColor(primaryColor, function (c) {
|
57
|
+
return c.lighten(35);
|
58
|
+
});
|
59
|
+
variables['primary-color-deprecated-l-20'] = formatColor(primaryColor, function (c) {
|
60
|
+
return c.lighten(20);
|
61
|
+
});
|
62
|
+
variables['primary-color-deprecated-t-20'] = formatColor(primaryColor, function (c) {
|
63
|
+
return c.tint(20);
|
64
|
+
});
|
65
|
+
variables['primary-color-deprecated-t-50'] = formatColor(primaryColor, function (c) {
|
66
|
+
return c.tint(50);
|
67
|
+
});
|
68
|
+
variables['primary-color-deprecated-f-12'] = formatColor(primaryColor, function (c) {
|
69
|
+
return c.setAlpha(c.getAlpha() * 0.12);
|
70
|
+
});
|
71
|
+
var primaryActiveColor = new _tinycolor.TinyColor(primaryColors[0]);
|
72
|
+
variables['primary-color-active-deprecated-f-30'] = formatColor(primaryActiveColor, function (c) {
|
73
|
+
return c.setAlpha(c.getAlpha() * 0.3);
|
74
|
+
});
|
75
|
+
variables['primary-color-active-deprecated-d-02'] = formatColor(primaryActiveColor, function (c) {
|
76
|
+
return c.darken(2);
|
77
|
+
});
|
78
|
+
} // ================ Success Color ================
|
79
|
+
|
80
|
+
|
81
|
+
if (theme.successColor) {
|
82
|
+
fillColor(theme.successColor, 'success');
|
83
|
+
} // ================ Warning Color ================
|
84
|
+
|
85
|
+
|
86
|
+
if (theme.warningColor) {
|
87
|
+
fillColor(theme.warningColor, 'warning');
|
88
|
+
} // ================= Error Color =================
|
89
|
+
|
90
|
+
|
91
|
+
if (theme.errorColor) {
|
92
|
+
fillColor(theme.errorColor, 'error');
|
93
|
+
} // ================= Info Color ==================
|
94
|
+
|
95
|
+
|
96
|
+
if (theme.infoColor) {
|
97
|
+
fillColor(theme.infoColor, 'info');
|
98
|
+
} // Convert to css variables
|
99
|
+
|
100
|
+
|
101
|
+
var cssList = Object.keys(variables).map(function (key) {
|
102
|
+
return "--".concat(globalPrefixCls, "-").concat(key, ": ").concat(variables[key], ";");
|
103
|
+
});
|
104
|
+
return "\n :root {\n ".concat(cssList.join('\n'), "\n }\n ").trim();
|
105
|
+
}
|
106
|
+
|
107
|
+
function registerTheme(globalPrefixCls, theme) {
|
108
|
+
var style = getStyle(globalPrefixCls, theme);
|
109
|
+
|
110
|
+
if ((0, _canUseDom["default"])()) {
|
111
|
+
(0, _dynamicCSS.updateCSS)(style, "".concat(dynamicStyleMark, "-dynamic-theme"));
|
112
|
+
} else {
|
113
|
+
process.env.NODE_ENV !== "production" ? (0, _warning["default"])(false, 'ConfigProvider', 'SSR do not support dynamic theme with css variables.') : void 0;
|
114
|
+
}
|
115
|
+
}
|
@@ -0,0 +1,50 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
|
4
|
+
|
5
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard")["default"];
|
6
|
+
|
7
|
+
Object.defineProperty(exports, "__esModule", {
|
8
|
+
value: true
|
9
|
+
});
|
10
|
+
exports["default"] = void 0;
|
11
|
+
|
12
|
+
var React = _interopRequireWildcard(require("react"));
|
13
|
+
|
14
|
+
var _ = require(".");
|
15
|
+
|
16
|
+
var _empty = _interopRequireDefault(require("../empty"));
|
17
|
+
|
18
|
+
var defaultRenderEmpty = function defaultRenderEmpty(componentName) {
|
19
|
+
return /*#__PURE__*/React.createElement(_.ConfigConsumer, null, function (_ref) {
|
20
|
+
var getPrefixCls = _ref.getPrefixCls;
|
21
|
+
var prefix = getPrefixCls('empty');
|
22
|
+
|
23
|
+
switch (componentName) {
|
24
|
+
case 'Table':
|
25
|
+
case 'List':
|
26
|
+
return /*#__PURE__*/React.createElement(_empty["default"], {
|
27
|
+
image: _empty["default"].PRESENTED_IMAGE_SIMPLE
|
28
|
+
});
|
29
|
+
|
30
|
+
case 'Select':
|
31
|
+
case 'TreeSelect':
|
32
|
+
case 'Cascader':
|
33
|
+
case 'Transfer':
|
34
|
+
case 'Mentions':
|
35
|
+
return /*#__PURE__*/React.createElement(_empty["default"], {
|
36
|
+
image: _empty["default"].PRESENTED_IMAGE_SIMPLE,
|
37
|
+
className: "".concat(prefix, "-small")
|
38
|
+
});
|
39
|
+
|
40
|
+
/* istanbul ignore next */
|
41
|
+
|
42
|
+
default:
|
43
|
+
// Should never hit if we take all the component into consider.
|
44
|
+
return /*#__PURE__*/React.createElement(_empty["default"], null);
|
45
|
+
}
|
46
|
+
});
|
47
|
+
};
|
48
|
+
|
49
|
+
var _default = defaultRenderEmpty;
|
50
|
+
exports["default"] = _default;
|
@@ -1,5 +1,61 @@
|
|
1
|
-
import {
|
2
|
-
import '
|
3
|
-
import type {
|
4
|
-
|
5
|
-
|
1
|
+
import type { ValidateMessages } from 'rc-field-form/lib/interface';
|
2
|
+
import * as React from 'react';
|
3
|
+
import type { RequiredMark } from '../form/Form';
|
4
|
+
import type { Locale } from '../locale-provider';
|
5
|
+
import type { Theme } from './context';
|
6
|
+
import { ConfigConsumer, ConfigConsumerProps, ConfigContext, CSPConfig, DirectionType } from './context';
|
7
|
+
import { RenderEmptyHandler } from './defaultRenderEmpty';
|
8
|
+
import type { SizeType } from './SizeContext';
|
9
|
+
import SizeContext from './SizeContext';
|
10
|
+
export { RenderEmptyHandler, ConfigContext, ConfigConsumer, CSPConfig, DirectionType, ConfigConsumerProps, };
|
11
|
+
export declare const configConsumerProps: string[];
|
12
|
+
export interface ConfigProviderProps {
|
13
|
+
getTargetContainer?: () => HTMLElement | Window;
|
14
|
+
getPopupContainer?: (triggerNode?: HTMLElement) => HTMLElement;
|
15
|
+
prefixCls?: string;
|
16
|
+
iconPrefixCls?: string;
|
17
|
+
children?: React.ReactNode;
|
18
|
+
renderEmpty?: RenderEmptyHandler;
|
19
|
+
csp?: CSPConfig;
|
20
|
+
autoInsertSpaceInButton?: boolean;
|
21
|
+
form?: {
|
22
|
+
validateMessages?: ValidateMessages;
|
23
|
+
requiredMark?: RequiredMark;
|
24
|
+
colon?: boolean;
|
25
|
+
};
|
26
|
+
input?: {
|
27
|
+
autoComplete?: string;
|
28
|
+
};
|
29
|
+
pagination?: {
|
30
|
+
showSizeChanger?: boolean;
|
31
|
+
};
|
32
|
+
locale?: Locale;
|
33
|
+
pageHeader?: {
|
34
|
+
ghost: boolean;
|
35
|
+
};
|
36
|
+
componentSize?: SizeType;
|
37
|
+
componentDisabled?: boolean;
|
38
|
+
direction?: DirectionType;
|
39
|
+
space?: {
|
40
|
+
size?: SizeType | number;
|
41
|
+
};
|
42
|
+
virtual?: boolean;
|
43
|
+
dropdownMatchSelectWidth?: boolean;
|
44
|
+
}
|
45
|
+
export declare const defaultPrefixCls = "ant";
|
46
|
+
export declare const defaultIconPrefixCls = "anticon";
|
47
|
+
declare function getGlobalIconPrefixCls(): string;
|
48
|
+
declare const setGlobalConfig: ({ prefixCls, iconPrefixCls, theme, }: Pick<ConfigProviderProps, "prefixCls" | "iconPrefixCls"> & {
|
49
|
+
theme?: Theme | undefined;
|
50
|
+
}) => void;
|
51
|
+
export declare const globalConfig: () => {
|
52
|
+
getPrefixCls: (suffixCls?: string, customizePrefixCls?: string) => string;
|
53
|
+
getIconPrefixCls: typeof getGlobalIconPrefixCls;
|
54
|
+
getRootPrefixCls: (rootPrefixCls?: string, customizePrefixCls?: string) => string;
|
55
|
+
};
|
56
|
+
declare const ConfigProvider: React.FC<ConfigProviderProps> & {
|
57
|
+
ConfigContext: typeof ConfigContext;
|
58
|
+
SizeContext: typeof SizeContext;
|
59
|
+
config: typeof setGlobalConfig;
|
60
|
+
};
|
61
|
+
export default ConfigProvider;
|
@@ -1,14 +1,254 @@
|
|
1
|
-
|
1
|
+
"use strict";
|
2
2
|
|
3
|
-
|
4
|
-
import { ConfigProvider } from 'antd';
|
5
|
-
import zhCN from 'antd/es/locale/zh_CN';
|
6
|
-
import 'moment/locale/zh-cn';
|
3
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard")["default"];
|
7
4
|
|
8
|
-
var
|
9
|
-
|
10
|
-
|
11
|
-
|
5
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
|
6
|
+
|
7
|
+
Object.defineProperty(exports, "__esModule", {
|
8
|
+
value: true
|
9
|
+
});
|
10
|
+
Object.defineProperty(exports, "ConfigConsumer", {
|
11
|
+
enumerable: true,
|
12
|
+
get: function get() {
|
13
|
+
return _context.ConfigConsumer;
|
14
|
+
}
|
15
|
+
});
|
16
|
+
Object.defineProperty(exports, "ConfigContext", {
|
17
|
+
enumerable: true,
|
18
|
+
get: function get() {
|
19
|
+
return _context.ConfigContext;
|
20
|
+
}
|
21
|
+
});
|
22
|
+
exports.globalConfig = exports.defaultPrefixCls = exports.defaultIconPrefixCls = exports["default"] = exports.configConsumerProps = void 0;
|
23
|
+
|
24
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
25
|
+
|
26
|
+
var _Context = _interopRequireDefault(require("@ant-design/icons/lib/components/Context"));
|
27
|
+
|
28
|
+
var _rcFieldForm = require("rc-field-form");
|
29
|
+
|
30
|
+
var _useMemo = _interopRequireDefault(require("rc-util/lib/hooks/useMemo"));
|
31
|
+
|
32
|
+
var React = _interopRequireWildcard(require("react"));
|
33
|
+
|
34
|
+
var _localeProvider = _interopRequireWildcard(require("../locale-provider"));
|
35
|
+
|
36
|
+
var _LocaleReceiver = _interopRequireDefault(require("../locale-provider/LocaleReceiver"));
|
37
|
+
|
38
|
+
var _default2 = _interopRequireDefault(require("../locale/default"));
|
39
|
+
|
40
|
+
var _message = _interopRequireDefault(require("../message"));
|
41
|
+
|
42
|
+
var _notification = _interopRequireDefault(require("../notification"));
|
43
|
+
|
44
|
+
var _context = require("./context");
|
45
|
+
|
46
|
+
var _cssVariables = require("./cssVariables");
|
47
|
+
|
48
|
+
var _DisabledContext = require("./DisabledContext");
|
49
|
+
|
50
|
+
var _SizeContext = _interopRequireWildcard(require("./SizeContext"));
|
51
|
+
|
52
|
+
var configConsumerProps = ['getTargetContainer', 'getPopupContainer', 'rootPrefixCls', 'getPrefixCls', 'renderEmpty', 'csp', 'autoInsertSpaceInButton', 'locale', 'pageHeader']; // These props is used by `useContext` directly in sub component
|
53
|
+
|
54
|
+
exports.configConsumerProps = configConsumerProps;
|
55
|
+
var PASSED_PROPS = ['getTargetContainer', 'getPopupContainer', 'renderEmpty', 'pageHeader', 'input', 'pagination', 'form'];
|
56
|
+
var defaultPrefixCls = 'ant';
|
57
|
+
exports.defaultPrefixCls = defaultPrefixCls;
|
58
|
+
var defaultIconPrefixCls = 'anticon';
|
59
|
+
exports.defaultIconPrefixCls = defaultIconPrefixCls;
|
60
|
+
var globalPrefixCls;
|
61
|
+
var globalIconPrefixCls;
|
62
|
+
|
63
|
+
function getGlobalPrefixCls() {
|
64
|
+
return globalPrefixCls || defaultPrefixCls;
|
65
|
+
}
|
66
|
+
|
67
|
+
function getGlobalIconPrefixCls() {
|
68
|
+
return globalIconPrefixCls || defaultIconPrefixCls;
|
69
|
+
}
|
70
|
+
|
71
|
+
var setGlobalConfig = function setGlobalConfig(_ref) {
|
72
|
+
var prefixCls = _ref.prefixCls,
|
73
|
+
iconPrefixCls = _ref.iconPrefixCls,
|
74
|
+
theme = _ref.theme;
|
75
|
+
|
76
|
+
if (prefixCls !== undefined) {
|
77
|
+
globalPrefixCls = prefixCls;
|
78
|
+
}
|
79
|
+
|
80
|
+
if (iconPrefixCls !== undefined) {
|
81
|
+
globalIconPrefixCls = iconPrefixCls;
|
82
|
+
}
|
83
|
+
|
84
|
+
if (theme) {
|
85
|
+
(0, _cssVariables.registerTheme)(getGlobalPrefixCls(), theme);
|
86
|
+
}
|
12
87
|
};
|
13
88
|
|
14
|
-
|
89
|
+
var globalConfig = function globalConfig() {
|
90
|
+
return {
|
91
|
+
getPrefixCls: function getPrefixCls(suffixCls, customizePrefixCls) {
|
92
|
+
if (customizePrefixCls) return customizePrefixCls;
|
93
|
+
return suffixCls ? "".concat(getGlobalPrefixCls(), "-").concat(suffixCls) : getGlobalPrefixCls();
|
94
|
+
},
|
95
|
+
getIconPrefixCls: getGlobalIconPrefixCls,
|
96
|
+
getRootPrefixCls: function getRootPrefixCls(rootPrefixCls, customizePrefixCls) {
|
97
|
+
// Customize rootPrefixCls is first priority
|
98
|
+
if (rootPrefixCls) {
|
99
|
+
return rootPrefixCls;
|
100
|
+
} // If Global prefixCls provided, use this
|
101
|
+
|
102
|
+
|
103
|
+
if (globalPrefixCls) {
|
104
|
+
return globalPrefixCls;
|
105
|
+
} // [Legacy] If customize prefixCls provided, we cut it to get the prefixCls
|
106
|
+
|
107
|
+
|
108
|
+
if (customizePrefixCls && customizePrefixCls.includes('-')) {
|
109
|
+
return customizePrefixCls.replace(/^(.*)-[^-]*$/, '$1');
|
110
|
+
} // Fallback to default prefixCls
|
111
|
+
|
112
|
+
|
113
|
+
return getGlobalPrefixCls();
|
114
|
+
}
|
115
|
+
};
|
116
|
+
};
|
117
|
+
|
118
|
+
exports.globalConfig = globalConfig;
|
119
|
+
|
120
|
+
var ProviderChildren = function ProviderChildren(props) {
|
121
|
+
var _a, _b;
|
122
|
+
|
123
|
+
var children = props.children,
|
124
|
+
csp = props.csp,
|
125
|
+
autoInsertSpaceInButton = props.autoInsertSpaceInButton,
|
126
|
+
form = props.form,
|
127
|
+
locale = props.locale,
|
128
|
+
componentSize = props.componentSize,
|
129
|
+
direction = props.direction,
|
130
|
+
space = props.space,
|
131
|
+
virtual = props.virtual,
|
132
|
+
dropdownMatchSelectWidth = props.dropdownMatchSelectWidth,
|
133
|
+
legacyLocale = props.legacyLocale,
|
134
|
+
parentContext = props.parentContext,
|
135
|
+
iconPrefixCls = props.iconPrefixCls,
|
136
|
+
componentDisabled = props.componentDisabled;
|
137
|
+
var getPrefixCls = React.useCallback(function (suffixCls, customizePrefixCls) {
|
138
|
+
var prefixCls = props.prefixCls;
|
139
|
+
if (customizePrefixCls) return customizePrefixCls;
|
140
|
+
var mergedPrefixCls = prefixCls || parentContext.getPrefixCls('');
|
141
|
+
return suffixCls ? "".concat(mergedPrefixCls, "-").concat(suffixCls) : mergedPrefixCls;
|
142
|
+
}, [parentContext.getPrefixCls, props.prefixCls]);
|
143
|
+
var config = (0, _extends2["default"])((0, _extends2["default"])({}, parentContext), {
|
144
|
+
csp: csp,
|
145
|
+
autoInsertSpaceInButton: autoInsertSpaceInButton,
|
146
|
+
locale: locale || legacyLocale,
|
147
|
+
direction: direction,
|
148
|
+
space: space,
|
149
|
+
virtual: virtual,
|
150
|
+
dropdownMatchSelectWidth: dropdownMatchSelectWidth,
|
151
|
+
getPrefixCls: getPrefixCls
|
152
|
+
}); // Pass the props used by `useContext` directly with child component.
|
153
|
+
// These props should merged into `config`.
|
154
|
+
|
155
|
+
PASSED_PROPS.forEach(function (propName) {
|
156
|
+
var propValue = props[propName];
|
157
|
+
|
158
|
+
if (propValue) {
|
159
|
+
config[propName] = propValue;
|
160
|
+
}
|
161
|
+
}); // https://github.com/ant-design/ant-design/issues/27617
|
162
|
+
|
163
|
+
var memoedConfig = (0, _useMemo["default"])(function () {
|
164
|
+
return config;
|
165
|
+
}, config, function (prevConfig, currentConfig) {
|
166
|
+
var prevKeys = Object.keys(prevConfig);
|
167
|
+
var currentKeys = Object.keys(currentConfig);
|
168
|
+
return prevKeys.length !== currentKeys.length || prevKeys.some(function (key) {
|
169
|
+
return prevConfig[key] !== currentConfig[key];
|
170
|
+
});
|
171
|
+
});
|
172
|
+
var memoIconContextValue = React.useMemo(function () {
|
173
|
+
return {
|
174
|
+
prefixCls: iconPrefixCls,
|
175
|
+
csp: csp
|
176
|
+
};
|
177
|
+
}, [iconPrefixCls, csp]);
|
178
|
+
var childNode = children; // Additional Form provider
|
179
|
+
|
180
|
+
var validateMessages = {};
|
181
|
+
|
182
|
+
if (locale) {
|
183
|
+
validateMessages = ((_a = locale.Form) === null || _a === void 0 ? void 0 : _a.defaultValidateMessages) || ((_b = _default2["default"].Form) === null || _b === void 0 ? void 0 : _b.defaultValidateMessages) || {};
|
184
|
+
}
|
185
|
+
|
186
|
+
if (form && form.validateMessages) {
|
187
|
+
validateMessages = (0, _extends2["default"])((0, _extends2["default"])({}, validateMessages), form.validateMessages);
|
188
|
+
}
|
189
|
+
|
190
|
+
if (Object.keys(validateMessages).length > 0) {
|
191
|
+
childNode = /*#__PURE__*/React.createElement(_rcFieldForm.FormProvider, {
|
192
|
+
validateMessages: validateMessages
|
193
|
+
}, children);
|
194
|
+
}
|
195
|
+
|
196
|
+
if (locale) {
|
197
|
+
childNode = /*#__PURE__*/React.createElement(_localeProvider["default"], {
|
198
|
+
locale: locale,
|
199
|
+
_ANT_MARK__: _localeProvider.ANT_MARK
|
200
|
+
}, childNode);
|
201
|
+
}
|
202
|
+
|
203
|
+
if (iconPrefixCls || csp) {
|
204
|
+
childNode = /*#__PURE__*/React.createElement(_Context["default"].Provider, {
|
205
|
+
value: memoIconContextValue
|
206
|
+
}, childNode);
|
207
|
+
}
|
208
|
+
|
209
|
+
if (componentSize) {
|
210
|
+
childNode = /*#__PURE__*/React.createElement(_SizeContext.SizeContextProvider, {
|
211
|
+
size: componentSize
|
212
|
+
}, childNode);
|
213
|
+
}
|
214
|
+
|
215
|
+
if (componentDisabled !== undefined) {
|
216
|
+
childNode = /*#__PURE__*/React.createElement(_DisabledContext.DisabledContextProvider, {
|
217
|
+
disabled: componentDisabled
|
218
|
+
}, childNode);
|
219
|
+
}
|
220
|
+
|
221
|
+
return /*#__PURE__*/React.createElement(_context.ConfigContext.Provider, {
|
222
|
+
value: memoedConfig
|
223
|
+
}, childNode);
|
224
|
+
};
|
225
|
+
|
226
|
+
var ConfigProvider = function ConfigProvider(props) {
|
227
|
+
React.useEffect(function () {
|
228
|
+
if (props.direction) {
|
229
|
+
_message["default"].config({
|
230
|
+
rtl: props.direction === 'rtl'
|
231
|
+
});
|
232
|
+
|
233
|
+
_notification["default"].config({
|
234
|
+
rtl: props.direction === 'rtl'
|
235
|
+
});
|
236
|
+
}
|
237
|
+
}, [props.direction]);
|
238
|
+
return /*#__PURE__*/React.createElement(_LocaleReceiver["default"], null, function (_, __, legacyLocale) {
|
239
|
+
return /*#__PURE__*/React.createElement(_context.ConfigConsumer, null, function (context) {
|
240
|
+
return /*#__PURE__*/React.createElement(ProviderChildren, (0, _extends2["default"])({
|
241
|
+
parentContext: context,
|
242
|
+
legacyLocale: legacyLocale
|
243
|
+
}, props));
|
244
|
+
});
|
245
|
+
});
|
246
|
+
};
|
247
|
+
/** @private internal Usage. do not use in your production */
|
248
|
+
|
249
|
+
|
250
|
+
ConfigProvider.ConfigContext = _context.ConfigContext;
|
251
|
+
ConfigProvider.SizeContext = _SizeContext["default"];
|
252
|
+
ConfigProvider.config = setGlobalConfig;
|
253
|
+
var _default = ConfigProvider;
|
254
|
+
exports["default"] = _default;
|
@@ -0,0 +1 @@
|
|
1
|
+
import './index.less';
|