@seeqdev/qomponents 0.0.131 → 0.0.133

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 (241) hide show
  1. package/dist/Accordion/Accordion.js +9 -0
  2. package/dist/Accordion/Accordion.js.map +1 -0
  3. package/dist/Accordion/Accordion.stories.js +115 -0
  4. package/dist/Accordion/Accordion.stories.js.map +1 -0
  5. package/dist/Accordion/Accordion.test.js +55 -0
  6. package/dist/Accordion/Accordion.test.js.map +1 -0
  7. package/dist/Accordion/Accordion.types.js +2 -0
  8. package/dist/Accordion/Accordion.types.js.map +1 -0
  9. package/dist/Accordion/index.js +2 -0
  10. package/dist/Accordion/index.js.map +1 -0
  11. package/dist/Alert/Alert.js +34 -0
  12. package/dist/Alert/Alert.js.map +1 -0
  13. package/dist/Alert/Alert.stories.js +52 -0
  14. package/dist/Alert/Alert.stories.js.map +1 -0
  15. package/dist/Alert/Alert.test.js +51 -0
  16. package/dist/Alert/Alert.test.js.map +1 -0
  17. package/dist/Alert/Alert.types.js +2 -0
  18. package/dist/Alert/Alert.types.js.map +1 -0
  19. package/dist/Alert/index.js +2 -0
  20. package/dist/Alert/index.js.map +1 -0
  21. package/dist/Button/Button.js +92 -0
  22. package/dist/Button/Button.js.map +1 -0
  23. package/dist/Button/Button.stories.js +100 -0
  24. package/dist/Button/Button.stories.js.map +1 -0
  25. package/dist/Button/Button.test.js +49 -0
  26. package/dist/Button/Button.test.js.map +1 -0
  27. package/dist/Button/Button.types.js +5 -0
  28. package/dist/Button/Button.types.js.map +1 -0
  29. package/dist/Button/index.js +2 -0
  30. package/dist/Button/index.js.map +1 -0
  31. package/dist/ButtonGroup/ButtonGroup.js +33 -0
  32. package/dist/ButtonGroup/ButtonGroup.js.map +1 -0
  33. package/dist/ButtonGroup/ButtonGroup.stories.js +385 -0
  34. package/dist/ButtonGroup/ButtonGroup.stories.js.map +1 -0
  35. package/dist/ButtonGroup/ButtonGroup.test.js +67 -0
  36. package/dist/ButtonGroup/ButtonGroup.test.js.map +1 -0
  37. package/dist/ButtonGroup/ButtonGroup.types.js +2 -0
  38. package/dist/ButtonGroup/ButtonGroup.types.js.map +1 -0
  39. package/dist/ButtonGroup/index.js +2 -0
  40. package/dist/ButtonGroup/index.js.map +1 -0
  41. package/dist/ButtonWithDropdown/ButtonWithDropdown.js +60 -0
  42. package/dist/ButtonWithDropdown/ButtonWithDropdown.js.map +1 -0
  43. package/dist/ButtonWithDropdown/ButtonWithDropdown.stories.js +143 -0
  44. package/dist/ButtonWithDropdown/ButtonWithDropdown.stories.js.map +1 -0
  45. package/dist/ButtonWithDropdown/ButtonWithDropdown.test.js +93 -0
  46. package/dist/ButtonWithDropdown/ButtonWithDropdown.test.js.map +1 -0
  47. package/dist/ButtonWithDropdown/ButtonWithDropdown.types.js +2 -0
  48. package/dist/ButtonWithDropdown/ButtonWithDropdown.types.js.map +1 -0
  49. package/dist/ButtonWithDropdown/index.js +2 -0
  50. package/dist/ButtonWithDropdown/index.js.map +1 -0
  51. package/dist/ButtonWithPopover/ButtonWithPopover.js +62 -0
  52. package/dist/ButtonWithPopover/ButtonWithPopover.js.map +1 -0
  53. package/dist/ButtonWithPopover/ButtonWithPopover.stories.js +75 -0
  54. package/dist/ButtonWithPopover/ButtonWithPopover.stories.js.map +1 -0
  55. package/dist/ButtonWithPopover/ButtonWithPopover.test.js +82 -0
  56. package/dist/ButtonWithPopover/ButtonWithPopover.test.js.map +1 -0
  57. package/dist/ButtonWithPopover/ButtonWithPopover.types.js +2 -0
  58. package/dist/ButtonWithPopover/ButtonWithPopover.types.js.map +1 -0
  59. package/dist/ButtonWithPopover/index.js +2 -0
  60. package/dist/ButtonWithPopover/index.js.map +1 -0
  61. package/dist/Carousel/Carousel.js +67 -0
  62. package/dist/Carousel/Carousel.js.map +1 -0
  63. package/dist/Carousel/Carousel.stories.js +115 -0
  64. package/dist/Carousel/Carousel.stories.js.map +1 -0
  65. package/dist/Carousel/Carousel.test.js +48 -0
  66. package/dist/Carousel/Carousel.test.js.map +1 -0
  67. package/dist/Carousel/Carousel.types.js +2 -0
  68. package/dist/Carousel/Carousel.types.js.map +1 -0
  69. package/dist/Carousel/index.js +2 -0
  70. package/dist/Carousel/index.js.map +1 -0
  71. package/dist/Checkbox/Checkbox.js +26 -0
  72. package/dist/Checkbox/Checkbox.js.map +1 -0
  73. package/dist/Checkbox/Checkbox.stories.js +34 -0
  74. package/dist/Checkbox/Checkbox.stories.js.map +1 -0
  75. package/dist/Checkbox/Checkbox.test.js +94 -0
  76. package/dist/Checkbox/Checkbox.test.js.map +1 -0
  77. package/dist/Checkbox/Checkbox.types.js +2 -0
  78. package/dist/Checkbox/Checkbox.types.js.map +1 -0
  79. package/dist/Checkbox/index.js +2 -0
  80. package/dist/Checkbox/index.js.map +1 -0
  81. package/dist/Collapse/Collapse.js +18 -0
  82. package/dist/Collapse/Collapse.js.map +1 -0
  83. package/dist/Collapse/Collapse.stories.js +37 -0
  84. package/dist/Collapse/Collapse.stories.js.map +1 -0
  85. package/dist/Collapse/Collapse.test.js +19 -0
  86. package/dist/Collapse/Collapse.test.js.map +1 -0
  87. package/dist/Collapse/Collapse.types.js +2 -0
  88. package/dist/Collapse/Collapse.types.js.map +1 -0
  89. package/dist/Collapse/index.js +2 -0
  90. package/dist/Collapse/index.js.map +1 -0
  91. package/dist/FontCustom.woff +0 -0
  92. package/dist/FontCustom.woff2 +0 -0
  93. package/dist/Icon/Icon.js +55 -0
  94. package/dist/Icon/Icon.js.map +1 -0
  95. package/dist/Icon/Icon.stories.js +47 -0
  96. package/dist/Icon/Icon.stories.js.map +1 -0
  97. package/dist/Icon/Icon.test.js +55 -0
  98. package/dist/Icon/Icon.test.js.map +1 -0
  99. package/dist/Icon/Icon.types.js +16 -0
  100. package/dist/Icon/Icon.types.js.map +1 -0
  101. package/dist/Icon/index.js +2 -0
  102. package/dist/Icon/index.js.map +1 -0
  103. package/dist/InputGroup/InputGroup.js +32 -0
  104. package/dist/InputGroup/InputGroup.js.map +1 -0
  105. package/dist/InputGroup/InputGroup.stories.js +168 -0
  106. package/dist/InputGroup/InputGroup.stories.js.map +1 -0
  107. package/dist/InputGroup/InputGroup.test.js +43 -0
  108. package/dist/InputGroup/InputGroup.test.js.map +1 -0
  109. package/dist/InputGroup/InputGroup.types.js +2 -0
  110. package/dist/InputGroup/InputGroup.types.js.map +1 -0
  111. package/dist/InputGroup/index.js +2 -0
  112. package/dist/InputGroup/index.js.map +1 -0
  113. package/dist/Modal/Modal.js +100 -0
  114. package/dist/Modal/Modal.js.map +1 -0
  115. package/dist/Modal/Modal.stories.js +127 -0
  116. package/dist/Modal/Modal.stories.js.map +1 -0
  117. package/dist/Modal/Modal.test.js +108 -0
  118. package/dist/Modal/Modal.test.js.map +1 -0
  119. package/dist/Modal/Modal.types.js +2 -0
  120. package/dist/Modal/Modal.types.js.map +1 -0
  121. package/dist/Modal/index.js +2 -0
  122. package/dist/Modal/index.js.map +1 -0
  123. package/dist/ProgressBar/ProgressBar.js +50 -0
  124. package/dist/ProgressBar/ProgressBar.js.map +1 -0
  125. package/dist/ProgressBar/ProgressBar.stories.js +81 -0
  126. package/dist/ProgressBar/ProgressBar.stories.js.map +1 -0
  127. package/dist/ProgressBar/ProgressBar.test.js +44 -0
  128. package/dist/ProgressBar/ProgressBar.test.js.map +1 -0
  129. package/dist/ProgressBar/ProgressBar.types.d.ts +2 -0
  130. package/dist/ProgressBar/ProgressBar.types.js +2 -0
  131. package/dist/ProgressBar/ProgressBar.types.js.map +1 -0
  132. package/dist/ProgressBar/index.js +2 -0
  133. package/dist/ProgressBar/index.js.map +1 -0
  134. package/dist/SeeqActionDropdown/SeeqActionDropdown.js +48 -0
  135. package/dist/SeeqActionDropdown/SeeqActionDropdown.js.map +1 -0
  136. package/dist/SeeqActionDropdown/SeeqActionDropdown.stories.js +80 -0
  137. package/dist/SeeqActionDropdown/SeeqActionDropdown.stories.js.map +1 -0
  138. package/dist/SeeqActionDropdown/SeeqActionDropdown.test.js +73 -0
  139. package/dist/SeeqActionDropdown/SeeqActionDropdown.test.js.map +1 -0
  140. package/dist/SeeqActionDropdown/SeeqActionDropdown.types.js +2 -0
  141. package/dist/SeeqActionDropdown/SeeqActionDropdown.types.js.map +1 -0
  142. package/dist/SeeqActionDropdown/index.js +2 -0
  143. package/dist/SeeqActionDropdown/index.js.map +1 -0
  144. package/dist/SeeqActionDropdown/variants.js +23 -0
  145. package/dist/SeeqActionDropdown/variants.js.map +1 -0
  146. package/dist/Select/Select.js +174 -0
  147. package/dist/Select/Select.js.map +1 -0
  148. package/dist/Select/Select.stories.js +80 -0
  149. package/dist/Select/Select.stories.js.map +1 -0
  150. package/dist/Select/Select.test.js +182 -0
  151. package/dist/Select/Select.test.js.map +1 -0
  152. package/dist/Select/Select.types.js +2 -0
  153. package/dist/Select/Select.types.js.map +1 -0
  154. package/dist/Select/index.js +3 -0
  155. package/dist/Select/index.js.map +1 -0
  156. package/dist/Slider/Slider.js +13 -0
  157. package/dist/Slider/Slider.js.map +1 -0
  158. package/dist/Slider/Slider.stories.js +58 -0
  159. package/dist/Slider/Slider.stories.js.map +1 -0
  160. package/dist/Slider/Slider.test.js +33 -0
  161. package/dist/Slider/Slider.test.js.map +1 -0
  162. package/dist/Slider/Slider.types.js +2 -0
  163. package/dist/Slider/Slider.types.js.map +1 -0
  164. package/dist/Slider/index.js +2 -0
  165. package/dist/Slider/index.js.map +1 -0
  166. package/dist/Tabs/Tabs.js +22 -0
  167. package/dist/Tabs/Tabs.js.map +1 -0
  168. package/dist/Tabs/Tabs.stories.js +91 -0
  169. package/dist/Tabs/Tabs.stories.js.map +1 -0
  170. package/dist/Tabs/Tabs.test.js +91 -0
  171. package/dist/Tabs/Tabs.test.js.map +1 -0
  172. package/dist/Tabs/Tabs.types.js +2 -0
  173. package/dist/Tabs/Tabs.types.js.map +1 -0
  174. package/dist/Tabs/index.js +2 -0
  175. package/dist/Tabs/index.js.map +1 -0
  176. package/dist/TextArea/TextArea.js +25 -0
  177. package/dist/TextArea/TextArea.js.map +1 -0
  178. package/dist/TextArea/TextArea.stories.js +46 -0
  179. package/dist/TextArea/TextArea.stories.js.map +1 -0
  180. package/dist/TextArea/TextArea.test.js +68 -0
  181. package/dist/TextArea/TextArea.test.js.map +1 -0
  182. package/dist/TextArea/TextArea.types.js +2 -0
  183. package/dist/TextArea/TextArea.types.js.map +1 -0
  184. package/dist/TextArea/index.js +2 -0
  185. package/dist/TextArea/index.js.map +1 -0
  186. package/dist/TextField/TextField.js +79 -0
  187. package/dist/TextField/TextField.js.map +1 -0
  188. package/dist/TextField/TextField.stories.js +70 -0
  189. package/dist/TextField/TextField.stories.js.map +1 -0
  190. package/dist/TextField/TextField.test.js +39 -0
  191. package/dist/TextField/TextField.test.js.map +1 -0
  192. package/dist/TextField/TextField.types.js +2 -0
  193. package/dist/TextField/TextField.types.js.map +1 -0
  194. package/dist/TextField/index.js +2 -0
  195. package/dist/TextField/index.js.map +1 -0
  196. package/dist/ToolbarButton/ToolbarButton.js +75 -0
  197. package/dist/ToolbarButton/ToolbarButton.js.map +1 -0
  198. package/dist/ToolbarButton/ToolbarButton.stories.js +94 -0
  199. package/dist/ToolbarButton/ToolbarButton.stories.js.map +1 -0
  200. package/dist/ToolbarButton/ToolbarButton.test.js +93 -0
  201. package/dist/ToolbarButton/ToolbarButton.test.js.map +1 -0
  202. package/dist/ToolbarButton/ToolbarButton.types.js +2 -0
  203. package/dist/ToolbarButton/ToolbarButton.types.js.map +1 -0
  204. package/dist/ToolbarButton/index.js +2 -0
  205. package/dist/ToolbarButton/index.js.map +1 -0
  206. package/dist/Tooltip/QTip.stories.js +45 -0
  207. package/dist/Tooltip/QTip.stories.js.map +1 -0
  208. package/dist/Tooltip/QTip.types.js +2 -0
  209. package/dist/Tooltip/QTip.types.js.map +1 -0
  210. package/dist/Tooltip/QTipPerformance.stories.js +30 -0
  211. package/dist/Tooltip/QTipPerformance.stories.js.map +1 -0
  212. package/dist/Tooltip/Qtip.js +168 -0
  213. package/dist/Tooltip/Qtip.js.map +1 -0
  214. package/dist/Tooltip/Tooltip.js +36 -0
  215. package/dist/Tooltip/Tooltip.js.map +1 -0
  216. package/dist/Tooltip/Tooltip.stories.js +32 -0
  217. package/dist/Tooltip/Tooltip.stories.js.map +1 -0
  218. package/dist/Tooltip/Tooltip.types.js +3 -0
  219. package/dist/Tooltip/Tooltip.types.js.map +1 -0
  220. package/dist/Tooltip/TooltipPerformance.stories.js +30 -0
  221. package/dist/Tooltip/TooltipPerformance.stories.js.map +1 -0
  222. package/dist/Tooltip/index.js +3 -0
  223. package/dist/Tooltip/index.js.map +1 -0
  224. package/dist/Tooltip/qTip.utilities.js +11 -0
  225. package/dist/Tooltip/qTip.utilities.js.map +1 -0
  226. package/dist/index.esm.js +1217 -19
  227. package/dist/index.esm.js.map +1 -1
  228. package/dist/index.js +1217 -19
  229. package/dist/index.js.map +1 -1
  230. package/dist/styles.css +9 -0
  231. package/dist/types.js +2 -0
  232. package/dist/types.js.map +1 -0
  233. package/dist/utils/browserId.js +29 -0
  234. package/dist/utils/browserId.js.map +1 -0
  235. package/dist/utils/svg.js +20 -0
  236. package/dist/utils/svg.js.map +1 -0
  237. package/dist/utils/validateStyleDimension.js +14 -0
  238. package/dist/utils/validateStyleDimension.js.map +1 -0
  239. package/dist/utils/validateStyleDimension.test.js +20 -0
  240. package/dist/utils/validateStyleDimension.test.js.map +1 -0
  241. package/package.json +4 -2
package/dist/index.esm.js CHANGED
@@ -1478,7 +1478,7 @@ const arrow$1 = options => ({
1478
1478
  * clipping boundary. Alternative to `autoPlacement`.
1479
1479
  * @see https://floating-ui.com/docs/flip
1480
1480
  */
1481
- const flip = function (options) {
1481
+ const flip$1 = function (options) {
1482
1482
  if (options === void 0) {
1483
1483
  options = {};
1484
1484
  }
@@ -3103,7 +3103,7 @@ const $cf1ac5d9fe0e8206$export$bc4ae5855d3c4fc = /*#__PURE__*/ forwardRef((props
3103
3103
  limiter: sticky === 'partial' ? limitShift() : undefined,
3104
3104
  ...detectOverflowOptions
3105
3105
  }),
3106
- avoidCollisions && flip({
3106
+ avoidCollisions && flip$1({
3107
3107
  ...detectOverflowOptions
3108
3108
  }),
3109
3109
  size({
@@ -6305,22 +6305,22 @@ const QTip = () => {
6305
6305
  React__default.createElement("div", { className: "tw-absolute tw-w-[10px] tw-h-[10px] tw-rotate-45 tw-bg-black", ref: tooltipArrowRef }))));
6306
6306
  };
6307
6307
 
6308
- function _typeof(obj) {
6308
+ function _typeof$1(obj) {
6309
6309
  "@babel/helpers - typeof";
6310
6310
 
6311
- return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
6311
+ return _typeof$1 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
6312
6312
  return typeof obj;
6313
6313
  } : function (obj) {
6314
6314
  return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
6315
- }, _typeof(obj);
6315
+ }, _typeof$1(obj);
6316
6316
  }
6317
6317
 
6318
6318
  function _toPrimitive(input, hint) {
6319
- if (_typeof(input) !== "object" || input === null) return input;
6319
+ if (_typeof$1(input) !== "object" || input === null) return input;
6320
6320
  var prim = input[Symbol.toPrimitive];
6321
6321
  if (prim !== undefined) {
6322
6322
  var res = prim.call(input, hint || "default");
6323
- if (_typeof(res) !== "object") return res;
6323
+ if (_typeof$1(res) !== "object") return res;
6324
6324
  throw new TypeError("@@toPrimitive must return a primitive value.");
6325
6325
  }
6326
6326
  return (hint === "string" ? String : Number)(input);
@@ -6328,7 +6328,7 @@ function _toPrimitive(input, hint) {
6328
6328
 
6329
6329
  function _toPropertyKey(arg) {
6330
6330
  var key = _toPrimitive(arg, "string");
6331
- return _typeof(key) === "symbol" ? key : String(key);
6331
+ return _typeof$1(key) === "symbol" ? key : String(key);
6332
6332
  }
6333
6333
 
6334
6334
  function _defineProperty(obj, key, value) {
@@ -6595,7 +6595,7 @@ function _assertThisInitialized(self) {
6595
6595
  }
6596
6596
 
6597
6597
  function _possibleConstructorReturn(self, call) {
6598
- if (call && (_typeof(call) === "object" || typeof call === "function")) {
6598
+ if (call && (_typeof$1(call) === "object" || typeof call === "function")) {
6599
6599
  return call;
6600
6600
  } else if (call !== void 0) {
6601
6601
  throw new TypeError("Derived constructors may only return object or undefined");
@@ -9320,7 +9320,7 @@ function classNames$1(prefix, state) {
9320
9320
 
9321
9321
  var cleanValue = function cleanValue(value) {
9322
9322
  if (isArray(value)) return value.filter(Boolean);
9323
- if (_typeof(value) === 'object' && value !== null) return [value];
9323
+ if (_typeof$1(value) === 'object' && value !== null) return [value];
9324
9324
  return [];
9325
9325
  };
9326
9326
 
@@ -16506,7 +16506,7 @@ function normalizeColor(color) {
16506
16506
  ) >>> 0;
16507
16507
  }
16508
16508
  if (match = hsl.exec(color)) {
16509
- return (hslToRgb(
16509
+ return (hslToRgb$1(
16510
16510
  parse360(match[1]),
16511
16511
  // h
16512
16512
  parsePercentage(match[2]),
@@ -16517,7 +16517,7 @@ function normalizeColor(color) {
16517
16517
  0;
16518
16518
  }
16519
16519
  if (match = hsla.exec(color)) {
16520
- return (hslToRgb(
16520
+ return (hslToRgb$1(
16521
16521
  parse360(match[1]),
16522
16522
  // h
16523
16523
  parsePercentage(match[2]),
@@ -16542,7 +16542,7 @@ function hue2rgb(p, q, t) {
16542
16542
  return p + (q - p) * (2 / 3 - t) * 6;
16543
16543
  return p;
16544
16544
  }
16545
- function hslToRgb(h, s, l) {
16545
+ function hslToRgb$1(h, s, l) {
16546
16546
  const q = l < 0.5 ? l * (1 + s) : l + s - l * s;
16547
16547
  const p = 2 * l - q;
16548
16548
  const r = hue2rgb(p, q, h + 1 / 3);
@@ -20920,10 +20920,1192 @@ Defaulting to \`null\`.`;
20920
20920
  var Root = Progress;
20921
20921
  var Indicator = ProgressIndicator$1;
20922
20922
 
20923
+ // This file is autogenerated. It's used to publish ESM to npm.
20924
+ function _typeof(obj) {
20925
+ "@babel/helpers - typeof";
20926
+
20927
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
20928
+ return typeof obj;
20929
+ } : function (obj) {
20930
+ return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
20931
+ }, _typeof(obj);
20932
+ }
20933
+
20934
+ // https://github.com/bgrins/TinyColor
20935
+ // Brian Grinstead, MIT License
20936
+
20937
+ var trimLeft = /^\s+/;
20938
+ var trimRight = /\s+$/;
20939
+ function tinycolor(color, opts) {
20940
+ color = color ? color : "";
20941
+ opts = opts || {};
20942
+
20943
+ // If input is already a tinycolor, return itself
20944
+ if (color instanceof tinycolor) {
20945
+ return color;
20946
+ }
20947
+ // If we are called as a function, call using new instead
20948
+ if (!(this instanceof tinycolor)) {
20949
+ return new tinycolor(color, opts);
20950
+ }
20951
+ var rgb = inputToRGB(color);
20952
+ 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;
20953
+ this._gradientType = opts.gradientType;
20954
+
20955
+ // Don't let the range of [0,255] come back in [0,1].
20956
+ // Potentially lose a little bit of precision here, but will fix issues where
20957
+ // .5 gets interpreted as half of the total, instead of half of 1
20958
+ // If it was supposed to be 128, this was already taken care of by `inputToRgb`
20959
+ if (this._r < 1) this._r = Math.round(this._r);
20960
+ if (this._g < 1) this._g = Math.round(this._g);
20961
+ if (this._b < 1) this._b = Math.round(this._b);
20962
+ this._ok = rgb.ok;
20963
+ }
20964
+ tinycolor.prototype = {
20965
+ isDark: function isDark() {
20966
+ return this.getBrightness() < 128;
20967
+ },
20968
+ isLight: function isLight() {
20969
+ return !this.isDark();
20970
+ },
20971
+ isValid: function isValid() {
20972
+ return this._ok;
20973
+ },
20974
+ getOriginalInput: function getOriginalInput() {
20975
+ return this._originalInput;
20976
+ },
20977
+ getFormat: function getFormat() {
20978
+ return this._format;
20979
+ },
20980
+ getAlpha: function getAlpha() {
20981
+ return this._a;
20982
+ },
20983
+ getBrightness: function getBrightness() {
20984
+ //http://www.w3.org/TR/AERT#color-contrast
20985
+ var rgb = this.toRgb();
20986
+ return (rgb.r * 299 + rgb.g * 587 + rgb.b * 114) / 1000;
20987
+ },
20988
+ getLuminance: function getLuminance() {
20989
+ //http://www.w3.org/TR/2008/REC-WCAG20-20081211/#relativeluminancedef
20990
+ var rgb = this.toRgb();
20991
+ var RsRGB, GsRGB, BsRGB, R, G, B;
20992
+ RsRGB = rgb.r / 255;
20993
+ GsRGB = rgb.g / 255;
20994
+ BsRGB = rgb.b / 255;
20995
+ if (RsRGB <= 0.03928) R = RsRGB / 12.92;else R = Math.pow((RsRGB + 0.055) / 1.055, 2.4);
20996
+ if (GsRGB <= 0.03928) G = GsRGB / 12.92;else G = Math.pow((GsRGB + 0.055) / 1.055, 2.4);
20997
+ if (BsRGB <= 0.03928) B = BsRGB / 12.92;else B = Math.pow((BsRGB + 0.055) / 1.055, 2.4);
20998
+ return 0.2126 * R + 0.7152 * G + 0.0722 * B;
20999
+ },
21000
+ setAlpha: function setAlpha(value) {
21001
+ this._a = boundAlpha(value);
21002
+ this._roundA = Math.round(100 * this._a) / 100;
21003
+ return this;
21004
+ },
21005
+ toHsv: function toHsv() {
21006
+ var hsv = rgbToHsv(this._r, this._g, this._b);
21007
+ return {
21008
+ h: hsv.h * 360,
21009
+ s: hsv.s,
21010
+ v: hsv.v,
21011
+ a: this._a
21012
+ };
21013
+ },
21014
+ toHsvString: function toHsvString() {
21015
+ var hsv = rgbToHsv(this._r, this._g, this._b);
21016
+ var h = Math.round(hsv.h * 360),
21017
+ s = Math.round(hsv.s * 100),
21018
+ v = Math.round(hsv.v * 100);
21019
+ return this._a == 1 ? "hsv(" + h + ", " + s + "%, " + v + "%)" : "hsva(" + h + ", " + s + "%, " + v + "%, " + this._roundA + ")";
21020
+ },
21021
+ toHsl: function toHsl() {
21022
+ var hsl = rgbToHsl(this._r, this._g, this._b);
21023
+ return {
21024
+ h: hsl.h * 360,
21025
+ s: hsl.s,
21026
+ l: hsl.l,
21027
+ a: this._a
21028
+ };
21029
+ },
21030
+ toHslString: function toHslString() {
21031
+ var hsl = rgbToHsl(this._r, this._g, this._b);
21032
+ var h = Math.round(hsl.h * 360),
21033
+ s = Math.round(hsl.s * 100),
21034
+ l = Math.round(hsl.l * 100);
21035
+ return this._a == 1 ? "hsl(" + h + ", " + s + "%, " + l + "%)" : "hsla(" + h + ", " + s + "%, " + l + "%, " + this._roundA + ")";
21036
+ },
21037
+ toHex: function toHex(allow3Char) {
21038
+ return rgbToHex(this._r, this._g, this._b, allow3Char);
21039
+ },
21040
+ toHexString: function toHexString(allow3Char) {
21041
+ return "#" + this.toHex(allow3Char);
21042
+ },
21043
+ toHex8: function toHex8(allow4Char) {
21044
+ return rgbaToHex(this._r, this._g, this._b, this._a, allow4Char);
21045
+ },
21046
+ toHex8String: function toHex8String(allow4Char) {
21047
+ return "#" + this.toHex8(allow4Char);
21048
+ },
21049
+ toRgb: function toRgb() {
21050
+ return {
21051
+ r: Math.round(this._r),
21052
+ g: Math.round(this._g),
21053
+ b: Math.round(this._b),
21054
+ a: this._a
21055
+ };
21056
+ },
21057
+ toRgbString: function toRgbString() {
21058
+ 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 + ")";
21059
+ },
21060
+ toPercentageRgb: function toPercentageRgb() {
21061
+ return {
21062
+ r: Math.round(bound01(this._r, 255) * 100) + "%",
21063
+ g: Math.round(bound01(this._g, 255) * 100) + "%",
21064
+ b: Math.round(bound01(this._b, 255) * 100) + "%",
21065
+ a: this._a
21066
+ };
21067
+ },
21068
+ toPercentageRgbString: function toPercentageRgbString() {
21069
+ 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 + ")";
21070
+ },
21071
+ toName: function toName() {
21072
+ if (this._a === 0) {
21073
+ return "transparent";
21074
+ }
21075
+ if (this._a < 1) {
21076
+ return false;
21077
+ }
21078
+ return hexNames[rgbToHex(this._r, this._g, this._b, true)] || false;
21079
+ },
21080
+ toFilter: function toFilter(secondColor) {
21081
+ var hex8String = "#" + rgbaToArgbHex(this._r, this._g, this._b, this._a);
21082
+ var secondHex8String = hex8String;
21083
+ var gradientType = this._gradientType ? "GradientType = 1, " : "";
21084
+ if (secondColor) {
21085
+ var s = tinycolor(secondColor);
21086
+ secondHex8String = "#" + rgbaToArgbHex(s._r, s._g, s._b, s._a);
21087
+ }
21088
+ return "progid:DXImageTransform.Microsoft.gradient(" + gradientType + "startColorstr=" + hex8String + ",endColorstr=" + secondHex8String + ")";
21089
+ },
21090
+ toString: function toString(format) {
21091
+ var formatSet = !!format;
21092
+ format = format || this._format;
21093
+ var formattedString = false;
21094
+ var hasAlpha = this._a < 1 && this._a >= 0;
21095
+ var needsAlphaFormat = !formatSet && hasAlpha && (format === "hex" || format === "hex6" || format === "hex3" || format === "hex4" || format === "hex8" || format === "name");
21096
+ if (needsAlphaFormat) {
21097
+ // Special case for "transparent", all other non-alpha formats
21098
+ // will return rgba when there is transparency.
21099
+ if (format === "name" && this._a === 0) {
21100
+ return this.toName();
21101
+ }
21102
+ return this.toRgbString();
21103
+ }
21104
+ if (format === "rgb") {
21105
+ formattedString = this.toRgbString();
21106
+ }
21107
+ if (format === "prgb") {
21108
+ formattedString = this.toPercentageRgbString();
21109
+ }
21110
+ if (format === "hex" || format === "hex6") {
21111
+ formattedString = this.toHexString();
21112
+ }
21113
+ if (format === "hex3") {
21114
+ formattedString = this.toHexString(true);
21115
+ }
21116
+ if (format === "hex4") {
21117
+ formattedString = this.toHex8String(true);
21118
+ }
21119
+ if (format === "hex8") {
21120
+ formattedString = this.toHex8String();
21121
+ }
21122
+ if (format === "name") {
21123
+ formattedString = this.toName();
21124
+ }
21125
+ if (format === "hsl") {
21126
+ formattedString = this.toHslString();
21127
+ }
21128
+ if (format === "hsv") {
21129
+ formattedString = this.toHsvString();
21130
+ }
21131
+ return formattedString || this.toHexString();
21132
+ },
21133
+ clone: function clone() {
21134
+ return tinycolor(this.toString());
21135
+ },
21136
+ _applyModification: function _applyModification(fn, args) {
21137
+ var color = fn.apply(null, [this].concat([].slice.call(args)));
21138
+ this._r = color._r;
21139
+ this._g = color._g;
21140
+ this._b = color._b;
21141
+ this.setAlpha(color._a);
21142
+ return this;
21143
+ },
21144
+ lighten: function lighten() {
21145
+ return this._applyModification(_lighten, arguments);
21146
+ },
21147
+ brighten: function brighten() {
21148
+ return this._applyModification(_brighten, arguments);
21149
+ },
21150
+ darken: function darken() {
21151
+ return this._applyModification(_darken, arguments);
21152
+ },
21153
+ desaturate: function desaturate() {
21154
+ return this._applyModification(_desaturate, arguments);
21155
+ },
21156
+ saturate: function saturate() {
21157
+ return this._applyModification(_saturate, arguments);
21158
+ },
21159
+ greyscale: function greyscale() {
21160
+ return this._applyModification(_greyscale, arguments);
21161
+ },
21162
+ spin: function spin() {
21163
+ return this._applyModification(_spin, arguments);
21164
+ },
21165
+ _applyCombination: function _applyCombination(fn, args) {
21166
+ return fn.apply(null, [this].concat([].slice.call(args)));
21167
+ },
21168
+ analogous: function analogous() {
21169
+ return this._applyCombination(_analogous, arguments);
21170
+ },
21171
+ complement: function complement() {
21172
+ return this._applyCombination(_complement, arguments);
21173
+ },
21174
+ monochromatic: function monochromatic() {
21175
+ return this._applyCombination(_monochromatic, arguments);
21176
+ },
21177
+ splitcomplement: function splitcomplement() {
21178
+ return this._applyCombination(_splitcomplement, arguments);
21179
+ },
21180
+ // Disabled until https://github.com/bgrins/TinyColor/issues/254
21181
+ // polyad: function (number) {
21182
+ // return this._applyCombination(polyad, [number]);
21183
+ // },
21184
+ triad: function triad() {
21185
+ return this._applyCombination(polyad, [3]);
21186
+ },
21187
+ tetrad: function tetrad() {
21188
+ return this._applyCombination(polyad, [4]);
21189
+ }
21190
+ };
21191
+
21192
+ // If input is an object, force 1 into "1.0" to handle ratios properly
21193
+ // String input requires "1.0" as input, so 1 will be treated as 1
21194
+ tinycolor.fromRatio = function (color, opts) {
21195
+ if (_typeof(color) == "object") {
21196
+ var newColor = {};
21197
+ for (var i in color) {
21198
+ if (color.hasOwnProperty(i)) {
21199
+ if (i === "a") {
21200
+ newColor[i] = color[i];
21201
+ } else {
21202
+ newColor[i] = convertToPercentage(color[i]);
21203
+ }
21204
+ }
21205
+ }
21206
+ color = newColor;
21207
+ }
21208
+ return tinycolor(color, opts);
21209
+ };
21210
+
21211
+ // Given a string or object, convert that input to RGB
21212
+ // Possible string inputs:
21213
+ //
21214
+ // "red"
21215
+ // "#f00" or "f00"
21216
+ // "#ff0000" or "ff0000"
21217
+ // "#ff000000" or "ff000000"
21218
+ // "rgb 255 0 0" or "rgb (255, 0, 0)"
21219
+ // "rgb 1.0 0 0" or "rgb (1, 0, 0)"
21220
+ // "rgba (255, 0, 0, 1)" or "rgba 255, 0, 0, 1"
21221
+ // "rgba (1.0, 0, 0, 1)" or "rgba 1.0, 0, 0, 1"
21222
+ // "hsl(0, 100%, 50%)" or "hsl 0 100% 50%"
21223
+ // "hsla(0, 100%, 50%, 1)" or "hsla 0 100% 50%, 1"
21224
+ // "hsv(0, 100%, 100%)" or "hsv 0 100% 100%"
21225
+ //
21226
+ function inputToRGB(color) {
21227
+ var rgb = {
21228
+ r: 0,
21229
+ g: 0,
21230
+ b: 0
21231
+ };
21232
+ var a = 1;
21233
+ var s = null;
21234
+ var v = null;
21235
+ var l = null;
21236
+ var ok = false;
21237
+ var format = false;
21238
+ if (typeof color == "string") {
21239
+ color = stringInputToObject(color);
21240
+ }
21241
+ if (_typeof(color) == "object") {
21242
+ if (isValidCSSUnit(color.r) && isValidCSSUnit(color.g) && isValidCSSUnit(color.b)) {
21243
+ rgb = rgbToRgb(color.r, color.g, color.b);
21244
+ ok = true;
21245
+ format = String(color.r).substr(-1) === "%" ? "prgb" : "rgb";
21246
+ } else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.v)) {
21247
+ s = convertToPercentage(color.s);
21248
+ v = convertToPercentage(color.v);
21249
+ rgb = hsvToRgb(color.h, s, v);
21250
+ ok = true;
21251
+ format = "hsv";
21252
+ } else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.l)) {
21253
+ s = convertToPercentage(color.s);
21254
+ l = convertToPercentage(color.l);
21255
+ rgb = hslToRgb(color.h, s, l);
21256
+ ok = true;
21257
+ format = "hsl";
21258
+ }
21259
+ if (color.hasOwnProperty("a")) {
21260
+ a = color.a;
21261
+ }
21262
+ }
21263
+ a = boundAlpha(a);
21264
+ return {
21265
+ ok: ok,
21266
+ format: color.format || format,
21267
+ r: Math.min(255, Math.max(rgb.r, 0)),
21268
+ g: Math.min(255, Math.max(rgb.g, 0)),
21269
+ b: Math.min(255, Math.max(rgb.b, 0)),
21270
+ a: a
21271
+ };
21272
+ }
21273
+
21274
+ // Conversion Functions
21275
+ // --------------------
21276
+
21277
+ // `rgbToHsl`, `rgbToHsv`, `hslToRgb`, `hsvToRgb` modified from:
21278
+ // <http://mjijackson.com/2008/02/rgb-to-hsl-and-rgb-to-hsv-color-model-conversion-algorithms-in-javascript>
21279
+
21280
+ // `rgbToRgb`
21281
+ // Handle bounds / percentage checking to conform to CSS color spec
21282
+ // <http://www.w3.org/TR/css3-color/>
21283
+ // *Assumes:* r, g, b in [0, 255] or [0, 1]
21284
+ // *Returns:* { r, g, b } in [0, 255]
21285
+ function rgbToRgb(r, g, b) {
21286
+ return {
21287
+ r: bound01(r, 255) * 255,
21288
+ g: bound01(g, 255) * 255,
21289
+ b: bound01(b, 255) * 255
21290
+ };
21291
+ }
21292
+
21293
+ // `rgbToHsl`
21294
+ // Converts an RGB color value to HSL.
21295
+ // *Assumes:* r, g, and b are contained in [0, 255] or [0, 1]
21296
+ // *Returns:* { h, s, l } in [0,1]
21297
+ function rgbToHsl(r, g, b) {
21298
+ r = bound01(r, 255);
21299
+ g = bound01(g, 255);
21300
+ b = bound01(b, 255);
21301
+ var max = Math.max(r, g, b),
21302
+ min = Math.min(r, g, b);
21303
+ var h,
21304
+ s,
21305
+ l = (max + min) / 2;
21306
+ if (max == min) {
21307
+ h = s = 0; // achromatic
21308
+ } else {
21309
+ var d = max - min;
21310
+ s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
21311
+ switch (max) {
21312
+ case r:
21313
+ h = (g - b) / d + (g < b ? 6 : 0);
21314
+ break;
21315
+ case g:
21316
+ h = (b - r) / d + 2;
21317
+ break;
21318
+ case b:
21319
+ h = (r - g) / d + 4;
21320
+ break;
21321
+ }
21322
+ h /= 6;
21323
+ }
21324
+ return {
21325
+ h: h,
21326
+ s: s,
21327
+ l: l
21328
+ };
21329
+ }
21330
+
21331
+ // `hslToRgb`
21332
+ // Converts an HSL color value to RGB.
21333
+ // *Assumes:* h is contained in [0, 1] or [0, 360] and s and l are contained [0, 1] or [0, 100]
21334
+ // *Returns:* { r, g, b } in the set [0, 255]
21335
+ function hslToRgb(h, s, l) {
21336
+ var r, g, b;
21337
+ h = bound01(h, 360);
21338
+ s = bound01(s, 100);
21339
+ l = bound01(l, 100);
21340
+ function hue2rgb(p, q, t) {
21341
+ if (t < 0) t += 1;
21342
+ if (t > 1) t -= 1;
21343
+ if (t < 1 / 6) return p + (q - p) * 6 * t;
21344
+ if (t < 1 / 2) return q;
21345
+ if (t < 2 / 3) return p + (q - p) * (2 / 3 - t) * 6;
21346
+ return p;
21347
+ }
21348
+ if (s === 0) {
21349
+ r = g = b = l; // achromatic
21350
+ } else {
21351
+ var q = l < 0.5 ? l * (1 + s) : l + s - l * s;
21352
+ var p = 2 * l - q;
21353
+ r = hue2rgb(p, q, h + 1 / 3);
21354
+ g = hue2rgb(p, q, h);
21355
+ b = hue2rgb(p, q, h - 1 / 3);
21356
+ }
21357
+ return {
21358
+ r: r * 255,
21359
+ g: g * 255,
21360
+ b: b * 255
21361
+ };
21362
+ }
21363
+
21364
+ // `rgbToHsv`
21365
+ // Converts an RGB color value to HSV
21366
+ // *Assumes:* r, g, and b are contained in the set [0, 255] or [0, 1]
21367
+ // *Returns:* { h, s, v } in [0,1]
21368
+ function rgbToHsv(r, g, b) {
21369
+ r = bound01(r, 255);
21370
+ g = bound01(g, 255);
21371
+ b = bound01(b, 255);
21372
+ var max = Math.max(r, g, b),
21373
+ min = Math.min(r, g, b);
21374
+ var h,
21375
+ s,
21376
+ v = max;
21377
+ var d = max - min;
21378
+ s = max === 0 ? 0 : d / max;
21379
+ if (max == min) {
21380
+ h = 0; // achromatic
21381
+ } else {
21382
+ switch (max) {
21383
+ case r:
21384
+ h = (g - b) / d + (g < b ? 6 : 0);
21385
+ break;
21386
+ case g:
21387
+ h = (b - r) / d + 2;
21388
+ break;
21389
+ case b:
21390
+ h = (r - g) / d + 4;
21391
+ break;
21392
+ }
21393
+ h /= 6;
21394
+ }
21395
+ return {
21396
+ h: h,
21397
+ s: s,
21398
+ v: v
21399
+ };
21400
+ }
21401
+
21402
+ // `hsvToRgb`
21403
+ // Converts an HSV color value to RGB.
21404
+ // *Assumes:* h is contained in [0, 1] or [0, 360] and s and v are contained in [0, 1] or [0, 100]
21405
+ // *Returns:* { r, g, b } in the set [0, 255]
21406
+ function hsvToRgb(h, s, v) {
21407
+ h = bound01(h, 360) * 6;
21408
+ s = bound01(s, 100);
21409
+ v = bound01(v, 100);
21410
+ var i = Math.floor(h),
21411
+ f = h - i,
21412
+ p = v * (1 - s),
21413
+ q = v * (1 - f * s),
21414
+ t = v * (1 - (1 - f) * s),
21415
+ mod = i % 6,
21416
+ r = [v, q, p, p, t, v][mod],
21417
+ g = [t, v, v, q, p, p][mod],
21418
+ b = [p, p, t, v, v, q][mod];
21419
+ return {
21420
+ r: r * 255,
21421
+ g: g * 255,
21422
+ b: b * 255
21423
+ };
21424
+ }
21425
+
21426
+ // `rgbToHex`
21427
+ // Converts an RGB color to hex
21428
+ // Assumes r, g, and b are contained in the set [0, 255]
21429
+ // Returns a 3 or 6 character hex
21430
+ function rgbToHex(r, g, b, allow3Char) {
21431
+ var hex = [pad2(Math.round(r).toString(16)), pad2(Math.round(g).toString(16)), pad2(Math.round(b).toString(16))];
21432
+
21433
+ // Return a 3 character hex if possible
21434
+ 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)) {
21435
+ return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0);
21436
+ }
21437
+ return hex.join("");
21438
+ }
21439
+
21440
+ // `rgbaToHex`
21441
+ // Converts an RGBA color plus alpha transparency to hex
21442
+ // Assumes r, g, b are contained in the set [0, 255] and
21443
+ // a in [0, 1]. Returns a 4 or 8 character rgba hex
21444
+ function rgbaToHex(r, g, b, a, allow4Char) {
21445
+ var hex = [pad2(Math.round(r).toString(16)), pad2(Math.round(g).toString(16)), pad2(Math.round(b).toString(16)), pad2(convertDecimalToHex(a))];
21446
+
21447
+ // Return a 4 character hex if possible
21448
+ 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)) {
21449
+ return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0) + hex[3].charAt(0);
21450
+ }
21451
+ return hex.join("");
21452
+ }
21453
+
21454
+ // `rgbaToArgbHex`
21455
+ // Converts an RGBA color to an ARGB Hex8 string
21456
+ // Rarely used, but required for "toFilter()"
21457
+ function rgbaToArgbHex(r, g, b, a) {
21458
+ var hex = [pad2(convertDecimalToHex(a)), pad2(Math.round(r).toString(16)), pad2(Math.round(g).toString(16)), pad2(Math.round(b).toString(16))];
21459
+ return hex.join("");
21460
+ }
21461
+
21462
+ // `equals`
21463
+ // Can be called with any tinycolor input
21464
+ tinycolor.equals = function (color1, color2) {
21465
+ if (!color1 || !color2) return false;
21466
+ return tinycolor(color1).toRgbString() == tinycolor(color2).toRgbString();
21467
+ };
21468
+ tinycolor.random = function () {
21469
+ return tinycolor.fromRatio({
21470
+ r: Math.random(),
21471
+ g: Math.random(),
21472
+ b: Math.random()
21473
+ });
21474
+ };
21475
+
21476
+ // Modification Functions
21477
+ // ----------------------
21478
+ // Thanks to less.js for some of the basics here
21479
+ // <https://github.com/cloudhead/less.js/blob/master/lib/less/functions.js>
21480
+
21481
+ function _desaturate(color, amount) {
21482
+ amount = amount === 0 ? 0 : amount || 10;
21483
+ var hsl = tinycolor(color).toHsl();
21484
+ hsl.s -= amount / 100;
21485
+ hsl.s = clamp01(hsl.s);
21486
+ return tinycolor(hsl);
21487
+ }
21488
+ function _saturate(color, amount) {
21489
+ amount = amount === 0 ? 0 : amount || 10;
21490
+ var hsl = tinycolor(color).toHsl();
21491
+ hsl.s += amount / 100;
21492
+ hsl.s = clamp01(hsl.s);
21493
+ return tinycolor(hsl);
21494
+ }
21495
+ function _greyscale(color) {
21496
+ return tinycolor(color).desaturate(100);
21497
+ }
21498
+ function _lighten(color, amount) {
21499
+ amount = amount === 0 ? 0 : amount || 10;
21500
+ var hsl = tinycolor(color).toHsl();
21501
+ hsl.l += amount / 100;
21502
+ hsl.l = clamp01(hsl.l);
21503
+ return tinycolor(hsl);
21504
+ }
21505
+ function _brighten(color, amount) {
21506
+ amount = amount === 0 ? 0 : amount || 10;
21507
+ var rgb = tinycolor(color).toRgb();
21508
+ rgb.r = Math.max(0, Math.min(255, rgb.r - Math.round(255 * -(amount / 100))));
21509
+ rgb.g = Math.max(0, Math.min(255, rgb.g - Math.round(255 * -(amount / 100))));
21510
+ rgb.b = Math.max(0, Math.min(255, rgb.b - Math.round(255 * -(amount / 100))));
21511
+ return tinycolor(rgb);
21512
+ }
21513
+ function _darken(color, amount) {
21514
+ amount = amount === 0 ? 0 : amount || 10;
21515
+ var hsl = tinycolor(color).toHsl();
21516
+ hsl.l -= amount / 100;
21517
+ hsl.l = clamp01(hsl.l);
21518
+ return tinycolor(hsl);
21519
+ }
21520
+
21521
+ // Spin takes a positive or negative amount within [-360, 360] indicating the change of hue.
21522
+ // Values outside of this range will be wrapped into this range.
21523
+ function _spin(color, amount) {
21524
+ var hsl = tinycolor(color).toHsl();
21525
+ var hue = (hsl.h + amount) % 360;
21526
+ hsl.h = hue < 0 ? 360 + hue : hue;
21527
+ return tinycolor(hsl);
21528
+ }
21529
+
21530
+ // Combination Functions
21531
+ // ---------------------
21532
+ // Thanks to jQuery xColor for some of the ideas behind these
21533
+ // <https://github.com/infusion/jQuery-xcolor/blob/master/jquery.xcolor.js>
21534
+
21535
+ function _complement(color) {
21536
+ var hsl = tinycolor(color).toHsl();
21537
+ hsl.h = (hsl.h + 180) % 360;
21538
+ return tinycolor(hsl);
21539
+ }
21540
+ function polyad(color, number) {
21541
+ if (isNaN(number) || number <= 0) {
21542
+ throw new Error("Argument to polyad must be a positive number");
21543
+ }
21544
+ var hsl = tinycolor(color).toHsl();
21545
+ var result = [tinycolor(color)];
21546
+ var step = 360 / number;
21547
+ for (var i = 1; i < number; i++) {
21548
+ result.push(tinycolor({
21549
+ h: (hsl.h + i * step) % 360,
21550
+ s: hsl.s,
21551
+ l: hsl.l
21552
+ }));
21553
+ }
21554
+ return result;
21555
+ }
21556
+ function _splitcomplement(color) {
21557
+ var hsl = tinycolor(color).toHsl();
21558
+ var h = hsl.h;
21559
+ return [tinycolor(color), tinycolor({
21560
+ h: (h + 72) % 360,
21561
+ s: hsl.s,
21562
+ l: hsl.l
21563
+ }), tinycolor({
21564
+ h: (h + 216) % 360,
21565
+ s: hsl.s,
21566
+ l: hsl.l
21567
+ })];
21568
+ }
21569
+ function _analogous(color, results, slices) {
21570
+ results = results || 6;
21571
+ slices = slices || 30;
21572
+ var hsl = tinycolor(color).toHsl();
21573
+ var part = 360 / slices;
21574
+ var ret = [tinycolor(color)];
21575
+ for (hsl.h = (hsl.h - (part * results >> 1) + 720) % 360; --results;) {
21576
+ hsl.h = (hsl.h + part) % 360;
21577
+ ret.push(tinycolor(hsl));
21578
+ }
21579
+ return ret;
21580
+ }
21581
+ function _monochromatic(color, results) {
21582
+ results = results || 6;
21583
+ var hsv = tinycolor(color).toHsv();
21584
+ var h = hsv.h,
21585
+ s = hsv.s,
21586
+ v = hsv.v;
21587
+ var ret = [];
21588
+ var modification = 1 / results;
21589
+ while (results--) {
21590
+ ret.push(tinycolor({
21591
+ h: h,
21592
+ s: s,
21593
+ v: v
21594
+ }));
21595
+ v = (v + modification) % 1;
21596
+ }
21597
+ return ret;
21598
+ }
21599
+
21600
+ // Utility Functions
21601
+ // ---------------------
21602
+
21603
+ tinycolor.mix = function (color1, color2, amount) {
21604
+ amount = amount === 0 ? 0 : amount || 50;
21605
+ var rgb1 = tinycolor(color1).toRgb();
21606
+ var rgb2 = tinycolor(color2).toRgb();
21607
+ var p = amount / 100;
21608
+ var rgba = {
21609
+ r: (rgb2.r - rgb1.r) * p + rgb1.r,
21610
+ g: (rgb2.g - rgb1.g) * p + rgb1.g,
21611
+ b: (rgb2.b - rgb1.b) * p + rgb1.b,
21612
+ a: (rgb2.a - rgb1.a) * p + rgb1.a
21613
+ };
21614
+ return tinycolor(rgba);
21615
+ };
21616
+
21617
+ // Readability Functions
21618
+ // ---------------------
21619
+ // <http://www.w3.org/TR/2008/REC-WCAG20-20081211/#contrast-ratiodef (WCAG Version 2)
21620
+
21621
+ // `contrast`
21622
+ // Analyze the 2 colors and returns the color contrast defined by (WCAG Version 2)
21623
+ tinycolor.readability = function (color1, color2) {
21624
+ var c1 = tinycolor(color1);
21625
+ var c2 = tinycolor(color2);
21626
+ return (Math.max(c1.getLuminance(), c2.getLuminance()) + 0.05) / (Math.min(c1.getLuminance(), c2.getLuminance()) + 0.05);
21627
+ };
21628
+
21629
+ // `isReadable`
21630
+ // Ensure that foreground and background color combinations meet WCAG2 guidelines.
21631
+ // The third argument is an optional Object.
21632
+ // the 'level' property states 'AA' or 'AAA' - if missing or invalid, it defaults to 'AA';
21633
+ // the 'size' property states 'large' or 'small' - if missing or invalid, it defaults to 'small'.
21634
+ // If the entire object is absent, isReadable defaults to {level:"AA",size:"small"}.
21635
+
21636
+ // *Example*
21637
+ // tinycolor.isReadable("#000", "#111") => false
21638
+ // tinycolor.isReadable("#000", "#111",{level:"AA",size:"large"}) => false
21639
+ tinycolor.isReadable = function (color1, color2, wcag2) {
21640
+ var readability = tinycolor.readability(color1, color2);
21641
+ var wcag2Parms, out;
21642
+ out = false;
21643
+ wcag2Parms = validateWCAG2Parms(wcag2);
21644
+ switch (wcag2Parms.level + wcag2Parms.size) {
21645
+ case "AAsmall":
21646
+ case "AAAlarge":
21647
+ out = readability >= 4.5;
21648
+ break;
21649
+ case "AAlarge":
21650
+ out = readability >= 3;
21651
+ break;
21652
+ case "AAAsmall":
21653
+ out = readability >= 7;
21654
+ break;
21655
+ }
21656
+ return out;
21657
+ };
21658
+
21659
+ // `mostReadable`
21660
+ // Given a base color and a list of possible foreground or background
21661
+ // colors for that base, returns the most readable color.
21662
+ // Optionally returns Black or White if the most readable color is unreadable.
21663
+ // *Example*
21664
+ // tinycolor.mostReadable(tinycolor.mostReadable("#123", ["#124", "#125"],{includeFallbackColors:false}).toHexString(); // "#112255"
21665
+ // tinycolor.mostReadable(tinycolor.mostReadable("#123", ["#124", "#125"],{includeFallbackColors:true}).toHexString(); // "#ffffff"
21666
+ // tinycolor.mostReadable("#a8015a", ["#faf3f3"],{includeFallbackColors:true,level:"AAA",size:"large"}).toHexString(); // "#faf3f3"
21667
+ // tinycolor.mostReadable("#a8015a", ["#faf3f3"],{includeFallbackColors:true,level:"AAA",size:"small"}).toHexString(); // "#ffffff"
21668
+ tinycolor.mostReadable = function (baseColor, colorList, args) {
21669
+ var bestColor = null;
21670
+ var bestScore = 0;
21671
+ var readability;
21672
+ var includeFallbackColors, level, size;
21673
+ args = args || {};
21674
+ includeFallbackColors = args.includeFallbackColors;
21675
+ level = args.level;
21676
+ size = args.size;
21677
+ for (var i = 0; i < colorList.length; i++) {
21678
+ readability = tinycolor.readability(baseColor, colorList[i]);
21679
+ if (readability > bestScore) {
21680
+ bestScore = readability;
21681
+ bestColor = tinycolor(colorList[i]);
21682
+ }
21683
+ }
21684
+ if (tinycolor.isReadable(baseColor, bestColor, {
21685
+ level: level,
21686
+ size: size
21687
+ }) || !includeFallbackColors) {
21688
+ return bestColor;
21689
+ } else {
21690
+ args.includeFallbackColors = false;
21691
+ return tinycolor.mostReadable(baseColor, ["#fff", "#000"], args);
21692
+ }
21693
+ };
21694
+
21695
+ // Big List of Colors
21696
+ // ------------------
21697
+ // <https://www.w3.org/TR/css-color-4/#named-colors>
21698
+ var names = tinycolor.names = {
21699
+ aliceblue: "f0f8ff",
21700
+ antiquewhite: "faebd7",
21701
+ aqua: "0ff",
21702
+ aquamarine: "7fffd4",
21703
+ azure: "f0ffff",
21704
+ beige: "f5f5dc",
21705
+ bisque: "ffe4c4",
21706
+ black: "000",
21707
+ blanchedalmond: "ffebcd",
21708
+ blue: "00f",
21709
+ blueviolet: "8a2be2",
21710
+ brown: "a52a2a",
21711
+ burlywood: "deb887",
21712
+ burntsienna: "ea7e5d",
21713
+ cadetblue: "5f9ea0",
21714
+ chartreuse: "7fff00",
21715
+ chocolate: "d2691e",
21716
+ coral: "ff7f50",
21717
+ cornflowerblue: "6495ed",
21718
+ cornsilk: "fff8dc",
21719
+ crimson: "dc143c",
21720
+ cyan: "0ff",
21721
+ darkblue: "00008b",
21722
+ darkcyan: "008b8b",
21723
+ darkgoldenrod: "b8860b",
21724
+ darkgray: "a9a9a9",
21725
+ darkgreen: "006400",
21726
+ darkgrey: "a9a9a9",
21727
+ darkkhaki: "bdb76b",
21728
+ darkmagenta: "8b008b",
21729
+ darkolivegreen: "556b2f",
21730
+ darkorange: "ff8c00",
21731
+ darkorchid: "9932cc",
21732
+ darkred: "8b0000",
21733
+ darksalmon: "e9967a",
21734
+ darkseagreen: "8fbc8f",
21735
+ darkslateblue: "483d8b",
21736
+ darkslategray: "2f4f4f",
21737
+ darkslategrey: "2f4f4f",
21738
+ darkturquoise: "00ced1",
21739
+ darkviolet: "9400d3",
21740
+ deeppink: "ff1493",
21741
+ deepskyblue: "00bfff",
21742
+ dimgray: "696969",
21743
+ dimgrey: "696969",
21744
+ dodgerblue: "1e90ff",
21745
+ firebrick: "b22222",
21746
+ floralwhite: "fffaf0",
21747
+ forestgreen: "228b22",
21748
+ fuchsia: "f0f",
21749
+ gainsboro: "dcdcdc",
21750
+ ghostwhite: "f8f8ff",
21751
+ gold: "ffd700",
21752
+ goldenrod: "daa520",
21753
+ gray: "808080",
21754
+ green: "008000",
21755
+ greenyellow: "adff2f",
21756
+ grey: "808080",
21757
+ honeydew: "f0fff0",
21758
+ hotpink: "ff69b4",
21759
+ indianred: "cd5c5c",
21760
+ indigo: "4b0082",
21761
+ ivory: "fffff0",
21762
+ khaki: "f0e68c",
21763
+ lavender: "e6e6fa",
21764
+ lavenderblush: "fff0f5",
21765
+ lawngreen: "7cfc00",
21766
+ lemonchiffon: "fffacd",
21767
+ lightblue: "add8e6",
21768
+ lightcoral: "f08080",
21769
+ lightcyan: "e0ffff",
21770
+ lightgoldenrodyellow: "fafad2",
21771
+ lightgray: "d3d3d3",
21772
+ lightgreen: "90ee90",
21773
+ lightgrey: "d3d3d3",
21774
+ lightpink: "ffb6c1",
21775
+ lightsalmon: "ffa07a",
21776
+ lightseagreen: "20b2aa",
21777
+ lightskyblue: "87cefa",
21778
+ lightslategray: "789",
21779
+ lightslategrey: "789",
21780
+ lightsteelblue: "b0c4de",
21781
+ lightyellow: "ffffe0",
21782
+ lime: "0f0",
21783
+ limegreen: "32cd32",
21784
+ linen: "faf0e6",
21785
+ magenta: "f0f",
21786
+ maroon: "800000",
21787
+ mediumaquamarine: "66cdaa",
21788
+ mediumblue: "0000cd",
21789
+ mediumorchid: "ba55d3",
21790
+ mediumpurple: "9370db",
21791
+ mediumseagreen: "3cb371",
21792
+ mediumslateblue: "7b68ee",
21793
+ mediumspringgreen: "00fa9a",
21794
+ mediumturquoise: "48d1cc",
21795
+ mediumvioletred: "c71585",
21796
+ midnightblue: "191970",
21797
+ mintcream: "f5fffa",
21798
+ mistyrose: "ffe4e1",
21799
+ moccasin: "ffe4b5",
21800
+ navajowhite: "ffdead",
21801
+ navy: "000080",
21802
+ oldlace: "fdf5e6",
21803
+ olive: "808000",
21804
+ olivedrab: "6b8e23",
21805
+ orange: "ffa500",
21806
+ orangered: "ff4500",
21807
+ orchid: "da70d6",
21808
+ palegoldenrod: "eee8aa",
21809
+ palegreen: "98fb98",
21810
+ paleturquoise: "afeeee",
21811
+ palevioletred: "db7093",
21812
+ papayawhip: "ffefd5",
21813
+ peachpuff: "ffdab9",
21814
+ peru: "cd853f",
21815
+ pink: "ffc0cb",
21816
+ plum: "dda0dd",
21817
+ powderblue: "b0e0e6",
21818
+ purple: "800080",
21819
+ rebeccapurple: "663399",
21820
+ red: "f00",
21821
+ rosybrown: "bc8f8f",
21822
+ royalblue: "4169e1",
21823
+ saddlebrown: "8b4513",
21824
+ salmon: "fa8072",
21825
+ sandybrown: "f4a460",
21826
+ seagreen: "2e8b57",
21827
+ seashell: "fff5ee",
21828
+ sienna: "a0522d",
21829
+ silver: "c0c0c0",
21830
+ skyblue: "87ceeb",
21831
+ slateblue: "6a5acd",
21832
+ slategray: "708090",
21833
+ slategrey: "708090",
21834
+ snow: "fffafa",
21835
+ springgreen: "00ff7f",
21836
+ steelblue: "4682b4",
21837
+ tan: "d2b48c",
21838
+ teal: "008080",
21839
+ thistle: "d8bfd8",
21840
+ tomato: "ff6347",
21841
+ turquoise: "40e0d0",
21842
+ violet: "ee82ee",
21843
+ wheat: "f5deb3",
21844
+ white: "fff",
21845
+ whitesmoke: "f5f5f5",
21846
+ yellow: "ff0",
21847
+ yellowgreen: "9acd32"
21848
+ };
21849
+
21850
+ // Make it easy to access colors via `hexNames[hex]`
21851
+ var hexNames = tinycolor.hexNames = flip(names);
21852
+
21853
+ // Utilities
21854
+ // ---------
21855
+
21856
+ // `{ 'name1': 'val1' }` becomes `{ 'val1': 'name1' }`
21857
+ function flip(o) {
21858
+ var flipped = {};
21859
+ for (var i in o) {
21860
+ if (o.hasOwnProperty(i)) {
21861
+ flipped[o[i]] = i;
21862
+ }
21863
+ }
21864
+ return flipped;
21865
+ }
21866
+
21867
+ // Return a valid alpha value [0,1] with all invalid values being set to 1
21868
+ function boundAlpha(a) {
21869
+ a = parseFloat(a);
21870
+ if (isNaN(a) || a < 0 || a > 1) {
21871
+ a = 1;
21872
+ }
21873
+ return a;
21874
+ }
21875
+
21876
+ // Take input from [0, n] and return it as [0, 1]
21877
+ function bound01(n, max) {
21878
+ if (isOnePointZero(n)) n = "100%";
21879
+ var processPercent = isPercentage(n);
21880
+ n = Math.min(max, Math.max(0, parseFloat(n)));
21881
+
21882
+ // Automatically convert percentage into number
21883
+ if (processPercent) {
21884
+ n = parseInt(n * max, 10) / 100;
21885
+ }
21886
+
21887
+ // Handle floating point rounding errors
21888
+ if (Math.abs(n - max) < 0.000001) {
21889
+ return 1;
21890
+ }
21891
+
21892
+ // Convert into [0, 1] range if it isn't already
21893
+ return n % max / parseFloat(max);
21894
+ }
21895
+
21896
+ // Force a number between 0 and 1
21897
+ function clamp01(val) {
21898
+ return Math.min(1, Math.max(0, val));
21899
+ }
21900
+
21901
+ // Parse a base-16 hex value into a base-10 integer
21902
+ function parseIntFromHex(val) {
21903
+ return parseInt(val, 16);
21904
+ }
21905
+
21906
+ // Need to handle 1.0 as 100%, since once it is a number, there is no difference between it and 1
21907
+ // <http://stackoverflow.com/questions/7422072/javascript-how-to-detect-number-as-a-decimal-including-1-0>
21908
+ function isOnePointZero(n) {
21909
+ return typeof n == "string" && n.indexOf(".") != -1 && parseFloat(n) === 1;
21910
+ }
21911
+
21912
+ // Check to see if string passed in is a percentage
21913
+ function isPercentage(n) {
21914
+ return typeof n === "string" && n.indexOf("%") != -1;
21915
+ }
21916
+
21917
+ // Force a hex value to have 2 characters
21918
+ function pad2(c) {
21919
+ return c.length == 1 ? "0" + c : "" + c;
21920
+ }
21921
+
21922
+ // Replace a decimal with it's percentage value
21923
+ function convertToPercentage(n) {
21924
+ if (n <= 1) {
21925
+ n = n * 100 + "%";
21926
+ }
21927
+ return n;
21928
+ }
21929
+
21930
+ // Converts a decimal to a hex value
21931
+ function convertDecimalToHex(d) {
21932
+ return Math.round(parseFloat(d) * 255).toString(16);
21933
+ }
21934
+ // Converts a hex value to a decimal
21935
+ function convertHexToDecimal(h) {
21936
+ return parseIntFromHex(h) / 255;
21937
+ }
21938
+ var matchers = function () {
21939
+ // <http://www.w3.org/TR/css3-values/#integers>
21940
+ var CSS_INTEGER = "[-\\+]?\\d+%?";
21941
+
21942
+ // <http://www.w3.org/TR/css3-values/#number-value>
21943
+ var CSS_NUMBER = "[-\\+]?\\d*\\.\\d+%?";
21944
+
21945
+ // Allow positive/negative integer/number. Don't capture the either/or, just the entire outcome.
21946
+ var CSS_UNIT = "(?:" + CSS_NUMBER + ")|(?:" + CSS_INTEGER + ")";
21947
+
21948
+ // Actual matching.
21949
+ // Parentheses and commas are optional, but not required.
21950
+ // Whitespace can take the place of commas or opening paren
21951
+ var PERMISSIVE_MATCH3 = "[\\s|\\(]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")\\s*\\)?";
21952
+ var PERMISSIVE_MATCH4 = "[\\s|\\(]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")\\s*\\)?";
21953
+ return {
21954
+ CSS_UNIT: new RegExp(CSS_UNIT),
21955
+ rgb: new RegExp("rgb" + PERMISSIVE_MATCH3),
21956
+ rgba: new RegExp("rgba" + PERMISSIVE_MATCH4),
21957
+ hsl: new RegExp("hsl" + PERMISSIVE_MATCH3),
21958
+ hsla: new RegExp("hsla" + PERMISSIVE_MATCH4),
21959
+ hsv: new RegExp("hsv" + PERMISSIVE_MATCH3),
21960
+ hsva: new RegExp("hsva" + PERMISSIVE_MATCH4),
21961
+ hex3: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
21962
+ hex6: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,
21963
+ hex4: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
21964
+ hex8: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/
21965
+ };
21966
+ }();
21967
+
21968
+ // `isValidCSSUnit`
21969
+ // Take in a single string / number and check to see if it looks like a CSS unit
21970
+ // (see `matchers` above for definition).
21971
+ function isValidCSSUnit(color) {
21972
+ return !!matchers.CSS_UNIT.exec(color);
21973
+ }
21974
+
21975
+ // `stringInputToObject`
21976
+ // Permissive string parsing. Take in a number of formats, and output an object
21977
+ // based on detected format. Returns `{ r, g, b }` or `{ h, s, l }` or `{ h, s, v}`
21978
+ function stringInputToObject(color) {
21979
+ color = color.replace(trimLeft, "").replace(trimRight, "").toLowerCase();
21980
+ var named = false;
21981
+ if (names[color]) {
21982
+ color = names[color];
21983
+ named = true;
21984
+ } else if (color == "transparent") {
21985
+ return {
21986
+ r: 0,
21987
+ g: 0,
21988
+ b: 0,
21989
+ a: 0,
21990
+ format: "name"
21991
+ };
21992
+ }
21993
+
21994
+ // Try to match string input using regular expressions.
21995
+ // Keep most of the number bounding out of this function - don't worry about [0,1] or [0,100] or [0,360]
21996
+ // Just return an object and let the conversion functions handle that.
21997
+ // This way the result will be the same whether the tinycolor is initialized with string or object.
21998
+ var match;
21999
+ if (match = matchers.rgb.exec(color)) {
22000
+ return {
22001
+ r: match[1],
22002
+ g: match[2],
22003
+ b: match[3]
22004
+ };
22005
+ }
22006
+ if (match = matchers.rgba.exec(color)) {
22007
+ return {
22008
+ r: match[1],
22009
+ g: match[2],
22010
+ b: match[3],
22011
+ a: match[4]
22012
+ };
22013
+ }
22014
+ if (match = matchers.hsl.exec(color)) {
22015
+ return {
22016
+ h: match[1],
22017
+ s: match[2],
22018
+ l: match[3]
22019
+ };
22020
+ }
22021
+ if (match = matchers.hsla.exec(color)) {
22022
+ return {
22023
+ h: match[1],
22024
+ s: match[2],
22025
+ l: match[3],
22026
+ a: match[4]
22027
+ };
22028
+ }
22029
+ if (match = matchers.hsv.exec(color)) {
22030
+ return {
22031
+ h: match[1],
22032
+ s: match[2],
22033
+ v: match[3]
22034
+ };
22035
+ }
22036
+ if (match = matchers.hsva.exec(color)) {
22037
+ return {
22038
+ h: match[1],
22039
+ s: match[2],
22040
+ v: match[3],
22041
+ a: match[4]
22042
+ };
22043
+ }
22044
+ if (match = matchers.hex8.exec(color)) {
22045
+ return {
22046
+ r: parseIntFromHex(match[1]),
22047
+ g: parseIntFromHex(match[2]),
22048
+ b: parseIntFromHex(match[3]),
22049
+ a: convertHexToDecimal(match[4]),
22050
+ format: named ? "name" : "hex8"
22051
+ };
22052
+ }
22053
+ if (match = matchers.hex6.exec(color)) {
22054
+ return {
22055
+ r: parseIntFromHex(match[1]),
22056
+ g: parseIntFromHex(match[2]),
22057
+ b: parseIntFromHex(match[3]),
22058
+ format: named ? "name" : "hex"
22059
+ };
22060
+ }
22061
+ if (match = matchers.hex4.exec(color)) {
22062
+ return {
22063
+ r: parseIntFromHex(match[1] + "" + match[1]),
22064
+ g: parseIntFromHex(match[2] + "" + match[2]),
22065
+ b: parseIntFromHex(match[3] + "" + match[3]),
22066
+ a: convertHexToDecimal(match[4] + "" + match[4]),
22067
+ format: named ? "name" : "hex8"
22068
+ };
22069
+ }
22070
+ if (match = matchers.hex3.exec(color)) {
22071
+ return {
22072
+ r: parseIntFromHex(match[1] + "" + match[1]),
22073
+ g: parseIntFromHex(match[2] + "" + match[2]),
22074
+ b: parseIntFromHex(match[3] + "" + match[3]),
22075
+ format: named ? "name" : "hex"
22076
+ };
22077
+ }
22078
+ return false;
22079
+ }
22080
+ function validateWCAG2Parms(parms) {
22081
+ // return valid WCAG2 parms for isReadable.
22082
+ // If input parms are invalid, return {"level":"AA", "size":"small"}
22083
+ var level, size;
22084
+ parms = parms || {
22085
+ level: "AA",
22086
+ size: "small"
22087
+ };
22088
+ level = (parms.level || "AA").toUpperCase();
22089
+ size = (parms.size || "small").toLowerCase();
22090
+ if (level !== "AA" && level !== "AAA") {
22091
+ level = "AA";
22092
+ }
22093
+ if (size !== "small" && size !== "large") {
22094
+ size = "small";
22095
+ }
22096
+ return {
22097
+ level: level,
22098
+ size: size
22099
+ };
22100
+ }
22101
+
22102
+ const baseLabelClasses = 'tw-left-1 tw-text-xs tw-text-sq-text-color dark:tw-text-sq-dark-text tw-items-center tw-h-[18px]';
20923
22103
  const ProgressIndicator = (props) => {
20924
22104
  const { value, color = undefined, testId, label, extraClasses = '', labelClasses = '', valuesLength, max, index, ...tooltipProps } = props;
20925
22105
  const tooltipData = getQTipData(tooltipProps);
20926
22106
  const previousWidth = useRef(0);
22107
+ const indicatorElementRef = useRef(null);
22108
+ const [textColorClass, setTextColorClass] = React__default.useState('');
20927
22109
  const [animatedWidth, setAnimatedWidth] = React__default.useState(previousWidth.current);
20928
22110
  useEffect(() => {
20929
22111
  const timeout = setTimeout(() => {
@@ -20933,17 +22115,33 @@ const ProgressIndicator = (props) => {
20933
22115
  }, 100);
20934
22116
  return () => clearTimeout(timeout);
20935
22117
  }, [value]);
20936
- return (React__default.createElement(Indicator, { className: `tw-ease-[cubic-bezier(0.65, 0, 0.35, 1)] tw-w-full tw-h-full tw-duration-[660ms] tw-flex tw-bg-sq-color-dark tw-justify-center tw-items-center ${extraClasses}`, ...tooltipData, "data-qtip-text": tooltipProps.tooltip ? tooltipProps.tooltip : `${value}%`, "data-testid": `progress-bar-indicator-${testId ? testId : value}`, key: `${index}-${value}`, style: {
22118
+ const bgColor = color || undefined;
22119
+ const bgClass = color ? '' : 'tw-bg-sq-color-dark';
22120
+ const computeTextClass = (elem) => {
22121
+ const computedStyle = getComputedStyle(elem);
22122
+ const backgroundColor = computedStyle.backgroundColor;
22123
+ const textColorClass = tinycolor(backgroundColor).isDark()
22124
+ ? 'tw-text-sq-white dark:tw-text-sq-white'
22125
+ : 'tw-text-sq-text-color dark:tw-text-sq-text-color';
22126
+ setTextColorClass(textColorClass);
22127
+ };
22128
+ useEffect(() => {
22129
+ if (indicatorElementRef.current) {
22130
+ computeTextClass(indicatorElementRef.current);
22131
+ }
22132
+ }, [!!indicatorElementRef.current]);
22133
+ return (React__default.createElement(Indicator, { className: `tw-ease-[cubic-bezier(0.65, 0, 0.35, 1)] tw-w-full tw-h-[18px] tw-duration-[660ms] tw-flex tw-justify-center tw-items-center tw-overflow-hidden ${bgClass} ${extraClasses}`, ...tooltipData, "data-qtip-text": tooltipProps.tooltip ? tooltipProps.tooltip : `${value}%`, "data-testid": `progress-bar-indicator-${testId ? testId : value}`, key: `${index}-${value}`, ref: indicatorElementRef, style: {
20937
22134
  // Background color will default to the theme color if undefined
20938
- backgroundColor: color ? color : undefined,
22135
+ backgroundColor: bgColor,
20939
22136
  animation: 'width 660ms forwards',
20940
22137
  width: `${animatedWidth}%`,
20941
- } }, label ? (React__default.createElement("span", { className: `tw-left-1 tw-text-xs tw-text-sq-text-color dark:tw-text-sq-dark-text tw-items-center ${labelClasses}` }, label)) : undefined));
22138
+ } }, label ? React__default.createElement("span", { className: `${baseLabelClasses} ${labelClasses} ${textColorClass}` }, label) : undefined));
20942
22139
  };
20943
- const ProgressBar = ({ values = [], max = 100, containerExtraClasses = '', }) => {
20944
- return (React__default.createElement(Root, { className: `tw-relative tw-h-[18px] tw-w-full tw-overflow-hidden tw-rounded-[2.5px] tw-bg-sq-dark-gray dark:tw-bg-sq-dark-disabled-gray tw-flex tw-flex-1 ${containerExtraClasses}`, max: max, value: values.reduce((acc, { value }) => acc + value, 0) }, values.map((props, i) => {
22140
+ const ProgressBar = ({ values = [], max = 100, containerExtraClasses = '', zeroValueLabel = 'No progress yet', }) => {
22141
+ const totalValue = values.reduce((acc, { value }) => acc + value, 0);
22142
+ return (React__default.createElement(Root, { className: `tw-relative tw-h-[18px] tw-w-full tw-overflow-hidden tw-rounded-[2.5px] tw-bg-sq-dark-gray dark:tw-bg-sq-dark-disabled-gray tw-flex tw-flex-1 ${containerExtraClasses}`, max: max, value: totalValue }, totalValue > 0 ? (values.map((props, i) => {
20945
22143
  return React__default.createElement(ProgressIndicator, { ...props, max: max, valuesLength: values.length, index: i, key: i });
20946
- })));
22144
+ })) : (React__default.createElement("div", { className: `${baseLabelClasses} tw-mx-auto tw-overflow-hidden` }, zeroValueLabel))));
20947
22145
  };
20948
22146
 
20949
22147
  const baseClasses = 'tw-flex tw-outline-none tw-rounded-sm tw-w-full tw-relative tw-flex-wrap';