@pnkx-lib/ui 1.9.462 → 1.9.463

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/es/ui/Layout.js CHANGED
@@ -1,10 +1,9 @@
1
1
  import { jsx } from 'react/jsx-runtime';
2
- import { _ as _typeof, c as _arrayLikeToArray, a as _unsupportedIterableToArray, b as _defineProperty } from '../chunks/defineProperty-CTLrw71t.js';
2
+ import { g as genStyleHooks, u as unit, C as ConfigContext, o as omit, t as toArray, a as useComponentConfig, _ as _toConsumableArray } from '../chunks/toArray-GtzhUyP3.js';
3
3
  import * as React from 'react';
4
- import React__default, { useContext, createContext, useState, useEffect, useRef } from 'react';
5
- import { r } from '../chunks/index-t0ynpS_n.js';
6
- import { _ as _createClass, a as _classCallCheck, b as _inherits, c as _createSuper, d as _assertThisInitialized } from '../chunks/createSuper-C90IQ42g.js';
7
- import { I as Icon, _ as _extends, w as warningOnce, a as _slicedToArray, b as warning$1, c as canUseDom, d as _objectSpread2, u as updateCSS, r as removeCSS, e as _arrayWithHoles, f as _nonIterableRest, g as resetWarned$1, F as FastColor, h as generate, p as presetPrimaryColors, i as presetPalettes, j as _objectWithoutProperties, k as IconContext } from '../chunks/AntdIcon-D_ySRKRj.js';
4
+ import { useContext, useState, useEffect, useRef } from 'react';
5
+ import { c as classNames } from '../chunks/index-xdC7i8zM.js';
6
+ import { I as Icon, _ as _extends } from '../chunks/AntdIcon-KP2HuB_x.js';
8
7
 
9
8
  // This icon file is generated automatically.
10
9
  var BarsOutlined$1 = { "icon": { "tag": "svg", "attrs": { "viewBox": "0 0 1024 1024", "focusable": "false" }, "children": [{ "tag": "path", "attrs": { "d": "M912 192H328c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h584c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8zm0 284H328c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h584c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8zm0 284H328c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h584c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8zM104 228a56 56 0 10112 0 56 56 0 10-112 0zm0 284a56 56 0 10112 0 56 56 0 10-112 0zm0 284a56 56 0 10112 0 56 56 0 10-112 0z" } }] }, "name": "bars", "theme": "outlined" };
@@ -54,4337 +53,6 @@ if (process.env.NODE_ENV !== 'production') {
54
53
  RefIcon.displayName = 'RightOutlined';
55
54
  }
56
55
 
57
- function useMemo(getValue, condition, shouldUpdate) {
58
- var cacheRef = React.useRef({});
59
- if (!('value' in cacheRef.current) || shouldUpdate(cacheRef.current.condition, condition)) {
60
- cacheRef.current.value = getValue();
61
- cacheRef.current.condition = condition;
62
- }
63
- return cacheRef.current.value;
64
- }
65
-
66
- var REACT_ELEMENT_TYPE_18 = Symbol.for('react.element');
67
- var REACT_ELEMENT_TYPE_19 = Symbol.for('react.transitional.element');
68
- var REACT_FRAGMENT_TYPE = Symbol.for('react.fragment');
69
-
70
- /**
71
- * Compatible with React 18 or 19 to check if node is a Fragment.
72
- */
73
- function isFragment(object) {
74
- return (
75
- // Base object type
76
- object && _typeof(object) === 'object' && (
77
- // React Element type
78
- object.$$typeof === REACT_ELEMENT_TYPE_18 || object.$$typeof === REACT_ELEMENT_TYPE_19) &&
79
- // React Fragment type
80
- object.type === REACT_FRAGMENT_TYPE
81
- );
82
- }
83
-
84
- function _arrayWithoutHoles(r) {
85
- if (Array.isArray(r)) return _arrayLikeToArray(r);
86
- }
87
-
88
- function _iterableToArray(r) {
89
- if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
90
- }
91
-
92
- function _nonIterableSpread() {
93
- throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
94
- }
95
-
96
- function _toConsumableArray(r) {
97
- return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
98
- }
99
-
100
- function omit(obj, fields) {
101
- var clone = Object.assign({}, obj);
102
- if (Array.isArray(fields)) {
103
- fields.forEach(function (key) {
104
- delete clone[key];
105
- });
106
- }
107
- return clone;
108
- }
109
-
110
- /* eslint-disable */
111
- // Inspired by https://github.com/garycourt/murmurhash-js
112
- // Ported from https://github.com/aappleby/smhasher/blob/61a0530f28277f2e850bfc39600ce61d02b518de/src/MurmurHash2.cpp#L37-L86
113
- function murmur2(str) {
114
- // 'm' and 'r' are mixing constants generated offline.
115
- // They're not really 'magic', they just happen to work well.
116
- // const m = 0x5bd1e995;
117
- // const r = 24;
118
- // Initialize the hash
119
- var h = 0; // Mix 4 bytes at a time into the hash
120
-
121
- var k,
122
- i = 0,
123
- len = str.length;
124
-
125
- for (; len >= 4; ++i, len -= 4) {
126
- k = str.charCodeAt(i) & 0xff | (str.charCodeAt(++i) & 0xff) << 8 | (str.charCodeAt(++i) & 0xff) << 16 | (str.charCodeAt(++i) & 0xff) << 24;
127
- k =
128
- /* Math.imul(k, m): */
129
- (k & 0xffff) * 0x5bd1e995 + ((k >>> 16) * 0xe995 << 16);
130
- k ^=
131
- /* k >>> r: */
132
- k >>> 24;
133
- h =
134
- /* Math.imul(k, m): */
135
- (k & 0xffff) * 0x5bd1e995 + ((k >>> 16) * 0xe995 << 16) ^
136
- /* Math.imul(h, m): */
137
- (h & 0xffff) * 0x5bd1e995 + ((h >>> 16) * 0xe995 << 16);
138
- } // Handle the last few bytes of the input array
139
-
140
-
141
- switch (len) {
142
- case 3:
143
- h ^= (str.charCodeAt(i + 2) & 0xff) << 16;
144
-
145
- case 2:
146
- h ^= (str.charCodeAt(i + 1) & 0xff) << 8;
147
-
148
- case 1:
149
- h ^= str.charCodeAt(i) & 0xff;
150
- h =
151
- /* Math.imul(h, m): */
152
- (h & 0xffff) * 0x5bd1e995 + ((h >>> 16) * 0xe995 << 16);
153
- } // Do a few final mixes of the hash to ensure the last few
154
- // bytes are well-incorporated.
155
-
156
-
157
- h ^= h >>> 13;
158
- h =
159
- /* Math.imul(h, m): */
160
- (h & 0xffff) * 0x5bd1e995 + ((h >>> 16) * 0xe995 << 16);
161
- return ((h ^ h >>> 15) >>> 0).toString(36);
162
- }
163
-
164
- /**
165
- * Deeply compares two object literals.
166
- * @param obj1 object 1
167
- * @param obj2 object 2
168
- * @param shallow shallow compare
169
- * @returns
170
- */
171
- function isEqual(obj1, obj2) {
172
- var shallow = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
173
- // https://github.com/mapbox/mapbox-gl-js/pull/5979/files#diff-fde7145050c47cc3a306856efd5f9c3016e86e859de9afbd02c879be5067e58f
174
- var refSet = new Set();
175
- function deepEqual(a, b) {
176
- var level = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
177
- var circular = refSet.has(a);
178
- warningOnce(!circular, 'Warning: There may be circular references');
179
- if (circular) {
180
- return false;
181
- }
182
- if (a === b) {
183
- return true;
184
- }
185
- if (shallow && level > 1) {
186
- return false;
187
- }
188
- refSet.add(a);
189
- var newLevel = level + 1;
190
- if (Array.isArray(a)) {
191
- if (!Array.isArray(b) || a.length !== b.length) {
192
- return false;
193
- }
194
- for (var i = 0; i < a.length; i++) {
195
- if (!deepEqual(a[i], b[i], newLevel)) {
196
- return false;
197
- }
198
- }
199
- return true;
200
- }
201
- if (a && b && _typeof(a) === 'object' && _typeof(b) === 'object') {
202
- var keys = Object.keys(a);
203
- if (keys.length !== Object.keys(b).length) {
204
- return false;
205
- }
206
- return keys.every(function (key) {
207
- return deepEqual(a[key], b[key], newLevel);
208
- });
209
- }
210
- // other
211
- return false;
212
- }
213
- return deepEqual(obj1, obj2);
214
- }
215
-
216
- // [times, realValue]
217
-
218
- var SPLIT = '%';
219
-
220
- /** Connect key with `SPLIT` */
221
- function pathKey(keys) {
222
- return keys.join(SPLIT);
223
- }
224
- var Entity = /*#__PURE__*/function () {
225
- function Entity(instanceId) {
226
- _classCallCheck(this, Entity);
227
- _defineProperty(this, "instanceId", void 0);
228
- /** @private Internal cache map. Do not access this directly */
229
- _defineProperty(this, "cache", new Map());
230
- _defineProperty(this, "extracted", new Set());
231
- this.instanceId = instanceId;
232
- }
233
- _createClass(Entity, [{
234
- key: "get",
235
- value: function get(keys) {
236
- return this.opGet(pathKey(keys));
237
- }
238
-
239
- /** A fast get cache with `get` concat. */
240
- }, {
241
- key: "opGet",
242
- value: function opGet(keyPathStr) {
243
- return this.cache.get(keyPathStr) || null;
244
- }
245
- }, {
246
- key: "update",
247
- value: function update(keys, valueFn) {
248
- return this.opUpdate(pathKey(keys), valueFn);
249
- }
250
-
251
- /** A fast get cache with `get` concat. */
252
- }, {
253
- key: "opUpdate",
254
- value: function opUpdate(keyPathStr, valueFn) {
255
- var prevValue = this.cache.get(keyPathStr);
256
- var nextValue = valueFn(prevValue);
257
- if (nextValue === null) {
258
- this.cache.delete(keyPathStr);
259
- } else {
260
- this.cache.set(keyPathStr, nextValue);
261
- }
262
- }
263
- }]);
264
- return Entity;
265
- }();
266
-
267
- var ATTR_TOKEN = 'data-token-hash';
268
- var ATTR_MARK = 'data-css-hash';
269
- var ATTR_CACHE_PATH = 'data-cache-path';
270
-
271
- // Mark css-in-js instance in style element
272
- var CSS_IN_JS_INSTANCE = '__cssinjs_instance__';
273
- function createCache() {
274
- var cssinjsInstanceId = Math.random().toString(12).slice(2);
275
-
276
- // Tricky SSR: Move all inline style to the head.
277
- // PS: We do not recommend tricky mode.
278
- if (typeof document !== 'undefined' && document.head && document.body) {
279
- var styles = document.body.querySelectorAll("style[".concat(ATTR_MARK, "]")) || [];
280
- var firstChild = document.head.firstChild;
281
- Array.from(styles).forEach(function (style) {
282
- style[CSS_IN_JS_INSTANCE] = style[CSS_IN_JS_INSTANCE] || cssinjsInstanceId;
283
-
284
- // Not force move if no head
285
- if (style[CSS_IN_JS_INSTANCE] === cssinjsInstanceId) {
286
- document.head.insertBefore(style, firstChild);
287
- }
288
- });
289
-
290
- // Deduplicate of moved styles
291
- var styleHash = {};
292
- Array.from(document.querySelectorAll("style[".concat(ATTR_MARK, "]"))).forEach(function (style) {
293
- var hash = style.getAttribute(ATTR_MARK);
294
- if (styleHash[hash]) {
295
- if (style[CSS_IN_JS_INSTANCE] === cssinjsInstanceId) {
296
- var _style$parentNode;
297
- (_style$parentNode = style.parentNode) === null || _style$parentNode === void 0 || _style$parentNode.removeChild(style);
298
- }
299
- } else {
300
- styleHash[hash] = true;
301
- }
302
- });
303
- }
304
- return new Entity(cssinjsInstanceId);
305
- }
306
- var StyleContext = /*#__PURE__*/React.createContext({
307
- hashPriority: 'low',
308
- cache: createCache(),
309
- defaultCache: true
310
- });
311
-
312
- // ================================== Cache ==================================
313
-
314
- function sameDerivativeOption(left, right) {
315
- if (left.length !== right.length) {
316
- return false;
317
- }
318
- for (var i = 0; i < left.length; i++) {
319
- if (left[i] !== right[i]) {
320
- return false;
321
- }
322
- }
323
- return true;
324
- }
325
- var ThemeCache = /*#__PURE__*/function () {
326
- function ThemeCache() {
327
- _classCallCheck(this, ThemeCache);
328
- _defineProperty(this, "cache", void 0);
329
- _defineProperty(this, "keys", void 0);
330
- _defineProperty(this, "cacheCallTimes", void 0);
331
- this.cache = new Map();
332
- this.keys = [];
333
- this.cacheCallTimes = 0;
334
- }
335
- _createClass(ThemeCache, [{
336
- key: "size",
337
- value: function size() {
338
- return this.keys.length;
339
- }
340
- }, {
341
- key: "internalGet",
342
- value: function internalGet(derivativeOption) {
343
- var _cache2, _cache3;
344
- var updateCallTimes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
345
- var cache = {
346
- map: this.cache
347
- };
348
- derivativeOption.forEach(function (derivative) {
349
- if (!cache) {
350
- cache = undefined;
351
- } else {
352
- var _cache;
353
- cache = (_cache = cache) === null || _cache === void 0 || (_cache = _cache.map) === null || _cache === void 0 ? void 0 : _cache.get(derivative);
354
- }
355
- });
356
- if ((_cache2 = cache) !== null && _cache2 !== void 0 && _cache2.value && updateCallTimes) {
357
- cache.value[1] = this.cacheCallTimes++;
358
- }
359
- return (_cache3 = cache) === null || _cache3 === void 0 ? void 0 : _cache3.value;
360
- }
361
- }, {
362
- key: "get",
363
- value: function get(derivativeOption) {
364
- var _this$internalGet;
365
- return (_this$internalGet = this.internalGet(derivativeOption, true)) === null || _this$internalGet === void 0 ? void 0 : _this$internalGet[0];
366
- }
367
- }, {
368
- key: "has",
369
- value: function has(derivativeOption) {
370
- return !!this.internalGet(derivativeOption);
371
- }
372
- }, {
373
- key: "set",
374
- value: function set(derivativeOption, value) {
375
- var _this = this;
376
- // New cache
377
- if (!this.has(derivativeOption)) {
378
- if (this.size() + 1 > ThemeCache.MAX_CACHE_SIZE + ThemeCache.MAX_CACHE_OFFSET) {
379
- var _this$keys$reduce = this.keys.reduce(function (result, key) {
380
- var _result = _slicedToArray(result, 2),
381
- callTimes = _result[1];
382
- if (_this.internalGet(key)[1] < callTimes) {
383
- return [key, _this.internalGet(key)[1]];
384
- }
385
- return result;
386
- }, [this.keys[0], this.cacheCallTimes]),
387
- _this$keys$reduce2 = _slicedToArray(_this$keys$reduce, 1),
388
- targetKey = _this$keys$reduce2[0];
389
- this.delete(targetKey);
390
- }
391
- this.keys.push(derivativeOption);
392
- }
393
- var cache = this.cache;
394
- derivativeOption.forEach(function (derivative, index) {
395
- if (index === derivativeOption.length - 1) {
396
- cache.set(derivative, {
397
- value: [value, _this.cacheCallTimes++]
398
- });
399
- } else {
400
- var cacheValue = cache.get(derivative);
401
- if (!cacheValue) {
402
- cache.set(derivative, {
403
- map: new Map()
404
- });
405
- } else if (!cacheValue.map) {
406
- cacheValue.map = new Map();
407
- }
408
- cache = cache.get(derivative).map;
409
- }
410
- });
411
- }
412
- }, {
413
- key: "deleteByPath",
414
- value: function deleteByPath(currentCache, derivatives) {
415
- var cache = currentCache.get(derivatives[0]);
416
- if (derivatives.length === 1) {
417
- var _cache$value;
418
- if (!cache.map) {
419
- currentCache.delete(derivatives[0]);
420
- } else {
421
- currentCache.set(derivatives[0], {
422
- map: cache.map
423
- });
424
- }
425
- return (_cache$value = cache.value) === null || _cache$value === void 0 ? void 0 : _cache$value[0];
426
- }
427
- var result = this.deleteByPath(cache.map, derivatives.slice(1));
428
- if ((!cache.map || cache.map.size === 0) && !cache.value) {
429
- currentCache.delete(derivatives[0]);
430
- }
431
- return result;
432
- }
433
- }, {
434
- key: "delete",
435
- value: function _delete(derivativeOption) {
436
- // If cache exists
437
- if (this.has(derivativeOption)) {
438
- this.keys = this.keys.filter(function (item) {
439
- return !sameDerivativeOption(item, derivativeOption);
440
- });
441
- return this.deleteByPath(this.cache, derivativeOption);
442
- }
443
- return undefined;
444
- }
445
- }]);
446
- return ThemeCache;
447
- }();
448
- _defineProperty(ThemeCache, "MAX_CACHE_SIZE", 20);
449
- _defineProperty(ThemeCache, "MAX_CACHE_OFFSET", 5);
450
-
451
- var uuid = 0;
452
-
453
- /**
454
- * Theme with algorithms to derive tokens from design tokens.
455
- * Use `createTheme` first which will help to manage the theme instance cache.
456
- */
457
- var Theme = /*#__PURE__*/function () {
458
- function Theme(derivatives) {
459
- _classCallCheck(this, Theme);
460
- _defineProperty(this, "derivatives", void 0);
461
- _defineProperty(this, "id", void 0);
462
- this.derivatives = Array.isArray(derivatives) ? derivatives : [derivatives];
463
- this.id = uuid;
464
- if (derivatives.length === 0) {
465
- warning$1(derivatives.length > 0, '[Ant Design CSS-in-JS] Theme should have at least one derivative function.');
466
- }
467
- uuid += 1;
468
- }
469
- _createClass(Theme, [{
470
- key: "getDerivativeToken",
471
- value: function getDerivativeToken(token) {
472
- return this.derivatives.reduce(function (result, derivative) {
473
- return derivative(token, result);
474
- }, undefined);
475
- }
476
- }]);
477
- return Theme;
478
- }();
479
-
480
- var cacheThemes = new ThemeCache();
481
-
482
- /**
483
- * Same as new Theme, but will always return same one if `derivative` not changed.
484
- */
485
- function createTheme(derivatives) {
486
- var derivativeArr = Array.isArray(derivatives) ? derivatives : [derivatives];
487
- // Create new theme if not exist
488
- if (!cacheThemes.has(derivativeArr)) {
489
- cacheThemes.set(derivativeArr, new Theme(derivativeArr));
490
- }
491
-
492
- // Get theme from cache and return
493
- return cacheThemes.get(derivativeArr);
494
- }
495
-
496
- // Create a cache for memo concat
497
-
498
- var resultCache = new WeakMap();
499
- var RESULT_VALUE = {};
500
- function memoResult(callback, deps) {
501
- var current = resultCache;
502
- for (var i = 0; i < deps.length; i += 1) {
503
- var dep = deps[i];
504
- if (!current.has(dep)) {
505
- current.set(dep, new WeakMap());
506
- }
507
- current = current.get(dep);
508
- }
509
- if (!current.has(RESULT_VALUE)) {
510
- current.set(RESULT_VALUE, callback());
511
- }
512
- return current.get(RESULT_VALUE);
513
- }
514
-
515
- // Create a cache here to avoid always loop generate
516
- var flattenTokenCache = new WeakMap();
517
-
518
- /**
519
- * Flatten token to string, this will auto cache the result when token not change
520
- */
521
- function flattenToken(token) {
522
- var str = flattenTokenCache.get(token) || '';
523
- if (!str) {
524
- Object.keys(token).forEach(function (key) {
525
- var value = token[key];
526
- str += key;
527
- if (value instanceof Theme) {
528
- str += value.id;
529
- } else if (value && _typeof(value) === 'object') {
530
- str += flattenToken(value);
531
- } else {
532
- str += value;
533
- }
534
- });
535
-
536
- // https://github.com/ant-design/ant-design/issues/48386
537
- // Should hash the string to avoid style tag name too long
538
- str = murmur2(str);
539
-
540
- // Put in cache
541
- flattenTokenCache.set(token, str);
542
- }
543
- return str;
544
- }
545
-
546
- /**
547
- * Convert derivative token to key string
548
- */
549
- function token2key(token, salt) {
550
- return murmur2("".concat(salt, "_").concat(flattenToken(token)));
551
- }
552
- var isClientSide = canUseDom();
553
- function unit$1(num) {
554
- if (typeof num === 'number') {
555
- return "".concat(num, "px");
556
- }
557
- return num;
558
- }
559
-
560
- var token2CSSVar = function token2CSSVar(token) {
561
- var prefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
562
- return "--".concat(prefix ? "".concat(prefix, "-") : '').concat(token).replace(/([a-z0-9])([A-Z])/g, '$1-$2').replace(/([A-Z]+)([A-Z][a-z0-9]+)/g, '$1-$2').replace(/([a-z])([A-Z0-9])/g, '$1-$2').toLowerCase();
563
- };
564
- var serializeCSSVar = function serializeCSSVar(cssVars, hashId, options) {
565
- if (!Object.keys(cssVars).length) {
566
- return '';
567
- }
568
- return ".".concat(hashId).concat(options !== null && options !== void 0 && options.scope ? ".".concat(options.scope) : '', "{").concat(Object.entries(cssVars).map(function (_ref) {
569
- var _ref2 = _slicedToArray(_ref, 2),
570
- key = _ref2[0],
571
- value = _ref2[1];
572
- return "".concat(key, ":").concat(value, ";");
573
- }).join(''), "}");
574
- };
575
- var transformToken = function transformToken(token, themeKey, config) {
576
- var cssVars = {};
577
- var result = {};
578
- Object.entries(token).forEach(function (_ref3) {
579
- var _config$preserve, _config$ignore;
580
- var _ref4 = _slicedToArray(_ref3, 2),
581
- key = _ref4[0],
582
- value = _ref4[1];
583
- if (config !== null && config !== void 0 && (_config$preserve = config.preserve) !== null && _config$preserve !== void 0 && _config$preserve[key]) {
584
- result[key] = value;
585
- } else if ((typeof value === 'string' || typeof value === 'number') && !(config !== null && config !== void 0 && (_config$ignore = config.ignore) !== null && _config$ignore !== void 0 && _config$ignore[key])) {
586
- var _config$unitless;
587
- var cssVar = token2CSSVar(key, config === null || config === void 0 ? void 0 : config.prefix);
588
- cssVars[cssVar] = typeof value === 'number' && !(config !== null && config !== void 0 && (_config$unitless = config.unitless) !== null && _config$unitless !== void 0 && _config$unitless[key]) ? "".concat(value, "px") : String(value);
589
- result[key] = "var(".concat(cssVar, ")");
590
- }
591
- });
592
- return [result, serializeCSSVar(cssVars, themeKey, {
593
- scope: config === null || config === void 0 ? void 0 : config.scope
594
- })];
595
- };
596
-
597
- /**
598
- * Wrap `React.useLayoutEffect` which will not throw warning message in test env
599
- */
600
- var useInternalLayoutEffect = process.env.NODE_ENV !== 'test' && canUseDom() ? React.useLayoutEffect : React.useEffect;
601
- var useLayoutEffect = function useLayoutEffect(callback, deps) {
602
- var firstMountRef = React.useRef(true);
603
- useInternalLayoutEffect(function () {
604
- return callback(firstMountRef.current);
605
- }, deps);
606
-
607
- // We tell react that first mount has passed
608
- useInternalLayoutEffect(function () {
609
- firstMountRef.current = false;
610
- return function () {
611
- firstMountRef.current = true;
612
- };
613
- }, []);
614
- };
615
-
616
- // We need fully clone React function here
617
- // to avoid webpack warning React 17 do not export `useId`
618
- var fullClone$2 = _objectSpread2({}, React);
619
- var useInsertionEffect$1 = fullClone$2.useInsertionEffect;
620
- /**
621
- * Polyfill `useInsertionEffect` for React < 18
622
- * @param renderEffect will be executed in `useMemo`, and do not have callback
623
- * @param effect will be executed in `useLayoutEffect`
624
- * @param deps
625
- */
626
- var useInsertionEffectPolyfill = function useInsertionEffectPolyfill(renderEffect, effect, deps) {
627
- React.useMemo(renderEffect, deps);
628
- useLayoutEffect(function () {
629
- return effect(true);
630
- }, deps);
631
- };
632
-
633
- /**
634
- * Compatible `useInsertionEffect`
635
- * will use `useInsertionEffect` if React version >= 18,
636
- * otherwise use `useInsertionEffectPolyfill`.
637
- */
638
- var useCompatibleInsertionEffect = useInsertionEffect$1 ? function (renderEffect, effect, deps) {
639
- return useInsertionEffect$1(function () {
640
- renderEffect();
641
- return effect();
642
- }, deps);
643
- } : useInsertionEffectPolyfill;
644
-
645
- var fullClone$1 = _objectSpread2({}, React);
646
- var useInsertionEffect = fullClone$1.useInsertionEffect;
647
-
648
- // DO NOT register functions in useEffect cleanup function, or functions that registered will never be called.
649
- var useCleanupRegister = function useCleanupRegister(deps) {
650
- var effectCleanups = [];
651
- var cleanupFlag = false;
652
- function register(fn) {
653
- if (cleanupFlag) {
654
- if (process.env.NODE_ENV !== 'production') {
655
- warning$1(false, '[Ant Design CSS-in-JS] You are registering a cleanup function after unmount, which will not have any effect.');
656
- }
657
- return;
658
- }
659
- effectCleanups.push(fn);
660
- }
661
- React.useEffect(function () {
662
- // Compatible with strict mode
663
- cleanupFlag = false;
664
- return function () {
665
- cleanupFlag = true;
666
- if (effectCleanups.length) {
667
- effectCleanups.forEach(function (fn) {
668
- return fn();
669
- });
670
- }
671
- };
672
- }, deps);
673
- return register;
674
- };
675
- var useRun = function useRun() {
676
- return function (fn) {
677
- fn();
678
- };
679
- };
680
-
681
- // Only enable register in React 18
682
- var useEffectCleanupRegister = typeof useInsertionEffect !== 'undefined' ? useCleanupRegister : useRun;
683
-
684
- function useProdHMR() {
685
- return false;
686
- }
687
- var webpackHMR = false;
688
- function useDevHMR() {
689
- return webpackHMR;
690
- }
691
- const useHMR = process.env.NODE_ENV === 'production' ? useProdHMR : useDevHMR;
692
-
693
- // Webpack `module.hot.accept` do not support any deps update trigger
694
- // We have to hack handler to force mark as HRM
695
- if (process.env.NODE_ENV !== 'production' && typeof module !== 'undefined' && module && module.hot && typeof window !== 'undefined') {
696
- // Use `globalThis` first, and `window` for older browsers
697
- // const win = globalThis as any;
698
- var win = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : null;
699
- if (win && typeof win.webpackHotUpdate === 'function') {
700
- var originWebpackHotUpdate = win.webpackHotUpdate;
701
- win.webpackHotUpdate = function () {
702
- webpackHMR = true;
703
- setTimeout(function () {
704
- webpackHMR = false;
705
- }, 0);
706
- return originWebpackHotUpdate.apply(void 0, arguments);
707
- };
708
- }
709
- }
710
-
711
- function useGlobalCache(prefix, keyPath, cacheFn, onCacheRemove,
712
- // Add additional effect trigger by `useInsertionEffect`
713
- onCacheEffect) {
714
- var _React$useContext = React.useContext(StyleContext),
715
- globalCache = _React$useContext.cache;
716
- var fullPath = [prefix].concat(_toConsumableArray(keyPath));
717
- var fullPathStr = pathKey(fullPath);
718
- var register = useEffectCleanupRegister([fullPathStr]);
719
- var HMRUpdate = useHMR();
720
- var buildCache = function buildCache(updater) {
721
- globalCache.opUpdate(fullPathStr, function (prevCache) {
722
- var _ref = prevCache || [undefined, undefined],
723
- _ref2 = _slicedToArray(_ref, 2),
724
- _ref2$ = _ref2[0],
725
- times = _ref2$ === void 0 ? 0 : _ref2$,
726
- cache = _ref2[1];
727
-
728
- // HMR should always ignore cache since developer may change it
729
- var tmpCache = cache;
730
- if (process.env.NODE_ENV !== 'production' && cache && HMRUpdate) {
731
- onCacheRemove === null || onCacheRemove === void 0 || onCacheRemove(tmpCache, HMRUpdate);
732
- tmpCache = null;
733
- }
734
- var mergedCache = tmpCache || cacheFn();
735
- var data = [times, mergedCache];
736
-
737
- // Call updater if need additional logic
738
- return updater ? updater(data) : data;
739
- });
740
- };
741
-
742
- // Create cache
743
- React.useMemo(function () {
744
- buildCache();
745
- }, /* eslint-disable react-hooks/exhaustive-deps */
746
- [fullPathStr]
747
- /* eslint-enable */);
748
- var cacheEntity = globalCache.opGet(fullPathStr);
749
-
750
- // HMR clean the cache but not trigger `useMemo` again
751
- // Let's fallback of this
752
- // ref https://github.com/ant-design/cssinjs/issues/127
753
- if (process.env.NODE_ENV !== 'production' && !cacheEntity) {
754
- buildCache();
755
- cacheEntity = globalCache.opGet(fullPathStr);
756
- }
757
- var cacheContent = cacheEntity[1];
758
-
759
- // Remove if no need anymore
760
- useCompatibleInsertionEffect(function () {
761
- onCacheEffect === null || onCacheEffect === void 0 || onCacheEffect(cacheContent);
762
- }, function (polyfill) {
763
- // It's bad to call build again in effect.
764
- // But we have to do this since StrictMode will call effect twice
765
- // which will clear cache on the first time.
766
- buildCache(function (_ref3) {
767
- var _ref4 = _slicedToArray(_ref3, 2),
768
- times = _ref4[0],
769
- cache = _ref4[1];
770
- if (polyfill && times === 0) {
771
- onCacheEffect === null || onCacheEffect === void 0 || onCacheEffect(cacheContent);
772
- }
773
- return [times + 1, cache];
774
- });
775
- return function () {
776
- globalCache.opUpdate(fullPathStr, function (prevCache) {
777
- var _ref5 = prevCache || [],
778
- _ref6 = _slicedToArray(_ref5, 2),
779
- _ref6$ = _ref6[0],
780
- times = _ref6$ === void 0 ? 0 : _ref6$,
781
- cache = _ref6[1];
782
- var nextCount = times - 1;
783
- if (nextCount === 0) {
784
- // Always remove styles in useEffect callback
785
- register(function () {
786
- // With polyfill, registered callback will always be called synchronously
787
- // But without polyfill, it will be called in effect clean up,
788
- // And by that time this cache is cleaned up.
789
- if (polyfill || !globalCache.opGet(fullPathStr)) {
790
- onCacheRemove === null || onCacheRemove === void 0 || onCacheRemove(cache, false);
791
- }
792
- });
793
- return null;
794
- }
795
- return [times - 1, cache];
796
- });
797
- };
798
- }, [fullPathStr]);
799
- return cacheContent;
800
- }
801
-
802
- var EMPTY_OVERRIDE = {};
803
-
804
- // Generate different prefix to make user selector break in production env.
805
- // This helps developer not to do style override directly on the hash id.
806
- var hashPrefix = process.env.NODE_ENV !== 'production' ? 'css-dev-only-do-not-override' : 'css';
807
- var tokenKeys = new Map();
808
- function recordCleanToken(tokenKey) {
809
- tokenKeys.set(tokenKey, (tokenKeys.get(tokenKey) || 0) + 1);
810
- }
811
- function removeStyleTags(key, instanceId) {
812
- if (typeof document !== 'undefined') {
813
- var styles = document.querySelectorAll("style[".concat(ATTR_TOKEN, "=\"").concat(key, "\"]"));
814
- styles.forEach(function (style) {
815
- if (style[CSS_IN_JS_INSTANCE] === instanceId) {
816
- var _style$parentNode;
817
- (_style$parentNode = style.parentNode) === null || _style$parentNode === void 0 || _style$parentNode.removeChild(style);
818
- }
819
- });
820
- }
821
- }
822
- var TOKEN_THRESHOLD = 0;
823
-
824
- // Remove will check current keys first
825
- function cleanTokenStyle(tokenKey, instanceId) {
826
- tokenKeys.set(tokenKey, (tokenKeys.get(tokenKey) || 0) - 1);
827
- var cleanableKeyList = new Set();
828
- tokenKeys.forEach(function (value, key) {
829
- if (value <= 0) cleanableKeyList.add(key);
830
- });
831
-
832
- // Should keep tokens under threshold for not to insert style too often
833
- if (tokenKeys.size - cleanableKeyList.size > TOKEN_THRESHOLD) {
834
- cleanableKeyList.forEach(function (key) {
835
- removeStyleTags(key, instanceId);
836
- tokenKeys.delete(key);
837
- });
838
- }
839
- }
840
- var getComputedToken$1 = function getComputedToken(originToken, overrideToken, theme, format) {
841
- var derivativeToken = theme.getDerivativeToken(originToken);
842
-
843
- // Merge with override
844
- var mergedDerivativeToken = _objectSpread2(_objectSpread2({}, derivativeToken), overrideToken);
845
-
846
- // Format if needed
847
- if (format) {
848
- mergedDerivativeToken = format(mergedDerivativeToken);
849
- }
850
- return mergedDerivativeToken;
851
- };
852
- var TOKEN_PREFIX = 'token';
853
- /**
854
- * Cache theme derivative token as global shared one
855
- * @param theme Theme entity
856
- * @param tokens List of tokens, used for cache. Please do not dynamic generate object directly
857
- * @param option Additional config
858
- * @returns Call Theme.getDerivativeToken(tokenObject) to get token
859
- */
860
- function useCacheToken(theme, tokens) {
861
- var option = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
862
- var _useContext = useContext(StyleContext),
863
- instanceId = _useContext.cache.instanceId,
864
- container = _useContext.container;
865
- var _option$salt = option.salt,
866
- salt = _option$salt === void 0 ? '' : _option$salt,
867
- _option$override = option.override,
868
- override = _option$override === void 0 ? EMPTY_OVERRIDE : _option$override,
869
- formatToken = option.formatToken,
870
- compute = option.getComputedToken,
871
- cssVar = option.cssVar;
872
-
873
- // Basic - We do basic cache here
874
- var mergedToken = memoResult(function () {
875
- return Object.assign.apply(Object, [{}].concat(_toConsumableArray(tokens)));
876
- }, tokens);
877
- var tokenStr = flattenToken(mergedToken);
878
- var overrideTokenStr = flattenToken(override);
879
- var cssVarStr = cssVar ? flattenToken(cssVar) : '';
880
- var cachedToken = useGlobalCache(TOKEN_PREFIX, [salt, theme.id, tokenStr, overrideTokenStr, cssVarStr], function () {
881
- var _cssVar$key;
882
- var mergedDerivativeToken = compute ? compute(mergedToken, override, theme) : getComputedToken$1(mergedToken, override, theme, formatToken);
883
-
884
- // Replace token value with css variables
885
- var actualToken = _objectSpread2({}, mergedDerivativeToken);
886
- var cssVarsStr = '';
887
- if (!!cssVar) {
888
- var _transformToken = transformToken(mergedDerivativeToken, cssVar.key, {
889
- prefix: cssVar.prefix,
890
- ignore: cssVar.ignore,
891
- unitless: cssVar.unitless,
892
- preserve: cssVar.preserve
893
- });
894
- var _transformToken2 = _slicedToArray(_transformToken, 2);
895
- mergedDerivativeToken = _transformToken2[0];
896
- cssVarsStr = _transformToken2[1];
897
- }
898
-
899
- // Optimize for `useStyleRegister` performance
900
- var tokenKey = token2key(mergedDerivativeToken, salt);
901
- mergedDerivativeToken._tokenKey = tokenKey;
902
- actualToken._tokenKey = token2key(actualToken, salt);
903
- var themeKey = (_cssVar$key = cssVar === null || cssVar === void 0 ? void 0 : cssVar.key) !== null && _cssVar$key !== void 0 ? _cssVar$key : tokenKey;
904
- mergedDerivativeToken._themeKey = themeKey;
905
- recordCleanToken(themeKey);
906
- var hashId = "".concat(hashPrefix, "-").concat(murmur2(tokenKey));
907
- mergedDerivativeToken._hashId = hashId; // Not used
908
-
909
- return [mergedDerivativeToken, hashId, actualToken, cssVarsStr, (cssVar === null || cssVar === void 0 ? void 0 : cssVar.key) || ''];
910
- }, function (cache) {
911
- // Remove token will remove all related style
912
- cleanTokenStyle(cache[0]._themeKey, instanceId);
913
- }, function (_ref) {
914
- var _ref2 = _slicedToArray(_ref, 4),
915
- token = _ref2[0],
916
- cssVarsStr = _ref2[3];
917
- if (cssVar && cssVarsStr) {
918
- var style = updateCSS(cssVarsStr, murmur2("css-variables-".concat(token._themeKey)), {
919
- mark: ATTR_MARK,
920
- prepend: 'queue',
921
- attachTo: container,
922
- priority: -999
923
- });
924
- style[CSS_IN_JS_INSTANCE] = instanceId;
925
-
926
- // Used for `useCacheToken` to remove on batch when token removed
927
- style.setAttribute(ATTR_TOKEN, token._themeKey);
928
- }
929
- });
930
- return cachedToken;
931
- }
932
-
933
- var unitlessKeys = {
934
- animationIterationCount: 1,
935
- borderImageOutset: 1,
936
- borderImageSlice: 1,
937
- borderImageWidth: 1,
938
- boxFlex: 1,
939
- boxFlexGroup: 1,
940
- boxOrdinalGroup: 1,
941
- columnCount: 1,
942
- columns: 1,
943
- flex: 1,
944
- flexGrow: 1,
945
- flexPositive: 1,
946
- flexShrink: 1,
947
- flexNegative: 1,
948
- flexOrder: 1,
949
- gridRow: 1,
950
- gridRowEnd: 1,
951
- gridRowSpan: 1,
952
- gridRowStart: 1,
953
- gridColumn: 1,
954
- gridColumnEnd: 1,
955
- gridColumnSpan: 1,
956
- gridColumnStart: 1,
957
- msGridRow: 1,
958
- msGridRowSpan: 1,
959
- msGridColumn: 1,
960
- msGridColumnSpan: 1,
961
- fontWeight: 1,
962
- lineHeight: 1,
963
- opacity: 1,
964
- order: 1,
965
- orphans: 1,
966
- tabSize: 1,
967
- widows: 1,
968
- zIndex: 1,
969
- zoom: 1,
970
- WebkitLineClamp: 1,
971
- // SVG-related properties
972
- fillOpacity: 1,
973
- floodOpacity: 1,
974
- stopOpacity: 1,
975
- strokeDasharray: 1,
976
- strokeDashoffset: 1,
977
- strokeMiterlimit: 1,
978
- strokeOpacity: 1,
979
- strokeWidth: 1
980
- };
981
-
982
- var COMMENT = 'comm';
983
- var RULESET = 'rule';
984
- var DECLARATION = 'decl';
985
- var IMPORT = '@import';
986
- var NAMESPACE = '@namespace';
987
- var KEYFRAMES = '@keyframes';
988
- var LAYER = '@layer';
989
-
990
- /**
991
- * @param {number}
992
- * @return {number}
993
- */
994
- var abs = Math.abs;
995
-
996
- /**
997
- * @param {number}
998
- * @return {string}
999
- */
1000
- var from = String.fromCharCode;
1001
-
1002
- /**
1003
- * @param {string} value
1004
- * @return {string}
1005
- */
1006
- function trim (value) {
1007
- return value.trim()
1008
- }
1009
-
1010
- /**
1011
- * @param {string} value
1012
- * @param {(string|RegExp)} pattern
1013
- * @param {string} replacement
1014
- * @return {string}
1015
- */
1016
- function replace (value, pattern, replacement) {
1017
- return value.replace(pattern, replacement)
1018
- }
1019
-
1020
- /**
1021
- * @param {string} value
1022
- * @param {string} search
1023
- * @param {number} position
1024
- * @return {number}
1025
- */
1026
- function indexof (value, search, position) {
1027
- return value.indexOf(search, position)
1028
- }
1029
-
1030
- /**
1031
- * @param {string} value
1032
- * @param {number} index
1033
- * @return {number}
1034
- */
1035
- function charat (value, index) {
1036
- return value.charCodeAt(index) | 0
1037
- }
1038
-
1039
- /**
1040
- * @param {string} value
1041
- * @param {number} begin
1042
- * @param {number} end
1043
- * @return {string}
1044
- */
1045
- function substr (value, begin, end) {
1046
- return value.slice(begin, end)
1047
- }
1048
-
1049
- /**
1050
- * @param {string} value
1051
- * @return {number}
1052
- */
1053
- function strlen (value) {
1054
- return value.length
1055
- }
1056
-
1057
- /**
1058
- * @param {any[]} value
1059
- * @return {number}
1060
- */
1061
- function sizeof (value) {
1062
- return value.length
1063
- }
1064
-
1065
- /**
1066
- * @param {any} value
1067
- * @param {any[]} array
1068
- * @return {any}
1069
- */
1070
- function append (value, array) {
1071
- return array.push(value), value
1072
- }
1073
-
1074
- var line = 1;
1075
- var column = 1;
1076
- var length = 0;
1077
- var position = 0;
1078
- var character = 0;
1079
- var characters = '';
1080
-
1081
- /**
1082
- * @param {string} value
1083
- * @param {object | null} root
1084
- * @param {object | null} parent
1085
- * @param {string} type
1086
- * @param {string[] | string} props
1087
- * @param {object[] | string} children
1088
- * @param {object[]} siblings
1089
- * @param {number} length
1090
- */
1091
- function node (value, root, parent, type, props, children, length, siblings) {
1092
- return {value: value, root: root, parent: parent, type: type, props: props, children: children, line: line, column: column, length: length, return: '', siblings: siblings}
1093
- }
1094
-
1095
- /**
1096
- * @return {number}
1097
- */
1098
- function char () {
1099
- return character
1100
- }
1101
-
1102
- /**
1103
- * @return {number}
1104
- */
1105
- function prev () {
1106
- character = position > 0 ? charat(characters, --position) : 0;
1107
-
1108
- if (column--, character === 10)
1109
- column = 1, line--;
1110
-
1111
- return character
1112
- }
1113
-
1114
- /**
1115
- * @return {number}
1116
- */
1117
- function next () {
1118
- character = position < length ? charat(characters, position++) : 0;
1119
-
1120
- if (column++, character === 10)
1121
- column = 1, line++;
1122
-
1123
- return character
1124
- }
1125
-
1126
- /**
1127
- * @return {number}
1128
- */
1129
- function peek () {
1130
- return charat(characters, position)
1131
- }
1132
-
1133
- /**
1134
- * @return {number}
1135
- */
1136
- function caret () {
1137
- return position
1138
- }
1139
-
1140
- /**
1141
- * @param {number} begin
1142
- * @param {number} end
1143
- * @return {string}
1144
- */
1145
- function slice (begin, end) {
1146
- return substr(characters, begin, end)
1147
- }
1148
-
1149
- /**
1150
- * @param {number} type
1151
- * @return {number}
1152
- */
1153
- function token (type) {
1154
- switch (type) {
1155
- // \0 \t \n \r \s whitespace token
1156
- case 0: case 9: case 10: case 13: case 32:
1157
- return 5
1158
- // ! + , / > @ ~ isolate token
1159
- case 33: case 43: case 44: case 47: case 62: case 64: case 126:
1160
- // ; { } breakpoint token
1161
- case 59: case 123: case 125:
1162
- return 4
1163
- // : accompanied token
1164
- case 58:
1165
- return 3
1166
- // " ' ( [ opening delimit token
1167
- case 34: case 39: case 40: case 91:
1168
- return 2
1169
- // ) ] closing delimit token
1170
- case 41: case 93:
1171
- return 1
1172
- }
1173
-
1174
- return 0
1175
- }
1176
-
1177
- /**
1178
- * @param {string} value
1179
- * @return {any[]}
1180
- */
1181
- function alloc (value) {
1182
- return line = column = 1, length = strlen(characters = value), position = 0, []
1183
- }
1184
-
1185
- /**
1186
- * @param {any} value
1187
- * @return {any}
1188
- */
1189
- function dealloc (value) {
1190
- return characters = '', value
1191
- }
1192
-
1193
- /**
1194
- * @param {number} type
1195
- * @return {string}
1196
- */
1197
- function delimit (type) {
1198
- return trim(slice(position - 1, delimiter(type === 91 ? type + 2 : type === 40 ? type + 1 : type)))
1199
- }
1200
-
1201
- /**
1202
- * @param {number} type
1203
- * @return {string}
1204
- */
1205
- function whitespace (type) {
1206
- while (character = peek())
1207
- if (character < 33)
1208
- next();
1209
- else
1210
- break
1211
-
1212
- return token(type) > 2 || token(character) > 3 ? '' : ' '
1213
- }
1214
-
1215
- /**
1216
- * @param {number} index
1217
- * @param {number} count
1218
- * @return {string}
1219
- */
1220
- function escaping (index, count) {
1221
- while (--count && next())
1222
- // not 0-9 A-F a-f
1223
- if (character < 48 || character > 102 || (character > 57 && character < 65) || (character > 70 && character < 97))
1224
- break
1225
-
1226
- return slice(index, caret() + (count < 6 && peek() == 32 && next() == 32))
1227
- }
1228
-
1229
- /**
1230
- * @param {number} type
1231
- * @return {number}
1232
- */
1233
- function delimiter (type) {
1234
- while (next())
1235
- switch (character) {
1236
- // ] ) " '
1237
- case type:
1238
- return position
1239
- // " '
1240
- case 34: case 39:
1241
- if (type !== 34 && type !== 39)
1242
- delimiter(character);
1243
- break
1244
- // (
1245
- case 40:
1246
- if (type === 41)
1247
- delimiter(type);
1248
- break
1249
- // \
1250
- case 92:
1251
- next();
1252
- break
1253
- }
1254
-
1255
- return position
1256
- }
1257
-
1258
- /**
1259
- * @param {number} type
1260
- * @param {number} index
1261
- * @return {number}
1262
- */
1263
- function commenter (type, index) {
1264
- while (next())
1265
- // //
1266
- if (type + character === 47 + 10)
1267
- break
1268
- // /*
1269
- else if (type + character === 42 + 42 && peek() === 47)
1270
- break
1271
-
1272
- return '/*' + slice(index, position - 1) + '*' + from(type === 47 ? type : next())
1273
- }
1274
-
1275
- /**
1276
- * @param {number} index
1277
- * @return {string}
1278
- */
1279
- function identifier (index) {
1280
- while (!token(peek()))
1281
- next();
1282
-
1283
- return slice(index, position)
1284
- }
1285
-
1286
- /**
1287
- * @param {string} value
1288
- * @return {object[]}
1289
- */
1290
- function compile (value) {
1291
- return dealloc(parse('', null, null, null, [''], value = alloc(value), 0, [0], value))
1292
- }
1293
-
1294
- /**
1295
- * @param {string} value
1296
- * @param {object} root
1297
- * @param {object?} parent
1298
- * @param {string[]} rule
1299
- * @param {string[]} rules
1300
- * @param {string[]} rulesets
1301
- * @param {number[]} pseudo
1302
- * @param {number[]} points
1303
- * @param {string[]} declarations
1304
- * @return {object}
1305
- */
1306
- function parse (value, root, parent, rule, rules, rulesets, pseudo, points, declarations) {
1307
- var index = 0;
1308
- var offset = 0;
1309
- var length = pseudo;
1310
- var atrule = 0;
1311
- var property = 0;
1312
- var previous = 0;
1313
- var variable = 1;
1314
- var scanning = 1;
1315
- var ampersand = 1;
1316
- var character = 0;
1317
- var type = '';
1318
- var props = rules;
1319
- var children = rulesets;
1320
- var reference = rule;
1321
- var characters = type;
1322
-
1323
- while (scanning)
1324
- switch (previous = character, character = next()) {
1325
- // (
1326
- case 40:
1327
- if (previous != 108 && charat(characters, length - 1) == 58) {
1328
- if (indexof(characters += replace(delimit(character), '&', '&\f'), '&\f', abs(index ? points[index - 1] : 0)) != -1)
1329
- ampersand = -1;
1330
- break
1331
- }
1332
- // " ' [
1333
- case 34: case 39: case 91:
1334
- characters += delimit(character);
1335
- break
1336
- // \t \n \r \s
1337
- case 9: case 10: case 13: case 32:
1338
- characters += whitespace(previous);
1339
- break
1340
- // \
1341
- case 92:
1342
- characters += escaping(caret() - 1, 7);
1343
- continue
1344
- // /
1345
- case 47:
1346
- switch (peek()) {
1347
- case 42: case 47:
1348
- append(comment(commenter(next(), caret()), root, parent, declarations), declarations);
1349
- if ((token(previous || 1) == 5 || token(peek() || 1) == 5) && strlen(characters) && substr(characters, -1, void 0) !== ' ') characters += ' ';
1350
- break
1351
- default:
1352
- characters += '/';
1353
- }
1354
- break
1355
- // {
1356
- case 123 * variable:
1357
- points[index++] = strlen(characters) * ampersand;
1358
- // } ; \0
1359
- case 125 * variable: case 59: case 0:
1360
- switch (character) {
1361
- // \0 }
1362
- case 0: case 125: scanning = 0;
1363
- // ;
1364
- case 59 + offset: if (ampersand == -1) characters = replace(characters, /\f/g, '');
1365
- if (property > 0 && (strlen(characters) - length || (variable === 0 && previous === 47)))
1366
- append(property > 32 ? declaration(characters + ';', rule, parent, length - 1, declarations) : declaration(replace(characters, ' ', '') + ';', rule, parent, length - 2, declarations), declarations);
1367
- break
1368
- // @ ;
1369
- case 59: characters += ';';
1370
- // { rule/at-rule
1371
- default:
1372
- append(reference = ruleset(characters, root, parent, index, offset, rules, points, type, props = [], children = [], length, rulesets), rulesets);
1373
-
1374
- if (character === 123)
1375
- if (offset === 0)
1376
- parse(characters, root, reference, reference, props, rulesets, length, points, children);
1377
- else {
1378
- switch (atrule) {
1379
- // c(ontainer)
1380
- case 99:
1381
- if (charat(characters, 3) === 110) break
1382
- // l(ayer)
1383
- case 108:
1384
- if (charat(characters, 2) === 97) break
1385
- default:
1386
- offset = 0;
1387
- // d(ocument) m(edia) s(upports)
1388
- case 100: case 109: case 115:
1389
- }
1390
- if (offset) parse(value, reference, reference, rule && append(ruleset(value, reference, reference, 0, 0, rules, points, type, rules, props = [], length, children), children), rules, children, length, points, rule ? props : children);
1391
- else parse(characters, reference, reference, reference, [''], children, 0, points, children);
1392
- }
1393
- }
1394
-
1395
- index = offset = property = 0, variable = ampersand = 1, type = characters = '', length = pseudo;
1396
- break
1397
- // :
1398
- case 58:
1399
- length = 1 + strlen(characters), property = previous;
1400
- default:
1401
- if (variable < 1)
1402
- if (character == 123)
1403
- --variable;
1404
- else if (character == 125 && variable++ == 0 && prev() == 125)
1405
- continue
1406
-
1407
- switch (characters += from(character), character * variable) {
1408
- // &
1409
- case 38:
1410
- ampersand = offset > 0 ? 1 : (characters += '\f', -1);
1411
- break
1412
- // ,
1413
- case 44:
1414
- points[index++] = (strlen(characters) - 1) * ampersand, ampersand = 1;
1415
- break
1416
- // @
1417
- case 64:
1418
- // -
1419
- if (peek() === 45)
1420
- characters += delimit(next());
1421
-
1422
- atrule = peek(), offset = length = strlen(type = characters += identifier(caret())), character++;
1423
- break
1424
- // -
1425
- case 45:
1426
- if (previous === 45 && strlen(characters) == 2)
1427
- variable = 0;
1428
- }
1429
- }
1430
-
1431
- return rulesets
1432
- }
1433
-
1434
- /**
1435
- * @param {string} value
1436
- * @param {object} root
1437
- * @param {object?} parent
1438
- * @param {number} index
1439
- * @param {number} offset
1440
- * @param {string[]} rules
1441
- * @param {number[]} points
1442
- * @param {string} type
1443
- * @param {string[]} props
1444
- * @param {string[]} children
1445
- * @param {number} length
1446
- * @param {object[]} siblings
1447
- * @return {object}
1448
- */
1449
- function ruleset (value, root, parent, index, offset, rules, points, type, props, children, length, siblings) {
1450
- var post = offset - 1;
1451
- var rule = offset === 0 ? rules : [''];
1452
- var size = sizeof(rule);
1453
-
1454
- for (var i = 0, j = 0, k = 0; i < index; ++i)
1455
- for (var x = 0, y = substr(value, post + 1, post = abs(j = points[i])), z = value; x < size; ++x)
1456
- if (z = trim(j > 0 ? rule[x] + ' ' + y : replace(y, /&\f/g, rule[x])))
1457
- props[k++] = z;
1458
-
1459
- return node(value, root, parent, offset === 0 ? RULESET : type, props, children, length, siblings)
1460
- }
1461
-
1462
- /**
1463
- * @param {number} value
1464
- * @param {object} root
1465
- * @param {object?} parent
1466
- * @param {object[]} siblings
1467
- * @return {object}
1468
- */
1469
- function comment (value, root, parent, siblings) {
1470
- return node(value, root, parent, COMMENT, from(char()), substr(value, 2, -2), 0, siblings)
1471
- }
1472
-
1473
- /**
1474
- * @param {string} value
1475
- * @param {object} root
1476
- * @param {object?} parent
1477
- * @param {number} length
1478
- * @param {object[]} siblings
1479
- * @return {object}
1480
- */
1481
- function declaration (value, root, parent, length, siblings) {
1482
- return node(value, root, parent, DECLARATION, substr(value, 0, length), substr(value, length + 1, -1), length, siblings)
1483
- }
1484
-
1485
- /**
1486
- * @param {object[]} children
1487
- * @param {function} callback
1488
- * @return {string}
1489
- */
1490
- function serialize (children, callback) {
1491
- var output = '';
1492
-
1493
- for (var i = 0; i < children.length; i++)
1494
- output += callback(children[i], i, children, callback) || '';
1495
-
1496
- return output
1497
- }
1498
-
1499
- /**
1500
- * @param {object} element
1501
- * @param {number} index
1502
- * @param {object[]} children
1503
- * @param {function} callback
1504
- * @return {string}
1505
- */
1506
- function stringify (element, index, children, callback) {
1507
- switch (element.type) {
1508
- case LAYER: if (element.children.length) break
1509
- case IMPORT: case NAMESPACE: case DECLARATION: return element.return = element.return || element.value
1510
- case COMMENT: return ''
1511
- case KEYFRAMES: return element.return = element.value + '{' + serialize(element.children, callback) + '}'
1512
- case RULESET: if (!strlen(element.value = element.props.join(','))) return ''
1513
- }
1514
-
1515
- return strlen(children = serialize(element.children, callback)) ? element.return = element.value + '{' + children + '}' : ''
1516
- }
1517
-
1518
- function lintWarning(message, info) {
1519
- var path = info.path,
1520
- parentSelectors = info.parentSelectors;
1521
- warningOnce(false, "[Ant Design CSS-in-JS] ".concat(path ? "Error in ".concat(path, ": ") : '').concat(message).concat(parentSelectors.length ? " Selector: ".concat(parentSelectors.join(' | ')) : ''));
1522
- }
1523
-
1524
- var linter$1 = function linter(key, value, info) {
1525
- if (key === 'content') {
1526
- // From emotion: https://github.com/emotion-js/emotion/blob/main/packages/serialize/src/index.js#L63
1527
- var contentValuePattern = /(attr|counters?|url|(((repeating-)?(linear|radial))|conic)-gradient)\(|(no-)?(open|close)-quote/;
1528
- var contentValues = ['normal', 'none', 'initial', 'inherit', 'unset'];
1529
- if (typeof value !== 'string' || contentValues.indexOf(value) === -1 && !contentValuePattern.test(value) && (value.charAt(0) !== value.charAt(value.length - 1) || value.charAt(0) !== '"' && value.charAt(0) !== "'")) {
1530
- lintWarning("You seem to be using a value for 'content' without quotes, try replacing it with `content: '\"".concat(value, "\"'`."), info);
1531
- }
1532
- }
1533
- };
1534
-
1535
- var linter = function linter(key, value, info) {
1536
- if (key === 'animation') {
1537
- if (info.hashId && value !== 'none') {
1538
- lintWarning("You seem to be using hashed animation '".concat(value, "', in which case 'animationName' with Keyframe as value is recommended."), info);
1539
- }
1540
- }
1541
- };
1542
-
1543
- var ATTR_CACHE_MAP = 'data-ant-cssinjs-cache-path';
1544
-
1545
- /**
1546
- * This marks style from the css file.
1547
- * Which means not exist in `<style />` tag.
1548
- */
1549
- var CSS_FILE_STYLE = '_FILE_STYLE__';
1550
- var cachePathMap;
1551
- var fromCSSFile = true;
1552
- function prepare() {
1553
- if (!cachePathMap) {
1554
- cachePathMap = {};
1555
- if (canUseDom()) {
1556
- var div = document.createElement('div');
1557
- div.className = ATTR_CACHE_MAP;
1558
- div.style.position = 'fixed';
1559
- div.style.visibility = 'hidden';
1560
- div.style.top = '-9999px';
1561
- document.body.appendChild(div);
1562
- var content = getComputedStyle(div).content || '';
1563
- content = content.replace(/^"/, '').replace(/"$/, '');
1564
-
1565
- // Fill data
1566
- content.split(';').forEach(function (item) {
1567
- var _item$split = item.split(':'),
1568
- _item$split2 = _slicedToArray(_item$split, 2),
1569
- path = _item$split2[0],
1570
- hash = _item$split2[1];
1571
- cachePathMap[path] = hash;
1572
- });
1573
-
1574
- // Remove inline record style
1575
- var inlineMapStyle = document.querySelector("style[".concat(ATTR_CACHE_MAP, "]"));
1576
- if (inlineMapStyle) {
1577
- var _inlineMapStyle$paren;
1578
- fromCSSFile = false;
1579
- (_inlineMapStyle$paren = inlineMapStyle.parentNode) === null || _inlineMapStyle$paren === void 0 || _inlineMapStyle$paren.removeChild(inlineMapStyle);
1580
- }
1581
- document.body.removeChild(div);
1582
- }
1583
- }
1584
- }
1585
- function existPath(path) {
1586
- prepare();
1587
- return !!cachePathMap[path];
1588
- }
1589
- function getStyleAndHash(path) {
1590
- var hash = cachePathMap[path];
1591
- var styleStr = null;
1592
- if (hash && canUseDom()) {
1593
- if (fromCSSFile) {
1594
- styleStr = CSS_FILE_STYLE;
1595
- } else {
1596
- var _style = document.querySelector("style[".concat(ATTR_MARK, "=\"").concat(cachePathMap[path], "\"]"));
1597
- if (_style) {
1598
- styleStr = _style.innerHTML;
1599
- } else {
1600
- // Clean up since not exist anymore
1601
- delete cachePathMap[path];
1602
- }
1603
- }
1604
- }
1605
- return [styleStr, hash];
1606
- }
1607
-
1608
- var SKIP_CHECK = '_skip_check_';
1609
- var MULTI_VALUE = '_multi_value_';
1610
- // ============================================================================
1611
- // == Parser ==
1612
- // ============================================================================
1613
- // Preprocessor style content to browser support one
1614
- function normalizeStyle(styleStr) {
1615
- var serialized = serialize(compile(styleStr), stringify);
1616
- return serialized.replace(/\{%%%\:[^;];}/g, ';');
1617
- }
1618
- function isCompoundCSSProperty(value) {
1619
- return _typeof(value) === 'object' && value && (SKIP_CHECK in value || MULTI_VALUE in value);
1620
- }
1621
-
1622
- // 注入 hash 值
1623
- function injectSelectorHash(key, hashId, hashPriority) {
1624
- if (!hashId) {
1625
- return key;
1626
- }
1627
- var hashClassName = ".".concat(hashId);
1628
- var hashSelector = hashPriority === 'low' ? ":where(".concat(hashClassName, ")") : hashClassName;
1629
-
1630
- // 注入 hashId
1631
- var keys = key.split(',').map(function (k) {
1632
- var _firstPath$match;
1633
- var fullPath = k.trim().split(/\s+/);
1634
-
1635
- // 如果 Selector 第一个是 HTML Element,那我们就插到它的后面。反之,就插到最前面。
1636
- var firstPath = fullPath[0] || '';
1637
- var htmlElement = ((_firstPath$match = firstPath.match(/^\w+/)) === null || _firstPath$match === void 0 ? void 0 : _firstPath$match[0]) || '';
1638
- firstPath = "".concat(htmlElement).concat(hashSelector).concat(firstPath.slice(htmlElement.length));
1639
- return [firstPath].concat(_toConsumableArray(fullPath.slice(1))).join(' ');
1640
- });
1641
- return keys.join(',');
1642
- }
1643
- // Parse CSSObject to style content
1644
- var parseStyle = function parseStyle(interpolation) {
1645
- var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1646
- var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
1647
- root: true,
1648
- parentSelectors: []
1649
- },
1650
- root = _ref.root,
1651
- injectHash = _ref.injectHash,
1652
- parentSelectors = _ref.parentSelectors;
1653
- var hashId = config.hashId,
1654
- layer = config.layer,
1655
- path = config.path,
1656
- hashPriority = config.hashPriority,
1657
- _config$transformers = config.transformers,
1658
- transformers = _config$transformers === void 0 ? [] : _config$transformers,
1659
- _config$linters = config.linters,
1660
- linters = _config$linters === void 0 ? [] : _config$linters;
1661
- var styleStr = '';
1662
- var effectStyle = {};
1663
- function parseKeyframes(keyframes) {
1664
- var animationName = keyframes.getName(hashId);
1665
- if (!effectStyle[animationName]) {
1666
- var _parseStyle = parseStyle(keyframes.style, config, {
1667
- root: false,
1668
- parentSelectors: parentSelectors
1669
- }),
1670
- _parseStyle2 = _slicedToArray(_parseStyle, 1),
1671
- _parsedStr = _parseStyle2[0];
1672
- effectStyle[animationName] = "@keyframes ".concat(keyframes.getName(hashId)).concat(_parsedStr);
1673
- }
1674
- }
1675
- function flattenList(list) {
1676
- var fullList = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
1677
- list.forEach(function (item) {
1678
- if (Array.isArray(item)) {
1679
- flattenList(item, fullList);
1680
- } else if (item) {
1681
- fullList.push(item);
1682
- }
1683
- });
1684
- return fullList;
1685
- }
1686
- var flattenStyleList = flattenList(Array.isArray(interpolation) ? interpolation : [interpolation]);
1687
- flattenStyleList.forEach(function (originStyle) {
1688
- // Only root level can use raw string
1689
- var style = typeof originStyle === 'string' && !root ? {} : originStyle;
1690
- if (typeof style === 'string') {
1691
- styleStr += "".concat(style, "\n");
1692
- } else if (style._keyframe) {
1693
- // Keyframe
1694
- parseKeyframes(style);
1695
- } else {
1696
- var mergedStyle = transformers.reduce(function (prev, trans) {
1697
- var _trans$visit;
1698
- return (trans === null || trans === void 0 || (_trans$visit = trans.visit) === null || _trans$visit === void 0 ? void 0 : _trans$visit.call(trans, prev)) || prev;
1699
- }, style);
1700
-
1701
- // Normal CSSObject
1702
- Object.keys(mergedStyle).forEach(function (key) {
1703
- var value = mergedStyle[key];
1704
- if (_typeof(value) === 'object' && value && (key !== 'animationName' || !value._keyframe) && !isCompoundCSSProperty(value)) {
1705
- var subInjectHash = false;
1706
-
1707
- // 当成嵌套对象来处理
1708
- var mergedKey = key.trim();
1709
- // Whether treat child as root. In most case it is false.
1710
- var nextRoot = false;
1711
-
1712
- // 拆分多个选择器
1713
- if ((root || injectHash) && hashId) {
1714
- if (mergedKey.startsWith('@')) {
1715
- // 略过媒体查询,交给子节点继续插入 hashId
1716
- subInjectHash = true;
1717
- } else if (mergedKey === '&') {
1718
- // 抹掉 root selector 上的单个 &
1719
- mergedKey = injectSelectorHash('', hashId, hashPriority);
1720
- } else {
1721
- // 注入 hashId
1722
- mergedKey = injectSelectorHash(key, hashId, hashPriority);
1723
- }
1724
- } else if (root && !hashId && (mergedKey === '&' || mergedKey === '')) {
1725
- // In case of `{ '&': { a: { color: 'red' } } }` or `{ '': { a: { color: 'red' } } }` without hashId,
1726
- // we will get `&{a:{color:red;}}` or `{a:{color:red;}}` string for stylis to compile.
1727
- // But it does not conform to stylis syntax,
1728
- // and finally we will get `{color:red;}` as css, which is wrong.
1729
- // So we need to remove key in root, and treat child `{ a: { color: 'red' } }` as root.
1730
- mergedKey = '';
1731
- nextRoot = true;
1732
- }
1733
- var _parseStyle3 = parseStyle(value, config, {
1734
- root: nextRoot,
1735
- injectHash: subInjectHash,
1736
- parentSelectors: [].concat(_toConsumableArray(parentSelectors), [mergedKey])
1737
- }),
1738
- _parseStyle4 = _slicedToArray(_parseStyle3, 2),
1739
- _parsedStr2 = _parseStyle4[0],
1740
- childEffectStyle = _parseStyle4[1];
1741
- effectStyle = _objectSpread2(_objectSpread2({}, effectStyle), childEffectStyle);
1742
- styleStr += "".concat(mergedKey).concat(_parsedStr2);
1743
- } else {
1744
- var _value;
1745
- function appendStyle(cssKey, cssValue) {
1746
- if (process.env.NODE_ENV !== 'production' && (_typeof(value) !== 'object' || !(value !== null && value !== void 0 && value[SKIP_CHECK]))) {
1747
- [linter$1, linter].concat(_toConsumableArray(linters)).forEach(function (linter) {
1748
- return linter(cssKey, cssValue, {
1749
- path: path,
1750
- hashId: hashId,
1751
- parentSelectors: parentSelectors
1752
- });
1753
- });
1754
- }
1755
-
1756
- // 如果是样式则直接插入
1757
- var styleName = cssKey.replace(/[A-Z]/g, function (match) {
1758
- return "-".concat(match.toLowerCase());
1759
- });
1760
-
1761
- // Auto suffix with px
1762
- var formatValue = cssValue;
1763
- if (!unitlessKeys[cssKey] && typeof formatValue === 'number' && formatValue !== 0) {
1764
- formatValue = "".concat(formatValue, "px");
1765
- }
1766
-
1767
- // handle animationName & Keyframe value
1768
- if (cssKey === 'animationName' && cssValue !== null && cssValue !== void 0 && cssValue._keyframe) {
1769
- parseKeyframes(cssValue);
1770
- formatValue = cssValue.getName(hashId);
1771
- }
1772
- styleStr += "".concat(styleName, ":").concat(formatValue, ";");
1773
- }
1774
- var actualValue = (_value = value === null || value === void 0 ? void 0 : value.value) !== null && _value !== void 0 ? _value : value;
1775
- if (_typeof(value) === 'object' && value !== null && value !== void 0 && value[MULTI_VALUE] && Array.isArray(actualValue)) {
1776
- actualValue.forEach(function (item) {
1777
- appendStyle(key, item);
1778
- });
1779
- } else {
1780
- appendStyle(key, actualValue);
1781
- }
1782
- }
1783
- });
1784
- }
1785
- });
1786
- if (!root) {
1787
- styleStr = "{".concat(styleStr, "}");
1788
- } else if (layer) {
1789
- // fixme: https://github.com/thysultan/stylis/pull/339
1790
- if (styleStr) {
1791
- styleStr = "@layer ".concat(layer.name, " {").concat(styleStr, "}");
1792
- }
1793
- if (layer.dependencies) {
1794
- effectStyle["@layer ".concat(layer.name)] = layer.dependencies.map(function (deps) {
1795
- return "@layer ".concat(deps, ", ").concat(layer.name, ";");
1796
- }).join('\n');
1797
- }
1798
- }
1799
- return [styleStr, effectStyle];
1800
- };
1801
-
1802
- // ============================================================================
1803
- // == Register ==
1804
- // ============================================================================
1805
- function uniqueHash(path, styleStr) {
1806
- return murmur2("".concat(path.join('%')).concat(styleStr));
1807
- }
1808
- function Empty() {
1809
- return null;
1810
- }
1811
- var STYLE_PREFIX = 'style';
1812
- /**
1813
- * Register a style to the global style sheet.
1814
- */
1815
- function useStyleRegister(info, styleFn) {
1816
- var token = info.token,
1817
- path = info.path,
1818
- hashId = info.hashId,
1819
- layer = info.layer,
1820
- nonce = info.nonce,
1821
- clientOnly = info.clientOnly,
1822
- _info$order = info.order,
1823
- order = _info$order === void 0 ? 0 : _info$order;
1824
- var _React$useContext = React.useContext(StyleContext),
1825
- autoClear = _React$useContext.autoClear,
1826
- mock = _React$useContext.mock,
1827
- defaultCache = _React$useContext.defaultCache,
1828
- hashPriority = _React$useContext.hashPriority,
1829
- container = _React$useContext.container,
1830
- ssrInline = _React$useContext.ssrInline,
1831
- transformers = _React$useContext.transformers,
1832
- linters = _React$useContext.linters,
1833
- cache = _React$useContext.cache,
1834
- enableLayer = _React$useContext.layer;
1835
- var tokenKey = token._tokenKey;
1836
- var fullPath = [tokenKey];
1837
- if (enableLayer) {
1838
- fullPath.push('layer');
1839
- }
1840
- fullPath.push.apply(fullPath, _toConsumableArray(path));
1841
-
1842
- // Check if need insert style
1843
- var isMergedClientSide = isClientSide;
1844
- if (process.env.NODE_ENV !== 'production' && mock !== undefined) {
1845
- isMergedClientSide = mock === 'client';
1846
- }
1847
- var _useGlobalCache = useGlobalCache(STYLE_PREFIX, fullPath,
1848
- // Create cache if needed
1849
- function () {
1850
- var cachePath = fullPath.join('|');
1851
-
1852
- // Get style from SSR inline style directly
1853
- if (existPath(cachePath)) {
1854
- var _getStyleAndHash = getStyleAndHash(cachePath),
1855
- _getStyleAndHash2 = _slicedToArray(_getStyleAndHash, 2),
1856
- inlineCacheStyleStr = _getStyleAndHash2[0],
1857
- styleHash = _getStyleAndHash2[1];
1858
- if (inlineCacheStyleStr) {
1859
- return [inlineCacheStyleStr, tokenKey, styleHash, {}, clientOnly, order];
1860
- }
1861
- }
1862
-
1863
- // Generate style
1864
- var styleObj = styleFn();
1865
- var _parseStyle5 = parseStyle(styleObj, {
1866
- hashId: hashId,
1867
- hashPriority: hashPriority,
1868
- layer: enableLayer ? layer : undefined,
1869
- path: path.join('-'),
1870
- transformers: transformers,
1871
- linters: linters
1872
- }),
1873
- _parseStyle6 = _slicedToArray(_parseStyle5, 2),
1874
- parsedStyle = _parseStyle6[0],
1875
- effectStyle = _parseStyle6[1];
1876
- var styleStr = normalizeStyle(parsedStyle);
1877
- var styleId = uniqueHash(fullPath, styleStr);
1878
- return [styleStr, tokenKey, styleId, effectStyle, clientOnly, order];
1879
- },
1880
- // Remove cache if no need
1881
- function (_ref2, fromHMR) {
1882
- var _ref3 = _slicedToArray(_ref2, 3),
1883
- styleId = _ref3[2];
1884
- if ((fromHMR || autoClear) && isClientSide) {
1885
- removeCSS(styleId, {
1886
- mark: ATTR_MARK,
1887
- attachTo: container
1888
- });
1889
- }
1890
- },
1891
- // Effect: Inject style here
1892
- function (_ref4) {
1893
- var _ref5 = _slicedToArray(_ref4, 4),
1894
- styleStr = _ref5[0],
1895
- styleId = _ref5[2],
1896
- effectStyle = _ref5[3];
1897
- if (isMergedClientSide && styleStr !== CSS_FILE_STYLE) {
1898
- var mergedCSSConfig = {
1899
- mark: ATTR_MARK,
1900
- prepend: enableLayer ? false : 'queue',
1901
- attachTo: container,
1902
- priority: order
1903
- };
1904
- var nonceStr = typeof nonce === 'function' ? nonce() : nonce;
1905
- if (nonceStr) {
1906
- mergedCSSConfig.csp = {
1907
- nonce: nonceStr
1908
- };
1909
- }
1910
-
1911
- // ================= Split Effect Style =================
1912
- // We will split effectStyle here since @layer should be at the top level
1913
- var effectLayerKeys = [];
1914
- var effectRestKeys = [];
1915
- Object.keys(effectStyle).forEach(function (key) {
1916
- if (key.startsWith('@layer')) {
1917
- effectLayerKeys.push(key);
1918
- } else {
1919
- effectRestKeys.push(key);
1920
- }
1921
- });
1922
-
1923
- // ================= Inject Layer Style =================
1924
- // Inject layer style
1925
- effectLayerKeys.forEach(function (effectKey) {
1926
- updateCSS(normalizeStyle(effectStyle[effectKey]), "_layer-".concat(effectKey), _objectSpread2(_objectSpread2({}, mergedCSSConfig), {}, {
1927
- prepend: true
1928
- }));
1929
- });
1930
-
1931
- // ==================== Inject Style ====================
1932
- // Inject style
1933
- var style = updateCSS(styleStr, styleId, mergedCSSConfig);
1934
- style[CSS_IN_JS_INSTANCE] = cache.instanceId;
1935
-
1936
- // Used for `useCacheToken` to remove on batch when token removed
1937
- style.setAttribute(ATTR_TOKEN, tokenKey);
1938
-
1939
- // Debug usage. Dev only
1940
- if (process.env.NODE_ENV !== 'production') {
1941
- style.setAttribute(ATTR_CACHE_PATH, fullPath.join('|'));
1942
- }
1943
-
1944
- // ================ Inject Effect Style =================
1945
- // Inject client side effect style
1946
- effectRestKeys.forEach(function (effectKey) {
1947
- updateCSS(normalizeStyle(effectStyle[effectKey]), "_effect-".concat(effectKey), mergedCSSConfig);
1948
- });
1949
- }
1950
- }),
1951
- _useGlobalCache2 = _slicedToArray(_useGlobalCache, 3),
1952
- cachedStyleStr = _useGlobalCache2[0],
1953
- cachedTokenKey = _useGlobalCache2[1],
1954
- cachedStyleId = _useGlobalCache2[2];
1955
- return function (node) {
1956
- var styleNode;
1957
- if (!ssrInline || isMergedClientSide || !defaultCache) {
1958
- styleNode = /*#__PURE__*/React.createElement(Empty, null);
1959
- } else {
1960
- styleNode = /*#__PURE__*/React.createElement("style", _extends({}, _defineProperty(_defineProperty({}, ATTR_TOKEN, cachedTokenKey), ATTR_MARK, cachedStyleId), {
1961
- dangerouslySetInnerHTML: {
1962
- __html: cachedStyleStr
1963
- }
1964
- }));
1965
- }
1966
- return /*#__PURE__*/React.createElement(React.Fragment, null, styleNode, node);
1967
- };
1968
- }
1969
-
1970
- var CSS_VAR_PREFIX = 'cssVar';
1971
- var useCSSVarRegister = function useCSSVarRegister(config, fn) {
1972
- var key = config.key,
1973
- prefix = config.prefix,
1974
- unitless = config.unitless,
1975
- ignore = config.ignore,
1976
- token = config.token,
1977
- _config$scope = config.scope,
1978
- scope = _config$scope === void 0 ? '' : _config$scope;
1979
- var _useContext = useContext(StyleContext),
1980
- instanceId = _useContext.cache.instanceId,
1981
- container = _useContext.container;
1982
- var tokenKey = token._tokenKey;
1983
- var stylePath = [].concat(_toConsumableArray(config.path), [key, scope, tokenKey]);
1984
- var cache = useGlobalCache(CSS_VAR_PREFIX, stylePath, function () {
1985
- var originToken = fn();
1986
- var _transformToken = transformToken(originToken, key, {
1987
- prefix: prefix,
1988
- unitless: unitless,
1989
- ignore: ignore,
1990
- scope: scope
1991
- }),
1992
- _transformToken2 = _slicedToArray(_transformToken, 2),
1993
- mergedToken = _transformToken2[0],
1994
- cssVarsStr = _transformToken2[1];
1995
- var styleId = uniqueHash(stylePath, cssVarsStr);
1996
- return [mergedToken, cssVarsStr, styleId, key];
1997
- }, function (_ref) {
1998
- var _ref2 = _slicedToArray(_ref, 3),
1999
- styleId = _ref2[2];
2000
- if (isClientSide) {
2001
- removeCSS(styleId, {
2002
- mark: ATTR_MARK,
2003
- attachTo: container
2004
- });
2005
- }
2006
- }, function (_ref3) {
2007
- var _ref4 = _slicedToArray(_ref3, 3),
2008
- cssVarsStr = _ref4[1],
2009
- styleId = _ref4[2];
2010
- if (!cssVarsStr) {
2011
- return;
2012
- }
2013
- var style = updateCSS(cssVarsStr, styleId, {
2014
- mark: ATTR_MARK,
2015
- prepend: 'queue',
2016
- attachTo: container,
2017
- priority: -999
2018
- });
2019
- style[CSS_IN_JS_INSTANCE] = instanceId;
2020
-
2021
- // Used for `useCacheToken` to remove on batch when token removed
2022
- style.setAttribute(ATTR_TOKEN, key);
2023
- });
2024
- return cache;
2025
- };
2026
-
2027
- function _toArray(r) {
2028
- return _arrayWithHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableRest();
2029
- }
2030
-
2031
- function get(entity, path) {
2032
- var current = entity;
2033
- for (var i = 0; i < path.length; i += 1) {
2034
- if (current === null || current === undefined) {
2035
- return undefined;
2036
- }
2037
- current = current[path[i]];
2038
- }
2039
- return current;
2040
- }
2041
-
2042
- function internalSet(entity, paths, value, removeIfUndefined) {
2043
- if (!paths.length) {
2044
- return value;
2045
- }
2046
- var _paths = _toArray(paths),
2047
- path = _paths[0],
2048
- restPath = _paths.slice(1);
2049
- var clone;
2050
- if (!entity && typeof path === 'number') {
2051
- clone = [];
2052
- } else if (Array.isArray(entity)) {
2053
- clone = _toConsumableArray(entity);
2054
- } else {
2055
- clone = _objectSpread2({}, entity);
2056
- }
2057
-
2058
- // Delete prop if `removeIfUndefined` and value is undefined
2059
- if (removeIfUndefined && value === undefined && restPath.length === 1) {
2060
- delete clone[path][restPath[0]];
2061
- } else {
2062
- clone[path] = internalSet(clone[path], restPath, value, removeIfUndefined);
2063
- }
2064
- return clone;
2065
- }
2066
- function set(entity, paths, value) {
2067
- var removeIfUndefined = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
2068
- // Do nothing if `removeIfUndefined` and parent object not exist
2069
- if (paths.length && removeIfUndefined && value === undefined && !get(entity, paths.slice(0, -1))) {
2070
- return entity;
2071
- }
2072
- return internalSet(entity, paths, value, removeIfUndefined);
2073
- }
2074
- function isObject(obj) {
2075
- return _typeof(obj) === 'object' && obj !== null && Object.getPrototypeOf(obj) === Object.prototype;
2076
- }
2077
- function createEmpty(source) {
2078
- return Array.isArray(source) ? [] : {};
2079
- }
2080
- var keys = typeof Reflect === 'undefined' ? Object.keys : Reflect.ownKeys;
2081
-
2082
- /**
2083
- * Merge objects which will create
2084
- */
2085
- function merge$1() {
2086
- for (var _len = arguments.length, sources = new Array(_len), _key = 0; _key < _len; _key++) {
2087
- sources[_key] = arguments[_key];
2088
- }
2089
- var clone = createEmpty(sources[0]);
2090
- sources.forEach(function (src) {
2091
- function internalMerge(path, parentLoopSet) {
2092
- var loopSet = new Set(parentLoopSet);
2093
- var value = get(src, path);
2094
- var isArr = Array.isArray(value);
2095
- if (isArr || isObject(value)) {
2096
- // Only add not loop obj
2097
- if (!loopSet.has(value)) {
2098
- loopSet.add(value);
2099
- var originValue = get(clone, path);
2100
- if (isArr) {
2101
- // Array will always be override
2102
- clone = set(clone, path, []);
2103
- } else if (!originValue || _typeof(originValue) !== 'object') {
2104
- // Init container if not exist
2105
- clone = set(clone, path, createEmpty(value));
2106
- }
2107
- keys(value).forEach(function (key) {
2108
- internalMerge([].concat(_toConsumableArray(path), [key]), loopSet);
2109
- });
2110
- }
2111
- } else {
2112
- clone = set(clone, path, value);
2113
- }
2114
- }
2115
- internalMerge([]);
2116
- });
2117
- return clone;
2118
- }
2119
-
2120
- function noop$1() {}
2121
- let deprecatedWarnList = null;
2122
- function resetWarned() {
2123
- deprecatedWarnList = null;
2124
- resetWarned$1();
2125
- }
2126
- let _warning = noop$1;
2127
- if (process.env.NODE_ENV !== 'production') {
2128
- _warning = (valid, component, message) => {
2129
- warningOnce(valid, `[antd: ${component}] ${message}`);
2130
- // StrictMode will inject console which will not throw warning in React 17.
2131
- if (process.env.NODE_ENV === 'test') {
2132
- resetWarned();
2133
- }
2134
- };
2135
- }
2136
- const warning = _warning;
2137
- const WarningContext = /*#__PURE__*/React.createContext({});
2138
- /**
2139
- * This is a hook but we not named as `useWarning`
2140
- * since this is only used in development.
2141
- * We should always wrap this in `if (process.env.NODE_ENV !== 'production')` condition
2142
- */
2143
- const devUseWarning = process.env.NODE_ENV !== 'production' ? component => {
2144
- const {
2145
- strict
2146
- } = React.useContext(WarningContext);
2147
- const typeWarning = (valid, type, message) => {
2148
- if (!valid) {
2149
- if (strict === false && type === 'deprecated') {
2150
- const existWarning = deprecatedWarnList;
2151
- if (!deprecatedWarnList) {
2152
- deprecatedWarnList = {};
2153
- }
2154
- deprecatedWarnList[component] = deprecatedWarnList[component] || [];
2155
- if (!deprecatedWarnList[component].includes(message || '')) {
2156
- deprecatedWarnList[component].push(message || '');
2157
- }
2158
- // Warning for the first time
2159
- if (!existWarning) {
2160
- console.warn('[antd] There exists deprecated usage in your code:', deprecatedWarnList);
2161
- }
2162
- } else {
2163
- process.env.NODE_ENV !== "production" ? warning(valid, component, message) : void 0;
2164
- }
2165
- }
2166
- };
2167
- typeWarning.deprecated = (valid, oldProp, newProp, message) => {
2168
- typeWarning(valid, 'deprecated', `\`${oldProp}\` is deprecated. Please use \`${newProp}\` instead.${message ? ` ${message}` : ''}`);
2169
- };
2170
- return typeWarning;
2171
- } : () => {
2172
- const noopWarning = () => {};
2173
- noopWarning.deprecated = noop$1;
2174
- return noopWarning;
2175
- };
2176
-
2177
- // ZombieJ: We export single file here since
2178
- // ConfigProvider use this which will make loop deps
2179
- // to import whole `rc-field-form`
2180
- const ValidateMessagesContext = /*#__PURE__*/createContext(undefined);
2181
-
2182
- const typeTemplate = '${label} is not a valid ${type}';
2183
- const localeValues = {
2184
- Modal: {
2185
- okText: 'OK',
2186
- cancelText: 'Cancel',
2187
- justOkText: 'OK'
2188
- },
2189
- Form: {
2190
- optional: '(optional)',
2191
- defaultValidateMessages: {
2192
- default: 'Field validation error for ${label}',
2193
- required: 'Please enter ${label}',
2194
- enum: '${label} must be one of [${enum}]',
2195
- whitespace: '${label} cannot be a blank character',
2196
- date: {
2197
- format: '${label} date format is invalid',
2198
- parse: '${label} cannot be converted to a date',
2199
- invalid: '${label} is an invalid date'
2200
- },
2201
- types: {
2202
- string: typeTemplate,
2203
- method: typeTemplate,
2204
- array: typeTemplate,
2205
- object: typeTemplate,
2206
- number: typeTemplate,
2207
- date: typeTemplate,
2208
- boolean: typeTemplate,
2209
- integer: typeTemplate,
2210
- float: typeTemplate,
2211
- regexp: typeTemplate,
2212
- email: typeTemplate,
2213
- url: typeTemplate,
2214
- hex: typeTemplate
2215
- },
2216
- string: {
2217
- len: '${label} must be ${len} characters',
2218
- min: '${label} must be at least ${min} characters',
2219
- max: '${label} must be up to ${max} characters',
2220
- range: '${label} must be between ${min}-${max} characters'
2221
- },
2222
- number: {
2223
- len: '${label} must be equal to ${len}',
2224
- min: '${label} must be minimum ${min}',
2225
- max: '${label} must be maximum ${max}',
2226
- range: '${label} must be between ${min}-${max}'
2227
- },
2228
- array: {
2229
- len: 'Must be ${len} ${label}',
2230
- min: 'At least ${min} ${label}',
2231
- max: 'At most ${max} ${label}',
2232
- range: 'The amount of ${label} must be between ${min}-${max}'
2233
- },
2234
- pattern: {
2235
- mismatch: '${label} does not match the pattern ${pattern}'
2236
- }
2237
- }
2238
- }};
2239
-
2240
- Object.assign({}, localeValues.Modal);
2241
- let localeList = [];
2242
- const generateLocale = () => localeList.reduce((merged, locale) => Object.assign(Object.assign({}, merged), locale), localeValues.Modal);
2243
- function changeConfirmLocale(newLocale) {
2244
- if (newLocale) {
2245
- const cloneLocale = Object.assign({}, newLocale);
2246
- localeList.push(cloneLocale);
2247
- generateLocale();
2248
- return () => {
2249
- localeList = localeList.filter(locale => locale !== cloneLocale);
2250
- generateLocale();
2251
- };
2252
- }
2253
- Object.assign({}, localeValues.Modal);
2254
- }
2255
-
2256
- const LocaleContext = /*#__PURE__*/createContext(undefined);
2257
-
2258
- const ANT_MARK = 'internalMark';
2259
- const LocaleProvider = props => {
2260
- const {
2261
- locale = {},
2262
- children,
2263
- _ANT_MARK__
2264
- } = props;
2265
- if (process.env.NODE_ENV !== 'production') {
2266
- const warning = devUseWarning('LocaleProvider');
2267
- process.env.NODE_ENV !== "production" ? warning(_ANT_MARK__ === ANT_MARK, 'deprecated', '`LocaleProvider` is deprecated. Please use `locale` with `ConfigProvider` instead: http://u.ant.design/locale') : void 0;
2268
- }
2269
- React.useEffect(() => {
2270
- const clearLocale = changeConfirmLocale(locale === null || locale === void 0 ? void 0 : locale.Modal);
2271
- return clearLocale;
2272
- }, [locale]);
2273
- const getMemoizedContextValue = React.useMemo(() => Object.assign(Object.assign({}, locale), {
2274
- exist: true
2275
- }), [locale]);
2276
- return /*#__PURE__*/React.createElement(LocaleContext.Provider, {
2277
- value: getMemoizedContextValue
2278
- }, children);
2279
- };
2280
- if (process.env.NODE_ENV !== 'production') {
2281
- LocaleProvider.displayName = 'LocaleProvider';
2282
- }
2283
-
2284
- const defaultPresetColors = {
2285
- blue: '#1677FF',
2286
- purple: '#722ED1',
2287
- cyan: '#13C2C2',
2288
- green: '#52C41A',
2289
- magenta: '#EB2F96',
2290
- /**
2291
- * @deprecated Use magenta instead
2292
- */
2293
- pink: '#EB2F96',
2294
- red: '#F5222D',
2295
- orange: '#FA8C16',
2296
- yellow: '#FADB14',
2297
- volcano: '#FA541C',
2298
- geekblue: '#2F54EB',
2299
- gold: '#FAAD14',
2300
- lime: '#A0D911'
2301
- };
2302
- const seedToken = Object.assign(Object.assign({}, defaultPresetColors), {
2303
- // Color
2304
- colorPrimary: '#1677ff',
2305
- colorSuccess: '#52c41a',
2306
- colorWarning: '#faad14',
2307
- colorError: '#ff4d4f',
2308
- colorInfo: '#1677ff',
2309
- colorLink: '',
2310
- colorTextBase: '',
2311
- colorBgBase: '',
2312
- // Font
2313
- fontFamily: `-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial,
2314
- 'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol',
2315
- 'Noto Color Emoji'`,
2316
- fontFamilyCode: `'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, Courier, monospace`,
2317
- fontSize: 14,
2318
- // Line
2319
- lineWidth: 1,
2320
- lineType: 'solid',
2321
- // Motion
2322
- motionUnit: 0.1,
2323
- motionBase: 0,
2324
- motionEaseOutCirc: 'cubic-bezier(0.08, 0.82, 0.17, 1)',
2325
- motionEaseInOutCirc: 'cubic-bezier(0.78, 0.14, 0.15, 0.86)',
2326
- motionEaseOut: 'cubic-bezier(0.215, 0.61, 0.355, 1)',
2327
- motionEaseInOut: 'cubic-bezier(0.645, 0.045, 0.355, 1)',
2328
- motionEaseOutBack: 'cubic-bezier(0.12, 0.4, 0.29, 1.46)',
2329
- motionEaseInBack: 'cubic-bezier(0.71, -0.46, 0.88, 0.6)',
2330
- motionEaseInQuint: 'cubic-bezier(0.755, 0.05, 0.855, 0.06)',
2331
- motionEaseOutQuint: 'cubic-bezier(0.23, 1, 0.32, 1)',
2332
- // Radius
2333
- borderRadius: 6,
2334
- // Size
2335
- sizeUnit: 4,
2336
- sizeStep: 4,
2337
- sizePopupArrow: 16,
2338
- // Control Base
2339
- controlHeight: 32,
2340
- // zIndex
2341
- zIndexBase: 0,
2342
- zIndexPopupBase: 1000,
2343
- // Image
2344
- opacityImage: 1,
2345
- // Wireframe
2346
- wireframe: false,
2347
- // Motion
2348
- motion: true
2349
- });
2350
-
2351
- function genColorMapToken(seed, {
2352
- generateColorPalettes,
2353
- generateNeutralColorPalettes
2354
- }) {
2355
- const {
2356
- colorSuccess: colorSuccessBase,
2357
- colorWarning: colorWarningBase,
2358
- colorError: colorErrorBase,
2359
- colorInfo: colorInfoBase,
2360
- colorPrimary: colorPrimaryBase,
2361
- colorBgBase,
2362
- colorTextBase
2363
- } = seed;
2364
- const primaryColors = generateColorPalettes(colorPrimaryBase);
2365
- const successColors = generateColorPalettes(colorSuccessBase);
2366
- const warningColors = generateColorPalettes(colorWarningBase);
2367
- const errorColors = generateColorPalettes(colorErrorBase);
2368
- const infoColors = generateColorPalettes(colorInfoBase);
2369
- const neutralColors = generateNeutralColorPalettes(colorBgBase, colorTextBase);
2370
- // Color Link
2371
- const colorLink = seed.colorLink || seed.colorInfo;
2372
- const linkColors = generateColorPalettes(colorLink);
2373
- const colorErrorBgFilledHover = new FastColor(errorColors[1]).mix(new FastColor(errorColors[3]), 50).toHexString();
2374
- return Object.assign(Object.assign({}, neutralColors), {
2375
- colorPrimaryBg: primaryColors[1],
2376
- colorPrimaryBgHover: primaryColors[2],
2377
- colorPrimaryBorder: primaryColors[3],
2378
- colorPrimaryBorderHover: primaryColors[4],
2379
- colorPrimaryHover: primaryColors[5],
2380
- colorPrimary: primaryColors[6],
2381
- colorPrimaryActive: primaryColors[7],
2382
- colorPrimaryTextHover: primaryColors[8],
2383
- colorPrimaryText: primaryColors[9],
2384
- colorPrimaryTextActive: primaryColors[10],
2385
- colorSuccessBg: successColors[1],
2386
- colorSuccessBgHover: successColors[2],
2387
- colorSuccessBorder: successColors[3],
2388
- colorSuccessBorderHover: successColors[4],
2389
- colorSuccessHover: successColors[4],
2390
- colorSuccess: successColors[6],
2391
- colorSuccessActive: successColors[7],
2392
- colorSuccessTextHover: successColors[8],
2393
- colorSuccessText: successColors[9],
2394
- colorSuccessTextActive: successColors[10],
2395
- colorErrorBg: errorColors[1],
2396
- colorErrorBgHover: errorColors[2],
2397
- colorErrorBgFilledHover,
2398
- colorErrorBgActive: errorColors[3],
2399
- colorErrorBorder: errorColors[3],
2400
- colorErrorBorderHover: errorColors[4],
2401
- colorErrorHover: errorColors[5],
2402
- colorError: errorColors[6],
2403
- colorErrorActive: errorColors[7],
2404
- colorErrorTextHover: errorColors[8],
2405
- colorErrorText: errorColors[9],
2406
- colorErrorTextActive: errorColors[10],
2407
- colorWarningBg: warningColors[1],
2408
- colorWarningBgHover: warningColors[2],
2409
- colorWarningBorder: warningColors[3],
2410
- colorWarningBorderHover: warningColors[4],
2411
- colorWarningHover: warningColors[4],
2412
- colorWarning: warningColors[6],
2413
- colorWarningActive: warningColors[7],
2414
- colorWarningTextHover: warningColors[8],
2415
- colorWarningText: warningColors[9],
2416
- colorWarningTextActive: warningColors[10],
2417
- colorInfoBg: infoColors[1],
2418
- colorInfoBgHover: infoColors[2],
2419
- colorInfoBorder: infoColors[3],
2420
- colorInfoBorderHover: infoColors[4],
2421
- colorInfoHover: infoColors[4],
2422
- colorInfo: infoColors[6],
2423
- colorInfoActive: infoColors[7],
2424
- colorInfoTextHover: infoColors[8],
2425
- colorInfoText: infoColors[9],
2426
- colorInfoTextActive: infoColors[10],
2427
- colorLinkHover: linkColors[4],
2428
- colorLink: linkColors[6],
2429
- colorLinkActive: linkColors[7],
2430
- colorBgMask: new FastColor('#000').setA(0.45).toRgbString(),
2431
- colorWhite: '#fff'
2432
- });
2433
- }
2434
-
2435
- const genRadius = radiusBase => {
2436
- let radiusLG = radiusBase;
2437
- let radiusSM = radiusBase;
2438
- let radiusXS = radiusBase;
2439
- let radiusOuter = radiusBase;
2440
- // radiusLG
2441
- if (radiusBase < 6 && radiusBase >= 5) {
2442
- radiusLG = radiusBase + 1;
2443
- } else if (radiusBase < 16 && radiusBase >= 6) {
2444
- radiusLG = radiusBase + 2;
2445
- } else if (radiusBase >= 16) {
2446
- radiusLG = 16;
2447
- }
2448
- // radiusSM
2449
- if (radiusBase < 7 && radiusBase >= 5) {
2450
- radiusSM = 4;
2451
- } else if (radiusBase < 8 && radiusBase >= 7) {
2452
- radiusSM = 5;
2453
- } else if (radiusBase < 14 && radiusBase >= 8) {
2454
- radiusSM = 6;
2455
- } else if (radiusBase < 16 && radiusBase >= 14) {
2456
- radiusSM = 7;
2457
- } else if (radiusBase >= 16) {
2458
- radiusSM = 8;
2459
- }
2460
- // radiusXS
2461
- if (radiusBase < 6 && radiusBase >= 2) {
2462
- radiusXS = 1;
2463
- } else if (radiusBase >= 6) {
2464
- radiusXS = 2;
2465
- }
2466
- // radiusOuter
2467
- if (radiusBase > 4 && radiusBase < 8) {
2468
- radiusOuter = 4;
2469
- } else if (radiusBase >= 8) {
2470
- radiusOuter = 6;
2471
- }
2472
- return {
2473
- borderRadius: radiusBase,
2474
- borderRadiusXS: radiusXS,
2475
- borderRadiusSM: radiusSM,
2476
- borderRadiusLG: radiusLG,
2477
- borderRadiusOuter: radiusOuter
2478
- };
2479
- };
2480
-
2481
- function genCommonMapToken(token) {
2482
- const {
2483
- motionUnit,
2484
- motionBase,
2485
- borderRadius,
2486
- lineWidth
2487
- } = token;
2488
- return Object.assign({
2489
- // motion
2490
- motionDurationFast: `${(motionBase + motionUnit).toFixed(1)}s`,
2491
- motionDurationMid: `${(motionBase + motionUnit * 2).toFixed(1)}s`,
2492
- motionDurationSlow: `${(motionBase + motionUnit * 3).toFixed(1)}s`,
2493
- // line
2494
- lineWidthBold: lineWidth + 1
2495
- }, genRadius(borderRadius));
2496
- }
2497
-
2498
- const genControlHeight = token => {
2499
- const {
2500
- controlHeight
2501
- } = token;
2502
- return {
2503
- controlHeightSM: controlHeight * 0.75,
2504
- controlHeightXS: controlHeight * 0.5,
2505
- controlHeightLG: controlHeight * 1.25
2506
- };
2507
- };
2508
-
2509
- function getLineHeight(fontSize) {
2510
- return (fontSize + 8) / fontSize;
2511
- }
2512
- // https://zhuanlan.zhihu.com/p/32746810
2513
- function getFontSizes(base) {
2514
- const fontSizes = Array.from({
2515
- length: 10
2516
- }).map((_, index) => {
2517
- const i = index - 1;
2518
- const baseSize = base * Math.pow(Math.E, i / 5);
2519
- const intSize = index > 1 ? Math.floor(baseSize) : Math.ceil(baseSize);
2520
- // Convert to even
2521
- return Math.floor(intSize / 2) * 2;
2522
- });
2523
- fontSizes[1] = base;
2524
- return fontSizes.map(size => ({
2525
- size,
2526
- lineHeight: getLineHeight(size)
2527
- }));
2528
- }
2529
-
2530
- const genFontMapToken = fontSize => {
2531
- const fontSizePairs = getFontSizes(fontSize);
2532
- const fontSizes = fontSizePairs.map(pair => pair.size);
2533
- const lineHeights = fontSizePairs.map(pair => pair.lineHeight);
2534
- const fontSizeMD = fontSizes[1];
2535
- const fontSizeSM = fontSizes[0];
2536
- const fontSizeLG = fontSizes[2];
2537
- const lineHeight = lineHeights[1];
2538
- const lineHeightSM = lineHeights[0];
2539
- const lineHeightLG = lineHeights[2];
2540
- return {
2541
- fontSizeSM,
2542
- fontSize: fontSizeMD,
2543
- fontSizeLG,
2544
- fontSizeXL: fontSizes[3],
2545
- fontSizeHeading1: fontSizes[6],
2546
- fontSizeHeading2: fontSizes[5],
2547
- fontSizeHeading3: fontSizes[4],
2548
- fontSizeHeading4: fontSizes[3],
2549
- fontSizeHeading5: fontSizes[2],
2550
- lineHeight,
2551
- lineHeightLG,
2552
- lineHeightSM,
2553
- fontHeight: Math.round(lineHeight * fontSizeMD),
2554
- fontHeightLG: Math.round(lineHeightLG * fontSizeLG),
2555
- fontHeightSM: Math.round(lineHeightSM * fontSizeSM),
2556
- lineHeightHeading1: lineHeights[6],
2557
- lineHeightHeading2: lineHeights[5],
2558
- lineHeightHeading3: lineHeights[4],
2559
- lineHeightHeading4: lineHeights[3],
2560
- lineHeightHeading5: lineHeights[2]
2561
- };
2562
- };
2563
-
2564
- function genSizeMapToken(token) {
2565
- const {
2566
- sizeUnit,
2567
- sizeStep
2568
- } = token;
2569
- return {
2570
- sizeXXL: sizeUnit * (sizeStep + 8),
2571
- // 48
2572
- sizeXL: sizeUnit * (sizeStep + 4),
2573
- // 32
2574
- sizeLG: sizeUnit * (sizeStep + 2),
2575
- // 24
2576
- sizeMD: sizeUnit * (sizeStep + 1),
2577
- // 20
2578
- sizeMS: sizeUnit * sizeStep,
2579
- // 16
2580
- size: sizeUnit * sizeStep,
2581
- // 16
2582
- sizeSM: sizeUnit * (sizeStep - 1),
2583
- // 12
2584
- sizeXS: sizeUnit * (sizeStep - 2),
2585
- // 8
2586
- sizeXXS: sizeUnit * (sizeStep - 3) // 4
2587
- };
2588
- }
2589
-
2590
- const getAlphaColor$1 = (baseColor, alpha) => new FastColor(baseColor).setA(alpha).toRgbString();
2591
- const getSolidColor = (baseColor, brightness) => {
2592
- const instance = new FastColor(baseColor);
2593
- return instance.darken(brightness).toHexString();
2594
- };
2595
-
2596
- const generateColorPalettes = baseColor => {
2597
- const colors = generate(baseColor);
2598
- return {
2599
- 1: colors[0],
2600
- 2: colors[1],
2601
- 3: colors[2],
2602
- 4: colors[3],
2603
- 5: colors[4],
2604
- 6: colors[5],
2605
- 7: colors[6],
2606
- 8: colors[4],
2607
- 9: colors[5],
2608
- 10: colors[6]
2609
- // 8: colors[7],
2610
- // 9: colors[8],
2611
- // 10: colors[9],
2612
- };
2613
- };
2614
- const generateNeutralColorPalettes = (bgBaseColor, textBaseColor) => {
2615
- const colorBgBase = bgBaseColor || '#fff';
2616
- const colorTextBase = textBaseColor || '#000';
2617
- return {
2618
- colorBgBase,
2619
- colorTextBase,
2620
- colorText: getAlphaColor$1(colorTextBase, 0.88),
2621
- colorTextSecondary: getAlphaColor$1(colorTextBase, 0.65),
2622
- colorTextTertiary: getAlphaColor$1(colorTextBase, 0.45),
2623
- colorTextQuaternary: getAlphaColor$1(colorTextBase, 0.25),
2624
- colorFill: getAlphaColor$1(colorTextBase, 0.15),
2625
- colorFillSecondary: getAlphaColor$1(colorTextBase, 0.06),
2626
- colorFillTertiary: getAlphaColor$1(colorTextBase, 0.04),
2627
- colorFillQuaternary: getAlphaColor$1(colorTextBase, 0.02),
2628
- colorBgSolid: getAlphaColor$1(colorTextBase, 1),
2629
- colorBgSolidHover: getAlphaColor$1(colorTextBase, 0.75),
2630
- colorBgSolidActive: getAlphaColor$1(colorTextBase, 0.95),
2631
- colorBgLayout: getSolidColor(colorBgBase, 4),
2632
- colorBgContainer: getSolidColor(colorBgBase, 0),
2633
- colorBgElevated: getSolidColor(colorBgBase, 0),
2634
- colorBgSpotlight: getAlphaColor$1(colorTextBase, 0.85),
2635
- colorBgBlur: 'transparent',
2636
- colorBorder: getSolidColor(colorBgBase, 15),
2637
- colorBorderSecondary: getSolidColor(colorBgBase, 6)
2638
- };
2639
- };
2640
-
2641
- function derivative(token) {
2642
- // pink is deprecated name of magenta, keep this for backwards compatibility
2643
- presetPrimaryColors.pink = presetPrimaryColors.magenta;
2644
- presetPalettes.pink = presetPalettes.magenta;
2645
- const colorPalettes = Object.keys(defaultPresetColors).map(colorKey => {
2646
- const colors = token[colorKey] === presetPrimaryColors[colorKey] ? presetPalettes[colorKey] : generate(token[colorKey]);
2647
- return Array.from({
2648
- length: 10
2649
- }, () => 1).reduce((prev, _, i) => {
2650
- prev[`${colorKey}-${i + 1}`] = colors[i];
2651
- prev[`${colorKey}${i + 1}`] = colors[i];
2652
- return prev;
2653
- }, {});
2654
- }).reduce((prev, cur) => {
2655
- prev = Object.assign(Object.assign({}, prev), cur);
2656
- return prev;
2657
- }, {});
2658
- return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, token), colorPalettes), genColorMapToken(token, {
2659
- generateColorPalettes,
2660
- generateNeutralColorPalettes
2661
- })), genFontMapToken(token.fontSize)), genSizeMapToken(token)), genControlHeight(token)), genCommonMapToken(token));
2662
- }
2663
-
2664
- const defaultTheme = createTheme(derivative);
2665
-
2666
- // ================================ Context =================================
2667
- // To ensure snapshot stable. We disable hashed in test env.
2668
- const defaultConfig = {
2669
- token: seedToken,
2670
- override: {
2671
- override: seedToken
2672
- },
2673
- hashed: true
2674
- };
2675
- const DesignTokenContext = /*#__PURE__*/React__default.createContext(defaultConfig);
2676
-
2677
- const defaultPrefixCls = 'ant';
2678
- const defaultIconPrefixCls = 'anticon';
2679
- const defaultGetPrefixCls = (suffixCls, customizePrefixCls) => {
2680
- if (customizePrefixCls) {
2681
- return customizePrefixCls;
2682
- }
2683
- return suffixCls ? `${defaultPrefixCls}-${suffixCls}` : defaultPrefixCls;
2684
- };
2685
- // zombieJ: 🚨 Do not pass `defaultRenderEmpty` here since it will cause circular dependency.
2686
- const ConfigContext = /*#__PURE__*/React.createContext({
2687
- // We provide a default function for Context without provider
2688
- getPrefixCls: defaultGetPrefixCls,
2689
- iconPrefixCls: defaultIconPrefixCls
2690
- });
2691
- const EMPTY_OBJECT = {};
2692
- /**
2693
- * Get ConfigProvider configured component props.
2694
- * This help to reduce bundle size for saving `?.` operator.
2695
- * Do not use as `useMemo` deps since we do not cache the object here.
2696
- *
2697
- * NOTE: not refactor this with `useMemo` since memo will cost another memory space,
2698
- * which will waste both compare calculation & memory.
2699
- */
2700
- function useComponentConfig(propName) {
2701
- const context = React.useContext(ConfigContext);
2702
- const {
2703
- getPrefixCls,
2704
- direction,
2705
- getPopupContainer
2706
- } = context;
2707
- const propValue = context[propName];
2708
- return Object.assign(Object.assign({
2709
- classNames: EMPTY_OBJECT,
2710
- styles: EMPTY_OBJECT
2711
- }, propValue), {
2712
- getPrefixCls,
2713
- direction,
2714
- getPopupContainer
2715
- });
2716
- }
2717
-
2718
- const dynamicStyleMark = `-ant-${Date.now()}-${Math.random()}`;
2719
- function getStyle(globalPrefixCls, theme) {
2720
- const variables = {};
2721
- const formatColor = (color, updater) => {
2722
- let clone = color.clone();
2723
- clone = (updater === null || updater === void 0 ? void 0 : updater(clone)) || clone;
2724
- return clone.toRgbString();
2725
- };
2726
- const fillColor = (colorVal, type) => {
2727
- const baseColor = new FastColor(colorVal);
2728
- const colorPalettes = generate(baseColor.toRgbString());
2729
- variables[`${type}-color`] = formatColor(baseColor);
2730
- variables[`${type}-color-disabled`] = colorPalettes[1];
2731
- variables[`${type}-color-hover`] = colorPalettes[4];
2732
- variables[`${type}-color-active`] = colorPalettes[6];
2733
- variables[`${type}-color-outline`] = baseColor.clone().setA(0.2).toRgbString();
2734
- variables[`${type}-color-deprecated-bg`] = colorPalettes[0];
2735
- variables[`${type}-color-deprecated-border`] = colorPalettes[2];
2736
- };
2737
- // ================ Primary Color ================
2738
- if (theme.primaryColor) {
2739
- fillColor(theme.primaryColor, 'primary');
2740
- const primaryColor = new FastColor(theme.primaryColor);
2741
- const primaryColors = generate(primaryColor.toRgbString());
2742
- // Legacy - We should use semantic naming standard
2743
- primaryColors.forEach((color, index) => {
2744
- variables[`primary-${index + 1}`] = color;
2745
- });
2746
- // Deprecated
2747
- variables['primary-color-deprecated-l-35'] = formatColor(primaryColor, c => c.lighten(35));
2748
- variables['primary-color-deprecated-l-20'] = formatColor(primaryColor, c => c.lighten(20));
2749
- variables['primary-color-deprecated-t-20'] = formatColor(primaryColor, c => c.tint(20));
2750
- variables['primary-color-deprecated-t-50'] = formatColor(primaryColor, c => c.tint(50));
2751
- variables['primary-color-deprecated-f-12'] = formatColor(primaryColor, c => c.setA(c.a * 0.12));
2752
- const primaryActiveColor = new FastColor(primaryColors[0]);
2753
- variables['primary-color-active-deprecated-f-30'] = formatColor(primaryActiveColor, c => c.setA(c.a * 0.3));
2754
- variables['primary-color-active-deprecated-d-02'] = formatColor(primaryActiveColor, c => c.darken(2));
2755
- }
2756
- // ================ Success Color ================
2757
- if (theme.successColor) {
2758
- fillColor(theme.successColor, 'success');
2759
- }
2760
- // ================ Warning Color ================
2761
- if (theme.warningColor) {
2762
- fillColor(theme.warningColor, 'warning');
2763
- }
2764
- // ================= Error Color =================
2765
- if (theme.errorColor) {
2766
- fillColor(theme.errorColor, 'error');
2767
- }
2768
- // ================= Info Color ==================
2769
- if (theme.infoColor) {
2770
- fillColor(theme.infoColor, 'info');
2771
- }
2772
- // Convert to css variables
2773
- const cssList = Object.keys(variables).map(key => `--${globalPrefixCls}-${key}: ${variables[key]};`);
2774
- return `
2775
- :root {
2776
- ${cssList.join('\n')}
2777
- }
2778
- `.trim();
2779
- }
2780
- function registerTheme(globalPrefixCls, theme) {
2781
- const style = getStyle(globalPrefixCls, theme);
2782
- if (canUseDom()) {
2783
- updateCSS(style, `${dynamicStyleMark}-dynamic-theme`);
2784
- } else {
2785
- process.env.NODE_ENV !== "production" ? warning(false, 'ConfigProvider', 'SSR do not support dynamic theme with css variables.') : void 0;
2786
- }
2787
- }
2788
-
2789
- const DisabledContext = /*#__PURE__*/React.createContext(false);
2790
- const DisabledContextProvider = ({
2791
- children,
2792
- disabled
2793
- }) => {
2794
- const originDisabled = React.useContext(DisabledContext);
2795
- return /*#__PURE__*/React.createElement(DisabledContext.Provider, {
2796
- value: disabled !== null && disabled !== void 0 ? disabled : originDisabled
2797
- }, children);
2798
- };
2799
-
2800
- const SizeContext = /*#__PURE__*/React.createContext(undefined);
2801
- const SizeContextProvider = ({
2802
- children,
2803
- size
2804
- }) => {
2805
- const originSize = React.useContext(SizeContext);
2806
- return /*#__PURE__*/React.createElement(SizeContext.Provider, {
2807
- value: size || originSize
2808
- }, children);
2809
- };
2810
-
2811
- function useConfig() {
2812
- const componentDisabled = useContext(DisabledContext);
2813
- const componentSize = useContext(SizeContext);
2814
- return {
2815
- componentDisabled,
2816
- componentSize
2817
- };
2818
- }
2819
-
2820
- var AbstractCalculator = /*#__PURE__*/_createClass(function AbstractCalculator() {
2821
- _classCallCheck(this, AbstractCalculator);
2822
- });
2823
-
2824
- var CALC_UNIT = 'CALC_UNIT';
2825
- var regexp = new RegExp(CALC_UNIT, 'g');
2826
- function unit(value) {
2827
- if (typeof value === 'number') {
2828
- return "".concat(value).concat(CALC_UNIT);
2829
- }
2830
- return value;
2831
- }
2832
- var CSSCalculator = /*#__PURE__*/function (_AbstractCalculator) {
2833
- _inherits(CSSCalculator, _AbstractCalculator);
2834
- var _super = _createSuper(CSSCalculator);
2835
- function CSSCalculator(num, unitlessCssVar) {
2836
- var _this;
2837
- _classCallCheck(this, CSSCalculator);
2838
- _this = _super.call(this);
2839
- _defineProperty(_assertThisInitialized(_this), "result", '');
2840
- _defineProperty(_assertThisInitialized(_this), "unitlessCssVar", void 0);
2841
- _defineProperty(_assertThisInitialized(_this), "lowPriority", void 0);
2842
- var numType = _typeof(num);
2843
- _this.unitlessCssVar = unitlessCssVar;
2844
- if (num instanceof CSSCalculator) {
2845
- _this.result = "(".concat(num.result, ")");
2846
- } else if (numType === 'number') {
2847
- _this.result = unit(num);
2848
- } else if (numType === 'string') {
2849
- _this.result = num;
2850
- }
2851
- return _this;
2852
- }
2853
- _createClass(CSSCalculator, [{
2854
- key: "add",
2855
- value: function add(num) {
2856
- if (num instanceof CSSCalculator) {
2857
- this.result = "".concat(this.result, " + ").concat(num.getResult());
2858
- } else if (typeof num === 'number' || typeof num === 'string') {
2859
- this.result = "".concat(this.result, " + ").concat(unit(num));
2860
- }
2861
- this.lowPriority = true;
2862
- return this;
2863
- }
2864
- }, {
2865
- key: "sub",
2866
- value: function sub(num) {
2867
- if (num instanceof CSSCalculator) {
2868
- this.result = "".concat(this.result, " - ").concat(num.getResult());
2869
- } else if (typeof num === 'number' || typeof num === 'string') {
2870
- this.result = "".concat(this.result, " - ").concat(unit(num));
2871
- }
2872
- this.lowPriority = true;
2873
- return this;
2874
- }
2875
- }, {
2876
- key: "mul",
2877
- value: function mul(num) {
2878
- if (this.lowPriority) {
2879
- this.result = "(".concat(this.result, ")");
2880
- }
2881
- if (num instanceof CSSCalculator) {
2882
- this.result = "".concat(this.result, " * ").concat(num.getResult(true));
2883
- } else if (typeof num === 'number' || typeof num === 'string') {
2884
- this.result = "".concat(this.result, " * ").concat(num);
2885
- }
2886
- this.lowPriority = false;
2887
- return this;
2888
- }
2889
- }, {
2890
- key: "div",
2891
- value: function div(num) {
2892
- if (this.lowPriority) {
2893
- this.result = "(".concat(this.result, ")");
2894
- }
2895
- if (num instanceof CSSCalculator) {
2896
- this.result = "".concat(this.result, " / ").concat(num.getResult(true));
2897
- } else if (typeof num === 'number' || typeof num === 'string') {
2898
- this.result = "".concat(this.result, " / ").concat(num);
2899
- }
2900
- this.lowPriority = false;
2901
- return this;
2902
- }
2903
- }, {
2904
- key: "getResult",
2905
- value: function getResult(force) {
2906
- return this.lowPriority || force ? "(".concat(this.result, ")") : this.result;
2907
- }
2908
- }, {
2909
- key: "equal",
2910
- value: function equal(options) {
2911
- var _this2 = this;
2912
- var _ref = options || {},
2913
- cssUnit = _ref.unit;
2914
- var mergedUnit = true;
2915
- if (typeof cssUnit === 'boolean') {
2916
- mergedUnit = cssUnit;
2917
- } else if (Array.from(this.unitlessCssVar).some(function (cssVar) {
2918
- return _this2.result.includes(cssVar);
2919
- })) {
2920
- mergedUnit = false;
2921
- }
2922
- this.result = this.result.replace(regexp, mergedUnit ? 'px' : '');
2923
- if (typeof this.lowPriority !== 'undefined') {
2924
- return "calc(".concat(this.result, ")");
2925
- }
2926
- return this.result;
2927
- }
2928
- }]);
2929
- return CSSCalculator;
2930
- }(AbstractCalculator);
2931
-
2932
- var NumCalculator = /*#__PURE__*/function (_AbstractCalculator) {
2933
- _inherits(NumCalculator, _AbstractCalculator);
2934
- var _super = _createSuper(NumCalculator);
2935
- function NumCalculator(num) {
2936
- var _this;
2937
- _classCallCheck(this, NumCalculator);
2938
- _this = _super.call(this);
2939
- _defineProperty(_assertThisInitialized(_this), "result", 0);
2940
- if (num instanceof NumCalculator) {
2941
- _this.result = num.result;
2942
- } else if (typeof num === 'number') {
2943
- _this.result = num;
2944
- }
2945
- return _this;
2946
- }
2947
- _createClass(NumCalculator, [{
2948
- key: "add",
2949
- value: function add(num) {
2950
- if (num instanceof NumCalculator) {
2951
- this.result += num.result;
2952
- } else if (typeof num === 'number') {
2953
- this.result += num;
2954
- }
2955
- return this;
2956
- }
2957
- }, {
2958
- key: "sub",
2959
- value: function sub(num) {
2960
- if (num instanceof NumCalculator) {
2961
- this.result -= num.result;
2962
- } else if (typeof num === 'number') {
2963
- this.result -= num;
2964
- }
2965
- return this;
2966
- }
2967
- }, {
2968
- key: "mul",
2969
- value: function mul(num) {
2970
- if (num instanceof NumCalculator) {
2971
- this.result *= num.result;
2972
- } else if (typeof num === 'number') {
2973
- this.result *= num;
2974
- }
2975
- return this;
2976
- }
2977
- }, {
2978
- key: "div",
2979
- value: function div(num) {
2980
- if (num instanceof NumCalculator) {
2981
- this.result /= num.result;
2982
- } else if (typeof num === 'number') {
2983
- this.result /= num;
2984
- }
2985
- return this;
2986
- }
2987
- }, {
2988
- key: "equal",
2989
- value: function equal() {
2990
- return this.result;
2991
- }
2992
- }]);
2993
- return NumCalculator;
2994
- }(AbstractCalculator);
2995
-
2996
- var genCalc = function genCalc(type, unitlessCssVar) {
2997
- var Calculator = type === 'css' ? CSSCalculator : NumCalculator;
2998
- return function (num) {
2999
- return new Calculator(num, unitlessCssVar);
3000
- };
3001
- };
3002
-
3003
- var getCompVarPrefix = function getCompVarPrefix(component, prefix) {
3004
- return "".concat([prefix, component.replace(/([A-Z]+)([A-Z][a-z]+)/g, '$1-$2').replace(/([a-z])([A-Z])/g, '$1-$2')].filter(Boolean).join('-'));
3005
- };
3006
-
3007
- function getComponentToken(component, token, defaultToken, options) {
3008
- var customToken = _objectSpread2({}, token[component]);
3009
- if (options !== null && options !== void 0 && options.deprecatedTokens) {
3010
- var deprecatedTokens = options.deprecatedTokens;
3011
- deprecatedTokens.forEach(function (_ref) {
3012
- var _ref2 = _slicedToArray(_ref, 2),
3013
- oldTokenKey = _ref2[0],
3014
- newTokenKey = _ref2[1];
3015
- if (process.env.NODE_ENV !== 'production') {
3016
- warningOnce(!(customToken !== null && customToken !== void 0 && customToken[oldTokenKey]), "Component Token `".concat(String(oldTokenKey), "` of ").concat(String(component), " is deprecated. Please use `").concat(String(newTokenKey), "` instead."));
3017
- }
3018
-
3019
- // Should wrap with `if` clause, or there will be `undefined` in object.
3020
- if (customToken !== null && customToken !== void 0 && customToken[oldTokenKey] || customToken !== null && customToken !== void 0 && customToken[newTokenKey]) {
3021
- var _customToken$newToken;
3022
- (_customToken$newToken = customToken[newTokenKey]) !== null && _customToken$newToken !== void 0 ? _customToken$newToken : customToken[newTokenKey] = customToken === null || customToken === void 0 ? void 0 : customToken[oldTokenKey];
3023
- }
3024
- });
3025
- }
3026
- var mergedToken = _objectSpread2(_objectSpread2({}, defaultToken), customToken);
3027
-
3028
- // Remove same value as global token to minimize size
3029
- Object.keys(mergedToken).forEach(function (key) {
3030
- if (mergedToken[key] === token[key]) {
3031
- delete mergedToken[key];
3032
- }
3033
- });
3034
- return mergedToken;
3035
- }
3036
-
3037
- var enableStatistic = process.env.NODE_ENV !== 'production' || typeof CSSINJS_STATISTIC !== 'undefined';
3038
- var recording = true;
3039
-
3040
- /**
3041
- * This function will do as `Object.assign` in production. But will use Object.defineProperty:get to
3042
- * pass all value access in development. To support statistic field usage with alias token.
3043
- */
3044
- function merge() {
3045
- for (var _len = arguments.length, objs = new Array(_len), _key = 0; _key < _len; _key++) {
3046
- objs[_key] = arguments[_key];
3047
- }
3048
- /* istanbul ignore next */
3049
- if (!enableStatistic) {
3050
- return Object.assign.apply(Object, [{}].concat(objs));
3051
- }
3052
- recording = false;
3053
- var ret = {};
3054
- objs.forEach(function (obj) {
3055
- if (_typeof(obj) !== 'object') {
3056
- return;
3057
- }
3058
- var keys = Object.keys(obj);
3059
- keys.forEach(function (key) {
3060
- Object.defineProperty(ret, key, {
3061
- configurable: true,
3062
- enumerable: true,
3063
- get: function get() {
3064
- return obj[key];
3065
- }
3066
- });
3067
- });
3068
- });
3069
- recording = true;
3070
- return ret;
3071
- }
3072
-
3073
- /** @internal Internal Usage. Not use in your production. */
3074
- var statistic = {};
3075
-
3076
- /* istanbul ignore next */
3077
- function noop() {}
3078
-
3079
- /** Statistic token usage case. Should use `merge` function if you do not want spread record. */
3080
- var statisticToken = function statisticToken(token) {
3081
- var tokenKeys;
3082
- var proxy = token;
3083
- var flush = noop;
3084
- if (enableStatistic && typeof Proxy !== 'undefined') {
3085
- tokenKeys = new Set();
3086
- proxy = new Proxy(token, {
3087
- get: function get(obj, prop) {
3088
- if (recording) {
3089
- var _tokenKeys;
3090
- (_tokenKeys = tokenKeys) === null || _tokenKeys === void 0 || _tokenKeys.add(prop);
3091
- }
3092
- return obj[prop];
3093
- }
3094
- });
3095
- flush = function flush(componentName, componentToken) {
3096
- var _statistic$componentN;
3097
- statistic[componentName] = {
3098
- global: Array.from(tokenKeys),
3099
- component: _objectSpread2(_objectSpread2({}, (_statistic$componentN = statistic[componentName]) === null || _statistic$componentN === void 0 ? void 0 : _statistic$componentN.component), componentToken)
3100
- };
3101
- };
3102
- }
3103
- return {
3104
- token: proxy,
3105
- keys: tokenKeys,
3106
- flush: flush
3107
- };
3108
- };
3109
-
3110
- function getDefaultComponentToken(component, token, getDefaultToken) {
3111
- if (typeof getDefaultToken === 'function') {
3112
- var _token$component;
3113
- return getDefaultToken(merge(token, (_token$component = token[component]) !== null && _token$component !== void 0 ? _token$component : {}));
3114
- }
3115
- return getDefaultToken !== null && getDefaultToken !== void 0 ? getDefaultToken : {};
3116
- }
3117
-
3118
- function genMaxMin(type) {
3119
- if (type === 'js') {
3120
- return {
3121
- max: Math.max,
3122
- min: Math.min
3123
- };
3124
- }
3125
- return {
3126
- max: function max() {
3127
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
3128
- args[_key] = arguments[_key];
3129
- }
3130
- return "max(".concat(args.map(function (value) {
3131
- return unit$1(value);
3132
- }).join(','), ")");
3133
- },
3134
- min: function min() {
3135
- for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
3136
- args[_key2] = arguments[_key2];
3137
- }
3138
- return "min(".concat(args.map(function (value) {
3139
- return unit$1(value);
3140
- }).join(','), ")");
3141
- }
3142
- };
3143
- }
3144
-
3145
- var BEAT_LIMIT = 1000 * 60 * 10;
3146
-
3147
- /**
3148
- * A helper class to map keys to values.
3149
- * It supports both primitive keys and object keys.
3150
- */
3151
- var ArrayKeyMap = /*#__PURE__*/function () {
3152
- function ArrayKeyMap() {
3153
- _classCallCheck(this, ArrayKeyMap);
3154
- _defineProperty(this, "map", new Map());
3155
- // Use WeakMap to avoid memory leak
3156
- _defineProperty(this, "objectIDMap", new WeakMap());
3157
- _defineProperty(this, "nextID", 0);
3158
- _defineProperty(this, "lastAccessBeat", new Map());
3159
- // We will clean up the cache when reach the limit
3160
- _defineProperty(this, "accessBeat", 0);
3161
- }
3162
- _createClass(ArrayKeyMap, [{
3163
- key: "set",
3164
- value: function set(keys, value) {
3165
- // New set will trigger clear
3166
- this.clear();
3167
-
3168
- // Set logic
3169
- var compositeKey = this.getCompositeKey(keys);
3170
- this.map.set(compositeKey, value);
3171
- this.lastAccessBeat.set(compositeKey, Date.now());
3172
- }
3173
- }, {
3174
- key: "get",
3175
- value: function get(keys) {
3176
- var compositeKey = this.getCompositeKey(keys);
3177
- var cache = this.map.get(compositeKey);
3178
- this.lastAccessBeat.set(compositeKey, Date.now());
3179
- this.accessBeat += 1;
3180
- return cache;
3181
- }
3182
- }, {
3183
- key: "getCompositeKey",
3184
- value: function getCompositeKey(keys) {
3185
- var _this = this;
3186
- var ids = keys.map(function (key) {
3187
- if (key && _typeof(key) === 'object') {
3188
- return "obj_".concat(_this.getObjectID(key));
3189
- }
3190
- return "".concat(_typeof(key), "_").concat(key);
3191
- });
3192
- return ids.join('|');
3193
- }
3194
- }, {
3195
- key: "getObjectID",
3196
- value: function getObjectID(obj) {
3197
- if (this.objectIDMap.has(obj)) {
3198
- return this.objectIDMap.get(obj);
3199
- }
3200
- var id = this.nextID;
3201
- this.objectIDMap.set(obj, id);
3202
- this.nextID += 1;
3203
- return id;
3204
- }
3205
- }, {
3206
- key: "clear",
3207
- value: function clear() {
3208
- var _this2 = this;
3209
- if (this.accessBeat > 10000) {
3210
- var now = Date.now();
3211
- this.lastAccessBeat.forEach(function (beat, key) {
3212
- if (now - beat > BEAT_LIMIT) {
3213
- _this2.map.delete(key);
3214
- _this2.lastAccessBeat.delete(key);
3215
- }
3216
- });
3217
- this.accessBeat = 0;
3218
- }
3219
- }
3220
- }]);
3221
- return ArrayKeyMap;
3222
- }();
3223
- var uniqueMap = new ArrayKeyMap();
3224
-
3225
- /**
3226
- * Like `useMemo`, but this hook result will be shared across all instances.
3227
- */
3228
- function useUniqueMemo(memoFn, deps) {
3229
- return React__default.useMemo(function () {
3230
- var cachedValue = uniqueMap.get(deps);
3231
- if (cachedValue) {
3232
- return cachedValue;
3233
- }
3234
- var newValue = memoFn();
3235
- uniqueMap.set(deps, newValue);
3236
- return newValue;
3237
- }, deps);
3238
- }
3239
-
3240
- /**
3241
- * Provide a default hook since not everyone needs to config this.
3242
- */
3243
- var useDefaultCSP = function useDefaultCSP() {
3244
- return {};
3245
- };
3246
-
3247
- function genStyleUtils(config) {
3248
- // Dependency inversion for preparing basic config.
3249
- var _config$useCSP = config.useCSP,
3250
- useCSP = _config$useCSP === void 0 ? useDefaultCSP : _config$useCSP,
3251
- useToken = config.useToken,
3252
- usePrefix = config.usePrefix,
3253
- getResetStyles = config.getResetStyles,
3254
- getCommonStyle = config.getCommonStyle,
3255
- getCompUnitless = config.getCompUnitless;
3256
- function genStyleHooks(component, styleFn, getDefaultToken, options) {
3257
- var componentName = Array.isArray(component) ? component[0] : component;
3258
- function prefixToken(key) {
3259
- return "".concat(String(componentName)).concat(key.slice(0, 1).toUpperCase()).concat(key.slice(1));
3260
- }
3261
-
3262
- // Fill unitless
3263
- var originUnitless = (options === null || options === void 0 ? void 0 : options.unitless) || {};
3264
- var originCompUnitless = typeof getCompUnitless === 'function' ? getCompUnitless(component) : {};
3265
- var compUnitless = _objectSpread2(_objectSpread2({}, originCompUnitless), {}, _defineProperty({}, prefixToken('zIndexPopup'), true));
3266
- Object.keys(originUnitless).forEach(function (key) {
3267
- compUnitless[prefixToken(key)] = originUnitless[key];
3268
- });
3269
-
3270
- // Options
3271
- var mergedOptions = _objectSpread2(_objectSpread2({}, options), {}, {
3272
- unitless: compUnitless,
3273
- prefixToken: prefixToken
3274
- });
3275
-
3276
- // Hooks
3277
- var useStyle = genComponentStyleHook(component, styleFn, getDefaultToken, mergedOptions);
3278
- var useCSSVar = genCSSVarRegister(componentName, getDefaultToken, mergedOptions);
3279
- return function (prefixCls) {
3280
- var rootCls = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : prefixCls;
3281
- var _useStyle = useStyle(prefixCls, rootCls),
3282
- _useStyle2 = _slicedToArray(_useStyle, 2),
3283
- hashId = _useStyle2[1];
3284
- var _useCSSVar = useCSSVar(rootCls),
3285
- _useCSSVar2 = _slicedToArray(_useCSSVar, 2),
3286
- wrapCSSVar = _useCSSVar2[0],
3287
- cssVarCls = _useCSSVar2[1];
3288
- return [wrapCSSVar, hashId, cssVarCls];
3289
- };
3290
- }
3291
- function genCSSVarRegister(component, getDefaultToken, options) {
3292
- var compUnitless = options.unitless,
3293
- _options$injectStyle = options.injectStyle,
3294
- injectStyle = _options$injectStyle === void 0 ? true : _options$injectStyle,
3295
- prefixToken = options.prefixToken,
3296
- ignore = options.ignore;
3297
- var CSSVarRegister = function CSSVarRegister(_ref) {
3298
- var rootCls = _ref.rootCls,
3299
- _ref$cssVar = _ref.cssVar,
3300
- cssVar = _ref$cssVar === void 0 ? {} : _ref$cssVar;
3301
- var _useToken = useToken(),
3302
- realToken = _useToken.realToken;
3303
- useCSSVarRegister({
3304
- path: [component],
3305
- prefix: cssVar.prefix,
3306
- key: cssVar.key,
3307
- unitless: compUnitless,
3308
- ignore: ignore,
3309
- token: realToken,
3310
- scope: rootCls
3311
- }, function () {
3312
- var defaultToken = getDefaultComponentToken(component, realToken, getDefaultToken);
3313
- var componentToken = getComponentToken(component, realToken, defaultToken, {
3314
- deprecatedTokens: options === null || options === void 0 ? void 0 : options.deprecatedTokens
3315
- });
3316
- Object.keys(defaultToken).forEach(function (key) {
3317
- componentToken[prefixToken(key)] = componentToken[key];
3318
- delete componentToken[key];
3319
- });
3320
- return componentToken;
3321
- });
3322
- return null;
3323
- };
3324
- var useCSSVar = function useCSSVar(rootCls) {
3325
- var _useToken2 = useToken(),
3326
- cssVar = _useToken2.cssVar;
3327
- return [function (node) {
3328
- return injectStyle && cssVar ? /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(CSSVarRegister, {
3329
- rootCls: rootCls,
3330
- cssVar: cssVar,
3331
- component: component
3332
- }), node) : node;
3333
- }, cssVar === null || cssVar === void 0 ? void 0 : cssVar.key];
3334
- };
3335
- return useCSSVar;
3336
- }
3337
- function genComponentStyleHook(componentName, styleFn, getDefaultToken) {
3338
- var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
3339
- var cells = Array.isArray(componentName) ? componentName : [componentName, componentName];
3340
- var _cells = _slicedToArray(cells, 1),
3341
- component = _cells[0];
3342
- var concatComponent = cells.join('-');
3343
- var mergedLayer = config.layer || {
3344
- name: 'antd'
3345
- };
3346
-
3347
- // Return new style hook
3348
- return function (prefixCls) {
3349
- var rootCls = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : prefixCls;
3350
- var _useToken3 = useToken(),
3351
- theme = _useToken3.theme,
3352
- realToken = _useToken3.realToken,
3353
- hashId = _useToken3.hashId,
3354
- token = _useToken3.token,
3355
- cssVar = _useToken3.cssVar;
3356
- var _usePrefix = usePrefix(),
3357
- rootPrefixCls = _usePrefix.rootPrefixCls,
3358
- iconPrefixCls = _usePrefix.iconPrefixCls;
3359
- var csp = useCSP();
3360
- var type = cssVar ? 'css' : 'js';
3361
-
3362
- // Use unique memo to share the result across all instances
3363
- var calc = useUniqueMemo(function () {
3364
- var unitlessCssVar = new Set();
3365
- if (cssVar) {
3366
- Object.keys(options.unitless || {}).forEach(function (key) {
3367
- // Some component proxy the AliasToken (e.g. Image) and some not (e.g. Modal)
3368
- // We should both pass in `unitlessCssVar` to make sure the CSSVar can be unitless.
3369
- unitlessCssVar.add(token2CSSVar(key, cssVar.prefix));
3370
- unitlessCssVar.add(token2CSSVar(key, getCompVarPrefix(component, cssVar.prefix)));
3371
- });
3372
- }
3373
- return genCalc(type, unitlessCssVar);
3374
- }, [type, component, cssVar === null || cssVar === void 0 ? void 0 : cssVar.prefix]);
3375
- var _genMaxMin = genMaxMin(type),
3376
- max = _genMaxMin.max,
3377
- min = _genMaxMin.min;
3378
-
3379
- // Shared config
3380
- var sharedConfig = {
3381
- theme: theme,
3382
- token: token,
3383
- hashId: hashId,
3384
- nonce: function nonce() {
3385
- return csp.nonce;
3386
- },
3387
- clientOnly: options.clientOnly,
3388
- layer: mergedLayer,
3389
- // antd is always at top of styles
3390
- order: options.order || -999
3391
- };
3392
-
3393
- // This if statement is safe, as it will only be used if the generator has the function. It's not dynamic.
3394
- if (typeof getResetStyles === 'function') {
3395
- // Generate style for all need reset tags.
3396
- useStyleRegister(_objectSpread2(_objectSpread2({}, sharedConfig), {}, {
3397
- clientOnly: false,
3398
- path: ['Shared', rootPrefixCls]
3399
- }), function () {
3400
- return getResetStyles(token, {
3401
- prefix: {
3402
- rootPrefixCls: rootPrefixCls,
3403
- iconPrefixCls: iconPrefixCls
3404
- },
3405
- csp: csp
3406
- });
3407
- });
3408
- }
3409
- var wrapSSR = useStyleRegister(_objectSpread2(_objectSpread2({}, sharedConfig), {}, {
3410
- path: [concatComponent, prefixCls, iconPrefixCls]
3411
- }), function () {
3412
- if (options.injectStyle === false) {
3413
- return [];
3414
- }
3415
- var _statisticToken = statisticToken(token),
3416
- proxyToken = _statisticToken.token,
3417
- flush = _statisticToken.flush;
3418
- var defaultComponentToken = getDefaultComponentToken(component, realToken, getDefaultToken);
3419
- var componentCls = ".".concat(prefixCls);
3420
- var componentToken = getComponentToken(component, realToken, defaultComponentToken, {
3421
- deprecatedTokens: options.deprecatedTokens
3422
- });
3423
- if (cssVar && defaultComponentToken && _typeof(defaultComponentToken) === 'object') {
3424
- Object.keys(defaultComponentToken).forEach(function (key) {
3425
- defaultComponentToken[key] = "var(".concat(token2CSSVar(key, getCompVarPrefix(component, cssVar.prefix)), ")");
3426
- });
3427
- }
3428
- var mergedToken = merge(proxyToken, {
3429
- componentCls: componentCls,
3430
- prefixCls: prefixCls,
3431
- iconCls: ".".concat(iconPrefixCls),
3432
- antCls: ".".concat(rootPrefixCls),
3433
- calc: calc,
3434
- // @ts-ignore
3435
- max: max,
3436
- // @ts-ignore
3437
- min: min
3438
- }, cssVar ? defaultComponentToken : componentToken);
3439
- var styleInterpolation = styleFn(mergedToken, {
3440
- hashId: hashId,
3441
- prefixCls: prefixCls,
3442
- rootPrefixCls: rootPrefixCls,
3443
- iconPrefixCls: iconPrefixCls
3444
- });
3445
- flush(component, componentToken);
3446
- var commonStyle = typeof getCommonStyle === 'function' ? getCommonStyle(mergedToken, prefixCls, rootCls, options.resetFont) : null;
3447
- return [options.resetStyle === false ? null : commonStyle, styleInterpolation];
3448
- });
3449
- return [wrapSSR, hashId];
3450
- };
3451
- }
3452
- function genSubStyleComponent(componentName, styleFn, getDefaultToken) {
3453
- var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
3454
- var useStyle = genComponentStyleHook(componentName, styleFn, getDefaultToken, _objectSpread2({
3455
- resetStyle: false,
3456
- // Sub Style should default after root one
3457
- order: -998
3458
- }, options));
3459
- var StyledComponent = function StyledComponent(_ref2) {
3460
- var prefixCls = _ref2.prefixCls,
3461
- _ref2$rootCls = _ref2.rootCls,
3462
- rootCls = _ref2$rootCls === void 0 ? prefixCls : _ref2$rootCls;
3463
- useStyle(prefixCls, rootCls);
3464
- return null;
3465
- };
3466
- if (process.env.NODE_ENV !== 'production') {
3467
- StyledComponent.displayName = "SubStyle_".concat(String(Array.isArray(componentName) ? componentName.join('.') : componentName));
3468
- }
3469
- return StyledComponent;
3470
- }
3471
- return {
3472
- genStyleHooks: genStyleHooks,
3473
- genSubStyleComponent: genSubStyleComponent,
3474
- genComponentStyleHook: genComponentStyleHook
3475
- };
3476
- }
3477
-
3478
- const version = '5.27.1';
3479
-
3480
- function isStableColor(color) {
3481
- return color >= 0 && color <= 255;
3482
- }
3483
- function getAlphaColor(frontColor, backgroundColor) {
3484
- const {
3485
- r: fR,
3486
- g: fG,
3487
- b: fB,
3488
- a: originAlpha
3489
- } = new FastColor(frontColor).toRgb();
3490
- if (originAlpha < 1) {
3491
- return frontColor;
3492
- }
3493
- const {
3494
- r: bR,
3495
- g: bG,
3496
- b: bB
3497
- } = new FastColor(backgroundColor).toRgb();
3498
- for (let fA = 0.01; fA <= 1; fA += 0.01) {
3499
- const r = Math.round((fR - bR * (1 - fA)) / fA);
3500
- const g = Math.round((fG - bG * (1 - fA)) / fA);
3501
- const b = Math.round((fB - bB * (1 - fA)) / fA);
3502
- if (isStableColor(r) && isStableColor(g) && isStableColor(b)) {
3503
- return new FastColor({
3504
- r,
3505
- g,
3506
- b,
3507
- a: Math.round(fA * 100) / 100
3508
- }).toRgbString();
3509
- }
3510
- }
3511
- // fallback
3512
- /* istanbul ignore next */
3513
- return new FastColor({
3514
- r: fR,
3515
- g: fG,
3516
- b: fB,
3517
- a: 1
3518
- }).toRgbString();
3519
- }
3520
-
3521
- var __rest$4 = undefined && undefined.__rest || function (s, e) {
3522
- var t = {};
3523
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
3524
- if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
3525
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
3526
- }
3527
- return t;
3528
- };
3529
- /**
3530
- * Seed (designer) > Derivative (designer) > Alias (developer).
3531
- *
3532
- * Merge seed & derivative & override token and generate alias token for developer.
3533
- */
3534
- function formatToken(derivativeToken) {
3535
- const {
3536
- override
3537
- } = derivativeToken,
3538
- restToken = __rest$4(derivativeToken, ["override"]);
3539
- const overrideTokens = Object.assign({}, override);
3540
- Object.keys(seedToken).forEach(token => {
3541
- delete overrideTokens[token];
3542
- });
3543
- const mergedToken = Object.assign(Object.assign({}, restToken), overrideTokens);
3544
- const screenXS = 480;
3545
- const screenSM = 576;
3546
- const screenMD = 768;
3547
- const screenLG = 992;
3548
- const screenXL = 1200;
3549
- const screenXXL = 1600;
3550
- // Motion
3551
- if (mergedToken.motion === false) {
3552
- const fastDuration = '0s';
3553
- mergedToken.motionDurationFast = fastDuration;
3554
- mergedToken.motionDurationMid = fastDuration;
3555
- mergedToken.motionDurationSlow = fastDuration;
3556
- }
3557
- // Generate alias token
3558
- const aliasToken = Object.assign(Object.assign(Object.assign({}, mergedToken), {
3559
- // ============== Background ============== //
3560
- colorFillContent: mergedToken.colorFillSecondary,
3561
- colorFillContentHover: mergedToken.colorFill,
3562
- colorFillAlter: mergedToken.colorFillQuaternary,
3563
- colorBgContainerDisabled: mergedToken.colorFillTertiary,
3564
- // ============== Split ============== //
3565
- colorBorderBg: mergedToken.colorBgContainer,
3566
- colorSplit: getAlphaColor(mergedToken.colorBorderSecondary, mergedToken.colorBgContainer),
3567
- // ============== Text ============== //
3568
- colorTextPlaceholder: mergedToken.colorTextQuaternary,
3569
- colorTextDisabled: mergedToken.colorTextQuaternary,
3570
- colorTextHeading: mergedToken.colorText,
3571
- colorTextLabel: mergedToken.colorTextSecondary,
3572
- colorTextDescription: mergedToken.colorTextTertiary,
3573
- colorTextLightSolid: mergedToken.colorWhite,
3574
- colorHighlight: mergedToken.colorError,
3575
- colorBgTextHover: mergedToken.colorFillSecondary,
3576
- colorBgTextActive: mergedToken.colorFill,
3577
- colorIcon: mergedToken.colorTextTertiary,
3578
- colorIconHover: mergedToken.colorText,
3579
- colorErrorOutline: getAlphaColor(mergedToken.colorErrorBg, mergedToken.colorBgContainer),
3580
- colorWarningOutline: getAlphaColor(mergedToken.colorWarningBg, mergedToken.colorBgContainer),
3581
- // Font
3582
- fontSizeIcon: mergedToken.fontSizeSM,
3583
- // Line
3584
- lineWidthFocus: mergedToken.lineWidth * 3,
3585
- // Control
3586
- lineWidth: mergedToken.lineWidth,
3587
- controlOutlineWidth: mergedToken.lineWidth * 2,
3588
- // Checkbox size and expand icon size
3589
- controlInteractiveSize: mergedToken.controlHeight / 2,
3590
- controlItemBgHover: mergedToken.colorFillTertiary,
3591
- controlItemBgActive: mergedToken.colorPrimaryBg,
3592
- controlItemBgActiveHover: mergedToken.colorPrimaryBgHover,
3593
- controlItemBgActiveDisabled: mergedToken.colorFill,
3594
- controlTmpOutline: mergedToken.colorFillQuaternary,
3595
- controlOutline: getAlphaColor(mergedToken.colorPrimaryBg, mergedToken.colorBgContainer),
3596
- lineType: mergedToken.lineType,
3597
- borderRadius: mergedToken.borderRadius,
3598
- borderRadiusXS: mergedToken.borderRadiusXS,
3599
- borderRadiusSM: mergedToken.borderRadiusSM,
3600
- borderRadiusLG: mergedToken.borderRadiusLG,
3601
- fontWeightStrong: 600,
3602
- opacityLoading: 0.65,
3603
- linkDecoration: 'none',
3604
- linkHoverDecoration: 'none',
3605
- linkFocusDecoration: 'none',
3606
- controlPaddingHorizontal: 12,
3607
- controlPaddingHorizontalSM: 8,
3608
- paddingXXS: mergedToken.sizeXXS,
3609
- paddingXS: mergedToken.sizeXS,
3610
- paddingSM: mergedToken.sizeSM,
3611
- padding: mergedToken.size,
3612
- paddingMD: mergedToken.sizeMD,
3613
- paddingLG: mergedToken.sizeLG,
3614
- paddingXL: mergedToken.sizeXL,
3615
- paddingContentHorizontalLG: mergedToken.sizeLG,
3616
- paddingContentVerticalLG: mergedToken.sizeMS,
3617
- paddingContentHorizontal: mergedToken.sizeMS,
3618
- paddingContentVertical: mergedToken.sizeSM,
3619
- paddingContentHorizontalSM: mergedToken.size,
3620
- paddingContentVerticalSM: mergedToken.sizeXS,
3621
- marginXXS: mergedToken.sizeXXS,
3622
- marginXS: mergedToken.sizeXS,
3623
- marginSM: mergedToken.sizeSM,
3624
- margin: mergedToken.size,
3625
- marginMD: mergedToken.sizeMD,
3626
- marginLG: mergedToken.sizeLG,
3627
- marginXL: mergedToken.sizeXL,
3628
- marginXXL: mergedToken.sizeXXL,
3629
- boxShadow: `
3630
- 0 6px 16px 0 rgba(0, 0, 0, 0.08),
3631
- 0 3px 6px -4px rgba(0, 0, 0, 0.12),
3632
- 0 9px 28px 8px rgba(0, 0, 0, 0.05)
3633
- `,
3634
- boxShadowSecondary: `
3635
- 0 6px 16px 0 rgba(0, 0, 0, 0.08),
3636
- 0 3px 6px -4px rgba(0, 0, 0, 0.12),
3637
- 0 9px 28px 8px rgba(0, 0, 0, 0.05)
3638
- `,
3639
- boxShadowTertiary: `
3640
- 0 1px 2px 0 rgba(0, 0, 0, 0.03),
3641
- 0 1px 6px -1px rgba(0, 0, 0, 0.02),
3642
- 0 2px 4px 0 rgba(0, 0, 0, 0.02)
3643
- `,
3644
- screenXS,
3645
- screenXSMin: screenXS,
3646
- screenXSMax: screenSM - 1,
3647
- screenSM,
3648
- screenSMMin: screenSM,
3649
- screenSMMax: screenMD - 1,
3650
- screenMD,
3651
- screenMDMin: screenMD,
3652
- screenMDMax: screenLG - 1,
3653
- screenLG,
3654
- screenLGMin: screenLG,
3655
- screenLGMax: screenXL - 1,
3656
- screenXL,
3657
- screenXLMin: screenXL,
3658
- screenXLMax: screenXXL - 1,
3659
- screenXXL,
3660
- screenXXLMin: screenXXL,
3661
- boxShadowPopoverArrow: '2px 2px 5px rgba(0, 0, 0, 0.05)',
3662
- boxShadowCard: `
3663
- 0 1px 2px -2px ${new FastColor('rgba(0, 0, 0, 0.16)').toRgbString()},
3664
- 0 3px 6px 0 ${new FastColor('rgba(0, 0, 0, 0.12)').toRgbString()},
3665
- 0 5px 12px 4px ${new FastColor('rgba(0, 0, 0, 0.09)').toRgbString()}
3666
- `,
3667
- boxShadowDrawerRight: `
3668
- -6px 0 16px 0 rgba(0, 0, 0, 0.08),
3669
- -3px 0 6px -4px rgba(0, 0, 0, 0.12),
3670
- -9px 0 28px 8px rgba(0, 0, 0, 0.05)
3671
- `,
3672
- boxShadowDrawerLeft: `
3673
- 6px 0 16px 0 rgba(0, 0, 0, 0.08),
3674
- 3px 0 6px -4px rgba(0, 0, 0, 0.12),
3675
- 9px 0 28px 8px rgba(0, 0, 0, 0.05)
3676
- `,
3677
- boxShadowDrawerUp: `
3678
- 0 6px 16px 0 rgba(0, 0, 0, 0.08),
3679
- 0 3px 6px -4px rgba(0, 0, 0, 0.12),
3680
- 0 9px 28px 8px rgba(0, 0, 0, 0.05)
3681
- `,
3682
- boxShadowDrawerDown: `
3683
- 0 -6px 16px 0 rgba(0, 0, 0, 0.08),
3684
- 0 -3px 6px -4px rgba(0, 0, 0, 0.12),
3685
- 0 -9px 28px 8px rgba(0, 0, 0, 0.05)
3686
- `,
3687
- boxShadowTabsOverflowLeft: 'inset 10px 0 8px -8px rgba(0, 0, 0, 0.08)',
3688
- boxShadowTabsOverflowRight: 'inset -10px 0 8px -8px rgba(0, 0, 0, 0.08)',
3689
- boxShadowTabsOverflowTop: 'inset 0 10px 8px -8px rgba(0, 0, 0, 0.08)',
3690
- boxShadowTabsOverflowBottom: 'inset 0 -10px 8px -8px rgba(0, 0, 0, 0.08)'
3691
- }), overrideTokens);
3692
- return aliasToken;
3693
- }
3694
-
3695
- var __rest$3 = undefined && undefined.__rest || function (s, e) {
3696
- var t = {};
3697
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
3698
- if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
3699
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
3700
- }
3701
- return t;
3702
- };
3703
- const unitless = {
3704
- lineHeight: true,
3705
- lineHeightSM: true,
3706
- lineHeightLG: true,
3707
- lineHeightHeading1: true,
3708
- lineHeightHeading2: true,
3709
- lineHeightHeading3: true,
3710
- lineHeightHeading4: true,
3711
- lineHeightHeading5: true,
3712
- opacityLoading: true,
3713
- fontWeightStrong: true,
3714
- zIndexPopupBase: true,
3715
- zIndexBase: true,
3716
- opacityImage: true
3717
- };
3718
- const ignore = {
3719
- motionBase: true,
3720
- motionUnit: true
3721
- };
3722
- const preserve = {
3723
- screenXS: true,
3724
- screenXSMin: true,
3725
- screenXSMax: true,
3726
- screenSM: true,
3727
- screenSMMin: true,
3728
- screenSMMax: true,
3729
- screenMD: true,
3730
- screenMDMin: true,
3731
- screenMDMax: true,
3732
- screenLG: true,
3733
- screenLGMin: true,
3734
- screenLGMax: true,
3735
- screenXL: true,
3736
- screenXLMin: true,
3737
- screenXLMax: true,
3738
- screenXXL: true,
3739
- screenXXLMin: true
3740
- };
3741
- const getComputedToken = (originToken, overrideToken, theme) => {
3742
- const derivativeToken = theme.getDerivativeToken(originToken);
3743
- const {
3744
- override
3745
- } = overrideToken,
3746
- components = __rest$3(overrideToken, ["override"]);
3747
- // Merge with override
3748
- let mergedDerivativeToken = Object.assign(Object.assign({}, derivativeToken), {
3749
- override
3750
- });
3751
- // Format if needed
3752
- mergedDerivativeToken = formatToken(mergedDerivativeToken);
3753
- if (components) {
3754
- Object.entries(components).forEach(([key, value]) => {
3755
- const {
3756
- theme: componentTheme
3757
- } = value,
3758
- componentTokens = __rest$3(value, ["theme"]);
3759
- let mergedComponentToken = componentTokens;
3760
- if (componentTheme) {
3761
- mergedComponentToken = getComputedToken(Object.assign(Object.assign({}, mergedDerivativeToken), componentTokens), {
3762
- override: componentTokens
3763
- }, componentTheme);
3764
- }
3765
- mergedDerivativeToken[key] = mergedComponentToken;
3766
- });
3767
- }
3768
- return mergedDerivativeToken;
3769
- };
3770
- // ================================== Hook ==================================
3771
- function useToken() {
3772
- const {
3773
- token: rootDesignToken,
3774
- hashed,
3775
- theme,
3776
- override,
3777
- cssVar
3778
- } = React__default.useContext(DesignTokenContext);
3779
- const salt = `${version}-${hashed || ''}`;
3780
- const mergedTheme = theme || defaultTheme;
3781
- const [token, hashId, realToken] = useCacheToken(mergedTheme, [seedToken, rootDesignToken], {
3782
- salt,
3783
- override,
3784
- getComputedToken,
3785
- // formatToken will not be consumed after 1.15.0 with getComputedToken.
3786
- // But token will break if @ant-design/cssinjs is under 1.15.0 without it
3787
- formatToken,
3788
- cssVar: cssVar && {
3789
- prefix: cssVar.prefix,
3790
- key: cssVar.key,
3791
- unitless,
3792
- ignore,
3793
- preserve
3794
- }
3795
- });
3796
- return [mergedTheme, realToken, hashed ? hashId : '', token, cssVar];
3797
- }
3798
-
3799
- const resetIcon = () => ({
3800
- display: 'inline-flex',
3801
- alignItems: 'center',
3802
- color: 'inherit',
3803
- fontStyle: 'normal',
3804
- lineHeight: 0,
3805
- textAlign: 'center',
3806
- textTransform: 'none',
3807
- // for SVG icon, see https://blog.prototypr.io/align-svg-icons-to-text-and-say-goodbye-to-font-icons-d44b3d7b26b4
3808
- verticalAlign: '-0.125em',
3809
- textRendering: 'optimizeLegibility',
3810
- '-webkit-font-smoothing': 'antialiased',
3811
- '-moz-osx-font-smoothing': 'grayscale',
3812
- '> *': {
3813
- lineHeight: 1
3814
- },
3815
- svg: {
3816
- display: 'inline-block'
3817
- }
3818
- });
3819
- const genLinkStyle = token => ({
3820
- a: {
3821
- color: token.colorLink,
3822
- textDecoration: token.linkDecoration,
3823
- backgroundColor: 'transparent',
3824
- // remove the gray background on active links in IE 10.
3825
- outline: 'none',
3826
- cursor: 'pointer',
3827
- transition: `color ${token.motionDurationSlow}`,
3828
- '-webkit-text-decoration-skip': 'objects',
3829
- // remove gaps in links underline in iOS 8+ and Safari 8+.
3830
- '&:hover': {
3831
- color: token.colorLinkHover
3832
- },
3833
- '&:active': {
3834
- color: token.colorLinkActive
3835
- },
3836
- '&:active, &:hover': {
3837
- textDecoration: token.linkHoverDecoration,
3838
- outline: 0
3839
- },
3840
- // https://github.com/ant-design/ant-design/issues/22503
3841
- '&:focus': {
3842
- textDecoration: token.linkFocusDecoration,
3843
- outline: 0
3844
- },
3845
- '&[disabled]': {
3846
- color: token.colorTextDisabled,
3847
- cursor: 'not-allowed'
3848
- }
3849
- }
3850
- });
3851
- const genCommonStyle = (token, componentPrefixCls, rootCls, resetFont) => {
3852
- const prefixSelector = `[class^="${componentPrefixCls}"], [class*=" ${componentPrefixCls}"]`;
3853
- const rootPrefixSelector = rootCls ? `.${rootCls}` : prefixSelector;
3854
- const resetStyle = {
3855
- boxSizing: 'border-box',
3856
- '&::before, &::after': {
3857
- boxSizing: 'border-box'
3858
- }
3859
- };
3860
- let resetFontStyle = {};
3861
- if (resetFont !== false) {
3862
- resetFontStyle = {
3863
- fontFamily: token.fontFamily,
3864
- fontSize: token.fontSize
3865
- };
3866
- }
3867
- return {
3868
- [rootPrefixSelector]: Object.assign(Object.assign(Object.assign({}, resetFontStyle), resetStyle), {
3869
- [prefixSelector]: resetStyle
3870
- })
3871
- };
3872
- };
3873
- const genIconStyle = iconPrefixCls => ({
3874
- [`.${iconPrefixCls}`]: Object.assign(Object.assign({}, resetIcon()), {
3875
- [`.${iconPrefixCls} .${iconPrefixCls}-icon`]: {
3876
- display: 'block'
3877
- }
3878
- })
3879
- });
3880
-
3881
- const {
3882
- genStyleHooks} = genStyleUtils({
3883
- usePrefix: () => {
3884
- const {
3885
- getPrefixCls,
3886
- iconPrefixCls
3887
- } = useContext(ConfigContext);
3888
- const rootPrefixCls = getPrefixCls();
3889
- return {
3890
- rootPrefixCls,
3891
- iconPrefixCls
3892
- };
3893
- },
3894
- useToken: () => {
3895
- const [theme, realToken, hashId, token, cssVar] = useToken();
3896
- return {
3897
- theme,
3898
- realToken,
3899
- hashId,
3900
- token,
3901
- cssVar
3902
- };
3903
- },
3904
- useCSP: () => {
3905
- const {
3906
- csp
3907
- } = useContext(ConfigContext);
3908
- return csp !== null && csp !== void 0 ? csp : {};
3909
- },
3910
- getResetStyles: (token, config) => {
3911
- var _a;
3912
- const linkStyle = genLinkStyle(token);
3913
- return [linkStyle, {
3914
- '&': linkStyle
3915
- }, genIconStyle((_a = config === null || config === void 0 ? void 0 : config.prefix.iconPrefixCls) !== null && _a !== void 0 ? _a : defaultIconPrefixCls)];
3916
- },
3917
- getCommonStyle: genCommonStyle,
3918
- getCompUnitless: () => unitless
3919
- });
3920
-
3921
- const useResetIconStyle = (iconPrefixCls, csp) => {
3922
- const [theme, token] = useToken();
3923
- // Generate style for icons
3924
- return useStyleRegister({
3925
- token,
3926
- hashId: '',
3927
- path: ['ant-design-icons', iconPrefixCls],
3928
- nonce: () => csp === null || csp === void 0 ? void 0 : csp.nonce,
3929
- layer: {
3930
- name: 'antd'
3931
- }
3932
- }, () => genIconStyle(iconPrefixCls));
3933
- };
3934
-
3935
- const fullClone = Object.assign({}, React);
3936
- const {
3937
- useId
3938
- } = fullClone;
3939
- const useEmptyId = () => '';
3940
- const useThemeKey = typeof useId === 'undefined' ? useEmptyId : useId;
3941
-
3942
- function useTheme(theme, parentTheme, config) {
3943
- var _a, _b;
3944
- const warning = devUseWarning('ConfigProvider');
3945
- const themeConfig = theme || {};
3946
- const parentThemeConfig = themeConfig.inherit === false || !parentTheme ? Object.assign(Object.assign({}, defaultConfig), {
3947
- hashed: (_a = parentTheme === null || parentTheme === void 0 ? void 0 : parentTheme.hashed) !== null && _a !== void 0 ? _a : defaultConfig.hashed,
3948
- cssVar: parentTheme === null || parentTheme === void 0 ? void 0 : parentTheme.cssVar
3949
- }) : parentTheme;
3950
- const themeKey = useThemeKey();
3951
- if (process.env.NODE_ENV !== 'production') {
3952
- const cssVarEnabled = themeConfig.cssVar || parentThemeConfig.cssVar;
3953
- const validKey = !!(typeof themeConfig.cssVar === 'object' && ((_b = themeConfig.cssVar) === null || _b === void 0 ? void 0 : _b.key) || themeKey);
3954
- process.env.NODE_ENV !== "production" ? warning(!cssVarEnabled || validKey, 'breaking', 'Missing key in `cssVar` config. Please upgrade to React 18 or set `cssVar.key` manually in each ConfigProvider inside `cssVar` enabled ConfigProvider.') : void 0;
3955
- }
3956
- return useMemo(() => {
3957
- var _a, _b;
3958
- if (!theme) {
3959
- return parentTheme;
3960
- }
3961
- // Override
3962
- const mergedComponents = Object.assign({}, parentThemeConfig.components);
3963
- Object.keys(theme.components || {}).forEach(componentName => {
3964
- mergedComponents[componentName] = Object.assign(Object.assign({}, mergedComponents[componentName]), theme.components[componentName]);
3965
- });
3966
- const cssVarKey = `css-var-${themeKey.replace(/:/g, '')}`;
3967
- const mergedCssVar = ((_a = themeConfig.cssVar) !== null && _a !== void 0 ? _a : parentThemeConfig.cssVar) && Object.assign(Object.assign(Object.assign({
3968
- prefix: config === null || config === void 0 ? void 0 : config.prefixCls
3969
- }, typeof parentThemeConfig.cssVar === 'object' ? parentThemeConfig.cssVar : {}), typeof themeConfig.cssVar === 'object' ? themeConfig.cssVar : {}), {
3970
- key: typeof themeConfig.cssVar === 'object' && ((_b = themeConfig.cssVar) === null || _b === void 0 ? void 0 : _b.key) || cssVarKey
3971
- });
3972
- // Base token
3973
- return Object.assign(Object.assign(Object.assign({}, parentThemeConfig), themeConfig), {
3974
- token: Object.assign(Object.assign({}, parentThemeConfig.token), themeConfig.token),
3975
- components: mergedComponents,
3976
- cssVar: mergedCssVar
3977
- });
3978
- }, [themeConfig, parentThemeConfig], (prev, next) => prev.some((prevTheme, index) => {
3979
- const nextTheme = next[index];
3980
- return !isEqual(prevTheme, nextTheme, true);
3981
- }));
3982
- }
3983
-
3984
- var _excluded = ["children"];
3985
- var Context = /*#__PURE__*/React.createContext({});
3986
- function MotionProvider(_ref) {
3987
- var children = _ref.children,
3988
- props = _objectWithoutProperties(_ref, _excluded);
3989
- return /*#__PURE__*/React.createElement(Context.Provider, {
3990
- value: props
3991
- }, children);
3992
- }
3993
-
3994
- const MotionCacheContext = /*#__PURE__*/React.createContext(true);
3995
- if (process.env.NODE_ENV !== 'production') {
3996
- MotionCacheContext.displayName = 'MotionCacheContext';
3997
- }
3998
- function MotionWrapper(props) {
3999
- const parentMotion = React.useContext(MotionCacheContext);
4000
- const {
4001
- children
4002
- } = props;
4003
- const [, token] = useToken();
4004
- const {
4005
- motion
4006
- } = token;
4007
- const needWrapMotionProviderRef = React.useRef(false);
4008
- needWrapMotionProviderRef.current || (needWrapMotionProviderRef.current = parentMotion !== motion);
4009
- if (needWrapMotionProviderRef.current) {
4010
- return /*#__PURE__*/React.createElement(MotionCacheContext.Provider, {
4011
- value: motion
4012
- }, /*#__PURE__*/React.createElement(MotionProvider, {
4013
- motion: motion
4014
- }, children));
4015
- }
4016
- return children;
4017
- }
4018
-
4019
- /**
4020
- * Warning for ConfigProviderProps.
4021
- * This will be empty function in production.
4022
- */
4023
- const PropWarning = /*#__PURE__*/React.memo(({
4024
- dropdownMatchSelectWidth
4025
- }) => {
4026
- const warning = devUseWarning('ConfigProvider');
4027
- warning.deprecated(dropdownMatchSelectWidth === undefined, 'dropdownMatchSelectWidth', 'popupMatchSelectWidth');
4028
- return null;
4029
- });
4030
- if (process.env.NODE_ENV !== 'production') {
4031
- PropWarning.displayName = 'PropWarning';
4032
- }
4033
- const PropWarning$1 = process.env.NODE_ENV !== 'production' ? PropWarning : () => null;
4034
-
4035
- var __rest$2 = undefined && undefined.__rest || function (s, e) {
4036
- var t = {};
4037
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
4038
- if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
4039
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
4040
- }
4041
- return t;
4042
- };
4043
- // These props is used by `useContext` directly in sub component
4044
- const PASSED_PROPS = ['getTargetContainer', 'getPopupContainer', 'renderEmpty', 'input', 'pagination', 'form', 'select', 'button'];
4045
- let globalPrefixCls;
4046
- function getGlobalPrefixCls() {
4047
- return globalPrefixCls || defaultPrefixCls;
4048
- }
4049
- function isLegacyTheme(theme) {
4050
- return Object.keys(theme).some(key => key.endsWith('Color'));
4051
- }
4052
- const setGlobalConfig = props => {
4053
- const {
4054
- prefixCls,
4055
- theme} = props;
4056
- if (prefixCls !== undefined) {
4057
- globalPrefixCls = prefixCls;
4058
- }
4059
- if (theme) {
4060
- if (isLegacyTheme(theme)) {
4061
- process.env.NODE_ENV !== "production" ? warning(false, 'ConfigProvider', '`config` of css variable theme is not work in v5. Please use new `theme` config instead.') : void 0;
4062
- registerTheme(getGlobalPrefixCls(), theme);
4063
- }
4064
- }
4065
- };
4066
- const ProviderChildren = props => {
4067
- const {
4068
- children,
4069
- csp: customCsp,
4070
- autoInsertSpaceInButton,
4071
- alert,
4072
- anchor,
4073
- form,
4074
- locale,
4075
- componentSize,
4076
- direction,
4077
- space,
4078
- splitter,
4079
- virtual,
4080
- dropdownMatchSelectWidth,
4081
- popupMatchSelectWidth,
4082
- popupOverflow,
4083
- legacyLocale,
4084
- parentContext,
4085
- iconPrefixCls: customIconPrefixCls,
4086
- theme,
4087
- componentDisabled,
4088
- segmented,
4089
- statistic,
4090
- spin,
4091
- calendar,
4092
- carousel,
4093
- cascader,
4094
- collapse,
4095
- typography,
4096
- checkbox,
4097
- descriptions,
4098
- divider,
4099
- drawer,
4100
- skeleton,
4101
- steps,
4102
- image,
4103
- layout,
4104
- list,
4105
- mentions,
4106
- modal,
4107
- progress,
4108
- result,
4109
- slider,
4110
- breadcrumb,
4111
- menu,
4112
- pagination,
4113
- input,
4114
- textArea,
4115
- empty,
4116
- badge,
4117
- radio,
4118
- rate,
4119
- switch: SWITCH,
4120
- transfer,
4121
- avatar,
4122
- message,
4123
- tag,
4124
- table,
4125
- card,
4126
- tabs,
4127
- timeline,
4128
- timePicker,
4129
- upload,
4130
- notification,
4131
- tree,
4132
- colorPicker,
4133
- datePicker,
4134
- rangePicker,
4135
- flex,
4136
- wave,
4137
- dropdown,
4138
- warning: warningConfig,
4139
- tour,
4140
- tooltip,
4141
- popover,
4142
- popconfirm,
4143
- floatButton,
4144
- floatButtonGroup,
4145
- variant,
4146
- inputNumber,
4147
- treeSelect
4148
- } = props;
4149
- // =================================== Context ===================================
4150
- const getPrefixCls = React.useCallback((suffixCls, customizePrefixCls) => {
4151
- const {
4152
- prefixCls
4153
- } = props;
4154
- if (customizePrefixCls) {
4155
- return customizePrefixCls;
4156
- }
4157
- const mergedPrefixCls = prefixCls || parentContext.getPrefixCls('');
4158
- return suffixCls ? `${mergedPrefixCls}-${suffixCls}` : mergedPrefixCls;
4159
- }, [parentContext.getPrefixCls, props.prefixCls]);
4160
- const iconPrefixCls = customIconPrefixCls || parentContext.iconPrefixCls || defaultIconPrefixCls;
4161
- const csp = customCsp || parentContext.csp;
4162
- useResetIconStyle(iconPrefixCls, csp);
4163
- const mergedTheme = useTheme(theme, parentContext.theme, {
4164
- prefixCls: getPrefixCls('')
4165
- });
4166
- const baseConfig = {
4167
- csp,
4168
- autoInsertSpaceInButton,
4169
- alert,
4170
- anchor,
4171
- locale: locale || legacyLocale,
4172
- direction,
4173
- space,
4174
- splitter,
4175
- virtual,
4176
- popupMatchSelectWidth: popupMatchSelectWidth !== null && popupMatchSelectWidth !== void 0 ? popupMatchSelectWidth : dropdownMatchSelectWidth,
4177
- popupOverflow,
4178
- getPrefixCls,
4179
- iconPrefixCls,
4180
- theme: mergedTheme,
4181
- segmented,
4182
- statistic,
4183
- spin,
4184
- calendar,
4185
- carousel,
4186
- cascader,
4187
- collapse,
4188
- typography,
4189
- checkbox,
4190
- descriptions,
4191
- divider,
4192
- drawer,
4193
- skeleton,
4194
- steps,
4195
- image,
4196
- input,
4197
- textArea,
4198
- layout,
4199
- list,
4200
- mentions,
4201
- modal,
4202
- progress,
4203
- result,
4204
- slider,
4205
- breadcrumb,
4206
- menu,
4207
- pagination,
4208
- empty,
4209
- badge,
4210
- radio,
4211
- rate,
4212
- switch: SWITCH,
4213
- transfer,
4214
- avatar,
4215
- message,
4216
- tag,
4217
- table,
4218
- card,
4219
- tabs,
4220
- timeline,
4221
- timePicker,
4222
- upload,
4223
- notification,
4224
- tree,
4225
- colorPicker,
4226
- datePicker,
4227
- rangePicker,
4228
- flex,
4229
- wave,
4230
- dropdown,
4231
- warning: warningConfig,
4232
- tour,
4233
- tooltip,
4234
- popover,
4235
- popconfirm,
4236
- floatButton,
4237
- floatButtonGroup,
4238
- variant,
4239
- inputNumber,
4240
- treeSelect
4241
- };
4242
- if (process.env.NODE_ENV !== 'production') {
4243
- const warningFn = devUseWarning('ConfigProvider');
4244
- warningFn(!('autoInsertSpaceInButton' in props), 'deprecated', '`autoInsertSpaceInButton` is deprecated. Please use `{ button: { autoInsertSpace: boolean }}` instead.');
4245
- }
4246
- const config = Object.assign({}, parentContext);
4247
- Object.keys(baseConfig).forEach(key => {
4248
- if (baseConfig[key] !== undefined) {
4249
- config[key] = baseConfig[key];
4250
- }
4251
- });
4252
- // Pass the props used by `useContext` directly with child component.
4253
- // These props should merged into `config`.
4254
- PASSED_PROPS.forEach(propName => {
4255
- const propValue = props[propName];
4256
- if (propValue) {
4257
- config[propName] = propValue;
4258
- }
4259
- });
4260
- if (typeof autoInsertSpaceInButton !== 'undefined') {
4261
- // merge deprecated api
4262
- config.button = Object.assign({
4263
- autoInsertSpace: autoInsertSpaceInButton
4264
- }, config.button);
4265
- }
4266
- // https://github.com/ant-design/ant-design/issues/27617
4267
- const memoedConfig = useMemo(() => config, config, (prevConfig, currentConfig) => {
4268
- const prevKeys = Object.keys(prevConfig);
4269
- const currentKeys = Object.keys(currentConfig);
4270
- return prevKeys.length !== currentKeys.length || prevKeys.some(key => prevConfig[key] !== currentConfig[key]);
4271
- });
4272
- const {
4273
- layer
4274
- } = React.useContext(StyleContext);
4275
- const memoIconContextValue = React.useMemo(() => ({
4276
- prefixCls: iconPrefixCls,
4277
- csp,
4278
- layer: layer ? 'antd' : undefined
4279
- }), [iconPrefixCls, csp, layer]);
4280
- let childNode = /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(PropWarning$1, {
4281
- dropdownMatchSelectWidth: dropdownMatchSelectWidth
4282
- }), children);
4283
- const validateMessages = React.useMemo(() => {
4284
- var _a, _b, _c, _d;
4285
- return merge$1(((_a = localeValues.Form) === null || _a === void 0 ? void 0 : _a.defaultValidateMessages) || {}, ((_c = (_b = memoedConfig.locale) === null || _b === void 0 ? void 0 : _b.Form) === null || _c === void 0 ? void 0 : _c.defaultValidateMessages) || {}, ((_d = memoedConfig.form) === null || _d === void 0 ? void 0 : _d.validateMessages) || {}, (form === null || form === void 0 ? void 0 : form.validateMessages) || {});
4286
- }, [memoedConfig, form === null || form === void 0 ? void 0 : form.validateMessages]);
4287
- if (Object.keys(validateMessages).length > 0) {
4288
- childNode = /*#__PURE__*/React.createElement(ValidateMessagesContext.Provider, {
4289
- value: validateMessages
4290
- }, childNode);
4291
- }
4292
- if (locale) {
4293
- childNode = /*#__PURE__*/React.createElement(LocaleProvider, {
4294
- locale: locale,
4295
- _ANT_MARK__: ANT_MARK
4296
- }, childNode);
4297
- }
4298
- {
4299
- childNode = /*#__PURE__*/React.createElement(IconContext.Provider, {
4300
- value: memoIconContextValue
4301
- }, childNode);
4302
- }
4303
- if (componentSize) {
4304
- childNode = /*#__PURE__*/React.createElement(SizeContextProvider, {
4305
- size: componentSize
4306
- }, childNode);
4307
- }
4308
- // =================================== Motion ===================================
4309
- childNode = /*#__PURE__*/React.createElement(MotionWrapper, null, childNode);
4310
- // ================================ Dynamic theme ================================
4311
- const memoTheme = React.useMemo(() => {
4312
- const _a = mergedTheme || {},
4313
- {
4314
- algorithm,
4315
- token,
4316
- components,
4317
- cssVar
4318
- } = _a,
4319
- rest = __rest$2(_a, ["algorithm", "token", "components", "cssVar"]);
4320
- const themeObj = algorithm && (!Array.isArray(algorithm) || algorithm.length > 0) ? createTheme(algorithm) : defaultTheme;
4321
- const parsedComponents = {};
4322
- Object.entries(components || {}).forEach(([componentName, componentToken]) => {
4323
- const parsedToken = Object.assign({}, componentToken);
4324
- if ('algorithm' in parsedToken) {
4325
- if (parsedToken.algorithm === true) {
4326
- parsedToken.theme = themeObj;
4327
- } else if (Array.isArray(parsedToken.algorithm) || typeof parsedToken.algorithm === 'function') {
4328
- parsedToken.theme = createTheme(parsedToken.algorithm);
4329
- }
4330
- delete parsedToken.algorithm;
4331
- }
4332
- parsedComponents[componentName] = parsedToken;
4333
- });
4334
- const mergedToken = Object.assign(Object.assign({}, seedToken), token);
4335
- return Object.assign(Object.assign({}, rest), {
4336
- theme: themeObj,
4337
- token: mergedToken,
4338
- components: parsedComponents,
4339
- override: Object.assign({
4340
- override: mergedToken
4341
- }, parsedComponents),
4342
- cssVar: cssVar
4343
- });
4344
- }, [mergedTheme]);
4345
- if (theme) {
4346
- childNode = /*#__PURE__*/React.createElement(DesignTokenContext.Provider, {
4347
- value: memoTheme
4348
- }, childNode);
4349
- }
4350
- // ================================== Warning ===================================
4351
- if (memoedConfig.warning) {
4352
- childNode = /*#__PURE__*/React.createElement(WarningContext.Provider, {
4353
- value: memoedConfig.warning
4354
- }, childNode);
4355
- }
4356
- // =================================== Render ===================================
4357
- if (componentDisabled !== undefined) {
4358
- childNode = /*#__PURE__*/React.createElement(DisabledContextProvider, {
4359
- disabled: componentDisabled
4360
- }, childNode);
4361
- }
4362
- return /*#__PURE__*/React.createElement(ConfigContext.Provider, {
4363
- value: memoedConfig
4364
- }, childNode);
4365
- };
4366
- const ConfigProvider = props => {
4367
- const context = React.useContext(ConfigContext);
4368
- const antLocale = React.useContext(LocaleContext);
4369
- return /*#__PURE__*/React.createElement(ProviderChildren, Object.assign({
4370
- parentContext: context,
4371
- legacyLocale: antLocale
4372
- }, props));
4373
- };
4374
- ConfigProvider.ConfigContext = ConfigContext;
4375
- ConfigProvider.SizeContext = SizeContext;
4376
- ConfigProvider.config = setGlobalConfig;
4377
- ConfigProvider.useConfig = useConfig;
4378
- Object.defineProperty(ConfigProvider, 'SizeContext', {
4379
- get: () => {
4380
- process.env.NODE_ENV !== "production" ? warning(false, 'ConfigProvider', 'ConfigProvider.SizeContext is deprecated. Please use `ConfigProvider.useConfig().componentSize` instead.') : void 0;
4381
- return SizeContext;
4382
- }
4383
- });
4384
- if (process.env.NODE_ENV !== 'production') {
4385
- ConfigProvider.displayName = 'ConfigProvider';
4386
- }
4387
-
4388
56
  const LayoutContext = /*#__PURE__*/React.createContext({
4389
57
  siderHook: {
4390
58
  addSider: () => null,
@@ -4392,24 +60,6 @@ const LayoutContext = /*#__PURE__*/React.createContext({
4392
60
  }
4393
61
  });
4394
62
 
4395
- function toArray(children) {
4396
- var option = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
4397
- var ret = [];
4398
- React__default.Children.forEach(children, function (child) {
4399
- if ((child === undefined || child === null) && !option.keepEmpty) {
4400
- return;
4401
- }
4402
- if (Array.isArray(child)) {
4403
- ret = ret.concat(toArray(child));
4404
- } else if (isFragment(child) && child.props) {
4405
- ret = ret.concat(toArray(child.props.children, option));
4406
- } else {
4407
- ret.push(child);
4408
- }
4409
- });
4410
- return ret;
4411
- }
4412
-
4413
63
  const addMediaQueryListener = (mql, handler) => {
4414
64
  // Don't delete here, please keep the code compatible
4415
65
  if (typeof (mql === null || mql === void 0 ? void 0 : mql.addEventListener) !== 'undefined') {
@@ -4474,7 +124,7 @@ const genLayoutStyle = token => {
4474
124
  height: headerHeight,
4475
125
  padding: headerPadding,
4476
126
  color: headerColor,
4477
- lineHeight: unit$1(headerHeight),
127
+ lineHeight: unit(headerHeight),
4478
128
  background: headerBg,
4479
129
  // Other components/menu/style/index.less line:686
4480
130
  // Integration with header element so menu items have the same height
@@ -4591,7 +241,7 @@ const genSiderStyle = token => {
4591
241
  zIndex: 1,
4592
242
  height: triggerHeight,
4593
243
  color: triggerColor,
4594
- lineHeight: unit$1(triggerHeight),
244
+ lineHeight: unit(triggerHeight),
4595
245
  textAlign: 'center',
4596
246
  background: triggerBg,
4597
247
  cursor: 'pointer',
@@ -4610,7 +260,7 @@ const genSiderStyle = token => {
4610
260
  alignItems: 'center',
4611
261
  justifyContent: 'center',
4612
262
  background: siderBg,
4613
- borderRadius: `0 ${unit$1(borderRadiusLG)} ${unit$1(borderRadiusLG)} 0`,
263
+ borderRadius: `0 ${unit(borderRadiusLG)} ${unit(borderRadiusLG)} 0`,
4614
264
  cursor: 'pointer',
4615
265
  transition: `background ${motionDurationSlow} ease`,
4616
266
  '&::after': {
@@ -4625,7 +275,7 @@ const genSiderStyle = token => {
4625
275
  },
4626
276
  '&-right': {
4627
277
  insetInlineStart: token.calc(zeroTriggerWidth).mul(-1).equal(),
4628
- borderRadius: `${unit$1(borderRadiusLG)} 0 0 ${unit$1(borderRadiusLG)}`
278
+ borderRadius: `${unit(borderRadiusLG)} 0 0 ${unit(borderRadiusLG)}`
4629
279
  }
4630
280
  },
4631
281
  // Light
@@ -4756,7 +406,7 @@ const Sider = /*#__PURE__*/React.forwardRef((props, ref) => {
4756
406
  // special trigger when collapsedWidth == 0
4757
407
  const zeroWidthTrigger = parseFloat(String(collapsedWidth || 0)) === 0 ? (/*#__PURE__*/React.createElement("span", {
4758
408
  onClick: toggle,
4759
- className: r(`${prefixCls}-zero-width-trigger`, `${prefixCls}-zero-width-trigger-${reverseArrow ? 'right' : 'left'}`),
409
+ className: classNames(`${prefixCls}-zero-width-trigger`, `${prefixCls}-zero-width-trigger-${reverseArrow ? 'right' : 'left'}`),
4760
410
  style: zeroWidthTriggerStyle
4761
411
  }, trigger || /*#__PURE__*/React.createElement(RefIcon$2, null))) : null;
4762
412
  const reverseIcon = direction === 'rtl' === !reverseArrow;
@@ -4779,7 +429,7 @@ const Sider = /*#__PURE__*/React.forwardRef((props, ref) => {
4779
429
  minWidth: siderWidth,
4780
430
  width: siderWidth
4781
431
  });
4782
- const siderCls = r(prefixCls, `${prefixCls}-${theme}`, {
432
+ const siderCls = classNames(prefixCls, `${prefixCls}-${theme}`, {
4783
433
  [`${prefixCls}-collapsed`]: !!collapsed,
4784
434
  [`${prefixCls}-has-trigger`]: collapsible && trigger !== null && !zeroWidthTrigger,
4785
435
  [`${prefixCls}-below`]: !!below,
@@ -4854,7 +504,7 @@ const Basic = /*#__PURE__*/React.forwardRef((props, ref) => {
4854
504
  const [wrapSSR, hashId, cssVarCls] = useStyle$1(prefixCls);
4855
505
  const prefixWithSuffixCls = suffixCls ? `${prefixCls}-${suffixCls}` : prefixCls;
4856
506
  return wrapSSR(/*#__PURE__*/React.createElement(TagName, Object.assign({
4857
- className: r(customizePrefixCls || prefixWithSuffixCls, className, hashId, cssVarCls),
507
+ className: classNames(customizePrefixCls || prefixWithSuffixCls, className, hashId, cssVarCls),
4858
508
  ref: ref
4859
509
  }, others)));
4860
510
  });
@@ -4882,7 +532,7 @@ const BasicLayout = /*#__PURE__*/React.forwardRef((props, ref) => {
4882
532
  const prefixCls = getPrefixCls('layout', customizePrefixCls);
4883
533
  const mergedHasSider = useHasSider(siders, children, hasSider);
4884
534
  const [wrapCSSVar, hashId, cssVarCls] = useStyle$1(prefixCls);
4885
- const classString = r(prefixCls, {
535
+ const classString = classNames(prefixCls, {
4886
536
  [`${prefixCls}-has-sider`]: mergedHasSider,
4887
537
  [`${prefixCls}-rtl`]: direction === 'rtl'
4888
538
  }, contextClassName, className, rootClassName, hashId, cssVarCls);