@para-ui/core 4.0.0-beta → 4.0.0-rc

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 (124) hide show
  1. package/AutoTips/index.js +5 -5
  2. package/Button/index.js +2 -2
  3. package/Cascader/index.js +3 -3
  4. package/Checkbox/index.js +1 -1
  5. package/ColorPicker/index.js +2 -2
  6. package/ComboSelect/index.js +13 -14
  7. package/ComboSelect/utils.d.ts +5 -0
  8. package/CopyText/index.js +2 -2
  9. package/DatePicker/index.js +2 -1
  10. package/Desktop/index.js +1 -1
  11. package/DragVerify/index.js +2 -2
  12. package/Drawer/index.d.ts +2 -2
  13. package/Drawer/index.js +129 -24
  14. package/Drawer/interface.d.ts +8 -0
  15. package/Drawer/util.d.ts +6 -0
  16. package/DynamicMultiBox/index.d.ts +7 -2
  17. package/DynamicMultiBox/index.js +5 -5
  18. package/Form/index.js +6 -6
  19. package/FormItem/index.js +6 -6
  20. package/FunctionModal/index.js +5 -5
  21. package/GlobalContext/index.js +1 -1
  22. package/Help/index.js +1 -1
  23. package/InputNumber/index.js +1 -1
  24. package/Modal/index.js +2 -2
  25. package/MultiBox/index.js +8 -4
  26. package/Notification/index.js +1 -1
  27. package/OperateBtn/index.js +4 -3
  28. package/PageHeader/index.js +1 -1
  29. package/ParauiProvider/index.js +1 -1
  30. package/PasswordRules/index.js +1 -1
  31. package/PopConfirm/index.js +1 -1
  32. package/Radio/index.js +1 -1
  33. package/Search/index.js +1 -1
  34. package/Select/index.js +1 -1
  35. package/Selector/index.js +4 -4
  36. package/SelectorPicker/index.js +3 -3
  37. package/Status/index.d.ts +2 -0
  38. package/Status/index.js +17 -5
  39. package/Stepper/index.js +1 -1
  40. package/Styles/scrollbar.scss +66 -66
  41. package/Styles/theme.scss +62 -61
  42. package/Switch/index.js +1 -1
  43. package/Table/index.js +2 -2
  44. package/Tabs/index.js +1 -1
  45. package/Tag/index.js +10 -1184
  46. package/TimePicker/index.js +1 -0
  47. package/Title/index.d.ts +2 -0
  48. package/Title/index.js +6 -2
  49. package/Tooltip/index.js +1 -1
  50. package/Transfer/index.js +6 -6
  51. package/Tree/OperateBar/index.d.ts +2 -2
  52. package/Tree/index.js +4 -4
  53. package/Tree/interface.d.ts +4 -0
  54. package/Upload/index.js +6 -6
  55. package/_verture/{index-e2881a53.js → index-19947788.js} +2 -2
  56. package/_verture/{index-e6f85fd5.js → index-1c8d3e94.js} +3 -0
  57. package/_verture/{index-d63bd287.js → index-232d890b.js} +1 -1
  58. package/_verture/{index-7ec72724.js → index-47297a40.js} +36 -29
  59. package/_verture/{index-5c77417d.js → index-8469865e.js} +2 -2
  60. package/_verture/{index-68db2bc3.js → index-e1b800aa.js} +2 -2
  61. package/_verture/{modalContext-c12ca3e8.js → modalContext-670eab09.js} +1 -1
  62. package/_verture/tinycolor-ece3542d.js +1180 -0
  63. package/_verture/{utils-f0e81540.js → utils-06d86594.js} +3 -6
  64. package/index.js +11 -11
  65. package/locale/index.js +2 -2
  66. package/package.json +51 -8
  67. package/umd/AutoBox.js +1 -1
  68. package/umd/AutoTips.js +4 -4
  69. package/umd/Breadcrumbs.js +2 -2
  70. package/umd/Button.js +2 -2
  71. package/umd/ButtonGroup.js +4 -4
  72. package/umd/Cascader.js +6 -6
  73. package/umd/Checkbox.js +5 -5
  74. package/umd/CheckboxGroup.js +5 -5
  75. package/umd/ColorPicker.js +1 -1
  76. package/umd/ComboSelect.js +6 -6
  77. package/umd/CopyText.js +2 -2
  78. package/umd/DatePicker.js +2 -2
  79. package/umd/Desktop.js +2 -2
  80. package/umd/Drawer.js +4 -4
  81. package/umd/DynamicMultiBox.js +4 -4
  82. package/umd/Form.js +2 -2
  83. package/umd/FormItem.js +4 -4
  84. package/umd/FunctionModal.js +2 -2
  85. package/umd/GlobalContext.js +1 -1
  86. package/umd/Help.js +2 -2
  87. package/umd/InputLang.js +4 -4
  88. package/umd/InputNumber.js +2 -2
  89. package/umd/Label.js +2 -2
  90. package/umd/Modal.js +2 -2
  91. package/umd/MultiBox.js +2 -2
  92. package/umd/Notification.js +1 -1
  93. package/umd/OperateBtn.js +2 -2
  94. package/umd/PageHeader.js +2 -2
  95. package/umd/Pagination.js +2 -2
  96. package/umd/ParauiProvider.js +1 -1
  97. package/umd/PasswordRules.js +4 -4
  98. package/umd/PopConfirm.js +2 -2
  99. package/umd/Popover.js +1 -1
  100. package/umd/Radio.js +2 -2
  101. package/umd/RadioGroup.js +2 -2
  102. package/umd/Search.js +2 -2
  103. package/umd/Select.js +2 -2
  104. package/umd/SelectInput.js +2 -2
  105. package/umd/Selector.js +2 -2
  106. package/umd/SelectorPicker.js +2 -2
  107. package/umd/SingleBox.js +2 -2
  108. package/umd/Status.js +4 -4
  109. package/umd/Stepper.js +2 -2
  110. package/umd/Switch.js +2 -2
  111. package/umd/Table.js +6 -6
  112. package/umd/Tabs.js +2 -2
  113. package/umd/Tag.js +2 -2
  114. package/umd/TextEditor.js +2 -2
  115. package/umd/TextField.js +2 -2
  116. package/umd/TimePicker.js +2 -2
  117. package/umd/Title.js +2 -2
  118. package/umd/ToggleButton.js +4 -4
  119. package/umd/Tooltip.js +1 -1
  120. package/umd/Transfer.js +5 -5
  121. package/umd/Tree.js +7 -7
  122. package/umd/Upload.js +2 -2
  123. package/umd/locale.js +1 -1
  124. /package/_verture/{typeof-b240b062.js → typeof-c310ee4a.js} +0 -0
package/Tag/index.js CHANGED
@@ -7,9 +7,10 @@ import CloseIcon from '@para-ui/icons/Close';
7
7
  import EditIcon from '@para-ui/icons/EditOutline';
8
8
  import clsx from 'clsx';
9
9
  import { _ as _toConsumableArray } from '../_verture/toConsumableArray-8f4c9589.js';
10
- import { _ as _typeof$1 } from '../_verture/typeof-adeedc13.js';
10
+ import { _ as _typeof } from '../_verture/typeof-adeedc13.js';
11
11
  import { $ as $prefixCls } from '../_verture/constant-0d9802f7.js';
12
12
  import AutoTips from '../AutoTips/index.js';
13
+ import { t as tinycolor } from '../_verture/tinycolor-ece3542d.js';
13
14
  import { s as styleInject } from '../_verture/style-inject.es-300983ab.js';
14
15
  import Plus from '@para-ui/icons/Plus';
15
16
  import '../_verture/unsupportedIterableToArray-cb478f24.js';
@@ -19,7 +20,7 @@ import 'rc-tooltip/lib/placements';
19
20
  import '@para-ui/icons/Forbid';
20
21
  import '@paraview/lib';
21
22
 
22
- var css_248z = "@charset \"UTF-8\";\n/**\n* @author Hanz\n* @date 2022/1/12 上午9:43\n* @description\n*/\n/**\n* @author linhd\n* @date 2023/4/11 14:16\n* @description 最新色卡\n*/\n.paraui-v4-tag-outline.paraui-v4-tag {\n border: 0.5px solid rgb(92, 101, 115);\n}\n.paraui-v4-tag-outline.paraui-v4-tag-blue {\n border: 0.5px solid rgb(46, 101, 230);\n}\n.paraui-v4-tag-outline.paraui-v4-tag-green {\n border: 0.5px solid rgb(19, 191, 76);\n}\n.paraui-v4-tag-outline.paraui-v4-tag-yellow {\n border: 0.5px solid rgb(255, 147, 38);\n}\n.paraui-v4-tag-outline.paraui-v4-tag-red {\n border: 0.5px solid rgb(244, 66, 66);\n}\n\n.paraui-v4-tag-edit-input {\n height: 24px;\n align-self: flex-start;\n margin: 0 8px 8px 0;\n font-size: 14px;\n color: rgb(29, 33, 38);\n text-indent: 8px;\n border: 1px solid rgb(46, 101, 230);\n border-radius: 4px;\n}\n\n.paraui-v4-tag {\n display: inline-flex;\n justify-content: center;\n align-items: center;\n max-width: 100%;\n height: 24px;\n margin: 0 8px 8px 0;\n padding: 0 10px;\n font-size: 14px;\n color: rgb(29, 33, 38);\n white-space: nowrap;\n background: rgb(234, 236, 241);\n border-radius: 4px;\n line-height: 18px;\n}\n.paraui-v4-tag .tag-close-icon:hover {\n background-color: rgb(212, 218, 227);\n}\n.paraui-v4-tag .tag-edit-icon {\n display: flex;\n}\n.paraui-v4-tag.paraui-v4-tag-small {\n height: 20px;\n font-size: 12px;\n padding: 0 6px;\n}\n.paraui-v4-tag.paraui-v4-tag-small > svg {\n font-size: 12px;\n}\n.paraui-v4-tag.paraui-v4-tag-small > svg + .paraui-v4-auto-tips {\n margin-left: 2px;\n}\n.paraui-v4-tag.paraui-v4-tag-small .tag-close-icon {\n margin-left: 2px;\n}\n.paraui-v4-tag.paraui-v4-tag-small .tag-edit-icon {\n font-size: 12px;\n}\n.paraui-v4-tag > svg {\n color: inherit;\n font-size: 500;\n}\n.paraui-v4-tag .tag-edit-icon {\n color: inherit;\n font-size: 500;\n cursor: pointer;\n}\n.paraui-v4-tag .tag-edit-icon > svg {\n color: rgb(29, 33, 38);\n}\n.paraui-v4-tag .tag-close-icon {\n margin-left: 4px;\n color: inherit;\n font-size: 500;\n cursor: pointer;\n}\n.paraui-v4-tag .tag-close-icon:hover {\n color: inherit;\n}\n.paraui-v4-tag > svg + .paraui-v4-auto-tips {\n margin-left: 4px;\n}\n.paraui-v4-tag.paraui-v4-tag-has-color, .paraui-v4-tag.paraui-v4-tag-has-color svg, .paraui-v4-tag.paraui-v4-tag-has-color svg:hover {\n color: inherit;\n}\n.paraui-v4-tag.paraui-v4-tag-blue {\n color: rgb(46, 101, 230);\n background-color: rgba(46, 101, 230, 0.1);\n}\n.paraui-v4-tag.paraui-v4-tag-green {\n color: rgb(19, 191, 76);\n background-color: rgba(19, 191, 76, 0.1);\n}\n.paraui-v4-tag.paraui-v4-tag-yellow {\n color: rgb(255, 147, 38);\n background-color: rgba(255, 147, 38, 0.1);\n}\n.paraui-v4-tag.paraui-v4-tag-red {\n color: rgb(244, 66, 66);\n background-color: rgba(244, 66, 66, 0.1);\n}\n.paraui-v4-tag.paraui-v4-tag-hidden {\n display: none;\n}\n\n.paraui-v4-tag-group {\n display: flex;\n align-items: center;\n flex-flow: row wrap;\n}\n.paraui-v4-tag-group .tag-group-input {\n height: 24px;\n align-self: flex-start;\n font-size: 14px;\n color: rgb(29, 33, 38);\n text-indent: 8px;\n border: 1px solid rgb(46, 101, 230);\n border-radius: 4px;\n}\n.paraui-v4-tag-group .tag-group-input .tag-group-input-large {\n height: 28px;\n}\n.paraui-v4-tag-group .tag-group-new .tag-group-new-icon {\n padding: 0 5px;\n}\n.paraui-v4-tag-group .tag-group-add-btn {\n border: 1px dashed rgb(212, 218, 227);\n}\n.paraui-v4-tag-group .tag-group-add-btn .tag-edit-icon {\n background: none !important;\n}\n.paraui-v4-tag-group .tag-group-add-btn:hover {\n cursor: pointer;\n}\n.paraui-v4-tag-group .tag-group-add-btn:hover svg {\n color: rgb(46, 101, 230);\n}\n.paraui-v4-tag-group .tag-group-add-btn:hover .tag-text {\n color: rgb(46, 101, 230);\n}";
23
+ var css_248z = "@charset \"UTF-8\";\n/**\n* @author Hanz\n* @date 2022/1/12 上午9:43\n* @description\n*/\n/**\n* @author linhd\n* @date 2023/4/11 14:16\n* @description 最新色卡\n*/\n.paraui-v4-tag-outline.paraui-v4-tag {\n border: 0.5px solid rgb(92, 101, 115);\n}\n.paraui-v4-tag-outline.paraui-v4-tag-blue {\n border: 0.5px solid rgb(46, 101, 230);\n}\n.paraui-v4-tag-outline.paraui-v4-tag-green {\n border: 0.5px solid rgb(19, 191, 76);\n}\n.paraui-v4-tag-outline.paraui-v4-tag-yellow {\n border: 0.5px solid rgb(255, 147, 38);\n}\n.paraui-v4-tag-outline.paraui-v4-tag-red {\n border: 0.5px solid rgb(244, 66, 66);\n}\n\n.paraui-v4-tag-edit-input {\n height: 24px;\n align-self: flex-start;\n margin: 0 8px 8px 0;\n font-size: 14px;\n color: rgb(29, 33, 38);\n text-indent: 8px;\n border: 1px solid rgb(46, 101, 230);\n border-radius: 4px;\n}\n\n.paraui-v4-tag {\n display: inline-flex;\n justify-content: center;\n align-items: center;\n max-width: 100%;\n height: 24px;\n margin: 0 8px 8px 0;\n padding: 0 10px;\n font-size: 14px;\n color: rgb(29, 33, 38);\n white-space: nowrap;\n background: rgb(234, 236, 241);\n border-radius: 4px;\n line-height: 18px;\n}\n.paraui-v4-tag .tag-close-icon:hover {\n background-color: rgb(212, 218, 227);\n}\n.paraui-v4-tag .tag-edit-icon {\n display: flex;\n}\n.paraui-v4-tag.paraui-v4-tag-small {\n height: 20px;\n font-size: 12px;\n padding: 0 6px;\n}\n.paraui-v4-tag.paraui-v4-tag-small > svg {\n font-size: 12px;\n}\n.paraui-v4-tag.paraui-v4-tag-small > svg + .paraui-v4-auto-tips {\n margin-left: 2px;\n}\n.paraui-v4-tag.paraui-v4-tag-small .tag-close-icon {\n margin-left: 2px;\n}\n.paraui-v4-tag.paraui-v4-tag-small .tag-edit-icon {\n font-size: 12px;\n}\n.paraui-v4-tag > svg {\n color: inherit;\n font-size: 16px;\n}\n.paraui-v4-tag .tag-edit-icon {\n color: inherit;\n font-size: 16px;\n cursor: pointer;\n}\n.paraui-v4-tag .tag-edit-icon > svg {\n color: rgb(29, 33, 38);\n}\n.paraui-v4-tag .tag-close-icon {\n margin-left: 4px;\n color: inherit;\n font-size: 16px;\n cursor: pointer;\n}\n.paraui-v4-tag .tag-close-icon:hover {\n color: inherit;\n}\n.paraui-v4-tag > svg + .paraui-v4-auto-tips {\n margin-left: 4px;\n}\n.paraui-v4-tag.paraui-v4-tag-has-color, .paraui-v4-tag.paraui-v4-tag-has-color svg, .paraui-v4-tag.paraui-v4-tag-has-color svg:hover {\n color: inherit;\n}\n.paraui-v4-tag.paraui-v4-tag-blue {\n color: rgb(46, 101, 230);\n background-color: rgba(46, 101, 230, 0.1);\n}\n.paraui-v4-tag.paraui-v4-tag-green {\n color: rgb(19, 191, 76);\n background-color: rgba(19, 191, 76, 0.1);\n}\n.paraui-v4-tag.paraui-v4-tag-yellow {\n color: rgb(255, 147, 38);\n background-color: rgba(255, 147, 38, 0.1);\n}\n.paraui-v4-tag.paraui-v4-tag-red {\n color: rgb(244, 66, 66);\n background-color: rgba(244, 66, 66, 0.1);\n}\n.paraui-v4-tag.paraui-v4-tag-hidden {\n display: none;\n}\n\n.paraui-v4-tag-group {\n display: flex;\n align-items: center;\n flex-flow: row wrap;\n}\n.paraui-v4-tag-group .tag-group-input {\n height: 24px;\n align-self: flex-start;\n font-size: 14px;\n color: rgb(29, 33, 38);\n text-indent: 8px;\n border: 1px solid rgb(46, 101, 230);\n border-radius: 4px;\n}\n.paraui-v4-tag-group .tag-group-input .tag-group-input-large {\n height: 28px;\n}\n.paraui-v4-tag-group .tag-group-new .tag-group-new-icon {\n padding: 0 5px;\n}\n.paraui-v4-tag-group .tag-group-add-btn {\n border: 1px dashed rgb(212, 218, 227);\n}\n.paraui-v4-tag-group .tag-group-add-btn .tag-edit-icon {\n background: none !important;\n}\n.paraui-v4-tag-group .tag-group-add-btn:hover {\n cursor: pointer;\n}\n.paraui-v4-tag-group .tag-group-add-btn:hover svg {\n color: rgb(46, 101, 230);\n}\n.paraui-v4-tag-group .tag-group-add-btn:hover .tag-text {\n color: rgb(46, 101, 230);\n}";
23
24
  styleInject(css_248z);
24
25
 
25
26
  //tag group
@@ -57,7 +58,7 @@ var TagGroup = function TagGroup(props) {
57
58
  var tArr = props.data;
58
59
  //Item[]
59
60
  var unObjType = tArr.some(function (v) {
60
- return ["string", "number"].includes(_typeof$1(v));
61
+ return ["string", "number"].includes(_typeof(v));
61
62
  });
62
63
  if (unObjType) {
63
64
  tArr = tArr.map(function (_) {
@@ -194,1185 +195,6 @@ var TagGroup = function TagGroup(props) {
194
195
  }));
195
196
  };
196
197
 
197
- // This file is autogenerated. It's used to publish ESM to npm.
198
- function _typeof(obj) {
199
- "@babel/helpers - typeof";
200
-
201
- return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
202
- return typeof obj;
203
- } : function (obj) {
204
- return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
205
- }, _typeof(obj);
206
- }
207
-
208
- // https://github.com/bgrins/TinyColor
209
- // Brian Grinstead, MIT License
210
-
211
- var trimLeft = /^\s+/;
212
- var trimRight = /\s+$/;
213
- function tinycolor(color, opts) {
214
- color = color ? color : "";
215
- opts = opts || {};
216
-
217
- // If input is already a tinycolor, return itself
218
- if (color instanceof tinycolor) {
219
- return color;
220
- }
221
- // If we are called as a function, call using new instead
222
- if (!(this instanceof tinycolor)) {
223
- return new tinycolor(color, opts);
224
- }
225
- var rgb = inputToRGB(color);
226
- this._originalInput = color, this._r = rgb.r, this._g = rgb.g, this._b = rgb.b, this._a = rgb.a, this._roundA = Math.round(100 * this._a) / 100, this._format = opts.format || rgb.format;
227
- this._gradientType = opts.gradientType;
228
-
229
- // Don't let the range of [0,255] come back in [0,1].
230
- // Potentially lose a little bit of precision here, but will fix issues where
231
- // .5 gets interpreted as half of the total, instead of half of 1
232
- // If it was supposed to be 128, this was already taken care of by `inputToRgb`
233
- if (this._r < 1) this._r = Math.round(this._r);
234
- if (this._g < 1) this._g = Math.round(this._g);
235
- if (this._b < 1) this._b = Math.round(this._b);
236
- this._ok = rgb.ok;
237
- }
238
- tinycolor.prototype = {
239
- isDark: function isDark() {
240
- return this.getBrightness() < 128;
241
- },
242
- isLight: function isLight() {
243
- return !this.isDark();
244
- },
245
- isValid: function isValid() {
246
- return this._ok;
247
- },
248
- getOriginalInput: function getOriginalInput() {
249
- return this._originalInput;
250
- },
251
- getFormat: function getFormat() {
252
- return this._format;
253
- },
254
- getAlpha: function getAlpha() {
255
- return this._a;
256
- },
257
- getBrightness: function getBrightness() {
258
- //http://www.w3.org/TR/AERT#color-contrast
259
- var rgb = this.toRgb();
260
- return (rgb.r * 299 + rgb.g * 587 + rgb.b * 114) / 1000;
261
- },
262
- getLuminance: function getLuminance() {
263
- //http://www.w3.org/TR/2008/REC-WCAG20-20081211/#relativeluminancedef
264
- var rgb = this.toRgb();
265
- var RsRGB, GsRGB, BsRGB, R, G, B;
266
- RsRGB = rgb.r / 255;
267
- GsRGB = rgb.g / 255;
268
- BsRGB = rgb.b / 255;
269
- if (RsRGB <= 0.03928) R = RsRGB / 12.92;else R = Math.pow((RsRGB + 0.055) / 1.055, 2.4);
270
- if (GsRGB <= 0.03928) G = GsRGB / 12.92;else G = Math.pow((GsRGB + 0.055) / 1.055, 2.4);
271
- if (BsRGB <= 0.03928) B = BsRGB / 12.92;else B = Math.pow((BsRGB + 0.055) / 1.055, 2.4);
272
- return 0.2126 * R + 0.7152 * G + 0.0722 * B;
273
- },
274
- setAlpha: function setAlpha(value) {
275
- this._a = boundAlpha(value);
276
- this._roundA = Math.round(100 * this._a) / 100;
277
- return this;
278
- },
279
- toHsv: function toHsv() {
280
- var hsv = rgbToHsv(this._r, this._g, this._b);
281
- return {
282
- h: hsv.h * 360,
283
- s: hsv.s,
284
- v: hsv.v,
285
- a: this._a
286
- };
287
- },
288
- toHsvString: function toHsvString() {
289
- var hsv = rgbToHsv(this._r, this._g, this._b);
290
- var h = Math.round(hsv.h * 360),
291
- s = Math.round(hsv.s * 100),
292
- v = Math.round(hsv.v * 100);
293
- return this._a == 1 ? "hsv(" + h + ", " + s + "%, " + v + "%)" : "hsva(" + h + ", " + s + "%, " + v + "%, " + this._roundA + ")";
294
- },
295
- toHsl: function toHsl() {
296
- var hsl = rgbToHsl(this._r, this._g, this._b);
297
- return {
298
- h: hsl.h * 360,
299
- s: hsl.s,
300
- l: hsl.l,
301
- a: this._a
302
- };
303
- },
304
- toHslString: function toHslString() {
305
- var hsl = rgbToHsl(this._r, this._g, this._b);
306
- var h = Math.round(hsl.h * 360),
307
- s = Math.round(hsl.s * 100),
308
- l = Math.round(hsl.l * 100);
309
- return this._a == 1 ? "hsl(" + h + ", " + s + "%, " + l + "%)" : "hsla(" + h + ", " + s + "%, " + l + "%, " + this._roundA + ")";
310
- },
311
- toHex: function toHex(allow3Char) {
312
- return rgbToHex(this._r, this._g, this._b, allow3Char);
313
- },
314
- toHexString: function toHexString(allow3Char) {
315
- return "#" + this.toHex(allow3Char);
316
- },
317
- toHex8: function toHex8(allow4Char) {
318
- return rgbaToHex(this._r, this._g, this._b, this._a, allow4Char);
319
- },
320
- toHex8String: function toHex8String(allow4Char) {
321
- return "#" + this.toHex8(allow4Char);
322
- },
323
- toRgb: function toRgb() {
324
- return {
325
- r: Math.round(this._r),
326
- g: Math.round(this._g),
327
- b: Math.round(this._b),
328
- a: this._a
329
- };
330
- },
331
- toRgbString: function toRgbString() {
332
- return this._a == 1 ? "rgb(" + Math.round(this._r) + ", " + Math.round(this._g) + ", " + Math.round(this._b) + ")" : "rgba(" + Math.round(this._r) + ", " + Math.round(this._g) + ", " + Math.round(this._b) + ", " + this._roundA + ")";
333
- },
334
- toPercentageRgb: function toPercentageRgb() {
335
- return {
336
- r: Math.round(bound01(this._r, 255) * 100) + "%",
337
- g: Math.round(bound01(this._g, 255) * 100) + "%",
338
- b: Math.round(bound01(this._b, 255) * 100) + "%",
339
- a: this._a
340
- };
341
- },
342
- toPercentageRgbString: function toPercentageRgbString() {
343
- return this._a == 1 ? "rgb(" + Math.round(bound01(this._r, 255) * 100) + "%, " + Math.round(bound01(this._g, 255) * 100) + "%, " + Math.round(bound01(this._b, 255) * 100) + "%)" : "rgba(" + Math.round(bound01(this._r, 255) * 100) + "%, " + Math.round(bound01(this._g, 255) * 100) + "%, " + Math.round(bound01(this._b, 255) * 100) + "%, " + this._roundA + ")";
344
- },
345
- toName: function toName() {
346
- if (this._a === 0) {
347
- return "transparent";
348
- }
349
- if (this._a < 1) {
350
- return false;
351
- }
352
- return hexNames[rgbToHex(this._r, this._g, this._b, true)] || false;
353
- },
354
- toFilter: function toFilter(secondColor) {
355
- var hex8String = "#" + rgbaToArgbHex(this._r, this._g, this._b, this._a);
356
- var secondHex8String = hex8String;
357
- var gradientType = this._gradientType ? "GradientType = 1, " : "";
358
- if (secondColor) {
359
- var s = tinycolor(secondColor);
360
- secondHex8String = "#" + rgbaToArgbHex(s._r, s._g, s._b, s._a);
361
- }
362
- return "progid:DXImageTransform.Microsoft.gradient(" + gradientType + "startColorstr=" + hex8String + ",endColorstr=" + secondHex8String + ")";
363
- },
364
- toString: function toString(format) {
365
- var formatSet = !!format;
366
- format = format || this._format;
367
- var formattedString = false;
368
- var hasAlpha = this._a < 1 && this._a >= 0;
369
- var needsAlphaFormat = !formatSet && hasAlpha && (format === "hex" || format === "hex6" || format === "hex3" || format === "hex4" || format === "hex8" || format === "name");
370
- if (needsAlphaFormat) {
371
- // Special case for "transparent", all other non-alpha formats
372
- // will return rgba when there is transparency.
373
- if (format === "name" && this._a === 0) {
374
- return this.toName();
375
- }
376
- return this.toRgbString();
377
- }
378
- if (format === "rgb") {
379
- formattedString = this.toRgbString();
380
- }
381
- if (format === "prgb") {
382
- formattedString = this.toPercentageRgbString();
383
- }
384
- if (format === "hex" || format === "hex6") {
385
- formattedString = this.toHexString();
386
- }
387
- if (format === "hex3") {
388
- formattedString = this.toHexString(true);
389
- }
390
- if (format === "hex4") {
391
- formattedString = this.toHex8String(true);
392
- }
393
- if (format === "hex8") {
394
- formattedString = this.toHex8String();
395
- }
396
- if (format === "name") {
397
- formattedString = this.toName();
398
- }
399
- if (format === "hsl") {
400
- formattedString = this.toHslString();
401
- }
402
- if (format === "hsv") {
403
- formattedString = this.toHsvString();
404
- }
405
- return formattedString || this.toHexString();
406
- },
407
- clone: function clone() {
408
- return tinycolor(this.toString());
409
- },
410
- _applyModification: function _applyModification(fn, args) {
411
- var color = fn.apply(null, [this].concat([].slice.call(args)));
412
- this._r = color._r;
413
- this._g = color._g;
414
- this._b = color._b;
415
- this.setAlpha(color._a);
416
- return this;
417
- },
418
- lighten: function lighten() {
419
- return this._applyModification(_lighten, arguments);
420
- },
421
- brighten: function brighten() {
422
- return this._applyModification(_brighten, arguments);
423
- },
424
- darken: function darken() {
425
- return this._applyModification(_darken, arguments);
426
- },
427
- desaturate: function desaturate() {
428
- return this._applyModification(_desaturate, arguments);
429
- },
430
- saturate: function saturate() {
431
- return this._applyModification(_saturate, arguments);
432
- },
433
- greyscale: function greyscale() {
434
- return this._applyModification(_greyscale, arguments);
435
- },
436
- spin: function spin() {
437
- return this._applyModification(_spin, arguments);
438
- },
439
- _applyCombination: function _applyCombination(fn, args) {
440
- return fn.apply(null, [this].concat([].slice.call(args)));
441
- },
442
- analogous: function analogous() {
443
- return this._applyCombination(_analogous, arguments);
444
- },
445
- complement: function complement() {
446
- return this._applyCombination(_complement, arguments);
447
- },
448
- monochromatic: function monochromatic() {
449
- return this._applyCombination(_monochromatic, arguments);
450
- },
451
- splitcomplement: function splitcomplement() {
452
- return this._applyCombination(_splitcomplement, arguments);
453
- },
454
- // Disabled until https://github.com/bgrins/TinyColor/issues/254
455
- // polyad: function (number) {
456
- // return this._applyCombination(polyad, [number]);
457
- // },
458
- triad: function triad() {
459
- return this._applyCombination(polyad, [3]);
460
- },
461
- tetrad: function tetrad() {
462
- return this._applyCombination(polyad, [4]);
463
- }
464
- };
465
-
466
- // If input is an object, force 1 into "1.0" to handle ratios properly
467
- // String input requires "1.0" as input, so 1 will be treated as 1
468
- tinycolor.fromRatio = function (color, opts) {
469
- if (_typeof(color) == "object") {
470
- var newColor = {};
471
- for (var i in color) {
472
- if (color.hasOwnProperty(i)) {
473
- if (i === "a") {
474
- newColor[i] = color[i];
475
- } else {
476
- newColor[i] = convertToPercentage(color[i]);
477
- }
478
- }
479
- }
480
- color = newColor;
481
- }
482
- return tinycolor(color, opts);
483
- };
484
-
485
- // Given a string or object, convert that input to RGB
486
- // Possible string inputs:
487
- //
488
- // "red"
489
- // "#f00" or "f00"
490
- // "#ff0000" or "ff0000"
491
- // "#ff000000" or "ff000000"
492
- // "rgb 255 0 0" or "rgb (255, 0, 0)"
493
- // "rgb 1.0 0 0" or "rgb (1, 0, 0)"
494
- // "rgba (255, 0, 0, 1)" or "rgba 255, 0, 0, 1"
495
- // "rgba (1.0, 0, 0, 1)" or "rgba 1.0, 0, 0, 1"
496
- // "hsl(0, 100%, 50%)" or "hsl 0 100% 50%"
497
- // "hsla(0, 100%, 50%, 1)" or "hsla 0 100% 50%, 1"
498
- // "hsv(0, 100%, 100%)" or "hsv 0 100% 100%"
499
- //
500
- function inputToRGB(color) {
501
- var rgb = {
502
- r: 0,
503
- g: 0,
504
- b: 0
505
- };
506
- var a = 1;
507
- var s = null;
508
- var v = null;
509
- var l = null;
510
- var ok = false;
511
- var format = false;
512
- if (typeof color == "string") {
513
- color = stringInputToObject(color);
514
- }
515
- if (_typeof(color) == "object") {
516
- if (isValidCSSUnit(color.r) && isValidCSSUnit(color.g) && isValidCSSUnit(color.b)) {
517
- rgb = rgbToRgb(color.r, color.g, color.b);
518
- ok = true;
519
- format = String(color.r).substr(-1) === "%" ? "prgb" : "rgb";
520
- } else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.v)) {
521
- s = convertToPercentage(color.s);
522
- v = convertToPercentage(color.v);
523
- rgb = hsvToRgb(color.h, s, v);
524
- ok = true;
525
- format = "hsv";
526
- } else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.l)) {
527
- s = convertToPercentage(color.s);
528
- l = convertToPercentage(color.l);
529
- rgb = hslToRgb(color.h, s, l);
530
- ok = true;
531
- format = "hsl";
532
- }
533
- if (color.hasOwnProperty("a")) {
534
- a = color.a;
535
- }
536
- }
537
- a = boundAlpha(a);
538
- return {
539
- ok: ok,
540
- format: color.format || format,
541
- r: Math.min(255, Math.max(rgb.r, 0)),
542
- g: Math.min(255, Math.max(rgb.g, 0)),
543
- b: Math.min(255, Math.max(rgb.b, 0)),
544
- a: a
545
- };
546
- }
547
-
548
- // Conversion Functions
549
- // --------------------
550
-
551
- // `rgbToHsl`, `rgbToHsv`, `hslToRgb`, `hsvToRgb` modified from:
552
- // <http://mjijackson.com/2008/02/rgb-to-hsl-and-rgb-to-hsv-color-model-conversion-algorithms-in-javascript>
553
-
554
- // `rgbToRgb`
555
- // Handle bounds / percentage checking to conform to CSS color spec
556
- // <http://www.w3.org/TR/css3-color/>
557
- // *Assumes:* r, g, b in [0, 255] or [0, 1]
558
- // *Returns:* { r, g, b } in [0, 255]
559
- function rgbToRgb(r, g, b) {
560
- return {
561
- r: bound01(r, 255) * 255,
562
- g: bound01(g, 255) * 255,
563
- b: bound01(b, 255) * 255
564
- };
565
- }
566
-
567
- // `rgbToHsl`
568
- // Converts an RGB color value to HSL.
569
- // *Assumes:* r, g, and b are contained in [0, 255] or [0, 1]
570
- // *Returns:* { h, s, l } in [0,1]
571
- function rgbToHsl(r, g, b) {
572
- r = bound01(r, 255);
573
- g = bound01(g, 255);
574
- b = bound01(b, 255);
575
- var max = Math.max(r, g, b),
576
- min = Math.min(r, g, b);
577
- var h,
578
- s,
579
- l = (max + min) / 2;
580
- if (max == min) {
581
- h = s = 0; // achromatic
582
- } else {
583
- var d = max - min;
584
- s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
585
- switch (max) {
586
- case r:
587
- h = (g - b) / d + (g < b ? 6 : 0);
588
- break;
589
- case g:
590
- h = (b - r) / d + 2;
591
- break;
592
- case b:
593
- h = (r - g) / d + 4;
594
- break;
595
- }
596
- h /= 6;
597
- }
598
- return {
599
- h: h,
600
- s: s,
601
- l: l
602
- };
603
- }
604
-
605
- // `hslToRgb`
606
- // Converts an HSL color value to RGB.
607
- // *Assumes:* h is contained in [0, 1] or [0, 360] and s and l are contained [0, 1] or [0, 100]
608
- // *Returns:* { r, g, b } in the set [0, 255]
609
- function hslToRgb(h, s, l) {
610
- var r, g, b;
611
- h = bound01(h, 360);
612
- s = bound01(s, 100);
613
- l = bound01(l, 100);
614
- function hue2rgb(p, q, t) {
615
- if (t < 0) t += 1;
616
- if (t > 1) t -= 1;
617
- if (t < 1 / 6) return p + (q - p) * 6 * t;
618
- if (t < 1 / 2) return q;
619
- if (t < 2 / 3) return p + (q - p) * (2 / 3 - t) * 6;
620
- return p;
621
- }
622
- if (s === 0) {
623
- r = g = b = l; // achromatic
624
- } else {
625
- var q = l < 0.5 ? l * (1 + s) : l + s - l * s;
626
- var p = 2 * l - q;
627
- r = hue2rgb(p, q, h + 1 / 3);
628
- g = hue2rgb(p, q, h);
629
- b = hue2rgb(p, q, h - 1 / 3);
630
- }
631
- return {
632
- r: r * 255,
633
- g: g * 255,
634
- b: b * 255
635
- };
636
- }
637
-
638
- // `rgbToHsv`
639
- // Converts an RGB color value to HSV
640
- // *Assumes:* r, g, and b are contained in the set [0, 255] or [0, 1]
641
- // *Returns:* { h, s, v } in [0,1]
642
- function rgbToHsv(r, g, b) {
643
- r = bound01(r, 255);
644
- g = bound01(g, 255);
645
- b = bound01(b, 255);
646
- var max = Math.max(r, g, b),
647
- min = Math.min(r, g, b);
648
- var h,
649
- s,
650
- v = max;
651
- var d = max - min;
652
- s = max === 0 ? 0 : d / max;
653
- if (max == min) {
654
- h = 0; // achromatic
655
- } else {
656
- switch (max) {
657
- case r:
658
- h = (g - b) / d + (g < b ? 6 : 0);
659
- break;
660
- case g:
661
- h = (b - r) / d + 2;
662
- break;
663
- case b:
664
- h = (r - g) / d + 4;
665
- break;
666
- }
667
- h /= 6;
668
- }
669
- return {
670
- h: h,
671
- s: s,
672
- v: v
673
- };
674
- }
675
-
676
- // `hsvToRgb`
677
- // Converts an HSV color value to RGB.
678
- // *Assumes:* h is contained in [0, 1] or [0, 360] and s and v are contained in [0, 1] or [0, 100]
679
- // *Returns:* { r, g, b } in the set [0, 255]
680
- function hsvToRgb(h, s, v) {
681
- h = bound01(h, 360) * 6;
682
- s = bound01(s, 100);
683
- v = bound01(v, 100);
684
- var i = Math.floor(h),
685
- f = h - i,
686
- p = v * (1 - s),
687
- q = v * (1 - f * s),
688
- t = v * (1 - (1 - f) * s),
689
- mod = i % 6,
690
- r = [v, q, p, p, t, v][mod],
691
- g = [t, v, v, q, p, p][mod],
692
- b = [p, p, t, v, v, q][mod];
693
- return {
694
- r: r * 255,
695
- g: g * 255,
696
- b: b * 255
697
- };
698
- }
699
-
700
- // `rgbToHex`
701
- // Converts an RGB color to hex
702
- // Assumes r, g, and b are contained in the set [0, 255]
703
- // Returns a 3 or 6 character hex
704
- function rgbToHex(r, g, b, allow3Char) {
705
- var hex = [pad2(Math.round(r).toString(16)), pad2(Math.round(g).toString(16)), pad2(Math.round(b).toString(16))];
706
-
707
- // Return a 3 character hex if possible
708
- if (allow3Char && hex[0].charAt(0) == hex[0].charAt(1) && hex[1].charAt(0) == hex[1].charAt(1) && hex[2].charAt(0) == hex[2].charAt(1)) {
709
- return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0);
710
- }
711
- return hex.join("");
712
- }
713
-
714
- // `rgbaToHex`
715
- // Converts an RGBA color plus alpha transparency to hex
716
- // Assumes r, g, b are contained in the set [0, 255] and
717
- // a in [0, 1]. Returns a 4 or 8 character rgba hex
718
- function rgbaToHex(r, g, b, a, allow4Char) {
719
- var hex = [pad2(Math.round(r).toString(16)), pad2(Math.round(g).toString(16)), pad2(Math.round(b).toString(16)), pad2(convertDecimalToHex(a))];
720
-
721
- // Return a 4 character hex if possible
722
- if (allow4Char && hex[0].charAt(0) == hex[0].charAt(1) && hex[1].charAt(0) == hex[1].charAt(1) && hex[2].charAt(0) == hex[2].charAt(1) && hex[3].charAt(0) == hex[3].charAt(1)) {
723
- return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0) + hex[3].charAt(0);
724
- }
725
- return hex.join("");
726
- }
727
-
728
- // `rgbaToArgbHex`
729
- // Converts an RGBA color to an ARGB Hex8 string
730
- // Rarely used, but required for "toFilter()"
731
- function rgbaToArgbHex(r, g, b, a) {
732
- var hex = [pad2(convertDecimalToHex(a)), pad2(Math.round(r).toString(16)), pad2(Math.round(g).toString(16)), pad2(Math.round(b).toString(16))];
733
- return hex.join("");
734
- }
735
-
736
- // `equals`
737
- // Can be called with any tinycolor input
738
- tinycolor.equals = function (color1, color2) {
739
- if (!color1 || !color2) return false;
740
- return tinycolor(color1).toRgbString() == tinycolor(color2).toRgbString();
741
- };
742
- tinycolor.random = function () {
743
- return tinycolor.fromRatio({
744
- r: Math.random(),
745
- g: Math.random(),
746
- b: Math.random()
747
- });
748
- };
749
-
750
- // Modification Functions
751
- // ----------------------
752
- // Thanks to less.js for some of the basics here
753
- // <https://github.com/cloudhead/less.js/blob/master/lib/less/functions.js>
754
-
755
- function _desaturate(color, amount) {
756
- amount = amount === 0 ? 0 : amount || 10;
757
- var hsl = tinycolor(color).toHsl();
758
- hsl.s -= amount / 100;
759
- hsl.s = clamp01(hsl.s);
760
- return tinycolor(hsl);
761
- }
762
- function _saturate(color, amount) {
763
- amount = amount === 0 ? 0 : amount || 10;
764
- var hsl = tinycolor(color).toHsl();
765
- hsl.s += amount / 100;
766
- hsl.s = clamp01(hsl.s);
767
- return tinycolor(hsl);
768
- }
769
- function _greyscale(color) {
770
- return tinycolor(color).desaturate(100);
771
- }
772
- function _lighten(color, amount) {
773
- amount = amount === 0 ? 0 : amount || 10;
774
- var hsl = tinycolor(color).toHsl();
775
- hsl.l += amount / 100;
776
- hsl.l = clamp01(hsl.l);
777
- return tinycolor(hsl);
778
- }
779
- function _brighten(color, amount) {
780
- amount = amount === 0 ? 0 : amount || 10;
781
- var rgb = tinycolor(color).toRgb();
782
- rgb.r = Math.max(0, Math.min(255, rgb.r - Math.round(255 * -(amount / 100))));
783
- rgb.g = Math.max(0, Math.min(255, rgb.g - Math.round(255 * -(amount / 100))));
784
- rgb.b = Math.max(0, Math.min(255, rgb.b - Math.round(255 * -(amount / 100))));
785
- return tinycolor(rgb);
786
- }
787
- function _darken(color, amount) {
788
- amount = amount === 0 ? 0 : amount || 10;
789
- var hsl = tinycolor(color).toHsl();
790
- hsl.l -= amount / 100;
791
- hsl.l = clamp01(hsl.l);
792
- return tinycolor(hsl);
793
- }
794
-
795
- // Spin takes a positive or negative amount within [-360, 360] indicating the change of hue.
796
- // Values outside of this range will be wrapped into this range.
797
- function _spin(color, amount) {
798
- var hsl = tinycolor(color).toHsl();
799
- var hue = (hsl.h + amount) % 360;
800
- hsl.h = hue < 0 ? 360 + hue : hue;
801
- return tinycolor(hsl);
802
- }
803
-
804
- // Combination Functions
805
- // ---------------------
806
- // Thanks to jQuery xColor for some of the ideas behind these
807
- // <https://github.com/infusion/jQuery-xcolor/blob/master/jquery.xcolor.js>
808
-
809
- function _complement(color) {
810
- var hsl = tinycolor(color).toHsl();
811
- hsl.h = (hsl.h + 180) % 360;
812
- return tinycolor(hsl);
813
- }
814
- function polyad(color, number) {
815
- if (isNaN(number) || number <= 0) {
816
- throw new Error("Argument to polyad must be a positive number");
817
- }
818
- var hsl = tinycolor(color).toHsl();
819
- var result = [tinycolor(color)];
820
- var step = 360 / number;
821
- for (var i = 1; i < number; i++) {
822
- result.push(tinycolor({
823
- h: (hsl.h + i * step) % 360,
824
- s: hsl.s,
825
- l: hsl.l
826
- }));
827
- }
828
- return result;
829
- }
830
- function _splitcomplement(color) {
831
- var hsl = tinycolor(color).toHsl();
832
- var h = hsl.h;
833
- return [tinycolor(color), tinycolor({
834
- h: (h + 72) % 360,
835
- s: hsl.s,
836
- l: hsl.l
837
- }), tinycolor({
838
- h: (h + 216) % 360,
839
- s: hsl.s,
840
- l: hsl.l
841
- })];
842
- }
843
- function _analogous(color, results, slices) {
844
- results = results || 6;
845
- slices = slices || 30;
846
- var hsl = tinycolor(color).toHsl();
847
- var part = 360 / slices;
848
- var ret = [tinycolor(color)];
849
- for (hsl.h = (hsl.h - (part * results >> 1) + 720) % 360; --results;) {
850
- hsl.h = (hsl.h + part) % 360;
851
- ret.push(tinycolor(hsl));
852
- }
853
- return ret;
854
- }
855
- function _monochromatic(color, results) {
856
- results = results || 6;
857
- var hsv = tinycolor(color).toHsv();
858
- var h = hsv.h,
859
- s = hsv.s,
860
- v = hsv.v;
861
- var ret = [];
862
- var modification = 1 / results;
863
- while (results--) {
864
- ret.push(tinycolor({
865
- h: h,
866
- s: s,
867
- v: v
868
- }));
869
- v = (v + modification) % 1;
870
- }
871
- return ret;
872
- }
873
-
874
- // Utility Functions
875
- // ---------------------
876
-
877
- tinycolor.mix = function (color1, color2, amount) {
878
- amount = amount === 0 ? 0 : amount || 50;
879
- var rgb1 = tinycolor(color1).toRgb();
880
- var rgb2 = tinycolor(color2).toRgb();
881
- var p = amount / 100;
882
- var rgba = {
883
- r: (rgb2.r - rgb1.r) * p + rgb1.r,
884
- g: (rgb2.g - rgb1.g) * p + rgb1.g,
885
- b: (rgb2.b - rgb1.b) * p + rgb1.b,
886
- a: (rgb2.a - rgb1.a) * p + rgb1.a
887
- };
888
- return tinycolor(rgba);
889
- };
890
-
891
- // Readability Functions
892
- // ---------------------
893
- // <http://www.w3.org/TR/2008/REC-WCAG20-20081211/#contrast-ratiodef (WCAG Version 2)
894
-
895
- // `contrast`
896
- // Analyze the 2 colors and returns the color contrast defined by (WCAG Version 2)
897
- tinycolor.readability = function (color1, color2) {
898
- var c1 = tinycolor(color1);
899
- var c2 = tinycolor(color2);
900
- return (Math.max(c1.getLuminance(), c2.getLuminance()) + 0.05) / (Math.min(c1.getLuminance(), c2.getLuminance()) + 0.05);
901
- };
902
-
903
- // `isReadable`
904
- // Ensure that foreground and background color combinations meet WCAG2 guidelines.
905
- // The third argument is an optional Object.
906
- // the 'level' property states 'AA' or 'AAA' - if missing or invalid, it defaults to 'AA';
907
- // the 'size' property states 'large' or 'small' - if missing or invalid, it defaults to 'small'.
908
- // If the entire object is absent, isReadable defaults to {level:"AA",size:"small"}.
909
-
910
- // *Example*
911
- // tinycolor.isReadable("#000", "#111") => false
912
- // tinycolor.isReadable("#000", "#111",{level:"AA",size:"large"}) => false
913
- tinycolor.isReadable = function (color1, color2, wcag2) {
914
- var readability = tinycolor.readability(color1, color2);
915
- var wcag2Parms, out;
916
- out = false;
917
- wcag2Parms = validateWCAG2Parms(wcag2);
918
- switch (wcag2Parms.level + wcag2Parms.size) {
919
- case "AAsmall":
920
- case "AAAlarge":
921
- out = readability >= 4.5;
922
- break;
923
- case "AAlarge":
924
- out = readability >= 3;
925
- break;
926
- case "AAAsmall":
927
- out = readability >= 7;
928
- break;
929
- }
930
- return out;
931
- };
932
-
933
- // `mostReadable`
934
- // Given a base color and a list of possible foreground or background
935
- // colors for that base, returns the most readable color.
936
- // Optionally returns Black or White if the most readable color is unreadable.
937
- // *Example*
938
- // tinycolor.mostReadable(tinycolor.mostReadable("#123", ["#124", "#125"],{includeFallbackColors:false}).toHexString(); // "#112255"
939
- // tinycolor.mostReadable(tinycolor.mostReadable("#123", ["#124", "#125"],{includeFallbackColors:true}).toHexString(); // "#ffffff"
940
- // tinycolor.mostReadable("#a8015a", ["#faf3f3"],{includeFallbackColors:true,level:"AAA",size:"large"}).toHexString(); // "#faf3f3"
941
- // tinycolor.mostReadable("#a8015a", ["#faf3f3"],{includeFallbackColors:true,level:"AAA",size:"small"}).toHexString(); // "#ffffff"
942
- tinycolor.mostReadable = function (baseColor, colorList, args) {
943
- var bestColor = null;
944
- var bestScore = 0;
945
- var readability;
946
- var includeFallbackColors, level, size;
947
- args = args || {};
948
- includeFallbackColors = args.includeFallbackColors;
949
- level = args.level;
950
- size = args.size;
951
- for (var i = 0; i < colorList.length; i++) {
952
- readability = tinycolor.readability(baseColor, colorList[i]);
953
- if (readability > bestScore) {
954
- bestScore = readability;
955
- bestColor = tinycolor(colorList[i]);
956
- }
957
- }
958
- if (tinycolor.isReadable(baseColor, bestColor, {
959
- level: level,
960
- size: size
961
- }) || !includeFallbackColors) {
962
- return bestColor;
963
- } else {
964
- args.includeFallbackColors = false;
965
- return tinycolor.mostReadable(baseColor, ["#fff", "#000"], args);
966
- }
967
- };
968
-
969
- // Big List of Colors
970
- // ------------------
971
- // <https://www.w3.org/TR/css-color-4/#named-colors>
972
- var names = tinycolor.names = {
973
- aliceblue: "f0f8ff",
974
- antiquewhite: "faebd7",
975
- aqua: "0ff",
976
- aquamarine: "7fffd4",
977
- azure: "f0ffff",
978
- beige: "f5f5dc",
979
- bisque: "ffe4c4",
980
- black: "000",
981
- blanchedalmond: "ffebcd",
982
- blue: "00f",
983
- blueviolet: "8a2be2",
984
- brown: "a52a2a",
985
- burlywood: "deb887",
986
- burntsienna: "ea7e5d",
987
- cadetblue: "5f9ea0",
988
- chartreuse: "7fff00",
989
- chocolate: "d2691e",
990
- coral: "ff7f50",
991
- cornflowerblue: "6495ed",
992
- cornsilk: "fff8dc",
993
- crimson: "dc143c",
994
- cyan: "0ff",
995
- darkblue: "00008b",
996
- darkcyan: "008b8b",
997
- darkgoldenrod: "b8860b",
998
- darkgray: "a9a9a9",
999
- darkgreen: "006400",
1000
- darkgrey: "a9a9a9",
1001
- darkkhaki: "bdb76b",
1002
- darkmagenta: "8b008b",
1003
- darkolivegreen: "556b2f",
1004
- darkorange: "ff8c00",
1005
- darkorchid: "9932cc",
1006
- darkred: "8b0000",
1007
- darksalmon: "e9967a",
1008
- darkseagreen: "8fbc8f",
1009
- darkslateblue: "483d8b",
1010
- darkslategray: "2f4f4f",
1011
- darkslategrey: "2f4f4f",
1012
- darkturquoise: "00ced1",
1013
- darkviolet: "9400d3",
1014
- deeppink: "ff1493",
1015
- deepskyblue: "00bfff",
1016
- dimgray: "696969",
1017
- dimgrey: "696969",
1018
- dodgerblue: "1e90ff",
1019
- firebrick: "b22222",
1020
- floralwhite: "fffaf0",
1021
- forestgreen: "228b22",
1022
- fuchsia: "f0f",
1023
- gainsboro: "dcdcdc",
1024
- ghostwhite: "f8f8ff",
1025
- gold: "ffd700",
1026
- goldenrod: "daa520",
1027
- gray: "808080",
1028
- green: "008000",
1029
- greenyellow: "adff2f",
1030
- grey: "808080",
1031
- honeydew: "f0fff0",
1032
- hotpink: "ff69b4",
1033
- indianred: "cd5c5c",
1034
- indigo: "4b0082",
1035
- ivory: "fffff0",
1036
- khaki: "f0e68c",
1037
- lavender: "e6e6fa",
1038
- lavenderblush: "fff0f5",
1039
- lawngreen: "7cfc00",
1040
- lemonchiffon: "fffacd",
1041
- lightblue: "add8e6",
1042
- lightcoral: "f08080",
1043
- lightcyan: "e0ffff",
1044
- lightgoldenrodyellow: "fafad2",
1045
- lightgray: "d3d3d3",
1046
- lightgreen: "90ee90",
1047
- lightgrey: "d3d3d3",
1048
- lightpink: "ffb6c1",
1049
- lightsalmon: "ffa07a",
1050
- lightseagreen: "20b2aa",
1051
- lightskyblue: "87cefa",
1052
- lightslategray: "789",
1053
- lightslategrey: "789",
1054
- lightsteelblue: "b0c4de",
1055
- lightyellow: "ffffe0",
1056
- lime: "0f0",
1057
- limegreen: "32cd32",
1058
- linen: "faf0e6",
1059
- magenta: "f0f",
1060
- maroon: "800000",
1061
- mediumaquamarine: "66cdaa",
1062
- mediumblue: "0000cd",
1063
- mediumorchid: "ba55d3",
1064
- mediumpurple: "9370db",
1065
- mediumseagreen: "3cb371",
1066
- mediumslateblue: "7b68ee",
1067
- mediumspringgreen: "00fa9a",
1068
- mediumturquoise: "48d1cc",
1069
- mediumvioletred: "c71585",
1070
- midnightblue: "191970",
1071
- mintcream: "f5fffa",
1072
- mistyrose: "ffe4e1",
1073
- moccasin: "ffe4b5",
1074
- navajowhite: "ffdead",
1075
- navy: "000080",
1076
- oldlace: "fdf5e6",
1077
- olive: "808000",
1078
- olivedrab: "6b8e23",
1079
- orange: "ffa500",
1080
- orangered: "ff4500",
1081
- orchid: "da70d6",
1082
- palegoldenrod: "eee8aa",
1083
- palegreen: "98fb98",
1084
- paleturquoise: "afeeee",
1085
- palevioletred: "db7093",
1086
- papayawhip: "ffefd5",
1087
- peachpuff: "ffdab9",
1088
- peru: "cd853f",
1089
- pink: "ffc0cb",
1090
- plum: "dda0dd",
1091
- powderblue: "b0e0e6",
1092
- purple: "800080",
1093
- rebeccapurple: "663399",
1094
- red: "f00",
1095
- rosybrown: "bc8f8f",
1096
- royalblue: "4169e1",
1097
- saddlebrown: "8b4513",
1098
- salmon: "fa8072",
1099
- sandybrown: "f4a460",
1100
- seagreen: "2e8b57",
1101
- seashell: "fff5ee",
1102
- sienna: "a0522d",
1103
- silver: "c0c0c0",
1104
- skyblue: "87ceeb",
1105
- slateblue: "6a5acd",
1106
- slategray: "708090",
1107
- slategrey: "708090",
1108
- snow: "fffafa",
1109
- springgreen: "00ff7f",
1110
- steelblue: "4682b4",
1111
- tan: "d2b48c",
1112
- teal: "008080",
1113
- thistle: "d8bfd8",
1114
- tomato: "ff6347",
1115
- turquoise: "40e0d0",
1116
- violet: "ee82ee",
1117
- wheat: "f5deb3",
1118
- white: "fff",
1119
- whitesmoke: "f5f5f5",
1120
- yellow: "ff0",
1121
- yellowgreen: "9acd32"
1122
- };
1123
-
1124
- // Make it easy to access colors via `hexNames[hex]`
1125
- var hexNames = tinycolor.hexNames = flip(names);
1126
-
1127
- // Utilities
1128
- // ---------
1129
-
1130
- // `{ 'name1': 'val1' }` becomes `{ 'val1': 'name1' }`
1131
- function flip(o) {
1132
- var flipped = {};
1133
- for (var i in o) {
1134
- if (o.hasOwnProperty(i)) {
1135
- flipped[o[i]] = i;
1136
- }
1137
- }
1138
- return flipped;
1139
- }
1140
-
1141
- // Return a valid alpha value [0,1] with all invalid values being set to 1
1142
- function boundAlpha(a) {
1143
- a = parseFloat(a);
1144
- if (isNaN(a) || a < 0 || a > 1) {
1145
- a = 1;
1146
- }
1147
- return a;
1148
- }
1149
-
1150
- // Take input from [0, n] and return it as [0, 1]
1151
- function bound01(n, max) {
1152
- if (isOnePointZero(n)) n = "100%";
1153
- var processPercent = isPercentage(n);
1154
- n = Math.min(max, Math.max(0, parseFloat(n)));
1155
-
1156
- // Automatically convert percentage into number
1157
- if (processPercent) {
1158
- n = parseInt(n * max, 10) / 100;
1159
- }
1160
-
1161
- // Handle floating point rounding errors
1162
- if (Math.abs(n - max) < 0.000001) {
1163
- return 1;
1164
- }
1165
-
1166
- // Convert into [0, 1] range if it isn't already
1167
- return n % max / parseFloat(max);
1168
- }
1169
-
1170
- // Force a number between 0 and 1
1171
- function clamp01(val) {
1172
- return Math.min(1, Math.max(0, val));
1173
- }
1174
-
1175
- // Parse a base-16 hex value into a base-10 integer
1176
- function parseIntFromHex(val) {
1177
- return parseInt(val, 16);
1178
- }
1179
-
1180
- // Need to handle 1.0 as 100%, since once it is a number, there is no difference between it and 1
1181
- // <http://stackoverflow.com/questions/7422072/javascript-how-to-detect-number-as-a-decimal-including-1-0>
1182
- function isOnePointZero(n) {
1183
- return typeof n == "string" && n.indexOf(".") != -1 && parseFloat(n) === 1;
1184
- }
1185
-
1186
- // Check to see if string passed in is a percentage
1187
- function isPercentage(n) {
1188
- return typeof n === "string" && n.indexOf("%") != -1;
1189
- }
1190
-
1191
- // Force a hex value to have 2 characters
1192
- function pad2(c) {
1193
- return c.length == 1 ? "0" + c : "" + c;
1194
- }
1195
-
1196
- // Replace a decimal with it's percentage value
1197
- function convertToPercentage(n) {
1198
- if (n <= 1) {
1199
- n = n * 100 + "%";
1200
- }
1201
- return n;
1202
- }
1203
-
1204
- // Converts a decimal to a hex value
1205
- function convertDecimalToHex(d) {
1206
- return Math.round(parseFloat(d) * 255).toString(16);
1207
- }
1208
- // Converts a hex value to a decimal
1209
- function convertHexToDecimal(h) {
1210
- return parseIntFromHex(h) / 255;
1211
- }
1212
- var matchers = function () {
1213
- // <http://www.w3.org/TR/css3-values/#integers>
1214
- var CSS_INTEGER = "[-\\+]?\\d+%?";
1215
-
1216
- // <http://www.w3.org/TR/css3-values/#number-value>
1217
- var CSS_NUMBER = "[-\\+]?\\d*\\.\\d+%?";
1218
-
1219
- // Allow positive/negative integer/number. Don't capture the either/or, just the entire outcome.
1220
- var CSS_UNIT = "(?:" + CSS_NUMBER + ")|(?:" + CSS_INTEGER + ")";
1221
-
1222
- // Actual matching.
1223
- // Parentheses and commas are optional, but not required.
1224
- // Whitespace can take the place of commas or opening paren
1225
- var PERMISSIVE_MATCH3 = "[\\s|\\(]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")\\s*\\)?";
1226
- var PERMISSIVE_MATCH4 = "[\\s|\\(]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")\\s*\\)?";
1227
- return {
1228
- CSS_UNIT: new RegExp(CSS_UNIT),
1229
- rgb: new RegExp("rgb" + PERMISSIVE_MATCH3),
1230
- rgba: new RegExp("rgba" + PERMISSIVE_MATCH4),
1231
- hsl: new RegExp("hsl" + PERMISSIVE_MATCH3),
1232
- hsla: new RegExp("hsla" + PERMISSIVE_MATCH4),
1233
- hsv: new RegExp("hsv" + PERMISSIVE_MATCH3),
1234
- hsva: new RegExp("hsva" + PERMISSIVE_MATCH4),
1235
- hex3: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
1236
- hex6: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,
1237
- hex4: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
1238
- hex8: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/
1239
- };
1240
- }();
1241
-
1242
- // `isValidCSSUnit`
1243
- // Take in a single string / number and check to see if it looks like a CSS unit
1244
- // (see `matchers` above for definition).
1245
- function isValidCSSUnit(color) {
1246
- return !!matchers.CSS_UNIT.exec(color);
1247
- }
1248
-
1249
- // `stringInputToObject`
1250
- // Permissive string parsing. Take in a number of formats, and output an object
1251
- // based on detected format. Returns `{ r, g, b }` or `{ h, s, l }` or `{ h, s, v}`
1252
- function stringInputToObject(color) {
1253
- color = color.replace(trimLeft, "").replace(trimRight, "").toLowerCase();
1254
- var named = false;
1255
- if (names[color]) {
1256
- color = names[color];
1257
- named = true;
1258
- } else if (color == "transparent") {
1259
- return {
1260
- r: 0,
1261
- g: 0,
1262
- b: 0,
1263
- a: 0,
1264
- format: "name"
1265
- };
1266
- }
1267
-
1268
- // Try to match string input using regular expressions.
1269
- // Keep most of the number bounding out of this function - don't worry about [0,1] or [0,100] or [0,360]
1270
- // Just return an object and let the conversion functions handle that.
1271
- // This way the result will be the same whether the tinycolor is initialized with string or object.
1272
- var match;
1273
- if (match = matchers.rgb.exec(color)) {
1274
- return {
1275
- r: match[1],
1276
- g: match[2],
1277
- b: match[3]
1278
- };
1279
- }
1280
- if (match = matchers.rgba.exec(color)) {
1281
- return {
1282
- r: match[1],
1283
- g: match[2],
1284
- b: match[3],
1285
- a: match[4]
1286
- };
1287
- }
1288
- if (match = matchers.hsl.exec(color)) {
1289
- return {
1290
- h: match[1],
1291
- s: match[2],
1292
- l: match[3]
1293
- };
1294
- }
1295
- if (match = matchers.hsla.exec(color)) {
1296
- return {
1297
- h: match[1],
1298
- s: match[2],
1299
- l: match[3],
1300
- a: match[4]
1301
- };
1302
- }
1303
- if (match = matchers.hsv.exec(color)) {
1304
- return {
1305
- h: match[1],
1306
- s: match[2],
1307
- v: match[3]
1308
- };
1309
- }
1310
- if (match = matchers.hsva.exec(color)) {
1311
- return {
1312
- h: match[1],
1313
- s: match[2],
1314
- v: match[3],
1315
- a: match[4]
1316
- };
1317
- }
1318
- if (match = matchers.hex8.exec(color)) {
1319
- return {
1320
- r: parseIntFromHex(match[1]),
1321
- g: parseIntFromHex(match[2]),
1322
- b: parseIntFromHex(match[3]),
1323
- a: convertHexToDecimal(match[4]),
1324
- format: named ? "name" : "hex8"
1325
- };
1326
- }
1327
- if (match = matchers.hex6.exec(color)) {
1328
- return {
1329
- r: parseIntFromHex(match[1]),
1330
- g: parseIntFromHex(match[2]),
1331
- b: parseIntFromHex(match[3]),
1332
- format: named ? "name" : "hex"
1333
- };
1334
- }
1335
- if (match = matchers.hex4.exec(color)) {
1336
- return {
1337
- r: parseIntFromHex(match[1] + "" + match[1]),
1338
- g: parseIntFromHex(match[2] + "" + match[2]),
1339
- b: parseIntFromHex(match[3] + "" + match[3]),
1340
- a: convertHexToDecimal(match[4] + "" + match[4]),
1341
- format: named ? "name" : "hex8"
1342
- };
1343
- }
1344
- if (match = matchers.hex3.exec(color)) {
1345
- return {
1346
- r: parseIntFromHex(match[1] + "" + match[1]),
1347
- g: parseIntFromHex(match[2] + "" + match[2]),
1348
- b: parseIntFromHex(match[3] + "" + match[3]),
1349
- format: named ? "name" : "hex"
1350
- };
1351
- }
1352
- return false;
1353
- }
1354
- function validateWCAG2Parms(parms) {
1355
- // return valid WCAG2 parms for isReadable.
1356
- // If input parms are invalid, return {"level":"AA", "size":"small"}
1357
- var level, size;
1358
- parms = parms || {
1359
- level: "AA",
1360
- size: "small"
1361
- };
1362
- level = (parms.level || "AA").toUpperCase();
1363
- size = (parms.size || "small").toLowerCase();
1364
- if (level !== "AA" && level !== "AAA") {
1365
- level = "AA";
1366
- }
1367
- if (size !== "small" && size !== "large") {
1368
- size = "small";
1369
- }
1370
- return {
1371
- level: level,
1372
- size: size
1373
- };
1374
- }
1375
-
1376
198
  //预设颜色列表
1377
199
  var PresetColors = ["blue", "green", "yellow", "red"];
1378
200
  //tag
@@ -1459,12 +281,14 @@ var InternalTag = function InternalTag(props) {
1459
281
  }, style);
1460
282
  //tag closeIcon style
1461
283
  var closeIconStyle = {
1462
- backgroundColor: closeIconEnter ? tinycolor(color).setAlpha(0.1).toRgbString() : undefined
284
+ backgroundColor: closeIconEnter ? tinycolor(color).setAlpha(0.1).toRgbString() : undefined,
285
+ borderRadius: '2px'
1463
286
  };
1464
287
  //tag editIcon style
1465
288
  var editIconStyle = {
1466
289
  backgroundColor: editIconEnter ? tinycolor(color).setAlpha(0.1).toRgbString() : undefined,
1467
- marginRight: children ? "4px" : undefined
290
+ marginRight: children ? "4px" : undefined,
291
+ borderRadius: '2px'
1468
292
  };
1469
293
  //tag cls
1470
294
  var tagClassName = clsx("".concat($prefixCls, "-tag"), "".concat($prefixCls, "-tag-").concat(type), "".concat($prefixCls, "-tag-").concat(size), className, (_clsx = {}, _defineProperty(_clsx, "".concat($prefixCls, "-tag-has-color"), color), _defineProperty(_clsx, "".concat($prefixCls, "-tag-hidden"), !visible), _defineProperty(_clsx, "".concat($prefixCls, "-tag-").concat(color), isPresetColor()), _clsx));
@@ -1472,6 +296,7 @@ var InternalTag = function InternalTag(props) {
1472
296
  var handleCloseClick = function handleCloseClick(e) {
1473
297
  e.stopPropagation();
1474
298
  onClose === null || onClose === void 0 ? void 0 : onClose(e);
299
+ setCloseIconEnter(false);
1475
300
  if (e.defaultPrevented) {
1476
301
  return;
1477
302
  }
@@ -1497,6 +322,7 @@ var InternalTag = function InternalTag(props) {
1497
322
  if (e.defaultPrevented) {
1498
323
  return;
1499
324
  }
325
+ setEditIconEnter(false);
1500
326
  // 显示输入框
1501
327
  setInputVisible(true);
1502
328
  };