@hanwenbo/x-web-pro-components 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/es/blocks/index.d.ts +1 -0
- package/es/blocks/index.js +2 -0
- package/es/blocks/shared.d.ts +24 -0
- package/es/blocks/shared.js +77 -0
- package/es/components/card/index.d.ts +82 -0
- package/es/components/card/index.js +361 -0
- package/es/components/descriptions/index.d.ts +31 -0
- package/es/components/descriptions/index.js +434 -0
- package/es/components/field/index.d.ts +75 -0
- package/es/components/field/index.js +761 -0
- package/es/components/form/captcha.d.ts +19 -0
- package/es/components/form/captcha.js +165 -0
- package/es/components/form/colorPicker.d.ts +7 -0
- package/es/components/form/colorPicker.js +73 -0
- package/es/components/form/fieldControls.d.ts +43 -0
- package/es/components/form/fieldControls.js +282 -0
- package/es/components/form/index.d.ts +285 -0
- package/es/components/form/index.js +2268 -0
- package/es/components/form/loginForm.d.ts +22 -0
- package/es/components/form/loginForm.js +159 -0
- package/es/components/form/schemaForm.d.ts +30 -0
- package/es/components/form/schemaForm.js +644 -0
- package/es/components/form/stepsForm.d.ts +26 -0
- package/es/components/form/stepsForm.js +183 -0
- package/es/components/form/uploadButton.d.ts +20 -0
- package/es/components/form/uploadButton.js +134 -0
- package/es/components/form/uploadDragger.d.ts +13 -0
- package/es/components/form/uploadDragger.js +144 -0
- package/es/components/index.d.ts +9 -0
- package/es/components/index.js +9 -0
- package/es/components/layout/components/Help/index.d.ts +72 -0
- package/es/components/layout/components/Help/index.js +350 -0
- package/es/components/layout/index.d.ts +182 -0
- package/es/components/layout/index.js +892 -0
- package/es/components/list/index.d.ts +80 -0
- package/es/components/list/index.js +431 -0
- package/es/components/provider/context.d.ts +7 -0
- package/es/components/provider/context.js +21 -0
- package/es/components/provider/index.d.ts +28 -0
- package/es/components/provider/index.js +117 -0
- package/es/components/provider/intl.d.ts +38 -0
- package/es/components/provider/intl.js +112 -0
- package/es/components/provider/types.d.ts +37 -0
- package/es/components/provider/types.js +1 -0
- package/es/components/provider/useStyle/index.d.ts +28 -0
- package/es/components/provider/useStyle/index.js +208 -0
- package/es/components/skeleton/index.d.ts +61 -0
- package/es/components/skeleton/index.js +388 -0
- package/es/components/table/dragSortTable.d.ts +8 -0
- package/es/components/table/dragSortTable.js +229 -0
- package/es/components/table/editableTable.d.ts +31 -0
- package/es/components/table/editableTable.js +507 -0
- package/es/components/table/index.d.ts +52 -0
- package/es/components/table/index.js +1554 -0
- package/es/components/table/listToolBar.d.ts +48 -0
- package/es/components/table/listToolBar.js +194 -0
- package/es/components/table/search.d.ts +5 -0
- package/es/components/table/search.js +13 -0
- package/es/index.d.ts +4 -0
- package/es/index.js +4 -0
- package/es/types.d.ts +219 -0
- package/es/types.js +1 -0
- package/es/utils/attachPropertiesToComponent.d.ts +1 -0
- package/es/utils/attachPropertiesToComponent.js +6 -0
- package/es/utils/getRequestParams.d.ts +19 -0
- package/es/utils/getRequestParams.js +57 -0
- package/es/utils/getTableListColumns.d.ts +20 -0
- package/es/utils/getTableListColumns.js +36 -0
- package/es/utils/index.d.ts +4 -0
- package/es/utils/index.js +4 -0
- package/es/utils/loading.d.ts +3 -0
- package/es/utils/loading.js +25 -0
- package/es/version.d.ts +2 -0
- package/es/version.js +2 -0
- package/lib/blocks/index.d.ts +1 -0
- package/lib/blocks/index.js +5 -0
- package/lib/blocks/shared.d.ts +24 -0
- package/lib/blocks/shared.js +83 -0
- package/lib/components/card/index.d.ts +82 -0
- package/lib/components/card/index.js +368 -0
- package/lib/components/descriptions/index.d.ts +31 -0
- package/lib/components/descriptions/index.js +440 -0
- package/lib/components/field/index.d.ts +75 -0
- package/lib/components/field/index.js +767 -0
- package/lib/components/form/captcha.d.ts +19 -0
- package/lib/components/form/captcha.js +172 -0
- package/lib/components/form/colorPicker.d.ts +7 -0
- package/lib/components/form/colorPicker.js +79 -0
- package/lib/components/form/fieldControls.d.ts +43 -0
- package/lib/components/form/fieldControls.js +288 -0
- package/lib/components/form/index.d.ts +285 -0
- package/lib/components/form/index.js +2332 -0
- package/lib/components/form/loginForm.d.ts +22 -0
- package/lib/components/form/loginForm.js +165 -0
- package/lib/components/form/schemaForm.d.ts +30 -0
- package/lib/components/form/schemaForm.js +651 -0
- package/lib/components/form/stepsForm.d.ts +26 -0
- package/lib/components/form/stepsForm.js +189 -0
- package/lib/components/form/uploadButton.d.ts +20 -0
- package/lib/components/form/uploadButton.js +141 -0
- package/lib/components/form/uploadDragger.d.ts +13 -0
- package/lib/components/form/uploadDragger.js +151 -0
- package/lib/components/index.d.ts +9 -0
- package/lib/components/index.js +104 -0
- package/lib/components/layout/components/Help/index.d.ts +72 -0
- package/lib/components/layout/components/Help/index.js +356 -0
- package/lib/components/layout/index.d.ts +182 -0
- package/lib/components/layout/index.js +930 -0
- package/lib/components/list/index.d.ts +80 -0
- package/lib/components/list/index.js +438 -0
- package/lib/components/provider/context.d.ts +7 -0
- package/lib/components/provider/context.js +27 -0
- package/lib/components/provider/index.d.ts +28 -0
- package/lib/components/provider/index.js +174 -0
- package/lib/components/provider/intl.d.ts +38 -0
- package/lib/components/provider/intl.js +118 -0
- package/lib/components/provider/types.d.ts +37 -0
- package/lib/components/provider/types.js +5 -0
- package/lib/components/provider/useStyle/index.d.ts +28 -0
- package/lib/components/provider/useStyle/index.js +217 -0
- package/lib/components/skeleton/index.d.ts +61 -0
- package/lib/components/skeleton/index.js +394 -0
- package/lib/components/table/dragSortTable.d.ts +8 -0
- package/lib/components/table/dragSortTable.js +236 -0
- package/lib/components/table/editableTable.d.ts +31 -0
- package/lib/components/table/editableTable.js +514 -0
- package/lib/components/table/index.d.ts +52 -0
- package/lib/components/table/index.js +1699 -0
- package/lib/components/table/listToolBar.d.ts +48 -0
- package/lib/components/table/listToolBar.js +200 -0
- package/lib/components/table/search.d.ts +5 -0
- package/lib/components/table/search.js +20 -0
- package/lib/index.d.ts +4 -0
- package/lib/index.js +49 -0
- package/lib/types.d.ts +219 -0
- package/lib/types.js +5 -0
- package/lib/utils/attachPropertiesToComponent.d.ts +1 -0
- package/lib/utils/attachPropertiesToComponent.js +12 -0
- package/lib/utils/getRequestParams.d.ts +19 -0
- package/lib/utils/getRequestParams.js +63 -0
- package/lib/utils/getTableListColumns.d.ts +20 -0
- package/lib/utils/getTableListColumns.js +42 -0
- package/lib/utils/index.d.ts +4 -0
- package/lib/utils/index.js +49 -0
- package/lib/utils/loading.d.ts +3 -0
- package/lib/utils/loading.js +31 -0
- package/lib/version.d.ts +2 -0
- package/lib/version.js +8 -0
- package/package.json +68 -0
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _exportNames = {
|
|
7
|
+
isNeedOpenHash: true,
|
|
8
|
+
useProConfig: true,
|
|
9
|
+
useIntl: true,
|
|
10
|
+
ConfigConsumer: true,
|
|
11
|
+
IntlConsumer: true,
|
|
12
|
+
ProConfigProvider: true
|
|
13
|
+
};
|
|
14
|
+
exports.useProConfig = exports.useIntl = exports.isNeedOpenHash = exports.default = exports.ProConfigProvider = exports.IntlConsumer = exports.ConfigConsumer = void 0;
|
|
15
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
16
|
+
var _configProvider = require("@hanwenbo/x-web-ui/configProvider");
|
|
17
|
+
var _context = require("./context");
|
|
18
|
+
Object.keys(_context).forEach(function (key) {
|
|
19
|
+
if (key === "default" || key === "__esModule") return;
|
|
20
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
21
|
+
if (key in exports && exports[key] === _context[key]) return;
|
|
22
|
+
Object.defineProperty(exports, key, {
|
|
23
|
+
enumerable: true,
|
|
24
|
+
get: function get() {
|
|
25
|
+
return _context[key];
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
var _intl = require("./intl");
|
|
30
|
+
Object.keys(_intl).forEach(function (key) {
|
|
31
|
+
if (key === "default" || key === "__esModule") return;
|
|
32
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
33
|
+
if (key in exports && exports[key] === _intl[key]) return;
|
|
34
|
+
Object.defineProperty(exports, key, {
|
|
35
|
+
enumerable: true,
|
|
36
|
+
get: function get() {
|
|
37
|
+
return _intl[key];
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
42
|
+
var _types = require("./types");
|
|
43
|
+
Object.keys(_types).forEach(function (key) {
|
|
44
|
+
if (key === "default" || key === "__esModule") return;
|
|
45
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
46
|
+
if (key in exports && exports[key] === _types[key]) return;
|
|
47
|
+
Object.defineProperty(exports, key, {
|
|
48
|
+
enumerable: true,
|
|
49
|
+
get: function get() {
|
|
50
|
+
return _types[key];
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
var _useStyle = require("./useStyle");
|
|
55
|
+
Object.keys(_useStyle).forEach(function (key) {
|
|
56
|
+
if (key === "default" || key === "__esModule") return;
|
|
57
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
58
|
+
if (key in exports && exports[key] === _useStyle[key]) return;
|
|
59
|
+
Object.defineProperty(exports, key, {
|
|
60
|
+
enumerable: true,
|
|
61
|
+
get: function get() {
|
|
62
|
+
return _useStyle[key];
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
var _excluded = ["prefixCls", "valueTypeMap", "token", "hashed", "dark", "intl", "autoClearCache", "needDeps", "children"];
|
|
67
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
68
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
69
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
70
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
71
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
72
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
73
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
74
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
75
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
76
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
77
|
+
var getNodeEnv = function getNodeEnv() {
|
|
78
|
+
var _process;
|
|
79
|
+
return (_process = globalThis.process) === null || _process === void 0 || (_process = _process.env) === null || _process === void 0 ? void 0 : _process.NODE_ENV;
|
|
80
|
+
};
|
|
81
|
+
var isNeedOpenHash = exports.isNeedOpenHash = function isNeedOpenHash() {
|
|
82
|
+
var _getNodeEnv;
|
|
83
|
+
var env = (_getNodeEnv = getNodeEnv()) === null || _getNodeEnv === void 0 ? void 0 : _getNodeEnv.toUpperCase();
|
|
84
|
+
if (env === 'TEST' || env === 'DEV') {
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
return true;
|
|
88
|
+
};
|
|
89
|
+
var useProConfig = exports.useProConfig = function useProConfig() {
|
|
90
|
+
return (0, _react.useContext)(_context.ProProvider);
|
|
91
|
+
};
|
|
92
|
+
var useIntl = exports.useIntl = function useIntl() {
|
|
93
|
+
return useProConfig().intl;
|
|
94
|
+
};
|
|
95
|
+
var ConfigConsumer = exports.ConfigConsumer = _context.ProProvider.Consumer;
|
|
96
|
+
var IntlConsumer = exports.IntlConsumer = _context.ProProvider.Consumer;
|
|
97
|
+
var hashString = function hashString(input) {
|
|
98
|
+
var hash = 5381;
|
|
99
|
+
for (var index = 0; index < input.length; index += 1) {
|
|
100
|
+
hash = hash * 33 ^ input.charCodeAt(index);
|
|
101
|
+
}
|
|
102
|
+
return (hash >>> 0).toString(36);
|
|
103
|
+
};
|
|
104
|
+
var mergeToken = function mergeToken(parentToken, currentToken, prefixCls) {
|
|
105
|
+
var mergedToken = _objectSpread(_objectSpread({}, parentToken || {}), currentToken || {});
|
|
106
|
+
mergedToken.antCls = mergedToken.antCls || '.x-web-ui';
|
|
107
|
+
mergedToken.proComponentsCls = mergedToken.proComponentsCls || ".".concat(prefixCls);
|
|
108
|
+
mergedToken.themeId = mergedToken.themeId || 0;
|
|
109
|
+
return mergedToken;
|
|
110
|
+
};
|
|
111
|
+
var ProConfigProvider = exports.ProConfigProvider = function ProConfigProvider(_ref) {
|
|
112
|
+
var _ref2, _ref3;
|
|
113
|
+
var prefixCls = _ref.prefixCls,
|
|
114
|
+
_ref$valueTypeMap = _ref.valueTypeMap,
|
|
115
|
+
valueTypeMap = _ref$valueTypeMap === void 0 ? {} : _ref$valueTypeMap,
|
|
116
|
+
token = _ref.token,
|
|
117
|
+
hashed = _ref.hashed,
|
|
118
|
+
dark = _ref.dark,
|
|
119
|
+
_ref$intl = _ref.intl,
|
|
120
|
+
intl = _ref$intl === void 0 ? _intl.zhCNIntl : _ref$intl,
|
|
121
|
+
_ref$autoClearCache = _ref.autoClearCache,
|
|
122
|
+
autoClearCache = _ref$autoClearCache === void 0 ? false : _ref$autoClearCache,
|
|
123
|
+
_ref$needDeps = _ref.needDeps,
|
|
124
|
+
needDeps = _ref$needDeps === void 0 ? false : _ref$needDeps,
|
|
125
|
+
children = _ref.children,
|
|
126
|
+
configProviderProps = _objectWithoutProperties(_ref, _excluded);
|
|
127
|
+
var parentConfig = (0, _react.useContext)(_context.ProProvider);
|
|
128
|
+
var isNeedDepsPassThrough = needDeps && parentConfig.hashId !== undefined && Object.keys({
|
|
129
|
+
children: children,
|
|
130
|
+
needDeps: needDeps
|
|
131
|
+
}).sort().join('-') === 'children-needDeps';
|
|
132
|
+
var resolvedHashed = (_ref2 = hashed !== null && hashed !== void 0 ? hashed : parentConfig.hashed) !== null && _ref2 !== void 0 ? _ref2 : isNeedOpenHash();
|
|
133
|
+
var mergedPrefixCls = (_ref3 = prefixCls !== null && prefixCls !== void 0 ? prefixCls : parentConfig.prefixCls) !== null && _ref3 !== void 0 ? _ref3 : 'x-web-pro';
|
|
134
|
+
var mergedIntl = intl || parentConfig.intl || _intl.zhCNIntl;
|
|
135
|
+
var mergedToken = (0, _react.useMemo)(function () {
|
|
136
|
+
return mergeToken(parentConfig.token, token, mergedPrefixCls);
|
|
137
|
+
}, [mergedPrefixCls, parentConfig.token, token]);
|
|
138
|
+
var mergedCache = (0, _react.useMemo)(function () {
|
|
139
|
+
if (!autoClearCache && parentConfig.cache) {
|
|
140
|
+
return parentConfig.cache;
|
|
141
|
+
}
|
|
142
|
+
return new Map();
|
|
143
|
+
}, [autoClearCache, parentConfig.cache]);
|
|
144
|
+
var computedHashId = (0, _react.useMemo)(function () {
|
|
145
|
+
if (!resolvedHashed) {
|
|
146
|
+
return '';
|
|
147
|
+
}
|
|
148
|
+
return "".concat(mergedPrefixCls, "-").concat(hashString(JSON.stringify(mergedToken)));
|
|
149
|
+
}, [mergedPrefixCls, mergedToken, resolvedHashed]);
|
|
150
|
+
var contextValue = (0, _react.useMemo)(function () {
|
|
151
|
+
return {
|
|
152
|
+
cache: mergedCache,
|
|
153
|
+
dark: dark !== null && dark !== void 0 ? dark : parentConfig.dark,
|
|
154
|
+
hashId: computedHashId,
|
|
155
|
+
hashed: resolvedHashed,
|
|
156
|
+
intl: mergedIntl,
|
|
157
|
+
prefixCls: mergedPrefixCls,
|
|
158
|
+
token: mergedToken,
|
|
159
|
+
valueTypeMap: _objectSpread(_objectSpread({}, parentConfig.valueTypeMap || {}), valueTypeMap)
|
|
160
|
+
};
|
|
161
|
+
}, [computedHashId, dark, mergedCache, mergedIntl, mergedPrefixCls, mergedToken, parentConfig.dark, parentConfig.valueTypeMap, resolvedHashed, valueTypeMap]);
|
|
162
|
+
if (isNeedDepsPassThrough) {
|
|
163
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
|
|
164
|
+
children: children
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_configProvider.ConfigProvider, _objectSpread(_objectSpread({}, configProviderProps), {}, {
|
|
168
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_context.ProProvider.Provider, {
|
|
169
|
+
value: contextValue,
|
|
170
|
+
children: children
|
|
171
|
+
})
|
|
172
|
+
}));
|
|
173
|
+
};
|
|
174
|
+
var _default = exports.default = _context.ProProvider;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { IntlType } from './types';
|
|
2
|
+
export declare const createIntl: (locale: string, messages?: Record<string, string>) => IntlType;
|
|
3
|
+
export declare const mnMNIntl: IntlType;
|
|
4
|
+
export declare const arEGIntl: IntlType;
|
|
5
|
+
export declare const zhCNIntl: IntlType;
|
|
6
|
+
export declare const enUSIntl: IntlType;
|
|
7
|
+
export declare const enGBIntl: IntlType;
|
|
8
|
+
export declare const viVNIntl: IntlType;
|
|
9
|
+
export declare const itITIntl: IntlType;
|
|
10
|
+
export declare const jaJPIntl: IntlType;
|
|
11
|
+
export declare const esESIntl: IntlType;
|
|
12
|
+
export declare const caESIntl: IntlType;
|
|
13
|
+
export declare const ruRUIntl: IntlType;
|
|
14
|
+
export declare const srRSIntl: IntlType;
|
|
15
|
+
export declare const msMYIntl: IntlType;
|
|
16
|
+
export declare const zhTWIntl: IntlType;
|
|
17
|
+
export declare const zhHKIntl: IntlType;
|
|
18
|
+
export declare const frFRIntl: IntlType;
|
|
19
|
+
export declare const ptBRIntl: IntlType;
|
|
20
|
+
export declare const koKRIntl: IntlType;
|
|
21
|
+
export declare const idIDIntl: IntlType;
|
|
22
|
+
export declare const deDEIntl: IntlType;
|
|
23
|
+
export declare const faIRIntl: IntlType;
|
|
24
|
+
export declare const trTRIntl: IntlType;
|
|
25
|
+
export declare const plPLIntl: IntlType;
|
|
26
|
+
export declare const hrHRIntl: IntlType;
|
|
27
|
+
export declare const thTHIntl: IntlType;
|
|
28
|
+
export declare const csCZIntl: IntlType;
|
|
29
|
+
export declare const skSKIntl: IntlType;
|
|
30
|
+
export declare const heILIntl: IntlType;
|
|
31
|
+
export declare const ukUAIntl: IntlType;
|
|
32
|
+
export declare const uzUZIntl: IntlType;
|
|
33
|
+
export declare const nlNLIntl: IntlType;
|
|
34
|
+
export declare const roROIntl: IntlType;
|
|
35
|
+
export declare const svSEIntl: IntlType;
|
|
36
|
+
export declare const intlMap: Record<string, IntlType>;
|
|
37
|
+
export declare const intlMapKeys: string[];
|
|
38
|
+
export declare const findIntlKeyByAntdLocaleKey: <T extends string>(localeKey?: T | undefined) => T | undefined;
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.zhTWIntl = exports.zhHKIntl = exports.zhCNIntl = exports.viVNIntl = exports.uzUZIntl = exports.ukUAIntl = exports.trTRIntl = exports.thTHIntl = exports.svSEIntl = exports.srRSIntl = exports.skSKIntl = exports.ruRUIntl = exports.roROIntl = exports.ptBRIntl = exports.plPLIntl = exports.nlNLIntl = exports.msMYIntl = exports.mnMNIntl = exports.koKRIntl = exports.jaJPIntl = exports.itITIntl = exports.intlMapKeys = exports.intlMap = exports.idIDIntl = exports.hrHRIntl = exports.heILIntl = exports.frFRIntl = exports.findIntlKeyByAntdLocaleKey = exports.faIRIntl = exports.esESIntl = exports.enUSIntl = exports.enGBIntl = exports.deDEIntl = exports.csCZIntl = exports.createIntl = exports.caESIntl = exports.arEGIntl = void 0;
|
|
7
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
8
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
9
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
10
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
11
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
12
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
13
|
+
var createMessages = function createMessages(locale, overrides) {
|
|
14
|
+
return _objectSpread({
|
|
15
|
+
moneySymbol: locale.toLowerCase().startsWith('en') ? '$' : locale.toLowerCase().startsWith('zh') ? '¥' : '¥',
|
|
16
|
+
'tableForm.search': locale.toLowerCase().startsWith('zh') ? '查询' : 'Search',
|
|
17
|
+
'tableForm.reset': locale.toLowerCase().startsWith('zh') ? '重置' : 'Reset',
|
|
18
|
+
'tableForm.option': locale.toLowerCase().startsWith('zh') ? '操作' : 'Actions',
|
|
19
|
+
'tableForm.expand': locale.toLowerCase().startsWith('zh') ? '收起' : 'Collapse',
|
|
20
|
+
'tableForm.collapsed': locale.toLowerCase().startsWith('zh') ? '展开' : 'Expand',
|
|
21
|
+
'modalForm.submit': locale.toLowerCase().startsWith('zh') ? '提交' : 'Submit',
|
|
22
|
+
'modalForm.cancel': locale.toLowerCase().startsWith('zh') ? '取消' : 'Cancel',
|
|
23
|
+
'tableForm.empty': locale.toLowerCase().startsWith('zh') ? '暂无数据' : undefined
|
|
24
|
+
}, overrides);
|
|
25
|
+
};
|
|
26
|
+
var zhCNMessages = createMessages('zh-CN');
|
|
27
|
+
var createIntl = exports.createIntl = function createIntl(locale) {
|
|
28
|
+
var messages = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
29
|
+
var normalizedLocale = locale.replace(/_/g, '-');
|
|
30
|
+
var mergedMessages = createMessages(normalizedLocale, messages);
|
|
31
|
+
return {
|
|
32
|
+
locale: normalizedLocale,
|
|
33
|
+
getMessage: function getMessage(id, defaultMessage) {
|
|
34
|
+
if (mergedMessages[id]) {
|
|
35
|
+
return mergedMessages[id];
|
|
36
|
+
}
|
|
37
|
+
if (normalizedLocale.toLowerCase() !== 'zh-cn' && zhCNMessages[id]) {
|
|
38
|
+
return zhCNMessages[id];
|
|
39
|
+
}
|
|
40
|
+
return defaultMessage || id;
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
var mnMNIntl = exports.mnMNIntl = createIntl('mn-MN');
|
|
45
|
+
var arEGIntl = exports.arEGIntl = createIntl('ar-EG');
|
|
46
|
+
var zhCNIntl = exports.zhCNIntl = createIntl('zh-CN');
|
|
47
|
+
var enUSIntl = exports.enUSIntl = createIntl('en-US');
|
|
48
|
+
var enGBIntl = exports.enGBIntl = createIntl('en-GB');
|
|
49
|
+
var viVNIntl = exports.viVNIntl = createIntl('vi-VN');
|
|
50
|
+
var itITIntl = exports.itITIntl = createIntl('it-IT');
|
|
51
|
+
var jaJPIntl = exports.jaJPIntl = createIntl('ja-JP');
|
|
52
|
+
var esESIntl = exports.esESIntl = createIntl('es-ES');
|
|
53
|
+
var caESIntl = exports.caESIntl = createIntl('ca-ES');
|
|
54
|
+
var ruRUIntl = exports.ruRUIntl = createIntl('ru-RU');
|
|
55
|
+
var srRSIntl = exports.srRSIntl = createIntl('sr-RS');
|
|
56
|
+
var msMYIntl = exports.msMYIntl = createIntl('ms-MY');
|
|
57
|
+
var zhTWIntl = exports.zhTWIntl = createIntl('zh-TW');
|
|
58
|
+
var zhHKIntl = exports.zhHKIntl = createIntl('zh-HK');
|
|
59
|
+
var frFRIntl = exports.frFRIntl = createIntl('fr-FR');
|
|
60
|
+
var ptBRIntl = exports.ptBRIntl = createIntl('pt-BR');
|
|
61
|
+
var koKRIntl = exports.koKRIntl = createIntl('ko-KR');
|
|
62
|
+
var idIDIntl = exports.idIDIntl = createIntl('id-ID');
|
|
63
|
+
var deDEIntl = exports.deDEIntl = createIntl('de-DE');
|
|
64
|
+
var faIRIntl = exports.faIRIntl = createIntl('fa-IR');
|
|
65
|
+
var trTRIntl = exports.trTRIntl = createIntl('tr-TR');
|
|
66
|
+
var plPLIntl = exports.plPLIntl = createIntl('pl-PL');
|
|
67
|
+
var hrHRIntl = exports.hrHRIntl = createIntl('hr-HR');
|
|
68
|
+
var thTHIntl = exports.thTHIntl = createIntl('th-TH');
|
|
69
|
+
var csCZIntl = exports.csCZIntl = createIntl('cs-CZ');
|
|
70
|
+
var skSKIntl = exports.skSKIntl = createIntl('sk-SK');
|
|
71
|
+
var heILIntl = exports.heILIntl = createIntl('he-IL');
|
|
72
|
+
var ukUAIntl = exports.ukUAIntl = createIntl('uk-UA');
|
|
73
|
+
var uzUZIntl = exports.uzUZIntl = createIntl('uz-UZ');
|
|
74
|
+
var nlNLIntl = exports.nlNLIntl = createIntl('nl-NL');
|
|
75
|
+
var roROIntl = exports.roROIntl = createIntl('ro-RO');
|
|
76
|
+
var svSEIntl = exports.svSEIntl = createIntl('sv-SE');
|
|
77
|
+
var intlMap = exports.intlMap = {
|
|
78
|
+
'ar-EG': arEGIntl,
|
|
79
|
+
'ca-ES': caESIntl,
|
|
80
|
+
'cs-CZ': csCZIntl,
|
|
81
|
+
'de-DE': deDEIntl,
|
|
82
|
+
'en-GB': enGBIntl,
|
|
83
|
+
'en-US': enUSIntl,
|
|
84
|
+
'es-ES': esESIntl,
|
|
85
|
+
'fa-IR': faIRIntl,
|
|
86
|
+
'fr-FR': frFRIntl,
|
|
87
|
+
'he-IL': heILIntl,
|
|
88
|
+
'hr-HR': hrHRIntl,
|
|
89
|
+
'id-ID': idIDIntl,
|
|
90
|
+
'it-IT': itITIntl,
|
|
91
|
+
'ja-JP': jaJPIntl,
|
|
92
|
+
'ko-KR': koKRIntl,
|
|
93
|
+
'mn-MN': mnMNIntl,
|
|
94
|
+
'ms-MY': msMYIntl,
|
|
95
|
+
'nl-NL': nlNLIntl,
|
|
96
|
+
'pl-PL': plPLIntl,
|
|
97
|
+
'pt-BR': ptBRIntl,
|
|
98
|
+
'ro-RO': roROIntl,
|
|
99
|
+
'ru-RU': ruRUIntl,
|
|
100
|
+
'sk-SK': skSKIntl,
|
|
101
|
+
'sr-RS': srRSIntl,
|
|
102
|
+
'sv-SE': svSEIntl,
|
|
103
|
+
'th-TH': thTHIntl,
|
|
104
|
+
'tr-TR': trTRIntl,
|
|
105
|
+
'uk-UA': ukUAIntl,
|
|
106
|
+
'uz-UZ': uzUZIntl,
|
|
107
|
+
'vi-VN': viVNIntl,
|
|
108
|
+
'zh-CN': zhCNIntl,
|
|
109
|
+
'zh-HK': zhHKIntl,
|
|
110
|
+
'zh-TW': zhTWIntl
|
|
111
|
+
};
|
|
112
|
+
var intlMapKeys = exports.intlMapKeys = Object.keys(intlMap);
|
|
113
|
+
var findIntlKeyByAntdLocaleKey = exports.findIntlKeyByAntdLocaleKey = function findIntlKeyByAntdLocaleKey(localeKey) {
|
|
114
|
+
var localeName = (localeKey || 'zh-CN').toLowerCase().replace(/_/g, '-');
|
|
115
|
+
return intlMapKeys.find(function (intlKey) {
|
|
116
|
+
return intlKey.toLowerCase() === localeName;
|
|
117
|
+
});
|
|
118
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
import type { ProFieldFCMode, ProRenderFieldPropsType, ProSchemaValueEnumType } from '../../types';
|
|
3
|
+
import type { IntlType } from './intl';
|
|
4
|
+
export type { ProFieldFCMode, ProRenderFieldPropsType, ProSchemaValueEnumType };
|
|
5
|
+
export declare type ParamsType = Record<string, any>;
|
|
6
|
+
export declare type DeepPartial<T> = {
|
|
7
|
+
[P in keyof T]?: T[P] extends Record<string, any> ? DeepPartial<T[P]> : T[P];
|
|
8
|
+
};
|
|
9
|
+
export declare type ProTokenType = Record<string, any>;
|
|
10
|
+
export declare type ProFieldFCRenderProps = {
|
|
11
|
+
label?: React.ReactNode;
|
|
12
|
+
light?: boolean;
|
|
13
|
+
mode?: ProFieldFCMode;
|
|
14
|
+
onChange?: (...args: any[]) => void;
|
|
15
|
+
placeholder?: string | string[];
|
|
16
|
+
readonly?: boolean;
|
|
17
|
+
value?: any;
|
|
18
|
+
};
|
|
19
|
+
export declare type BaseProFieldFC = {
|
|
20
|
+
fieldProps?: any;
|
|
21
|
+
label?: React.ReactNode;
|
|
22
|
+
light?: boolean;
|
|
23
|
+
mode?: ProFieldFCMode;
|
|
24
|
+
proFieldKey?: React.Key;
|
|
25
|
+
text: React.ReactNode;
|
|
26
|
+
valueEnum?: Record<string, ProSchemaValueEnumType | React.ReactNode> | Map<any, any>;
|
|
27
|
+
};
|
|
28
|
+
export declare type ConfigContextPropsType = {
|
|
29
|
+
cache?: Map<any, any>;
|
|
30
|
+
dark?: boolean;
|
|
31
|
+
hashId?: string;
|
|
32
|
+
hashed?: boolean;
|
|
33
|
+
intl: IntlType;
|
|
34
|
+
prefixCls: string;
|
|
35
|
+
token: ProTokenType;
|
|
36
|
+
valueTypeMap: Record<string, ProRenderFieldPropsType>;
|
|
37
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ProTokenType } from '../types';
|
|
3
|
+
export declare const setAlpha: (baseColor: string, alpha: number) => string;
|
|
4
|
+
export declare const lighten: (baseColor: string, brightness: number) => string;
|
|
5
|
+
export declare type CSSObject = Record<string, any>;
|
|
6
|
+
export declare type CSSInterpolation = CSSObject | string | number | Array<CSSObject | string | number>;
|
|
7
|
+
export declare type GenerateStyle<ComponentToken extends object = Record<string, any>, ReturnType = CSSInterpolation> = (token: ComponentToken, ...rest: any[]) => ReturnType;
|
|
8
|
+
export declare type ProAliasToken = ProTokenType & {
|
|
9
|
+
themeId: number;
|
|
10
|
+
proComponentsCls: string;
|
|
11
|
+
antCls: string;
|
|
12
|
+
};
|
|
13
|
+
export declare const proTheme: {
|
|
14
|
+
useToken: () => {
|
|
15
|
+
hashId: string;
|
|
16
|
+
theme: {
|
|
17
|
+
id: number;
|
|
18
|
+
};
|
|
19
|
+
token: ProAliasToken;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
export declare const resetComponent: (token: ProAliasToken) => CSSObject;
|
|
23
|
+
export declare const operationUnit: (token: ProAliasToken) => CSSObject;
|
|
24
|
+
export declare type UseStyleResult = {
|
|
25
|
+
wrapSSR: (node: React.ReactElement) => React.ReactElement;
|
|
26
|
+
hashId: string;
|
|
27
|
+
};
|
|
28
|
+
export declare function useStyle(componentName: string, styleFn: (token: ProAliasToken) => CSSInterpolation): UseStyleResult;
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.setAlpha = exports.resetComponent = exports.proTheme = exports.operationUnit = exports.lighten = void 0;
|
|
7
|
+
exports.useStyle = useStyle;
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
var _context = require("../context");
|
|
10
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
11
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
12
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
13
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
14
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
15
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
16
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
17
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
18
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
19
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
20
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
21
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
22
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
23
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
24
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
25
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
26
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
27
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
28
|
+
var clamp = function clamp(value, min, max) {
|
|
29
|
+
return Math.min(Math.max(value, min), max);
|
|
30
|
+
};
|
|
31
|
+
var normalizeHex = function normalizeHex(color) {
|
|
32
|
+
var raw = color.replace('#', '').trim();
|
|
33
|
+
if (raw.length === 3) {
|
|
34
|
+
return raw.split('').map(function (char) {
|
|
35
|
+
return char + char;
|
|
36
|
+
}).join('');
|
|
37
|
+
}
|
|
38
|
+
return raw.length === 6 ? raw : '';
|
|
39
|
+
};
|
|
40
|
+
var toRgb = function toRgb(color) {
|
|
41
|
+
var hex = normalizeHex(color);
|
|
42
|
+
if (!hex) {
|
|
43
|
+
return undefined;
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
r: parseInt(hex.slice(0, 2), 16),
|
|
47
|
+
g: parseInt(hex.slice(2, 4), 16),
|
|
48
|
+
b: parseInt(hex.slice(4, 6), 16)
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
var setAlpha = exports.setAlpha = function setAlpha(baseColor, alpha) {
|
|
52
|
+
var rgb = toRgb(baseColor);
|
|
53
|
+
if (!rgb) {
|
|
54
|
+
return baseColor;
|
|
55
|
+
}
|
|
56
|
+
return "rgba(".concat(rgb.r, ", ").concat(rgb.g, ", ").concat(rgb.b, ", ").concat(clamp(alpha, 0, 1), ")");
|
|
57
|
+
};
|
|
58
|
+
var lighten = exports.lighten = function lighten(baseColor, brightness) {
|
|
59
|
+
var rgb = toRgb(baseColor);
|
|
60
|
+
if (!rgb) {
|
|
61
|
+
return baseColor;
|
|
62
|
+
}
|
|
63
|
+
var ratio = clamp(brightness, 0, 100) / 100;
|
|
64
|
+
var toHex = function toHex(value) {
|
|
65
|
+
return Math.round(value).toString(16).padStart(2, '0');
|
|
66
|
+
};
|
|
67
|
+
return "#".concat(toHex(rgb.r + (255 - rgb.r) * ratio)).concat(toHex(rgb.g + (255 - rgb.g) * ratio)).concat(toHex(rgb.b + (255 - rgb.b) * ratio));
|
|
68
|
+
};
|
|
69
|
+
var proTheme = exports.proTheme = {
|
|
70
|
+
useToken: function useToken() {
|
|
71
|
+
var _useProConfig = (0, _context.useProConfig)(),
|
|
72
|
+
hashId = _useProConfig.hashId,
|
|
73
|
+
hashed = _useProConfig.hashed,
|
|
74
|
+
prefixCls = _useProConfig.prefixCls,
|
|
75
|
+
token = _useProConfig.token;
|
|
76
|
+
return {
|
|
77
|
+
hashId: hashed ? hashId || "".concat(prefixCls, "-hash") : '',
|
|
78
|
+
theme: {
|
|
79
|
+
id: 0
|
|
80
|
+
},
|
|
81
|
+
token: _objectSpread(_objectSpread({}, token), {}, {
|
|
82
|
+
antCls: '.x-web-ui',
|
|
83
|
+
proComponentsCls: ".".concat(prefixCls),
|
|
84
|
+
themeId: 0
|
|
85
|
+
})
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
var resetComponent = exports.resetComponent = function resetComponent(token) {
|
|
90
|
+
return {
|
|
91
|
+
boxSizing: 'border-box',
|
|
92
|
+
color: token.colorText || 'inherit',
|
|
93
|
+
fontSize: token.fontSize || 14,
|
|
94
|
+
lineHeight: token.lineHeight || 1.5,
|
|
95
|
+
margin: 0,
|
|
96
|
+
padding: 0,
|
|
97
|
+
'*, *::before, *::after': {
|
|
98
|
+
boxSizing: 'border-box'
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
var operationUnit = exports.operationUnit = function operationUnit(token) {
|
|
103
|
+
return {
|
|
104
|
+
color: token.colorLink || token.colorPrimary || 'inherit',
|
|
105
|
+
cursor: 'pointer',
|
|
106
|
+
outline: 'none',
|
|
107
|
+
transition: 'color 0.2s'
|
|
108
|
+
};
|
|
109
|
+
};
|
|
110
|
+
var styleUsageMap = new Map();
|
|
111
|
+
var toKebabCase = function toKebabCase(value) {
|
|
112
|
+
return value.replace(/[A-Z]/g, function (match) {
|
|
113
|
+
return "-".concat(match.toLowerCase());
|
|
114
|
+
});
|
|
115
|
+
};
|
|
116
|
+
var isPlainObject = function isPlainObject(value) {
|
|
117
|
+
return Object.prototype.toString.call(value) === '[object Object]';
|
|
118
|
+
};
|
|
119
|
+
var serializeDeclarations = function serializeDeclarations(styles) {
|
|
120
|
+
return Object.entries(styles).filter(function (_ref) {
|
|
121
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
122
|
+
value = _ref2[1];
|
|
123
|
+
return value !== undefined && value !== null && _typeof(value) !== 'object';
|
|
124
|
+
}).map(function (_ref3) {
|
|
125
|
+
var _ref4 = _slicedToArray(_ref3, 2),
|
|
126
|
+
key = _ref4[0],
|
|
127
|
+
value = _ref4[1];
|
|
128
|
+
return "".concat(toKebabCase(key), ":").concat(String(value), ";");
|
|
129
|
+
}).join('');
|
|
130
|
+
};
|
|
131
|
+
var serializeRules = function serializeRules(selector, styles) {
|
|
132
|
+
var declarations = serializeDeclarations(styles);
|
|
133
|
+
var nestedRules = Object.entries(styles).filter(function (_ref5) {
|
|
134
|
+
var _ref6 = _slicedToArray(_ref5, 2),
|
|
135
|
+
value = _ref6[1];
|
|
136
|
+
return value !== undefined && value !== null && _typeof(value) === 'object';
|
|
137
|
+
}).flatMap(function (_ref7) {
|
|
138
|
+
var _ref8 = _slicedToArray(_ref7, 2),
|
|
139
|
+
key = _ref8[0],
|
|
140
|
+
value = _ref8[1];
|
|
141
|
+
if (!isPlainObject(value) && !Array.isArray(value)) {
|
|
142
|
+
return [];
|
|
143
|
+
}
|
|
144
|
+
if (key.startsWith('@')) {
|
|
145
|
+
return "".concat(key, "{").concat(serializeRules(selector, value), "}");
|
|
146
|
+
}
|
|
147
|
+
var nextSelector = key.includes('&') ? key.replace(/&/g, selector) : "".concat(selector, " ").concat(key);
|
|
148
|
+
return serializeRules(nextSelector, value);
|
|
149
|
+
});
|
|
150
|
+
var currentRule = declarations ? "".concat(selector, "{").concat(declarations, "}") : '';
|
|
151
|
+
return [currentRule].concat(_toConsumableArray(nestedRules)).filter(Boolean).join('');
|
|
152
|
+
};
|
|
153
|
+
var styleToCssText = function styleToCssText(selector, style) {
|
|
154
|
+
if (typeof style === 'string' || typeof style === 'number') {
|
|
155
|
+
return "".concat(selector, "{").concat(String(style), "}");
|
|
156
|
+
}
|
|
157
|
+
if (Array.isArray(style)) {
|
|
158
|
+
return style.map(function (item) {
|
|
159
|
+
return styleToCssText(selector, item);
|
|
160
|
+
}).join('');
|
|
161
|
+
}
|
|
162
|
+
if (!style || !isPlainObject(style)) {
|
|
163
|
+
return '';
|
|
164
|
+
}
|
|
165
|
+
return serializeRules(selector, style);
|
|
166
|
+
};
|
|
167
|
+
function useStyle(componentName, styleFn) {
|
|
168
|
+
var _useProConfig2 = (0, _context.useProConfig)(),
|
|
169
|
+
hashId = _useProConfig2.hashId,
|
|
170
|
+
hashed = _useProConfig2.hashed,
|
|
171
|
+
token = _useProConfig2.token;
|
|
172
|
+
var mergedHashId = hashed ? "".concat(hashId || 'x-web-pro', "-").concat(componentName) : '';
|
|
173
|
+
var styleId = mergedHashId ? "x-web-pro-style-".concat(mergedHashId) : '';
|
|
174
|
+
var cssText = (0, _react.useMemo)(function () {
|
|
175
|
+
if (!mergedHashId) {
|
|
176
|
+
return '';
|
|
177
|
+
}
|
|
178
|
+
return styleToCssText(".".concat(mergedHashId), styleFn(token));
|
|
179
|
+
}, [mergedHashId, styleFn, token]);
|
|
180
|
+
(0, _react.useEffect)(function () {
|
|
181
|
+
if (!mergedHashId || !cssText || typeof document === 'undefined') {
|
|
182
|
+
return undefined;
|
|
183
|
+
}
|
|
184
|
+
var styleTag = document.getElementById(styleId);
|
|
185
|
+
var nextUsage = (styleUsageMap.get(styleId) || 0) + 1;
|
|
186
|
+
styleUsageMap.set(styleId, nextUsage);
|
|
187
|
+
if (!styleTag) {
|
|
188
|
+
styleTag = document.createElement('style');
|
|
189
|
+
styleTag.id = styleId;
|
|
190
|
+
styleTag.setAttribute('data-x-web-pro-style', mergedHashId);
|
|
191
|
+
document.head.appendChild(styleTag);
|
|
192
|
+
}
|
|
193
|
+
styleTag.textContent = cssText;
|
|
194
|
+
return function () {
|
|
195
|
+
var currentUsage = (styleUsageMap.get(styleId) || 1) - 1;
|
|
196
|
+
if (currentUsage <= 0) {
|
|
197
|
+
var _styleTag;
|
|
198
|
+
styleUsageMap.delete(styleId);
|
|
199
|
+
(_styleTag = styleTag) === null || _styleTag === void 0 || (_styleTag = _styleTag.parentNode) === null || _styleTag === void 0 || _styleTag.removeChild(styleTag);
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
styleUsageMap.set(styleId, currentUsage);
|
|
203
|
+
};
|
|
204
|
+
}, [cssText, mergedHashId, styleId]);
|
|
205
|
+
return {
|
|
206
|
+
wrapSSR: function wrapSSR(node) {
|
|
207
|
+
if (!mergedHashId) {
|
|
208
|
+
return node;
|
|
209
|
+
}
|
|
210
|
+
var className = [node.props.className, mergedHashId].filter(Boolean).join(' ');
|
|
211
|
+
return /*#__PURE__*/_react.default.cloneElement(node, {
|
|
212
|
+
className: className
|
|
213
|
+
});
|
|
214
|
+
},
|
|
215
|
+
hashId: mergedHashId
|
|
216
|
+
};
|
|
217
|
+
}
|