@bigbinary/neetoui 8.3.0-beta2 → 8.3.0

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