@zendeskgarden/react-modals 9.11.3 → 9.12.1

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 (35) hide show
  1. package/dist/esm/elements/TooltipDialog/TooltipDialog.js +12 -3
  2. package/dist/esm/node_modules/@babel/runtime/helpers/esm/assertThisInitialized.js +12 -0
  3. package/dist/esm/node_modules/@babel/runtime/helpers/esm/construct.js +18 -0
  4. package/dist/esm/node_modules/@babel/runtime/helpers/esm/extends.js +17 -0
  5. package/dist/esm/node_modules/@babel/runtime/helpers/esm/getPrototypeOf.js +13 -0
  6. package/dist/esm/node_modules/@babel/runtime/helpers/esm/inheritsLoose.js +13 -0
  7. package/dist/esm/node_modules/@babel/runtime/helpers/esm/isNativeFunction.js +15 -0
  8. package/dist/esm/node_modules/@babel/runtime/helpers/esm/isNativeReflectConstruct.js +16 -0
  9. package/dist/esm/node_modules/@babel/runtime/helpers/esm/setPrototypeOf.js +13 -0
  10. package/dist/esm/node_modules/@babel/runtime/helpers/esm/wrapNativeSuper.js +35 -0
  11. package/dist/esm/node_modules/polished/dist/polished.esm.js +694 -0
  12. package/dist/esm/styled/StyledBackdrop.js +1 -1
  13. package/dist/esm/styled/StyledBody.js +1 -1
  14. package/dist/esm/styled/StyledClose.js +1 -1
  15. package/dist/esm/styled/StyledDrawer.js +1 -1
  16. package/dist/esm/styled/StyledDrawerBody.js +1 -1
  17. package/dist/esm/styled/StyledDrawerClose.js +1 -1
  18. package/dist/esm/styled/StyledDrawerFooter.js +1 -1
  19. package/dist/esm/styled/StyledDrawerFooterItem.js +1 -1
  20. package/dist/esm/styled/StyledDrawerHeader.js +1 -1
  21. package/dist/esm/styled/StyledFooter.js +1 -1
  22. package/dist/esm/styled/StyledFooterItem.js +1 -1
  23. package/dist/esm/styled/StyledHeader.js +1 -1
  24. package/dist/esm/styled/StyledModal.js +1 -1
  25. package/dist/esm/styled/StyledTooltipDialog.js +1 -1
  26. package/dist/esm/styled/StyledTooltipDialogBackdrop.js +3 -2
  27. package/dist/esm/styled/StyledTooltipDialogBody.js +1 -1
  28. package/dist/esm/styled/StyledTooltipDialogClose.js +1 -1
  29. package/dist/esm/styled/StyledTooltipDialogFooter.js +1 -1
  30. package/dist/esm/styled/StyledTooltipDialogFooterItem.js +1 -1
  31. package/dist/esm/styled/StyledTooltipDialogTitle.js +1 -1
  32. package/dist/index.cjs.js +796 -26
  33. package/dist/typings/elements/TooltipDialog/TooltipDialog.d.ts +6 -0
  34. package/dist/typings/types/index.d.ts +4 -0
  35. package/package.json +4 -4
@@ -0,0 +1,694 @@
1
+ /**
2
+ * Copyright Zendesk, Inc.
3
+ *
4
+ * Use of this source code is governed under the Apache License, Version 2.0
5
+ * found at http://www.apache.org/licenses/LICENSE-2.0.
6
+ */
7
+ import _extends from '../../@babel/runtime/helpers/esm/extends.js';
8
+ import _assertThisInitialized from '../../@babel/runtime/helpers/esm/assertThisInitialized.js';
9
+ import _inheritsLoose from '../../@babel/runtime/helpers/esm/inheritsLoose.js';
10
+ import _wrapNativeSuper from '../../@babel/runtime/helpers/esm/wrapNativeSuper.js';
11
+
12
+ var ERRORS = {
13
+ "1": "Passed invalid arguments to hsl, please pass multiple numbers e.g. hsl(360, 0.75, 0.4) or an object e.g. rgb({ hue: 255, saturation: 0.4, lightness: 0.75 }).\n\n",
14
+ "2": "Passed invalid arguments to hsla, please pass multiple numbers e.g. hsla(360, 0.75, 0.4, 0.7) or an object e.g. rgb({ hue: 255, saturation: 0.4, lightness: 0.75, alpha: 0.7 }).\n\n",
15
+ "3": "Passed an incorrect argument to a color function, please pass a string representation of a color.\n\n",
16
+ "4": "Couldn't generate valid rgb string from %s, it returned %s.\n\n",
17
+ "5": "Couldn't parse the color string. Please provide the color as a string in hex, rgb, rgba, hsl or hsla notation.\n\n",
18
+ "6": "Passed invalid arguments to rgb, please pass multiple numbers e.g. rgb(255, 205, 100) or an object e.g. rgb({ red: 255, green: 205, blue: 100 }).\n\n",
19
+ "7": "Passed invalid arguments to rgba, please pass multiple numbers e.g. rgb(255, 205, 100, 0.75) or an object e.g. rgb({ red: 255, green: 205, blue: 100, alpha: 0.75 }).\n\n",
20
+ "8": "Passed invalid argument to toColorString, please pass a RgbColor, RgbaColor, HslColor or HslaColor object.\n\n",
21
+ "9": "Please provide a number of steps to the modularScale helper.\n\n",
22
+ "10": "Please pass a number or one of the predefined scales to the modularScale helper as the ratio.\n\n",
23
+ "11": "Invalid value passed as base to modularScale, expected number or em string but got \"%s\"\n\n",
24
+ "12": "Expected a string ending in \"px\" or a number passed as the first argument to %s(), got \"%s\" instead.\n\n",
25
+ "13": "Expected a string ending in \"px\" or a number passed as the second argument to %s(), got \"%s\" instead.\n\n",
26
+ "14": "Passed invalid pixel value (\"%s\") to %s(), please pass a value like \"12px\" or 12.\n\n",
27
+ "15": "Passed invalid base value (\"%s\") to %s(), please pass a value like \"12px\" or 12.\n\n",
28
+ "16": "You must provide a template to this method.\n\n",
29
+ "17": "You passed an unsupported selector state to this method.\n\n",
30
+ "18": "minScreen and maxScreen must be provided as stringified numbers with the same units.\n\n",
31
+ "19": "fromSize and toSize must be provided as stringified numbers with the same units.\n\n",
32
+ "20": "expects either an array of objects or a single object with the properties prop, fromSize, and toSize.\n\n",
33
+ "21": "expects the objects in the first argument array to have the properties `prop`, `fromSize`, and `toSize`.\n\n",
34
+ "22": "expects the first argument object to have the properties `prop`, `fromSize`, and `toSize`.\n\n",
35
+ "23": "fontFace expects a name of a font-family.\n\n",
36
+ "24": "fontFace expects either the path to the font file(s) or a name of a local copy.\n\n",
37
+ "25": "fontFace expects localFonts to be an array.\n\n",
38
+ "26": "fontFace expects fileFormats to be an array.\n\n",
39
+ "27": "radialGradient requries at least 2 color-stops to properly render.\n\n",
40
+ "28": "Please supply a filename to retinaImage() as the first argument.\n\n",
41
+ "29": "Passed invalid argument to triangle, please pass correct pointingDirection e.g. 'right'.\n\n",
42
+ "30": "Passed an invalid value to `height` or `width`. Please provide a pixel based unit.\n\n",
43
+ "31": "The animation shorthand only takes 8 arguments. See the specification for more information: http://mdn.io/animation\n\n",
44
+ "32": "To pass multiple animations please supply them in arrays, e.g. animation(['rotate', '2s'], ['move', '1s'])\nTo pass a single animation please supply them in simple values, e.g. animation('rotate', '2s')\n\n",
45
+ "33": "The animation shorthand arrays can only have 8 elements. See the specification for more information: http://mdn.io/animation\n\n",
46
+ "34": "borderRadius expects a radius value as a string or number as the second argument.\n\n",
47
+ "35": "borderRadius expects one of \"top\", \"bottom\", \"left\" or \"right\" as the first argument.\n\n",
48
+ "36": "Property must be a string value.\n\n",
49
+ "37": "Syntax Error at %s.\n\n",
50
+ "38": "Formula contains a function that needs parentheses at %s.\n\n",
51
+ "39": "Formula is missing closing parenthesis at %s.\n\n",
52
+ "40": "Formula has too many closing parentheses at %s.\n\n",
53
+ "41": "All values in a formula must have the same unit or be unitless.\n\n",
54
+ "42": "Please provide a number of steps to the modularScale helper.\n\n",
55
+ "43": "Please pass a number or one of the predefined scales to the modularScale helper as the ratio.\n\n",
56
+ "44": "Invalid value passed as base to modularScale, expected number or em/rem string but got %s.\n\n",
57
+ "45": "Passed invalid argument to hslToColorString, please pass a HslColor or HslaColor object.\n\n",
58
+ "46": "Passed invalid argument to rgbToColorString, please pass a RgbColor or RgbaColor object.\n\n",
59
+ "47": "minScreen and maxScreen must be provided as stringified numbers with the same units.\n\n",
60
+ "48": "fromSize and toSize must be provided as stringified numbers with the same units.\n\n",
61
+ "49": "Expects either an array of objects or a single object with the properties prop, fromSize, and toSize.\n\n",
62
+ "50": "Expects the objects in the first argument array to have the properties prop, fromSize, and toSize.\n\n",
63
+ "51": "Expects the first argument object to have the properties prop, fromSize, and toSize.\n\n",
64
+ "52": "fontFace expects either the path to the font file(s) or a name of a local copy.\n\n",
65
+ "53": "fontFace expects localFonts to be an array.\n\n",
66
+ "54": "fontFace expects fileFormats to be an array.\n\n",
67
+ "55": "fontFace expects a name of a font-family.\n\n",
68
+ "56": "linearGradient requries at least 2 color-stops to properly render.\n\n",
69
+ "57": "radialGradient requries at least 2 color-stops to properly render.\n\n",
70
+ "58": "Please supply a filename to retinaImage() as the first argument.\n\n",
71
+ "59": "Passed invalid argument to triangle, please pass correct pointingDirection e.g. 'right'.\n\n",
72
+ "60": "Passed an invalid value to `height` or `width`. Please provide a pixel based unit.\n\n",
73
+ "61": "Property must be a string value.\n\n",
74
+ "62": "borderRadius expects a radius value as a string or number as the second argument.\n\n",
75
+ "63": "borderRadius expects one of \"top\", \"bottom\", \"left\" or \"right\" as the first argument.\n\n",
76
+ "64": "The animation shorthand only takes 8 arguments. See the specification for more information: http://mdn.io/animation.\n\n",
77
+ "65": "To pass multiple animations please supply them in arrays, e.g. animation(['rotate', '2s'], ['move', '1s'])\\nTo pass a single animation please supply them in simple values, e.g. animation('rotate', '2s').\n\n",
78
+ "66": "The animation shorthand arrays can only have 8 elements. See the specification for more information: http://mdn.io/animation.\n\n",
79
+ "67": "You must provide a template to this method.\n\n",
80
+ "68": "You passed an unsupported selector state to this method.\n\n",
81
+ "69": "Expected a string ending in \"px\" or a number passed as the first argument to %s(), got %s instead.\n\n",
82
+ "70": "Expected a string ending in \"px\" or a number passed as the second argument to %s(), got %s instead.\n\n",
83
+ "71": "Passed invalid pixel value %s to %s(), please pass a value like \"12px\" or 12.\n\n",
84
+ "72": "Passed invalid base value %s to %s(), please pass a value like \"12px\" or 12.\n\n",
85
+ "73": "Please provide a valid CSS variable.\n\n",
86
+ "74": "CSS variable not found and no default was provided.\n\n",
87
+ "75": "important requires a valid style object, got a %s instead.\n\n",
88
+ "76": "fromSize and toSize must be provided as stringified numbers with the same units as minScreen and maxScreen.\n\n",
89
+ "77": "remToPx expects a value in \"rem\" but you provided it in \"%s\".\n\n",
90
+ "78": "base must be set in \"px\" or \"%\" but you set it in \"%s\".\n"
91
+ };
92
+ function format() {
93
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
94
+ args[_key] = arguments[_key];
95
+ }
96
+ var a = args[0];
97
+ var b = [];
98
+ var c;
99
+ for (c = 1; c < args.length; c += 1) {
100
+ b.push(args[c]);
101
+ }
102
+ b.forEach(function (d) {
103
+ a = a.replace(/%[a-z]/, d);
104
+ });
105
+ return a;
106
+ }
107
+ var PolishedError = function (_Error) {
108
+ _inheritsLoose(PolishedError, _Error);
109
+ function PolishedError(code) {
110
+ var _this;
111
+ if (process.env.NODE_ENV === 'production') {
112
+ _this = _Error.call(this, "An error occurred. See https://github.com/styled-components/polished/blob/main/src/internalHelpers/errors.md#" + code + " for more information.") || this;
113
+ } else {
114
+ for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
115
+ args[_key2 - 1] = arguments[_key2];
116
+ }
117
+ _this = _Error.call(this, format.apply(void 0, [ERRORS[code]].concat(args))) || this;
118
+ }
119
+ return _assertThisInitialized(_this);
120
+ }
121
+ return PolishedError;
122
+ }(_wrapNativeSuper(Error));
123
+ function hideVisually() {
124
+ return {
125
+ border: '0',
126
+ clip: 'rect(0 0 0 0)',
127
+ height: '1px',
128
+ margin: '-1px',
129
+ overflow: 'hidden',
130
+ padding: '0',
131
+ position: 'absolute',
132
+ whiteSpace: 'nowrap',
133
+ width: '1px'
134
+ };
135
+ }
136
+ function colorToInt(color) {
137
+ return Math.round(color * 255);
138
+ }
139
+ function convertToInt(red, green, blue) {
140
+ return colorToInt(red) + "," + colorToInt(green) + "," + colorToInt(blue);
141
+ }
142
+ function hslToRgb(hue, saturation, lightness, convert) {
143
+ if (convert === void 0) {
144
+ convert = convertToInt;
145
+ }
146
+ if (saturation === 0) {
147
+ return convert(lightness, lightness, lightness);
148
+ }
149
+ var huePrime = (hue % 360 + 360) % 360 / 60;
150
+ var chroma = (1 - Math.abs(2 * lightness - 1)) * saturation;
151
+ var secondComponent = chroma * (1 - Math.abs(huePrime % 2 - 1));
152
+ var red = 0;
153
+ var green = 0;
154
+ var blue = 0;
155
+ if (huePrime >= 0 && huePrime < 1) {
156
+ red = chroma;
157
+ green = secondComponent;
158
+ } else if (huePrime >= 1 && huePrime < 2) {
159
+ red = secondComponent;
160
+ green = chroma;
161
+ } else if (huePrime >= 2 && huePrime < 3) {
162
+ green = chroma;
163
+ blue = secondComponent;
164
+ } else if (huePrime >= 3 && huePrime < 4) {
165
+ green = secondComponent;
166
+ blue = chroma;
167
+ } else if (huePrime >= 4 && huePrime < 5) {
168
+ red = secondComponent;
169
+ blue = chroma;
170
+ } else if (huePrime >= 5 && huePrime < 6) {
171
+ red = chroma;
172
+ blue = secondComponent;
173
+ }
174
+ var lightnessModification = lightness - chroma / 2;
175
+ var finalRed = red + lightnessModification;
176
+ var finalGreen = green + lightnessModification;
177
+ var finalBlue = blue + lightnessModification;
178
+ return convert(finalRed, finalGreen, finalBlue);
179
+ }
180
+ var namedColorMap = {
181
+ aliceblue: 'f0f8ff',
182
+ antiquewhite: 'faebd7',
183
+ aqua: '00ffff',
184
+ aquamarine: '7fffd4',
185
+ azure: 'f0ffff',
186
+ beige: 'f5f5dc',
187
+ bisque: 'ffe4c4',
188
+ black: '000',
189
+ blanchedalmond: 'ffebcd',
190
+ blue: '0000ff',
191
+ blueviolet: '8a2be2',
192
+ brown: 'a52a2a',
193
+ burlywood: 'deb887',
194
+ cadetblue: '5f9ea0',
195
+ chartreuse: '7fff00',
196
+ chocolate: 'd2691e',
197
+ coral: 'ff7f50',
198
+ cornflowerblue: '6495ed',
199
+ cornsilk: 'fff8dc',
200
+ crimson: 'dc143c',
201
+ cyan: '00ffff',
202
+ darkblue: '00008b',
203
+ darkcyan: '008b8b',
204
+ darkgoldenrod: 'b8860b',
205
+ darkgray: 'a9a9a9',
206
+ darkgreen: '006400',
207
+ darkgrey: 'a9a9a9',
208
+ darkkhaki: 'bdb76b',
209
+ darkmagenta: '8b008b',
210
+ darkolivegreen: '556b2f',
211
+ darkorange: 'ff8c00',
212
+ darkorchid: '9932cc',
213
+ darkred: '8b0000',
214
+ darksalmon: 'e9967a',
215
+ darkseagreen: '8fbc8f',
216
+ darkslateblue: '483d8b',
217
+ darkslategray: '2f4f4f',
218
+ darkslategrey: '2f4f4f',
219
+ darkturquoise: '00ced1',
220
+ darkviolet: '9400d3',
221
+ deeppink: 'ff1493',
222
+ deepskyblue: '00bfff',
223
+ dimgray: '696969',
224
+ dimgrey: '696969',
225
+ dodgerblue: '1e90ff',
226
+ firebrick: 'b22222',
227
+ floralwhite: 'fffaf0',
228
+ forestgreen: '228b22',
229
+ fuchsia: 'ff00ff',
230
+ gainsboro: 'dcdcdc',
231
+ ghostwhite: 'f8f8ff',
232
+ gold: 'ffd700',
233
+ goldenrod: 'daa520',
234
+ gray: '808080',
235
+ green: '008000',
236
+ greenyellow: 'adff2f',
237
+ grey: '808080',
238
+ honeydew: 'f0fff0',
239
+ hotpink: 'ff69b4',
240
+ indianred: 'cd5c5c',
241
+ indigo: '4b0082',
242
+ ivory: 'fffff0',
243
+ khaki: 'f0e68c',
244
+ lavender: 'e6e6fa',
245
+ lavenderblush: 'fff0f5',
246
+ lawngreen: '7cfc00',
247
+ lemonchiffon: 'fffacd',
248
+ lightblue: 'add8e6',
249
+ lightcoral: 'f08080',
250
+ lightcyan: 'e0ffff',
251
+ lightgoldenrodyellow: 'fafad2',
252
+ lightgray: 'd3d3d3',
253
+ lightgreen: '90ee90',
254
+ lightgrey: 'd3d3d3',
255
+ lightpink: 'ffb6c1',
256
+ lightsalmon: 'ffa07a',
257
+ lightseagreen: '20b2aa',
258
+ lightskyblue: '87cefa',
259
+ lightslategray: '789',
260
+ lightslategrey: '789',
261
+ lightsteelblue: 'b0c4de',
262
+ lightyellow: 'ffffe0',
263
+ lime: '0f0',
264
+ limegreen: '32cd32',
265
+ linen: 'faf0e6',
266
+ magenta: 'f0f',
267
+ maroon: '800000',
268
+ mediumaquamarine: '66cdaa',
269
+ mediumblue: '0000cd',
270
+ mediumorchid: 'ba55d3',
271
+ mediumpurple: '9370db',
272
+ mediumseagreen: '3cb371',
273
+ mediumslateblue: '7b68ee',
274
+ mediumspringgreen: '00fa9a',
275
+ mediumturquoise: '48d1cc',
276
+ mediumvioletred: 'c71585',
277
+ midnightblue: '191970',
278
+ mintcream: 'f5fffa',
279
+ mistyrose: 'ffe4e1',
280
+ moccasin: 'ffe4b5',
281
+ navajowhite: 'ffdead',
282
+ navy: '000080',
283
+ oldlace: 'fdf5e6',
284
+ olive: '808000',
285
+ olivedrab: '6b8e23',
286
+ orange: 'ffa500',
287
+ orangered: 'ff4500',
288
+ orchid: 'da70d6',
289
+ palegoldenrod: 'eee8aa',
290
+ palegreen: '98fb98',
291
+ paleturquoise: 'afeeee',
292
+ palevioletred: 'db7093',
293
+ papayawhip: 'ffefd5',
294
+ peachpuff: 'ffdab9',
295
+ peru: 'cd853f',
296
+ pink: 'ffc0cb',
297
+ plum: 'dda0dd',
298
+ powderblue: 'b0e0e6',
299
+ purple: '800080',
300
+ rebeccapurple: '639',
301
+ red: 'f00',
302
+ rosybrown: 'bc8f8f',
303
+ royalblue: '4169e1',
304
+ saddlebrown: '8b4513',
305
+ salmon: 'fa8072',
306
+ sandybrown: 'f4a460',
307
+ seagreen: '2e8b57',
308
+ seashell: 'fff5ee',
309
+ sienna: 'a0522d',
310
+ silver: 'c0c0c0',
311
+ skyblue: '87ceeb',
312
+ slateblue: '6a5acd',
313
+ slategray: '708090',
314
+ slategrey: '708090',
315
+ snow: 'fffafa',
316
+ springgreen: '00ff7f',
317
+ steelblue: '4682b4',
318
+ tan: 'd2b48c',
319
+ teal: '008080',
320
+ thistle: 'd8bfd8',
321
+ tomato: 'ff6347',
322
+ turquoise: '40e0d0',
323
+ violet: 'ee82ee',
324
+ wheat: 'f5deb3',
325
+ white: 'fff',
326
+ whitesmoke: 'f5f5f5',
327
+ yellow: 'ff0',
328
+ yellowgreen: '9acd32'
329
+ };
330
+ function nameToHex(color) {
331
+ if (typeof color !== 'string') return color;
332
+ var normalizedColorName = color.toLowerCase();
333
+ return namedColorMap[normalizedColorName] ? "#" + namedColorMap[normalizedColorName] : color;
334
+ }
335
+ var hexRegex = /^#[a-fA-F0-9]{6}$/;
336
+ var hexRgbaRegex = /^#[a-fA-F0-9]{8}$/;
337
+ var reducedHexRegex = /^#[a-fA-F0-9]{3}$/;
338
+ var reducedRgbaHexRegex = /^#[a-fA-F0-9]{4}$/;
339
+ var rgbRegex = /^rgb\(\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*\)$/i;
340
+ var rgbaRegex = /^rgb(?:a)?\(\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,|\/)\s*([-+]?\d*[.]?\d+[%]?)\s*\)$/i;
341
+ var hslRegex = /^hsl\(\s*(\d{0,3}[.]?[0-9]+(?:deg)?)\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*\)$/i;
342
+ var hslaRegex = /^hsl(?:a)?\(\s*(\d{0,3}[.]?[0-9]+(?:deg)?)\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,|\/)\s*([-+]?\d*[.]?\d+[%]?)\s*\)$/i;
343
+ function parseToRgb(color) {
344
+ if (typeof color !== 'string') {
345
+ throw new PolishedError(3);
346
+ }
347
+ var normalizedColor = nameToHex(color);
348
+ if (normalizedColor.match(hexRegex)) {
349
+ return {
350
+ red: parseInt("" + normalizedColor[1] + normalizedColor[2], 16),
351
+ green: parseInt("" + normalizedColor[3] + normalizedColor[4], 16),
352
+ blue: parseInt("" + normalizedColor[5] + normalizedColor[6], 16)
353
+ };
354
+ }
355
+ if (normalizedColor.match(hexRgbaRegex)) {
356
+ var alpha = parseFloat((parseInt("" + normalizedColor[7] + normalizedColor[8], 16) / 255).toFixed(2));
357
+ return {
358
+ red: parseInt("" + normalizedColor[1] + normalizedColor[2], 16),
359
+ green: parseInt("" + normalizedColor[3] + normalizedColor[4], 16),
360
+ blue: parseInt("" + normalizedColor[5] + normalizedColor[6], 16),
361
+ alpha: alpha
362
+ };
363
+ }
364
+ if (normalizedColor.match(reducedHexRegex)) {
365
+ return {
366
+ red: parseInt("" + normalizedColor[1] + normalizedColor[1], 16),
367
+ green: parseInt("" + normalizedColor[2] + normalizedColor[2], 16),
368
+ blue: parseInt("" + normalizedColor[3] + normalizedColor[3], 16)
369
+ };
370
+ }
371
+ if (normalizedColor.match(reducedRgbaHexRegex)) {
372
+ var _alpha = parseFloat((parseInt("" + normalizedColor[4] + normalizedColor[4], 16) / 255).toFixed(2));
373
+ return {
374
+ red: parseInt("" + normalizedColor[1] + normalizedColor[1], 16),
375
+ green: parseInt("" + normalizedColor[2] + normalizedColor[2], 16),
376
+ blue: parseInt("" + normalizedColor[3] + normalizedColor[3], 16),
377
+ alpha: _alpha
378
+ };
379
+ }
380
+ var rgbMatched = rgbRegex.exec(normalizedColor);
381
+ if (rgbMatched) {
382
+ return {
383
+ red: parseInt("" + rgbMatched[1], 10),
384
+ green: parseInt("" + rgbMatched[2], 10),
385
+ blue: parseInt("" + rgbMatched[3], 10)
386
+ };
387
+ }
388
+ var rgbaMatched = rgbaRegex.exec(normalizedColor.substring(0, 50));
389
+ if (rgbaMatched) {
390
+ return {
391
+ red: parseInt("" + rgbaMatched[1], 10),
392
+ green: parseInt("" + rgbaMatched[2], 10),
393
+ blue: parseInt("" + rgbaMatched[3], 10),
394
+ alpha: parseFloat("" + rgbaMatched[4]) > 1 ? parseFloat("" + rgbaMatched[4]) / 100 : parseFloat("" + rgbaMatched[4])
395
+ };
396
+ }
397
+ var hslMatched = hslRegex.exec(normalizedColor);
398
+ if (hslMatched) {
399
+ var hue = parseInt("" + hslMatched[1], 10);
400
+ var saturation = parseInt("" + hslMatched[2], 10) / 100;
401
+ var lightness = parseInt("" + hslMatched[3], 10) / 100;
402
+ var rgbColorString = "rgb(" + hslToRgb(hue, saturation, lightness) + ")";
403
+ var hslRgbMatched = rgbRegex.exec(rgbColorString);
404
+ if (!hslRgbMatched) {
405
+ throw new PolishedError(4, normalizedColor, rgbColorString);
406
+ }
407
+ return {
408
+ red: parseInt("" + hslRgbMatched[1], 10),
409
+ green: parseInt("" + hslRgbMatched[2], 10),
410
+ blue: parseInt("" + hslRgbMatched[3], 10)
411
+ };
412
+ }
413
+ var hslaMatched = hslaRegex.exec(normalizedColor.substring(0, 50));
414
+ if (hslaMatched) {
415
+ var _hue = parseInt("" + hslaMatched[1], 10);
416
+ var _saturation = parseInt("" + hslaMatched[2], 10) / 100;
417
+ var _lightness = parseInt("" + hslaMatched[3], 10) / 100;
418
+ var _rgbColorString = "rgb(" + hslToRgb(_hue, _saturation, _lightness) + ")";
419
+ var _hslRgbMatched = rgbRegex.exec(_rgbColorString);
420
+ if (!_hslRgbMatched) {
421
+ throw new PolishedError(4, normalizedColor, _rgbColorString);
422
+ }
423
+ return {
424
+ red: parseInt("" + _hslRgbMatched[1], 10),
425
+ green: parseInt("" + _hslRgbMatched[2], 10),
426
+ blue: parseInt("" + _hslRgbMatched[3], 10),
427
+ alpha: parseFloat("" + hslaMatched[4]) > 1 ? parseFloat("" + hslaMatched[4]) / 100 : parseFloat("" + hslaMatched[4])
428
+ };
429
+ }
430
+ throw new PolishedError(5);
431
+ }
432
+ function rgbToHsl(color) {
433
+ var red = color.red / 255;
434
+ var green = color.green / 255;
435
+ var blue = color.blue / 255;
436
+ var max = Math.max(red, green, blue);
437
+ var min = Math.min(red, green, blue);
438
+ var lightness = (max + min) / 2;
439
+ if (max === min) {
440
+ if (color.alpha !== undefined) {
441
+ return {
442
+ hue: 0,
443
+ saturation: 0,
444
+ lightness: lightness,
445
+ alpha: color.alpha
446
+ };
447
+ } else {
448
+ return {
449
+ hue: 0,
450
+ saturation: 0,
451
+ lightness: lightness
452
+ };
453
+ }
454
+ }
455
+ var hue;
456
+ var delta = max - min;
457
+ var saturation = lightness > 0.5 ? delta / (2 - max - min) : delta / (max + min);
458
+ switch (max) {
459
+ case red:
460
+ hue = (green - blue) / delta + (green < blue ? 6 : 0);
461
+ break;
462
+ case green:
463
+ hue = (blue - red) / delta + 2;
464
+ break;
465
+ default:
466
+ hue = (red - green) / delta + 4;
467
+ break;
468
+ }
469
+ hue *= 60;
470
+ if (color.alpha !== undefined) {
471
+ return {
472
+ hue: hue,
473
+ saturation: saturation,
474
+ lightness: lightness,
475
+ alpha: color.alpha
476
+ };
477
+ }
478
+ return {
479
+ hue: hue,
480
+ saturation: saturation,
481
+ lightness: lightness
482
+ };
483
+ }
484
+ function parseToHsl(color) {
485
+ return rgbToHsl(parseToRgb(color));
486
+ }
487
+ var reduceHexValue = function reduceHexValue(value) {
488
+ if (value.length === 7 && value[1] === value[2] && value[3] === value[4] && value[5] === value[6]) {
489
+ return "#" + value[1] + value[3] + value[5];
490
+ }
491
+ return value;
492
+ };
493
+ var reduceHexValue$1 = reduceHexValue;
494
+ function numberToHex(value) {
495
+ var hex = value.toString(16);
496
+ return hex.length === 1 ? "0" + hex : hex;
497
+ }
498
+ function colorToHex(color) {
499
+ return numberToHex(Math.round(color * 255));
500
+ }
501
+ function convertToHex(red, green, blue) {
502
+ return reduceHexValue$1("#" + colorToHex(red) + colorToHex(green) + colorToHex(blue));
503
+ }
504
+ function hslToHex(hue, saturation, lightness) {
505
+ return hslToRgb(hue, saturation, lightness, convertToHex);
506
+ }
507
+ function hsl(value, saturation, lightness) {
508
+ if (typeof value === 'number' && typeof saturation === 'number' && typeof lightness === 'number') {
509
+ return hslToHex(value, saturation, lightness);
510
+ } else if (typeof value === 'object' && saturation === undefined && lightness === undefined) {
511
+ return hslToHex(value.hue, value.saturation, value.lightness);
512
+ }
513
+ throw new PolishedError(1);
514
+ }
515
+ function hsla(value, saturation, lightness, alpha) {
516
+ if (typeof value === 'number' && typeof saturation === 'number' && typeof lightness === 'number' && typeof alpha === 'number') {
517
+ return "rgba(" + hslToRgb(value, saturation, lightness) + "," + alpha + ")";
518
+ } else if (typeof value === 'object' && saturation === undefined && lightness === undefined && alpha === undefined) {
519
+ return value.alpha >= 1 ? hslToHex(value.hue, value.saturation, value.lightness) : "rgba(" + hslToRgb(value.hue, value.saturation, value.lightness) + "," + value.alpha + ")";
520
+ }
521
+ throw new PolishedError(2);
522
+ }
523
+ function rgb(value, green, blue) {
524
+ if (typeof value === 'number' && typeof green === 'number' && typeof blue === 'number') {
525
+ return reduceHexValue$1("#" + numberToHex(value) + numberToHex(green) + numberToHex(blue));
526
+ } else if (typeof value === 'object' && green === undefined && blue === undefined) {
527
+ return reduceHexValue$1("#" + numberToHex(value.red) + numberToHex(value.green) + numberToHex(value.blue));
528
+ }
529
+ throw new PolishedError(6);
530
+ }
531
+ function rgba(firstValue, secondValue, thirdValue, fourthValue) {
532
+ if (typeof firstValue === 'string' && typeof secondValue === 'number') {
533
+ var rgbValue = parseToRgb(firstValue);
534
+ return "rgba(" + rgbValue.red + "," + rgbValue.green + "," + rgbValue.blue + "," + secondValue + ")";
535
+ } else if (typeof firstValue === 'number' && typeof secondValue === 'number' && typeof thirdValue === 'number' && typeof fourthValue === 'number') {
536
+ return "rgba(" + firstValue + "," + secondValue + "," + thirdValue + "," + fourthValue + ")";
537
+ } else if (typeof firstValue === 'object' && secondValue === undefined && thirdValue === undefined && fourthValue === undefined) {
538
+ return firstValue.alpha >= 1 ? rgb(firstValue.red, firstValue.green, firstValue.blue) : "rgba(" + firstValue.red + "," + firstValue.green + "," + firstValue.blue + "," + firstValue.alpha + ")";
539
+ }
540
+ throw new PolishedError(7);
541
+ }
542
+ var isRgb = function isRgb(color) {
543
+ return typeof color.red === 'number' && typeof color.green === 'number' && typeof color.blue === 'number' && (typeof color.alpha !== 'number' || typeof color.alpha === 'undefined');
544
+ };
545
+ var isRgba = function isRgba(color) {
546
+ return typeof color.red === 'number' && typeof color.green === 'number' && typeof color.blue === 'number' && typeof color.alpha === 'number';
547
+ };
548
+ var isHsl = function isHsl(color) {
549
+ return typeof color.hue === 'number' && typeof color.saturation === 'number' && typeof color.lightness === 'number' && (typeof color.alpha !== 'number' || typeof color.alpha === 'undefined');
550
+ };
551
+ var isHsla = function isHsla(color) {
552
+ return typeof color.hue === 'number' && typeof color.saturation === 'number' && typeof color.lightness === 'number' && typeof color.alpha === 'number';
553
+ };
554
+ function toColorString(color) {
555
+ if (typeof color !== 'object') throw new PolishedError(8);
556
+ if (isRgba(color)) return rgba(color);
557
+ if (isRgb(color)) return rgb(color);
558
+ if (isHsla(color)) return hsla(color);
559
+ if (isHsl(color)) return hsl(color);
560
+ throw new PolishedError(8);
561
+ }
562
+ function curried(f, length, acc) {
563
+ return function fn() {
564
+ var combined = acc.concat(Array.prototype.slice.call(arguments));
565
+ return combined.length >= length ? f.apply(this, combined) : curried(f, length, combined);
566
+ };
567
+ }
568
+ function curry(f) {
569
+ return curried(f, f.length, []);
570
+ }
571
+ function adjustHue(degree, color) {
572
+ if (color === 'transparent') return color;
573
+ var hslColor = parseToHsl(color);
574
+ return toColorString(_extends({}, hslColor, {
575
+ hue: hslColor.hue + parseFloat(degree)
576
+ }));
577
+ }
578
+ curry (adjustHue);
579
+ function guard(lowerBoundary, upperBoundary, value) {
580
+ return Math.max(lowerBoundary, Math.min(upperBoundary, value));
581
+ }
582
+ function darken(amount, color) {
583
+ if (color === 'transparent') return color;
584
+ var hslColor = parseToHsl(color);
585
+ return toColorString(_extends({}, hslColor, {
586
+ lightness: guard(0, 1, hslColor.lightness - parseFloat(amount))
587
+ }));
588
+ }
589
+ curry (darken);
590
+ function desaturate(amount, color) {
591
+ if (color === 'transparent') return color;
592
+ var hslColor = parseToHsl(color);
593
+ return toColorString(_extends({}, hslColor, {
594
+ saturation: guard(0, 1, hslColor.saturation - parseFloat(amount))
595
+ }));
596
+ }
597
+ curry (desaturate);
598
+ function lighten(amount, color) {
599
+ if (color === 'transparent') return color;
600
+ var hslColor = parseToHsl(color);
601
+ return toColorString(_extends({}, hslColor, {
602
+ lightness: guard(0, 1, hslColor.lightness + parseFloat(amount))
603
+ }));
604
+ }
605
+ curry (lighten);
606
+ function mix(weight, color, otherColor) {
607
+ if (color === 'transparent') return otherColor;
608
+ if (otherColor === 'transparent') return color;
609
+ if (weight === 0) return otherColor;
610
+ var parsedColor1 = parseToRgb(color);
611
+ var color1 = _extends({}, parsedColor1, {
612
+ alpha: typeof parsedColor1.alpha === 'number' ? parsedColor1.alpha : 1
613
+ });
614
+ var parsedColor2 = parseToRgb(otherColor);
615
+ var color2 = _extends({}, parsedColor2, {
616
+ alpha: typeof parsedColor2.alpha === 'number' ? parsedColor2.alpha : 1
617
+ });
618
+ var alphaDelta = color1.alpha - color2.alpha;
619
+ var x = parseFloat(weight) * 2 - 1;
620
+ var y = x * alphaDelta === -1 ? x : x + alphaDelta;
621
+ var z = 1 + x * alphaDelta;
622
+ var weight1 = (y / z + 1) / 2.0;
623
+ var weight2 = 1 - weight1;
624
+ var mixedColor = {
625
+ red: Math.floor(color1.red * weight1 + color2.red * weight2),
626
+ green: Math.floor(color1.green * weight1 + color2.green * weight2),
627
+ blue: Math.floor(color1.blue * weight1 + color2.blue * weight2),
628
+ alpha: color1.alpha * parseFloat(weight) + color2.alpha * (1 - parseFloat(weight))
629
+ };
630
+ return rgba(mixedColor);
631
+ }
632
+ var curriedMix = curry (mix);
633
+ var mix$1 = curriedMix;
634
+ function opacify(amount, color) {
635
+ if (color === 'transparent') return color;
636
+ var parsedColor = parseToRgb(color);
637
+ var alpha = typeof parsedColor.alpha === 'number' ? parsedColor.alpha : 1;
638
+ var colorWithAlpha = _extends({}, parsedColor, {
639
+ alpha: guard(0, 1, (alpha * 100 + parseFloat(amount) * 100) / 100)
640
+ });
641
+ return rgba(colorWithAlpha);
642
+ }
643
+ curry (opacify);
644
+ function saturate(amount, color) {
645
+ if (color === 'transparent') return color;
646
+ var hslColor = parseToHsl(color);
647
+ return toColorString(_extends({}, hslColor, {
648
+ saturation: guard(0, 1, hslColor.saturation + parseFloat(amount))
649
+ }));
650
+ }
651
+ curry (saturate);
652
+ function setHue(hue, color) {
653
+ if (color === 'transparent') return color;
654
+ return toColorString(_extends({}, parseToHsl(color), {
655
+ hue: parseFloat(hue)
656
+ }));
657
+ }
658
+ curry (setHue);
659
+ function setLightness(lightness, color) {
660
+ if (color === 'transparent') return color;
661
+ return toColorString(_extends({}, parseToHsl(color), {
662
+ lightness: parseFloat(lightness)
663
+ }));
664
+ }
665
+ curry (setLightness);
666
+ function setSaturation(saturation, color) {
667
+ if (color === 'transparent') return color;
668
+ return toColorString(_extends({}, parseToHsl(color), {
669
+ saturation: parseFloat(saturation)
670
+ }));
671
+ }
672
+ curry (setSaturation);
673
+ function shade(percentage, color) {
674
+ if (color === 'transparent') return color;
675
+ return mix$1(parseFloat(percentage), 'rgb(0, 0, 0)', color);
676
+ }
677
+ curry (shade);
678
+ function tint(percentage, color) {
679
+ if (color === 'transparent') return color;
680
+ return mix$1(parseFloat(percentage), 'rgb(255, 255, 255)', color);
681
+ }
682
+ curry (tint);
683
+ function transparentize(amount, color) {
684
+ if (color === 'transparent') return color;
685
+ var parsedColor = parseToRgb(color);
686
+ var alpha = typeof parsedColor.alpha === 'number' ? parsedColor.alpha : 1;
687
+ var colorWithAlpha = _extends({}, parsedColor, {
688
+ alpha: guard(0, 1, +(alpha * 100 - parseFloat(amount) * 100).toFixed(2) / 100)
689
+ });
690
+ return rgba(colorWithAlpha);
691
+ }
692
+ curry (transparentize);
693
+
694
+ export { hideVisually, hsl, hsla, mix$1 as mix, parseToHsl, parseToRgb, rgb, rgba, toColorString };