@bigbinary/neetoui 8.3.30 → 8.3.32

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