@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.
- package/dist/cjs/index.js +852 -85
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/components/HelperText/styles.d.ts +3 -3
- package/dist/cjs/types/components/IconButton/styles.d.ts +7 -1
- package/dist/cjs/types/components/Label/styles.d.ts +4 -4
- package/dist/cjs/types/components/Loader/styles.d.ts +1 -1
- package/dist/cjs/types/components/OrderStatus/styles.d.ts +3 -3
- package/dist/cjs/types/components/Pagination/styles.d.ts +14 -12
- package/dist/cjs/types/components/PaymentStatus/styles.d.ts +3 -3
- package/dist/cjs/types/components/StellaButton/styles.d.ts +1 -1
- package/dist/cjs/types/components/Sync/styles.d.ts +3 -3
- package/dist/cjs/types/components/Table/styles.d.ts +60 -33
- package/dist/cjs/types/components/TableUnitsAndTotals/styles.d.ts +7 -5
- package/dist/cjs/types/components/Tabs/Styles.d.ts +3 -3
- package/dist/cjs/types/components/Tabs/Tab.d.ts +1 -1
- package/dist/cjs/types/components/Tabs/types.d.ts +1 -1
- package/dist/cjs/types/components/TextField/NumberInput/NumberInput.d.ts +1 -1
- package/dist/cjs/types/components/TextField/NumberInput/types.d.ts +1 -0
- package/dist/cjs/types/components/TextField/PasswordInput/styles.d.ts +1 -1
- package/dist/cjs/types/components/TextField/styles.d.ts +5 -5
- package/dist/cjs/types/shared/utils/numberHelpers.d.ts +1 -1
- package/dist/esm/index.esm.js +855 -88
- package/dist/esm/index.esm.js.map +1 -1
- package/dist/esm/types/components/HelperText/styles.d.ts +3 -3
- package/dist/esm/types/components/IconButton/styles.d.ts +7 -1
- package/dist/esm/types/components/Label/styles.d.ts +4 -4
- package/dist/esm/types/components/Loader/styles.d.ts +1 -1
- package/dist/esm/types/components/OrderStatus/styles.d.ts +3 -3
- package/dist/esm/types/components/Pagination/styles.d.ts +14 -12
- package/dist/esm/types/components/PaymentStatus/styles.d.ts +3 -3
- package/dist/esm/types/components/StellaButton/styles.d.ts +1 -1
- package/dist/esm/types/components/Sync/styles.d.ts +3 -3
- package/dist/esm/types/components/Table/styles.d.ts +60 -33
- package/dist/esm/types/components/TableUnitsAndTotals/styles.d.ts +7 -5
- package/dist/esm/types/components/Tabs/Styles.d.ts +3 -3
- package/dist/esm/types/components/Tabs/Tab.d.ts +1 -1
- package/dist/esm/types/components/Tabs/types.d.ts +1 -1
- package/dist/esm/types/components/TextField/NumberInput/NumberInput.d.ts +1 -1
- package/dist/esm/types/components/TextField/NumberInput/types.d.ts +1 -0
- package/dist/esm/types/components/TextField/PasswordInput/styles.d.ts +1 -1
- package/dist/esm/types/components/TextField/styles.d.ts +5 -5
- package/dist/esm/types/shared/utils/numberHelpers.d.ts +1 -1
- package/dist/index.d.ts +3 -2
- package/package.json +3 -3
package/dist/cjs/index.js
CHANGED
|
@@ -4527,6 +4527,7 @@ var Entity = /*#__PURE__*/function () {
|
|
|
4527
4527
|
_defineProperty(this, "instanceId", void 0);
|
|
4528
4528
|
/** @private Internal cache map. Do not access this directly */
|
|
4529
4529
|
_defineProperty(this, "cache", new Map());
|
|
4530
|
+
_defineProperty(this, "extracted", new Set());
|
|
4530
4531
|
this.instanceId = instanceId;
|
|
4531
4532
|
}
|
|
4532
4533
|
_createClass(Entity, [{
|
|
@@ -4856,13 +4857,12 @@ function unit$1(num) {
|
|
|
4856
4857
|
return num;
|
|
4857
4858
|
}
|
|
4858
4859
|
function toStyleStr(style, tokenKey, styleId) {
|
|
4859
|
-
var _objectSpread2$1;
|
|
4860
4860
|
var customizeAttrs = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
4861
4861
|
var plain = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
|
4862
4862
|
if (plain) {
|
|
4863
4863
|
return style;
|
|
4864
4864
|
}
|
|
4865
|
-
var attrs = _objectSpread2(_objectSpread2({}, customizeAttrs), {}, (
|
|
4865
|
+
var attrs = _objectSpread2(_objectSpread2({}, customizeAttrs), {}, _defineProperty(_defineProperty({}, ATTR_TOKEN, tokenKey), ATTR_MARK, styleId));
|
|
4866
4866
|
var attrStr = Object.keys(attrs).map(function (attr) {
|
|
4867
4867
|
var val = attrs[attr];
|
|
4868
4868
|
return val ? "".concat(attr, "=\"").concat(val, "\"") : null;
|
|
@@ -5067,7 +5067,6 @@ onCacheEffect) {
|
|
|
5067
5067
|
}, /* eslint-disable react-hooks/exhaustive-deps */
|
|
5068
5068
|
[fullPathStr]
|
|
5069
5069
|
/* eslint-enable */);
|
|
5070
|
-
|
|
5071
5070
|
var cacheEntity = globalCache.opGet(fullPathStr);
|
|
5072
5071
|
|
|
5073
5072
|
// HMR clean the cache but not trigger `useMemo` again
|
|
@@ -5147,14 +5146,13 @@ var TOKEN_THRESHOLD = 0;
|
|
|
5147
5146
|
// Remove will check current keys first
|
|
5148
5147
|
function cleanTokenStyle(tokenKey, instanceId) {
|
|
5149
5148
|
tokenKeys.set(tokenKey, (tokenKeys.get(tokenKey) || 0) - 1);
|
|
5150
|
-
var
|
|
5151
|
-
|
|
5152
|
-
|
|
5153
|
-
return count <= 0;
|
|
5149
|
+
var cleanableKeyList = new Set();
|
|
5150
|
+
tokenKeys.forEach(function (value, key) {
|
|
5151
|
+
if (value <= 0) cleanableKeyList.add(key);
|
|
5154
5152
|
});
|
|
5155
5153
|
|
|
5156
5154
|
// Should keep tokens under threshold for not to insert style too often
|
|
5157
|
-
if (
|
|
5155
|
+
if (tokenKeys.size - cleanableKeyList.size > TOKEN_THRESHOLD) {
|
|
5158
5156
|
cleanableKeyList.forEach(function (key) {
|
|
5159
5157
|
removeStyleTags(key, instanceId);
|
|
5160
5158
|
tokenKeys.delete(key);
|
|
@@ -5363,16 +5361,6 @@ function replace (value, pattern, replacement) {
|
|
|
5363
5361
|
return value.replace(pattern, replacement)
|
|
5364
5362
|
}
|
|
5365
5363
|
|
|
5366
|
-
/**
|
|
5367
|
-
* @param {string} value
|
|
5368
|
-
* @param {string} search
|
|
5369
|
-
* @param {number} position
|
|
5370
|
-
* @return {number}
|
|
5371
|
-
*/
|
|
5372
|
-
function indexof (value, search, position) {
|
|
5373
|
-
return value.indexOf(search, position)
|
|
5374
|
-
}
|
|
5375
|
-
|
|
5376
5364
|
/**
|
|
5377
5365
|
* @param {string} value
|
|
5378
5366
|
* @param {number} index
|
|
@@ -5659,6 +5647,7 @@ function parse (value, root, parent, rule, rules, rulesets, pseudo, points, decl
|
|
|
5659
5647
|
var variable = 1;
|
|
5660
5648
|
var scanning = 1;
|
|
5661
5649
|
var ampersand = 1;
|
|
5650
|
+
var parens = 0;
|
|
5662
5651
|
var character = 0;
|
|
5663
5652
|
var type = '';
|
|
5664
5653
|
var props = rules;
|
|
@@ -5670,17 +5659,23 @@ function parse (value, root, parent, rule, rules, rulesets, pseudo, points, decl
|
|
|
5670
5659
|
switch (previous = character, character = next()) {
|
|
5671
5660
|
// (
|
|
5672
5661
|
case 40:
|
|
5673
|
-
if (previous != 108 && charat(characters, length - 1) == 58)
|
|
5674
|
-
|
|
5675
|
-
|
|
5676
|
-
|
|
5677
|
-
|
|
5662
|
+
if (previous != 108 && charat(characters, length - 1) == 58) parens++, characters += '(';
|
|
5663
|
+
else characters += delimit(character);
|
|
5664
|
+
break
|
|
5665
|
+
// )
|
|
5666
|
+
case 41:
|
|
5667
|
+
parens--, characters += ')';
|
|
5668
|
+
break
|
|
5678
5669
|
// " ' [
|
|
5679
5670
|
case 34: case 39: case 91:
|
|
5680
5671
|
characters += delimit(character);
|
|
5681
5672
|
break
|
|
5682
5673
|
// \t \n \r \s
|
|
5683
5674
|
case 9: case 10: case 13: case 32:
|
|
5675
|
+
if (parens > 0) {
|
|
5676
|
+
characters += from(character);
|
|
5677
|
+
break
|
|
5678
|
+
}
|
|
5684
5679
|
characters += whitespace$1(previous);
|
|
5685
5680
|
break
|
|
5686
5681
|
// \
|
|
@@ -5703,12 +5698,16 @@ function parse (value, root, parent, rule, rules, rulesets, pseudo, points, decl
|
|
|
5703
5698
|
points[index++] = strlen(characters) * ampersand;
|
|
5704
5699
|
// } ; \0
|
|
5705
5700
|
case 125 * variable: case 59: case 0:
|
|
5701
|
+
if (parens > 0 && character) {
|
|
5702
|
+
characters += from(character);
|
|
5703
|
+
break
|
|
5704
|
+
}
|
|
5706
5705
|
switch (character) {
|
|
5707
5706
|
// \0 }
|
|
5708
5707
|
case 0: case 125: scanning = 0;
|
|
5709
5708
|
// ;
|
|
5710
5709
|
case 59 + offset: if (ampersand == -1) characters = replace(characters, /\f/g, '');
|
|
5711
|
-
if (property > 0 && (strlen(characters) - length ||
|
|
5710
|
+
if (property > 0 && (strlen(characters) - length || variable === 0))
|
|
5712
5711
|
append(property > 32 ? declaration(characters + ';', rule, parent, length - 1, declarations) : declaration(replace(characters, ' ', '') + ';', rule, parent, length - 2, declarations), declarations);
|
|
5713
5712
|
break
|
|
5714
5713
|
// @ ;
|
|
@@ -5757,6 +5756,7 @@ function parse (value, root, parent, rule, rules, rulesets, pseudo, points, decl
|
|
|
5757
5756
|
break
|
|
5758
5757
|
// ,
|
|
5759
5758
|
case 44:
|
|
5759
|
+
if (parens > 0) break
|
|
5760
5760
|
points[index++] = (strlen(characters) - 1) * ampersand, ampersand = 1;
|
|
5761
5761
|
break
|
|
5762
5762
|
// @
|
|
@@ -6229,7 +6229,8 @@ function useStyleRegister(info, styleFn) {
|
|
|
6229
6229
|
styleId = _ref3[2];
|
|
6230
6230
|
if ((fromHMR || autoClear) && isClientSide) {
|
|
6231
6231
|
removeCSS(styleId, {
|
|
6232
|
-
mark: ATTR_MARK
|
|
6232
|
+
mark: ATTR_MARK,
|
|
6233
|
+
attachTo: container
|
|
6233
6234
|
});
|
|
6234
6235
|
}
|
|
6235
6236
|
},
|
|
@@ -6303,8 +6304,7 @@ function useStyleRegister(info, styleFn) {
|
|
|
6303
6304
|
if (!ssrInline || isMergedClientSide || !defaultCache) {
|
|
6304
6305
|
styleNode = /*#__PURE__*/a__namespace.createElement(Empty, null);
|
|
6305
6306
|
} else {
|
|
6306
|
-
|
|
6307
|
-
styleNode = /*#__PURE__*/a__namespace.createElement("style", _extends({}, (_ref6 = {}, _defineProperty(_ref6, ATTR_TOKEN, cachedTokenKey), _defineProperty(_ref6, ATTR_MARK, cachedStyleId), _ref6), {
|
|
6307
|
+
styleNode = /*#__PURE__*/a__namespace.createElement("style", _extends({}, _defineProperty(_defineProperty({}, ATTR_TOKEN, cachedTokenKey), ATTR_MARK, cachedStyleId), {
|
|
6308
6308
|
dangerouslySetInnerHTML: {
|
|
6309
6309
|
__html: cachedStyleStr
|
|
6310
6310
|
}
|
|
@@ -6391,7 +6391,8 @@ var useCSSVarRegister = function useCSSVarRegister(config, fn) {
|
|
|
6391
6391
|
styleId = _ref2[2];
|
|
6392
6392
|
if (isClientSide) {
|
|
6393
6393
|
removeCSS(styleId, {
|
|
6394
|
-
mark: ATTR_MARK
|
|
6394
|
+
mark: ATTR_MARK,
|
|
6395
|
+
attachTo: container
|
|
6395
6396
|
});
|
|
6396
6397
|
}
|
|
6397
6398
|
}, function (_ref3) {
|
|
@@ -6436,8 +6437,7 @@ var extract = function extract(cache, effectStyles, options) {
|
|
|
6436
6437
|
return [order, styleId, styleText];
|
|
6437
6438
|
};
|
|
6438
6439
|
|
|
6439
|
-
|
|
6440
|
-
(_ExtractStyleFns = {}, _defineProperty(_ExtractStyleFns, STYLE_PREFIX, extract$1), _defineProperty(_ExtractStyleFns, TOKEN_PREFIX, extract$2), _defineProperty(_ExtractStyleFns, CSS_VAR_PREFIX, extract), _ExtractStyleFns);
|
|
6440
|
+
_defineProperty(_defineProperty(_defineProperty({}, STYLE_PREFIX, extract$1), TOKEN_PREFIX, extract$2), CSS_VAR_PREFIX, extract);
|
|
6441
6441
|
|
|
6442
6442
|
var Keyframe = /*#__PURE__*/function () {
|
|
6443
6443
|
function Keyframe(name, style) {
|
|
@@ -8025,7 +8025,7 @@ function useMergedState(defaultStateValue, option) {
|
|
|
8025
8025
|
} else if (hasValue(defaultValue)) {
|
|
8026
8026
|
return typeof defaultValue === 'function' ? defaultValue() : defaultValue;
|
|
8027
8027
|
} else {
|
|
8028
|
-
return defaultStateValue;
|
|
8028
|
+
return typeof defaultStateValue === 'function' ? defaultStateValue() : defaultStateValue;
|
|
8029
8029
|
}
|
|
8030
8030
|
}),
|
|
8031
8031
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -8535,7 +8535,7 @@ function genStyleUtils(config) {
|
|
|
8535
8535
|
|
|
8536
8536
|
const PresetColors = ['blue', 'purple', 'cyan', 'green', 'magenta', 'pink', 'red', 'orange', 'yellow', 'volcano', 'geekblue', 'lime', 'gold'];
|
|
8537
8537
|
|
|
8538
|
-
var version = '5.
|
|
8538
|
+
var version = '5.29.3';
|
|
8539
8539
|
|
|
8540
8540
|
function isStableColor(color) {
|
|
8541
8541
|
return color >= 0 && color <= 255;
|
|
@@ -8776,17 +8776,6 @@ const unitless = {
|
|
|
8776
8776
|
opacityImage: true
|
|
8777
8777
|
};
|
|
8778
8778
|
const ignore = {
|
|
8779
|
-
size: true,
|
|
8780
|
-
sizeSM: true,
|
|
8781
|
-
sizeLG: true,
|
|
8782
|
-
sizeMD: true,
|
|
8783
|
-
sizeXS: true,
|
|
8784
|
-
sizeXXS: true,
|
|
8785
|
-
sizeMS: true,
|
|
8786
|
-
sizeXL: true,
|
|
8787
|
-
sizeXXL: true,
|
|
8788
|
-
sizeUnit: true,
|
|
8789
|
-
sizeStep: true,
|
|
8790
8779
|
motionBase: true,
|
|
8791
8780
|
motionUnit: true
|
|
8792
8781
|
};
|
|
@@ -9720,8 +9709,8 @@ function diffKeys() {
|
|
|
9720
9709
|
return list;
|
|
9721
9710
|
}
|
|
9722
9711
|
|
|
9723
|
-
var _excluded$
|
|
9724
|
-
_excluded2 = ["status"];
|
|
9712
|
+
var _excluded$6 = ["component", "children", "onVisibleChanged", "onAllRemoved"],
|
|
9713
|
+
_excluded2$1 = ["status"];
|
|
9725
9714
|
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'];
|
|
9726
9715
|
/**
|
|
9727
9716
|
* Generate a CSSMotionList component with config
|
|
@@ -9778,7 +9767,7 @@ function genCSSMotionList(transitionSupport) {
|
|
|
9778
9767
|
children = _this$props.children,
|
|
9779
9768
|
_onVisibleChanged = _this$props.onVisibleChanged;
|
|
9780
9769
|
_this$props.onAllRemoved;
|
|
9781
|
-
var restProps = _objectWithoutProperties(_this$props, _excluded$
|
|
9770
|
+
var restProps = _objectWithoutProperties(_this$props, _excluded$6);
|
|
9782
9771
|
var Component = component || a__namespace.Fragment;
|
|
9783
9772
|
var motionProps = {};
|
|
9784
9773
|
MOTION_PROP_NAMES.forEach(function (prop) {
|
|
@@ -9788,7 +9777,7 @@ function genCSSMotionList(transitionSupport) {
|
|
|
9788
9777
|
delete restProps.keys;
|
|
9789
9778
|
return /*#__PURE__*/a__namespace.createElement(Component, restProps, keyEntities.map(function (_ref2, index) {
|
|
9790
9779
|
var status = _ref2.status,
|
|
9791
|
-
eventProps = _objectWithoutProperties(_ref2, _excluded2);
|
|
9780
|
+
eventProps = _objectWithoutProperties(_ref2, _excluded2$1);
|
|
9792
9781
|
var visible = status === STATUS_ADD || status === STATUS_KEEP;
|
|
9793
9782
|
return /*#__PURE__*/a__namespace.createElement(CSSMotion$1, _extends({}, motionProps, {
|
|
9794
9783
|
key: eventProps.key,
|
|
@@ -9951,19 +9940,17 @@ function _regeneratorDefine(e, r, n, t) {
|
|
|
9951
9940
|
i = 0;
|
|
9952
9941
|
}
|
|
9953
9942
|
_regeneratorDefine = function regeneratorDefine(e, r, n, t) {
|
|
9954
|
-
|
|
9943
|
+
function o(r, n) {
|
|
9944
|
+
_regeneratorDefine(e, r, function (e) {
|
|
9945
|
+
return this._invoke(r, n, e);
|
|
9946
|
+
});
|
|
9947
|
+
}
|
|
9948
|
+
r ? i ? i(e, r, {
|
|
9955
9949
|
value: n,
|
|
9956
9950
|
enumerable: !t,
|
|
9957
9951
|
configurable: !t,
|
|
9958
9952
|
writable: !t
|
|
9959
|
-
}) : e[r] = n;
|
|
9960
|
-
var o = function o(r, n) {
|
|
9961
|
-
_regeneratorDefine(e, r, function (e) {
|
|
9962
|
-
return this._invoke(r, n, e);
|
|
9963
|
-
});
|
|
9964
|
-
};
|
|
9965
|
-
o("next", 0), o("throw", 1), o("return", 2);
|
|
9966
|
-
}
|
|
9953
|
+
}) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2));
|
|
9967
9954
|
}, _regeneratorDefine(e, r, n, t);
|
|
9968
9955
|
}
|
|
9969
9956
|
|
|
@@ -10273,6 +10260,734 @@ const NoCompactStyle = props => {
|
|
|
10273
10260
|
}, children);
|
|
10274
10261
|
};
|
|
10275
10262
|
|
|
10263
|
+
var _excluded$5 = ["b"],
|
|
10264
|
+
_excluded2 = ["v"];
|
|
10265
|
+
var getRoundNumber = function getRoundNumber(value) {
|
|
10266
|
+
return Math.round(Number(value || 0));
|
|
10267
|
+
};
|
|
10268
|
+
var convertHsb2Hsv = function convertHsb2Hsv(color) {
|
|
10269
|
+
if (color instanceof FastColor) {
|
|
10270
|
+
return color;
|
|
10271
|
+
}
|
|
10272
|
+
if (color && _typeof(color) === 'object' && 'h' in color && 'b' in color) {
|
|
10273
|
+
var _ref = color,
|
|
10274
|
+
b = _ref.b,
|
|
10275
|
+
resets = _objectWithoutProperties(_ref, _excluded$5);
|
|
10276
|
+
return _objectSpread2(_objectSpread2({}, resets), {}, {
|
|
10277
|
+
v: b
|
|
10278
|
+
});
|
|
10279
|
+
}
|
|
10280
|
+
if (typeof color === 'string' && /hsb/.test(color)) {
|
|
10281
|
+
return color.replace(/hsb/, 'hsv');
|
|
10282
|
+
}
|
|
10283
|
+
return color;
|
|
10284
|
+
};
|
|
10285
|
+
var Color = /*#__PURE__*/function (_FastColor) {
|
|
10286
|
+
_inherits(Color, _FastColor);
|
|
10287
|
+
var _super = _createSuper(Color);
|
|
10288
|
+
function Color(color) {
|
|
10289
|
+
_classCallCheck(this, Color);
|
|
10290
|
+
return _super.call(this, convertHsb2Hsv(color));
|
|
10291
|
+
}
|
|
10292
|
+
_createClass(Color, [{
|
|
10293
|
+
key: "toHsbString",
|
|
10294
|
+
value: function toHsbString() {
|
|
10295
|
+
var hsb = this.toHsb();
|
|
10296
|
+
var saturation = getRoundNumber(hsb.s * 100);
|
|
10297
|
+
var lightness = getRoundNumber(hsb.b * 100);
|
|
10298
|
+
var hue = getRoundNumber(hsb.h);
|
|
10299
|
+
var alpha = hsb.a;
|
|
10300
|
+
var hsbString = "hsb(".concat(hue, ", ").concat(saturation, "%, ").concat(lightness, "%)");
|
|
10301
|
+
var hsbaString = "hsba(".concat(hue, ", ").concat(saturation, "%, ").concat(lightness, "%, ").concat(alpha.toFixed(alpha === 0 ? 0 : 2), ")");
|
|
10302
|
+
return alpha === 1 ? hsbString : hsbaString;
|
|
10303
|
+
}
|
|
10304
|
+
}, {
|
|
10305
|
+
key: "toHsb",
|
|
10306
|
+
value: function toHsb() {
|
|
10307
|
+
var _this$toHsv = this.toHsv(),
|
|
10308
|
+
v = _this$toHsv.v,
|
|
10309
|
+
resets = _objectWithoutProperties(_this$toHsv, _excluded2);
|
|
10310
|
+
return _objectSpread2(_objectSpread2({}, resets), {}, {
|
|
10311
|
+
b: v,
|
|
10312
|
+
a: this.a
|
|
10313
|
+
});
|
|
10314
|
+
}
|
|
10315
|
+
}]);
|
|
10316
|
+
return Color;
|
|
10317
|
+
}(FastColor);
|
|
10318
|
+
|
|
10319
|
+
var ColorPickerPrefixCls = 'rc-color-picker';
|
|
10320
|
+
var generateColor$1 = function generateColor(color) {
|
|
10321
|
+
if (color instanceof Color) {
|
|
10322
|
+
return color;
|
|
10323
|
+
}
|
|
10324
|
+
return new Color(color);
|
|
10325
|
+
};
|
|
10326
|
+
var defaultColor = generateColor$1('#1677ff');
|
|
10327
|
+
var calculateColor = function calculateColor(props) {
|
|
10328
|
+
var offset = props.offset,
|
|
10329
|
+
targetRef = props.targetRef,
|
|
10330
|
+
containerRef = props.containerRef,
|
|
10331
|
+
color = props.color,
|
|
10332
|
+
type = props.type;
|
|
10333
|
+
var _containerRef$current = containerRef.current.getBoundingClientRect(),
|
|
10334
|
+
width = _containerRef$current.width,
|
|
10335
|
+
height = _containerRef$current.height;
|
|
10336
|
+
var _targetRef$current$ge = targetRef.current.getBoundingClientRect(),
|
|
10337
|
+
targetWidth = _targetRef$current$ge.width,
|
|
10338
|
+
targetHeight = _targetRef$current$ge.height;
|
|
10339
|
+
var centerOffsetX = targetWidth / 2;
|
|
10340
|
+
var centerOffsetY = targetHeight / 2;
|
|
10341
|
+
var saturation = (offset.x + centerOffsetX) / width;
|
|
10342
|
+
var bright = 1 - (offset.y + centerOffsetY) / height;
|
|
10343
|
+
var hsb = color.toHsb();
|
|
10344
|
+
var alphaOffset = saturation;
|
|
10345
|
+
var hueOffset = (offset.x + centerOffsetX) / width * 360;
|
|
10346
|
+
if (type) {
|
|
10347
|
+
switch (type) {
|
|
10348
|
+
case 'hue':
|
|
10349
|
+
return generateColor$1(_objectSpread2(_objectSpread2({}, hsb), {}, {
|
|
10350
|
+
h: hueOffset <= 0 ? 0 : hueOffset
|
|
10351
|
+
}));
|
|
10352
|
+
case 'alpha':
|
|
10353
|
+
return generateColor$1(_objectSpread2(_objectSpread2({}, hsb), {}, {
|
|
10354
|
+
a: alphaOffset <= 0 ? 0 : alphaOffset
|
|
10355
|
+
}));
|
|
10356
|
+
}
|
|
10357
|
+
}
|
|
10358
|
+
return generateColor$1({
|
|
10359
|
+
h: hsb.h,
|
|
10360
|
+
s: saturation <= 0 ? 0 : saturation,
|
|
10361
|
+
b: bright >= 1 ? 1 : bright,
|
|
10362
|
+
a: hsb.a
|
|
10363
|
+
});
|
|
10364
|
+
};
|
|
10365
|
+
var calcOffset = function calcOffset(color, type) {
|
|
10366
|
+
var hsb = color.toHsb();
|
|
10367
|
+
switch (type) {
|
|
10368
|
+
case 'hue':
|
|
10369
|
+
return {
|
|
10370
|
+
x: hsb.h / 360 * 100,
|
|
10371
|
+
y: 50
|
|
10372
|
+
};
|
|
10373
|
+
case 'alpha':
|
|
10374
|
+
return {
|
|
10375
|
+
x: color.a * 100,
|
|
10376
|
+
y: 50
|
|
10377
|
+
};
|
|
10378
|
+
|
|
10379
|
+
// Picker panel
|
|
10380
|
+
default:
|
|
10381
|
+
return {
|
|
10382
|
+
x: hsb.s * 100,
|
|
10383
|
+
y: (1 - hsb.b) * 100
|
|
10384
|
+
};
|
|
10385
|
+
}
|
|
10386
|
+
};
|
|
10387
|
+
|
|
10388
|
+
var ColorBlock = function ColorBlock(_ref) {
|
|
10389
|
+
var color = _ref.color,
|
|
10390
|
+
prefixCls = _ref.prefixCls,
|
|
10391
|
+
className = _ref.className,
|
|
10392
|
+
style = _ref.style,
|
|
10393
|
+
onClick = _ref.onClick;
|
|
10394
|
+
var colorBlockCls = "".concat(prefixCls, "-color-block");
|
|
10395
|
+
return /*#__PURE__*/a$m.createElement("div", {
|
|
10396
|
+
className: classNames(colorBlockCls, className),
|
|
10397
|
+
style: style,
|
|
10398
|
+
onClick: onClick
|
|
10399
|
+
}, /*#__PURE__*/a$m.createElement("div", {
|
|
10400
|
+
className: "".concat(colorBlockCls, "-inner"),
|
|
10401
|
+
style: {
|
|
10402
|
+
background: color
|
|
10403
|
+
}
|
|
10404
|
+
}));
|
|
10405
|
+
};
|
|
10406
|
+
|
|
10407
|
+
function getPosition(e) {
|
|
10408
|
+
var obj = 'touches' in e ? e.touches[0] : e;
|
|
10409
|
+
var scrollXOffset = document.documentElement.scrollLeft || document.body.scrollLeft || window.pageXOffset;
|
|
10410
|
+
var scrollYOffset = document.documentElement.scrollTop || document.body.scrollTop || window.pageYOffset;
|
|
10411
|
+
return {
|
|
10412
|
+
pageX: obj.pageX - scrollXOffset,
|
|
10413
|
+
pageY: obj.pageY - scrollYOffset
|
|
10414
|
+
};
|
|
10415
|
+
}
|
|
10416
|
+
function useColorDrag(props) {
|
|
10417
|
+
var targetRef = props.targetRef,
|
|
10418
|
+
containerRef = props.containerRef,
|
|
10419
|
+
direction = props.direction,
|
|
10420
|
+
onDragChange = props.onDragChange,
|
|
10421
|
+
onDragChangeComplete = props.onDragChangeComplete,
|
|
10422
|
+
calculate = props.calculate,
|
|
10423
|
+
color = props.color,
|
|
10424
|
+
disabledDrag = props.disabledDrag;
|
|
10425
|
+
var _useState = a$m.useState({
|
|
10426
|
+
x: 0,
|
|
10427
|
+
y: 0
|
|
10428
|
+
}),
|
|
10429
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
10430
|
+
offsetValue = _useState2[0],
|
|
10431
|
+
setOffsetValue = _useState2[1];
|
|
10432
|
+
var mouseMoveRef = a$m.useRef(null);
|
|
10433
|
+
var mouseUpRef = a$m.useRef(null);
|
|
10434
|
+
|
|
10435
|
+
// Always get position from `color`
|
|
10436
|
+
a$m.useEffect(function () {
|
|
10437
|
+
setOffsetValue(calculate());
|
|
10438
|
+
}, [color]);
|
|
10439
|
+
a$m.useEffect(function () {
|
|
10440
|
+
return function () {
|
|
10441
|
+
document.removeEventListener('mousemove', mouseMoveRef.current);
|
|
10442
|
+
document.removeEventListener('mouseup', mouseUpRef.current);
|
|
10443
|
+
document.removeEventListener('touchmove', mouseMoveRef.current);
|
|
10444
|
+
document.removeEventListener('touchend', mouseUpRef.current);
|
|
10445
|
+
mouseMoveRef.current = null;
|
|
10446
|
+
mouseUpRef.current = null;
|
|
10447
|
+
};
|
|
10448
|
+
}, []);
|
|
10449
|
+
var updateOffset = function updateOffset(e) {
|
|
10450
|
+
var _getPosition = getPosition(e),
|
|
10451
|
+
pageX = _getPosition.pageX,
|
|
10452
|
+
pageY = _getPosition.pageY;
|
|
10453
|
+
var _containerRef$current = containerRef.current.getBoundingClientRect(),
|
|
10454
|
+
rectX = _containerRef$current.x,
|
|
10455
|
+
rectY = _containerRef$current.y,
|
|
10456
|
+
width = _containerRef$current.width,
|
|
10457
|
+
height = _containerRef$current.height;
|
|
10458
|
+
var _targetRef$current$ge = targetRef.current.getBoundingClientRect(),
|
|
10459
|
+
targetWidth = _targetRef$current$ge.width,
|
|
10460
|
+
targetHeight = _targetRef$current$ge.height;
|
|
10461
|
+
var centerOffsetX = targetWidth / 2;
|
|
10462
|
+
var centerOffsetY = targetHeight / 2;
|
|
10463
|
+
var offsetX = Math.max(0, Math.min(pageX - rectX, width)) - centerOffsetX;
|
|
10464
|
+
var offsetY = Math.max(0, Math.min(pageY - rectY, height)) - centerOffsetY;
|
|
10465
|
+
var calcOffset = {
|
|
10466
|
+
x: offsetX,
|
|
10467
|
+
y: direction === 'x' ? offsetValue.y : offsetY
|
|
10468
|
+
};
|
|
10469
|
+
|
|
10470
|
+
// Exclusion of boundary cases
|
|
10471
|
+
if (targetWidth === 0 && targetHeight === 0 || targetWidth !== targetHeight) {
|
|
10472
|
+
return false;
|
|
10473
|
+
}
|
|
10474
|
+
onDragChange === null || onDragChange === void 0 || onDragChange(calcOffset);
|
|
10475
|
+
};
|
|
10476
|
+
var onDragMove = function onDragMove(e) {
|
|
10477
|
+
e.preventDefault();
|
|
10478
|
+
updateOffset(e);
|
|
10479
|
+
};
|
|
10480
|
+
var onDragStop = function onDragStop(e) {
|
|
10481
|
+
e.preventDefault();
|
|
10482
|
+
document.removeEventListener('mousemove', mouseMoveRef.current);
|
|
10483
|
+
document.removeEventListener('mouseup', mouseUpRef.current);
|
|
10484
|
+
document.removeEventListener('touchmove', mouseMoveRef.current);
|
|
10485
|
+
document.removeEventListener('touchend', mouseUpRef.current);
|
|
10486
|
+
mouseMoveRef.current = null;
|
|
10487
|
+
mouseUpRef.current = null;
|
|
10488
|
+
onDragChangeComplete === null || onDragChangeComplete === void 0 || onDragChangeComplete();
|
|
10489
|
+
};
|
|
10490
|
+
var onDragStart = function onDragStart(e) {
|
|
10491
|
+
// https://github.com/ant-design/ant-design/issues/43529
|
|
10492
|
+
document.removeEventListener('mousemove', mouseMoveRef.current);
|
|
10493
|
+
document.removeEventListener('mouseup', mouseUpRef.current);
|
|
10494
|
+
if (disabledDrag) {
|
|
10495
|
+
return;
|
|
10496
|
+
}
|
|
10497
|
+
updateOffset(e);
|
|
10498
|
+
document.addEventListener('mousemove', onDragMove);
|
|
10499
|
+
document.addEventListener('mouseup', onDragStop);
|
|
10500
|
+
document.addEventListener('touchmove', onDragMove);
|
|
10501
|
+
document.addEventListener('touchend', onDragStop);
|
|
10502
|
+
mouseMoveRef.current = onDragMove;
|
|
10503
|
+
mouseUpRef.current = onDragStop;
|
|
10504
|
+
};
|
|
10505
|
+
return [offsetValue, onDragStart];
|
|
10506
|
+
}
|
|
10507
|
+
|
|
10508
|
+
var Handler = function Handler(_ref) {
|
|
10509
|
+
var _ref$size = _ref.size,
|
|
10510
|
+
size = _ref$size === void 0 ? 'default' : _ref$size,
|
|
10511
|
+
color = _ref.color,
|
|
10512
|
+
prefixCls = _ref.prefixCls;
|
|
10513
|
+
return /*#__PURE__*/a$m.createElement("div", {
|
|
10514
|
+
className: classNames("".concat(prefixCls, "-handler"), _defineProperty({}, "".concat(prefixCls, "-handler-sm"), size === 'small')),
|
|
10515
|
+
style: {
|
|
10516
|
+
backgroundColor: color
|
|
10517
|
+
}
|
|
10518
|
+
});
|
|
10519
|
+
};
|
|
10520
|
+
|
|
10521
|
+
var Palette = function Palette(_ref) {
|
|
10522
|
+
var children = _ref.children,
|
|
10523
|
+
style = _ref.style,
|
|
10524
|
+
prefixCls = _ref.prefixCls;
|
|
10525
|
+
return /*#__PURE__*/a$m.createElement("div", {
|
|
10526
|
+
className: "".concat(prefixCls, "-palette"),
|
|
10527
|
+
style: _objectSpread2({
|
|
10528
|
+
position: 'relative'
|
|
10529
|
+
}, style)
|
|
10530
|
+
}, children);
|
|
10531
|
+
};
|
|
10532
|
+
|
|
10533
|
+
var Transform = /*#__PURE__*/a$m.forwardRef(function (props, ref) {
|
|
10534
|
+
var children = props.children,
|
|
10535
|
+
x = props.x,
|
|
10536
|
+
y = props.y;
|
|
10537
|
+
return /*#__PURE__*/a$m.createElement("div", {
|
|
10538
|
+
ref: ref,
|
|
10539
|
+
style: {
|
|
10540
|
+
position: 'absolute',
|
|
10541
|
+
left: "".concat(x, "%"),
|
|
10542
|
+
top: "".concat(y, "%"),
|
|
10543
|
+
zIndex: 1,
|
|
10544
|
+
transform: 'translate(-50%, -50%)'
|
|
10545
|
+
}
|
|
10546
|
+
}, children);
|
|
10547
|
+
});
|
|
10548
|
+
|
|
10549
|
+
var Picker = function Picker(_ref) {
|
|
10550
|
+
var color = _ref.color,
|
|
10551
|
+
onChange = _ref.onChange,
|
|
10552
|
+
prefixCls = _ref.prefixCls,
|
|
10553
|
+
onChangeComplete = _ref.onChangeComplete,
|
|
10554
|
+
disabled = _ref.disabled;
|
|
10555
|
+
var pickerRef = a$m.useRef();
|
|
10556
|
+
var transformRef = a$m.useRef();
|
|
10557
|
+
var colorRef = a$m.useRef(color);
|
|
10558
|
+
var onDragChange = useEvent(function (offsetValue) {
|
|
10559
|
+
var calcColor = calculateColor({
|
|
10560
|
+
offset: offsetValue,
|
|
10561
|
+
targetRef: transformRef,
|
|
10562
|
+
containerRef: pickerRef,
|
|
10563
|
+
color: color
|
|
10564
|
+
});
|
|
10565
|
+
colorRef.current = calcColor;
|
|
10566
|
+
onChange(calcColor);
|
|
10567
|
+
});
|
|
10568
|
+
var _useColorDrag = useColorDrag({
|
|
10569
|
+
color: color,
|
|
10570
|
+
containerRef: pickerRef,
|
|
10571
|
+
targetRef: transformRef,
|
|
10572
|
+
calculate: function calculate() {
|
|
10573
|
+
return calcOffset(color);
|
|
10574
|
+
},
|
|
10575
|
+
onDragChange: onDragChange,
|
|
10576
|
+
onDragChangeComplete: function onDragChangeComplete() {
|
|
10577
|
+
return onChangeComplete === null || onChangeComplete === void 0 ? void 0 : onChangeComplete(colorRef.current);
|
|
10578
|
+
},
|
|
10579
|
+
disabledDrag: disabled
|
|
10580
|
+
}),
|
|
10581
|
+
_useColorDrag2 = _slicedToArray(_useColorDrag, 2),
|
|
10582
|
+
offset = _useColorDrag2[0],
|
|
10583
|
+
dragStartHandle = _useColorDrag2[1];
|
|
10584
|
+
return /*#__PURE__*/a$m.createElement("div", {
|
|
10585
|
+
ref: pickerRef,
|
|
10586
|
+
className: "".concat(prefixCls, "-select"),
|
|
10587
|
+
onMouseDown: dragStartHandle,
|
|
10588
|
+
onTouchStart: dragStartHandle
|
|
10589
|
+
}, /*#__PURE__*/a$m.createElement(Palette, {
|
|
10590
|
+
prefixCls: prefixCls
|
|
10591
|
+
}, /*#__PURE__*/a$m.createElement(Transform, {
|
|
10592
|
+
x: offset.x,
|
|
10593
|
+
y: offset.y,
|
|
10594
|
+
ref: transformRef
|
|
10595
|
+
}, /*#__PURE__*/a$m.createElement(Handler, {
|
|
10596
|
+
color: color.toRgbString(),
|
|
10597
|
+
prefixCls: prefixCls
|
|
10598
|
+
})), /*#__PURE__*/a$m.createElement("div", {
|
|
10599
|
+
className: "".concat(prefixCls, "-saturation"),
|
|
10600
|
+
style: {
|
|
10601
|
+
backgroundColor: "hsl(".concat(color.toHsb().h, ",100%, 50%)"),
|
|
10602
|
+
backgroundImage: 'linear-gradient(0deg, #000, transparent),linear-gradient(90deg, #fff, hsla(0, 0%, 100%, 0))'
|
|
10603
|
+
}
|
|
10604
|
+
})));
|
|
10605
|
+
};
|
|
10606
|
+
|
|
10607
|
+
var useColorState = function useColorState(defaultValue, value) {
|
|
10608
|
+
var _useMergedState = useMergedState(defaultValue, {
|
|
10609
|
+
value: value
|
|
10610
|
+
}),
|
|
10611
|
+
_useMergedState2 = _slicedToArray(_useMergedState, 2),
|
|
10612
|
+
mergedValue = _useMergedState2[0],
|
|
10613
|
+
setValue = _useMergedState2[1];
|
|
10614
|
+
var color = a$m.useMemo(function () {
|
|
10615
|
+
return generateColor$1(mergedValue);
|
|
10616
|
+
}, [mergedValue]);
|
|
10617
|
+
return [color, setValue];
|
|
10618
|
+
};
|
|
10619
|
+
|
|
10620
|
+
var Gradient = function Gradient(_ref) {
|
|
10621
|
+
var colors = _ref.colors,
|
|
10622
|
+
children = _ref.children,
|
|
10623
|
+
_ref$direction = _ref.direction,
|
|
10624
|
+
direction = _ref$direction === void 0 ? 'to right' : _ref$direction,
|
|
10625
|
+
type = _ref.type,
|
|
10626
|
+
prefixCls = _ref.prefixCls;
|
|
10627
|
+
var gradientColors = a$m.useMemo(function () {
|
|
10628
|
+
return colors.map(function (color, idx) {
|
|
10629
|
+
var result = generateColor$1(color);
|
|
10630
|
+
if (type === 'alpha' && idx === colors.length - 1) {
|
|
10631
|
+
result = new Color(result.setA(1));
|
|
10632
|
+
}
|
|
10633
|
+
return result.toRgbString();
|
|
10634
|
+
}).join(',');
|
|
10635
|
+
}, [colors, type]);
|
|
10636
|
+
return /*#__PURE__*/a$m.createElement("div", {
|
|
10637
|
+
className: "".concat(prefixCls, "-gradient"),
|
|
10638
|
+
style: {
|
|
10639
|
+
position: 'absolute',
|
|
10640
|
+
inset: 0,
|
|
10641
|
+
background: "linear-gradient(".concat(direction, ", ").concat(gradientColors, ")")
|
|
10642
|
+
}
|
|
10643
|
+
}, children);
|
|
10644
|
+
};
|
|
10645
|
+
|
|
10646
|
+
var Slider = function Slider(props) {
|
|
10647
|
+
var prefixCls = props.prefixCls,
|
|
10648
|
+
colors = props.colors,
|
|
10649
|
+
disabled = props.disabled,
|
|
10650
|
+
onChange = props.onChange,
|
|
10651
|
+
onChangeComplete = props.onChangeComplete,
|
|
10652
|
+
color = props.color,
|
|
10653
|
+
type = props.type;
|
|
10654
|
+
var sliderRef = a$m.useRef();
|
|
10655
|
+
var transformRef = a$m.useRef();
|
|
10656
|
+
var colorRef = a$m.useRef(color);
|
|
10657
|
+
var getValue = function getValue(c) {
|
|
10658
|
+
return type === 'hue' ? c.getHue() : c.a * 100;
|
|
10659
|
+
};
|
|
10660
|
+
var onDragChange = useEvent(function (offsetValue) {
|
|
10661
|
+
var calcColor = calculateColor({
|
|
10662
|
+
offset: offsetValue,
|
|
10663
|
+
targetRef: transformRef,
|
|
10664
|
+
containerRef: sliderRef,
|
|
10665
|
+
color: color,
|
|
10666
|
+
type: type
|
|
10667
|
+
});
|
|
10668
|
+
colorRef.current = calcColor;
|
|
10669
|
+
onChange(getValue(calcColor));
|
|
10670
|
+
});
|
|
10671
|
+
var _useColorDrag = useColorDrag({
|
|
10672
|
+
color: color,
|
|
10673
|
+
targetRef: transformRef,
|
|
10674
|
+
containerRef: sliderRef,
|
|
10675
|
+
calculate: function calculate() {
|
|
10676
|
+
return calcOffset(color, type);
|
|
10677
|
+
},
|
|
10678
|
+
onDragChange: onDragChange,
|
|
10679
|
+
onDragChangeComplete: function onDragChangeComplete() {
|
|
10680
|
+
onChangeComplete(getValue(colorRef.current));
|
|
10681
|
+
},
|
|
10682
|
+
direction: 'x',
|
|
10683
|
+
disabledDrag: disabled
|
|
10684
|
+
}),
|
|
10685
|
+
_useColorDrag2 = _slicedToArray(_useColorDrag, 2),
|
|
10686
|
+
offset = _useColorDrag2[0],
|
|
10687
|
+
dragStartHandle = _useColorDrag2[1];
|
|
10688
|
+
var handleColor = a$m.useMemo(function () {
|
|
10689
|
+
if (type === 'hue') {
|
|
10690
|
+
var hsb = color.toHsb();
|
|
10691
|
+
hsb.s = 1;
|
|
10692
|
+
hsb.b = 1;
|
|
10693
|
+
hsb.a = 1;
|
|
10694
|
+
var lightColor = new Color(hsb);
|
|
10695
|
+
return lightColor;
|
|
10696
|
+
}
|
|
10697
|
+
return color;
|
|
10698
|
+
}, [color, type]);
|
|
10699
|
+
|
|
10700
|
+
// ========================= Gradient =========================
|
|
10701
|
+
var gradientList = a$m.useMemo(function () {
|
|
10702
|
+
return colors.map(function (info) {
|
|
10703
|
+
return "".concat(info.color, " ").concat(info.percent, "%");
|
|
10704
|
+
});
|
|
10705
|
+
}, [colors]);
|
|
10706
|
+
|
|
10707
|
+
// ========================== Render ==========================
|
|
10708
|
+
return /*#__PURE__*/a$m.createElement("div", {
|
|
10709
|
+
ref: sliderRef,
|
|
10710
|
+
className: classNames("".concat(prefixCls, "-slider"), "".concat(prefixCls, "-slider-").concat(type)),
|
|
10711
|
+
onMouseDown: dragStartHandle,
|
|
10712
|
+
onTouchStart: dragStartHandle
|
|
10713
|
+
}, /*#__PURE__*/a$m.createElement(Palette, {
|
|
10714
|
+
prefixCls: prefixCls
|
|
10715
|
+
}, /*#__PURE__*/a$m.createElement(Transform, {
|
|
10716
|
+
x: offset.x,
|
|
10717
|
+
y: offset.y,
|
|
10718
|
+
ref: transformRef
|
|
10719
|
+
}, /*#__PURE__*/a$m.createElement(Handler, {
|
|
10720
|
+
size: "small",
|
|
10721
|
+
color: handleColor.toHexString(),
|
|
10722
|
+
prefixCls: prefixCls
|
|
10723
|
+
})), /*#__PURE__*/a$m.createElement(Gradient, {
|
|
10724
|
+
colors: gradientList,
|
|
10725
|
+
type: type,
|
|
10726
|
+
prefixCls: prefixCls
|
|
10727
|
+
})));
|
|
10728
|
+
};
|
|
10729
|
+
|
|
10730
|
+
function useComponent(components) {
|
|
10731
|
+
return a__namespace.useMemo(function () {
|
|
10732
|
+
var _ref = components || {},
|
|
10733
|
+
slider = _ref.slider;
|
|
10734
|
+
return [slider || Slider];
|
|
10735
|
+
}, [components]);
|
|
10736
|
+
}
|
|
10737
|
+
|
|
10738
|
+
var HUE_COLORS = [{
|
|
10739
|
+
color: 'rgb(255, 0, 0)',
|
|
10740
|
+
percent: 0
|
|
10741
|
+
}, {
|
|
10742
|
+
color: 'rgb(255, 255, 0)',
|
|
10743
|
+
percent: 17
|
|
10744
|
+
}, {
|
|
10745
|
+
color: 'rgb(0, 255, 0)',
|
|
10746
|
+
percent: 33
|
|
10747
|
+
}, {
|
|
10748
|
+
color: 'rgb(0, 255, 255)',
|
|
10749
|
+
percent: 50
|
|
10750
|
+
}, {
|
|
10751
|
+
color: 'rgb(0, 0, 255)',
|
|
10752
|
+
percent: 67
|
|
10753
|
+
}, {
|
|
10754
|
+
color: 'rgb(255, 0, 255)',
|
|
10755
|
+
percent: 83
|
|
10756
|
+
}, {
|
|
10757
|
+
color: 'rgb(255, 0, 0)',
|
|
10758
|
+
percent: 100
|
|
10759
|
+
}];
|
|
10760
|
+
var ColorPicker = /*#__PURE__*/a$m.forwardRef(function (props, ref) {
|
|
10761
|
+
var value = props.value,
|
|
10762
|
+
defaultValue = props.defaultValue,
|
|
10763
|
+
_props$prefixCls = props.prefixCls,
|
|
10764
|
+
prefixCls = _props$prefixCls === void 0 ? ColorPickerPrefixCls : _props$prefixCls,
|
|
10765
|
+
onChange = props.onChange,
|
|
10766
|
+
onChangeComplete = props.onChangeComplete,
|
|
10767
|
+
className = props.className,
|
|
10768
|
+
style = props.style,
|
|
10769
|
+
panelRender = props.panelRender,
|
|
10770
|
+
_props$disabledAlpha = props.disabledAlpha,
|
|
10771
|
+
disabledAlpha = _props$disabledAlpha === void 0 ? false : _props$disabledAlpha,
|
|
10772
|
+
_props$disabled = props.disabled,
|
|
10773
|
+
disabled = _props$disabled === void 0 ? false : _props$disabled,
|
|
10774
|
+
components = props.components;
|
|
10775
|
+
|
|
10776
|
+
// ========================== Components ==========================
|
|
10777
|
+
var _useComponent = useComponent(components),
|
|
10778
|
+
_useComponent2 = _slicedToArray(_useComponent, 1),
|
|
10779
|
+
Slider = _useComponent2[0];
|
|
10780
|
+
|
|
10781
|
+
// ============================ Color =============================
|
|
10782
|
+
var _useColorState = useColorState(defaultValue || defaultColor, value),
|
|
10783
|
+
_useColorState2 = _slicedToArray(_useColorState, 2),
|
|
10784
|
+
colorValue = _useColorState2[0],
|
|
10785
|
+
setColorValue = _useColorState2[1];
|
|
10786
|
+
var alphaColor = a$m.useMemo(function () {
|
|
10787
|
+
return colorValue.setA(1).toRgbString();
|
|
10788
|
+
}, [colorValue]);
|
|
10789
|
+
|
|
10790
|
+
// ============================ Events ============================
|
|
10791
|
+
var handleChange = function handleChange(data, type) {
|
|
10792
|
+
if (!value) {
|
|
10793
|
+
setColorValue(data);
|
|
10794
|
+
}
|
|
10795
|
+
onChange === null || onChange === void 0 || onChange(data, type);
|
|
10796
|
+
};
|
|
10797
|
+
|
|
10798
|
+
// Convert
|
|
10799
|
+
var getHueColor = function getHueColor(hue) {
|
|
10800
|
+
return new Color(colorValue.setHue(hue));
|
|
10801
|
+
};
|
|
10802
|
+
var getAlphaColor = function getAlphaColor(alpha) {
|
|
10803
|
+
return new Color(colorValue.setA(alpha / 100));
|
|
10804
|
+
};
|
|
10805
|
+
|
|
10806
|
+
// Slider change
|
|
10807
|
+
var onHueChange = function onHueChange(hue) {
|
|
10808
|
+
handleChange(getHueColor(hue), {
|
|
10809
|
+
type: 'hue',
|
|
10810
|
+
value: hue
|
|
10811
|
+
});
|
|
10812
|
+
};
|
|
10813
|
+
var onAlphaChange = function onAlphaChange(alpha) {
|
|
10814
|
+
handleChange(getAlphaColor(alpha), {
|
|
10815
|
+
type: 'alpha',
|
|
10816
|
+
value: alpha
|
|
10817
|
+
});
|
|
10818
|
+
};
|
|
10819
|
+
|
|
10820
|
+
// Complete
|
|
10821
|
+
var onHueChangeComplete = function onHueChangeComplete(hue) {
|
|
10822
|
+
if (onChangeComplete) {
|
|
10823
|
+
onChangeComplete(getHueColor(hue));
|
|
10824
|
+
}
|
|
10825
|
+
};
|
|
10826
|
+
var onAlphaChangeComplete = function onAlphaChangeComplete(alpha) {
|
|
10827
|
+
if (onChangeComplete) {
|
|
10828
|
+
onChangeComplete(getAlphaColor(alpha));
|
|
10829
|
+
}
|
|
10830
|
+
};
|
|
10831
|
+
|
|
10832
|
+
// ============================ Render ============================
|
|
10833
|
+
var mergeCls = classNames("".concat(prefixCls, "-panel"), className, _defineProperty({}, "".concat(prefixCls, "-panel-disabled"), disabled));
|
|
10834
|
+
var sharedSliderProps = {
|
|
10835
|
+
prefixCls: prefixCls,
|
|
10836
|
+
disabled: disabled,
|
|
10837
|
+
color: colorValue
|
|
10838
|
+
};
|
|
10839
|
+
var defaultPanel = /*#__PURE__*/a$m.createElement(a$m.Fragment, null, /*#__PURE__*/a$m.createElement(Picker, _extends({
|
|
10840
|
+
onChange: handleChange
|
|
10841
|
+
}, sharedSliderProps, {
|
|
10842
|
+
onChangeComplete: onChangeComplete
|
|
10843
|
+
})), /*#__PURE__*/a$m.createElement("div", {
|
|
10844
|
+
className: "".concat(prefixCls, "-slider-container")
|
|
10845
|
+
}, /*#__PURE__*/a$m.createElement("div", {
|
|
10846
|
+
className: classNames("".concat(prefixCls, "-slider-group"), _defineProperty({}, "".concat(prefixCls, "-slider-group-disabled-alpha"), disabledAlpha))
|
|
10847
|
+
}, /*#__PURE__*/a$m.createElement(Slider, _extends({}, sharedSliderProps, {
|
|
10848
|
+
type: "hue",
|
|
10849
|
+
colors: HUE_COLORS,
|
|
10850
|
+
min: 0,
|
|
10851
|
+
max: 359,
|
|
10852
|
+
value: colorValue.getHue(),
|
|
10853
|
+
onChange: onHueChange,
|
|
10854
|
+
onChangeComplete: onHueChangeComplete
|
|
10855
|
+
})), !disabledAlpha && /*#__PURE__*/a$m.createElement(Slider, _extends({}, sharedSliderProps, {
|
|
10856
|
+
type: "alpha",
|
|
10857
|
+
colors: [{
|
|
10858
|
+
percent: 0,
|
|
10859
|
+
color: 'rgba(255, 0, 4, 0)'
|
|
10860
|
+
}, {
|
|
10861
|
+
percent: 100,
|
|
10862
|
+
color: alphaColor
|
|
10863
|
+
}],
|
|
10864
|
+
min: 0,
|
|
10865
|
+
max: 100,
|
|
10866
|
+
value: colorValue.a * 100,
|
|
10867
|
+
onChange: onAlphaChange,
|
|
10868
|
+
onChangeComplete: onAlphaChangeComplete
|
|
10869
|
+
}))), /*#__PURE__*/a$m.createElement(ColorBlock, {
|
|
10870
|
+
color: colorValue.toRgbString(),
|
|
10871
|
+
prefixCls: prefixCls
|
|
10872
|
+
})));
|
|
10873
|
+
return /*#__PURE__*/a$m.createElement("div", {
|
|
10874
|
+
className: mergeCls,
|
|
10875
|
+
style: style,
|
|
10876
|
+
ref: ref
|
|
10877
|
+
}, typeof panelRender === 'function' ? panelRender(defaultPanel) : defaultPanel);
|
|
10878
|
+
});
|
|
10879
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
10880
|
+
ColorPicker.displayName = 'ColorPicker';
|
|
10881
|
+
}
|
|
10882
|
+
|
|
10883
|
+
const toHexFormat = (value, alpha) => (value === null || value === void 0 ? void 0 : value.replace(/[^\w/]/g, '').slice(0, alpha ? 8 : 6)) || '';
|
|
10884
|
+
const getHex = (value, alpha) => value ? toHexFormat(value, alpha) : '';
|
|
10885
|
+
let AggregationColor = /*#__PURE__*/function () {
|
|
10886
|
+
function AggregationColor(color) {
|
|
10887
|
+
_classCallCheck(this, AggregationColor);
|
|
10888
|
+
var _a;
|
|
10889
|
+
this.cleared = false;
|
|
10890
|
+
// Clone from another AggregationColor
|
|
10891
|
+
if (color instanceof AggregationColor) {
|
|
10892
|
+
this.metaColor = color.metaColor.clone();
|
|
10893
|
+
this.colors = (_a = color.colors) === null || _a === void 0 ? void 0 : _a.map(info => ({
|
|
10894
|
+
color: new AggregationColor(info.color),
|
|
10895
|
+
percent: info.percent
|
|
10896
|
+
}));
|
|
10897
|
+
this.cleared = color.cleared;
|
|
10898
|
+
return;
|
|
10899
|
+
}
|
|
10900
|
+
const isArray = Array.isArray(color);
|
|
10901
|
+
if (isArray && color.length) {
|
|
10902
|
+
this.colors = color.map(({
|
|
10903
|
+
color: c,
|
|
10904
|
+
percent
|
|
10905
|
+
}) => ({
|
|
10906
|
+
color: new AggregationColor(c),
|
|
10907
|
+
percent
|
|
10908
|
+
}));
|
|
10909
|
+
this.metaColor = new Color(this.colors[0].color.metaColor);
|
|
10910
|
+
} else {
|
|
10911
|
+
this.metaColor = new Color(isArray ? '' : color);
|
|
10912
|
+
}
|
|
10913
|
+
if (!color || isArray && !this.colors) {
|
|
10914
|
+
this.metaColor = this.metaColor.setA(0);
|
|
10915
|
+
this.cleared = true;
|
|
10916
|
+
}
|
|
10917
|
+
}
|
|
10918
|
+
return _createClass(AggregationColor, [{
|
|
10919
|
+
key: "toHsb",
|
|
10920
|
+
value: function toHsb() {
|
|
10921
|
+
return this.metaColor.toHsb();
|
|
10922
|
+
}
|
|
10923
|
+
}, {
|
|
10924
|
+
key: "toHsbString",
|
|
10925
|
+
value: function toHsbString() {
|
|
10926
|
+
return this.metaColor.toHsbString();
|
|
10927
|
+
}
|
|
10928
|
+
}, {
|
|
10929
|
+
key: "toHex",
|
|
10930
|
+
value: function toHex() {
|
|
10931
|
+
return getHex(this.toHexString(), this.metaColor.a < 1);
|
|
10932
|
+
}
|
|
10933
|
+
}, {
|
|
10934
|
+
key: "toHexString",
|
|
10935
|
+
value: function toHexString() {
|
|
10936
|
+
return this.metaColor.toHexString();
|
|
10937
|
+
}
|
|
10938
|
+
}, {
|
|
10939
|
+
key: "toRgb",
|
|
10940
|
+
value: function toRgb() {
|
|
10941
|
+
return this.metaColor.toRgb();
|
|
10942
|
+
}
|
|
10943
|
+
}, {
|
|
10944
|
+
key: "toRgbString",
|
|
10945
|
+
value: function toRgbString() {
|
|
10946
|
+
return this.metaColor.toRgbString();
|
|
10947
|
+
}
|
|
10948
|
+
}, {
|
|
10949
|
+
key: "isGradient",
|
|
10950
|
+
value: function isGradient() {
|
|
10951
|
+
return !!this.colors && !this.cleared;
|
|
10952
|
+
}
|
|
10953
|
+
}, {
|
|
10954
|
+
key: "getColors",
|
|
10955
|
+
value: function getColors() {
|
|
10956
|
+
return this.colors || [{
|
|
10957
|
+
color: this,
|
|
10958
|
+
percent: 0
|
|
10959
|
+
}];
|
|
10960
|
+
}
|
|
10961
|
+
}, {
|
|
10962
|
+
key: "toCssString",
|
|
10963
|
+
value: function toCssString() {
|
|
10964
|
+
const {
|
|
10965
|
+
colors
|
|
10966
|
+
} = this;
|
|
10967
|
+
// CSS line-gradient
|
|
10968
|
+
if (colors) {
|
|
10969
|
+
const colorsStr = colors.map(c => `${c.color.toRgbString()} ${c.percent}%`).join(', ');
|
|
10970
|
+
return `linear-gradient(90deg, ${colorsStr})`;
|
|
10971
|
+
}
|
|
10972
|
+
return this.metaColor.toRgbString();
|
|
10973
|
+
}
|
|
10974
|
+
}, {
|
|
10975
|
+
key: "equals",
|
|
10976
|
+
value: function equals(color) {
|
|
10977
|
+
if (!color || this.isGradient() !== color.isGradient()) {
|
|
10978
|
+
return false;
|
|
10979
|
+
}
|
|
10980
|
+
if (!this.isGradient()) {
|
|
10981
|
+
return this.toHexString() === color.toHexString();
|
|
10982
|
+
}
|
|
10983
|
+
return this.colors.length === color.colors.length && this.colors.every((c, i) => {
|
|
10984
|
+
const target = color.colors[i];
|
|
10985
|
+
return c.percent === target.percent && c.color.equals(target.color);
|
|
10986
|
+
});
|
|
10987
|
+
}
|
|
10988
|
+
}]);
|
|
10989
|
+
}();
|
|
10990
|
+
|
|
10276
10991
|
const initMotionCommon = duration => ({
|
|
10277
10992
|
animationDuration: duration,
|
|
10278
10993
|
animationFillMode: 'both'
|
|
@@ -10492,6 +11207,13 @@ const initZoomMotion = (token, motionName) => {
|
|
|
10492
11207
|
}];
|
|
10493
11208
|
};
|
|
10494
11209
|
|
|
11210
|
+
const generateColor = color => {
|
|
11211
|
+
if (color instanceof AggregationColor) {
|
|
11212
|
+
return color;
|
|
11213
|
+
}
|
|
11214
|
+
return new AggregationColor(color);
|
|
11215
|
+
};
|
|
11216
|
+
|
|
10495
11217
|
var OrderContext = /*#__PURE__*/a__namespace.createContext(null);
|
|
10496
11218
|
|
|
10497
11219
|
var EMPTY_LIST = [];
|
|
@@ -10885,6 +11607,7 @@ function newMessages() {
|
|
|
10885
11607
|
float: '%s is not a %s',
|
|
10886
11608
|
regexp: '%s is not a valid %s',
|
|
10887
11609
|
email: '%s is not a valid %s',
|
|
11610
|
+
tel: '%s is not a valid %s',
|
|
10888
11611
|
url: '%s is not a valid %s',
|
|
10889
11612
|
hex: '%s is not a valid %s'
|
|
10890
11613
|
},
|
|
@@ -11023,7 +11746,7 @@ function format(template) {
|
|
|
11023
11746
|
return template;
|
|
11024
11747
|
}
|
|
11025
11748
|
function isNativeStringType(type) {
|
|
11026
|
-
return type === 'string' || type === 'url' || type === 'hex' || type === 'email' || type === 'date' || type === 'pattern';
|
|
11749
|
+
return type === 'string' || type === 'url' || type === 'hex' || type === 'email' || type === 'date' || type === 'pattern' || type === 'tel';
|
|
11027
11750
|
}
|
|
11028
11751
|
function isEmptyValue(value, type) {
|
|
11029
11752
|
if (value === undefined || value === null) {
|
|
@@ -11327,6 +12050,13 @@ var pattern$1 = {
|
|
|
11327
12050
|
// '^(?!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]*)?$',
|
|
11328
12051
|
// 'i',
|
|
11329
12052
|
// ),
|
|
12053
|
+
/**
|
|
12054
|
+
* Phone number regex, support country code, brackets, spaces, and dashes (or non-breaking hyphen \u2011).
|
|
12055
|
+
* @see https://regexr.com/3c53v
|
|
12056
|
+
* @see https://ihateregex.io/expr/phone/
|
|
12057
|
+
* @see https://developers.google.com/style/phone-numbers using non-breaking hyphen \u2011
|
|
12058
|
+
*/
|
|
12059
|
+
tel: /^(\+[0-9]{1,3}[-\s\u2011]?)?(\([0-9]{1,4}\)[-\s\u2011]?)?([0-9]+[-\s\u2011]?)*[0-9]+$/,
|
|
11330
12060
|
hex: /^#?([a-f0-9]{6}|[a-f0-9]{3})$/i
|
|
11331
12061
|
};
|
|
11332
12062
|
var types = {
|
|
@@ -11367,6 +12097,9 @@ var types = {
|
|
|
11367
12097
|
email: function email(value) {
|
|
11368
12098
|
return typeof value === 'string' && value.length <= 320 && !!value.match(pattern$1.email);
|
|
11369
12099
|
},
|
|
12100
|
+
tel: function tel(value) {
|
|
12101
|
+
return typeof value === 'string' && value.length <= 32 && !!value.match(pattern$1.tel);
|
|
12102
|
+
},
|
|
11370
12103
|
url: function url(value) {
|
|
11371
12104
|
return typeof value === 'string' && value.length <= 2048 && !!value.match(getUrlRegex());
|
|
11372
12105
|
},
|
|
@@ -11379,7 +12112,7 @@ var type$1 = function type(rule, value, source, errors, options) {
|
|
|
11379
12112
|
required$1(rule, value, source, errors, options);
|
|
11380
12113
|
return;
|
|
11381
12114
|
}
|
|
11382
|
-
var custom = ['integer', 'float', 'array', 'regexp', 'object', 'method', 'email', 'number', 'date', 'url', 'hex'];
|
|
12115
|
+
var custom = ['integer', 'float', 'array', 'regexp', 'object', 'method', 'email', 'tel', 'number', 'date', 'url', 'hex'];
|
|
11383
12116
|
var ruleType = rule.type;
|
|
11384
12117
|
if (custom.indexOf(ruleType) > -1) {
|
|
11385
12118
|
if (!types[ruleType](value)) {
|
|
@@ -11673,6 +12406,7 @@ var validators = {
|
|
|
11673
12406
|
url: type,
|
|
11674
12407
|
hex: type,
|
|
11675
12408
|
email: type,
|
|
12409
|
+
tel: type,
|
|
11676
12410
|
required: required,
|
|
11677
12411
|
any: any
|
|
11678
12412
|
};
|
|
@@ -11824,7 +12558,7 @@ var Schema = /*#__PURE__*/function () {
|
|
|
11824
12558
|
if (!options.suppressWarning && errorList.length) {
|
|
11825
12559
|
Schema.warning('async-validator:', errorList);
|
|
11826
12560
|
}
|
|
11827
|
-
if (errorList.length && rule.message !== undefined) {
|
|
12561
|
+
if (errorList.length && rule.message !== undefined && rule.message !== null) {
|
|
11828
12562
|
errorList = [].concat(rule.message);
|
|
11829
12563
|
}
|
|
11830
12564
|
|
|
@@ -12090,7 +12824,7 @@ function _validateRule() {
|
|
|
12090
12824
|
});
|
|
12091
12825
|
}
|
|
12092
12826
|
case 18:
|
|
12093
|
-
if (!(!result.length && subRuleField)) {
|
|
12827
|
+
if (!(!result.length && subRuleField && Array.isArray(value) && value.length > 0)) {
|
|
12094
12828
|
_context2.next = 23;
|
|
12095
12829
|
break;
|
|
12096
12830
|
}
|
|
@@ -15427,12 +16161,12 @@ function useAlign(open, popupEle, target, placement, builtinPlacements, popupAli
|
|
|
15427
16161
|
var offsetX4Right = popupMirrorRect.right - popupRect.x - (nextOffsetX + popupRect.width);
|
|
15428
16162
|
var offsetY4Bottom = popupMirrorRect.bottom - popupRect.y - (nextOffsetY + popupRect.height);
|
|
15429
16163
|
if (_scaleX === 1) {
|
|
15430
|
-
nextOffsetX = Math.
|
|
15431
|
-
offsetX4Right = Math.
|
|
16164
|
+
nextOffsetX = Math.floor(nextOffsetX);
|
|
16165
|
+
offsetX4Right = Math.floor(offsetX4Right);
|
|
15432
16166
|
}
|
|
15433
16167
|
if (_scaleY === 1) {
|
|
15434
|
-
nextOffsetY = Math.
|
|
15435
|
-
offsetY4Bottom = Math.
|
|
16168
|
+
nextOffsetY = Math.floor(nextOffsetY);
|
|
16169
|
+
offsetY4Bottom = Math.floor(offsetY4Bottom);
|
|
15436
16170
|
}
|
|
15437
16171
|
var nextOffsetInfo = {
|
|
15438
16172
|
ready: true,
|
|
@@ -15982,6 +16716,10 @@ function generateTrigger() {
|
|
|
15982
16716
|
cloneProps.className = classNames(originChildProps.className, className);
|
|
15983
16717
|
}
|
|
15984
16718
|
|
|
16719
|
+
// ============================ Perf ============================
|
|
16720
|
+
var renderedRef = a__namespace.useRef(false);
|
|
16721
|
+
renderedRef.current || (renderedRef.current = forceRender || mergedOpen || inMotion);
|
|
16722
|
+
|
|
15985
16723
|
// =========================== Render ===========================
|
|
15986
16724
|
var mergedChildrenProps = _objectSpread2(_objectSpread2({}, originChildProps), cloneProps);
|
|
15987
16725
|
|
|
@@ -16016,7 +16754,7 @@ function generateTrigger() {
|
|
|
16016
16754
|
onResize: onTargetResize
|
|
16017
16755
|
}, /*#__PURE__*/a__namespace.createElement(TriggerWrapper, {
|
|
16018
16756
|
getTriggerDOMNode: getTriggerDOMNode
|
|
16019
|
-
}, triggerNode)), /*#__PURE__*/a__namespace.createElement(TriggerContext.Provider, {
|
|
16757
|
+
}, triggerNode)), renderedRef.current && /*#__PURE__*/a__namespace.createElement(TriggerContext.Provider, {
|
|
16020
16758
|
value: context
|
|
16021
16759
|
}, /*#__PURE__*/a__namespace.createElement(Popup$1, {
|
|
16022
16760
|
portal: PortalComponent,
|
|
@@ -16607,6 +17345,11 @@ function getPlacements(config) {
|
|
|
16607
17345
|
borderRadius} = config;
|
|
16608
17346
|
const halfArrowWidth = arrowWidth / 2;
|
|
16609
17347
|
const placementMap = {};
|
|
17348
|
+
// Dynamic offset
|
|
17349
|
+
const arrowOffset = getArrowOffsetToken({
|
|
17350
|
+
contentRadius: borderRadius,
|
|
17351
|
+
limitVerticalRadius: true
|
|
17352
|
+
});
|
|
16610
17353
|
Object.keys(PlacementAlignMap).forEach(key => {
|
|
16611
17354
|
const template = arrowPointAtCenter && ArrowCenterPlacementAlignMap[key] || PlacementAlignMap[key];
|
|
16612
17355
|
const placementInfo = Object.assign(Object.assign({}, template), {
|
|
@@ -16641,11 +17384,6 @@ function getPlacements(config) {
|
|
|
16641
17384
|
placementInfo.offset[0] = halfArrowWidth + offset;
|
|
16642
17385
|
break;
|
|
16643
17386
|
}
|
|
16644
|
-
// Dynamic offset
|
|
16645
|
-
const arrowOffset = getArrowOffsetToken({
|
|
16646
|
-
contentRadius: borderRadius,
|
|
16647
|
-
limitVerticalRadius: true
|
|
16648
|
-
});
|
|
16649
17387
|
if (arrowPointAtCenter) {
|
|
16650
17388
|
switch (key) {
|
|
16651
17389
|
case 'topLeft':
|
|
@@ -16717,7 +17455,7 @@ const genTooltipStyle = token => {
|
|
|
16717
17455
|
minWidth: centerAlignMinWidth,
|
|
16718
17456
|
minHeight: controlHeight,
|
|
16719
17457
|
padding: `${unit$1(token.calc(paddingSM).div(2).equal())} ${unit$1(paddingXS)}`,
|
|
16720
|
-
color: tooltipColor
|
|
17458
|
+
color: `var(--ant-tooltip-color, ${tooltipColor})`,
|
|
16721
17459
|
textAlign: 'start',
|
|
16722
17460
|
textDecoration: 'none',
|
|
16723
17461
|
wordWrap: 'break-word',
|
|
@@ -16820,8 +17558,12 @@ function parseColor(prefixCls, color) {
|
|
|
16820
17558
|
});
|
|
16821
17559
|
const overlayStyle = {};
|
|
16822
17560
|
const arrowStyle = {};
|
|
17561
|
+
const rgb = generateColor(color).toRgb();
|
|
17562
|
+
const luminance = (0.299 * rgb.r + 0.587 * rgb.g + 0.114 * rgb.b) / 255;
|
|
17563
|
+
const textColor = luminance < 0.5 ? '#FFF' : '#000';
|
|
16823
17564
|
if (color && !isInternalColor) {
|
|
16824
17565
|
overlayStyle.background = color;
|
|
17566
|
+
overlayStyle['--ant-tooltip-color'] = textColor;
|
|
16825
17567
|
// @ts-ignore
|
|
16826
17568
|
arrowStyle['--antd-arrow-background-color'] = color;
|
|
16827
17569
|
}
|
|
@@ -16891,7 +17633,7 @@ const InternalTooltip = /*#__PURE__*/a__namespace.forwardRef((props, ref) => {
|
|
|
16891
17633
|
builtinPlacements,
|
|
16892
17634
|
arrowPointAtCenter = false,
|
|
16893
17635
|
autoAdjustOverflow = true,
|
|
16894
|
-
motion,
|
|
17636
|
+
motion: _motion,
|
|
16895
17637
|
getPopupContainer,
|
|
16896
17638
|
placement = 'top',
|
|
16897
17639
|
mouseEnterDelay = 0.1,
|
|
@@ -17474,7 +18216,7 @@ const PasswordInput = ({ id, className, htmlProps, label, placeholder = "Enter P
|
|
|
17474
18216
|
a$m.createElement(CustomIconButton$2, { variant: "tertiary", iconName: show ? "eye" : "eye-slash", ariaLabel: show ? "Hide" : "Show", onClick: () => setShow(!show), disabled: disabled })));
|
|
17475
18217
|
};
|
|
17476
18218
|
|
|
17477
|
-
const formatDynamicNumbersWithCommas = (num, decimalPlaces) => {
|
|
18219
|
+
const formatDynamicNumbersWithCommas = (num, decimalPlaces, isDegrees) => {
|
|
17478
18220
|
const onlyDigitNum = num.toString().replace(/[^\d.-]/g, "");
|
|
17479
18221
|
const decimalEnding = onlyDigitNum.endsWith(".");
|
|
17480
18222
|
const zeroEnding = onlyDigitNum.includes(".") && onlyDigitNum.endsWith("0");
|
|
@@ -17484,21 +18226,21 @@ const formatDynamicNumbersWithCommas = (num, decimalPlaces) => {
|
|
|
17484
18226
|
decimalTrailingZeros = match ? match[0] : "";
|
|
17485
18227
|
}
|
|
17486
18228
|
const decimalZero = onlyDigitNum.endsWith(`.${decimalTrailingZeros.length > 0 ? decimalTrailingZeros : "0"}`);
|
|
17487
|
-
if (onlyDigitNum === "
|
|
17488
|
-
return onlyDigitNum
|
|
18229
|
+
if (onlyDigitNum === "-" || onlyDigitNum === ".") {
|
|
18230
|
+
return `${onlyDigitNum}${isDegrees ? "°" : ""}`;
|
|
17489
18231
|
}
|
|
17490
|
-
if (isNaN(Number(onlyDigitNum))) {
|
|
18232
|
+
if (isNaN(Number(onlyDigitNum)) || onlyDigitNum === "") {
|
|
17491
18233
|
return "";
|
|
17492
18234
|
}
|
|
17493
18235
|
return onlyDigitNum
|
|
17494
18236
|
? `${Number(onlyDigitNum).toLocaleString("en-US", {
|
|
17495
18237
|
minimumFractionDigits: 0,
|
|
17496
18238
|
maximumFractionDigits: decimalPlaces,
|
|
17497
|
-
})}${decimalEnding ? "." : ""}${decimalZero ? "." : ""}${zeroEnding ? `${decimalTrailingZeros}` : ""}`
|
|
18239
|
+
})}${decimalEnding ? "." : ""}${decimalZero ? "." : ""}${zeroEnding ? `${decimalTrailingZeros}` : ""}${isDegrees ? "°" : ""}`
|
|
17498
18240
|
: "";
|
|
17499
18241
|
};
|
|
17500
18242
|
|
|
17501
|
-
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, }) => {
|
|
18243
|
+
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, }) => {
|
|
17502
18244
|
const containerProps = {
|
|
17503
18245
|
id,
|
|
17504
18246
|
label,
|
|
@@ -17517,7 +18259,25 @@ const NumberInput = ({ id, className, htmlProps, leftCategory, rightCategory, la
|
|
|
17517
18259
|
};
|
|
17518
18260
|
const [inputValue, setInputValue] = a$m.useState("");
|
|
17519
18261
|
const [placeholderText, setPlaceholderText] = a$m.useState(placeholder);
|
|
18262
|
+
const ref = a$m.useRef(null);
|
|
17520
18263
|
const valueToUse = value ?? inputValue;
|
|
18264
|
+
const moveCursorBeforeDegree = () => {
|
|
18265
|
+
const pos = ref.current?.selectionStart ?? 0;
|
|
18266
|
+
const maxPos = (ref.current && ref.current.value.length - 1) ?? 0;
|
|
18267
|
+
if (pos > maxPos && isDegrees) {
|
|
18268
|
+
requestAnimationFrame(() => {
|
|
18269
|
+
const pos = ref.current && ref.current.value.length - 1;
|
|
18270
|
+
ref.current?.setSelectionRange(pos, pos);
|
|
18271
|
+
});
|
|
18272
|
+
}
|
|
18273
|
+
};
|
|
18274
|
+
const handleSelect = (e) => {
|
|
18275
|
+
const pos = e.currentTarget.selectionStart ?? 0;
|
|
18276
|
+
const maxPos = e.currentTarget.value.length - 1;
|
|
18277
|
+
if (pos > maxPos && isDegrees) {
|
|
18278
|
+
e.currentTarget.setSelectionRange(maxPos, maxPos);
|
|
18279
|
+
}
|
|
18280
|
+
};
|
|
17521
18281
|
const handleKeyDown = (e) => {
|
|
17522
18282
|
if (e.key === "," ||
|
|
17523
18283
|
(e.key === "." && decimalPlaces === 0) ||
|
|
@@ -17528,10 +18288,14 @@ const NumberInput = ({ id, className, htmlProps, leftCategory, rightCategory, la
|
|
|
17528
18288
|
}
|
|
17529
18289
|
};
|
|
17530
18290
|
const handleChange = (e) => {
|
|
18291
|
+
moveCursorBeforeDegree();
|
|
17531
18292
|
const value = e.target.value;
|
|
17532
|
-
|
|
18293
|
+
let inputDecimalPlaces = value.includes(".")
|
|
17533
18294
|
? value.split(".")[1].length
|
|
17534
18295
|
: 0;
|
|
18296
|
+
if (isDegrees && inputDecimalPlaces > 0) {
|
|
18297
|
+
inputDecimalPlaces -= 1;
|
|
18298
|
+
}
|
|
17535
18299
|
if (e.currentTarget.checkValidity() &&
|
|
17536
18300
|
inputDecimalPlaces <= decimalPlaces) {
|
|
17537
18301
|
setInputValue(value);
|
|
@@ -17546,19 +18310,19 @@ const NumberInput = ({ id, className, htmlProps, leftCategory, rightCategory, la
|
|
|
17546
18310
|
const handleFocus = (e) => {
|
|
17547
18311
|
onFocus?.(e.target.value);
|
|
17548
18312
|
!onFocus && setPlaceholderText("");
|
|
18313
|
+
isDegrees && moveCursorBeforeDegree();
|
|
17549
18314
|
};
|
|
17550
18315
|
return (a$m.createElement(TextFieldContainer, { ...containerProps },
|
|
17551
|
-
a$m.createElement(TextFieldInput, { autoComplete: enableAutocomplete ? "on" : "off", "aria-describedby": `${id}-helper-text ${ariaDescribedBy}`, type: "text", inputMode: "numeric",
|
|
17552
|
-
|
|
17553
|
-
pattern: allowNegativeNumbers ? "^[\\d,\\.\\-]*$" : "^[\\d,\\.]*$", id: `${id}-text-field`, disabled: disabled || isLoading, placeholder: placeholderText, onChange: handleChange, onBlur: handleBlur, onFocus: handleFocus, onKeyDown: handleKeyDown, value: thousandSeparator
|
|
17554
|
-
? formatDynamicNumbersWithCommas(valueToUse, decimalPlaces)
|
|
18316
|
+
a$m.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
|
|
18317
|
+
? formatDynamicNumbersWithCommas(valueToUse, decimalPlaces, isDegrees)
|
|
17555
18318
|
: valueToUse, maxLength: maxLength &&
|
|
17556
18319
|
maxLength +
|
|
17557
18320
|
(thousandSeparator
|
|
17558
18321
|
? Math.floor(valueToUse.toString().split(".")[0].length / 4)
|
|
17559
18322
|
: 0) +
|
|
17560
18323
|
(inputValue.includes(".") ? 1 : 0) +
|
|
17561
|
-
(inputValue.includes("-") ? 1 : 0)
|
|
18324
|
+
(inputValue.includes("-") ? 1 : 0) +
|
|
18325
|
+
(inputValue.includes("°") ? 1 : 0), "$isTruncated": isTruncated, "$textAlign": textAlign, "$isDisabled": disabled, "$isLoading": isLoading, ...htmlProps })));
|
|
17562
18326
|
};
|
|
17563
18327
|
|
|
17564
18328
|
/**
|
|
@@ -22303,9 +23067,12 @@ const NotificationBubble = styled.span `
|
|
|
22303
23067
|
`;
|
|
22304
23068
|
|
|
22305
23069
|
const Tab = ({ id, className, onClick, htmlProps, label, variant = "light", active = false, notifications, }) => {
|
|
23070
|
+
const notificationText = typeof notifications === "number" && notifications <= 0
|
|
23071
|
+
? undefined
|
|
23072
|
+
: notifications;
|
|
22306
23073
|
return (a$m.createElement(TabButton, { id: id, "$variant": variant, className: `${className} ${active && "active"}`, onClick: () => onClick?.(label), ...htmlProps },
|
|
22307
23074
|
label,
|
|
22308
|
-
!!
|
|
23075
|
+
!!notificationText && (a$m.createElement(NotificationBubble, { "$isActive": active }, notificationText))));
|
|
22309
23076
|
};
|
|
22310
23077
|
|
|
22311
23078
|
const Tabs = ({ id, className, tabs, htmlProps, onTabClick, defaultActiveTab, variant = "light", isPill, }) => {
|