@bigbinary/neetoui 8.3.29 → 8.3.31

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 (305) hide show
  1. package/dist/Accordion.js +94 -76
  2. package/dist/Accordion.js.map +1 -1
  3. package/dist/ActionDropdown.js +29 -32
  4. package/dist/ActionDropdown.js.map +1 -1
  5. package/dist/Alert.js +44 -38
  6. package/dist/Alert.js.map +1 -1
  7. package/dist/Avatar.js +28 -22
  8. package/dist/Avatar.js.map +1 -1
  9. package/dist/Button.js +45 -43
  10. package/dist/Button.js.map +1 -1
  11. package/dist/Callout.js +12 -7
  12. package/dist/Callout.js.map +1 -1
  13. package/dist/Checkbox.js +35 -28
  14. package/dist/Checkbox.js.map +1 -1
  15. package/dist/ColorPicker.js +134 -117
  16. package/dist/ColorPicker.js.map +1 -1
  17. package/dist/DatePicker.js +25 -9
  18. package/dist/DatePicker.js.map +1 -1
  19. package/dist/Dropdown.js +75 -83
  20. package/dist/Dropdown.js.map +1 -1
  21. package/dist/Input.js +82 -70
  22. package/dist/Input.js.map +1 -1
  23. package/dist/Kbd.js +13 -7
  24. package/dist/Kbd.js.map +1 -1
  25. package/dist/Label.js +59 -40
  26. package/dist/Label.js.map +1 -1
  27. package/dist/Modal.js +76 -65
  28. package/dist/Modal.js.map +1 -1
  29. package/dist/MultiEmailInput.js +118 -99
  30. package/dist/MultiEmailInput.js.map +1 -1
  31. package/dist/NoData.js +55 -39
  32. package/dist/NoData.js.map +1 -1
  33. package/dist/Pagination.js +64 -52
  34. package/dist/Pagination.js.map +1 -1
  35. package/dist/Pane.js +66 -56
  36. package/dist/Pane.js.map +1 -1
  37. package/dist/Popover.js +10 -7
  38. package/dist/Popover.js.map +1 -1
  39. package/dist/ProgressBar.js +20 -17
  40. package/dist/ProgressBar.js.map +1 -1
  41. package/dist/Radio.js +50 -40
  42. package/dist/Radio.js.map +1 -1
  43. package/dist/Select.js +111 -90
  44. package/dist/Select.js.map +1 -1
  45. package/dist/Sidebar.js +265 -216
  46. package/dist/Sidebar.js.map +1 -1
  47. package/dist/Slider.js +45 -38
  48. package/dist/Slider.js.map +1 -1
  49. package/dist/Spinner.js +3 -2
  50. package/dist/Spinner.js.map +1 -1
  51. package/dist/Stepper.js +33 -26
  52. package/dist/Stepper.js.map +1 -1
  53. package/dist/Switch.js +56 -46
  54. package/dist/Switch.js.map +1 -1
  55. package/dist/Tab.js +17 -11
  56. package/dist/Tab.js.map +1 -1
  57. package/dist/Table.js +221 -182
  58. package/dist/Table.js.map +1 -1
  59. package/dist/Tag.js +31 -24
  60. package/dist/Tag.js.map +1 -1
  61. package/dist/{Textarea-DlEGZFfG.js → Textarea-D1gsiIxm.js} +66 -56
  62. package/dist/{Textarea-DlEGZFfG.js.map → Textarea-D1gsiIxm.js.map} +1 -1
  63. package/dist/Textarea.js +4 -4
  64. package/dist/TimePicker.js +25 -9
  65. package/dist/TimePicker.js.map +1 -1
  66. package/dist/Toastr.js +46 -37
  67. package/dist/Toastr.js.map +1 -1
  68. package/dist/Tooltip.js +10 -6
  69. package/dist/Tooltip.js.map +1 -1
  70. package/dist/TranslationProvider.js +6 -4
  71. package/dist/TranslationProvider.js.map +1 -1
  72. package/dist/Tree.js +17 -15
  73. package/dist/Tree.js.map +1 -1
  74. package/dist/TreeSelect.js +65 -58
  75. package/dist/TreeSelect.js.map +1 -1
  76. package/dist/Typography.js +7 -3
  77. package/dist/Typography.js.map +1 -1
  78. package/dist/cjs/Accordion.js +94 -76
  79. package/dist/cjs/Accordion.js.map +1 -1
  80. package/dist/cjs/ActionDropdown.js +29 -32
  81. package/dist/cjs/ActionDropdown.js.map +1 -1
  82. package/dist/cjs/Alert.js +43 -37
  83. package/dist/cjs/Alert.js.map +1 -1
  84. package/dist/cjs/Avatar.js +27 -21
  85. package/dist/cjs/Avatar.js.map +1 -1
  86. package/dist/cjs/Button.js +45 -43
  87. package/dist/cjs/Button.js.map +1 -1
  88. package/dist/cjs/Callout.js +11 -6
  89. package/dist/cjs/Callout.js.map +1 -1
  90. package/dist/cjs/Checkbox.js +34 -27
  91. package/dist/cjs/Checkbox.js.map +1 -1
  92. package/dist/cjs/ColorPicker.js +132 -115
  93. package/dist/cjs/ColorPicker.js.map +1 -1
  94. package/dist/cjs/DatePicker.js +25 -9
  95. package/dist/cjs/DatePicker.js.map +1 -1
  96. package/dist/cjs/Dropdown.js +74 -82
  97. package/dist/cjs/Dropdown.js.map +1 -1
  98. package/dist/cjs/Input.js +81 -69
  99. package/dist/cjs/Input.js.map +1 -1
  100. package/dist/cjs/Kbd.js +13 -7
  101. package/dist/cjs/Kbd.js.map +1 -1
  102. package/dist/cjs/Label.js +59 -40
  103. package/dist/cjs/Label.js.map +1 -1
  104. package/dist/cjs/Modal.js +76 -65
  105. package/dist/cjs/Modal.js.map +1 -1
  106. package/dist/cjs/MultiEmailInput.js +117 -98
  107. package/dist/cjs/MultiEmailInput.js.map +1 -1
  108. package/dist/cjs/NoData.js +55 -39
  109. package/dist/cjs/NoData.js.map +1 -1
  110. package/dist/cjs/Pagination.js +63 -51
  111. package/dist/cjs/Pagination.js.map +1 -1
  112. package/dist/cjs/Pane.js +65 -55
  113. package/dist/cjs/Pane.js.map +1 -1
  114. package/dist/cjs/Popover.js +10 -7
  115. package/dist/cjs/Popover.js.map +1 -1
  116. package/dist/cjs/ProgressBar.js +20 -17
  117. package/dist/cjs/ProgressBar.js.map +1 -1
  118. package/dist/cjs/Radio.js +49 -39
  119. package/dist/cjs/Radio.js.map +1 -1
  120. package/dist/cjs/Select.js +110 -89
  121. package/dist/cjs/Select.js.map +1 -1
  122. package/dist/cjs/Sidebar.js +268 -219
  123. package/dist/cjs/Sidebar.js.map +1 -1
  124. package/dist/cjs/Slider.js +45 -38
  125. package/dist/cjs/Slider.js.map +1 -1
  126. package/dist/cjs/Spinner.js +3 -2
  127. package/dist/cjs/Spinner.js.map +1 -1
  128. package/dist/cjs/Stepper.js +33 -26
  129. package/dist/cjs/Stepper.js.map +1 -1
  130. package/dist/cjs/Switch.js +55 -45
  131. package/dist/cjs/Switch.js.map +1 -1
  132. package/dist/cjs/Tab.js +17 -11
  133. package/dist/cjs/Tab.js.map +1 -1
  134. package/dist/cjs/Table.js +224 -185
  135. package/dist/cjs/Table.js.map +1 -1
  136. package/dist/cjs/Tag.js +30 -23
  137. package/dist/cjs/Tag.js.map +1 -1
  138. package/dist/cjs/{Textarea-CiUKmQHr.js → Textarea-BzBZbgdT.js} +65 -55
  139. package/dist/cjs/{Textarea-CiUKmQHr.js.map → Textarea-BzBZbgdT.js.map} +1 -1
  140. package/dist/cjs/Textarea.js +4 -4
  141. package/dist/cjs/TimePicker.js +25 -9
  142. package/dist/cjs/TimePicker.js.map +1 -1
  143. package/dist/cjs/Toastr.js +45 -36
  144. package/dist/cjs/Toastr.js.map +1 -1
  145. package/dist/cjs/Tooltip.js +10 -6
  146. package/dist/cjs/Tooltip.js.map +1 -1
  147. package/dist/cjs/TranslationProvider.js +5 -3
  148. package/dist/cjs/TranslationProvider.js.map +1 -1
  149. package/dist/cjs/Tree.js +17 -15
  150. package/dist/cjs/Tree.js.map +1 -1
  151. package/dist/cjs/TreeSelect.js +66 -59
  152. package/dist/cjs/TreeSelect.js.map +1 -1
  153. package/dist/cjs/Typography.js +7 -3
  154. package/dist/cjs/Typography.js.map +1 -1
  155. package/dist/cjs/constants.js.map +1 -1
  156. package/dist/cjs/formik/ActionBlock.js +16 -9
  157. package/dist/cjs/formik/ActionBlock.js.map +1 -1
  158. package/dist/cjs/formik/BlockNavigation.js +40 -30
  159. package/dist/cjs/formik/BlockNavigation.js.map +1 -1
  160. package/dist/cjs/formik/Button.js +5 -3
  161. package/dist/cjs/formik/Button.js.map +1 -1
  162. package/dist/cjs/formik/Checkbox.js +29 -28
  163. package/dist/cjs/formik/Checkbox.js.map +1 -1
  164. package/dist/cjs/formik/Form.js +53 -47
  165. package/dist/cjs/formik/Form.js.map +1 -1
  166. package/dist/cjs/formik/Input.js +27 -26
  167. package/dist/cjs/formik/Input.js.map +1 -1
  168. package/dist/cjs/formik/MultiEmailInput.js +10 -6
  169. package/dist/cjs/formik/MultiEmailInput.js.map +1 -1
  170. package/dist/cjs/formik/Radio.js +7 -7
  171. package/dist/cjs/formik/Radio.js.map +1 -1
  172. package/dist/cjs/formik/Select.js +15 -10
  173. package/dist/cjs/formik/Select.js.map +1 -1
  174. package/dist/cjs/formik/Slider.js +7 -7
  175. package/dist/cjs/formik/Slider.js.map +1 -1
  176. package/dist/cjs/formik/Switch.js +31 -28
  177. package/dist/cjs/formik/Switch.js.map +1 -1
  178. package/dist/cjs/formik/Textarea.js +28 -27
  179. package/dist/cjs/formik/Textarea.js.map +1 -1
  180. package/dist/cjs/formik/TreeSelect.js +8 -5
  181. package/dist/cjs/formik/TreeSelect.js.map +1 -1
  182. package/dist/cjs/formik/index.js +11 -7
  183. package/dist/cjs/formik/index.js.map +1 -1
  184. package/dist/cjs/{index-BQsO_CAs.js → index-Dv40T5Ly.js} +195 -169
  185. package/dist/cjs/{index-BQsO_CAs.js.map → index-Dv40T5Ly.js.map} +1 -1
  186. package/dist/cjs/{index--BeRLo6L.js → index-h3QcOeWw.js} +12 -14
  187. package/dist/cjs/{index--BeRLo6L.js.map → index-h3QcOeWw.js.map} +1 -1
  188. package/dist/cjs/index.css +1 -2
  189. package/dist/cjs/index.js +26 -10
  190. package/dist/cjs/index.js.map +1 -1
  191. package/dist/cjs/layouts.js +8 -3
  192. package/dist/cjs/layouts.js.map +1 -1
  193. package/dist/cjs/overlayManager.js +1 -2
  194. package/dist/cjs/overlayManager.js.map +1 -1
  195. package/dist/cjs/{react-select-creatable.esm-Bdv9YAMt.js → react-select-creatable.esm-lcdODVBz.js} +449 -243
  196. package/dist/cjs/react-select-creatable.esm-lcdODVBz.js.map +1 -0
  197. package/dist/cjs/useId-DXHUzdxd.js.map +1 -1
  198. package/dist/cjs/{useOverlayManager-CxBh9gVG.js → useOverlayManager-Bj58uLfc.js} +14 -9
  199. package/dist/cjs/{useOverlayManager-CxBh9gVG.js.map → useOverlayManager-Bj58uLfc.js.map} +1 -1
  200. package/dist/cjs/useQueryParams-BrrbBvY_.js +18 -0
  201. package/dist/cjs/{useQueryParams-l5fJJYCR.js.map → useQueryParams-BrrbBvY_.js.map} +1 -1
  202. package/dist/cjs/useRecentlyUsedColors-BcOkiB-v.js +1239 -0
  203. package/dist/cjs/useRecentlyUsedColors-BcOkiB-v.js.map +1 -0
  204. package/dist/cjs/useRestoreScrollPosition-DP8SUs19.js +236 -0
  205. package/dist/cjs/useRestoreScrollPosition-DP8SUs19.js.map +1 -0
  206. package/dist/constants.js.map +1 -1
  207. package/dist/formik/ActionBlock.js +16 -9
  208. package/dist/formik/ActionBlock.js.map +1 -1
  209. package/dist/formik/BlockNavigation.js +41 -31
  210. package/dist/formik/BlockNavigation.js.map +1 -1
  211. package/dist/formik/Button.js +6 -4
  212. package/dist/formik/Button.js.map +1 -1
  213. package/dist/formik/Checkbox.js +30 -29
  214. package/dist/formik/Checkbox.js.map +1 -1
  215. package/dist/formik/Form.js +54 -48
  216. package/dist/formik/Form.js.map +1 -1
  217. package/dist/formik/Input.js +28 -27
  218. package/dist/formik/Input.js.map +1 -1
  219. package/dist/formik/MultiEmailInput.js +11 -7
  220. package/dist/formik/MultiEmailInput.js.map +1 -1
  221. package/dist/formik/Radio.js +7 -7
  222. package/dist/formik/Radio.js.map +1 -1
  223. package/dist/formik/Select.js +17 -12
  224. package/dist/formik/Select.js.map +1 -1
  225. package/dist/formik/Slider.js +8 -8
  226. package/dist/formik/Slider.js.map +1 -1
  227. package/dist/formik/Switch.js +31 -28
  228. package/dist/formik/Switch.js.map +1 -1
  229. package/dist/formik/Textarea.js +29 -28
  230. package/dist/formik/Textarea.js.map +1 -1
  231. package/dist/formik/TreeSelect.js +9 -6
  232. package/dist/formik/TreeSelect.js.map +1 -1
  233. package/dist/formik/index.js +11 -7
  234. package/dist/formik/index.js.map +1 -1
  235. package/dist/{index-Dxaw6gl9.js → index-D6vmwyYl.js} +14 -16
  236. package/dist/index-D6vmwyYl.js.map +1 -0
  237. package/dist/{index-C4Jg7ZKa.js → index-D6yXgUQN.js} +196 -170
  238. package/dist/{index-C4Jg7ZKa.js.map → index-D6yXgUQN.js.map} +1 -1
  239. package/dist/index.css +1 -2
  240. package/dist/index.js +26 -10
  241. package/dist/index.js.map +1 -1
  242. package/dist/layouts.js +8 -3
  243. package/dist/layouts.js.map +1 -1
  244. package/dist/overlayManager.js +1 -2
  245. package/dist/overlayManager.js.map +1 -1
  246. package/dist/{react-select-creatable.esm-Dx_vEnyD.js → react-select-creatable.esm-opiJTCqo.js} +450 -244
  247. package/dist/react-select-creatable.esm-opiJTCqo.js.map +1 -0
  248. package/dist/useId-Jj9hXm-g.js.map +1 -1
  249. package/dist/{useOverlayManager-AZIGhUYS.js → useOverlayManager-BzuBvhPZ.js} +14 -9
  250. package/dist/{useOverlayManager-AZIGhUYS.js.map → useOverlayManager-BzuBvhPZ.js.map} +1 -1
  251. package/dist/useQueryParams-BKsf4FPY.js +16 -0
  252. package/dist/{useQueryParams-b60CHFUx.js.map → useQueryParams-BKsf4FPY.js.map} +1 -1
  253. package/dist/useRecentlyUsedColors-CtvdF-KQ.js +1236 -0
  254. package/dist/useRecentlyUsedColors-CtvdF-KQ.js.map +1 -0
  255. package/dist/useRestoreScrollPosition-BVX-mT5c.js +225 -0
  256. package/dist/useRestoreScrollPosition-BVX-mT5c.js.map +1 -0
  257. package/package.json +42 -48
  258. package/dist/cjs/react-select-creatable.esm-Bdv9YAMt.js.map +0 -1
  259. package/dist/cjs/useQueryParams-l5fJJYCR.js +0 -18
  260. package/dist/cjs/useRecentlyUsedColors-3cKx-eDH.js +0 -1270
  261. package/dist/cjs/useRecentlyUsedColors-3cKx-eDH.js.map +0 -1
  262. package/dist/cjs/useRestoreScrollPosition-PsoENtiB.js +0 -218
  263. package/dist/cjs/useRestoreScrollPosition-PsoENtiB.js.map +0 -1
  264. package/dist/index-Dxaw6gl9.js.map +0 -1
  265. package/dist/react-select-creatable.esm-Dx_vEnyD.js.map +0 -1
  266. package/dist/useQueryParams-b60CHFUx.js +0 -16
  267. package/dist/useRecentlyUsedColors-CqUfqfck.js +0 -1267
  268. package/dist/useRecentlyUsedColors-CqUfqfck.js.map +0 -1
  269. package/dist/useRestoreScrollPosition-C1NSANQW.js +0 -207
  270. package/dist/useRestoreScrollPosition-C1NSANQW.js.map +0 -1
  271. package/src/translations/ar.json +0 -41
  272. package/src/translations/bg.json +0 -41
  273. package/src/translations/ca.json +0 -41
  274. package/src/translations/cs.json +0 -41
  275. package/src/translations/da.json +0 -41
  276. package/src/translations/de.json +0 -41
  277. package/src/translations/en.json +0 -41
  278. package/src/translations/es-MX.json +0 -41
  279. package/src/translations/es.json +0 -41
  280. package/src/translations/et.json +0 -41
  281. package/src/translations/fi.json +0 -41
  282. package/src/translations/fil.json +0 -41
  283. package/src/translations/fr.json +0 -41
  284. package/src/translations/hi.json +0 -41
  285. package/src/translations/hr.json +0 -41
  286. package/src/translations/id.json +0 -41
  287. package/src/translations/index.js +0 -18
  288. package/src/translations/it.json +0 -41
  289. package/src/translations/ja.json +0 -41
  290. package/src/translations/ko.json +0 -41
  291. package/src/translations/nl.json +0 -41
  292. package/src/translations/pl.json +0 -41
  293. package/src/translations/pt-BR.json +0 -41
  294. package/src/translations/pt.json +0 -41
  295. package/src/translations/ro.json +0 -41
  296. package/src/translations/ru.json +0 -41
  297. package/src/translations/sk.json +0 -41
  298. package/src/translations/sl.json +0 -41
  299. package/src/translations/sv.json +0 -41
  300. package/src/translations/th.json +0 -41
  301. package/src/translations/tr.json +0 -41
  302. package/src/translations/uk.json +0 -41
  303. package/src/translations/vi.json +0 -41
  304. package/src/translations/zh-CN.json +0 -41
  305. package/src/translations/zh-TW.json +0 -41
@@ -0,0 +1,1239 @@
1
+ 'use strict';
2
+
3
+ var React = require('react');
4
+ var index = require('./index-h3QcOeWw.js');
5
+
6
+ // This file is autogenerated. It's used to publish ESM to npm.
7
+ function _typeof(obj) {
8
+ "@babel/helpers - typeof";
9
+
10
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
11
+ return typeof obj;
12
+ } : function (obj) {
13
+ return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
14
+ }, _typeof(obj);
15
+ }
16
+
17
+ // https://github.com/bgrins/TinyColor
18
+ // Brian Grinstead, MIT License
19
+
20
+ var trimLeft = /^\s+/;
21
+ var trimRight = /\s+$/;
22
+ function tinycolor(color, opts) {
23
+ color = color ? color : "";
24
+ opts = opts || {};
25
+
26
+ // If input is already a tinycolor, return itself
27
+ if (color instanceof tinycolor) {
28
+ return color;
29
+ }
30
+ // If we are called as a function, call using new instead
31
+ if (!(this instanceof tinycolor)) {
32
+ return new tinycolor(color, opts);
33
+ }
34
+ var rgb = inputToRGB(color);
35
+ 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;
36
+ this._gradientType = opts.gradientType;
37
+
38
+ // Don't let the range of [0,255] come back in [0,1].
39
+ // Potentially lose a little bit of precision here, but will fix issues where
40
+ // .5 gets interpreted as half of the total, instead of half of 1
41
+ // If it was supposed to be 128, this was already taken care of by `inputToRgb`
42
+ if (this._r < 1) this._r = Math.round(this._r);
43
+ if (this._g < 1) this._g = Math.round(this._g);
44
+ if (this._b < 1) this._b = Math.round(this._b);
45
+ this._ok = rgb.ok;
46
+ }
47
+ tinycolor.prototype = {
48
+ isDark: function isDark() {
49
+ return this.getBrightness() < 128;
50
+ },
51
+ isLight: function isLight() {
52
+ return !this.isDark();
53
+ },
54
+ isValid: function isValid() {
55
+ return this._ok;
56
+ },
57
+ getOriginalInput: function getOriginalInput() {
58
+ return this._originalInput;
59
+ },
60
+ getFormat: function getFormat() {
61
+ return this._format;
62
+ },
63
+ getAlpha: function getAlpha() {
64
+ return this._a;
65
+ },
66
+ getBrightness: function getBrightness() {
67
+ //http://www.w3.org/TR/AERT#color-contrast
68
+ var rgb = this.toRgb();
69
+ return (rgb.r * 299 + rgb.g * 587 + rgb.b * 114) / 1000;
70
+ },
71
+ getLuminance: function getLuminance() {
72
+ //http://www.w3.org/TR/2008/REC-WCAG20-20081211/#relativeluminancedef
73
+ var rgb = this.toRgb();
74
+ var RsRGB, GsRGB, BsRGB, R, G, B;
75
+ RsRGB = rgb.r / 255;
76
+ GsRGB = rgb.g / 255;
77
+ BsRGB = rgb.b / 255;
78
+ if (RsRGB <= 0.03928) R = RsRGB / 12.92;else R = Math.pow((RsRGB + 0.055) / 1.055, 2.4);
79
+ if (GsRGB <= 0.03928) G = GsRGB / 12.92;else G = Math.pow((GsRGB + 0.055) / 1.055, 2.4);
80
+ if (BsRGB <= 0.03928) B = BsRGB / 12.92;else B = Math.pow((BsRGB + 0.055) / 1.055, 2.4);
81
+ return 0.2126 * R + 0.7152 * G + 0.0722 * B;
82
+ },
83
+ setAlpha: function setAlpha(value) {
84
+ this._a = boundAlpha(value);
85
+ this._roundA = Math.round(100 * this._a) / 100;
86
+ return this;
87
+ },
88
+ toHsv: function toHsv() {
89
+ var hsv = rgbToHsv(this._r, this._g, this._b);
90
+ return {
91
+ h: hsv.h * 360,
92
+ s: hsv.s,
93
+ v: hsv.v,
94
+ a: this._a
95
+ };
96
+ },
97
+ toHsvString: function toHsvString() {
98
+ var hsv = rgbToHsv(this._r, this._g, this._b);
99
+ var h = Math.round(hsv.h * 360),
100
+ s = Math.round(hsv.s * 100),
101
+ v = Math.round(hsv.v * 100);
102
+ return this._a == 1 ? "hsv(" + h + ", " + s + "%, " + v + "%)" : "hsva(" + h + ", " + s + "%, " + v + "%, " + this._roundA + ")";
103
+ },
104
+ toHsl: function toHsl() {
105
+ var hsl = rgbToHsl(this._r, this._g, this._b);
106
+ return {
107
+ h: hsl.h * 360,
108
+ s: hsl.s,
109
+ l: hsl.l,
110
+ a: this._a
111
+ };
112
+ },
113
+ toHslString: function toHslString() {
114
+ var hsl = rgbToHsl(this._r, this._g, this._b);
115
+ var h = Math.round(hsl.h * 360),
116
+ s = Math.round(hsl.s * 100),
117
+ l = Math.round(hsl.l * 100);
118
+ return this._a == 1 ? "hsl(" + h + ", " + s + "%, " + l + "%)" : "hsla(" + h + ", " + s + "%, " + l + "%, " + this._roundA + ")";
119
+ },
120
+ toHex: function toHex(allow3Char) {
121
+ return rgbToHex(this._r, this._g, this._b, allow3Char);
122
+ },
123
+ toHexString: function toHexString(allow3Char) {
124
+ return "#" + this.toHex(allow3Char);
125
+ },
126
+ toHex8: function toHex8(allow4Char) {
127
+ return rgbaToHex(this._r, this._g, this._b, this._a, allow4Char);
128
+ },
129
+ toHex8String: function toHex8String(allow4Char) {
130
+ return "#" + this.toHex8(allow4Char);
131
+ },
132
+ toRgb: function toRgb() {
133
+ return {
134
+ r: Math.round(this._r),
135
+ g: Math.round(this._g),
136
+ b: Math.round(this._b),
137
+ a: this._a
138
+ };
139
+ },
140
+ toRgbString: function toRgbString() {
141
+ 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 + ")";
142
+ },
143
+ toPercentageRgb: function toPercentageRgb() {
144
+ return {
145
+ r: Math.round(bound01(this._r, 255) * 100) + "%",
146
+ g: Math.round(bound01(this._g, 255) * 100) + "%",
147
+ b: Math.round(bound01(this._b, 255) * 100) + "%",
148
+ a: this._a
149
+ };
150
+ },
151
+ toPercentageRgbString: function toPercentageRgbString() {
152
+ 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 + ")";
153
+ },
154
+ toName: function toName() {
155
+ if (this._a === 0) {
156
+ return "transparent";
157
+ }
158
+ if (this._a < 1) {
159
+ return false;
160
+ }
161
+ return hexNames[rgbToHex(this._r, this._g, this._b, true)] || false;
162
+ },
163
+ toFilter: function toFilter(secondColor) {
164
+ var hex8String = "#" + rgbaToArgbHex(this._r, this._g, this._b, this._a);
165
+ var secondHex8String = hex8String;
166
+ var gradientType = this._gradientType ? "GradientType = 1, " : "";
167
+ if (secondColor) {
168
+ var s = tinycolor(secondColor);
169
+ secondHex8String = "#" + rgbaToArgbHex(s._r, s._g, s._b, s._a);
170
+ }
171
+ return "progid:DXImageTransform.Microsoft.gradient(" + gradientType + "startColorstr=" + hex8String + ",endColorstr=" + secondHex8String + ")";
172
+ },
173
+ toString: function toString(format) {
174
+ var formatSet = !!format;
175
+ format = format || this._format;
176
+ var formattedString = false;
177
+ var hasAlpha = this._a < 1 && this._a >= 0;
178
+ var needsAlphaFormat = !formatSet && hasAlpha && (format === "hex" || format === "hex6" || format === "hex3" || format === "hex4" || format === "hex8" || format === "name");
179
+ if (needsAlphaFormat) {
180
+ // Special case for "transparent", all other non-alpha formats
181
+ // will return rgba when there is transparency.
182
+ if (format === "name" && this._a === 0) {
183
+ return this.toName();
184
+ }
185
+ return this.toRgbString();
186
+ }
187
+ if (format === "rgb") {
188
+ formattedString = this.toRgbString();
189
+ }
190
+ if (format === "prgb") {
191
+ formattedString = this.toPercentageRgbString();
192
+ }
193
+ if (format === "hex" || format === "hex6") {
194
+ formattedString = this.toHexString();
195
+ }
196
+ if (format === "hex3") {
197
+ formattedString = this.toHexString(true);
198
+ }
199
+ if (format === "hex4") {
200
+ formattedString = this.toHex8String(true);
201
+ }
202
+ if (format === "hex8") {
203
+ formattedString = this.toHex8String();
204
+ }
205
+ if (format === "name") {
206
+ formattedString = this.toName();
207
+ }
208
+ if (format === "hsl") {
209
+ formattedString = this.toHslString();
210
+ }
211
+ if (format === "hsv") {
212
+ formattedString = this.toHsvString();
213
+ }
214
+ return formattedString || this.toHexString();
215
+ },
216
+ clone: function clone() {
217
+ return tinycolor(this.toString());
218
+ },
219
+ _applyModification: function _applyModification(fn, args) {
220
+ var color = fn.apply(null, [this].concat([].slice.call(args)));
221
+ this._r = color._r;
222
+ this._g = color._g;
223
+ this._b = color._b;
224
+ this.setAlpha(color._a);
225
+ return this;
226
+ },
227
+ lighten: function lighten() {
228
+ return this._applyModification(_lighten, arguments);
229
+ },
230
+ brighten: function brighten() {
231
+ return this._applyModification(_brighten, arguments);
232
+ },
233
+ darken: function darken() {
234
+ return this._applyModification(_darken, arguments);
235
+ },
236
+ desaturate: function desaturate() {
237
+ return this._applyModification(_desaturate, arguments);
238
+ },
239
+ saturate: function saturate() {
240
+ return this._applyModification(_saturate, arguments);
241
+ },
242
+ greyscale: function greyscale() {
243
+ return this._applyModification(_greyscale, arguments);
244
+ },
245
+ spin: function spin() {
246
+ return this._applyModification(_spin, arguments);
247
+ },
248
+ _applyCombination: function _applyCombination(fn, args) {
249
+ return fn.apply(null, [this].concat([].slice.call(args)));
250
+ },
251
+ analogous: function analogous() {
252
+ return this._applyCombination(_analogous, arguments);
253
+ },
254
+ complement: function complement() {
255
+ return this._applyCombination(_complement, arguments);
256
+ },
257
+ monochromatic: function monochromatic() {
258
+ return this._applyCombination(_monochromatic, arguments);
259
+ },
260
+ splitcomplement: function splitcomplement() {
261
+ return this._applyCombination(_splitcomplement, arguments);
262
+ },
263
+ // Disabled until https://github.com/bgrins/TinyColor/issues/254
264
+ // polyad: function (number) {
265
+ // return this._applyCombination(polyad, [number]);
266
+ // },
267
+ triad: function triad() {
268
+ return this._applyCombination(polyad, [3]);
269
+ },
270
+ tetrad: function tetrad() {
271
+ return this._applyCombination(polyad, [4]);
272
+ }
273
+ };
274
+
275
+ // If input is an object, force 1 into "1.0" to handle ratios properly
276
+ // String input requires "1.0" as input, so 1 will be treated as 1
277
+ tinycolor.fromRatio = function (color, opts) {
278
+ if (_typeof(color) == "object") {
279
+ var newColor = {};
280
+ for (var i in color) {
281
+ if (color.hasOwnProperty(i)) {
282
+ if (i === "a") {
283
+ newColor[i] = color[i];
284
+ } else {
285
+ newColor[i] = convertToPercentage(color[i]);
286
+ }
287
+ }
288
+ }
289
+ color = newColor;
290
+ }
291
+ return tinycolor(color, opts);
292
+ };
293
+
294
+ // Given a string or object, convert that input to RGB
295
+ // Possible string inputs:
296
+ //
297
+ // "red"
298
+ // "#f00" or "f00"
299
+ // "#ff0000" or "ff0000"
300
+ // "#ff000000" or "ff000000"
301
+ // "rgb 255 0 0" or "rgb (255, 0, 0)"
302
+ // "rgb 1.0 0 0" or "rgb (1, 0, 0)"
303
+ // "rgba (255, 0, 0, 1)" or "rgba 255, 0, 0, 1"
304
+ // "rgba (1.0, 0, 0, 1)" or "rgba 1.0, 0, 0, 1"
305
+ // "hsl(0, 100%, 50%)" or "hsl 0 100% 50%"
306
+ // "hsla(0, 100%, 50%, 1)" or "hsla 0 100% 50%, 1"
307
+ // "hsv(0, 100%, 100%)" or "hsv 0 100% 100%"
308
+ //
309
+ function inputToRGB(color) {
310
+ var rgb = {
311
+ r: 0,
312
+ g: 0,
313
+ b: 0
314
+ };
315
+ var a = 1;
316
+ var s = null;
317
+ var v = null;
318
+ var l = null;
319
+ var ok = false;
320
+ var format = false;
321
+ if (typeof color == "string") {
322
+ color = stringInputToObject(color);
323
+ }
324
+ if (_typeof(color) == "object") {
325
+ if (isValidCSSUnit(color.r) && isValidCSSUnit(color.g) && isValidCSSUnit(color.b)) {
326
+ rgb = rgbToRgb(color.r, color.g, color.b);
327
+ ok = true;
328
+ format = String(color.r).substr(-1) === "%" ? "prgb" : "rgb";
329
+ } else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.v)) {
330
+ s = convertToPercentage(color.s);
331
+ v = convertToPercentage(color.v);
332
+ rgb = hsvToRgb(color.h, s, v);
333
+ ok = true;
334
+ format = "hsv";
335
+ } else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.l)) {
336
+ s = convertToPercentage(color.s);
337
+ l = convertToPercentage(color.l);
338
+ rgb = hslToRgb(color.h, s, l);
339
+ ok = true;
340
+ format = "hsl";
341
+ }
342
+ if (color.hasOwnProperty("a")) {
343
+ a = color.a;
344
+ }
345
+ }
346
+ a = boundAlpha(a);
347
+ return {
348
+ ok: ok,
349
+ format: color.format || format,
350
+ r: Math.min(255, Math.max(rgb.r, 0)),
351
+ g: Math.min(255, Math.max(rgb.g, 0)),
352
+ b: Math.min(255, Math.max(rgb.b, 0)),
353
+ a: a
354
+ };
355
+ }
356
+
357
+ // Conversion Functions
358
+ // --------------------
359
+
360
+ // `rgbToHsl`, `rgbToHsv`, `hslToRgb`, `hsvToRgb` modified from:
361
+ // <http://mjijackson.com/2008/02/rgb-to-hsl-and-rgb-to-hsv-color-model-conversion-algorithms-in-javascript>
362
+
363
+ // `rgbToRgb`
364
+ // Handle bounds / percentage checking to conform to CSS color spec
365
+ // <http://www.w3.org/TR/css3-color/>
366
+ // *Assumes:* r, g, b in [0, 255] or [0, 1]
367
+ // *Returns:* { r, g, b } in [0, 255]
368
+ function rgbToRgb(r, g, b) {
369
+ return {
370
+ r: bound01(r, 255) * 255,
371
+ g: bound01(g, 255) * 255,
372
+ b: bound01(b, 255) * 255
373
+ };
374
+ }
375
+
376
+ // `rgbToHsl`
377
+ // Converts an RGB color value to HSL.
378
+ // *Assumes:* r, g, and b are contained in [0, 255] or [0, 1]
379
+ // *Returns:* { h, s, l } in [0,1]
380
+ function rgbToHsl(r, g, b) {
381
+ r = bound01(r, 255);
382
+ g = bound01(g, 255);
383
+ b = bound01(b, 255);
384
+ var max = Math.max(r, g, b),
385
+ min = Math.min(r, g, b);
386
+ var h,
387
+ s,
388
+ l = (max + min) / 2;
389
+ if (max == min) {
390
+ h = s = 0; // achromatic
391
+ } else {
392
+ var d = max - min;
393
+ s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
394
+ switch (max) {
395
+ case r:
396
+ h = (g - b) / d + (g < b ? 6 : 0);
397
+ break;
398
+ case g:
399
+ h = (b - r) / d + 2;
400
+ break;
401
+ case b:
402
+ h = (r - g) / d + 4;
403
+ break;
404
+ }
405
+ h /= 6;
406
+ }
407
+ return {
408
+ h: h,
409
+ s: s,
410
+ l: l
411
+ };
412
+ }
413
+
414
+ // `hslToRgb`
415
+ // Converts an HSL color value to RGB.
416
+ // *Assumes:* h is contained in [0, 1] or [0, 360] and s and l are contained [0, 1] or [0, 100]
417
+ // *Returns:* { r, g, b } in the set [0, 255]
418
+ function hslToRgb(h, s, l) {
419
+ var r, g, b;
420
+ h = bound01(h, 360);
421
+ s = bound01(s, 100);
422
+ l = bound01(l, 100);
423
+ function hue2rgb(p, q, t) {
424
+ if (t < 0) t += 1;
425
+ if (t > 1) t -= 1;
426
+ if (t < 1 / 6) return p + (q - p) * 6 * t;
427
+ if (t < 1 / 2) return q;
428
+ if (t < 2 / 3) return p + (q - p) * (2 / 3 - t) * 6;
429
+ return p;
430
+ }
431
+ if (s === 0) {
432
+ r = g = b = l; // achromatic
433
+ } else {
434
+ var q = l < 0.5 ? l * (1 + s) : l + s - l * s;
435
+ var p = 2 * l - q;
436
+ r = hue2rgb(p, q, h + 1 / 3);
437
+ g = hue2rgb(p, q, h);
438
+ b = hue2rgb(p, q, h - 1 / 3);
439
+ }
440
+ return {
441
+ r: r * 255,
442
+ g: g * 255,
443
+ b: b * 255
444
+ };
445
+ }
446
+
447
+ // `rgbToHsv`
448
+ // Converts an RGB color value to HSV
449
+ // *Assumes:* r, g, and b are contained in the set [0, 255] or [0, 1]
450
+ // *Returns:* { h, s, v } in [0,1]
451
+ function rgbToHsv(r, g, b) {
452
+ r = bound01(r, 255);
453
+ g = bound01(g, 255);
454
+ b = bound01(b, 255);
455
+ var max = Math.max(r, g, b),
456
+ min = Math.min(r, g, b);
457
+ var h,
458
+ s,
459
+ v = max;
460
+ var d = max - min;
461
+ s = max === 0 ? 0 : d / max;
462
+ if (max == min) {
463
+ h = 0; // achromatic
464
+ } else {
465
+ switch (max) {
466
+ case r:
467
+ h = (g - b) / d + (g < b ? 6 : 0);
468
+ break;
469
+ case g:
470
+ h = (b - r) / d + 2;
471
+ break;
472
+ case b:
473
+ h = (r - g) / d + 4;
474
+ break;
475
+ }
476
+ h /= 6;
477
+ }
478
+ return {
479
+ h: h,
480
+ s: s,
481
+ v: v
482
+ };
483
+ }
484
+
485
+ // `hsvToRgb`
486
+ // Converts an HSV color value to RGB.
487
+ // *Assumes:* h is contained in [0, 1] or [0, 360] and s and v are contained in [0, 1] or [0, 100]
488
+ // *Returns:* { r, g, b } in the set [0, 255]
489
+ function hsvToRgb(h, s, v) {
490
+ h = bound01(h, 360) * 6;
491
+ s = bound01(s, 100);
492
+ v = bound01(v, 100);
493
+ var i = Math.floor(h),
494
+ f = h - i,
495
+ p = v * (1 - s),
496
+ q = v * (1 - f * s),
497
+ t = v * (1 - (1 - f) * s),
498
+ mod = i % 6,
499
+ r = [v, q, p, p, t, v][mod],
500
+ g = [t, v, v, q, p, p][mod],
501
+ b = [p, p, t, v, v, q][mod];
502
+ return {
503
+ r: r * 255,
504
+ g: g * 255,
505
+ b: b * 255
506
+ };
507
+ }
508
+
509
+ // `rgbToHex`
510
+ // Converts an RGB color to hex
511
+ // Assumes r, g, and b are contained in the set [0, 255]
512
+ // Returns a 3 or 6 character hex
513
+ function rgbToHex(r, g, b, allow3Char) {
514
+ var hex = [pad2(Math.round(r).toString(16)), pad2(Math.round(g).toString(16)), pad2(Math.round(b).toString(16))];
515
+
516
+ // Return a 3 character hex if possible
517
+ 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)) {
518
+ return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0);
519
+ }
520
+ return hex.join("");
521
+ }
522
+
523
+ // `rgbaToHex`
524
+ // Converts an RGBA color plus alpha transparency to hex
525
+ // Assumes r, g, b are contained in the set [0, 255] and
526
+ // a in [0, 1]. Returns a 4 or 8 character rgba hex
527
+ function rgbaToHex(r, g, b, a, allow4Char) {
528
+ var hex = [pad2(Math.round(r).toString(16)), pad2(Math.round(g).toString(16)), pad2(Math.round(b).toString(16)), pad2(convertDecimalToHex(a))];
529
+
530
+ // Return a 4 character hex if possible
531
+ 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)) {
532
+ return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0) + hex[3].charAt(0);
533
+ }
534
+ return hex.join("");
535
+ }
536
+
537
+ // `rgbaToArgbHex`
538
+ // Converts an RGBA color to an ARGB Hex8 string
539
+ // Rarely used, but required for "toFilter()"
540
+ function rgbaToArgbHex(r, g, b, a) {
541
+ var hex = [pad2(convertDecimalToHex(a)), pad2(Math.round(r).toString(16)), pad2(Math.round(g).toString(16)), pad2(Math.round(b).toString(16))];
542
+ return hex.join("");
543
+ }
544
+
545
+ // `equals`
546
+ // Can be called with any tinycolor input
547
+ tinycolor.equals = function (color1, color2) {
548
+ if (!color1 || !color2) return false;
549
+ return tinycolor(color1).toRgbString() == tinycolor(color2).toRgbString();
550
+ };
551
+ tinycolor.random = function () {
552
+ return tinycolor.fromRatio({
553
+ r: Math.random(),
554
+ g: Math.random(),
555
+ b: Math.random()
556
+ });
557
+ };
558
+
559
+ // Modification Functions
560
+ // ----------------------
561
+ // Thanks to less.js for some of the basics here
562
+ // <https://github.com/cloudhead/less.js/blob/master/lib/less/functions.js>
563
+
564
+ function _desaturate(color, amount) {
565
+ amount = amount === 0 ? 0 : amount || 10;
566
+ var hsl = tinycolor(color).toHsl();
567
+ hsl.s -= amount / 100;
568
+ hsl.s = clamp01(hsl.s);
569
+ return tinycolor(hsl);
570
+ }
571
+ function _saturate(color, amount) {
572
+ amount = amount === 0 ? 0 : amount || 10;
573
+ var hsl = tinycolor(color).toHsl();
574
+ hsl.s += amount / 100;
575
+ hsl.s = clamp01(hsl.s);
576
+ return tinycolor(hsl);
577
+ }
578
+ function _greyscale(color) {
579
+ return tinycolor(color).desaturate(100);
580
+ }
581
+ function _lighten(color, amount) {
582
+ amount = amount === 0 ? 0 : amount || 10;
583
+ var hsl = tinycolor(color).toHsl();
584
+ hsl.l += amount / 100;
585
+ hsl.l = clamp01(hsl.l);
586
+ return tinycolor(hsl);
587
+ }
588
+ function _brighten(color, amount) {
589
+ amount = amount === 0 ? 0 : amount || 10;
590
+ var rgb = tinycolor(color).toRgb();
591
+ rgb.r = Math.max(0, Math.min(255, rgb.r - Math.round(255 * -(amount / 100))));
592
+ rgb.g = Math.max(0, Math.min(255, rgb.g - Math.round(255 * -(amount / 100))));
593
+ rgb.b = Math.max(0, Math.min(255, rgb.b - Math.round(255 * -(amount / 100))));
594
+ return tinycolor(rgb);
595
+ }
596
+ function _darken(color, amount) {
597
+ amount = amount === 0 ? 0 : amount || 10;
598
+ var hsl = tinycolor(color).toHsl();
599
+ hsl.l -= amount / 100;
600
+ hsl.l = clamp01(hsl.l);
601
+ return tinycolor(hsl);
602
+ }
603
+
604
+ // Spin takes a positive or negative amount within [-360, 360] indicating the change of hue.
605
+ // Values outside of this range will be wrapped into this range.
606
+ function _spin(color, amount) {
607
+ var hsl = tinycolor(color).toHsl();
608
+ var hue = (hsl.h + amount) % 360;
609
+ hsl.h = hue < 0 ? 360 + hue : hue;
610
+ return tinycolor(hsl);
611
+ }
612
+
613
+ // Combination Functions
614
+ // ---------------------
615
+ // Thanks to jQuery xColor for some of the ideas behind these
616
+ // <https://github.com/infusion/jQuery-xcolor/blob/master/jquery.xcolor.js>
617
+
618
+ function _complement(color) {
619
+ var hsl = tinycolor(color).toHsl();
620
+ hsl.h = (hsl.h + 180) % 360;
621
+ return tinycolor(hsl);
622
+ }
623
+ function polyad(color, number) {
624
+ if (isNaN(number) || number <= 0) {
625
+ throw new Error("Argument to polyad must be a positive number");
626
+ }
627
+ var hsl = tinycolor(color).toHsl();
628
+ var result = [tinycolor(color)];
629
+ var step = 360 / number;
630
+ for (var i = 1; i < number; i++) {
631
+ result.push(tinycolor({
632
+ h: (hsl.h + i * step) % 360,
633
+ s: hsl.s,
634
+ l: hsl.l
635
+ }));
636
+ }
637
+ return result;
638
+ }
639
+ function _splitcomplement(color) {
640
+ var hsl = tinycolor(color).toHsl();
641
+ var h = hsl.h;
642
+ return [tinycolor(color), tinycolor({
643
+ h: (h + 72) % 360,
644
+ s: hsl.s,
645
+ l: hsl.l
646
+ }), tinycolor({
647
+ h: (h + 216) % 360,
648
+ s: hsl.s,
649
+ l: hsl.l
650
+ })];
651
+ }
652
+ function _analogous(color, results, slices) {
653
+ results = results || 6;
654
+ slices = slices || 30;
655
+ var hsl = tinycolor(color).toHsl();
656
+ var part = 360 / slices;
657
+ var ret = [tinycolor(color)];
658
+ for (hsl.h = (hsl.h - (part * results >> 1) + 720) % 360; --results;) {
659
+ hsl.h = (hsl.h + part) % 360;
660
+ ret.push(tinycolor(hsl));
661
+ }
662
+ return ret;
663
+ }
664
+ function _monochromatic(color, results) {
665
+ results = results || 6;
666
+ var hsv = tinycolor(color).toHsv();
667
+ var h = hsv.h,
668
+ s = hsv.s,
669
+ v = hsv.v;
670
+ var ret = [];
671
+ var modification = 1 / results;
672
+ while (results--) {
673
+ ret.push(tinycolor({
674
+ h: h,
675
+ s: s,
676
+ v: v
677
+ }));
678
+ v = (v + modification) % 1;
679
+ }
680
+ return ret;
681
+ }
682
+
683
+ // Utility Functions
684
+ // ---------------------
685
+
686
+ tinycolor.mix = function (color1, color2, amount) {
687
+ amount = amount === 0 ? 0 : amount || 50;
688
+ var rgb1 = tinycolor(color1).toRgb();
689
+ var rgb2 = tinycolor(color2).toRgb();
690
+ var p = amount / 100;
691
+ var rgba = {
692
+ r: (rgb2.r - rgb1.r) * p + rgb1.r,
693
+ g: (rgb2.g - rgb1.g) * p + rgb1.g,
694
+ b: (rgb2.b - rgb1.b) * p + rgb1.b,
695
+ a: (rgb2.a - rgb1.a) * p + rgb1.a
696
+ };
697
+ return tinycolor(rgba);
698
+ };
699
+
700
+ // Readability Functions
701
+ // ---------------------
702
+ // <http://www.w3.org/TR/2008/REC-WCAG20-20081211/#contrast-ratiodef (WCAG Version 2)
703
+
704
+ // `contrast`
705
+ // Analyze the 2 colors and returns the color contrast defined by (WCAG Version 2)
706
+ tinycolor.readability = function (color1, color2) {
707
+ var c1 = tinycolor(color1);
708
+ var c2 = tinycolor(color2);
709
+ return (Math.max(c1.getLuminance(), c2.getLuminance()) + 0.05) / (Math.min(c1.getLuminance(), c2.getLuminance()) + 0.05);
710
+ };
711
+
712
+ // `isReadable`
713
+ // Ensure that foreground and background color combinations meet WCAG2 guidelines.
714
+ // The third argument is an optional Object.
715
+ // the 'level' property states 'AA' or 'AAA' - if missing or invalid, it defaults to 'AA';
716
+ // the 'size' property states 'large' or 'small' - if missing or invalid, it defaults to 'small'.
717
+ // If the entire object is absent, isReadable defaults to {level:"AA",size:"small"}.
718
+
719
+ // *Example*
720
+ // tinycolor.isReadable("#000", "#111") => false
721
+ // tinycolor.isReadable("#000", "#111",{level:"AA",size:"large"}) => false
722
+ tinycolor.isReadable = function (color1, color2, wcag2) {
723
+ var readability = tinycolor.readability(color1, color2);
724
+ var wcag2Parms, out;
725
+ out = false;
726
+ wcag2Parms = validateWCAG2Parms(wcag2);
727
+ switch (wcag2Parms.level + wcag2Parms.size) {
728
+ case "AAsmall":
729
+ case "AAAlarge":
730
+ out = readability >= 4.5;
731
+ break;
732
+ case "AAlarge":
733
+ out = readability >= 3;
734
+ break;
735
+ case "AAAsmall":
736
+ out = readability >= 7;
737
+ break;
738
+ }
739
+ return out;
740
+ };
741
+
742
+ // `mostReadable`
743
+ // Given a base color and a list of possible foreground or background
744
+ // colors for that base, returns the most readable color.
745
+ // Optionally returns Black or White if the most readable color is unreadable.
746
+ // *Example*
747
+ // tinycolor.mostReadable(tinycolor.mostReadable("#123", ["#124", "#125"],{includeFallbackColors:false}).toHexString(); // "#112255"
748
+ // tinycolor.mostReadable(tinycolor.mostReadable("#123", ["#124", "#125"],{includeFallbackColors:true}).toHexString(); // "#ffffff"
749
+ // tinycolor.mostReadable("#a8015a", ["#faf3f3"],{includeFallbackColors:true,level:"AAA",size:"large"}).toHexString(); // "#faf3f3"
750
+ // tinycolor.mostReadable("#a8015a", ["#faf3f3"],{includeFallbackColors:true,level:"AAA",size:"small"}).toHexString(); // "#ffffff"
751
+ tinycolor.mostReadable = function (baseColor, colorList, args) {
752
+ var bestColor = null;
753
+ var bestScore = 0;
754
+ var readability;
755
+ var includeFallbackColors, level, size;
756
+ args = args || {};
757
+ includeFallbackColors = args.includeFallbackColors;
758
+ level = args.level;
759
+ size = args.size;
760
+ for (var i = 0; i < colorList.length; i++) {
761
+ readability = tinycolor.readability(baseColor, colorList[i]);
762
+ if (readability > bestScore) {
763
+ bestScore = readability;
764
+ bestColor = tinycolor(colorList[i]);
765
+ }
766
+ }
767
+ if (tinycolor.isReadable(baseColor, bestColor, {
768
+ level: level,
769
+ size: size
770
+ }) || !includeFallbackColors) {
771
+ return bestColor;
772
+ } else {
773
+ args.includeFallbackColors = false;
774
+ return tinycolor.mostReadable(baseColor, ["#fff", "#000"], args);
775
+ }
776
+ };
777
+
778
+ // Big List of Colors
779
+ // ------------------
780
+ // <https://www.w3.org/TR/css-color-4/#named-colors>
781
+ var names = tinycolor.names = {
782
+ aliceblue: "f0f8ff",
783
+ antiquewhite: "faebd7",
784
+ aqua: "0ff",
785
+ aquamarine: "7fffd4",
786
+ azure: "f0ffff",
787
+ beige: "f5f5dc",
788
+ bisque: "ffe4c4",
789
+ black: "000",
790
+ blanchedalmond: "ffebcd",
791
+ blue: "00f",
792
+ blueviolet: "8a2be2",
793
+ brown: "a52a2a",
794
+ burlywood: "deb887",
795
+ burntsienna: "ea7e5d",
796
+ cadetblue: "5f9ea0",
797
+ chartreuse: "7fff00",
798
+ chocolate: "d2691e",
799
+ coral: "ff7f50",
800
+ cornflowerblue: "6495ed",
801
+ cornsilk: "fff8dc",
802
+ crimson: "dc143c",
803
+ cyan: "0ff",
804
+ darkblue: "00008b",
805
+ darkcyan: "008b8b",
806
+ darkgoldenrod: "b8860b",
807
+ darkgray: "a9a9a9",
808
+ darkgreen: "006400",
809
+ darkgrey: "a9a9a9",
810
+ darkkhaki: "bdb76b",
811
+ darkmagenta: "8b008b",
812
+ darkolivegreen: "556b2f",
813
+ darkorange: "ff8c00",
814
+ darkorchid: "9932cc",
815
+ darkred: "8b0000",
816
+ darksalmon: "e9967a",
817
+ darkseagreen: "8fbc8f",
818
+ darkslateblue: "483d8b",
819
+ darkslategray: "2f4f4f",
820
+ darkslategrey: "2f4f4f",
821
+ darkturquoise: "00ced1",
822
+ darkviolet: "9400d3",
823
+ deeppink: "ff1493",
824
+ deepskyblue: "00bfff",
825
+ dimgray: "696969",
826
+ dimgrey: "696969",
827
+ dodgerblue: "1e90ff",
828
+ firebrick: "b22222",
829
+ floralwhite: "fffaf0",
830
+ forestgreen: "228b22",
831
+ fuchsia: "f0f",
832
+ gainsboro: "dcdcdc",
833
+ ghostwhite: "f8f8ff",
834
+ gold: "ffd700",
835
+ goldenrod: "daa520",
836
+ gray: "808080",
837
+ green: "008000",
838
+ greenyellow: "adff2f",
839
+ grey: "808080",
840
+ honeydew: "f0fff0",
841
+ hotpink: "ff69b4",
842
+ indianred: "cd5c5c",
843
+ indigo: "4b0082",
844
+ ivory: "fffff0",
845
+ khaki: "f0e68c",
846
+ lavender: "e6e6fa",
847
+ lavenderblush: "fff0f5",
848
+ lawngreen: "7cfc00",
849
+ lemonchiffon: "fffacd",
850
+ lightblue: "add8e6",
851
+ lightcoral: "f08080",
852
+ lightcyan: "e0ffff",
853
+ lightgoldenrodyellow: "fafad2",
854
+ lightgray: "d3d3d3",
855
+ lightgreen: "90ee90",
856
+ lightgrey: "d3d3d3",
857
+ lightpink: "ffb6c1",
858
+ lightsalmon: "ffa07a",
859
+ lightseagreen: "20b2aa",
860
+ lightskyblue: "87cefa",
861
+ lightslategray: "789",
862
+ lightslategrey: "789",
863
+ lightsteelblue: "b0c4de",
864
+ lightyellow: "ffffe0",
865
+ lime: "0f0",
866
+ limegreen: "32cd32",
867
+ linen: "faf0e6",
868
+ magenta: "f0f",
869
+ maroon: "800000",
870
+ mediumaquamarine: "66cdaa",
871
+ mediumblue: "0000cd",
872
+ mediumorchid: "ba55d3",
873
+ mediumpurple: "9370db",
874
+ mediumseagreen: "3cb371",
875
+ mediumslateblue: "7b68ee",
876
+ mediumspringgreen: "00fa9a",
877
+ mediumturquoise: "48d1cc",
878
+ mediumvioletred: "c71585",
879
+ midnightblue: "191970",
880
+ mintcream: "f5fffa",
881
+ mistyrose: "ffe4e1",
882
+ moccasin: "ffe4b5",
883
+ navajowhite: "ffdead",
884
+ navy: "000080",
885
+ oldlace: "fdf5e6",
886
+ olive: "808000",
887
+ olivedrab: "6b8e23",
888
+ orange: "ffa500",
889
+ orangered: "ff4500",
890
+ orchid: "da70d6",
891
+ palegoldenrod: "eee8aa",
892
+ palegreen: "98fb98",
893
+ paleturquoise: "afeeee",
894
+ palevioletred: "db7093",
895
+ papayawhip: "ffefd5",
896
+ peachpuff: "ffdab9",
897
+ peru: "cd853f",
898
+ pink: "ffc0cb",
899
+ plum: "dda0dd",
900
+ powderblue: "b0e0e6",
901
+ purple: "800080",
902
+ rebeccapurple: "663399",
903
+ red: "f00",
904
+ rosybrown: "bc8f8f",
905
+ royalblue: "4169e1",
906
+ saddlebrown: "8b4513",
907
+ salmon: "fa8072",
908
+ sandybrown: "f4a460",
909
+ seagreen: "2e8b57",
910
+ seashell: "fff5ee",
911
+ sienna: "a0522d",
912
+ silver: "c0c0c0",
913
+ skyblue: "87ceeb",
914
+ slateblue: "6a5acd",
915
+ slategray: "708090",
916
+ slategrey: "708090",
917
+ snow: "fffafa",
918
+ springgreen: "00ff7f",
919
+ steelblue: "4682b4",
920
+ tan: "d2b48c",
921
+ teal: "008080",
922
+ thistle: "d8bfd8",
923
+ tomato: "ff6347",
924
+ turquoise: "40e0d0",
925
+ violet: "ee82ee",
926
+ wheat: "f5deb3",
927
+ white: "fff",
928
+ whitesmoke: "f5f5f5",
929
+ yellow: "ff0",
930
+ yellowgreen: "9acd32"
931
+ };
932
+
933
+ // Make it easy to access colors via `hexNames[hex]`
934
+ var hexNames = tinycolor.hexNames = flip(names);
935
+
936
+ // Utilities
937
+ // ---------
938
+
939
+ // `{ 'name1': 'val1' }` becomes `{ 'val1': 'name1' }`
940
+ function flip(o) {
941
+ var flipped = {};
942
+ for (var i in o) {
943
+ if (o.hasOwnProperty(i)) {
944
+ flipped[o[i]] = i;
945
+ }
946
+ }
947
+ return flipped;
948
+ }
949
+
950
+ // Return a valid alpha value [0,1] with all invalid values being set to 1
951
+ function boundAlpha(a) {
952
+ a = parseFloat(a);
953
+ if (isNaN(a) || a < 0 || a > 1) {
954
+ a = 1;
955
+ }
956
+ return a;
957
+ }
958
+
959
+ // Take input from [0, n] and return it as [0, 1]
960
+ function bound01(n, max) {
961
+ if (isOnePointZero(n)) n = "100%";
962
+ var processPercent = isPercentage(n);
963
+ n = Math.min(max, Math.max(0, parseFloat(n)));
964
+
965
+ // Automatically convert percentage into number
966
+ if (processPercent) {
967
+ n = parseInt(n * max, 10) / 100;
968
+ }
969
+
970
+ // Handle floating point rounding errors
971
+ if (Math.abs(n - max) < 0.000001) {
972
+ return 1;
973
+ }
974
+
975
+ // Convert into [0, 1] range if it isn't already
976
+ return n % max / parseFloat(max);
977
+ }
978
+
979
+ // Force a number between 0 and 1
980
+ function clamp01(val) {
981
+ return Math.min(1, Math.max(0, val));
982
+ }
983
+
984
+ // Parse a base-16 hex value into a base-10 integer
985
+ function parseIntFromHex(val) {
986
+ return parseInt(val, 16);
987
+ }
988
+
989
+ // Need to handle 1.0 as 100%, since once it is a number, there is no difference between it and 1
990
+ // <http://stackoverflow.com/questions/7422072/javascript-how-to-detect-number-as-a-decimal-including-1-0>
991
+ function isOnePointZero(n) {
992
+ return typeof n == "string" && n.indexOf(".") != -1 && parseFloat(n) === 1;
993
+ }
994
+
995
+ // Check to see if string passed in is a percentage
996
+ function isPercentage(n) {
997
+ return typeof n === "string" && n.indexOf("%") != -1;
998
+ }
999
+
1000
+ // Force a hex value to have 2 characters
1001
+ function pad2(c) {
1002
+ return c.length == 1 ? "0" + c : "" + c;
1003
+ }
1004
+
1005
+ // Replace a decimal with it's percentage value
1006
+ function convertToPercentage(n) {
1007
+ if (n <= 1) {
1008
+ n = n * 100 + "%";
1009
+ }
1010
+ return n;
1011
+ }
1012
+
1013
+ // Converts a decimal to a hex value
1014
+ function convertDecimalToHex(d) {
1015
+ return Math.round(parseFloat(d) * 255).toString(16);
1016
+ }
1017
+ // Converts a hex value to a decimal
1018
+ function convertHexToDecimal(h) {
1019
+ return parseIntFromHex(h) / 255;
1020
+ }
1021
+ var matchers = function () {
1022
+ // <http://www.w3.org/TR/css3-values/#integers>
1023
+ var CSS_INTEGER = "[-\\+]?\\d+%?";
1024
+
1025
+ // <http://www.w3.org/TR/css3-values/#number-value>
1026
+ var CSS_NUMBER = "[-\\+]?\\d*\\.\\d+%?";
1027
+
1028
+ // Allow positive/negative integer/number. Don't capture the either/or, just the entire outcome.
1029
+ var CSS_UNIT = "(?:" + CSS_NUMBER + ")|(?:" + CSS_INTEGER + ")";
1030
+
1031
+ // Actual matching.
1032
+ // Parentheses and commas are optional, but not required.
1033
+ // Whitespace can take the place of commas or opening paren
1034
+ var PERMISSIVE_MATCH3 = "[\\s|\\(]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")\\s*\\)?";
1035
+ var PERMISSIVE_MATCH4 = "[\\s|\\(]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")\\s*\\)?";
1036
+ return {
1037
+ CSS_UNIT: new RegExp(CSS_UNIT),
1038
+ rgb: new RegExp("rgb" + PERMISSIVE_MATCH3),
1039
+ rgba: new RegExp("rgba" + PERMISSIVE_MATCH4),
1040
+ hsl: new RegExp("hsl" + PERMISSIVE_MATCH3),
1041
+ hsla: new RegExp("hsla" + PERMISSIVE_MATCH4),
1042
+ hsv: new RegExp("hsv" + PERMISSIVE_MATCH3),
1043
+ hsva: new RegExp("hsva" + PERMISSIVE_MATCH4),
1044
+ hex3: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
1045
+ hex6: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,
1046
+ hex4: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
1047
+ hex8: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/
1048
+ };
1049
+ }();
1050
+
1051
+ // `isValidCSSUnit`
1052
+ // Take in a single string / number and check to see if it looks like a CSS unit
1053
+ // (see `matchers` above for definition).
1054
+ function isValidCSSUnit(color) {
1055
+ return !!matchers.CSS_UNIT.exec(color);
1056
+ }
1057
+
1058
+ // `stringInputToObject`
1059
+ // Permissive string parsing. Take in a number of formats, and output an object
1060
+ // based on detected format. Returns `{ r, g, b }` or `{ h, s, l }` or `{ h, s, v}`
1061
+ function stringInputToObject(color) {
1062
+ color = color.replace(trimLeft, "").replace(trimRight, "").toLowerCase();
1063
+ var named = false;
1064
+ if (names[color]) {
1065
+ color = names[color];
1066
+ named = true;
1067
+ } else if (color == "transparent") {
1068
+ return {
1069
+ r: 0,
1070
+ g: 0,
1071
+ b: 0,
1072
+ a: 0,
1073
+ format: "name"
1074
+ };
1075
+ }
1076
+
1077
+ // Try to match string input using regular expressions.
1078
+ // Keep most of the number bounding out of this function - don't worry about [0,1] or [0,100] or [0,360]
1079
+ // Just return an object and let the conversion functions handle that.
1080
+ // This way the result will be the same whether the tinycolor is initialized with string or object.
1081
+ var match;
1082
+ if (match = matchers.rgb.exec(color)) {
1083
+ return {
1084
+ r: match[1],
1085
+ g: match[2],
1086
+ b: match[3]
1087
+ };
1088
+ }
1089
+ if (match = matchers.rgba.exec(color)) {
1090
+ return {
1091
+ r: match[1],
1092
+ g: match[2],
1093
+ b: match[3],
1094
+ a: match[4]
1095
+ };
1096
+ }
1097
+ if (match = matchers.hsl.exec(color)) {
1098
+ return {
1099
+ h: match[1],
1100
+ s: match[2],
1101
+ l: match[3]
1102
+ };
1103
+ }
1104
+ if (match = matchers.hsla.exec(color)) {
1105
+ return {
1106
+ h: match[1],
1107
+ s: match[2],
1108
+ l: match[3],
1109
+ a: match[4]
1110
+ };
1111
+ }
1112
+ if (match = matchers.hsv.exec(color)) {
1113
+ return {
1114
+ h: match[1],
1115
+ s: match[2],
1116
+ v: match[3]
1117
+ };
1118
+ }
1119
+ if (match = matchers.hsva.exec(color)) {
1120
+ return {
1121
+ h: match[1],
1122
+ s: match[2],
1123
+ v: match[3],
1124
+ a: match[4]
1125
+ };
1126
+ }
1127
+ if (match = matchers.hex8.exec(color)) {
1128
+ return {
1129
+ r: parseIntFromHex(match[1]),
1130
+ g: parseIntFromHex(match[2]),
1131
+ b: parseIntFromHex(match[3]),
1132
+ a: convertHexToDecimal(match[4]),
1133
+ format: named ? "name" : "hex8"
1134
+ };
1135
+ }
1136
+ if (match = matchers.hex6.exec(color)) {
1137
+ return {
1138
+ r: parseIntFromHex(match[1]),
1139
+ g: parseIntFromHex(match[2]),
1140
+ b: parseIntFromHex(match[3]),
1141
+ format: named ? "name" : "hex"
1142
+ };
1143
+ }
1144
+ if (match = matchers.hex4.exec(color)) {
1145
+ return {
1146
+ r: parseIntFromHex(match[1] + "" + match[1]),
1147
+ g: parseIntFromHex(match[2] + "" + match[2]),
1148
+ b: parseIntFromHex(match[3] + "" + match[3]),
1149
+ a: convertHexToDecimal(match[4] + "" + match[4]),
1150
+ format: named ? "name" : "hex8"
1151
+ };
1152
+ }
1153
+ if (match = matchers.hex3.exec(color)) {
1154
+ return {
1155
+ r: parseIntFromHex(match[1] + "" + match[1]),
1156
+ g: parseIntFromHex(match[2] + "" + match[2]),
1157
+ b: parseIntFromHex(match[3] + "" + match[3]),
1158
+ format: named ? "name" : "hex"
1159
+ };
1160
+ }
1161
+ return false;
1162
+ }
1163
+ function validateWCAG2Parms(parms) {
1164
+ // return valid WCAG2 parms for isReadable.
1165
+ // If input parms are invalid, return {"level":"AA", "size":"small"}
1166
+ var level, size;
1167
+ parms = parms || {
1168
+ level: "AA",
1169
+ size: "small"
1170
+ };
1171
+ level = (parms.level || "AA").toUpperCase();
1172
+ size = (parms.size || "small").toLowerCase();
1173
+ if (level !== "AA" && level !== "AAA") {
1174
+ level = "AA";
1175
+ }
1176
+ if (size !== "small" && size !== "large") {
1177
+ size = "small";
1178
+ }
1179
+ return {
1180
+ level: level,
1181
+ size: size
1182
+ };
1183
+ }
1184
+
1185
+ var createSyncedStore = function createSyncedStore(_ref) {
1186
+ var initialValue = _ref.initialValue,
1187
+ storageKey = _ref.storageKey;
1188
+ var listeners = new Set();
1189
+ var getStoredValue = function getStoredValue() {
1190
+ return index.getFromLocalStorage(storageKey, initialValue);
1191
+ };
1192
+ var setStoredValue = function setStoredValue(value) {
1193
+ index.setToLocalStorage(storageKey, value);
1194
+ listeners.forEach(function (listener) {
1195
+ return listener();
1196
+ });
1197
+ };
1198
+ var store = {
1199
+ value: getStoredValue(),
1200
+ getSnapshot: function getSnapshot() {
1201
+ return store.value;
1202
+ },
1203
+ setValue: function setValue(newValue) {
1204
+ store.value = newValue;
1205
+ setStoredValue(newValue);
1206
+ },
1207
+ subscribe: function subscribe(callback) {
1208
+ listeners.add(callback);
1209
+ var storageEventHandler = function storageEventHandler(event) {
1210
+ if (event.key !== storageKey) return;
1211
+ store.value = getStoredValue();
1212
+ listeners.forEach(function (listener) {
1213
+ return listener();
1214
+ });
1215
+ };
1216
+ if (listeners.size === 1) {
1217
+ window.addEventListener("storage", storageEventHandler);
1218
+ }
1219
+ return function () {
1220
+ listeners["delete"](callback);
1221
+ if (listeners.size === 0) {
1222
+ window.removeEventListener("storage", storageEventHandler);
1223
+ }
1224
+ };
1225
+ }
1226
+ };
1227
+ return store;
1228
+ };
1229
+ var store = createSyncedStore({
1230
+ initialValue: [],
1231
+ storageKey: "recently-used-colors"
1232
+ });
1233
+ var useRecentlyUsedColors = function useRecentlyUsedColors() {
1234
+ return [React.useSyncExternalStore(store.subscribe, store.getSnapshot), store.setValue];
1235
+ };
1236
+
1237
+ exports.tinycolor = tinycolor;
1238
+ exports.useRecentlyUsedColors = useRecentlyUsedColors;
1239
+ //# sourceMappingURL=useRecentlyUsedColors-BcOkiB-v.js.map