@bigbinary/neetoui 7.0.2 → 7.0.4

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