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