@stella-source/stellasource-dsl 3.2.0 → 3.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/dist/cjs/index.js +852 -85
  2. package/dist/cjs/index.js.map +1 -1
  3. package/dist/cjs/types/components/HelperText/styles.d.ts +3 -3
  4. package/dist/cjs/types/components/IconButton/styles.d.ts +7 -1
  5. package/dist/cjs/types/components/Label/styles.d.ts +4 -4
  6. package/dist/cjs/types/components/Loader/styles.d.ts +1 -1
  7. package/dist/cjs/types/components/OrderStatus/styles.d.ts +3 -3
  8. package/dist/cjs/types/components/Pagination/styles.d.ts +14 -12
  9. package/dist/cjs/types/components/PaymentStatus/styles.d.ts +3 -3
  10. package/dist/cjs/types/components/StellaButton/styles.d.ts +1 -1
  11. package/dist/cjs/types/components/Sync/styles.d.ts +3 -3
  12. package/dist/cjs/types/components/Table/styles.d.ts +60 -33
  13. package/dist/cjs/types/components/TableUnitsAndTotals/styles.d.ts +7 -5
  14. package/dist/cjs/types/components/Tabs/Styles.d.ts +3 -3
  15. package/dist/cjs/types/components/Tabs/Tab.d.ts +1 -1
  16. package/dist/cjs/types/components/Tabs/types.d.ts +1 -1
  17. package/dist/cjs/types/components/TextField/NumberInput/NumberInput.d.ts +1 -1
  18. package/dist/cjs/types/components/TextField/NumberInput/types.d.ts +1 -0
  19. package/dist/cjs/types/components/TextField/PasswordInput/styles.d.ts +1 -1
  20. package/dist/cjs/types/components/TextField/styles.d.ts +5 -5
  21. package/dist/cjs/types/shared/utils/numberHelpers.d.ts +1 -1
  22. package/dist/esm/index.esm.js +855 -88
  23. package/dist/esm/index.esm.js.map +1 -1
  24. package/dist/esm/types/components/HelperText/styles.d.ts +3 -3
  25. package/dist/esm/types/components/IconButton/styles.d.ts +7 -1
  26. package/dist/esm/types/components/Label/styles.d.ts +4 -4
  27. package/dist/esm/types/components/Loader/styles.d.ts +1 -1
  28. package/dist/esm/types/components/OrderStatus/styles.d.ts +3 -3
  29. package/dist/esm/types/components/Pagination/styles.d.ts +14 -12
  30. package/dist/esm/types/components/PaymentStatus/styles.d.ts +3 -3
  31. package/dist/esm/types/components/StellaButton/styles.d.ts +1 -1
  32. package/dist/esm/types/components/Sync/styles.d.ts +3 -3
  33. package/dist/esm/types/components/Table/styles.d.ts +60 -33
  34. package/dist/esm/types/components/TableUnitsAndTotals/styles.d.ts +7 -5
  35. package/dist/esm/types/components/Tabs/Styles.d.ts +3 -3
  36. package/dist/esm/types/components/Tabs/Tab.d.ts +1 -1
  37. package/dist/esm/types/components/Tabs/types.d.ts +1 -1
  38. package/dist/esm/types/components/TextField/NumberInput/NumberInput.d.ts +1 -1
  39. package/dist/esm/types/components/TextField/NumberInput/types.d.ts +1 -0
  40. package/dist/esm/types/components/TextField/PasswordInput/styles.d.ts +1 -1
  41. package/dist/esm/types/components/TextField/styles.d.ts +5 -5
  42. package/dist/esm/types/shared/utils/numberHelpers.d.ts +1 -1
  43. package/dist/index.d.ts +3 -2
  44. package/package.json +3 -3
@@ -4507,6 +4507,7 @@ var Entity = /*#__PURE__*/function () {
4507
4507
  _defineProperty(this, "instanceId", void 0);
4508
4508
  /** @private Internal cache map. Do not access this directly */
4509
4509
  _defineProperty(this, "cache", new Map());
4510
+ _defineProperty(this, "extracted", new Set());
4510
4511
  this.instanceId = instanceId;
4511
4512
  }
4512
4513
  _createClass(Entity, [{
@@ -4836,13 +4837,12 @@ function unit$1(num) {
4836
4837
  return num;
4837
4838
  }
4838
4839
  function toStyleStr(style, tokenKey, styleId) {
4839
- var _objectSpread2$1;
4840
4840
  var customizeAttrs = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
4841
4841
  var plain = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
4842
4842
  if (plain) {
4843
4843
  return style;
4844
4844
  }
4845
- var attrs = _objectSpread2(_objectSpread2({}, customizeAttrs), {}, (_objectSpread2$1 = {}, _defineProperty(_objectSpread2$1, ATTR_TOKEN, tokenKey), _defineProperty(_objectSpread2$1, ATTR_MARK, styleId), _objectSpread2$1));
4845
+ var attrs = _objectSpread2(_objectSpread2({}, customizeAttrs), {}, _defineProperty(_defineProperty({}, ATTR_TOKEN, tokenKey), ATTR_MARK, styleId));
4846
4846
  var attrStr = Object.keys(attrs).map(function (attr) {
4847
4847
  var val = attrs[attr];
4848
4848
  return val ? "".concat(attr, "=\"").concat(val, "\"") : null;
@@ -5047,7 +5047,6 @@ onCacheEffect) {
5047
5047
  }, /* eslint-disable react-hooks/exhaustive-deps */
5048
5048
  [fullPathStr]
5049
5049
  /* eslint-enable */);
5050
-
5051
5050
  var cacheEntity = globalCache.opGet(fullPathStr);
5052
5051
 
5053
5052
  // HMR clean the cache but not trigger `useMemo` again
@@ -5127,14 +5126,13 @@ var TOKEN_THRESHOLD = 0;
5127
5126
  // Remove will check current keys first
5128
5127
  function cleanTokenStyle(tokenKey, instanceId) {
5129
5128
  tokenKeys.set(tokenKey, (tokenKeys.get(tokenKey) || 0) - 1);
5130
- var tokenKeyList = Array.from(tokenKeys.keys());
5131
- var cleanableKeyList = tokenKeyList.filter(function (key) {
5132
- var count = tokenKeys.get(key) || 0;
5133
- return count <= 0;
5129
+ var cleanableKeyList = new Set();
5130
+ tokenKeys.forEach(function (value, key) {
5131
+ if (value <= 0) cleanableKeyList.add(key);
5134
5132
  });
5135
5133
 
5136
5134
  // Should keep tokens under threshold for not to insert style too often
5137
- if (tokenKeyList.length - cleanableKeyList.length > TOKEN_THRESHOLD) {
5135
+ if (tokenKeys.size - cleanableKeyList.size > TOKEN_THRESHOLD) {
5138
5136
  cleanableKeyList.forEach(function (key) {
5139
5137
  removeStyleTags(key, instanceId);
5140
5138
  tokenKeys.delete(key);
@@ -5343,16 +5341,6 @@ function replace (value, pattern, replacement) {
5343
5341
  return value.replace(pattern, replacement)
5344
5342
  }
5345
5343
 
5346
- /**
5347
- * @param {string} value
5348
- * @param {string} search
5349
- * @param {number} position
5350
- * @return {number}
5351
- */
5352
- function indexof (value, search, position) {
5353
- return value.indexOf(search, position)
5354
- }
5355
-
5356
5344
  /**
5357
5345
  * @param {string} value
5358
5346
  * @param {number} index
@@ -5639,6 +5627,7 @@ function parse (value, root, parent, rule, rules, rulesets, pseudo, points, decl
5639
5627
  var variable = 1;
5640
5628
  var scanning = 1;
5641
5629
  var ampersand = 1;
5630
+ var parens = 0;
5642
5631
  var character = 0;
5643
5632
  var type = '';
5644
5633
  var props = rules;
@@ -5650,17 +5639,23 @@ function parse (value, root, parent, rule, rules, rulesets, pseudo, points, decl
5650
5639
  switch (previous = character, character = next()) {
5651
5640
  // (
5652
5641
  case 40:
5653
- if (previous != 108 && charat(characters, length - 1) == 58) {
5654
- if (indexof(characters += replace(delimit(character), '&', '&\f'), '&\f', abs(index ? points[index - 1] : 0)) != -1)
5655
- ampersand = -1;
5656
- break
5657
- }
5642
+ if (previous != 108 && charat(characters, length - 1) == 58) parens++, characters += '(';
5643
+ else characters += delimit(character);
5644
+ break
5645
+ // )
5646
+ case 41:
5647
+ parens--, characters += ')';
5648
+ break
5658
5649
  // " ' [
5659
5650
  case 34: case 39: case 91:
5660
5651
  characters += delimit(character);
5661
5652
  break
5662
5653
  // \t \n \r \s
5663
5654
  case 9: case 10: case 13: case 32:
5655
+ if (parens > 0) {
5656
+ characters += from(character);
5657
+ break
5658
+ }
5664
5659
  characters += whitespace$1(previous);
5665
5660
  break
5666
5661
  // \
@@ -5683,12 +5678,16 @@ function parse (value, root, parent, rule, rules, rulesets, pseudo, points, decl
5683
5678
  points[index++] = strlen(characters) * ampersand;
5684
5679
  // } ; \0
5685
5680
  case 125 * variable: case 59: case 0:
5681
+ if (parens > 0 && character) {
5682
+ characters += from(character);
5683
+ break
5684
+ }
5686
5685
  switch (character) {
5687
5686
  // \0 }
5688
5687
  case 0: case 125: scanning = 0;
5689
5688
  // ;
5690
5689
  case 59 + offset: if (ampersand == -1) characters = replace(characters, /\f/g, '');
5691
- if (property > 0 && (strlen(characters) - length || (variable === 0 && previous === 47)))
5690
+ if (property > 0 && (strlen(characters) - length || variable === 0))
5692
5691
  append(property > 32 ? declaration(characters + ';', rule, parent, length - 1, declarations) : declaration(replace(characters, ' ', '') + ';', rule, parent, length - 2, declarations), declarations);
5693
5692
  break
5694
5693
  // @ ;
@@ -5737,6 +5736,7 @@ function parse (value, root, parent, rule, rules, rulesets, pseudo, points, decl
5737
5736
  break
5738
5737
  // ,
5739
5738
  case 44:
5739
+ if (parens > 0) break
5740
5740
  points[index++] = (strlen(characters) - 1) * ampersand, ampersand = 1;
5741
5741
  break
5742
5742
  // @
@@ -6209,7 +6209,8 @@ function useStyleRegister(info, styleFn) {
6209
6209
  styleId = _ref3[2];
6210
6210
  if ((fromHMR || autoClear) && isClientSide) {
6211
6211
  removeCSS(styleId, {
6212
- mark: ATTR_MARK
6212
+ mark: ATTR_MARK,
6213
+ attachTo: container
6213
6214
  });
6214
6215
  }
6215
6216
  },
@@ -6283,8 +6284,7 @@ function useStyleRegister(info, styleFn) {
6283
6284
  if (!ssrInline || isMergedClientSide || !defaultCache) {
6284
6285
  styleNode = /*#__PURE__*/a$m.createElement(Empty, null);
6285
6286
  } else {
6286
- var _ref6;
6287
- styleNode = /*#__PURE__*/a$m.createElement("style", _extends({}, (_ref6 = {}, _defineProperty(_ref6, ATTR_TOKEN, cachedTokenKey), _defineProperty(_ref6, ATTR_MARK, cachedStyleId), _ref6), {
6287
+ styleNode = /*#__PURE__*/a$m.createElement("style", _extends({}, _defineProperty(_defineProperty({}, ATTR_TOKEN, cachedTokenKey), ATTR_MARK, cachedStyleId), {
6288
6288
  dangerouslySetInnerHTML: {
6289
6289
  __html: cachedStyleStr
6290
6290
  }
@@ -6371,7 +6371,8 @@ var useCSSVarRegister = function useCSSVarRegister(config, fn) {
6371
6371
  styleId = _ref2[2];
6372
6372
  if (isClientSide) {
6373
6373
  removeCSS(styleId, {
6374
- mark: ATTR_MARK
6374
+ mark: ATTR_MARK,
6375
+ attachTo: container
6375
6376
  });
6376
6377
  }
6377
6378
  }, function (_ref3) {
@@ -6416,8 +6417,7 @@ var extract = function extract(cache, effectStyles, options) {
6416
6417
  return [order, styleId, styleText];
6417
6418
  };
6418
6419
 
6419
- var _ExtractStyleFns;
6420
- (_ExtractStyleFns = {}, _defineProperty(_ExtractStyleFns, STYLE_PREFIX, extract$1), _defineProperty(_ExtractStyleFns, TOKEN_PREFIX, extract$2), _defineProperty(_ExtractStyleFns, CSS_VAR_PREFIX, extract), _ExtractStyleFns);
6420
+ _defineProperty(_defineProperty(_defineProperty({}, STYLE_PREFIX, extract$1), TOKEN_PREFIX, extract$2), CSS_VAR_PREFIX, extract);
6421
6421
 
6422
6422
  var Keyframe = /*#__PURE__*/function () {
6423
6423
  function Keyframe(name, style) {
@@ -8005,7 +8005,7 @@ function useMergedState(defaultStateValue, option) {
8005
8005
  } else if (hasValue(defaultValue)) {
8006
8006
  return typeof defaultValue === 'function' ? defaultValue() : defaultValue;
8007
8007
  } else {
8008
- return defaultStateValue;
8008
+ return typeof defaultStateValue === 'function' ? defaultStateValue() : defaultStateValue;
8009
8009
  }
8010
8010
  }),
8011
8011
  _useState2 = _slicedToArray(_useState, 2),
@@ -8515,7 +8515,7 @@ function genStyleUtils(config) {
8515
8515
 
8516
8516
  const PresetColors = ['blue', 'purple', 'cyan', 'green', 'magenta', 'pink', 'red', 'orange', 'yellow', 'volcano', 'geekblue', 'lime', 'gold'];
8517
8517
 
8518
- var version = '5.26.3';
8518
+ var version = '5.29.3';
8519
8519
 
8520
8520
  function isStableColor(color) {
8521
8521
  return color >= 0 && color <= 255;
@@ -8756,17 +8756,6 @@ const unitless = {
8756
8756
  opacityImage: true
8757
8757
  };
8758
8758
  const ignore = {
8759
- size: true,
8760
- sizeSM: true,
8761
- sizeLG: true,
8762
- sizeMD: true,
8763
- sizeXS: true,
8764
- sizeXXS: true,
8765
- sizeMS: true,
8766
- sizeXL: true,
8767
- sizeXXL: true,
8768
- sizeUnit: true,
8769
- sizeStep: true,
8770
8759
  motionBase: true,
8771
8760
  motionUnit: true
8772
8761
  };
@@ -9700,8 +9689,8 @@ function diffKeys() {
9700
9689
  return list;
9701
9690
  }
9702
9691
 
9703
- var _excluded$5 = ["component", "children", "onVisibleChanged", "onAllRemoved"],
9704
- _excluded2 = ["status"];
9692
+ var _excluded$6 = ["component", "children", "onVisibleChanged", "onAllRemoved"],
9693
+ _excluded2$1 = ["status"];
9705
9694
  var MOTION_PROP_NAMES = ['eventProps', 'visible', 'children', 'motionName', 'motionAppear', 'motionEnter', 'motionLeave', 'motionLeaveImmediately', 'motionDeadline', 'removeOnLeave', 'leavedClassName', 'onAppearPrepare', 'onAppearStart', 'onAppearActive', 'onAppearEnd', 'onEnterStart', 'onEnterActive', 'onEnterEnd', 'onLeaveStart', 'onLeaveActive', 'onLeaveEnd'];
9706
9695
  /**
9707
9696
  * Generate a CSSMotionList component with config
@@ -9758,7 +9747,7 @@ function genCSSMotionList(transitionSupport) {
9758
9747
  children = _this$props.children,
9759
9748
  _onVisibleChanged = _this$props.onVisibleChanged;
9760
9749
  _this$props.onAllRemoved;
9761
- var restProps = _objectWithoutProperties(_this$props, _excluded$5);
9750
+ var restProps = _objectWithoutProperties(_this$props, _excluded$6);
9762
9751
  var Component = component || a$m.Fragment;
9763
9752
  var motionProps = {};
9764
9753
  MOTION_PROP_NAMES.forEach(function (prop) {
@@ -9768,7 +9757,7 @@ function genCSSMotionList(transitionSupport) {
9768
9757
  delete restProps.keys;
9769
9758
  return /*#__PURE__*/a$m.createElement(Component, restProps, keyEntities.map(function (_ref2, index) {
9770
9759
  var status = _ref2.status,
9771
- eventProps = _objectWithoutProperties(_ref2, _excluded2);
9760
+ eventProps = _objectWithoutProperties(_ref2, _excluded2$1);
9772
9761
  var visible = status === STATUS_ADD || status === STATUS_KEEP;
9773
9762
  return /*#__PURE__*/a$m.createElement(CSSMotion$1, _extends({}, motionProps, {
9774
9763
  key: eventProps.key,
@@ -9931,19 +9920,17 @@ function _regeneratorDefine(e, r, n, t) {
9931
9920
  i = 0;
9932
9921
  }
9933
9922
  _regeneratorDefine = function regeneratorDefine(e, r, n, t) {
9934
- if (r) i ? i(e, r, {
9923
+ function o(r, n) {
9924
+ _regeneratorDefine(e, r, function (e) {
9925
+ return this._invoke(r, n, e);
9926
+ });
9927
+ }
9928
+ r ? i ? i(e, r, {
9935
9929
  value: n,
9936
9930
  enumerable: !t,
9937
9931
  configurable: !t,
9938
9932
  writable: !t
9939
- }) : e[r] = n;else {
9940
- var o = function o(r, n) {
9941
- _regeneratorDefine(e, r, function (e) {
9942
- return this._invoke(r, n, e);
9943
- });
9944
- };
9945
- o("next", 0), o("throw", 1), o("return", 2);
9946
- }
9933
+ }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2));
9947
9934
  }, _regeneratorDefine(e, r, n, t);
9948
9935
  }
9949
9936
 
@@ -10253,6 +10240,734 @@ const NoCompactStyle = props => {
10253
10240
  }, children);
10254
10241
  };
10255
10242
 
10243
+ var _excluded$5 = ["b"],
10244
+ _excluded2 = ["v"];
10245
+ var getRoundNumber = function getRoundNumber(value) {
10246
+ return Math.round(Number(value || 0));
10247
+ };
10248
+ var convertHsb2Hsv = function convertHsb2Hsv(color) {
10249
+ if (color instanceof FastColor) {
10250
+ return color;
10251
+ }
10252
+ if (color && _typeof(color) === 'object' && 'h' in color && 'b' in color) {
10253
+ var _ref = color,
10254
+ b = _ref.b,
10255
+ resets = _objectWithoutProperties(_ref, _excluded$5);
10256
+ return _objectSpread2(_objectSpread2({}, resets), {}, {
10257
+ v: b
10258
+ });
10259
+ }
10260
+ if (typeof color === 'string' && /hsb/.test(color)) {
10261
+ return color.replace(/hsb/, 'hsv');
10262
+ }
10263
+ return color;
10264
+ };
10265
+ var Color = /*#__PURE__*/function (_FastColor) {
10266
+ _inherits(Color, _FastColor);
10267
+ var _super = _createSuper(Color);
10268
+ function Color(color) {
10269
+ _classCallCheck(this, Color);
10270
+ return _super.call(this, convertHsb2Hsv(color));
10271
+ }
10272
+ _createClass(Color, [{
10273
+ key: "toHsbString",
10274
+ value: function toHsbString() {
10275
+ var hsb = this.toHsb();
10276
+ var saturation = getRoundNumber(hsb.s * 100);
10277
+ var lightness = getRoundNumber(hsb.b * 100);
10278
+ var hue = getRoundNumber(hsb.h);
10279
+ var alpha = hsb.a;
10280
+ var hsbString = "hsb(".concat(hue, ", ").concat(saturation, "%, ").concat(lightness, "%)");
10281
+ var hsbaString = "hsba(".concat(hue, ", ").concat(saturation, "%, ").concat(lightness, "%, ").concat(alpha.toFixed(alpha === 0 ? 0 : 2), ")");
10282
+ return alpha === 1 ? hsbString : hsbaString;
10283
+ }
10284
+ }, {
10285
+ key: "toHsb",
10286
+ value: function toHsb() {
10287
+ var _this$toHsv = this.toHsv(),
10288
+ v = _this$toHsv.v,
10289
+ resets = _objectWithoutProperties(_this$toHsv, _excluded2);
10290
+ return _objectSpread2(_objectSpread2({}, resets), {}, {
10291
+ b: v,
10292
+ a: this.a
10293
+ });
10294
+ }
10295
+ }]);
10296
+ return Color;
10297
+ }(FastColor);
10298
+
10299
+ var ColorPickerPrefixCls = 'rc-color-picker';
10300
+ var generateColor$1 = function generateColor(color) {
10301
+ if (color instanceof Color) {
10302
+ return color;
10303
+ }
10304
+ return new Color(color);
10305
+ };
10306
+ var defaultColor = generateColor$1('#1677ff');
10307
+ var calculateColor = function calculateColor(props) {
10308
+ var offset = props.offset,
10309
+ targetRef = props.targetRef,
10310
+ containerRef = props.containerRef,
10311
+ color = props.color,
10312
+ type = props.type;
10313
+ var _containerRef$current = containerRef.current.getBoundingClientRect(),
10314
+ width = _containerRef$current.width,
10315
+ height = _containerRef$current.height;
10316
+ var _targetRef$current$ge = targetRef.current.getBoundingClientRect(),
10317
+ targetWidth = _targetRef$current$ge.width,
10318
+ targetHeight = _targetRef$current$ge.height;
10319
+ var centerOffsetX = targetWidth / 2;
10320
+ var centerOffsetY = targetHeight / 2;
10321
+ var saturation = (offset.x + centerOffsetX) / width;
10322
+ var bright = 1 - (offset.y + centerOffsetY) / height;
10323
+ var hsb = color.toHsb();
10324
+ var alphaOffset = saturation;
10325
+ var hueOffset = (offset.x + centerOffsetX) / width * 360;
10326
+ if (type) {
10327
+ switch (type) {
10328
+ case 'hue':
10329
+ return generateColor$1(_objectSpread2(_objectSpread2({}, hsb), {}, {
10330
+ h: hueOffset <= 0 ? 0 : hueOffset
10331
+ }));
10332
+ case 'alpha':
10333
+ return generateColor$1(_objectSpread2(_objectSpread2({}, hsb), {}, {
10334
+ a: alphaOffset <= 0 ? 0 : alphaOffset
10335
+ }));
10336
+ }
10337
+ }
10338
+ return generateColor$1({
10339
+ h: hsb.h,
10340
+ s: saturation <= 0 ? 0 : saturation,
10341
+ b: bright >= 1 ? 1 : bright,
10342
+ a: hsb.a
10343
+ });
10344
+ };
10345
+ var calcOffset = function calcOffset(color, type) {
10346
+ var hsb = color.toHsb();
10347
+ switch (type) {
10348
+ case 'hue':
10349
+ return {
10350
+ x: hsb.h / 360 * 100,
10351
+ y: 50
10352
+ };
10353
+ case 'alpha':
10354
+ return {
10355
+ x: color.a * 100,
10356
+ y: 50
10357
+ };
10358
+
10359
+ // Picker panel
10360
+ default:
10361
+ return {
10362
+ x: hsb.s * 100,
10363
+ y: (1 - hsb.b) * 100
10364
+ };
10365
+ }
10366
+ };
10367
+
10368
+ var ColorBlock = function ColorBlock(_ref) {
10369
+ var color = _ref.color,
10370
+ prefixCls = _ref.prefixCls,
10371
+ className = _ref.className,
10372
+ style = _ref.style,
10373
+ onClick = _ref.onClick;
10374
+ var colorBlockCls = "".concat(prefixCls, "-color-block");
10375
+ return /*#__PURE__*/a__default.createElement("div", {
10376
+ className: classNames(colorBlockCls, className),
10377
+ style: style,
10378
+ onClick: onClick
10379
+ }, /*#__PURE__*/a__default.createElement("div", {
10380
+ className: "".concat(colorBlockCls, "-inner"),
10381
+ style: {
10382
+ background: color
10383
+ }
10384
+ }));
10385
+ };
10386
+
10387
+ function getPosition(e) {
10388
+ var obj = 'touches' in e ? e.touches[0] : e;
10389
+ var scrollXOffset = document.documentElement.scrollLeft || document.body.scrollLeft || window.pageXOffset;
10390
+ var scrollYOffset = document.documentElement.scrollTop || document.body.scrollTop || window.pageYOffset;
10391
+ return {
10392
+ pageX: obj.pageX - scrollXOffset,
10393
+ pageY: obj.pageY - scrollYOffset
10394
+ };
10395
+ }
10396
+ function useColorDrag(props) {
10397
+ var targetRef = props.targetRef,
10398
+ containerRef = props.containerRef,
10399
+ direction = props.direction,
10400
+ onDragChange = props.onDragChange,
10401
+ onDragChangeComplete = props.onDragChangeComplete,
10402
+ calculate = props.calculate,
10403
+ color = props.color,
10404
+ disabledDrag = props.disabledDrag;
10405
+ var _useState = useState({
10406
+ x: 0,
10407
+ y: 0
10408
+ }),
10409
+ _useState2 = _slicedToArray(_useState, 2),
10410
+ offsetValue = _useState2[0],
10411
+ setOffsetValue = _useState2[1];
10412
+ var mouseMoveRef = useRef(null);
10413
+ var mouseUpRef = useRef(null);
10414
+
10415
+ // Always get position from `color`
10416
+ useEffect(function () {
10417
+ setOffsetValue(calculate());
10418
+ }, [color]);
10419
+ useEffect(function () {
10420
+ return function () {
10421
+ document.removeEventListener('mousemove', mouseMoveRef.current);
10422
+ document.removeEventListener('mouseup', mouseUpRef.current);
10423
+ document.removeEventListener('touchmove', mouseMoveRef.current);
10424
+ document.removeEventListener('touchend', mouseUpRef.current);
10425
+ mouseMoveRef.current = null;
10426
+ mouseUpRef.current = null;
10427
+ };
10428
+ }, []);
10429
+ var updateOffset = function updateOffset(e) {
10430
+ var _getPosition = getPosition(e),
10431
+ pageX = _getPosition.pageX,
10432
+ pageY = _getPosition.pageY;
10433
+ var _containerRef$current = containerRef.current.getBoundingClientRect(),
10434
+ rectX = _containerRef$current.x,
10435
+ rectY = _containerRef$current.y,
10436
+ width = _containerRef$current.width,
10437
+ height = _containerRef$current.height;
10438
+ var _targetRef$current$ge = targetRef.current.getBoundingClientRect(),
10439
+ targetWidth = _targetRef$current$ge.width,
10440
+ targetHeight = _targetRef$current$ge.height;
10441
+ var centerOffsetX = targetWidth / 2;
10442
+ var centerOffsetY = targetHeight / 2;
10443
+ var offsetX = Math.max(0, Math.min(pageX - rectX, width)) - centerOffsetX;
10444
+ var offsetY = Math.max(0, Math.min(pageY - rectY, height)) - centerOffsetY;
10445
+ var calcOffset = {
10446
+ x: offsetX,
10447
+ y: direction === 'x' ? offsetValue.y : offsetY
10448
+ };
10449
+
10450
+ // Exclusion of boundary cases
10451
+ if (targetWidth === 0 && targetHeight === 0 || targetWidth !== targetHeight) {
10452
+ return false;
10453
+ }
10454
+ onDragChange === null || onDragChange === void 0 || onDragChange(calcOffset);
10455
+ };
10456
+ var onDragMove = function onDragMove(e) {
10457
+ e.preventDefault();
10458
+ updateOffset(e);
10459
+ };
10460
+ var onDragStop = function onDragStop(e) {
10461
+ e.preventDefault();
10462
+ document.removeEventListener('mousemove', mouseMoveRef.current);
10463
+ document.removeEventListener('mouseup', mouseUpRef.current);
10464
+ document.removeEventListener('touchmove', mouseMoveRef.current);
10465
+ document.removeEventListener('touchend', mouseUpRef.current);
10466
+ mouseMoveRef.current = null;
10467
+ mouseUpRef.current = null;
10468
+ onDragChangeComplete === null || onDragChangeComplete === void 0 || onDragChangeComplete();
10469
+ };
10470
+ var onDragStart = function onDragStart(e) {
10471
+ // https://github.com/ant-design/ant-design/issues/43529
10472
+ document.removeEventListener('mousemove', mouseMoveRef.current);
10473
+ document.removeEventListener('mouseup', mouseUpRef.current);
10474
+ if (disabledDrag) {
10475
+ return;
10476
+ }
10477
+ updateOffset(e);
10478
+ document.addEventListener('mousemove', onDragMove);
10479
+ document.addEventListener('mouseup', onDragStop);
10480
+ document.addEventListener('touchmove', onDragMove);
10481
+ document.addEventListener('touchend', onDragStop);
10482
+ mouseMoveRef.current = onDragMove;
10483
+ mouseUpRef.current = onDragStop;
10484
+ };
10485
+ return [offsetValue, onDragStart];
10486
+ }
10487
+
10488
+ var Handler = function Handler(_ref) {
10489
+ var _ref$size = _ref.size,
10490
+ size = _ref$size === void 0 ? 'default' : _ref$size,
10491
+ color = _ref.color,
10492
+ prefixCls = _ref.prefixCls;
10493
+ return /*#__PURE__*/a__default.createElement("div", {
10494
+ className: classNames("".concat(prefixCls, "-handler"), _defineProperty({}, "".concat(prefixCls, "-handler-sm"), size === 'small')),
10495
+ style: {
10496
+ backgroundColor: color
10497
+ }
10498
+ });
10499
+ };
10500
+
10501
+ var Palette = function Palette(_ref) {
10502
+ var children = _ref.children,
10503
+ style = _ref.style,
10504
+ prefixCls = _ref.prefixCls;
10505
+ return /*#__PURE__*/a__default.createElement("div", {
10506
+ className: "".concat(prefixCls, "-palette"),
10507
+ style: _objectSpread2({
10508
+ position: 'relative'
10509
+ }, style)
10510
+ }, children);
10511
+ };
10512
+
10513
+ var Transform = /*#__PURE__*/forwardRef(function (props, ref) {
10514
+ var children = props.children,
10515
+ x = props.x,
10516
+ y = props.y;
10517
+ return /*#__PURE__*/a__default.createElement("div", {
10518
+ ref: ref,
10519
+ style: {
10520
+ position: 'absolute',
10521
+ left: "".concat(x, "%"),
10522
+ top: "".concat(y, "%"),
10523
+ zIndex: 1,
10524
+ transform: 'translate(-50%, -50%)'
10525
+ }
10526
+ }, children);
10527
+ });
10528
+
10529
+ var Picker = function Picker(_ref) {
10530
+ var color = _ref.color,
10531
+ onChange = _ref.onChange,
10532
+ prefixCls = _ref.prefixCls,
10533
+ onChangeComplete = _ref.onChangeComplete,
10534
+ disabled = _ref.disabled;
10535
+ var pickerRef = useRef();
10536
+ var transformRef = useRef();
10537
+ var colorRef = useRef(color);
10538
+ var onDragChange = useEvent(function (offsetValue) {
10539
+ var calcColor = calculateColor({
10540
+ offset: offsetValue,
10541
+ targetRef: transformRef,
10542
+ containerRef: pickerRef,
10543
+ color: color
10544
+ });
10545
+ colorRef.current = calcColor;
10546
+ onChange(calcColor);
10547
+ });
10548
+ var _useColorDrag = useColorDrag({
10549
+ color: color,
10550
+ containerRef: pickerRef,
10551
+ targetRef: transformRef,
10552
+ calculate: function calculate() {
10553
+ return calcOffset(color);
10554
+ },
10555
+ onDragChange: onDragChange,
10556
+ onDragChangeComplete: function onDragChangeComplete() {
10557
+ return onChangeComplete === null || onChangeComplete === void 0 ? void 0 : onChangeComplete(colorRef.current);
10558
+ },
10559
+ disabledDrag: disabled
10560
+ }),
10561
+ _useColorDrag2 = _slicedToArray(_useColorDrag, 2),
10562
+ offset = _useColorDrag2[0],
10563
+ dragStartHandle = _useColorDrag2[1];
10564
+ return /*#__PURE__*/a__default.createElement("div", {
10565
+ ref: pickerRef,
10566
+ className: "".concat(prefixCls, "-select"),
10567
+ onMouseDown: dragStartHandle,
10568
+ onTouchStart: dragStartHandle
10569
+ }, /*#__PURE__*/a__default.createElement(Palette, {
10570
+ prefixCls: prefixCls
10571
+ }, /*#__PURE__*/a__default.createElement(Transform, {
10572
+ x: offset.x,
10573
+ y: offset.y,
10574
+ ref: transformRef
10575
+ }, /*#__PURE__*/a__default.createElement(Handler, {
10576
+ color: color.toRgbString(),
10577
+ prefixCls: prefixCls
10578
+ })), /*#__PURE__*/a__default.createElement("div", {
10579
+ className: "".concat(prefixCls, "-saturation"),
10580
+ style: {
10581
+ backgroundColor: "hsl(".concat(color.toHsb().h, ",100%, 50%)"),
10582
+ backgroundImage: 'linear-gradient(0deg, #000, transparent),linear-gradient(90deg, #fff, hsla(0, 0%, 100%, 0))'
10583
+ }
10584
+ })));
10585
+ };
10586
+
10587
+ var useColorState = function useColorState(defaultValue, value) {
10588
+ var _useMergedState = useMergedState(defaultValue, {
10589
+ value: value
10590
+ }),
10591
+ _useMergedState2 = _slicedToArray(_useMergedState, 2),
10592
+ mergedValue = _useMergedState2[0],
10593
+ setValue = _useMergedState2[1];
10594
+ var color = useMemo$1(function () {
10595
+ return generateColor$1(mergedValue);
10596
+ }, [mergedValue]);
10597
+ return [color, setValue];
10598
+ };
10599
+
10600
+ var Gradient = function Gradient(_ref) {
10601
+ var colors = _ref.colors,
10602
+ children = _ref.children,
10603
+ _ref$direction = _ref.direction,
10604
+ direction = _ref$direction === void 0 ? 'to right' : _ref$direction,
10605
+ type = _ref.type,
10606
+ prefixCls = _ref.prefixCls;
10607
+ var gradientColors = useMemo$1(function () {
10608
+ return colors.map(function (color, idx) {
10609
+ var result = generateColor$1(color);
10610
+ if (type === 'alpha' && idx === colors.length - 1) {
10611
+ result = new Color(result.setA(1));
10612
+ }
10613
+ return result.toRgbString();
10614
+ }).join(',');
10615
+ }, [colors, type]);
10616
+ return /*#__PURE__*/a__default.createElement("div", {
10617
+ className: "".concat(prefixCls, "-gradient"),
10618
+ style: {
10619
+ position: 'absolute',
10620
+ inset: 0,
10621
+ background: "linear-gradient(".concat(direction, ", ").concat(gradientColors, ")")
10622
+ }
10623
+ }, children);
10624
+ };
10625
+
10626
+ var Slider = function Slider(props) {
10627
+ var prefixCls = props.prefixCls,
10628
+ colors = props.colors,
10629
+ disabled = props.disabled,
10630
+ onChange = props.onChange,
10631
+ onChangeComplete = props.onChangeComplete,
10632
+ color = props.color,
10633
+ type = props.type;
10634
+ var sliderRef = useRef();
10635
+ var transformRef = useRef();
10636
+ var colorRef = useRef(color);
10637
+ var getValue = function getValue(c) {
10638
+ return type === 'hue' ? c.getHue() : c.a * 100;
10639
+ };
10640
+ var onDragChange = useEvent(function (offsetValue) {
10641
+ var calcColor = calculateColor({
10642
+ offset: offsetValue,
10643
+ targetRef: transformRef,
10644
+ containerRef: sliderRef,
10645
+ color: color,
10646
+ type: type
10647
+ });
10648
+ colorRef.current = calcColor;
10649
+ onChange(getValue(calcColor));
10650
+ });
10651
+ var _useColorDrag = useColorDrag({
10652
+ color: color,
10653
+ targetRef: transformRef,
10654
+ containerRef: sliderRef,
10655
+ calculate: function calculate() {
10656
+ return calcOffset(color, type);
10657
+ },
10658
+ onDragChange: onDragChange,
10659
+ onDragChangeComplete: function onDragChangeComplete() {
10660
+ onChangeComplete(getValue(colorRef.current));
10661
+ },
10662
+ direction: 'x',
10663
+ disabledDrag: disabled
10664
+ }),
10665
+ _useColorDrag2 = _slicedToArray(_useColorDrag, 2),
10666
+ offset = _useColorDrag2[0],
10667
+ dragStartHandle = _useColorDrag2[1];
10668
+ var handleColor = a__default.useMemo(function () {
10669
+ if (type === 'hue') {
10670
+ var hsb = color.toHsb();
10671
+ hsb.s = 1;
10672
+ hsb.b = 1;
10673
+ hsb.a = 1;
10674
+ var lightColor = new Color(hsb);
10675
+ return lightColor;
10676
+ }
10677
+ return color;
10678
+ }, [color, type]);
10679
+
10680
+ // ========================= Gradient =========================
10681
+ var gradientList = a__default.useMemo(function () {
10682
+ return colors.map(function (info) {
10683
+ return "".concat(info.color, " ").concat(info.percent, "%");
10684
+ });
10685
+ }, [colors]);
10686
+
10687
+ // ========================== Render ==========================
10688
+ return /*#__PURE__*/a__default.createElement("div", {
10689
+ ref: sliderRef,
10690
+ className: classNames("".concat(prefixCls, "-slider"), "".concat(prefixCls, "-slider-").concat(type)),
10691
+ onMouseDown: dragStartHandle,
10692
+ onTouchStart: dragStartHandle
10693
+ }, /*#__PURE__*/a__default.createElement(Palette, {
10694
+ prefixCls: prefixCls
10695
+ }, /*#__PURE__*/a__default.createElement(Transform, {
10696
+ x: offset.x,
10697
+ y: offset.y,
10698
+ ref: transformRef
10699
+ }, /*#__PURE__*/a__default.createElement(Handler, {
10700
+ size: "small",
10701
+ color: handleColor.toHexString(),
10702
+ prefixCls: prefixCls
10703
+ })), /*#__PURE__*/a__default.createElement(Gradient, {
10704
+ colors: gradientList,
10705
+ type: type,
10706
+ prefixCls: prefixCls
10707
+ })));
10708
+ };
10709
+
10710
+ function useComponent(components) {
10711
+ return a$m.useMemo(function () {
10712
+ var _ref = components || {},
10713
+ slider = _ref.slider;
10714
+ return [slider || Slider];
10715
+ }, [components]);
10716
+ }
10717
+
10718
+ var HUE_COLORS = [{
10719
+ color: 'rgb(255, 0, 0)',
10720
+ percent: 0
10721
+ }, {
10722
+ color: 'rgb(255, 255, 0)',
10723
+ percent: 17
10724
+ }, {
10725
+ color: 'rgb(0, 255, 0)',
10726
+ percent: 33
10727
+ }, {
10728
+ color: 'rgb(0, 255, 255)',
10729
+ percent: 50
10730
+ }, {
10731
+ color: 'rgb(0, 0, 255)',
10732
+ percent: 67
10733
+ }, {
10734
+ color: 'rgb(255, 0, 255)',
10735
+ percent: 83
10736
+ }, {
10737
+ color: 'rgb(255, 0, 0)',
10738
+ percent: 100
10739
+ }];
10740
+ var ColorPicker = /*#__PURE__*/forwardRef(function (props, ref) {
10741
+ var value = props.value,
10742
+ defaultValue = props.defaultValue,
10743
+ _props$prefixCls = props.prefixCls,
10744
+ prefixCls = _props$prefixCls === void 0 ? ColorPickerPrefixCls : _props$prefixCls,
10745
+ onChange = props.onChange,
10746
+ onChangeComplete = props.onChangeComplete,
10747
+ className = props.className,
10748
+ style = props.style,
10749
+ panelRender = props.panelRender,
10750
+ _props$disabledAlpha = props.disabledAlpha,
10751
+ disabledAlpha = _props$disabledAlpha === void 0 ? false : _props$disabledAlpha,
10752
+ _props$disabled = props.disabled,
10753
+ disabled = _props$disabled === void 0 ? false : _props$disabled,
10754
+ components = props.components;
10755
+
10756
+ // ========================== Components ==========================
10757
+ var _useComponent = useComponent(components),
10758
+ _useComponent2 = _slicedToArray(_useComponent, 1),
10759
+ Slider = _useComponent2[0];
10760
+
10761
+ // ============================ Color =============================
10762
+ var _useColorState = useColorState(defaultValue || defaultColor, value),
10763
+ _useColorState2 = _slicedToArray(_useColorState, 2),
10764
+ colorValue = _useColorState2[0],
10765
+ setColorValue = _useColorState2[1];
10766
+ var alphaColor = useMemo$1(function () {
10767
+ return colorValue.setA(1).toRgbString();
10768
+ }, [colorValue]);
10769
+
10770
+ // ============================ Events ============================
10771
+ var handleChange = function handleChange(data, type) {
10772
+ if (!value) {
10773
+ setColorValue(data);
10774
+ }
10775
+ onChange === null || onChange === void 0 || onChange(data, type);
10776
+ };
10777
+
10778
+ // Convert
10779
+ var getHueColor = function getHueColor(hue) {
10780
+ return new Color(colorValue.setHue(hue));
10781
+ };
10782
+ var getAlphaColor = function getAlphaColor(alpha) {
10783
+ return new Color(colorValue.setA(alpha / 100));
10784
+ };
10785
+
10786
+ // Slider change
10787
+ var onHueChange = function onHueChange(hue) {
10788
+ handleChange(getHueColor(hue), {
10789
+ type: 'hue',
10790
+ value: hue
10791
+ });
10792
+ };
10793
+ var onAlphaChange = function onAlphaChange(alpha) {
10794
+ handleChange(getAlphaColor(alpha), {
10795
+ type: 'alpha',
10796
+ value: alpha
10797
+ });
10798
+ };
10799
+
10800
+ // Complete
10801
+ var onHueChangeComplete = function onHueChangeComplete(hue) {
10802
+ if (onChangeComplete) {
10803
+ onChangeComplete(getHueColor(hue));
10804
+ }
10805
+ };
10806
+ var onAlphaChangeComplete = function onAlphaChangeComplete(alpha) {
10807
+ if (onChangeComplete) {
10808
+ onChangeComplete(getAlphaColor(alpha));
10809
+ }
10810
+ };
10811
+
10812
+ // ============================ Render ============================
10813
+ var mergeCls = classNames("".concat(prefixCls, "-panel"), className, _defineProperty({}, "".concat(prefixCls, "-panel-disabled"), disabled));
10814
+ var sharedSliderProps = {
10815
+ prefixCls: prefixCls,
10816
+ disabled: disabled,
10817
+ color: colorValue
10818
+ };
10819
+ var defaultPanel = /*#__PURE__*/a__default.createElement(a__default.Fragment, null, /*#__PURE__*/a__default.createElement(Picker, _extends({
10820
+ onChange: handleChange
10821
+ }, sharedSliderProps, {
10822
+ onChangeComplete: onChangeComplete
10823
+ })), /*#__PURE__*/a__default.createElement("div", {
10824
+ className: "".concat(prefixCls, "-slider-container")
10825
+ }, /*#__PURE__*/a__default.createElement("div", {
10826
+ className: classNames("".concat(prefixCls, "-slider-group"), _defineProperty({}, "".concat(prefixCls, "-slider-group-disabled-alpha"), disabledAlpha))
10827
+ }, /*#__PURE__*/a__default.createElement(Slider, _extends({}, sharedSliderProps, {
10828
+ type: "hue",
10829
+ colors: HUE_COLORS,
10830
+ min: 0,
10831
+ max: 359,
10832
+ value: colorValue.getHue(),
10833
+ onChange: onHueChange,
10834
+ onChangeComplete: onHueChangeComplete
10835
+ })), !disabledAlpha && /*#__PURE__*/a__default.createElement(Slider, _extends({}, sharedSliderProps, {
10836
+ type: "alpha",
10837
+ colors: [{
10838
+ percent: 0,
10839
+ color: 'rgba(255, 0, 4, 0)'
10840
+ }, {
10841
+ percent: 100,
10842
+ color: alphaColor
10843
+ }],
10844
+ min: 0,
10845
+ max: 100,
10846
+ value: colorValue.a * 100,
10847
+ onChange: onAlphaChange,
10848
+ onChangeComplete: onAlphaChangeComplete
10849
+ }))), /*#__PURE__*/a__default.createElement(ColorBlock, {
10850
+ color: colorValue.toRgbString(),
10851
+ prefixCls: prefixCls
10852
+ })));
10853
+ return /*#__PURE__*/a__default.createElement("div", {
10854
+ className: mergeCls,
10855
+ style: style,
10856
+ ref: ref
10857
+ }, typeof panelRender === 'function' ? panelRender(defaultPanel) : defaultPanel);
10858
+ });
10859
+ if (process.env.NODE_ENV !== 'production') {
10860
+ ColorPicker.displayName = 'ColorPicker';
10861
+ }
10862
+
10863
+ const toHexFormat = (value, alpha) => (value === null || value === void 0 ? void 0 : value.replace(/[^\w/]/g, '').slice(0, alpha ? 8 : 6)) || '';
10864
+ const getHex = (value, alpha) => value ? toHexFormat(value, alpha) : '';
10865
+ let AggregationColor = /*#__PURE__*/function () {
10866
+ function AggregationColor(color) {
10867
+ _classCallCheck(this, AggregationColor);
10868
+ var _a;
10869
+ this.cleared = false;
10870
+ // Clone from another AggregationColor
10871
+ if (color instanceof AggregationColor) {
10872
+ this.metaColor = color.metaColor.clone();
10873
+ this.colors = (_a = color.colors) === null || _a === void 0 ? void 0 : _a.map(info => ({
10874
+ color: new AggregationColor(info.color),
10875
+ percent: info.percent
10876
+ }));
10877
+ this.cleared = color.cleared;
10878
+ return;
10879
+ }
10880
+ const isArray = Array.isArray(color);
10881
+ if (isArray && color.length) {
10882
+ this.colors = color.map(({
10883
+ color: c,
10884
+ percent
10885
+ }) => ({
10886
+ color: new AggregationColor(c),
10887
+ percent
10888
+ }));
10889
+ this.metaColor = new Color(this.colors[0].color.metaColor);
10890
+ } else {
10891
+ this.metaColor = new Color(isArray ? '' : color);
10892
+ }
10893
+ if (!color || isArray && !this.colors) {
10894
+ this.metaColor = this.metaColor.setA(0);
10895
+ this.cleared = true;
10896
+ }
10897
+ }
10898
+ return _createClass(AggregationColor, [{
10899
+ key: "toHsb",
10900
+ value: function toHsb() {
10901
+ return this.metaColor.toHsb();
10902
+ }
10903
+ }, {
10904
+ key: "toHsbString",
10905
+ value: function toHsbString() {
10906
+ return this.metaColor.toHsbString();
10907
+ }
10908
+ }, {
10909
+ key: "toHex",
10910
+ value: function toHex() {
10911
+ return getHex(this.toHexString(), this.metaColor.a < 1);
10912
+ }
10913
+ }, {
10914
+ key: "toHexString",
10915
+ value: function toHexString() {
10916
+ return this.metaColor.toHexString();
10917
+ }
10918
+ }, {
10919
+ key: "toRgb",
10920
+ value: function toRgb() {
10921
+ return this.metaColor.toRgb();
10922
+ }
10923
+ }, {
10924
+ key: "toRgbString",
10925
+ value: function toRgbString() {
10926
+ return this.metaColor.toRgbString();
10927
+ }
10928
+ }, {
10929
+ key: "isGradient",
10930
+ value: function isGradient() {
10931
+ return !!this.colors && !this.cleared;
10932
+ }
10933
+ }, {
10934
+ key: "getColors",
10935
+ value: function getColors() {
10936
+ return this.colors || [{
10937
+ color: this,
10938
+ percent: 0
10939
+ }];
10940
+ }
10941
+ }, {
10942
+ key: "toCssString",
10943
+ value: function toCssString() {
10944
+ const {
10945
+ colors
10946
+ } = this;
10947
+ // CSS line-gradient
10948
+ if (colors) {
10949
+ const colorsStr = colors.map(c => `${c.color.toRgbString()} ${c.percent}%`).join(', ');
10950
+ return `linear-gradient(90deg, ${colorsStr})`;
10951
+ }
10952
+ return this.metaColor.toRgbString();
10953
+ }
10954
+ }, {
10955
+ key: "equals",
10956
+ value: function equals(color) {
10957
+ if (!color || this.isGradient() !== color.isGradient()) {
10958
+ return false;
10959
+ }
10960
+ if (!this.isGradient()) {
10961
+ return this.toHexString() === color.toHexString();
10962
+ }
10963
+ return this.colors.length === color.colors.length && this.colors.every((c, i) => {
10964
+ const target = color.colors[i];
10965
+ return c.percent === target.percent && c.color.equals(target.color);
10966
+ });
10967
+ }
10968
+ }]);
10969
+ }();
10970
+
10256
10971
  const initMotionCommon = duration => ({
10257
10972
  animationDuration: duration,
10258
10973
  animationFillMode: 'both'
@@ -10472,6 +11187,13 @@ const initZoomMotion = (token, motionName) => {
10472
11187
  }];
10473
11188
  };
10474
11189
 
11190
+ const generateColor = color => {
11191
+ if (color instanceof AggregationColor) {
11192
+ return color;
11193
+ }
11194
+ return new AggregationColor(color);
11195
+ };
11196
+
10475
11197
  var OrderContext = /*#__PURE__*/a$m.createContext(null);
10476
11198
 
10477
11199
  var EMPTY_LIST = [];
@@ -10865,6 +11587,7 @@ function newMessages() {
10865
11587
  float: '%s is not a %s',
10866
11588
  regexp: '%s is not a valid %s',
10867
11589
  email: '%s is not a valid %s',
11590
+ tel: '%s is not a valid %s',
10868
11591
  url: '%s is not a valid %s',
10869
11592
  hex: '%s is not a valid %s'
10870
11593
  },
@@ -11003,7 +11726,7 @@ function format(template) {
11003
11726
  return template;
11004
11727
  }
11005
11728
  function isNativeStringType(type) {
11006
- return type === 'string' || type === 'url' || type === 'hex' || type === 'email' || type === 'date' || type === 'pattern';
11729
+ return type === 'string' || type === 'url' || type === 'hex' || type === 'email' || type === 'date' || type === 'pattern' || type === 'tel';
11007
11730
  }
11008
11731
  function isEmptyValue(value, type) {
11009
11732
  if (value === undefined || value === null) {
@@ -11307,6 +12030,13 @@ var pattern$1 = {
11307
12030
  // '^(?!mailto:)(?:(?:http|https|ftp)://|//)(?:\\S+(?::\\S*)?@)?(?:(?:(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[0-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|(?:(?:[a-z\\u00a1-\\uffff0-9]+-*)*[a-z\\u00a1-\\uffff0-9]+)(?:\\.(?:[a-z\\u00a1-\\uffff0-9]+-*)*[a-z\\u00a1-\\uffff0-9]+)*(?:\\.(?:[a-z\\u00a1-\\uffff]{2,})))|localhost)(?::\\d{2,5})?(?:(/|\\?|#)[^\\s]*)?$',
11308
12031
  // 'i',
11309
12032
  // ),
12033
+ /**
12034
+ * Phone number regex, support country code, brackets, spaces, and dashes (or non-breaking hyphen \u2011).
12035
+ * @see https://regexr.com/3c53v
12036
+ * @see https://ihateregex.io/expr/phone/
12037
+ * @see https://developers.google.com/style/phone-numbers using non-breaking hyphen \u2011
12038
+ */
12039
+ tel: /^(\+[0-9]{1,3}[-\s\u2011]?)?(\([0-9]{1,4}\)[-\s\u2011]?)?([0-9]+[-\s\u2011]?)*[0-9]+$/,
11310
12040
  hex: /^#?([a-f0-9]{6}|[a-f0-9]{3})$/i
11311
12041
  };
11312
12042
  var types = {
@@ -11347,6 +12077,9 @@ var types = {
11347
12077
  email: function email(value) {
11348
12078
  return typeof value === 'string' && value.length <= 320 && !!value.match(pattern$1.email);
11349
12079
  },
12080
+ tel: function tel(value) {
12081
+ return typeof value === 'string' && value.length <= 32 && !!value.match(pattern$1.tel);
12082
+ },
11350
12083
  url: function url(value) {
11351
12084
  return typeof value === 'string' && value.length <= 2048 && !!value.match(getUrlRegex());
11352
12085
  },
@@ -11359,7 +12092,7 @@ var type$1 = function type(rule, value, source, errors, options) {
11359
12092
  required$1(rule, value, source, errors, options);
11360
12093
  return;
11361
12094
  }
11362
- var custom = ['integer', 'float', 'array', 'regexp', 'object', 'method', 'email', 'number', 'date', 'url', 'hex'];
12095
+ var custom = ['integer', 'float', 'array', 'regexp', 'object', 'method', 'email', 'tel', 'number', 'date', 'url', 'hex'];
11363
12096
  var ruleType = rule.type;
11364
12097
  if (custom.indexOf(ruleType) > -1) {
11365
12098
  if (!types[ruleType](value)) {
@@ -11653,6 +12386,7 @@ var validators = {
11653
12386
  url: type,
11654
12387
  hex: type,
11655
12388
  email: type,
12389
+ tel: type,
11656
12390
  required: required,
11657
12391
  any: any
11658
12392
  };
@@ -11804,7 +12538,7 @@ var Schema = /*#__PURE__*/function () {
11804
12538
  if (!options.suppressWarning && errorList.length) {
11805
12539
  Schema.warning('async-validator:', errorList);
11806
12540
  }
11807
- if (errorList.length && rule.message !== undefined) {
12541
+ if (errorList.length && rule.message !== undefined && rule.message !== null) {
11808
12542
  errorList = [].concat(rule.message);
11809
12543
  }
11810
12544
 
@@ -12070,7 +12804,7 @@ function _validateRule() {
12070
12804
  });
12071
12805
  }
12072
12806
  case 18:
12073
- if (!(!result.length && subRuleField)) {
12807
+ if (!(!result.length && subRuleField && Array.isArray(value) && value.length > 0)) {
12074
12808
  _context2.next = 23;
12075
12809
  break;
12076
12810
  }
@@ -15407,12 +16141,12 @@ function useAlign(open, popupEle, target, placement, builtinPlacements, popupAli
15407
16141
  var offsetX4Right = popupMirrorRect.right - popupRect.x - (nextOffsetX + popupRect.width);
15408
16142
  var offsetY4Bottom = popupMirrorRect.bottom - popupRect.y - (nextOffsetY + popupRect.height);
15409
16143
  if (_scaleX === 1) {
15410
- nextOffsetX = Math.round(nextOffsetX);
15411
- offsetX4Right = Math.round(offsetX4Right);
16144
+ nextOffsetX = Math.floor(nextOffsetX);
16145
+ offsetX4Right = Math.floor(offsetX4Right);
15412
16146
  }
15413
16147
  if (_scaleY === 1) {
15414
- nextOffsetY = Math.round(nextOffsetY);
15415
- offsetY4Bottom = Math.round(offsetY4Bottom);
16148
+ nextOffsetY = Math.floor(nextOffsetY);
16149
+ offsetY4Bottom = Math.floor(offsetY4Bottom);
15416
16150
  }
15417
16151
  var nextOffsetInfo = {
15418
16152
  ready: true,
@@ -15962,6 +16696,10 @@ function generateTrigger() {
15962
16696
  cloneProps.className = classNames(originChildProps.className, className);
15963
16697
  }
15964
16698
 
16699
+ // ============================ Perf ============================
16700
+ var renderedRef = a$m.useRef(false);
16701
+ renderedRef.current || (renderedRef.current = forceRender || mergedOpen || inMotion);
16702
+
15965
16703
  // =========================== Render ===========================
15966
16704
  var mergedChildrenProps = _objectSpread2(_objectSpread2({}, originChildProps), cloneProps);
15967
16705
 
@@ -15996,7 +16734,7 @@ function generateTrigger() {
15996
16734
  onResize: onTargetResize
15997
16735
  }, /*#__PURE__*/a$m.createElement(TriggerWrapper, {
15998
16736
  getTriggerDOMNode: getTriggerDOMNode
15999
- }, triggerNode)), /*#__PURE__*/a$m.createElement(TriggerContext.Provider, {
16737
+ }, triggerNode)), renderedRef.current && /*#__PURE__*/a$m.createElement(TriggerContext.Provider, {
16000
16738
  value: context
16001
16739
  }, /*#__PURE__*/a$m.createElement(Popup$1, {
16002
16740
  portal: PortalComponent,
@@ -16166,7 +16904,7 @@ var placements = {
16166
16904
  };
16167
16905
 
16168
16906
  var _excluded = ["overlayClassName", "trigger", "mouseEnterDelay", "mouseLeaveDelay", "overlayStyle", "prefixCls", "children", "onVisibleChange", "afterVisibleChange", "transitionName", "animation", "motion", "placement", "align", "destroyTooltipOnHide", "defaultVisible", "getTooltipContainer", "overlayInnerStyle", "arrowContent", "overlay", "id", "showArrow", "classNames", "styles"];
16169
- var Tooltip$2 = function Tooltip(props, ref) {
16907
+ var Tooltip$3 = function Tooltip(props, ref) {
16170
16908
  var overlayClassName = props.overlayClassName,
16171
16909
  _props$trigger = props.trigger,
16172
16910
  trigger = _props$trigger === void 0 ? ['hover'] : _props$trigger,
@@ -16249,7 +16987,7 @@ var Tooltip$2 = function Tooltip(props, ref) {
16249
16987
  arrow: showArrow
16250
16988
  }, extraProps), getChildren());
16251
16989
  };
16252
- var Tooltip$3 = /*#__PURE__*/forwardRef(Tooltip$2);
16990
+ var Tooltip$2 = /*#__PURE__*/forwardRef(Tooltip$3);
16253
16991
 
16254
16992
  function getArrowToken(token) {
16255
16993
  const {
@@ -16587,6 +17325,11 @@ function getPlacements(config) {
16587
17325
  borderRadius} = config;
16588
17326
  const halfArrowWidth = arrowWidth / 2;
16589
17327
  const placementMap = {};
17328
+ // Dynamic offset
17329
+ const arrowOffset = getArrowOffsetToken({
17330
+ contentRadius: borderRadius,
17331
+ limitVerticalRadius: true
17332
+ });
16590
17333
  Object.keys(PlacementAlignMap).forEach(key => {
16591
17334
  const template = arrowPointAtCenter && ArrowCenterPlacementAlignMap[key] || PlacementAlignMap[key];
16592
17335
  const placementInfo = Object.assign(Object.assign({}, template), {
@@ -16621,11 +17364,6 @@ function getPlacements(config) {
16621
17364
  placementInfo.offset[0] = halfArrowWidth + offset;
16622
17365
  break;
16623
17366
  }
16624
- // Dynamic offset
16625
- const arrowOffset = getArrowOffsetToken({
16626
- contentRadius: borderRadius,
16627
- limitVerticalRadius: true
16628
- });
16629
17367
  if (arrowPointAtCenter) {
16630
17368
  switch (key) {
16631
17369
  case 'topLeft':
@@ -16697,7 +17435,7 @@ const genTooltipStyle = token => {
16697
17435
  minWidth: centerAlignMinWidth,
16698
17436
  minHeight: controlHeight,
16699
17437
  padding: `${unit$1(token.calc(paddingSM).div(2).equal())} ${unit$1(paddingXS)}`,
16700
- color: tooltipColor,
17438
+ color: `var(--ant-tooltip-color, ${tooltipColor})`,
16701
17439
  textAlign: 'start',
16702
17440
  textDecoration: 'none',
16703
17441
  wordWrap: 'break-word',
@@ -16800,8 +17538,12 @@ function parseColor(prefixCls, color) {
16800
17538
  });
16801
17539
  const overlayStyle = {};
16802
17540
  const arrowStyle = {};
17541
+ const rgb = generateColor(color).toRgb();
17542
+ const luminance = (0.299 * rgb.r + 0.587 * rgb.g + 0.114 * rgb.b) / 255;
17543
+ const textColor = luminance < 0.5 ? '#FFF' : '#000';
16803
17544
  if (color && !isInternalColor) {
16804
17545
  overlayStyle.background = color;
17546
+ overlayStyle['--ant-tooltip-color'] = textColor;
16805
17547
  // @ts-ignore
16806
17548
  arrowStyle['--antd-arrow-background-color'] = color;
16807
17549
  }
@@ -16871,7 +17613,7 @@ const InternalTooltip = /*#__PURE__*/a$m.forwardRef((props, ref) => {
16871
17613
  builtinPlacements,
16872
17614
  arrowPointAtCenter = false,
16873
17615
  autoAdjustOverflow = true,
16874
- motion,
17616
+ motion: _motion,
16875
17617
  getPopupContainer,
16876
17618
  placement = 'top',
16877
17619
  mouseEnterDelay = 0.1,
@@ -16980,7 +17722,7 @@ const InternalTooltip = /*#__PURE__*/a$m.forwardRef((props, ref) => {
16980
17722
  const bodyClassNames = classNames(contextClassNames.body, tooltipClassNames === null || tooltipClassNames === void 0 ? void 0 : tooltipClassNames.body);
16981
17723
  // ============================ zIndex ============================
16982
17724
  const [zIndex, contextZIndex] = useZIndex('Tooltip', restProps.zIndex);
16983
- const content = /*#__PURE__*/a$m.createElement(Tooltip$3, Object.assign({}, restProps, {
17725
+ const content = /*#__PURE__*/a$m.createElement(Tooltip$2, Object.assign({}, restProps, {
16984
17726
  zIndex: zIndex,
16985
17727
  showArrow: mergedShowArrow,
16986
17728
  placement: placement,
@@ -17454,7 +18196,7 @@ const PasswordInput = ({ id, className, htmlProps, label, placeholder = "Enter P
17454
18196
  a__default.createElement(CustomIconButton$2, { variant: "tertiary", iconName: show ? "eye" : "eye-slash", ariaLabel: show ? "Hide" : "Show", onClick: () => setShow(!show), disabled: disabled })));
17455
18197
  };
17456
18198
 
17457
- const formatDynamicNumbersWithCommas = (num, decimalPlaces) => {
18199
+ const formatDynamicNumbersWithCommas = (num, decimalPlaces, isDegrees) => {
17458
18200
  const onlyDigitNum = num.toString().replace(/[^\d.-]/g, "");
17459
18201
  const decimalEnding = onlyDigitNum.endsWith(".");
17460
18202
  const zeroEnding = onlyDigitNum.includes(".") && onlyDigitNum.endsWith("0");
@@ -17464,21 +18206,21 @@ const formatDynamicNumbersWithCommas = (num, decimalPlaces) => {
17464
18206
  decimalTrailingZeros = match ? match[0] : "";
17465
18207
  }
17466
18208
  const decimalZero = onlyDigitNum.endsWith(`.${decimalTrailingZeros.length > 0 ? decimalTrailingZeros : "0"}`);
17467
- if (onlyDigitNum === "" || onlyDigitNum === "-" || onlyDigitNum === ".") {
17468
- return onlyDigitNum;
18209
+ if (onlyDigitNum === "-" || onlyDigitNum === ".") {
18210
+ return `${onlyDigitNum}${isDegrees ? "°" : ""}`;
17469
18211
  }
17470
- if (isNaN(Number(onlyDigitNum))) {
18212
+ if (isNaN(Number(onlyDigitNum)) || onlyDigitNum === "") {
17471
18213
  return "";
17472
18214
  }
17473
18215
  return onlyDigitNum
17474
18216
  ? `${Number(onlyDigitNum).toLocaleString("en-US", {
17475
18217
  minimumFractionDigits: 0,
17476
18218
  maximumFractionDigits: decimalPlaces,
17477
- })}${decimalEnding ? "." : ""}${decimalZero ? "." : ""}${zeroEnding ? `${decimalTrailingZeros}` : ""}`
18219
+ })}${decimalEnding ? "." : ""}${decimalZero ? "." : ""}${zeroEnding ? `${decimalTrailingZeros}` : ""}${isDegrees ? "°" : ""}`
17478
18220
  : "";
17479
18221
  };
17480
18222
 
17481
- const NumberInput = ({ id, className, htmlProps, leftCategory, rightCategory, label, onChange, onBlur, onFocus, value, isRequired, maxLength, tooltipText, helperText, endIcon, placeholder = "0", textAlign = "left", isTruncated = false, helperTextAffectLayout = true, hideLabel = false, disabled = false, isLoading = false, hasError = false, thousandSeparator = true, decimalPlaces = 0, allowNegativeNumbers = false, ariaDescribedBy, enableAutocomplete = false, }) => {
18223
+ const NumberInput = ({ id, className, htmlProps, leftCategory, rightCategory, label, onChange, onBlur, onFocus, value, isRequired, maxLength, tooltipText, helperText, endIcon, placeholder = "0", textAlign = "left", isTruncated = false, helperTextAffectLayout = true, hideLabel = false, disabled = false, isLoading = false, hasError = false, thousandSeparator = true, decimalPlaces = 0, allowNegativeNumbers = false, ariaDescribedBy, enableAutocomplete = false, isDegrees = false, }) => {
17482
18224
  const containerProps = {
17483
18225
  id,
17484
18226
  label,
@@ -17497,7 +18239,25 @@ const NumberInput = ({ id, className, htmlProps, leftCategory, rightCategory, la
17497
18239
  };
17498
18240
  const [inputValue, setInputValue] = useState("");
17499
18241
  const [placeholderText, setPlaceholderText] = useState(placeholder);
18242
+ const ref = useRef(null);
17500
18243
  const valueToUse = value ?? inputValue;
18244
+ const moveCursorBeforeDegree = () => {
18245
+ const pos = ref.current?.selectionStart ?? 0;
18246
+ const maxPos = (ref.current && ref.current.value.length - 1) ?? 0;
18247
+ if (pos > maxPos && isDegrees) {
18248
+ requestAnimationFrame(() => {
18249
+ const pos = ref.current && ref.current.value.length - 1;
18250
+ ref.current?.setSelectionRange(pos, pos);
18251
+ });
18252
+ }
18253
+ };
18254
+ const handleSelect = (e) => {
18255
+ const pos = e.currentTarget.selectionStart ?? 0;
18256
+ const maxPos = e.currentTarget.value.length - 1;
18257
+ if (pos > maxPos && isDegrees) {
18258
+ e.currentTarget.setSelectionRange(maxPos, maxPos);
18259
+ }
18260
+ };
17501
18261
  const handleKeyDown = (e) => {
17502
18262
  if (e.key === "," ||
17503
18263
  (e.key === "." && decimalPlaces === 0) ||
@@ -17508,10 +18268,14 @@ const NumberInput = ({ id, className, htmlProps, leftCategory, rightCategory, la
17508
18268
  }
17509
18269
  };
17510
18270
  const handleChange = (e) => {
18271
+ moveCursorBeforeDegree();
17511
18272
  const value = e.target.value;
17512
- const inputDecimalPlaces = value.includes(".")
18273
+ let inputDecimalPlaces = value.includes(".")
17513
18274
  ? value.split(".")[1].length
17514
18275
  : 0;
18276
+ if (isDegrees && inputDecimalPlaces > 0) {
18277
+ inputDecimalPlaces -= 1;
18278
+ }
17515
18279
  if (e.currentTarget.checkValidity() &&
17516
18280
  inputDecimalPlaces <= decimalPlaces) {
17517
18281
  setInputValue(value);
@@ -17526,19 +18290,19 @@ const NumberInput = ({ id, className, htmlProps, leftCategory, rightCategory, la
17526
18290
  const handleFocus = (e) => {
17527
18291
  onFocus?.(e.target.value);
17528
18292
  !onFocus && setPlaceholderText("");
18293
+ isDegrees && moveCursorBeforeDegree();
17529
18294
  };
17530
18295
  return (a__default.createElement(TextFieldContainer, { ...containerProps },
17531
- a__default.createElement(TextFieldInput, { autoComplete: enableAutocomplete ? "on" : "off", "aria-describedby": `${id}-helper-text ${ariaDescribedBy}`, type: "text", inputMode: "numeric",
17532
- // prettier-ignore
17533
- pattern: allowNegativeNumbers ? "^[\\d,\\.\\-]*$" : "^[\\d,\\.]*$", id: `${id}-text-field`, disabled: disabled || isLoading, placeholder: placeholderText, onChange: handleChange, onBlur: handleBlur, onFocus: handleFocus, onKeyDown: handleKeyDown, value: thousandSeparator
17534
- ? formatDynamicNumbersWithCommas(valueToUse, decimalPlaces)
18296
+ a__default.createElement(TextFieldInput, { ref: ref, autoComplete: enableAutocomplete ? "on" : "off", "aria-describedby": `${id}-helper-text ${ariaDescribedBy}`, type: "text", inputMode: "numeric", pattern: allowNegativeNumbers ? "^[\\d,.\\-°]*$" : "^[\\d,.°]*$", id: `${id}-text-field`, disabled: disabled || isLoading, placeholder: placeholderText, onChange: handleChange, onBlur: handleBlur, onFocus: handleFocus, onKeyDown: handleKeyDown, onClick: isDegrees ? moveCursorBeforeDegree : undefined, onKeyUp: isDegrees ? moveCursorBeforeDegree : undefined, onSelect: handleSelect, value: thousandSeparator
18297
+ ? formatDynamicNumbersWithCommas(valueToUse, decimalPlaces, isDegrees)
17535
18298
  : valueToUse, maxLength: maxLength &&
17536
18299
  maxLength +
17537
18300
  (thousandSeparator
17538
18301
  ? Math.floor(valueToUse.toString().split(".")[0].length / 4)
17539
18302
  : 0) +
17540
18303
  (inputValue.includes(".") ? 1 : 0) +
17541
- (inputValue.includes("-") ? 1 : 0), "$isTruncated": isTruncated, "$textAlign": textAlign, "$isDisabled": disabled, "$isLoading": isLoading, ...htmlProps })));
18304
+ (inputValue.includes("-") ? 1 : 0) +
18305
+ (inputValue.includes("°") ? 1 : 0), "$isTruncated": isTruncated, "$textAlign": textAlign, "$isDisabled": disabled, "$isLoading": isLoading, ...htmlProps })));
17542
18306
  };
17543
18307
 
17544
18308
  /**
@@ -22283,9 +23047,12 @@ const NotificationBubble = styled.span `
22283
23047
  `;
22284
23048
 
22285
23049
  const Tab = ({ id, className, onClick, htmlProps, label, variant = "light", active = false, notifications, }) => {
23050
+ const notificationText = typeof notifications === "number" && notifications <= 0
23051
+ ? undefined
23052
+ : notifications;
22286
23053
  return (a__default.createElement(TabButton, { id: id, "$variant": variant, className: `${className} ${active && "active"}`, onClick: () => onClick?.(label), ...htmlProps },
22287
23054
  label,
22288
- !!(notifications && notifications > 0) && (a__default.createElement(NotificationBubble, { "$isActive": active }, notifications))));
23055
+ !!notificationText && (a__default.createElement(NotificationBubble, { "$isActive": active }, notificationText))));
22289
23056
  };
22290
23057
 
22291
23058
  const Tabs = ({ id, className, tabs, htmlProps, onTabClick, defaultActiveTab, variant = "light", isPill, }) => {