favesalon-embed 1.0.2 → 1.0.3
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.
- package/dist/custom-elements/index.d.ts +12 -0
- package/dist/favesalon-embed/_commonjsHelpers-9bc404fc.js +44 -0
- package/dist/favesalon-embed/{app-globals-15861a7f.js → app-globals-60769a2c.js} +1 -1
- package/dist/favesalon-embed/chat-box.entry.js +54 -0
- package/dist/favesalon-embed/chat-button.entry.js +3 -8
- package/dist/favesalon-embed/chat-form.entry.js +2 -2
- package/dist/favesalon-embed/chat-messages.entry.js +6 -4
- package/dist/favesalon-embed/chat-rooms.entry.js +17279 -0
- package/dist/favesalon-embed/favesalon-embed.esm.js +1 -1
- package/dist/favesalon-embed/{index-aa906326.js → index-04c09911.js} +1 -1
- package/dist/favesalon-embed/index-ac52896a.js +4803 -0
- package/dist/favesalon-embed/isObject-13b86c17.js +203 -0
- package/dist/favesalon-embed/relativeTime-15477f02.js +7 -0
- package/dist/favesalon-embed/salon-info.entry.js +1 -1
- package/dist/favesalon-embed/salon-latest-reviews.entry.js +2 -2
- package/dist/favesalon-embed/salon-latest-styles.entry.js +1 -1
- package/dist/favesalon-embed/salon-locations.entry.js +2 -2
- package/dist/favesalon-embed/salon-lookbook.entry.js +1 -1
- package/dist/favesalon-embed/salon-reviews.entry.js +1 -1
- package/dist/favesalon-embed/salon-schedules.entry.js +1 -1
- package/dist/favesalon-embed/salon-services.entry.js +1 -1
- package/dist/favesalon-embed/salon-stylists.entry.js +1 -1
- package/dist/favesalon-embed/services-55a87166.js +23655 -0
- package/dist/favesalon-embed/services-7c46a2fd.js +23854 -0
- package/dist/favesalon-embed/style-detail.entry.js +1 -1
- package/dist/favesalon-embed/user-avatar.entry.js +11 -3
- package/dist/favesalon-embed/{utils-7de9628a.js → utils-2c19db45.js} +3 -0
- package/dist/types/components/chat-box/index.d.ts +12 -0
- package/dist/types/components/chat-rooms/index.d.ts +12 -0
- package/dist/types/components/user-avatar/index.d.ts +2 -1
- package/dist/types/components.d.ts +45 -2
- package/dist/types/utils/utils.d.ts +1 -0
- package/package.json +1 -1
- package/dist/favesalon-embed/app-globals-270fe240.js +0 -712
- package/dist/favesalon-embed/app-globals-b8b0fc7a.js +0 -712
- package/dist/favesalon-embed/index-9ad82b12.js +0 -3371
- package/dist/favesalon-embed/index-b97af793.js +0 -3371
|
@@ -0,0 +1,4803 @@
|
|
|
1
|
+
import { c as createCommonjsModule, g as getDefaultExportFromCjs, b as getAugmentedNamespace } from './_commonjsHelpers-9bc404fc.js';
|
|
2
|
+
|
|
3
|
+
'use strict';
|
|
4
|
+
|
|
5
|
+
var colorName = {
|
|
6
|
+
"aliceblue": [240, 248, 255],
|
|
7
|
+
"antiquewhite": [250, 235, 215],
|
|
8
|
+
"aqua": [0, 255, 255],
|
|
9
|
+
"aquamarine": [127, 255, 212],
|
|
10
|
+
"azure": [240, 255, 255],
|
|
11
|
+
"beige": [245, 245, 220],
|
|
12
|
+
"bisque": [255, 228, 196],
|
|
13
|
+
"black": [0, 0, 0],
|
|
14
|
+
"blanchedalmond": [255, 235, 205],
|
|
15
|
+
"blue": [0, 0, 255],
|
|
16
|
+
"blueviolet": [138, 43, 226],
|
|
17
|
+
"brown": [165, 42, 42],
|
|
18
|
+
"burlywood": [222, 184, 135],
|
|
19
|
+
"cadetblue": [95, 158, 160],
|
|
20
|
+
"chartreuse": [127, 255, 0],
|
|
21
|
+
"chocolate": [210, 105, 30],
|
|
22
|
+
"coral": [255, 127, 80],
|
|
23
|
+
"cornflowerblue": [100, 149, 237],
|
|
24
|
+
"cornsilk": [255, 248, 220],
|
|
25
|
+
"crimson": [220, 20, 60],
|
|
26
|
+
"cyan": [0, 255, 255],
|
|
27
|
+
"darkblue": [0, 0, 139],
|
|
28
|
+
"darkcyan": [0, 139, 139],
|
|
29
|
+
"darkgoldenrod": [184, 134, 11],
|
|
30
|
+
"darkgray": [169, 169, 169],
|
|
31
|
+
"darkgreen": [0, 100, 0],
|
|
32
|
+
"darkgrey": [169, 169, 169],
|
|
33
|
+
"darkkhaki": [189, 183, 107],
|
|
34
|
+
"darkmagenta": [139, 0, 139],
|
|
35
|
+
"darkolivegreen": [85, 107, 47],
|
|
36
|
+
"darkorange": [255, 140, 0],
|
|
37
|
+
"darkorchid": [153, 50, 204],
|
|
38
|
+
"darkred": [139, 0, 0],
|
|
39
|
+
"darksalmon": [233, 150, 122],
|
|
40
|
+
"darkseagreen": [143, 188, 143],
|
|
41
|
+
"darkslateblue": [72, 61, 139],
|
|
42
|
+
"darkslategray": [47, 79, 79],
|
|
43
|
+
"darkslategrey": [47, 79, 79],
|
|
44
|
+
"darkturquoise": [0, 206, 209],
|
|
45
|
+
"darkviolet": [148, 0, 211],
|
|
46
|
+
"deeppink": [255, 20, 147],
|
|
47
|
+
"deepskyblue": [0, 191, 255],
|
|
48
|
+
"dimgray": [105, 105, 105],
|
|
49
|
+
"dimgrey": [105, 105, 105],
|
|
50
|
+
"dodgerblue": [30, 144, 255],
|
|
51
|
+
"firebrick": [178, 34, 34],
|
|
52
|
+
"floralwhite": [255, 250, 240],
|
|
53
|
+
"forestgreen": [34, 139, 34],
|
|
54
|
+
"fuchsia": [255, 0, 255],
|
|
55
|
+
"gainsboro": [220, 220, 220],
|
|
56
|
+
"ghostwhite": [248, 248, 255],
|
|
57
|
+
"gold": [255, 215, 0],
|
|
58
|
+
"goldenrod": [218, 165, 32],
|
|
59
|
+
"gray": [128, 128, 128],
|
|
60
|
+
"green": [0, 128, 0],
|
|
61
|
+
"greenyellow": [173, 255, 47],
|
|
62
|
+
"grey": [128, 128, 128],
|
|
63
|
+
"honeydew": [240, 255, 240],
|
|
64
|
+
"hotpink": [255, 105, 180],
|
|
65
|
+
"indianred": [205, 92, 92],
|
|
66
|
+
"indigo": [75, 0, 130],
|
|
67
|
+
"ivory": [255, 255, 240],
|
|
68
|
+
"khaki": [240, 230, 140],
|
|
69
|
+
"lavender": [230, 230, 250],
|
|
70
|
+
"lavenderblush": [255, 240, 245],
|
|
71
|
+
"lawngreen": [124, 252, 0],
|
|
72
|
+
"lemonchiffon": [255, 250, 205],
|
|
73
|
+
"lightblue": [173, 216, 230],
|
|
74
|
+
"lightcoral": [240, 128, 128],
|
|
75
|
+
"lightcyan": [224, 255, 255],
|
|
76
|
+
"lightgoldenrodyellow": [250, 250, 210],
|
|
77
|
+
"lightgray": [211, 211, 211],
|
|
78
|
+
"lightgreen": [144, 238, 144],
|
|
79
|
+
"lightgrey": [211, 211, 211],
|
|
80
|
+
"lightpink": [255, 182, 193],
|
|
81
|
+
"lightsalmon": [255, 160, 122],
|
|
82
|
+
"lightseagreen": [32, 178, 170],
|
|
83
|
+
"lightskyblue": [135, 206, 250],
|
|
84
|
+
"lightslategray": [119, 136, 153],
|
|
85
|
+
"lightslategrey": [119, 136, 153],
|
|
86
|
+
"lightsteelblue": [176, 196, 222],
|
|
87
|
+
"lightyellow": [255, 255, 224],
|
|
88
|
+
"lime": [0, 255, 0],
|
|
89
|
+
"limegreen": [50, 205, 50],
|
|
90
|
+
"linen": [250, 240, 230],
|
|
91
|
+
"magenta": [255, 0, 255],
|
|
92
|
+
"maroon": [128, 0, 0],
|
|
93
|
+
"mediumaquamarine": [102, 205, 170],
|
|
94
|
+
"mediumblue": [0, 0, 205],
|
|
95
|
+
"mediumorchid": [186, 85, 211],
|
|
96
|
+
"mediumpurple": [147, 112, 219],
|
|
97
|
+
"mediumseagreen": [60, 179, 113],
|
|
98
|
+
"mediumslateblue": [123, 104, 238],
|
|
99
|
+
"mediumspringgreen": [0, 250, 154],
|
|
100
|
+
"mediumturquoise": [72, 209, 204],
|
|
101
|
+
"mediumvioletred": [199, 21, 133],
|
|
102
|
+
"midnightblue": [25, 25, 112],
|
|
103
|
+
"mintcream": [245, 255, 250],
|
|
104
|
+
"mistyrose": [255, 228, 225],
|
|
105
|
+
"moccasin": [255, 228, 181],
|
|
106
|
+
"navajowhite": [255, 222, 173],
|
|
107
|
+
"navy": [0, 0, 128],
|
|
108
|
+
"oldlace": [253, 245, 230],
|
|
109
|
+
"olive": [128, 128, 0],
|
|
110
|
+
"olivedrab": [107, 142, 35],
|
|
111
|
+
"orange": [255, 165, 0],
|
|
112
|
+
"orangered": [255, 69, 0],
|
|
113
|
+
"orchid": [218, 112, 214],
|
|
114
|
+
"palegoldenrod": [238, 232, 170],
|
|
115
|
+
"palegreen": [152, 251, 152],
|
|
116
|
+
"paleturquoise": [175, 238, 238],
|
|
117
|
+
"palevioletred": [219, 112, 147],
|
|
118
|
+
"papayawhip": [255, 239, 213],
|
|
119
|
+
"peachpuff": [255, 218, 185],
|
|
120
|
+
"peru": [205, 133, 63],
|
|
121
|
+
"pink": [255, 192, 203],
|
|
122
|
+
"plum": [221, 160, 221],
|
|
123
|
+
"powderblue": [176, 224, 230],
|
|
124
|
+
"purple": [128, 0, 128],
|
|
125
|
+
"rebeccapurple": [102, 51, 153],
|
|
126
|
+
"red": [255, 0, 0],
|
|
127
|
+
"rosybrown": [188, 143, 143],
|
|
128
|
+
"royalblue": [65, 105, 225],
|
|
129
|
+
"saddlebrown": [139, 69, 19],
|
|
130
|
+
"salmon": [250, 128, 114],
|
|
131
|
+
"sandybrown": [244, 164, 96],
|
|
132
|
+
"seagreen": [46, 139, 87],
|
|
133
|
+
"seashell": [255, 245, 238],
|
|
134
|
+
"sienna": [160, 82, 45],
|
|
135
|
+
"silver": [192, 192, 192],
|
|
136
|
+
"skyblue": [135, 206, 235],
|
|
137
|
+
"slateblue": [106, 90, 205],
|
|
138
|
+
"slategray": [112, 128, 144],
|
|
139
|
+
"slategrey": [112, 128, 144],
|
|
140
|
+
"snow": [255, 250, 250],
|
|
141
|
+
"springgreen": [0, 255, 127],
|
|
142
|
+
"steelblue": [70, 130, 180],
|
|
143
|
+
"tan": [210, 180, 140],
|
|
144
|
+
"teal": [0, 128, 128],
|
|
145
|
+
"thistle": [216, 191, 216],
|
|
146
|
+
"tomato": [255, 99, 71],
|
|
147
|
+
"turquoise": [64, 224, 208],
|
|
148
|
+
"violet": [238, 130, 238],
|
|
149
|
+
"wheat": [245, 222, 179],
|
|
150
|
+
"white": [255, 255, 255],
|
|
151
|
+
"whitesmoke": [245, 245, 245],
|
|
152
|
+
"yellow": [255, 255, 0],
|
|
153
|
+
"yellowgreen": [154, 205, 50]
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
var isArrayish = function isArrayish(obj) {
|
|
157
|
+
if (!obj || typeof obj === 'string') {
|
|
158
|
+
return false;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
return obj instanceof Array || Array.isArray(obj) ||
|
|
162
|
+
(obj.length >= 0 && (obj.splice instanceof Function ||
|
|
163
|
+
(Object.getOwnPropertyDescriptor(obj, (obj.length - 1)) && obj.constructor.name !== 'String')));
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
var simpleSwizzle = createCommonjsModule(function (module) {
|
|
167
|
+
'use strict';
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
var concat = Array.prototype.concat;
|
|
172
|
+
var slice = Array.prototype.slice;
|
|
173
|
+
|
|
174
|
+
var swizzle = module.exports = function swizzle(args) {
|
|
175
|
+
var results = [];
|
|
176
|
+
|
|
177
|
+
for (var i = 0, len = args.length; i < len; i++) {
|
|
178
|
+
var arg = args[i];
|
|
179
|
+
|
|
180
|
+
if (isArrayish(arg)) {
|
|
181
|
+
// http://jsperf.com/javascript-array-concat-vs-push/98
|
|
182
|
+
results = concat.call(results, slice.call(arg));
|
|
183
|
+
} else {
|
|
184
|
+
results.push(arg);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
return results;
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
swizzle.wrap = function (fn) {
|
|
192
|
+
return function () {
|
|
193
|
+
return fn(swizzle(arguments));
|
|
194
|
+
};
|
|
195
|
+
};
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
var colorString = createCommonjsModule(function (module) {
|
|
199
|
+
/* MIT license */
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
var reverseNames = {};
|
|
204
|
+
|
|
205
|
+
// create a list of reverse color names
|
|
206
|
+
for (var name in colorName) {
|
|
207
|
+
if (colorName.hasOwnProperty(name)) {
|
|
208
|
+
reverseNames[colorName[name]] = name;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
var cs = module.exports = {
|
|
213
|
+
to: {},
|
|
214
|
+
get: {}
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
cs.get = function (string) {
|
|
218
|
+
var prefix = string.substring(0, 3).toLowerCase();
|
|
219
|
+
var val;
|
|
220
|
+
var model;
|
|
221
|
+
switch (prefix) {
|
|
222
|
+
case 'hsl':
|
|
223
|
+
val = cs.get.hsl(string);
|
|
224
|
+
model = 'hsl';
|
|
225
|
+
break;
|
|
226
|
+
case 'hwb':
|
|
227
|
+
val = cs.get.hwb(string);
|
|
228
|
+
model = 'hwb';
|
|
229
|
+
break;
|
|
230
|
+
default:
|
|
231
|
+
val = cs.get.rgb(string);
|
|
232
|
+
model = 'rgb';
|
|
233
|
+
break;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
if (!val) {
|
|
237
|
+
return null;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
return {model: model, value: val};
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
cs.get.rgb = function (string) {
|
|
244
|
+
if (!string) {
|
|
245
|
+
return null;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
var abbr = /^#([a-f0-9]{3,4})$/i;
|
|
249
|
+
var hex = /^#([a-f0-9]{6})([a-f0-9]{2})?$/i;
|
|
250
|
+
var rgba = /^rgba?\(\s*([+-]?\d+)\s*,\s*([+-]?\d+)\s*,\s*([+-]?\d+)\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)$/;
|
|
251
|
+
var per = /^rgba?\(\s*([+-]?[\d\.]+)\%\s*,\s*([+-]?[\d\.]+)\%\s*,\s*([+-]?[\d\.]+)\%\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)$/;
|
|
252
|
+
var keyword = /(\D+)/;
|
|
253
|
+
|
|
254
|
+
var rgb = [0, 0, 0, 1];
|
|
255
|
+
var match;
|
|
256
|
+
var i;
|
|
257
|
+
var hexAlpha;
|
|
258
|
+
|
|
259
|
+
if (match = string.match(hex)) {
|
|
260
|
+
hexAlpha = match[2];
|
|
261
|
+
match = match[1];
|
|
262
|
+
|
|
263
|
+
for (i = 0; i < 3; i++) {
|
|
264
|
+
// https://jsperf.com/slice-vs-substr-vs-substring-methods-long-string/19
|
|
265
|
+
var i2 = i * 2;
|
|
266
|
+
rgb[i] = parseInt(match.slice(i2, i2 + 2), 16);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
if (hexAlpha) {
|
|
270
|
+
rgb[3] = parseInt(hexAlpha, 16) / 255;
|
|
271
|
+
}
|
|
272
|
+
} else if (match = string.match(abbr)) {
|
|
273
|
+
match = match[1];
|
|
274
|
+
hexAlpha = match[3];
|
|
275
|
+
|
|
276
|
+
for (i = 0; i < 3; i++) {
|
|
277
|
+
rgb[i] = parseInt(match[i] + match[i], 16);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
if (hexAlpha) {
|
|
281
|
+
rgb[3] = parseInt(hexAlpha + hexAlpha, 16) / 255;
|
|
282
|
+
}
|
|
283
|
+
} else if (match = string.match(rgba)) {
|
|
284
|
+
for (i = 0; i < 3; i++) {
|
|
285
|
+
rgb[i] = parseInt(match[i + 1], 0);
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
if (match[4]) {
|
|
289
|
+
rgb[3] = parseFloat(match[4]);
|
|
290
|
+
}
|
|
291
|
+
} else if (match = string.match(per)) {
|
|
292
|
+
for (i = 0; i < 3; i++) {
|
|
293
|
+
rgb[i] = Math.round(parseFloat(match[i + 1]) * 2.55);
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
if (match[4]) {
|
|
297
|
+
rgb[3] = parseFloat(match[4]);
|
|
298
|
+
}
|
|
299
|
+
} else if (match = string.match(keyword)) {
|
|
300
|
+
if (match[1] === 'transparent') {
|
|
301
|
+
return [0, 0, 0, 0];
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
rgb = colorName[match[1]];
|
|
305
|
+
|
|
306
|
+
if (!rgb) {
|
|
307
|
+
return null;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
rgb[3] = 1;
|
|
311
|
+
|
|
312
|
+
return rgb;
|
|
313
|
+
} else {
|
|
314
|
+
return null;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
for (i = 0; i < 3; i++) {
|
|
318
|
+
rgb[i] = clamp(rgb[i], 0, 255);
|
|
319
|
+
}
|
|
320
|
+
rgb[3] = clamp(rgb[3], 0, 1);
|
|
321
|
+
|
|
322
|
+
return rgb;
|
|
323
|
+
};
|
|
324
|
+
|
|
325
|
+
cs.get.hsl = function (string) {
|
|
326
|
+
if (!string) {
|
|
327
|
+
return null;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
var hsl = /^hsla?\(\s*([+-]?(?:\d{0,3}\.)?\d+)(?:deg)?\s*,?\s*([+-]?[\d\.]+)%\s*,?\s*([+-]?[\d\.]+)%\s*(?:[,|\/]\s*([+-]?[\d\.]+)\s*)?\)$/;
|
|
331
|
+
var match = string.match(hsl);
|
|
332
|
+
|
|
333
|
+
if (match) {
|
|
334
|
+
var alpha = parseFloat(match[4]);
|
|
335
|
+
var h = (parseFloat(match[1]) + 360) % 360;
|
|
336
|
+
var s = clamp(parseFloat(match[2]), 0, 100);
|
|
337
|
+
var l = clamp(parseFloat(match[3]), 0, 100);
|
|
338
|
+
var a = clamp(isNaN(alpha) ? 1 : alpha, 0, 1);
|
|
339
|
+
|
|
340
|
+
return [h, s, l, a];
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
return null;
|
|
344
|
+
};
|
|
345
|
+
|
|
346
|
+
cs.get.hwb = function (string) {
|
|
347
|
+
if (!string) {
|
|
348
|
+
return null;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
var hwb = /^hwb\(\s*([+-]?\d{0,3}(?:\.\d+)?)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)$/;
|
|
352
|
+
var match = string.match(hwb);
|
|
353
|
+
|
|
354
|
+
if (match) {
|
|
355
|
+
var alpha = parseFloat(match[4]);
|
|
356
|
+
var h = ((parseFloat(match[1]) % 360) + 360) % 360;
|
|
357
|
+
var w = clamp(parseFloat(match[2]), 0, 100);
|
|
358
|
+
var b = clamp(parseFloat(match[3]), 0, 100);
|
|
359
|
+
var a = clamp(isNaN(alpha) ? 1 : alpha, 0, 1);
|
|
360
|
+
return [h, w, b, a];
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
return null;
|
|
364
|
+
};
|
|
365
|
+
|
|
366
|
+
cs.to.hex = function () {
|
|
367
|
+
var rgba = simpleSwizzle(arguments);
|
|
368
|
+
|
|
369
|
+
return (
|
|
370
|
+
'#' +
|
|
371
|
+
hexDouble(rgba[0]) +
|
|
372
|
+
hexDouble(rgba[1]) +
|
|
373
|
+
hexDouble(rgba[2]) +
|
|
374
|
+
(rgba[3] < 1
|
|
375
|
+
? (hexDouble(Math.round(rgba[3] * 255)))
|
|
376
|
+
: '')
|
|
377
|
+
);
|
|
378
|
+
};
|
|
379
|
+
|
|
380
|
+
cs.to.rgb = function () {
|
|
381
|
+
var rgba = simpleSwizzle(arguments);
|
|
382
|
+
|
|
383
|
+
return rgba.length < 4 || rgba[3] === 1
|
|
384
|
+
? 'rgb(' + Math.round(rgba[0]) + ', ' + Math.round(rgba[1]) + ', ' + Math.round(rgba[2]) + ')'
|
|
385
|
+
: 'rgba(' + Math.round(rgba[0]) + ', ' + Math.round(rgba[1]) + ', ' + Math.round(rgba[2]) + ', ' + rgba[3] + ')';
|
|
386
|
+
};
|
|
387
|
+
|
|
388
|
+
cs.to.rgb.percent = function () {
|
|
389
|
+
var rgba = simpleSwizzle(arguments);
|
|
390
|
+
|
|
391
|
+
var r = Math.round(rgba[0] / 255 * 100);
|
|
392
|
+
var g = Math.round(rgba[1] / 255 * 100);
|
|
393
|
+
var b = Math.round(rgba[2] / 255 * 100);
|
|
394
|
+
|
|
395
|
+
return rgba.length < 4 || rgba[3] === 1
|
|
396
|
+
? 'rgb(' + r + '%, ' + g + '%, ' + b + '%)'
|
|
397
|
+
: 'rgba(' + r + '%, ' + g + '%, ' + b + '%, ' + rgba[3] + ')';
|
|
398
|
+
};
|
|
399
|
+
|
|
400
|
+
cs.to.hsl = function () {
|
|
401
|
+
var hsla = simpleSwizzle(arguments);
|
|
402
|
+
return hsla.length < 4 || hsla[3] === 1
|
|
403
|
+
? 'hsl(' + hsla[0] + ', ' + hsla[1] + '%, ' + hsla[2] + '%)'
|
|
404
|
+
: 'hsla(' + hsla[0] + ', ' + hsla[1] + '%, ' + hsla[2] + '%, ' + hsla[3] + ')';
|
|
405
|
+
};
|
|
406
|
+
|
|
407
|
+
// hwb is a bit different than rgb(a) & hsl(a) since there is no alpha specific syntax
|
|
408
|
+
// (hwb have alpha optional & 1 is default value)
|
|
409
|
+
cs.to.hwb = function () {
|
|
410
|
+
var hwba = simpleSwizzle(arguments);
|
|
411
|
+
|
|
412
|
+
var a = '';
|
|
413
|
+
if (hwba.length >= 4 && hwba[3] !== 1) {
|
|
414
|
+
a = ', ' + hwba[3];
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
return 'hwb(' + hwba[0] + ', ' + hwba[1] + '%, ' + hwba[2] + '%' + a + ')';
|
|
418
|
+
};
|
|
419
|
+
|
|
420
|
+
cs.to.keyword = function (rgb) {
|
|
421
|
+
return reverseNames[rgb.slice(0, 3)];
|
|
422
|
+
};
|
|
423
|
+
|
|
424
|
+
// helpers
|
|
425
|
+
function clamp(num, min, max) {
|
|
426
|
+
return Math.min(Math.max(min, num), max);
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
function hexDouble(num) {
|
|
430
|
+
var str = num.toString(16).toUpperCase();
|
|
431
|
+
return (str.length < 2) ? '0' + str : str;
|
|
432
|
+
}
|
|
433
|
+
});
|
|
434
|
+
|
|
435
|
+
/* MIT license */
|
|
436
|
+
/* eslint-disable no-mixed-operators */
|
|
437
|
+
|
|
438
|
+
|
|
439
|
+
// NOTE: conversions should only return primitive values (i.e. arrays, or
|
|
440
|
+
// values that give correct `typeof` results).
|
|
441
|
+
// do not use box values types (i.e. Number(), String(), etc.)
|
|
442
|
+
|
|
443
|
+
const reverseKeywords = {};
|
|
444
|
+
for (const key of Object.keys(colorName)) {
|
|
445
|
+
reverseKeywords[colorName[key]] = key;
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
const convert$1 = {
|
|
449
|
+
rgb: {channels: 3, labels: 'rgb'},
|
|
450
|
+
hsl: {channels: 3, labels: 'hsl'},
|
|
451
|
+
hsv: {channels: 3, labels: 'hsv'},
|
|
452
|
+
hwb: {channels: 3, labels: 'hwb'},
|
|
453
|
+
cmyk: {channels: 4, labels: 'cmyk'},
|
|
454
|
+
xyz: {channels: 3, labels: 'xyz'},
|
|
455
|
+
lab: {channels: 3, labels: 'lab'},
|
|
456
|
+
lch: {channels: 3, labels: 'lch'},
|
|
457
|
+
hex: {channels: 1, labels: ['hex']},
|
|
458
|
+
keyword: {channels: 1, labels: ['keyword']},
|
|
459
|
+
ansi16: {channels: 1, labels: ['ansi16']},
|
|
460
|
+
ansi256: {channels: 1, labels: ['ansi256']},
|
|
461
|
+
hcg: {channels: 3, labels: ['h', 'c', 'g']},
|
|
462
|
+
apple: {channels: 3, labels: ['r16', 'g16', 'b16']},
|
|
463
|
+
gray: {channels: 1, labels: ['gray']}
|
|
464
|
+
};
|
|
465
|
+
|
|
466
|
+
var conversions = convert$1;
|
|
467
|
+
|
|
468
|
+
// Hide .channels and .labels properties
|
|
469
|
+
for (const model of Object.keys(convert$1)) {
|
|
470
|
+
if (!('channels' in convert$1[model])) {
|
|
471
|
+
throw new Error('missing channels property: ' + model);
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
if (!('labels' in convert$1[model])) {
|
|
475
|
+
throw new Error('missing channel labels property: ' + model);
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
if (convert$1[model].labels.length !== convert$1[model].channels) {
|
|
479
|
+
throw new Error('channel and label counts mismatch: ' + model);
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
const {channels, labels} = convert$1[model];
|
|
483
|
+
delete convert$1[model].channels;
|
|
484
|
+
delete convert$1[model].labels;
|
|
485
|
+
Object.defineProperty(convert$1[model], 'channels', {value: channels});
|
|
486
|
+
Object.defineProperty(convert$1[model], 'labels', {value: labels});
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
convert$1.rgb.hsl = function (rgb) {
|
|
490
|
+
const r = rgb[0] / 255;
|
|
491
|
+
const g = rgb[1] / 255;
|
|
492
|
+
const b = rgb[2] / 255;
|
|
493
|
+
const min = Math.min(r, g, b);
|
|
494
|
+
const max = Math.max(r, g, b);
|
|
495
|
+
const delta = max - min;
|
|
496
|
+
let h;
|
|
497
|
+
let s;
|
|
498
|
+
|
|
499
|
+
if (max === min) {
|
|
500
|
+
h = 0;
|
|
501
|
+
} else if (r === max) {
|
|
502
|
+
h = (g - b) / delta;
|
|
503
|
+
} else if (g === max) {
|
|
504
|
+
h = 2 + (b - r) / delta;
|
|
505
|
+
} else if (b === max) {
|
|
506
|
+
h = 4 + (r - g) / delta;
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
h = Math.min(h * 60, 360);
|
|
510
|
+
|
|
511
|
+
if (h < 0) {
|
|
512
|
+
h += 360;
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
const l = (min + max) / 2;
|
|
516
|
+
|
|
517
|
+
if (max === min) {
|
|
518
|
+
s = 0;
|
|
519
|
+
} else if (l <= 0.5) {
|
|
520
|
+
s = delta / (max + min);
|
|
521
|
+
} else {
|
|
522
|
+
s = delta / (2 - max - min);
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
return [h, s * 100, l * 100];
|
|
526
|
+
};
|
|
527
|
+
|
|
528
|
+
convert$1.rgb.hsv = function (rgb) {
|
|
529
|
+
let rdif;
|
|
530
|
+
let gdif;
|
|
531
|
+
let bdif;
|
|
532
|
+
let h;
|
|
533
|
+
let s;
|
|
534
|
+
|
|
535
|
+
const r = rgb[0] / 255;
|
|
536
|
+
const g = rgb[1] / 255;
|
|
537
|
+
const b = rgb[2] / 255;
|
|
538
|
+
const v = Math.max(r, g, b);
|
|
539
|
+
const diff = v - Math.min(r, g, b);
|
|
540
|
+
const diffc = function (c) {
|
|
541
|
+
return (v - c) / 6 / diff + 1 / 2;
|
|
542
|
+
};
|
|
543
|
+
|
|
544
|
+
if (diff === 0) {
|
|
545
|
+
h = 0;
|
|
546
|
+
s = 0;
|
|
547
|
+
} else {
|
|
548
|
+
s = diff / v;
|
|
549
|
+
rdif = diffc(r);
|
|
550
|
+
gdif = diffc(g);
|
|
551
|
+
bdif = diffc(b);
|
|
552
|
+
|
|
553
|
+
if (r === v) {
|
|
554
|
+
h = bdif - gdif;
|
|
555
|
+
} else if (g === v) {
|
|
556
|
+
h = (1 / 3) + rdif - bdif;
|
|
557
|
+
} else if (b === v) {
|
|
558
|
+
h = (2 / 3) + gdif - rdif;
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
if (h < 0) {
|
|
562
|
+
h += 1;
|
|
563
|
+
} else if (h > 1) {
|
|
564
|
+
h -= 1;
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
return [
|
|
569
|
+
h * 360,
|
|
570
|
+
s * 100,
|
|
571
|
+
v * 100
|
|
572
|
+
];
|
|
573
|
+
};
|
|
574
|
+
|
|
575
|
+
convert$1.rgb.hwb = function (rgb) {
|
|
576
|
+
const r = rgb[0];
|
|
577
|
+
const g = rgb[1];
|
|
578
|
+
let b = rgb[2];
|
|
579
|
+
const h = convert$1.rgb.hsl(rgb)[0];
|
|
580
|
+
const w = 1 / 255 * Math.min(r, Math.min(g, b));
|
|
581
|
+
|
|
582
|
+
b = 1 - 1 / 255 * Math.max(r, Math.max(g, b));
|
|
583
|
+
|
|
584
|
+
return [h, w * 100, b * 100];
|
|
585
|
+
};
|
|
586
|
+
|
|
587
|
+
convert$1.rgb.cmyk = function (rgb) {
|
|
588
|
+
const r = rgb[0] / 255;
|
|
589
|
+
const g = rgb[1] / 255;
|
|
590
|
+
const b = rgb[2] / 255;
|
|
591
|
+
|
|
592
|
+
const k = Math.min(1 - r, 1 - g, 1 - b);
|
|
593
|
+
const c = (1 - r - k) / (1 - k) || 0;
|
|
594
|
+
const m = (1 - g - k) / (1 - k) || 0;
|
|
595
|
+
const y = (1 - b - k) / (1 - k) || 0;
|
|
596
|
+
|
|
597
|
+
return [c * 100, m * 100, y * 100, k * 100];
|
|
598
|
+
};
|
|
599
|
+
|
|
600
|
+
function comparativeDistance(x, y) {
|
|
601
|
+
/*
|
|
602
|
+
See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
|
|
603
|
+
*/
|
|
604
|
+
return (
|
|
605
|
+
((x[0] - y[0]) ** 2) +
|
|
606
|
+
((x[1] - y[1]) ** 2) +
|
|
607
|
+
((x[2] - y[2]) ** 2)
|
|
608
|
+
);
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
convert$1.rgb.keyword = function (rgb) {
|
|
612
|
+
const reversed = reverseKeywords[rgb];
|
|
613
|
+
if (reversed) {
|
|
614
|
+
return reversed;
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
let currentClosestDistance = Infinity;
|
|
618
|
+
let currentClosestKeyword;
|
|
619
|
+
|
|
620
|
+
for (const keyword of Object.keys(colorName)) {
|
|
621
|
+
const value = colorName[keyword];
|
|
622
|
+
|
|
623
|
+
// Compute comparative distance
|
|
624
|
+
const distance = comparativeDistance(rgb, value);
|
|
625
|
+
|
|
626
|
+
// Check if its less, if so set as closest
|
|
627
|
+
if (distance < currentClosestDistance) {
|
|
628
|
+
currentClosestDistance = distance;
|
|
629
|
+
currentClosestKeyword = keyword;
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
return currentClosestKeyword;
|
|
634
|
+
};
|
|
635
|
+
|
|
636
|
+
convert$1.keyword.rgb = function (keyword) {
|
|
637
|
+
return colorName[keyword];
|
|
638
|
+
};
|
|
639
|
+
|
|
640
|
+
convert$1.rgb.xyz = function (rgb) {
|
|
641
|
+
let r = rgb[0] / 255;
|
|
642
|
+
let g = rgb[1] / 255;
|
|
643
|
+
let b = rgb[2] / 255;
|
|
644
|
+
|
|
645
|
+
// Assume sRGB
|
|
646
|
+
r = r > 0.04045 ? (((r + 0.055) / 1.055) ** 2.4) : (r / 12.92);
|
|
647
|
+
g = g > 0.04045 ? (((g + 0.055) / 1.055) ** 2.4) : (g / 12.92);
|
|
648
|
+
b = b > 0.04045 ? (((b + 0.055) / 1.055) ** 2.4) : (b / 12.92);
|
|
649
|
+
|
|
650
|
+
const x = (r * 0.4124) + (g * 0.3576) + (b * 0.1805);
|
|
651
|
+
const y = (r * 0.2126) + (g * 0.7152) + (b * 0.0722);
|
|
652
|
+
const z = (r * 0.0193) + (g * 0.1192) + (b * 0.9505);
|
|
653
|
+
|
|
654
|
+
return [x * 100, y * 100, z * 100];
|
|
655
|
+
};
|
|
656
|
+
|
|
657
|
+
convert$1.rgb.lab = function (rgb) {
|
|
658
|
+
const xyz = convert$1.rgb.xyz(rgb);
|
|
659
|
+
let x = xyz[0];
|
|
660
|
+
let y = xyz[1];
|
|
661
|
+
let z = xyz[2];
|
|
662
|
+
|
|
663
|
+
x /= 95.047;
|
|
664
|
+
y /= 100;
|
|
665
|
+
z /= 108.883;
|
|
666
|
+
|
|
667
|
+
x = x > 0.008856 ? (x ** (1 / 3)) : (7.787 * x) + (16 / 116);
|
|
668
|
+
y = y > 0.008856 ? (y ** (1 / 3)) : (7.787 * y) + (16 / 116);
|
|
669
|
+
z = z > 0.008856 ? (z ** (1 / 3)) : (7.787 * z) + (16 / 116);
|
|
670
|
+
|
|
671
|
+
const l = (116 * y) - 16;
|
|
672
|
+
const a = 500 * (x - y);
|
|
673
|
+
const b = 200 * (y - z);
|
|
674
|
+
|
|
675
|
+
return [l, a, b];
|
|
676
|
+
};
|
|
677
|
+
|
|
678
|
+
convert$1.hsl.rgb = function (hsl) {
|
|
679
|
+
const h = hsl[0] / 360;
|
|
680
|
+
const s = hsl[1] / 100;
|
|
681
|
+
const l = hsl[2] / 100;
|
|
682
|
+
let t2;
|
|
683
|
+
let t3;
|
|
684
|
+
let val;
|
|
685
|
+
|
|
686
|
+
if (s === 0) {
|
|
687
|
+
val = l * 255;
|
|
688
|
+
return [val, val, val];
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
if (l < 0.5) {
|
|
692
|
+
t2 = l * (1 + s);
|
|
693
|
+
} else {
|
|
694
|
+
t2 = l + s - l * s;
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
const t1 = 2 * l - t2;
|
|
698
|
+
|
|
699
|
+
const rgb = [0, 0, 0];
|
|
700
|
+
for (let i = 0; i < 3; i++) {
|
|
701
|
+
t3 = h + 1 / 3 * -(i - 1);
|
|
702
|
+
if (t3 < 0) {
|
|
703
|
+
t3++;
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
if (t3 > 1) {
|
|
707
|
+
t3--;
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
if (6 * t3 < 1) {
|
|
711
|
+
val = t1 + (t2 - t1) * 6 * t3;
|
|
712
|
+
} else if (2 * t3 < 1) {
|
|
713
|
+
val = t2;
|
|
714
|
+
} else if (3 * t3 < 2) {
|
|
715
|
+
val = t1 + (t2 - t1) * (2 / 3 - t3) * 6;
|
|
716
|
+
} else {
|
|
717
|
+
val = t1;
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
rgb[i] = val * 255;
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
return rgb;
|
|
724
|
+
};
|
|
725
|
+
|
|
726
|
+
convert$1.hsl.hsv = function (hsl) {
|
|
727
|
+
const h = hsl[0];
|
|
728
|
+
let s = hsl[1] / 100;
|
|
729
|
+
let l = hsl[2] / 100;
|
|
730
|
+
let smin = s;
|
|
731
|
+
const lmin = Math.max(l, 0.01);
|
|
732
|
+
|
|
733
|
+
l *= 2;
|
|
734
|
+
s *= (l <= 1) ? l : 2 - l;
|
|
735
|
+
smin *= lmin <= 1 ? lmin : 2 - lmin;
|
|
736
|
+
const v = (l + s) / 2;
|
|
737
|
+
const sv = l === 0 ? (2 * smin) / (lmin + smin) : (2 * s) / (l + s);
|
|
738
|
+
|
|
739
|
+
return [h, sv * 100, v * 100];
|
|
740
|
+
};
|
|
741
|
+
|
|
742
|
+
convert$1.hsv.rgb = function (hsv) {
|
|
743
|
+
const h = hsv[0] / 60;
|
|
744
|
+
const s = hsv[1] / 100;
|
|
745
|
+
let v = hsv[2] / 100;
|
|
746
|
+
const hi = Math.floor(h) % 6;
|
|
747
|
+
|
|
748
|
+
const f = h - Math.floor(h);
|
|
749
|
+
const p = 255 * v * (1 - s);
|
|
750
|
+
const q = 255 * v * (1 - (s * f));
|
|
751
|
+
const t = 255 * v * (1 - (s * (1 - f)));
|
|
752
|
+
v *= 255;
|
|
753
|
+
|
|
754
|
+
switch (hi) {
|
|
755
|
+
case 0:
|
|
756
|
+
return [v, t, p];
|
|
757
|
+
case 1:
|
|
758
|
+
return [q, v, p];
|
|
759
|
+
case 2:
|
|
760
|
+
return [p, v, t];
|
|
761
|
+
case 3:
|
|
762
|
+
return [p, q, v];
|
|
763
|
+
case 4:
|
|
764
|
+
return [t, p, v];
|
|
765
|
+
case 5:
|
|
766
|
+
return [v, p, q];
|
|
767
|
+
}
|
|
768
|
+
};
|
|
769
|
+
|
|
770
|
+
convert$1.hsv.hsl = function (hsv) {
|
|
771
|
+
const h = hsv[0];
|
|
772
|
+
const s = hsv[1] / 100;
|
|
773
|
+
const v = hsv[2] / 100;
|
|
774
|
+
const vmin = Math.max(v, 0.01);
|
|
775
|
+
let sl;
|
|
776
|
+
let l;
|
|
777
|
+
|
|
778
|
+
l = (2 - s) * v;
|
|
779
|
+
const lmin = (2 - s) * vmin;
|
|
780
|
+
sl = s * vmin;
|
|
781
|
+
sl /= (lmin <= 1) ? lmin : 2 - lmin;
|
|
782
|
+
sl = sl || 0;
|
|
783
|
+
l /= 2;
|
|
784
|
+
|
|
785
|
+
return [h, sl * 100, l * 100];
|
|
786
|
+
};
|
|
787
|
+
|
|
788
|
+
// http://dev.w3.org/csswg/css-color/#hwb-to-rgb
|
|
789
|
+
convert$1.hwb.rgb = function (hwb) {
|
|
790
|
+
const h = hwb[0] / 360;
|
|
791
|
+
let wh = hwb[1] / 100;
|
|
792
|
+
let bl = hwb[2] / 100;
|
|
793
|
+
const ratio = wh + bl;
|
|
794
|
+
let f;
|
|
795
|
+
|
|
796
|
+
// Wh + bl cant be > 1
|
|
797
|
+
if (ratio > 1) {
|
|
798
|
+
wh /= ratio;
|
|
799
|
+
bl /= ratio;
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
const i = Math.floor(6 * h);
|
|
803
|
+
const v = 1 - bl;
|
|
804
|
+
f = 6 * h - i;
|
|
805
|
+
|
|
806
|
+
if ((i & 0x01) !== 0) {
|
|
807
|
+
f = 1 - f;
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
const n = wh + f * (v - wh); // Linear interpolation
|
|
811
|
+
|
|
812
|
+
let r;
|
|
813
|
+
let g;
|
|
814
|
+
let b;
|
|
815
|
+
/* eslint-disable max-statements-per-line,no-multi-spaces */
|
|
816
|
+
switch (i) {
|
|
817
|
+
default:
|
|
818
|
+
case 6:
|
|
819
|
+
case 0: r = v; g = n; b = wh; break;
|
|
820
|
+
case 1: r = n; g = v; b = wh; break;
|
|
821
|
+
case 2: r = wh; g = v; b = n; break;
|
|
822
|
+
case 3: r = wh; g = n; b = v; break;
|
|
823
|
+
case 4: r = n; g = wh; b = v; break;
|
|
824
|
+
case 5: r = v; g = wh; b = n; break;
|
|
825
|
+
}
|
|
826
|
+
/* eslint-enable max-statements-per-line,no-multi-spaces */
|
|
827
|
+
|
|
828
|
+
return [r * 255, g * 255, b * 255];
|
|
829
|
+
};
|
|
830
|
+
|
|
831
|
+
convert$1.cmyk.rgb = function (cmyk) {
|
|
832
|
+
const c = cmyk[0] / 100;
|
|
833
|
+
const m = cmyk[1] / 100;
|
|
834
|
+
const y = cmyk[2] / 100;
|
|
835
|
+
const k = cmyk[3] / 100;
|
|
836
|
+
|
|
837
|
+
const r = 1 - Math.min(1, c * (1 - k) + k);
|
|
838
|
+
const g = 1 - Math.min(1, m * (1 - k) + k);
|
|
839
|
+
const b = 1 - Math.min(1, y * (1 - k) + k);
|
|
840
|
+
|
|
841
|
+
return [r * 255, g * 255, b * 255];
|
|
842
|
+
};
|
|
843
|
+
|
|
844
|
+
convert$1.xyz.rgb = function (xyz) {
|
|
845
|
+
const x = xyz[0] / 100;
|
|
846
|
+
const y = xyz[1] / 100;
|
|
847
|
+
const z = xyz[2] / 100;
|
|
848
|
+
let r;
|
|
849
|
+
let g;
|
|
850
|
+
let b;
|
|
851
|
+
|
|
852
|
+
r = (x * 3.2406) + (y * -1.5372) + (z * -0.4986);
|
|
853
|
+
g = (x * -0.9689) + (y * 1.8758) + (z * 0.0415);
|
|
854
|
+
b = (x * 0.0557) + (y * -0.2040) + (z * 1.0570);
|
|
855
|
+
|
|
856
|
+
// Assume sRGB
|
|
857
|
+
r = r > 0.0031308
|
|
858
|
+
? ((1.055 * (r ** (1.0 / 2.4))) - 0.055)
|
|
859
|
+
: r * 12.92;
|
|
860
|
+
|
|
861
|
+
g = g > 0.0031308
|
|
862
|
+
? ((1.055 * (g ** (1.0 / 2.4))) - 0.055)
|
|
863
|
+
: g * 12.92;
|
|
864
|
+
|
|
865
|
+
b = b > 0.0031308
|
|
866
|
+
? ((1.055 * (b ** (1.0 / 2.4))) - 0.055)
|
|
867
|
+
: b * 12.92;
|
|
868
|
+
|
|
869
|
+
r = Math.min(Math.max(0, r), 1);
|
|
870
|
+
g = Math.min(Math.max(0, g), 1);
|
|
871
|
+
b = Math.min(Math.max(0, b), 1);
|
|
872
|
+
|
|
873
|
+
return [r * 255, g * 255, b * 255];
|
|
874
|
+
};
|
|
875
|
+
|
|
876
|
+
convert$1.xyz.lab = function (xyz) {
|
|
877
|
+
let x = xyz[0];
|
|
878
|
+
let y = xyz[1];
|
|
879
|
+
let z = xyz[2];
|
|
880
|
+
|
|
881
|
+
x /= 95.047;
|
|
882
|
+
y /= 100;
|
|
883
|
+
z /= 108.883;
|
|
884
|
+
|
|
885
|
+
x = x > 0.008856 ? (x ** (1 / 3)) : (7.787 * x) + (16 / 116);
|
|
886
|
+
y = y > 0.008856 ? (y ** (1 / 3)) : (7.787 * y) + (16 / 116);
|
|
887
|
+
z = z > 0.008856 ? (z ** (1 / 3)) : (7.787 * z) + (16 / 116);
|
|
888
|
+
|
|
889
|
+
const l = (116 * y) - 16;
|
|
890
|
+
const a = 500 * (x - y);
|
|
891
|
+
const b = 200 * (y - z);
|
|
892
|
+
|
|
893
|
+
return [l, a, b];
|
|
894
|
+
};
|
|
895
|
+
|
|
896
|
+
convert$1.lab.xyz = function (lab) {
|
|
897
|
+
const l = lab[0];
|
|
898
|
+
const a = lab[1];
|
|
899
|
+
const b = lab[2];
|
|
900
|
+
let x;
|
|
901
|
+
let y;
|
|
902
|
+
let z;
|
|
903
|
+
|
|
904
|
+
y = (l + 16) / 116;
|
|
905
|
+
x = a / 500 + y;
|
|
906
|
+
z = y - b / 200;
|
|
907
|
+
|
|
908
|
+
const y2 = y ** 3;
|
|
909
|
+
const x2 = x ** 3;
|
|
910
|
+
const z2 = z ** 3;
|
|
911
|
+
y = y2 > 0.008856 ? y2 : (y - 16 / 116) / 7.787;
|
|
912
|
+
x = x2 > 0.008856 ? x2 : (x - 16 / 116) / 7.787;
|
|
913
|
+
z = z2 > 0.008856 ? z2 : (z - 16 / 116) / 7.787;
|
|
914
|
+
|
|
915
|
+
x *= 95.047;
|
|
916
|
+
y *= 100;
|
|
917
|
+
z *= 108.883;
|
|
918
|
+
|
|
919
|
+
return [x, y, z];
|
|
920
|
+
};
|
|
921
|
+
|
|
922
|
+
convert$1.lab.lch = function (lab) {
|
|
923
|
+
const l = lab[0];
|
|
924
|
+
const a = lab[1];
|
|
925
|
+
const b = lab[2];
|
|
926
|
+
let h;
|
|
927
|
+
|
|
928
|
+
const hr = Math.atan2(b, a);
|
|
929
|
+
h = hr * 360 / 2 / Math.PI;
|
|
930
|
+
|
|
931
|
+
if (h < 0) {
|
|
932
|
+
h += 360;
|
|
933
|
+
}
|
|
934
|
+
|
|
935
|
+
const c = Math.sqrt(a * a + b * b);
|
|
936
|
+
|
|
937
|
+
return [l, c, h];
|
|
938
|
+
};
|
|
939
|
+
|
|
940
|
+
convert$1.lch.lab = function (lch) {
|
|
941
|
+
const l = lch[0];
|
|
942
|
+
const c = lch[1];
|
|
943
|
+
const h = lch[2];
|
|
944
|
+
|
|
945
|
+
const hr = h / 360 * 2 * Math.PI;
|
|
946
|
+
const a = c * Math.cos(hr);
|
|
947
|
+
const b = c * Math.sin(hr);
|
|
948
|
+
|
|
949
|
+
return [l, a, b];
|
|
950
|
+
};
|
|
951
|
+
|
|
952
|
+
convert$1.rgb.ansi16 = function (args, saturation = null) {
|
|
953
|
+
const [r, g, b] = args;
|
|
954
|
+
let value = saturation === null ? convert$1.rgb.hsv(args)[2] : saturation; // Hsv -> ansi16 optimization
|
|
955
|
+
|
|
956
|
+
value = Math.round(value / 50);
|
|
957
|
+
|
|
958
|
+
if (value === 0) {
|
|
959
|
+
return 30;
|
|
960
|
+
}
|
|
961
|
+
|
|
962
|
+
let ansi = 30
|
|
963
|
+
+ ((Math.round(b / 255) << 2)
|
|
964
|
+
| (Math.round(g / 255) << 1)
|
|
965
|
+
| Math.round(r / 255));
|
|
966
|
+
|
|
967
|
+
if (value === 2) {
|
|
968
|
+
ansi += 60;
|
|
969
|
+
}
|
|
970
|
+
|
|
971
|
+
return ansi;
|
|
972
|
+
};
|
|
973
|
+
|
|
974
|
+
convert$1.hsv.ansi16 = function (args) {
|
|
975
|
+
// Optimization here; we already know the value and don't need to get
|
|
976
|
+
// it converted for us.
|
|
977
|
+
return convert$1.rgb.ansi16(convert$1.hsv.rgb(args), args[2]);
|
|
978
|
+
};
|
|
979
|
+
|
|
980
|
+
convert$1.rgb.ansi256 = function (args) {
|
|
981
|
+
const r = args[0];
|
|
982
|
+
const g = args[1];
|
|
983
|
+
const b = args[2];
|
|
984
|
+
|
|
985
|
+
// We use the extended greyscale palette here, with the exception of
|
|
986
|
+
// black and white. normal palette only has 4 greyscale shades.
|
|
987
|
+
if (r === g && g === b) {
|
|
988
|
+
if (r < 8) {
|
|
989
|
+
return 16;
|
|
990
|
+
}
|
|
991
|
+
|
|
992
|
+
if (r > 248) {
|
|
993
|
+
return 231;
|
|
994
|
+
}
|
|
995
|
+
|
|
996
|
+
return Math.round(((r - 8) / 247) * 24) + 232;
|
|
997
|
+
}
|
|
998
|
+
|
|
999
|
+
const ansi = 16
|
|
1000
|
+
+ (36 * Math.round(r / 255 * 5))
|
|
1001
|
+
+ (6 * Math.round(g / 255 * 5))
|
|
1002
|
+
+ Math.round(b / 255 * 5);
|
|
1003
|
+
|
|
1004
|
+
return ansi;
|
|
1005
|
+
};
|
|
1006
|
+
|
|
1007
|
+
convert$1.ansi16.rgb = function (args) {
|
|
1008
|
+
let color = args % 10;
|
|
1009
|
+
|
|
1010
|
+
// Handle greyscale
|
|
1011
|
+
if (color === 0 || color === 7) {
|
|
1012
|
+
if (args > 50) {
|
|
1013
|
+
color += 3.5;
|
|
1014
|
+
}
|
|
1015
|
+
|
|
1016
|
+
color = color / 10.5 * 255;
|
|
1017
|
+
|
|
1018
|
+
return [color, color, color];
|
|
1019
|
+
}
|
|
1020
|
+
|
|
1021
|
+
const mult = (~~(args > 50) + 1) * 0.5;
|
|
1022
|
+
const r = ((color & 1) * mult) * 255;
|
|
1023
|
+
const g = (((color >> 1) & 1) * mult) * 255;
|
|
1024
|
+
const b = (((color >> 2) & 1) * mult) * 255;
|
|
1025
|
+
|
|
1026
|
+
return [r, g, b];
|
|
1027
|
+
};
|
|
1028
|
+
|
|
1029
|
+
convert$1.ansi256.rgb = function (args) {
|
|
1030
|
+
// Handle greyscale
|
|
1031
|
+
if (args >= 232) {
|
|
1032
|
+
const c = (args - 232) * 10 + 8;
|
|
1033
|
+
return [c, c, c];
|
|
1034
|
+
}
|
|
1035
|
+
|
|
1036
|
+
args -= 16;
|
|
1037
|
+
|
|
1038
|
+
let rem;
|
|
1039
|
+
const r = Math.floor(args / 36) / 5 * 255;
|
|
1040
|
+
const g = Math.floor((rem = args % 36) / 6) / 5 * 255;
|
|
1041
|
+
const b = (rem % 6) / 5 * 255;
|
|
1042
|
+
|
|
1043
|
+
return [r, g, b];
|
|
1044
|
+
};
|
|
1045
|
+
|
|
1046
|
+
convert$1.rgb.hex = function (args) {
|
|
1047
|
+
const integer = ((Math.round(args[0]) & 0xFF) << 16)
|
|
1048
|
+
+ ((Math.round(args[1]) & 0xFF) << 8)
|
|
1049
|
+
+ (Math.round(args[2]) & 0xFF);
|
|
1050
|
+
|
|
1051
|
+
const string = integer.toString(16).toUpperCase();
|
|
1052
|
+
return '000000'.substring(string.length) + string;
|
|
1053
|
+
};
|
|
1054
|
+
|
|
1055
|
+
convert$1.hex.rgb = function (args) {
|
|
1056
|
+
const match = args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);
|
|
1057
|
+
if (!match) {
|
|
1058
|
+
return [0, 0, 0];
|
|
1059
|
+
}
|
|
1060
|
+
|
|
1061
|
+
let colorString = match[0];
|
|
1062
|
+
|
|
1063
|
+
if (match[0].length === 3) {
|
|
1064
|
+
colorString = colorString.split('').map(char => {
|
|
1065
|
+
return char + char;
|
|
1066
|
+
}).join('');
|
|
1067
|
+
}
|
|
1068
|
+
|
|
1069
|
+
const integer = parseInt(colorString, 16);
|
|
1070
|
+
const r = (integer >> 16) & 0xFF;
|
|
1071
|
+
const g = (integer >> 8) & 0xFF;
|
|
1072
|
+
const b = integer & 0xFF;
|
|
1073
|
+
|
|
1074
|
+
return [r, g, b];
|
|
1075
|
+
};
|
|
1076
|
+
|
|
1077
|
+
convert$1.rgb.hcg = function (rgb) {
|
|
1078
|
+
const r = rgb[0] / 255;
|
|
1079
|
+
const g = rgb[1] / 255;
|
|
1080
|
+
const b = rgb[2] / 255;
|
|
1081
|
+
const max = Math.max(Math.max(r, g), b);
|
|
1082
|
+
const min = Math.min(Math.min(r, g), b);
|
|
1083
|
+
const chroma = (max - min);
|
|
1084
|
+
let grayscale;
|
|
1085
|
+
let hue;
|
|
1086
|
+
|
|
1087
|
+
if (chroma < 1) {
|
|
1088
|
+
grayscale = min / (1 - chroma);
|
|
1089
|
+
} else {
|
|
1090
|
+
grayscale = 0;
|
|
1091
|
+
}
|
|
1092
|
+
|
|
1093
|
+
if (chroma <= 0) {
|
|
1094
|
+
hue = 0;
|
|
1095
|
+
} else
|
|
1096
|
+
if (max === r) {
|
|
1097
|
+
hue = ((g - b) / chroma) % 6;
|
|
1098
|
+
} else
|
|
1099
|
+
if (max === g) {
|
|
1100
|
+
hue = 2 + (b - r) / chroma;
|
|
1101
|
+
} else {
|
|
1102
|
+
hue = 4 + (r - g) / chroma;
|
|
1103
|
+
}
|
|
1104
|
+
|
|
1105
|
+
hue /= 6;
|
|
1106
|
+
hue %= 1;
|
|
1107
|
+
|
|
1108
|
+
return [hue * 360, chroma * 100, grayscale * 100];
|
|
1109
|
+
};
|
|
1110
|
+
|
|
1111
|
+
convert$1.hsl.hcg = function (hsl) {
|
|
1112
|
+
const s = hsl[1] / 100;
|
|
1113
|
+
const l = hsl[2] / 100;
|
|
1114
|
+
|
|
1115
|
+
const c = l < 0.5 ? (2.0 * s * l) : (2.0 * s * (1.0 - l));
|
|
1116
|
+
|
|
1117
|
+
let f = 0;
|
|
1118
|
+
if (c < 1.0) {
|
|
1119
|
+
f = (l - 0.5 * c) / (1.0 - c);
|
|
1120
|
+
}
|
|
1121
|
+
|
|
1122
|
+
return [hsl[0], c * 100, f * 100];
|
|
1123
|
+
};
|
|
1124
|
+
|
|
1125
|
+
convert$1.hsv.hcg = function (hsv) {
|
|
1126
|
+
const s = hsv[1] / 100;
|
|
1127
|
+
const v = hsv[2] / 100;
|
|
1128
|
+
|
|
1129
|
+
const c = s * v;
|
|
1130
|
+
let f = 0;
|
|
1131
|
+
|
|
1132
|
+
if (c < 1.0) {
|
|
1133
|
+
f = (v - c) / (1 - c);
|
|
1134
|
+
}
|
|
1135
|
+
|
|
1136
|
+
return [hsv[0], c * 100, f * 100];
|
|
1137
|
+
};
|
|
1138
|
+
|
|
1139
|
+
convert$1.hcg.rgb = function (hcg) {
|
|
1140
|
+
const h = hcg[0] / 360;
|
|
1141
|
+
const c = hcg[1] / 100;
|
|
1142
|
+
const g = hcg[2] / 100;
|
|
1143
|
+
|
|
1144
|
+
if (c === 0.0) {
|
|
1145
|
+
return [g * 255, g * 255, g * 255];
|
|
1146
|
+
}
|
|
1147
|
+
|
|
1148
|
+
const pure = [0, 0, 0];
|
|
1149
|
+
const hi = (h % 1) * 6;
|
|
1150
|
+
const v = hi % 1;
|
|
1151
|
+
const w = 1 - v;
|
|
1152
|
+
let mg = 0;
|
|
1153
|
+
|
|
1154
|
+
/* eslint-disable max-statements-per-line */
|
|
1155
|
+
switch (Math.floor(hi)) {
|
|
1156
|
+
case 0:
|
|
1157
|
+
pure[0] = 1; pure[1] = v; pure[2] = 0; break;
|
|
1158
|
+
case 1:
|
|
1159
|
+
pure[0] = w; pure[1] = 1; pure[2] = 0; break;
|
|
1160
|
+
case 2:
|
|
1161
|
+
pure[0] = 0; pure[1] = 1; pure[2] = v; break;
|
|
1162
|
+
case 3:
|
|
1163
|
+
pure[0] = 0; pure[1] = w; pure[2] = 1; break;
|
|
1164
|
+
case 4:
|
|
1165
|
+
pure[0] = v; pure[1] = 0; pure[2] = 1; break;
|
|
1166
|
+
default:
|
|
1167
|
+
pure[0] = 1; pure[1] = 0; pure[2] = w;
|
|
1168
|
+
}
|
|
1169
|
+
/* eslint-enable max-statements-per-line */
|
|
1170
|
+
|
|
1171
|
+
mg = (1.0 - c) * g;
|
|
1172
|
+
|
|
1173
|
+
return [
|
|
1174
|
+
(c * pure[0] + mg) * 255,
|
|
1175
|
+
(c * pure[1] + mg) * 255,
|
|
1176
|
+
(c * pure[2] + mg) * 255
|
|
1177
|
+
];
|
|
1178
|
+
};
|
|
1179
|
+
|
|
1180
|
+
convert$1.hcg.hsv = function (hcg) {
|
|
1181
|
+
const c = hcg[1] / 100;
|
|
1182
|
+
const g = hcg[2] / 100;
|
|
1183
|
+
|
|
1184
|
+
const v = c + g * (1.0 - c);
|
|
1185
|
+
let f = 0;
|
|
1186
|
+
|
|
1187
|
+
if (v > 0.0) {
|
|
1188
|
+
f = c / v;
|
|
1189
|
+
}
|
|
1190
|
+
|
|
1191
|
+
return [hcg[0], f * 100, v * 100];
|
|
1192
|
+
};
|
|
1193
|
+
|
|
1194
|
+
convert$1.hcg.hsl = function (hcg) {
|
|
1195
|
+
const c = hcg[1] / 100;
|
|
1196
|
+
const g = hcg[2] / 100;
|
|
1197
|
+
|
|
1198
|
+
const l = g * (1.0 - c) + 0.5 * c;
|
|
1199
|
+
let s = 0;
|
|
1200
|
+
|
|
1201
|
+
if (l > 0.0 && l < 0.5) {
|
|
1202
|
+
s = c / (2 * l);
|
|
1203
|
+
} else
|
|
1204
|
+
if (l >= 0.5 && l < 1.0) {
|
|
1205
|
+
s = c / (2 * (1 - l));
|
|
1206
|
+
}
|
|
1207
|
+
|
|
1208
|
+
return [hcg[0], s * 100, l * 100];
|
|
1209
|
+
};
|
|
1210
|
+
|
|
1211
|
+
convert$1.hcg.hwb = function (hcg) {
|
|
1212
|
+
const c = hcg[1] / 100;
|
|
1213
|
+
const g = hcg[2] / 100;
|
|
1214
|
+
const v = c + g * (1.0 - c);
|
|
1215
|
+
return [hcg[0], (v - c) * 100, (1 - v) * 100];
|
|
1216
|
+
};
|
|
1217
|
+
|
|
1218
|
+
convert$1.hwb.hcg = function (hwb) {
|
|
1219
|
+
const w = hwb[1] / 100;
|
|
1220
|
+
const b = hwb[2] / 100;
|
|
1221
|
+
const v = 1 - b;
|
|
1222
|
+
const c = v - w;
|
|
1223
|
+
let g = 0;
|
|
1224
|
+
|
|
1225
|
+
if (c < 1) {
|
|
1226
|
+
g = (v - c) / (1 - c);
|
|
1227
|
+
}
|
|
1228
|
+
|
|
1229
|
+
return [hwb[0], c * 100, g * 100];
|
|
1230
|
+
};
|
|
1231
|
+
|
|
1232
|
+
convert$1.apple.rgb = function (apple) {
|
|
1233
|
+
return [(apple[0] / 65535) * 255, (apple[1] / 65535) * 255, (apple[2] / 65535) * 255];
|
|
1234
|
+
};
|
|
1235
|
+
|
|
1236
|
+
convert$1.rgb.apple = function (rgb) {
|
|
1237
|
+
return [(rgb[0] / 255) * 65535, (rgb[1] / 255) * 65535, (rgb[2] / 255) * 65535];
|
|
1238
|
+
};
|
|
1239
|
+
|
|
1240
|
+
convert$1.gray.rgb = function (args) {
|
|
1241
|
+
return [args[0] / 100 * 255, args[0] / 100 * 255, args[0] / 100 * 255];
|
|
1242
|
+
};
|
|
1243
|
+
|
|
1244
|
+
convert$1.gray.hsl = function (args) {
|
|
1245
|
+
return [0, 0, args[0]];
|
|
1246
|
+
};
|
|
1247
|
+
|
|
1248
|
+
convert$1.gray.hsv = convert$1.gray.hsl;
|
|
1249
|
+
|
|
1250
|
+
convert$1.gray.hwb = function (gray) {
|
|
1251
|
+
return [0, 100, gray[0]];
|
|
1252
|
+
};
|
|
1253
|
+
|
|
1254
|
+
convert$1.gray.cmyk = function (gray) {
|
|
1255
|
+
return [0, 0, 0, gray[0]];
|
|
1256
|
+
};
|
|
1257
|
+
|
|
1258
|
+
convert$1.gray.lab = function (gray) {
|
|
1259
|
+
return [gray[0], 0, 0];
|
|
1260
|
+
};
|
|
1261
|
+
|
|
1262
|
+
convert$1.gray.hex = function (gray) {
|
|
1263
|
+
const val = Math.round(gray[0] / 100 * 255) & 0xFF;
|
|
1264
|
+
const integer = (val << 16) + (val << 8) + val;
|
|
1265
|
+
|
|
1266
|
+
const string = integer.toString(16).toUpperCase();
|
|
1267
|
+
return '000000'.substring(string.length) + string;
|
|
1268
|
+
};
|
|
1269
|
+
|
|
1270
|
+
convert$1.rgb.gray = function (rgb) {
|
|
1271
|
+
const val = (rgb[0] + rgb[1] + rgb[2]) / 3;
|
|
1272
|
+
return [val / 255 * 100];
|
|
1273
|
+
};
|
|
1274
|
+
|
|
1275
|
+
/*
|
|
1276
|
+
This function routes a model to all other models.
|
|
1277
|
+
|
|
1278
|
+
all functions that are routed have a property `.conversion` attached
|
|
1279
|
+
to the returned synthetic function. This property is an array
|
|
1280
|
+
of strings, each with the steps in between the 'from' and 'to'
|
|
1281
|
+
color models (inclusive).
|
|
1282
|
+
|
|
1283
|
+
conversions that are not possible simply are not included.
|
|
1284
|
+
*/
|
|
1285
|
+
|
|
1286
|
+
function buildGraph() {
|
|
1287
|
+
const graph = {};
|
|
1288
|
+
// https://jsperf.com/object-keys-vs-for-in-with-closure/3
|
|
1289
|
+
const models = Object.keys(conversions);
|
|
1290
|
+
|
|
1291
|
+
for (let len = models.length, i = 0; i < len; i++) {
|
|
1292
|
+
graph[models[i]] = {
|
|
1293
|
+
// http://jsperf.com/1-vs-infinity
|
|
1294
|
+
// micro-opt, but this is simple.
|
|
1295
|
+
distance: -1,
|
|
1296
|
+
parent: null
|
|
1297
|
+
};
|
|
1298
|
+
}
|
|
1299
|
+
|
|
1300
|
+
return graph;
|
|
1301
|
+
}
|
|
1302
|
+
|
|
1303
|
+
// https://en.wikipedia.org/wiki/Breadth-first_search
|
|
1304
|
+
function deriveBFS(fromModel) {
|
|
1305
|
+
const graph = buildGraph();
|
|
1306
|
+
const queue = [fromModel]; // Unshift -> queue -> pop
|
|
1307
|
+
|
|
1308
|
+
graph[fromModel].distance = 0;
|
|
1309
|
+
|
|
1310
|
+
while (queue.length) {
|
|
1311
|
+
const current = queue.pop();
|
|
1312
|
+
const adjacents = Object.keys(conversions[current]);
|
|
1313
|
+
|
|
1314
|
+
for (let len = adjacents.length, i = 0; i < len; i++) {
|
|
1315
|
+
const adjacent = adjacents[i];
|
|
1316
|
+
const node = graph[adjacent];
|
|
1317
|
+
|
|
1318
|
+
if (node.distance === -1) {
|
|
1319
|
+
node.distance = graph[current].distance + 1;
|
|
1320
|
+
node.parent = current;
|
|
1321
|
+
queue.unshift(adjacent);
|
|
1322
|
+
}
|
|
1323
|
+
}
|
|
1324
|
+
}
|
|
1325
|
+
|
|
1326
|
+
return graph;
|
|
1327
|
+
}
|
|
1328
|
+
|
|
1329
|
+
function link(from, to) {
|
|
1330
|
+
return function (args) {
|
|
1331
|
+
return to(from(args));
|
|
1332
|
+
};
|
|
1333
|
+
}
|
|
1334
|
+
|
|
1335
|
+
function wrapConversion(toModel, graph) {
|
|
1336
|
+
const path = [graph[toModel].parent, toModel];
|
|
1337
|
+
let fn = conversions[graph[toModel].parent][toModel];
|
|
1338
|
+
|
|
1339
|
+
let cur = graph[toModel].parent;
|
|
1340
|
+
while (graph[cur].parent) {
|
|
1341
|
+
path.unshift(graph[cur].parent);
|
|
1342
|
+
fn = link(conversions[graph[cur].parent][cur], fn);
|
|
1343
|
+
cur = graph[cur].parent;
|
|
1344
|
+
}
|
|
1345
|
+
|
|
1346
|
+
fn.conversion = path;
|
|
1347
|
+
return fn;
|
|
1348
|
+
}
|
|
1349
|
+
|
|
1350
|
+
var route = function (fromModel) {
|
|
1351
|
+
const graph = deriveBFS(fromModel);
|
|
1352
|
+
const conversion = {};
|
|
1353
|
+
|
|
1354
|
+
const models = Object.keys(graph);
|
|
1355
|
+
for (let len = models.length, i = 0; i < len; i++) {
|
|
1356
|
+
const toModel = models[i];
|
|
1357
|
+
const node = graph[toModel];
|
|
1358
|
+
|
|
1359
|
+
if (node.parent === null) {
|
|
1360
|
+
// No possible conversion, or this node is the source model.
|
|
1361
|
+
continue;
|
|
1362
|
+
}
|
|
1363
|
+
|
|
1364
|
+
conversion[toModel] = wrapConversion(toModel, graph);
|
|
1365
|
+
}
|
|
1366
|
+
|
|
1367
|
+
return conversion;
|
|
1368
|
+
};
|
|
1369
|
+
|
|
1370
|
+
const convert = {};
|
|
1371
|
+
|
|
1372
|
+
const models = Object.keys(conversions);
|
|
1373
|
+
|
|
1374
|
+
function wrapRaw(fn) {
|
|
1375
|
+
const wrappedFn = function (...args) {
|
|
1376
|
+
const arg0 = args[0];
|
|
1377
|
+
if (arg0 === undefined || arg0 === null) {
|
|
1378
|
+
return arg0;
|
|
1379
|
+
}
|
|
1380
|
+
|
|
1381
|
+
if (arg0.length > 1) {
|
|
1382
|
+
args = arg0;
|
|
1383
|
+
}
|
|
1384
|
+
|
|
1385
|
+
return fn(args);
|
|
1386
|
+
};
|
|
1387
|
+
|
|
1388
|
+
// Preserve .conversion property if there is one
|
|
1389
|
+
if ('conversion' in fn) {
|
|
1390
|
+
wrappedFn.conversion = fn.conversion;
|
|
1391
|
+
}
|
|
1392
|
+
|
|
1393
|
+
return wrappedFn;
|
|
1394
|
+
}
|
|
1395
|
+
|
|
1396
|
+
function wrapRounded(fn) {
|
|
1397
|
+
const wrappedFn = function (...args) {
|
|
1398
|
+
const arg0 = args[0];
|
|
1399
|
+
|
|
1400
|
+
if (arg0 === undefined || arg0 === null) {
|
|
1401
|
+
return arg0;
|
|
1402
|
+
}
|
|
1403
|
+
|
|
1404
|
+
if (arg0.length > 1) {
|
|
1405
|
+
args = arg0;
|
|
1406
|
+
}
|
|
1407
|
+
|
|
1408
|
+
const result = fn(args);
|
|
1409
|
+
|
|
1410
|
+
// We're assuming the result is an array here.
|
|
1411
|
+
// see notice in conversions.js; don't use box types
|
|
1412
|
+
// in conversion functions.
|
|
1413
|
+
if (typeof result === 'object') {
|
|
1414
|
+
for (let len = result.length, i = 0; i < len; i++) {
|
|
1415
|
+
result[i] = Math.round(result[i]);
|
|
1416
|
+
}
|
|
1417
|
+
}
|
|
1418
|
+
|
|
1419
|
+
return result;
|
|
1420
|
+
};
|
|
1421
|
+
|
|
1422
|
+
// Preserve .conversion property if there is one
|
|
1423
|
+
if ('conversion' in fn) {
|
|
1424
|
+
wrappedFn.conversion = fn.conversion;
|
|
1425
|
+
}
|
|
1426
|
+
|
|
1427
|
+
return wrappedFn;
|
|
1428
|
+
}
|
|
1429
|
+
|
|
1430
|
+
models.forEach(fromModel => {
|
|
1431
|
+
convert[fromModel] = {};
|
|
1432
|
+
|
|
1433
|
+
Object.defineProperty(convert[fromModel], 'channels', {value: conversions[fromModel].channels});
|
|
1434
|
+
Object.defineProperty(convert[fromModel], 'labels', {value: conversions[fromModel].labels});
|
|
1435
|
+
|
|
1436
|
+
const routes = route(fromModel);
|
|
1437
|
+
const routeModels = Object.keys(routes);
|
|
1438
|
+
|
|
1439
|
+
routeModels.forEach(toModel => {
|
|
1440
|
+
const fn = routes[toModel];
|
|
1441
|
+
|
|
1442
|
+
convert[fromModel][toModel] = wrapRounded(fn);
|
|
1443
|
+
convert[fromModel][toModel].raw = wrapRaw(fn);
|
|
1444
|
+
});
|
|
1445
|
+
});
|
|
1446
|
+
|
|
1447
|
+
var colorConvert = convert;
|
|
1448
|
+
|
|
1449
|
+
const _slice = [].slice;
|
|
1450
|
+
|
|
1451
|
+
const skippedModels = [
|
|
1452
|
+
// To be honest, I don't really feel like keyword belongs in color convert, but eh.
|
|
1453
|
+
'keyword',
|
|
1454
|
+
|
|
1455
|
+
// Gray conflicts with some method names, and has its own method defined.
|
|
1456
|
+
'gray',
|
|
1457
|
+
|
|
1458
|
+
// Shouldn't really be in color-convert either...
|
|
1459
|
+
'hex',
|
|
1460
|
+
];
|
|
1461
|
+
|
|
1462
|
+
const hashedModelKeys = {};
|
|
1463
|
+
for (const model of Object.keys(colorConvert)) {
|
|
1464
|
+
hashedModelKeys[_slice.call(colorConvert[model].labels).sort().join('')] = model;
|
|
1465
|
+
}
|
|
1466
|
+
|
|
1467
|
+
const limiters = {};
|
|
1468
|
+
|
|
1469
|
+
function Color(object, model) {
|
|
1470
|
+
if (!(this instanceof Color)) {
|
|
1471
|
+
return new Color(object, model);
|
|
1472
|
+
}
|
|
1473
|
+
|
|
1474
|
+
if (model && model in skippedModels) {
|
|
1475
|
+
model = null;
|
|
1476
|
+
}
|
|
1477
|
+
|
|
1478
|
+
if (model && !(model in colorConvert)) {
|
|
1479
|
+
throw new Error('Unknown model: ' + model);
|
|
1480
|
+
}
|
|
1481
|
+
|
|
1482
|
+
let i;
|
|
1483
|
+
let channels;
|
|
1484
|
+
|
|
1485
|
+
if (object == null) { // eslint-disable-line no-eq-null,eqeqeq
|
|
1486
|
+
this.model = 'rgb';
|
|
1487
|
+
this.color = [0, 0, 0];
|
|
1488
|
+
this.valpha = 1;
|
|
1489
|
+
} else if (object instanceof Color) {
|
|
1490
|
+
this.model = object.model;
|
|
1491
|
+
this.color = object.color.slice();
|
|
1492
|
+
this.valpha = object.valpha;
|
|
1493
|
+
} else if (typeof object === 'string') {
|
|
1494
|
+
const result = colorString.get(object);
|
|
1495
|
+
if (result === null) {
|
|
1496
|
+
throw new Error('Unable to parse color from string: ' + object);
|
|
1497
|
+
}
|
|
1498
|
+
|
|
1499
|
+
this.model = result.model;
|
|
1500
|
+
channels = colorConvert[this.model].channels;
|
|
1501
|
+
this.color = result.value.slice(0, channels);
|
|
1502
|
+
this.valpha = typeof result.value[channels] === 'number' ? result.value[channels] : 1;
|
|
1503
|
+
} else if (object.length > 0) {
|
|
1504
|
+
this.model = model || 'rgb';
|
|
1505
|
+
channels = colorConvert[this.model].channels;
|
|
1506
|
+
const newArray = _slice.call(object, 0, channels);
|
|
1507
|
+
this.color = zeroArray(newArray, channels);
|
|
1508
|
+
this.valpha = typeof object[channels] === 'number' ? object[channels] : 1;
|
|
1509
|
+
} else if (typeof object === 'number') {
|
|
1510
|
+
// This is always RGB - can be converted later on.
|
|
1511
|
+
this.model = 'rgb';
|
|
1512
|
+
this.color = [
|
|
1513
|
+
(object >> 16) & 0xFF,
|
|
1514
|
+
(object >> 8) & 0xFF,
|
|
1515
|
+
object & 0xFF,
|
|
1516
|
+
];
|
|
1517
|
+
this.valpha = 1;
|
|
1518
|
+
} else {
|
|
1519
|
+
this.valpha = 1;
|
|
1520
|
+
|
|
1521
|
+
const keys = Object.keys(object);
|
|
1522
|
+
if ('alpha' in object) {
|
|
1523
|
+
keys.splice(keys.indexOf('alpha'), 1);
|
|
1524
|
+
this.valpha = typeof object.alpha === 'number' ? object.alpha : 0;
|
|
1525
|
+
}
|
|
1526
|
+
|
|
1527
|
+
const hashedKeys = keys.sort().join('');
|
|
1528
|
+
if (!(hashedKeys in hashedModelKeys)) {
|
|
1529
|
+
throw new Error('Unable to parse color from object: ' + JSON.stringify(object));
|
|
1530
|
+
}
|
|
1531
|
+
|
|
1532
|
+
this.model = hashedModelKeys[hashedKeys];
|
|
1533
|
+
|
|
1534
|
+
const labels = colorConvert[this.model].labels;
|
|
1535
|
+
const color = [];
|
|
1536
|
+
for (i = 0; i < labels.length; i++) {
|
|
1537
|
+
color.push(object[labels[i]]);
|
|
1538
|
+
}
|
|
1539
|
+
|
|
1540
|
+
this.color = zeroArray(color);
|
|
1541
|
+
}
|
|
1542
|
+
|
|
1543
|
+
// Perform limitations (clamping, etc.)
|
|
1544
|
+
if (limiters[this.model]) {
|
|
1545
|
+
channels = colorConvert[this.model].channels;
|
|
1546
|
+
for (i = 0; i < channels; i++) {
|
|
1547
|
+
const limit = limiters[this.model][i];
|
|
1548
|
+
if (limit) {
|
|
1549
|
+
this.color[i] = limit(this.color[i]);
|
|
1550
|
+
}
|
|
1551
|
+
}
|
|
1552
|
+
}
|
|
1553
|
+
|
|
1554
|
+
this.valpha = Math.max(0, Math.min(1, this.valpha));
|
|
1555
|
+
|
|
1556
|
+
if (Object.freeze) {
|
|
1557
|
+
Object.freeze(this);
|
|
1558
|
+
}
|
|
1559
|
+
}
|
|
1560
|
+
|
|
1561
|
+
Color.prototype = {
|
|
1562
|
+
toString() {
|
|
1563
|
+
return this.string();
|
|
1564
|
+
},
|
|
1565
|
+
|
|
1566
|
+
toJSON() {
|
|
1567
|
+
return this[this.model]();
|
|
1568
|
+
},
|
|
1569
|
+
|
|
1570
|
+
string(places) {
|
|
1571
|
+
let self = this.model in colorString.to ? this : this.rgb();
|
|
1572
|
+
self = self.round(typeof places === 'number' ? places : 1);
|
|
1573
|
+
const args = self.valpha === 1 ? self.color : self.color.concat(this.valpha);
|
|
1574
|
+
return colorString.to[self.model](args);
|
|
1575
|
+
},
|
|
1576
|
+
|
|
1577
|
+
percentString(places) {
|
|
1578
|
+
const self = this.rgb().round(typeof places === 'number' ? places : 1);
|
|
1579
|
+
const args = self.valpha === 1 ? self.color : self.color.concat(this.valpha);
|
|
1580
|
+
return colorString.to.rgb.percent(args);
|
|
1581
|
+
},
|
|
1582
|
+
|
|
1583
|
+
array() {
|
|
1584
|
+
return this.valpha === 1 ? this.color.slice() : this.color.concat(this.valpha);
|
|
1585
|
+
},
|
|
1586
|
+
|
|
1587
|
+
object() {
|
|
1588
|
+
const result = {};
|
|
1589
|
+
const channels = colorConvert[this.model].channels;
|
|
1590
|
+
const labels = colorConvert[this.model].labels;
|
|
1591
|
+
|
|
1592
|
+
for (let i = 0; i < channels; i++) {
|
|
1593
|
+
result[labels[i]] = this.color[i];
|
|
1594
|
+
}
|
|
1595
|
+
|
|
1596
|
+
if (this.valpha !== 1) {
|
|
1597
|
+
result.alpha = this.valpha;
|
|
1598
|
+
}
|
|
1599
|
+
|
|
1600
|
+
return result;
|
|
1601
|
+
},
|
|
1602
|
+
|
|
1603
|
+
unitArray() {
|
|
1604
|
+
const rgb = this.rgb().color;
|
|
1605
|
+
rgb[0] /= 255;
|
|
1606
|
+
rgb[1] /= 255;
|
|
1607
|
+
rgb[2] /= 255;
|
|
1608
|
+
|
|
1609
|
+
if (this.valpha !== 1) {
|
|
1610
|
+
rgb.push(this.valpha);
|
|
1611
|
+
}
|
|
1612
|
+
|
|
1613
|
+
return rgb;
|
|
1614
|
+
},
|
|
1615
|
+
|
|
1616
|
+
unitObject() {
|
|
1617
|
+
const rgb = this.rgb().object();
|
|
1618
|
+
rgb.r /= 255;
|
|
1619
|
+
rgb.g /= 255;
|
|
1620
|
+
rgb.b /= 255;
|
|
1621
|
+
|
|
1622
|
+
if (this.valpha !== 1) {
|
|
1623
|
+
rgb.alpha = this.valpha;
|
|
1624
|
+
}
|
|
1625
|
+
|
|
1626
|
+
return rgb;
|
|
1627
|
+
},
|
|
1628
|
+
|
|
1629
|
+
round(places) {
|
|
1630
|
+
places = Math.max(places || 0, 0);
|
|
1631
|
+
return new Color(this.color.map(roundToPlace(places)).concat(this.valpha), this.model);
|
|
1632
|
+
},
|
|
1633
|
+
|
|
1634
|
+
alpha(value) {
|
|
1635
|
+
if (arguments.length > 0) {
|
|
1636
|
+
return new Color(this.color.concat(Math.max(0, Math.min(1, value))), this.model);
|
|
1637
|
+
}
|
|
1638
|
+
|
|
1639
|
+
return this.valpha;
|
|
1640
|
+
},
|
|
1641
|
+
|
|
1642
|
+
// Rgb
|
|
1643
|
+
red: getset('rgb', 0, maxfn(255)),
|
|
1644
|
+
green: getset('rgb', 1, maxfn(255)),
|
|
1645
|
+
blue: getset('rgb', 2, maxfn(255)),
|
|
1646
|
+
|
|
1647
|
+
hue: getset(['hsl', 'hsv', 'hsl', 'hwb', 'hcg'], 0, value => ((value % 360) + 360) % 360),
|
|
1648
|
+
|
|
1649
|
+
saturationl: getset('hsl', 1, maxfn(100)),
|
|
1650
|
+
lightness: getset('hsl', 2, maxfn(100)),
|
|
1651
|
+
|
|
1652
|
+
saturationv: getset('hsv', 1, maxfn(100)),
|
|
1653
|
+
value: getset('hsv', 2, maxfn(100)),
|
|
1654
|
+
|
|
1655
|
+
chroma: getset('hcg', 1, maxfn(100)),
|
|
1656
|
+
gray: getset('hcg', 2, maxfn(100)),
|
|
1657
|
+
|
|
1658
|
+
white: getset('hwb', 1, maxfn(100)),
|
|
1659
|
+
wblack: getset('hwb', 2, maxfn(100)),
|
|
1660
|
+
|
|
1661
|
+
cyan: getset('cmyk', 0, maxfn(100)),
|
|
1662
|
+
magenta: getset('cmyk', 1, maxfn(100)),
|
|
1663
|
+
yellow: getset('cmyk', 2, maxfn(100)),
|
|
1664
|
+
black: getset('cmyk', 3, maxfn(100)),
|
|
1665
|
+
|
|
1666
|
+
x: getset('xyz', 0, maxfn(100)),
|
|
1667
|
+
y: getset('xyz', 1, maxfn(100)),
|
|
1668
|
+
z: getset('xyz', 2, maxfn(100)),
|
|
1669
|
+
|
|
1670
|
+
l: getset('lab', 0, maxfn(100)),
|
|
1671
|
+
a: getset('lab', 1),
|
|
1672
|
+
b: getset('lab', 2),
|
|
1673
|
+
|
|
1674
|
+
keyword(value) {
|
|
1675
|
+
if (arguments.length > 0) {
|
|
1676
|
+
return new Color(value);
|
|
1677
|
+
}
|
|
1678
|
+
|
|
1679
|
+
return colorConvert[this.model].keyword(this.color);
|
|
1680
|
+
},
|
|
1681
|
+
|
|
1682
|
+
hex(value) {
|
|
1683
|
+
if (arguments.length > 0) {
|
|
1684
|
+
return new Color(value);
|
|
1685
|
+
}
|
|
1686
|
+
|
|
1687
|
+
return colorString.to.hex(this.rgb().round().color);
|
|
1688
|
+
},
|
|
1689
|
+
|
|
1690
|
+
rgbNumber() {
|
|
1691
|
+
const rgb = this.rgb().color;
|
|
1692
|
+
return ((rgb[0] & 0xFF) << 16) | ((rgb[1] & 0xFF) << 8) | (rgb[2] & 0xFF);
|
|
1693
|
+
},
|
|
1694
|
+
|
|
1695
|
+
luminosity() {
|
|
1696
|
+
// http://www.w3.org/TR/WCAG20/#relativeluminancedef
|
|
1697
|
+
const rgb = this.rgb().color;
|
|
1698
|
+
|
|
1699
|
+
const lum = [];
|
|
1700
|
+
for (const [i, element] of rgb.entries()) {
|
|
1701
|
+
const chan = element / 255;
|
|
1702
|
+
lum[i] = (chan <= 0.039_28) ? chan / 12.92 : ((chan + 0.055) / 1.055) ** 2.4;
|
|
1703
|
+
}
|
|
1704
|
+
|
|
1705
|
+
return 0.2126 * lum[0] + 0.7152 * lum[1] + 0.0722 * lum[2];
|
|
1706
|
+
},
|
|
1707
|
+
|
|
1708
|
+
contrast(color2) {
|
|
1709
|
+
// http://www.w3.org/TR/WCAG20/#contrast-ratiodef
|
|
1710
|
+
const lum1 = this.luminosity();
|
|
1711
|
+
const lum2 = color2.luminosity();
|
|
1712
|
+
|
|
1713
|
+
if (lum1 > lum2) {
|
|
1714
|
+
return (lum1 + 0.05) / (lum2 + 0.05);
|
|
1715
|
+
}
|
|
1716
|
+
|
|
1717
|
+
return (lum2 + 0.05) / (lum1 + 0.05);
|
|
1718
|
+
},
|
|
1719
|
+
|
|
1720
|
+
level(color2) {
|
|
1721
|
+
const contrastRatio = this.contrast(color2);
|
|
1722
|
+
if (contrastRatio >= 7.1) {
|
|
1723
|
+
return 'AAA';
|
|
1724
|
+
}
|
|
1725
|
+
|
|
1726
|
+
return (contrastRatio >= 4.5) ? 'AA' : '';
|
|
1727
|
+
},
|
|
1728
|
+
|
|
1729
|
+
isDark() {
|
|
1730
|
+
// YIQ equation from http://24ways.org/2010/calculating-color-contrast
|
|
1731
|
+
const rgb = this.rgb().color;
|
|
1732
|
+
const yiq = (rgb[0] * 299 + rgb[1] * 587 + rgb[2] * 114) / 1000;
|
|
1733
|
+
return yiq < 128;
|
|
1734
|
+
},
|
|
1735
|
+
|
|
1736
|
+
isLight() {
|
|
1737
|
+
return !this.isDark();
|
|
1738
|
+
},
|
|
1739
|
+
|
|
1740
|
+
negate() {
|
|
1741
|
+
const rgb = this.rgb();
|
|
1742
|
+
for (let i = 0; i < 3; i++) {
|
|
1743
|
+
rgb.color[i] = 255 - rgb.color[i];
|
|
1744
|
+
}
|
|
1745
|
+
|
|
1746
|
+
return rgb;
|
|
1747
|
+
},
|
|
1748
|
+
|
|
1749
|
+
lighten(ratio) {
|
|
1750
|
+
const hsl = this.hsl();
|
|
1751
|
+
hsl.color[2] += hsl.color[2] * ratio;
|
|
1752
|
+
return hsl;
|
|
1753
|
+
},
|
|
1754
|
+
|
|
1755
|
+
darken(ratio) {
|
|
1756
|
+
const hsl = this.hsl();
|
|
1757
|
+
hsl.color[2] -= hsl.color[2] * ratio;
|
|
1758
|
+
return hsl;
|
|
1759
|
+
},
|
|
1760
|
+
|
|
1761
|
+
saturate(ratio) {
|
|
1762
|
+
const hsl = this.hsl();
|
|
1763
|
+
hsl.color[1] += hsl.color[1] * ratio;
|
|
1764
|
+
return hsl;
|
|
1765
|
+
},
|
|
1766
|
+
|
|
1767
|
+
desaturate(ratio) {
|
|
1768
|
+
const hsl = this.hsl();
|
|
1769
|
+
hsl.color[1] -= hsl.color[1] * ratio;
|
|
1770
|
+
return hsl;
|
|
1771
|
+
},
|
|
1772
|
+
|
|
1773
|
+
whiten(ratio) {
|
|
1774
|
+
const hwb = this.hwb();
|
|
1775
|
+
hwb.color[1] += hwb.color[1] * ratio;
|
|
1776
|
+
return hwb;
|
|
1777
|
+
},
|
|
1778
|
+
|
|
1779
|
+
blacken(ratio) {
|
|
1780
|
+
const hwb = this.hwb();
|
|
1781
|
+
hwb.color[2] += hwb.color[2] * ratio;
|
|
1782
|
+
return hwb;
|
|
1783
|
+
},
|
|
1784
|
+
|
|
1785
|
+
grayscale() {
|
|
1786
|
+
// http://en.wikipedia.org/wiki/Grayscale#Converting_color_to_grayscale
|
|
1787
|
+
const rgb = this.rgb().color;
|
|
1788
|
+
const value = rgb[0] * 0.3 + rgb[1] * 0.59 + rgb[2] * 0.11;
|
|
1789
|
+
return Color.rgb(value, value, value);
|
|
1790
|
+
},
|
|
1791
|
+
|
|
1792
|
+
fade(ratio) {
|
|
1793
|
+
return this.alpha(this.valpha - (this.valpha * ratio));
|
|
1794
|
+
},
|
|
1795
|
+
|
|
1796
|
+
opaquer(ratio) {
|
|
1797
|
+
return this.alpha(this.valpha + (this.valpha * ratio));
|
|
1798
|
+
},
|
|
1799
|
+
|
|
1800
|
+
rotate(degrees) {
|
|
1801
|
+
const hsl = this.hsl();
|
|
1802
|
+
let hue = hsl.color[0];
|
|
1803
|
+
hue = (hue + degrees) % 360;
|
|
1804
|
+
hue = hue < 0 ? 360 + hue : hue;
|
|
1805
|
+
hsl.color[0] = hue;
|
|
1806
|
+
return hsl;
|
|
1807
|
+
},
|
|
1808
|
+
|
|
1809
|
+
mix(mixinColor, weight) {
|
|
1810
|
+
// Ported from sass implementation in C
|
|
1811
|
+
// https://github.com/sass/libsass/blob/0e6b4a2850092356aa3ece07c6b249f0221caced/functions.cpp#L209
|
|
1812
|
+
if (!mixinColor || !mixinColor.rgb) {
|
|
1813
|
+
throw new Error('Argument to "mix" was not a Color instance, but rather an instance of ' + typeof mixinColor);
|
|
1814
|
+
}
|
|
1815
|
+
|
|
1816
|
+
const color1 = mixinColor.rgb();
|
|
1817
|
+
const color2 = this.rgb();
|
|
1818
|
+
const p = weight === undefined ? 0.5 : weight;
|
|
1819
|
+
|
|
1820
|
+
const w = 2 * p - 1;
|
|
1821
|
+
const a = color1.alpha() - color2.alpha();
|
|
1822
|
+
|
|
1823
|
+
const w1 = (((w * a === -1) ? w : (w + a) / (1 + w * a)) + 1) / 2;
|
|
1824
|
+
const w2 = 1 - w1;
|
|
1825
|
+
|
|
1826
|
+
return Color.rgb(
|
|
1827
|
+
w1 * color1.red() + w2 * color2.red(),
|
|
1828
|
+
w1 * color1.green() + w2 * color2.green(),
|
|
1829
|
+
w1 * color1.blue() + w2 * color2.blue(),
|
|
1830
|
+
color1.alpha() * p + color2.alpha() * (1 - p));
|
|
1831
|
+
},
|
|
1832
|
+
};
|
|
1833
|
+
|
|
1834
|
+
// Model conversion methods and static constructors
|
|
1835
|
+
for (const model of Object.keys(colorConvert)) {
|
|
1836
|
+
if (skippedModels.includes(model)) {
|
|
1837
|
+
continue;
|
|
1838
|
+
}
|
|
1839
|
+
|
|
1840
|
+
const channels = colorConvert[model].channels;
|
|
1841
|
+
|
|
1842
|
+
// Conversion methods
|
|
1843
|
+
Color.prototype[model] = function () {
|
|
1844
|
+
if (this.model === model) {
|
|
1845
|
+
return new Color(this);
|
|
1846
|
+
}
|
|
1847
|
+
|
|
1848
|
+
if (arguments.length > 0) {
|
|
1849
|
+
return new Color(arguments, model);
|
|
1850
|
+
}
|
|
1851
|
+
|
|
1852
|
+
const newAlpha = typeof arguments[channels] === 'number' ? channels : this.valpha;
|
|
1853
|
+
return new Color(assertArray(colorConvert[this.model][model].raw(this.color)).concat(newAlpha), model);
|
|
1854
|
+
};
|
|
1855
|
+
|
|
1856
|
+
// 'static' construction methods
|
|
1857
|
+
Color[model] = function (color) {
|
|
1858
|
+
if (typeof color === 'number') {
|
|
1859
|
+
color = zeroArray(_slice.call(arguments), channels);
|
|
1860
|
+
}
|
|
1861
|
+
|
|
1862
|
+
return new Color(color, model);
|
|
1863
|
+
};
|
|
1864
|
+
}
|
|
1865
|
+
|
|
1866
|
+
function roundTo(number, places) {
|
|
1867
|
+
return Number(number.toFixed(places));
|
|
1868
|
+
}
|
|
1869
|
+
|
|
1870
|
+
function roundToPlace(places) {
|
|
1871
|
+
return function (number) {
|
|
1872
|
+
return roundTo(number, places);
|
|
1873
|
+
};
|
|
1874
|
+
}
|
|
1875
|
+
|
|
1876
|
+
function getset(model, channel, modifier) {
|
|
1877
|
+
model = Array.isArray(model) ? model : [model];
|
|
1878
|
+
|
|
1879
|
+
for (const m of model) {
|
|
1880
|
+
(limiters[m] || (limiters[m] = []))[channel] = modifier;
|
|
1881
|
+
}
|
|
1882
|
+
|
|
1883
|
+
model = model[0];
|
|
1884
|
+
|
|
1885
|
+
return function (value) {
|
|
1886
|
+
let result;
|
|
1887
|
+
|
|
1888
|
+
if (arguments.length > 0) {
|
|
1889
|
+
if (modifier) {
|
|
1890
|
+
value = modifier(value);
|
|
1891
|
+
}
|
|
1892
|
+
|
|
1893
|
+
result = this[model]();
|
|
1894
|
+
result.color[channel] = value;
|
|
1895
|
+
return result;
|
|
1896
|
+
}
|
|
1897
|
+
|
|
1898
|
+
result = this[model]().color[channel];
|
|
1899
|
+
if (modifier) {
|
|
1900
|
+
result = modifier(result);
|
|
1901
|
+
}
|
|
1902
|
+
|
|
1903
|
+
return result;
|
|
1904
|
+
};
|
|
1905
|
+
}
|
|
1906
|
+
|
|
1907
|
+
function maxfn(max) {
|
|
1908
|
+
return function (v) {
|
|
1909
|
+
return Math.max(0, Math.min(max, v));
|
|
1910
|
+
};
|
|
1911
|
+
}
|
|
1912
|
+
|
|
1913
|
+
function assertArray(value) {
|
|
1914
|
+
return Array.isArray(value) ? value : [value];
|
|
1915
|
+
}
|
|
1916
|
+
|
|
1917
|
+
function zeroArray(array, length) {
|
|
1918
|
+
for (let i = 0; i < length; i++) {
|
|
1919
|
+
if (typeof array[i] !== 'number') {
|
|
1920
|
+
array[i] = 0;
|
|
1921
|
+
}
|
|
1922
|
+
}
|
|
1923
|
+
|
|
1924
|
+
return array;
|
|
1925
|
+
}
|
|
1926
|
+
|
|
1927
|
+
var color = Color;
|
|
1928
|
+
|
|
1929
|
+
/*
|
|
1930
|
+
object-assign
|
|
1931
|
+
(c) Sindre Sorhus
|
|
1932
|
+
@license MIT
|
|
1933
|
+
*/
|
|
1934
|
+
|
|
1935
|
+
'use strict';
|
|
1936
|
+
/* eslint-disable no-unused-vars */
|
|
1937
|
+
var getOwnPropertySymbols = Object.getOwnPropertySymbols;
|
|
1938
|
+
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
1939
|
+
var propIsEnumerable = Object.prototype.propertyIsEnumerable;
|
|
1940
|
+
|
|
1941
|
+
function toObject(val) {
|
|
1942
|
+
if (val === null || val === undefined) {
|
|
1943
|
+
throw new TypeError('Object.assign cannot be called with null or undefined');
|
|
1944
|
+
}
|
|
1945
|
+
|
|
1946
|
+
return Object(val);
|
|
1947
|
+
}
|
|
1948
|
+
|
|
1949
|
+
function shouldUseNative() {
|
|
1950
|
+
try {
|
|
1951
|
+
if (!Object.assign) {
|
|
1952
|
+
return false;
|
|
1953
|
+
}
|
|
1954
|
+
|
|
1955
|
+
// Detect buggy property enumeration order in older V8 versions.
|
|
1956
|
+
|
|
1957
|
+
// https://bugs.chromium.org/p/v8/issues/detail?id=4118
|
|
1958
|
+
var test1 = new String('abc'); // eslint-disable-line no-new-wrappers
|
|
1959
|
+
test1[5] = 'de';
|
|
1960
|
+
if (Object.getOwnPropertyNames(test1)[0] === '5') {
|
|
1961
|
+
return false;
|
|
1962
|
+
}
|
|
1963
|
+
|
|
1964
|
+
// https://bugs.chromium.org/p/v8/issues/detail?id=3056
|
|
1965
|
+
var test2 = {};
|
|
1966
|
+
for (var i = 0; i < 10; i++) {
|
|
1967
|
+
test2['_' + String.fromCharCode(i)] = i;
|
|
1968
|
+
}
|
|
1969
|
+
var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
|
|
1970
|
+
return test2[n];
|
|
1971
|
+
});
|
|
1972
|
+
if (order2.join('') !== '0123456789') {
|
|
1973
|
+
return false;
|
|
1974
|
+
}
|
|
1975
|
+
|
|
1976
|
+
// https://bugs.chromium.org/p/v8/issues/detail?id=3056
|
|
1977
|
+
var test3 = {};
|
|
1978
|
+
'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
|
|
1979
|
+
test3[letter] = letter;
|
|
1980
|
+
});
|
|
1981
|
+
if (Object.keys(Object.assign({}, test3)).join('') !==
|
|
1982
|
+
'abcdefghijklmnopqrst') {
|
|
1983
|
+
return false;
|
|
1984
|
+
}
|
|
1985
|
+
|
|
1986
|
+
return true;
|
|
1987
|
+
} catch (err) {
|
|
1988
|
+
// We don't expect any of the above to throw, but better to be safe.
|
|
1989
|
+
return false;
|
|
1990
|
+
}
|
|
1991
|
+
}
|
|
1992
|
+
|
|
1993
|
+
var objectAssign = shouldUseNative() ? Object.assign : function (target, source) {
|
|
1994
|
+
var from;
|
|
1995
|
+
var to = toObject(target);
|
|
1996
|
+
var symbols;
|
|
1997
|
+
|
|
1998
|
+
for (var s = 1; s < arguments.length; s++) {
|
|
1999
|
+
from = Object(arguments[s]);
|
|
2000
|
+
|
|
2001
|
+
for (var key in from) {
|
|
2002
|
+
if (hasOwnProperty.call(from, key)) {
|
|
2003
|
+
to[key] = from[key];
|
|
2004
|
+
}
|
|
2005
|
+
}
|
|
2006
|
+
|
|
2007
|
+
if (getOwnPropertySymbols) {
|
|
2008
|
+
symbols = getOwnPropertySymbols(from);
|
|
2009
|
+
for (var i = 0; i < symbols.length; i++) {
|
|
2010
|
+
if (propIsEnumerable.call(from, symbols[i])) {
|
|
2011
|
+
to[symbols[i]] = from[symbols[i]];
|
|
2012
|
+
}
|
|
2013
|
+
}
|
|
2014
|
+
}
|
|
2015
|
+
}
|
|
2016
|
+
|
|
2017
|
+
return to;
|
|
2018
|
+
};
|
|
2019
|
+
|
|
2020
|
+
var sheet = createCommonjsModule(function (module, exports) {
|
|
2021
|
+
'use strict';
|
|
2022
|
+
|
|
2023
|
+
Object.defineProperty(exports, "__esModule", {
|
|
2024
|
+
value: true
|
|
2025
|
+
});
|
|
2026
|
+
exports.StyleSheet = StyleSheet;
|
|
2027
|
+
|
|
2028
|
+
|
|
2029
|
+
|
|
2030
|
+
var _objectAssign2 = _interopRequireDefault(objectAssign);
|
|
2031
|
+
|
|
2032
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
2033
|
+
|
|
2034
|
+
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
|
|
2035
|
+
|
|
2036
|
+
/*
|
|
2037
|
+
|
|
2038
|
+
high performance StyleSheet for css-in-js systems
|
|
2039
|
+
|
|
2040
|
+
- uses multiple style tags behind the scenes for millions of rules
|
|
2041
|
+
- uses `insertRule` for appending in production for *much* faster performance
|
|
2042
|
+
- 'polyfills' on server side
|
|
2043
|
+
|
|
2044
|
+
|
|
2045
|
+
// usage
|
|
2046
|
+
|
|
2047
|
+
import StyleSheet from 'glamor/lib/sheet'
|
|
2048
|
+
let styleSheet = new StyleSheet()
|
|
2049
|
+
|
|
2050
|
+
styleSheet.inject()
|
|
2051
|
+
- 'injects' the stylesheet into the page (or into memory if on server)
|
|
2052
|
+
|
|
2053
|
+
styleSheet.insert('#box { border: 1px solid red; }')
|
|
2054
|
+
- appends a css rule into the stylesheet
|
|
2055
|
+
|
|
2056
|
+
styleSheet.flush()
|
|
2057
|
+
- empties the stylesheet of all its contents
|
|
2058
|
+
|
|
2059
|
+
|
|
2060
|
+
*/
|
|
2061
|
+
|
|
2062
|
+
function last(arr) {
|
|
2063
|
+
return arr[arr.length - 1];
|
|
2064
|
+
}
|
|
2065
|
+
|
|
2066
|
+
function sheetForTag(tag) {
|
|
2067
|
+
if (tag.sheet) {
|
|
2068
|
+
return tag.sheet;
|
|
2069
|
+
}
|
|
2070
|
+
|
|
2071
|
+
// this weirdness brought to you by firefox
|
|
2072
|
+
for (var i = 0; i < document.styleSheets.length; i++) {
|
|
2073
|
+
if (document.styleSheets[i].ownerNode === tag) {
|
|
2074
|
+
return document.styleSheets[i];
|
|
2075
|
+
}
|
|
2076
|
+
}
|
|
2077
|
+
}
|
|
2078
|
+
|
|
2079
|
+
var isBrowser = typeof window !== 'undefined';
|
|
2080
|
+
var isDev = "development" === 'development' || !"development"; //(x => (x === 'development') || !x)("development")
|
|
2081
|
+
var isTest = "development" === 'test';
|
|
2082
|
+
|
|
2083
|
+
var oldIE = function () {
|
|
2084
|
+
if (isBrowser) {
|
|
2085
|
+
var div = document.createElement('div');
|
|
2086
|
+
div.innerHTML = '<!--[if lt IE 10]><i></i><![endif]-->';
|
|
2087
|
+
return div.getElementsByTagName('i').length === 1;
|
|
2088
|
+
}
|
|
2089
|
+
}();
|
|
2090
|
+
|
|
2091
|
+
function makeStyleTag() {
|
|
2092
|
+
var tag = document.createElement('style');
|
|
2093
|
+
tag.type = 'text/css';
|
|
2094
|
+
tag.setAttribute('data-glamor', '');
|
|
2095
|
+
tag.appendChild(document.createTextNode(''));
|
|
2096
|
+
(document.head || document.getElementsByTagName('head')[0]).appendChild(tag);
|
|
2097
|
+
return tag;
|
|
2098
|
+
}
|
|
2099
|
+
|
|
2100
|
+
function StyleSheet() {
|
|
2101
|
+
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
2102
|
+
_ref$speedy = _ref.speedy,
|
|
2103
|
+
speedy = _ref$speedy === undefined ? !isDev && !isTest : _ref$speedy,
|
|
2104
|
+
_ref$maxLength = _ref.maxLength,
|
|
2105
|
+
maxLength = _ref$maxLength === undefined ? isBrowser && oldIE ? 4000 : 65000 : _ref$maxLength;
|
|
2106
|
+
|
|
2107
|
+
this.isSpeedy = speedy; // the big drawback here is that the css won't be editable in devtools
|
|
2108
|
+
this.sheet = undefined;
|
|
2109
|
+
this.tags = [];
|
|
2110
|
+
this.maxLength = maxLength;
|
|
2111
|
+
this.ctr = 0;
|
|
2112
|
+
}
|
|
2113
|
+
|
|
2114
|
+
(0, _objectAssign2.default)(StyleSheet.prototype, {
|
|
2115
|
+
getSheet: function getSheet() {
|
|
2116
|
+
return sheetForTag(last(this.tags));
|
|
2117
|
+
},
|
|
2118
|
+
inject: function inject() {
|
|
2119
|
+
var _this = this;
|
|
2120
|
+
|
|
2121
|
+
if (this.injected) {
|
|
2122
|
+
throw new Error('already injected stylesheet!');
|
|
2123
|
+
}
|
|
2124
|
+
if (isBrowser) {
|
|
2125
|
+
this.tags[0] = makeStyleTag();
|
|
2126
|
+
} else {
|
|
2127
|
+
// server side 'polyfill'. just enough behavior to be useful.
|
|
2128
|
+
this.sheet = {
|
|
2129
|
+
cssRules: [],
|
|
2130
|
+
insertRule: function insertRule(rule) {
|
|
2131
|
+
// enough 'spec compliance' to be able to extract the rules later
|
|
2132
|
+
// in other words, just the cssText field
|
|
2133
|
+
_this.sheet.cssRules.push({ cssText: rule });
|
|
2134
|
+
}
|
|
2135
|
+
};
|
|
2136
|
+
}
|
|
2137
|
+
this.injected = true;
|
|
2138
|
+
},
|
|
2139
|
+
speedy: function speedy(bool) {
|
|
2140
|
+
if (this.ctr !== 0) {
|
|
2141
|
+
throw new Error('cannot change speedy mode after inserting any rule to sheet. Either call speedy(' + bool + ') earlier in your app, or call flush() before speedy(' + bool + ')');
|
|
2142
|
+
}
|
|
2143
|
+
this.isSpeedy = !!bool;
|
|
2144
|
+
},
|
|
2145
|
+
_insert: function _insert(rule) {
|
|
2146
|
+
// this weirdness for perf, and chrome's weird bug
|
|
2147
|
+
// https://stackoverflow.com/questions/20007992/chrome-suddenly-stopped-accepting-insertrule
|
|
2148
|
+
try {
|
|
2149
|
+
var sheet = this.getSheet();
|
|
2150
|
+
sheet.insertRule(rule, rule.indexOf('@import') !== -1 ? 0 : sheet.cssRules.length);
|
|
2151
|
+
} catch (e) {
|
|
2152
|
+
if (isDev) {
|
|
2153
|
+
// might need beter dx for this
|
|
2154
|
+
console.warn('whoops, illegal rule inserted', rule); //eslint-disable-line no-console
|
|
2155
|
+
}
|
|
2156
|
+
}
|
|
2157
|
+
},
|
|
2158
|
+
insert: function insert(rule) {
|
|
2159
|
+
|
|
2160
|
+
if (isBrowser) {
|
|
2161
|
+
// this is the ultrafast version, works across browsers
|
|
2162
|
+
if (this.isSpeedy && this.getSheet().insertRule) {
|
|
2163
|
+
this._insert(rule);
|
|
2164
|
+
}
|
|
2165
|
+
// more browser weirdness. I don't even know
|
|
2166
|
+
// else if(this.tags.length > 0 && this.tags::last().styleSheet) {
|
|
2167
|
+
// this.tags::last().styleSheet.cssText+= rule
|
|
2168
|
+
// }
|
|
2169
|
+
else {
|
|
2170
|
+
if (rule.indexOf('@import') !== -1) {
|
|
2171
|
+
var tag = last(this.tags);
|
|
2172
|
+
tag.insertBefore(document.createTextNode(rule), tag.firstChild);
|
|
2173
|
+
} else {
|
|
2174
|
+
last(this.tags).appendChild(document.createTextNode(rule));
|
|
2175
|
+
}
|
|
2176
|
+
}
|
|
2177
|
+
} else {
|
|
2178
|
+
// server side is pretty simple
|
|
2179
|
+
this.sheet.insertRule(rule, rule.indexOf('@import') !== -1 ? 0 : this.sheet.cssRules.length);
|
|
2180
|
+
}
|
|
2181
|
+
|
|
2182
|
+
this.ctr++;
|
|
2183
|
+
if (isBrowser && this.ctr % this.maxLength === 0) {
|
|
2184
|
+
this.tags.push(makeStyleTag());
|
|
2185
|
+
}
|
|
2186
|
+
return this.ctr - 1;
|
|
2187
|
+
},
|
|
2188
|
+
|
|
2189
|
+
// commenting this out till we decide on v3's decision
|
|
2190
|
+
// _replace(index, rule) {
|
|
2191
|
+
// // this weirdness for perf, and chrome's weird bug
|
|
2192
|
+
// // https://stackoverflow.com/questions/20007992/chrome-suddenly-stopped-accepting-insertrule
|
|
2193
|
+
// try {
|
|
2194
|
+
// let sheet = this.getSheet()
|
|
2195
|
+
// sheet.deleteRule(index) // todo - correct index here
|
|
2196
|
+
// sheet.insertRule(rule, index)
|
|
2197
|
+
// }
|
|
2198
|
+
// catch(e) {
|
|
2199
|
+
// if(isDev) {
|
|
2200
|
+
// // might need beter dx for this
|
|
2201
|
+
// console.warn('whoops, problem replacing rule', rule) //eslint-disable-line no-console
|
|
2202
|
+
// }
|
|
2203
|
+
// }
|
|
2204
|
+
|
|
2205
|
+
// }
|
|
2206
|
+
// replace(index, rule) {
|
|
2207
|
+
// if(isBrowser) {
|
|
2208
|
+
// if(this.isSpeedy && this.getSheet().insertRule) {
|
|
2209
|
+
// this._replace(index, rule)
|
|
2210
|
+
// }
|
|
2211
|
+
// else {
|
|
2212
|
+
// let _slot = Math.floor((index + this.maxLength) / this.maxLength) - 1
|
|
2213
|
+
// let _index = (index % this.maxLength) + 1
|
|
2214
|
+
// let tag = this.tags[_slot]
|
|
2215
|
+
// tag.replaceChild(document.createTextNode(rule), tag.childNodes[_index])
|
|
2216
|
+
// }
|
|
2217
|
+
// }
|
|
2218
|
+
// else {
|
|
2219
|
+
// let rules = this.sheet.cssRules
|
|
2220
|
+
// this.sheet.cssRules = [ ...rules.slice(0, index), { cssText: rule }, ...rules.slice(index + 1) ]
|
|
2221
|
+
// }
|
|
2222
|
+
// }
|
|
2223
|
+
delete: function _delete(index) {
|
|
2224
|
+
// we insert a blank rule when 'deleting' so previously returned indexes remain stable
|
|
2225
|
+
return this.replace(index, '');
|
|
2226
|
+
},
|
|
2227
|
+
flush: function flush() {
|
|
2228
|
+
if (isBrowser) {
|
|
2229
|
+
this.tags.forEach(function (tag) {
|
|
2230
|
+
return tag.parentNode.removeChild(tag);
|
|
2231
|
+
});
|
|
2232
|
+
this.tags = [];
|
|
2233
|
+
this.sheet = null;
|
|
2234
|
+
this.ctr = 0;
|
|
2235
|
+
// todo - look for remnants in document.styleSheets
|
|
2236
|
+
} else {
|
|
2237
|
+
// simpler on server
|
|
2238
|
+
this.sheet.cssRules = [];
|
|
2239
|
+
}
|
|
2240
|
+
this.injected = false;
|
|
2241
|
+
},
|
|
2242
|
+
rules: function rules() {
|
|
2243
|
+
if (!isBrowser) {
|
|
2244
|
+
return this.sheet.cssRules;
|
|
2245
|
+
}
|
|
2246
|
+
var arr = [];
|
|
2247
|
+
this.tags.forEach(function (tag) {
|
|
2248
|
+
return arr.splice.apply(arr, [arr.length, 0].concat(_toConsumableArray(Array.from(sheetForTag(tag).cssRules))));
|
|
2249
|
+
});
|
|
2250
|
+
return arr;
|
|
2251
|
+
}
|
|
2252
|
+
});
|
|
2253
|
+
});
|
|
2254
|
+
|
|
2255
|
+
const sheet$1 = /*@__PURE__*/getDefaultExportFromCjs(sheet);
|
|
2256
|
+
|
|
2257
|
+
"use strict";
|
|
2258
|
+
|
|
2259
|
+
/**
|
|
2260
|
+
* Copyright (c) 2013-present, Facebook, Inc.
|
|
2261
|
+
*
|
|
2262
|
+
* This source code is licensed under the MIT license found in the
|
|
2263
|
+
* LICENSE file in the root directory of this source tree.
|
|
2264
|
+
*
|
|
2265
|
+
* @typechecks
|
|
2266
|
+
*/
|
|
2267
|
+
|
|
2268
|
+
var _hyphenPattern = /-(.)/g;
|
|
2269
|
+
|
|
2270
|
+
/**
|
|
2271
|
+
* Camelcases a hyphenated string, for example:
|
|
2272
|
+
*
|
|
2273
|
+
* > camelize('background-color')
|
|
2274
|
+
* < "backgroundColor"
|
|
2275
|
+
*
|
|
2276
|
+
* @param {string} string
|
|
2277
|
+
* @return {string}
|
|
2278
|
+
*/
|
|
2279
|
+
function camelize(string) {
|
|
2280
|
+
return string.replace(_hyphenPattern, function (_, character) {
|
|
2281
|
+
return character.toUpperCase();
|
|
2282
|
+
});
|
|
2283
|
+
}
|
|
2284
|
+
|
|
2285
|
+
var camelize_1 = camelize;
|
|
2286
|
+
|
|
2287
|
+
/**
|
|
2288
|
+
* Copyright (c) 2013-present, Facebook, Inc.
|
|
2289
|
+
*
|
|
2290
|
+
* This source code is licensed under the MIT license found in the
|
|
2291
|
+
* LICENSE file in the root directory of this source tree.
|
|
2292
|
+
*
|
|
2293
|
+
* @typechecks
|
|
2294
|
+
*/
|
|
2295
|
+
|
|
2296
|
+
'use strict';
|
|
2297
|
+
|
|
2298
|
+
|
|
2299
|
+
|
|
2300
|
+
var msPattern$2 = /^-ms-/;
|
|
2301
|
+
|
|
2302
|
+
/**
|
|
2303
|
+
* Camelcases a hyphenated CSS property name, for example:
|
|
2304
|
+
*
|
|
2305
|
+
* > camelizeStyleName('background-color')
|
|
2306
|
+
* < "backgroundColor"
|
|
2307
|
+
* > camelizeStyleName('-moz-transition')
|
|
2308
|
+
* < "MozTransition"
|
|
2309
|
+
* > camelizeStyleName('-ms-transition')
|
|
2310
|
+
* < "msTransition"
|
|
2311
|
+
*
|
|
2312
|
+
* As Andi Smith suggests
|
|
2313
|
+
* (http://www.andismith.com/blog/2012/02/modernizr-prefixed/), an `-ms` prefix
|
|
2314
|
+
* is converted to lowercase `ms`.
|
|
2315
|
+
*
|
|
2316
|
+
* @param {string} string
|
|
2317
|
+
* @return {string}
|
|
2318
|
+
*/
|
|
2319
|
+
function camelizeStyleName(string) {
|
|
2320
|
+
return camelize_1(string.replace(msPattern$2, 'ms-'));
|
|
2321
|
+
}
|
|
2322
|
+
|
|
2323
|
+
var camelizeStyleName_1 = camelizeStyleName;
|
|
2324
|
+
|
|
2325
|
+
var CSSProperty_1 = createCommonjsModule(function (module, exports) {
|
|
2326
|
+
'use strict';
|
|
2327
|
+
|
|
2328
|
+
Object.defineProperty(exports, "__esModule", {
|
|
2329
|
+
value: true
|
|
2330
|
+
});
|
|
2331
|
+
/**
|
|
2332
|
+
* Copyright 2013-present, Facebook, Inc.
|
|
2333
|
+
* All rights reserved.
|
|
2334
|
+
*
|
|
2335
|
+
* This source code is licensed under the BSD-style license found in the
|
|
2336
|
+
* LICENSE file in the root directory of this source tree. An additional grant
|
|
2337
|
+
* of patent rights can be found in the PATENTS file in the same directory.
|
|
2338
|
+
*
|
|
2339
|
+
* @providesModule CSSProperty
|
|
2340
|
+
*/
|
|
2341
|
+
|
|
2342
|
+
/**
|
|
2343
|
+
* CSS properties which accept numbers but are not in units of "px".
|
|
2344
|
+
*/
|
|
2345
|
+
|
|
2346
|
+
var isUnitlessNumber = {
|
|
2347
|
+
animationIterationCount: true,
|
|
2348
|
+
borderImageOutset: true,
|
|
2349
|
+
borderImageSlice: true,
|
|
2350
|
+
borderImageWidth: true,
|
|
2351
|
+
boxFlex: true,
|
|
2352
|
+
boxFlexGroup: true,
|
|
2353
|
+
boxOrdinalGroup: true,
|
|
2354
|
+
columnCount: true,
|
|
2355
|
+
flex: true,
|
|
2356
|
+
flexGrow: true,
|
|
2357
|
+
flexPositive: true,
|
|
2358
|
+
flexShrink: true,
|
|
2359
|
+
flexNegative: true,
|
|
2360
|
+
flexOrder: true,
|
|
2361
|
+
gridRow: true,
|
|
2362
|
+
gridRowStart: true,
|
|
2363
|
+
gridRowEnd: true,
|
|
2364
|
+
gridColumn: true,
|
|
2365
|
+
gridColumnStart: true,
|
|
2366
|
+
gridColumnEnd: true,
|
|
2367
|
+
fontWeight: true,
|
|
2368
|
+
lineClamp: true,
|
|
2369
|
+
lineHeight: true,
|
|
2370
|
+
opacity: true,
|
|
2371
|
+
order: true,
|
|
2372
|
+
orphans: true,
|
|
2373
|
+
tabSize: true,
|
|
2374
|
+
widows: true,
|
|
2375
|
+
zIndex: true,
|
|
2376
|
+
zoom: true,
|
|
2377
|
+
|
|
2378
|
+
// SVG-related properties
|
|
2379
|
+
fillOpacity: true,
|
|
2380
|
+
floodOpacity: true,
|
|
2381
|
+
stopOpacity: true,
|
|
2382
|
+
strokeDasharray: true,
|
|
2383
|
+
strokeDashoffset: true,
|
|
2384
|
+
strokeMiterlimit: true,
|
|
2385
|
+
strokeOpacity: true,
|
|
2386
|
+
strokeWidth: true
|
|
2387
|
+
|
|
2388
|
+
/**
|
|
2389
|
+
* @param {string} prefix vendor-specific prefix, eg: Webkit
|
|
2390
|
+
* @param {string} key style name, eg: transitionDuration
|
|
2391
|
+
* @return {string} style name prefixed with `prefix`, properly camelCased, eg:
|
|
2392
|
+
* WebkitTransitionDuration
|
|
2393
|
+
*/
|
|
2394
|
+
};function prefixKey(prefix, key) {
|
|
2395
|
+
return prefix + key.charAt(0).toUpperCase() + key.substring(1);
|
|
2396
|
+
}
|
|
2397
|
+
|
|
2398
|
+
/**
|
|
2399
|
+
* Support style names that may come passed in prefixed by adding permutations
|
|
2400
|
+
* of vendor prefixes.
|
|
2401
|
+
*/
|
|
2402
|
+
var prefixes = ['Webkit', 'ms', 'Moz', 'O'];
|
|
2403
|
+
|
|
2404
|
+
// Using Object.keys here, or else the vanilla for-in loop makes IE8 go into an
|
|
2405
|
+
// infinite loop, because it iterates over the newly added props too.
|
|
2406
|
+
Object.keys(isUnitlessNumber).forEach(function (prop) {
|
|
2407
|
+
prefixes.forEach(function (prefix) {
|
|
2408
|
+
isUnitlessNumber[prefixKey(prefix, prop)] = isUnitlessNumber[prop];
|
|
2409
|
+
});
|
|
2410
|
+
});
|
|
2411
|
+
|
|
2412
|
+
/**
|
|
2413
|
+
* Most style properties can be unset by doing .style[prop] = '' but IE8
|
|
2414
|
+
* doesn't like doing that with shorthand properties so for the properties that
|
|
2415
|
+
* IE8 breaks on, which are listed here, we instead unset each of the
|
|
2416
|
+
* individual properties. See http://bugs.jquery.com/ticket/12385.
|
|
2417
|
+
* The 4-value 'clock' properties like margin, padding, border-width seem to
|
|
2418
|
+
* behave without any problems. Curiously, list-style works too without any
|
|
2419
|
+
* special prodding.
|
|
2420
|
+
*/
|
|
2421
|
+
var shorthandPropertyExpansions = {
|
|
2422
|
+
background: {
|
|
2423
|
+
backgroundAttachment: true,
|
|
2424
|
+
backgroundColor: true,
|
|
2425
|
+
backgroundImage: true,
|
|
2426
|
+
backgroundPositionX: true,
|
|
2427
|
+
backgroundPositionY: true,
|
|
2428
|
+
backgroundRepeat: true
|
|
2429
|
+
},
|
|
2430
|
+
backgroundPosition: {
|
|
2431
|
+
backgroundPositionX: true,
|
|
2432
|
+
backgroundPositionY: true
|
|
2433
|
+
},
|
|
2434
|
+
border: {
|
|
2435
|
+
borderWidth: true,
|
|
2436
|
+
borderStyle: true,
|
|
2437
|
+
borderColor: true
|
|
2438
|
+
},
|
|
2439
|
+
borderBottom: {
|
|
2440
|
+
borderBottomWidth: true,
|
|
2441
|
+
borderBottomStyle: true,
|
|
2442
|
+
borderBottomColor: true
|
|
2443
|
+
},
|
|
2444
|
+
borderLeft: {
|
|
2445
|
+
borderLeftWidth: true,
|
|
2446
|
+
borderLeftStyle: true,
|
|
2447
|
+
borderLeftColor: true
|
|
2448
|
+
},
|
|
2449
|
+
borderRight: {
|
|
2450
|
+
borderRightWidth: true,
|
|
2451
|
+
borderRightStyle: true,
|
|
2452
|
+
borderRightColor: true
|
|
2453
|
+
},
|
|
2454
|
+
borderTop: {
|
|
2455
|
+
borderTopWidth: true,
|
|
2456
|
+
borderTopStyle: true,
|
|
2457
|
+
borderTopColor: true
|
|
2458
|
+
},
|
|
2459
|
+
font: {
|
|
2460
|
+
fontStyle: true,
|
|
2461
|
+
fontVariant: true,
|
|
2462
|
+
fontWeight: true,
|
|
2463
|
+
fontSize: true,
|
|
2464
|
+
lineHeight: true,
|
|
2465
|
+
fontFamily: true
|
|
2466
|
+
},
|
|
2467
|
+
outline: {
|
|
2468
|
+
outlineWidth: true,
|
|
2469
|
+
outlineStyle: true,
|
|
2470
|
+
outlineColor: true
|
|
2471
|
+
}
|
|
2472
|
+
};
|
|
2473
|
+
|
|
2474
|
+
var CSSProperty = {
|
|
2475
|
+
isUnitlessNumber: isUnitlessNumber,
|
|
2476
|
+
shorthandPropertyExpansions: shorthandPropertyExpansions
|
|
2477
|
+
};
|
|
2478
|
+
|
|
2479
|
+
exports.default = CSSProperty;
|
|
2480
|
+
});
|
|
2481
|
+
|
|
2482
|
+
const CSSProperty = /*@__PURE__*/getDefaultExportFromCjs(CSSProperty_1);
|
|
2483
|
+
|
|
2484
|
+
"use strict";
|
|
2485
|
+
|
|
2486
|
+
/**
|
|
2487
|
+
* Copyright (c) 2013-present, Facebook, Inc.
|
|
2488
|
+
*
|
|
2489
|
+
* This source code is licensed under the MIT license found in the
|
|
2490
|
+
* LICENSE file in the root directory of this source tree.
|
|
2491
|
+
*
|
|
2492
|
+
*
|
|
2493
|
+
*/
|
|
2494
|
+
|
|
2495
|
+
function makeEmptyFunction(arg) {
|
|
2496
|
+
return function () {
|
|
2497
|
+
return arg;
|
|
2498
|
+
};
|
|
2499
|
+
}
|
|
2500
|
+
|
|
2501
|
+
/**
|
|
2502
|
+
* This function accepts and discards inputs; it has no side effects. This is
|
|
2503
|
+
* primarily useful idiomatically for overridable function endpoints which
|
|
2504
|
+
* always need to be callable, since JS lacks a null-call idiom ala Cocoa.
|
|
2505
|
+
*/
|
|
2506
|
+
var emptyFunction = function emptyFunction() {};
|
|
2507
|
+
|
|
2508
|
+
emptyFunction.thatReturns = makeEmptyFunction;
|
|
2509
|
+
emptyFunction.thatReturnsFalse = makeEmptyFunction(false);
|
|
2510
|
+
emptyFunction.thatReturnsTrue = makeEmptyFunction(true);
|
|
2511
|
+
emptyFunction.thatReturnsNull = makeEmptyFunction(null);
|
|
2512
|
+
emptyFunction.thatReturnsThis = function () {
|
|
2513
|
+
return this;
|
|
2514
|
+
};
|
|
2515
|
+
emptyFunction.thatReturnsArgument = function (arg) {
|
|
2516
|
+
return arg;
|
|
2517
|
+
};
|
|
2518
|
+
|
|
2519
|
+
var emptyFunction_1 = emptyFunction;
|
|
2520
|
+
|
|
2521
|
+
/**
|
|
2522
|
+
* Copyright (c) 2014-present, Facebook, Inc.
|
|
2523
|
+
*
|
|
2524
|
+
* This source code is licensed under the MIT license found in the
|
|
2525
|
+
* LICENSE file in the root directory of this source tree.
|
|
2526
|
+
*
|
|
2527
|
+
*/
|
|
2528
|
+
|
|
2529
|
+
'use strict';
|
|
2530
|
+
|
|
2531
|
+
|
|
2532
|
+
|
|
2533
|
+
/**
|
|
2534
|
+
* Similar to invariant but only logs a warning if the condition is not met.
|
|
2535
|
+
* This can be used to log issues in development environments in critical
|
|
2536
|
+
* paths. Removing the logging code for production environments will keep the
|
|
2537
|
+
* same logic and follow the same code paths.
|
|
2538
|
+
*/
|
|
2539
|
+
|
|
2540
|
+
var warning = emptyFunction_1;
|
|
2541
|
+
|
|
2542
|
+
if ("development" !== 'production') {
|
|
2543
|
+
var printWarning = function printWarning(format) {
|
|
2544
|
+
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
2545
|
+
args[_key - 1] = arguments[_key];
|
|
2546
|
+
}
|
|
2547
|
+
|
|
2548
|
+
var argIndex = 0;
|
|
2549
|
+
var message = 'Warning: ' + format.replace(/%s/g, function () {
|
|
2550
|
+
return args[argIndex++];
|
|
2551
|
+
});
|
|
2552
|
+
if (typeof console !== 'undefined') {
|
|
2553
|
+
console.error(message);
|
|
2554
|
+
}
|
|
2555
|
+
try {
|
|
2556
|
+
// --- Welcome to debugging React ---
|
|
2557
|
+
// This error was thrown as a convenience so that you can use this stack
|
|
2558
|
+
// to find the callsite that caused this warning to fire.
|
|
2559
|
+
throw new Error(message);
|
|
2560
|
+
} catch (x) {}
|
|
2561
|
+
};
|
|
2562
|
+
|
|
2563
|
+
warning = function warning(condition, format) {
|
|
2564
|
+
if (format === undefined) {
|
|
2565
|
+
throw new Error('`warning(condition, format, ...args)` requires a warning ' + 'message argument');
|
|
2566
|
+
}
|
|
2567
|
+
|
|
2568
|
+
if (format.indexOf('Failed Composite propType: ') === 0) {
|
|
2569
|
+
return; // Ignore CompositeComponent proptype check.
|
|
2570
|
+
}
|
|
2571
|
+
|
|
2572
|
+
if (!condition) {
|
|
2573
|
+
for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
|
|
2574
|
+
args[_key2 - 2] = arguments[_key2];
|
|
2575
|
+
}
|
|
2576
|
+
|
|
2577
|
+
printWarning.apply(undefined, [format].concat(args));
|
|
2578
|
+
}
|
|
2579
|
+
};
|
|
2580
|
+
}
|
|
2581
|
+
|
|
2582
|
+
var warning_1 = warning;
|
|
2583
|
+
|
|
2584
|
+
var dangerousStyleValue_1 = createCommonjsModule(function (module, exports) {
|
|
2585
|
+
'use strict';
|
|
2586
|
+
|
|
2587
|
+
Object.defineProperty(exports, "__esModule", {
|
|
2588
|
+
value: true
|
|
2589
|
+
});
|
|
2590
|
+
|
|
2591
|
+
|
|
2592
|
+
|
|
2593
|
+
var _CSSProperty2 = _interopRequireDefault(CSSProperty_1);
|
|
2594
|
+
|
|
2595
|
+
|
|
2596
|
+
|
|
2597
|
+
var _warning2 = _interopRequireDefault(warning_1);
|
|
2598
|
+
|
|
2599
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
2600
|
+
|
|
2601
|
+
/**
|
|
2602
|
+
* Copyright 2013-present, Facebook, Inc.
|
|
2603
|
+
* All rights reserved.
|
|
2604
|
+
*
|
|
2605
|
+
* This source code is licensed under the BSD-style license found in the
|
|
2606
|
+
* LICENSE file in the root directory of this source tree. An additional grant
|
|
2607
|
+
* of patent rights can be found in the PATENTS file in the same directory.
|
|
2608
|
+
*
|
|
2609
|
+
* @providesModule dangerousStyleValue
|
|
2610
|
+
*/
|
|
2611
|
+
|
|
2612
|
+
var isUnitlessNumber = _CSSProperty2.default.isUnitlessNumber;
|
|
2613
|
+
var styleWarnings = {};
|
|
2614
|
+
|
|
2615
|
+
/**
|
|
2616
|
+
* Convert a value into the proper css writable value. The style name `name`
|
|
2617
|
+
* should be logical (no hyphens), as specified
|
|
2618
|
+
* in `CSSProperty.isUnitlessNumber`.
|
|
2619
|
+
*
|
|
2620
|
+
* @param {string} name CSS property name such as `topMargin`.
|
|
2621
|
+
* @param {*} value CSS property value such as `10px`.
|
|
2622
|
+
* @param {ReactDOMComponent} component
|
|
2623
|
+
* @return {string} Normalized style value with dimensions applied.
|
|
2624
|
+
*/
|
|
2625
|
+
function dangerousStyleValue(name, value, component) {
|
|
2626
|
+
// Note that we've removed escapeTextForBrowser() calls here since the
|
|
2627
|
+
// whole string will be escaped when the attribute is injected into
|
|
2628
|
+
// the markup. If you provide unsafe user data here they can inject
|
|
2629
|
+
// arbitrary CSS which may be problematic (I couldn't repro this):
|
|
2630
|
+
// https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet
|
|
2631
|
+
// http://www.thespanner.co.uk/2007/11/26/ultimate-xss-css-injection/
|
|
2632
|
+
// This is not an XSS hole but instead a potential CSS injection issue
|
|
2633
|
+
// which has lead to a greater discussion about how we're going to
|
|
2634
|
+
// trust URLs moving forward. See #2115901
|
|
2635
|
+
|
|
2636
|
+
var isEmpty = value == null || typeof value === 'boolean' || value === '';
|
|
2637
|
+
if (isEmpty) {
|
|
2638
|
+
return '';
|
|
2639
|
+
}
|
|
2640
|
+
|
|
2641
|
+
var isNonNumeric = isNaN(value);
|
|
2642
|
+
if (isNonNumeric || value === 0 || isUnitlessNumber.hasOwnProperty(name) && isUnitlessNumber[name]) {
|
|
2643
|
+
return '' + value; // cast to string
|
|
2644
|
+
}
|
|
2645
|
+
|
|
2646
|
+
if (typeof value === 'string') {
|
|
2647
|
+
if ("development" !== 'production') {
|
|
2648
|
+
// Allow '0' to pass through without warning. 0 is already special and
|
|
2649
|
+
// doesn't require units, so we don't need to warn about it.
|
|
2650
|
+
if (component && value !== '0') {
|
|
2651
|
+
var owner = component._currentElement._owner;
|
|
2652
|
+
var ownerName = owner ? owner.getName() : null;
|
|
2653
|
+
if (ownerName && !styleWarnings[ownerName]) {
|
|
2654
|
+
styleWarnings[ownerName] = {};
|
|
2655
|
+
}
|
|
2656
|
+
var warned = false;
|
|
2657
|
+
if (ownerName) {
|
|
2658
|
+
var warnings = styleWarnings[ownerName];
|
|
2659
|
+
warned = warnings[name];
|
|
2660
|
+
if (!warned) {
|
|
2661
|
+
warnings[name] = true;
|
|
2662
|
+
}
|
|
2663
|
+
}
|
|
2664
|
+
if (!warned) {
|
|
2665
|
+
"development" !== 'production' ? (0, _warning2.default)(false, 'a `%s` tag (owner: `%s`) was passed a numeric string value ' + 'for CSS property `%s` (value: `%s`) which will be treated ' + 'as a unitless number in a future version of React.', component._currentElement.type, ownerName || 'unknown', name, value) : void 0;
|
|
2666
|
+
}
|
|
2667
|
+
}
|
|
2668
|
+
}
|
|
2669
|
+
value = value.trim();
|
|
2670
|
+
}
|
|
2671
|
+
return value + 'px';
|
|
2672
|
+
}
|
|
2673
|
+
|
|
2674
|
+
exports.default = dangerousStyleValue;
|
|
2675
|
+
});
|
|
2676
|
+
|
|
2677
|
+
const dangerousStyleValue = /*@__PURE__*/getDefaultExportFromCjs(dangerousStyleValue_1);
|
|
2678
|
+
|
|
2679
|
+
'use strict';
|
|
2680
|
+
|
|
2681
|
+
/**
|
|
2682
|
+
* Copyright (c) 2013-present, Facebook, Inc.
|
|
2683
|
+
*
|
|
2684
|
+
* This source code is licensed under the MIT license found in the
|
|
2685
|
+
* LICENSE file in the root directory of this source tree.
|
|
2686
|
+
*
|
|
2687
|
+
* @typechecks
|
|
2688
|
+
*/
|
|
2689
|
+
|
|
2690
|
+
var _uppercasePattern = /([A-Z])/g;
|
|
2691
|
+
|
|
2692
|
+
/**
|
|
2693
|
+
* Hyphenates a camelcased string, for example:
|
|
2694
|
+
*
|
|
2695
|
+
* > hyphenate('backgroundColor')
|
|
2696
|
+
* < "background-color"
|
|
2697
|
+
*
|
|
2698
|
+
* For CSS style names, use `hyphenateStyleName` instead which works properly
|
|
2699
|
+
* with all vendor prefixes, including `ms`.
|
|
2700
|
+
*
|
|
2701
|
+
* @param {string} string
|
|
2702
|
+
* @return {string}
|
|
2703
|
+
*/
|
|
2704
|
+
function hyphenate(string) {
|
|
2705
|
+
return string.replace(_uppercasePattern, '-$1').toLowerCase();
|
|
2706
|
+
}
|
|
2707
|
+
|
|
2708
|
+
var hyphenate_1 = hyphenate;
|
|
2709
|
+
|
|
2710
|
+
/**
|
|
2711
|
+
* Copyright (c) 2013-present, Facebook, Inc.
|
|
2712
|
+
*
|
|
2713
|
+
* This source code is licensed under the MIT license found in the
|
|
2714
|
+
* LICENSE file in the root directory of this source tree.
|
|
2715
|
+
*
|
|
2716
|
+
* @typechecks
|
|
2717
|
+
*/
|
|
2718
|
+
|
|
2719
|
+
'use strict';
|
|
2720
|
+
|
|
2721
|
+
|
|
2722
|
+
|
|
2723
|
+
var msPattern$1 = /^ms-/;
|
|
2724
|
+
|
|
2725
|
+
/**
|
|
2726
|
+
* Hyphenates a camelcased CSS property name, for example:
|
|
2727
|
+
*
|
|
2728
|
+
* > hyphenateStyleName('backgroundColor')
|
|
2729
|
+
* < "background-color"
|
|
2730
|
+
* > hyphenateStyleName('MozTransition')
|
|
2731
|
+
* < "-moz-transition"
|
|
2732
|
+
* > hyphenateStyleName('msTransition')
|
|
2733
|
+
* < "-ms-transition"
|
|
2734
|
+
*
|
|
2735
|
+
* As Modernizr suggests (http://modernizr.com/docs/#prefixed), an `ms` prefix
|
|
2736
|
+
* is converted to `-ms-`.
|
|
2737
|
+
*
|
|
2738
|
+
* @param {string} string
|
|
2739
|
+
* @return {string}
|
|
2740
|
+
*/
|
|
2741
|
+
function hyphenateStyleName$2(string) {
|
|
2742
|
+
return hyphenate_1(string).replace(msPattern$1, '-ms-');
|
|
2743
|
+
}
|
|
2744
|
+
|
|
2745
|
+
var hyphenateStyleName_1 = hyphenateStyleName$2;
|
|
2746
|
+
|
|
2747
|
+
/**
|
|
2748
|
+
* Copyright (c) 2013-present, Facebook, Inc.
|
|
2749
|
+
*
|
|
2750
|
+
* This source code is licensed under the MIT license found in the
|
|
2751
|
+
* LICENSE file in the root directory of this source tree.
|
|
2752
|
+
*
|
|
2753
|
+
*
|
|
2754
|
+
* @typechecks static-only
|
|
2755
|
+
*/
|
|
2756
|
+
|
|
2757
|
+
'use strict';
|
|
2758
|
+
|
|
2759
|
+
/**
|
|
2760
|
+
* Memoizes the return value of a function that accepts one string argument.
|
|
2761
|
+
*/
|
|
2762
|
+
|
|
2763
|
+
function memoizeStringOnly(callback) {
|
|
2764
|
+
var cache = {};
|
|
2765
|
+
return function (string) {
|
|
2766
|
+
if (!cache.hasOwnProperty(string)) {
|
|
2767
|
+
cache[string] = callback.call(this, string);
|
|
2768
|
+
}
|
|
2769
|
+
return cache[string];
|
|
2770
|
+
};
|
|
2771
|
+
}
|
|
2772
|
+
|
|
2773
|
+
var memoizeStringOnly_1 = memoizeStringOnly;
|
|
2774
|
+
|
|
2775
|
+
var CSSPropertyOperations = createCommonjsModule(function (module, exports) {
|
|
2776
|
+
'use strict';
|
|
2777
|
+
|
|
2778
|
+
Object.defineProperty(exports, "__esModule", {
|
|
2779
|
+
value: true
|
|
2780
|
+
});
|
|
2781
|
+
exports.processStyleName = undefined;
|
|
2782
|
+
exports.createMarkupForStyles = createMarkupForStyles;
|
|
2783
|
+
|
|
2784
|
+
|
|
2785
|
+
|
|
2786
|
+
var _camelizeStyleName2 = _interopRequireDefault(camelizeStyleName_1);
|
|
2787
|
+
|
|
2788
|
+
|
|
2789
|
+
|
|
2790
|
+
var _dangerousStyleValue2 = _interopRequireDefault(dangerousStyleValue_1);
|
|
2791
|
+
|
|
2792
|
+
|
|
2793
|
+
|
|
2794
|
+
var _hyphenateStyleName2 = _interopRequireDefault(hyphenateStyleName_1);
|
|
2795
|
+
|
|
2796
|
+
|
|
2797
|
+
|
|
2798
|
+
var _memoizeStringOnly2 = _interopRequireDefault(memoizeStringOnly_1);
|
|
2799
|
+
|
|
2800
|
+
|
|
2801
|
+
|
|
2802
|
+
var _warning2 = _interopRequireDefault(warning_1);
|
|
2803
|
+
|
|
2804
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
2805
|
+
|
|
2806
|
+
var processStyleName = exports.processStyleName = (0, _memoizeStringOnly2.default)(_hyphenateStyleName2.default); /**
|
|
2807
|
+
* Copyright 2013-present, Facebook, Inc.
|
|
2808
|
+
* All rights reserved.
|
|
2809
|
+
*
|
|
2810
|
+
* This source code is licensed under the BSD-style license found in the
|
|
2811
|
+
* LICENSE file in the root directory of this source tree. An additional grant
|
|
2812
|
+
* of patent rights can be found in the PATENTS file in the same directory.
|
|
2813
|
+
*
|
|
2814
|
+
* @providesModule CSSPropertyOperations
|
|
2815
|
+
*/
|
|
2816
|
+
|
|
2817
|
+
if ("development" !== 'production') {
|
|
2818
|
+
// 'msTransform' is correct, but the other prefixes should be capitalized
|
|
2819
|
+
var badVendoredStyleNamePattern = /^(?:webkit|moz|o)[A-Z]/;
|
|
2820
|
+
|
|
2821
|
+
// style values shouldn't contain a semicolon
|
|
2822
|
+
var badStyleValueWithSemicolonPattern = /;\s*$/;
|
|
2823
|
+
|
|
2824
|
+
var warnedStyleNames = {};
|
|
2825
|
+
var warnedStyleValues = {};
|
|
2826
|
+
var warnedForNaNValue = false;
|
|
2827
|
+
|
|
2828
|
+
var warnHyphenatedStyleName = function warnHyphenatedStyleName(name, owner) {
|
|
2829
|
+
if (warnedStyleNames.hasOwnProperty(name) && warnedStyleNames[name]) {
|
|
2830
|
+
return;
|
|
2831
|
+
}
|
|
2832
|
+
|
|
2833
|
+
warnedStyleNames[name] = true;
|
|
2834
|
+
"development" !== 'production' ? (0, _warning2.default)(false, 'Unsupported style property %s. Did you mean %s?%s', name, (0, _camelizeStyleName2.default)(name), checkRenderMessage(owner)) : void 0;
|
|
2835
|
+
};
|
|
2836
|
+
|
|
2837
|
+
var warnBadVendoredStyleName = function warnBadVendoredStyleName(name, owner) {
|
|
2838
|
+
if (warnedStyleNames.hasOwnProperty(name) && warnedStyleNames[name]) {
|
|
2839
|
+
return;
|
|
2840
|
+
}
|
|
2841
|
+
|
|
2842
|
+
warnedStyleNames[name] = true;
|
|
2843
|
+
"development" !== 'production' ? (0, _warning2.default)(false, 'Unsupported vendor-prefixed style property %s. Did you mean %s?%s', name, name.charAt(0).toUpperCase() + name.slice(1), checkRenderMessage(owner)) : void 0;
|
|
2844
|
+
};
|
|
2845
|
+
|
|
2846
|
+
var warnStyleValueWithSemicolon = function warnStyleValueWithSemicolon(name, value, owner) {
|
|
2847
|
+
if (warnedStyleValues.hasOwnProperty(value) && warnedStyleValues[value]) {
|
|
2848
|
+
return;
|
|
2849
|
+
}
|
|
2850
|
+
|
|
2851
|
+
warnedStyleValues[value] = true;
|
|
2852
|
+
"development" !== 'production' ? (0, _warning2.default)(false, 'Style property values shouldn\'t contain a semicolon.%s ' + 'Try "%s: %s" instead.', checkRenderMessage(owner), name, value.replace(badStyleValueWithSemicolonPattern, '')) : void 0;
|
|
2853
|
+
};
|
|
2854
|
+
|
|
2855
|
+
var warnStyleValueIsNaN = function warnStyleValueIsNaN(name, value, owner) {
|
|
2856
|
+
if (warnedForNaNValue) {
|
|
2857
|
+
return;
|
|
2858
|
+
}
|
|
2859
|
+
|
|
2860
|
+
warnedForNaNValue = true;
|
|
2861
|
+
"development" !== 'production' ? (0, _warning2.default)(false, '`NaN` is an invalid value for the `%s` css style property.%s', name, checkRenderMessage(owner)) : void 0;
|
|
2862
|
+
};
|
|
2863
|
+
|
|
2864
|
+
var checkRenderMessage = function checkRenderMessage(owner) {
|
|
2865
|
+
if (owner) {
|
|
2866
|
+
var name = owner.getName();
|
|
2867
|
+
if (name) {
|
|
2868
|
+
return ' Check the render method of `' + name + '`.';
|
|
2869
|
+
}
|
|
2870
|
+
}
|
|
2871
|
+
return '';
|
|
2872
|
+
};
|
|
2873
|
+
|
|
2874
|
+
/**
|
|
2875
|
+
* @param {string} name
|
|
2876
|
+
* @param {*} value
|
|
2877
|
+
* @param {ReactDOMComponent} component
|
|
2878
|
+
*/
|
|
2879
|
+
var warnValidStyle = function warnValidStyle(name, value, component) {
|
|
2880
|
+
//eslint-disable-line no-var
|
|
2881
|
+
var owner = void 0;
|
|
2882
|
+
if (component) {
|
|
2883
|
+
owner = component._currentElement._owner;
|
|
2884
|
+
}
|
|
2885
|
+
if (name.indexOf('-') > -1) {
|
|
2886
|
+
warnHyphenatedStyleName(name, owner);
|
|
2887
|
+
} else if (badVendoredStyleNamePattern.test(name)) {
|
|
2888
|
+
warnBadVendoredStyleName(name, owner);
|
|
2889
|
+
} else if (badStyleValueWithSemicolonPattern.test(value)) {
|
|
2890
|
+
warnStyleValueWithSemicolon(name, value, owner);
|
|
2891
|
+
}
|
|
2892
|
+
|
|
2893
|
+
if (typeof value === 'number' && isNaN(value)) {
|
|
2894
|
+
warnStyleValueIsNaN(name, value, owner);
|
|
2895
|
+
}
|
|
2896
|
+
};
|
|
2897
|
+
}
|
|
2898
|
+
|
|
2899
|
+
/**
|
|
2900
|
+
* Serializes a mapping of style properties for use as inline styles:
|
|
2901
|
+
*
|
|
2902
|
+
* > createMarkupForStyles({width: '200px', height: 0})
|
|
2903
|
+
* "width:200px;height:0;"
|
|
2904
|
+
*
|
|
2905
|
+
* Undefined values are ignored so that declarative programming is easier.
|
|
2906
|
+
* The result should be HTML-escaped before insertion into the DOM.
|
|
2907
|
+
*
|
|
2908
|
+
* @param {object} styles
|
|
2909
|
+
* @param {ReactDOMComponent} component
|
|
2910
|
+
* @return {?string}
|
|
2911
|
+
*/
|
|
2912
|
+
|
|
2913
|
+
function createMarkupForStyles(styles, component) {
|
|
2914
|
+
var serialized = '';
|
|
2915
|
+
for (var styleName in styles) {
|
|
2916
|
+
var isCustomProp = styleName.indexOf('--') === 0;
|
|
2917
|
+
if (!styles.hasOwnProperty(styleName)) {
|
|
2918
|
+
continue;
|
|
2919
|
+
}
|
|
2920
|
+
if (styleName === 'label') {
|
|
2921
|
+
continue;
|
|
2922
|
+
}
|
|
2923
|
+
var styleValue = styles[styleName];
|
|
2924
|
+
if ("development" !== 'production' && !isCustomProp) {
|
|
2925
|
+
warnValidStyle(styleName, styleValue, component);
|
|
2926
|
+
}
|
|
2927
|
+
if (styleValue != null) {
|
|
2928
|
+
if (isCustomProp) {
|
|
2929
|
+
serialized += styleName + ':' + styleValue + ';';
|
|
2930
|
+
} else {
|
|
2931
|
+
serialized += processStyleName(styleName) + ':';
|
|
2932
|
+
serialized += (0, _dangerousStyleValue2.default)(styleName, styleValue, component) + ';';
|
|
2933
|
+
}
|
|
2934
|
+
}
|
|
2935
|
+
}
|
|
2936
|
+
return serialized || null;
|
|
2937
|
+
}
|
|
2938
|
+
});
|
|
2939
|
+
|
|
2940
|
+
const index$1 = /*@__PURE__*/getDefaultExportFromCjs(CSSPropertyOperations);
|
|
2941
|
+
|
|
2942
|
+
var clean_1 = createCommonjsModule(function (module, exports) {
|
|
2943
|
+
'use strict';
|
|
2944
|
+
|
|
2945
|
+
Object.defineProperty(exports, "__esModule", {
|
|
2946
|
+
value: true
|
|
2947
|
+
});
|
|
2948
|
+
|
|
2949
|
+
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
|
|
2950
|
+
|
|
2951
|
+
exports.default = clean;
|
|
2952
|
+
// Returns true for null, false, undefined and {}
|
|
2953
|
+
function isFalsy(value) {
|
|
2954
|
+
return value === null || value === undefined || value === false || (typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object' && Object.keys(value).length === 0;
|
|
2955
|
+
}
|
|
2956
|
+
|
|
2957
|
+
function cleanObject(object) {
|
|
2958
|
+
if (isFalsy(object)) return null;
|
|
2959
|
+
if ((typeof object === 'undefined' ? 'undefined' : _typeof(object)) !== 'object') return object;
|
|
2960
|
+
|
|
2961
|
+
var acc = {},
|
|
2962
|
+
keys = Object.keys(object),
|
|
2963
|
+
hasFalsy = false;
|
|
2964
|
+
for (var i = 0; i < keys.length; i++) {
|
|
2965
|
+
var value = object[keys[i]];
|
|
2966
|
+
var filteredValue = clean(value);
|
|
2967
|
+
if (filteredValue === null || filteredValue !== value) {
|
|
2968
|
+
hasFalsy = true;
|
|
2969
|
+
}
|
|
2970
|
+
if (filteredValue !== null) {
|
|
2971
|
+
acc[keys[i]] = filteredValue;
|
|
2972
|
+
}
|
|
2973
|
+
}
|
|
2974
|
+
return Object.keys(acc).length === 0 ? null : hasFalsy ? acc : object;
|
|
2975
|
+
}
|
|
2976
|
+
|
|
2977
|
+
function cleanArray(rules) {
|
|
2978
|
+
var hasFalsy = false;
|
|
2979
|
+
var filtered = [];
|
|
2980
|
+
rules.forEach(function (rule) {
|
|
2981
|
+
var filteredRule = clean(rule);
|
|
2982
|
+
if (filteredRule === null || filteredRule !== rule) {
|
|
2983
|
+
hasFalsy = true;
|
|
2984
|
+
}
|
|
2985
|
+
if (filteredRule !== null) {
|
|
2986
|
+
filtered.push(filteredRule);
|
|
2987
|
+
}
|
|
2988
|
+
});
|
|
2989
|
+
return filtered.length == 0 ? null : hasFalsy ? filtered : rules;
|
|
2990
|
+
}
|
|
2991
|
+
|
|
2992
|
+
// Takes style array or object provided by user and clears all the falsy data
|
|
2993
|
+
// If there is no styles left after filtration returns null
|
|
2994
|
+
function clean(input) {
|
|
2995
|
+
return Array.isArray(input) ? cleanArray(input) : cleanObject(input);
|
|
2996
|
+
}
|
|
2997
|
+
});
|
|
2998
|
+
|
|
2999
|
+
const clean = /*@__PURE__*/getDefaultExportFromCjs(clean_1);
|
|
3000
|
+
|
|
3001
|
+
var staticData = createCommonjsModule(function (module, exports) {
|
|
3002
|
+
"use strict";
|
|
3003
|
+
|
|
3004
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3005
|
+
value: true
|
|
3006
|
+
});
|
|
3007
|
+
|
|
3008
|
+
var w = ["Webkit"];
|
|
3009
|
+
var m = ["Moz"];
|
|
3010
|
+
var ms = ["ms"];
|
|
3011
|
+
var wm = ["Webkit", "Moz"];
|
|
3012
|
+
var wms = ["Webkit", "ms"];
|
|
3013
|
+
var wmms = ["Webkit", "Moz", "ms"];
|
|
3014
|
+
|
|
3015
|
+
exports.default = {
|
|
3016
|
+
plugins: [],
|
|
3017
|
+
prefixMap: { "appearance": wm, "userSelect": wmms, "textEmphasisPosition": w, "textEmphasis": w, "textEmphasisStyle": w, "textEmphasisColor": w, "boxDecorationBreak": w, "clipPath": w, "maskImage": w, "maskMode": w, "maskRepeat": w, "maskPosition": w, "maskClip": w, "maskOrigin": w, "maskSize": w, "maskComposite": w, "mask": w, "maskBorderSource": w, "maskBorderMode": w, "maskBorderSlice": w, "maskBorderWidth": w, "maskBorderOutset": w, "maskBorderRepeat": w, "maskBorder": w, "maskType": w, "textDecorationStyle": w, "textDecorationSkip": w, "textDecorationLine": w, "textDecorationColor": w, "filter": w, "fontFeatureSettings": w, "breakAfter": wmms, "breakBefore": wmms, "breakInside": wmms, "columnCount": wm, "columnFill": wm, "columnGap": wm, "columnRule": wm, "columnRuleColor": wm, "columnRuleStyle": wm, "columnRuleWidth": wm, "columns": wm, "columnSpan": wm, "columnWidth": wm, "writingMode": wms, "flex": w, "flexBasis": w, "flexDirection": w, "flexGrow": w, "flexFlow": w, "flexShrink": w, "flexWrap": w, "alignContent": w, "alignItems": w, "alignSelf": w, "justifyContent": w, "order": w, "transform": w, "transformOrigin": w, "transformOriginX": w, "transformOriginY": w, "backfaceVisibility": w, "perspective": w, "perspectiveOrigin": w, "transformStyle": w, "transformOriginZ": w, "animation": w, "animationDelay": w, "animationDirection": w, "animationFillMode": w, "animationDuration": w, "animationIterationCount": w, "animationName": w, "animationPlayState": w, "animationTimingFunction": w, "backdropFilter": w, "fontKerning": w, "scrollSnapType": wms, "scrollSnapPointsX": wms, "scrollSnapPointsY": wms, "scrollSnapDestination": wms, "scrollSnapCoordinate": wms, "shapeImageThreshold": w, "shapeImageMargin": w, "shapeImageOutside": w, "hyphens": wmms, "flowInto": wms, "flowFrom": wms, "regionFragment": wms, "textAlignLast": m, "tabSize": m, "wrapFlow": ms, "wrapThrough": ms, "wrapMargin": ms, "gridTemplateColumns": ms, "gridTemplateRows": ms, "gridTemplateAreas": ms, "gridTemplate": ms, "gridAutoColumns": ms, "gridAutoRows": ms, "gridAutoFlow": ms, "grid": ms, "gridRowStart": ms, "gridColumnStart": ms, "gridRowEnd": ms, "gridRow": ms, "gridColumn": ms, "gridColumnEnd": ms, "gridColumnGap": ms, "gridRowGap": ms, "gridArea": ms, "gridGap": ms, "textSizeAdjust": wms, "borderImage": w, "borderImageOutset": w, "borderImageRepeat": w, "borderImageSlice": w, "borderImageSource": w, "borderImageWidth": w, "transitionDelay": w, "transitionDuration": w, "transitionProperty": w, "transitionTimingFunction": w }
|
|
3018
|
+
};
|
|
3019
|
+
module.exports = exports["default"];
|
|
3020
|
+
});
|
|
3021
|
+
|
|
3022
|
+
const staticData$1 = /*@__PURE__*/getDefaultExportFromCjs(staticData);
|
|
3023
|
+
|
|
3024
|
+
var capitalizeString_1 = createCommonjsModule(function (module, exports) {
|
|
3025
|
+
"use strict";
|
|
3026
|
+
|
|
3027
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3028
|
+
value: true
|
|
3029
|
+
});
|
|
3030
|
+
exports.default = capitalizeString;
|
|
3031
|
+
function capitalizeString(str) {
|
|
3032
|
+
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
3033
|
+
}
|
|
3034
|
+
module.exports = exports["default"];
|
|
3035
|
+
});
|
|
3036
|
+
|
|
3037
|
+
const capitalizeString = /*@__PURE__*/getDefaultExportFromCjs(capitalizeString_1);
|
|
3038
|
+
|
|
3039
|
+
var prefixProperty_1 = createCommonjsModule(function (module, exports) {
|
|
3040
|
+
'use strict';
|
|
3041
|
+
|
|
3042
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3043
|
+
value: true
|
|
3044
|
+
});
|
|
3045
|
+
exports.default = prefixProperty;
|
|
3046
|
+
|
|
3047
|
+
|
|
3048
|
+
|
|
3049
|
+
var _capitalizeString2 = _interopRequireDefault(capitalizeString_1);
|
|
3050
|
+
|
|
3051
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
3052
|
+
|
|
3053
|
+
function prefixProperty(prefixProperties, property, style) {
|
|
3054
|
+
if (prefixProperties.hasOwnProperty(property)) {
|
|
3055
|
+
var requiredPrefixes = prefixProperties[property];
|
|
3056
|
+
for (var i = 0, len = requiredPrefixes.length; i < len; ++i) {
|
|
3057
|
+
style[requiredPrefixes[i] + (0, _capitalizeString2.default)(property)] = style[property];
|
|
3058
|
+
}
|
|
3059
|
+
}
|
|
3060
|
+
}
|
|
3061
|
+
module.exports = exports['default'];
|
|
3062
|
+
});
|
|
3063
|
+
|
|
3064
|
+
const prefixProperty = /*@__PURE__*/getDefaultExportFromCjs(prefixProperty_1);
|
|
3065
|
+
|
|
3066
|
+
var prefixValue_1 = createCommonjsModule(function (module, exports) {
|
|
3067
|
+
"use strict";
|
|
3068
|
+
|
|
3069
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3070
|
+
value: true
|
|
3071
|
+
});
|
|
3072
|
+
exports.default = prefixValue;
|
|
3073
|
+
function prefixValue(plugins, property, value, style, metaData) {
|
|
3074
|
+
for (var i = 0, len = plugins.length; i < len; ++i) {
|
|
3075
|
+
var processedValue = plugins[i](property, value, style, metaData);
|
|
3076
|
+
|
|
3077
|
+
// we can stop processing if a value is returned
|
|
3078
|
+
// as all plugin criteria are unique
|
|
3079
|
+
if (processedValue) {
|
|
3080
|
+
return processedValue;
|
|
3081
|
+
}
|
|
3082
|
+
}
|
|
3083
|
+
}
|
|
3084
|
+
module.exports = exports["default"];
|
|
3085
|
+
});
|
|
3086
|
+
|
|
3087
|
+
const prefixValue = /*@__PURE__*/getDefaultExportFromCjs(prefixValue_1);
|
|
3088
|
+
|
|
3089
|
+
var cursor_1 = createCommonjsModule(function (module, exports) {
|
|
3090
|
+
'use strict';
|
|
3091
|
+
|
|
3092
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3093
|
+
value: true
|
|
3094
|
+
});
|
|
3095
|
+
exports.default = cursor;
|
|
3096
|
+
var prefixes = ['-webkit-', '-moz-', ''];
|
|
3097
|
+
|
|
3098
|
+
var values = {
|
|
3099
|
+
'zoom-in': true,
|
|
3100
|
+
'zoom-out': true,
|
|
3101
|
+
grab: true,
|
|
3102
|
+
grabbing: true
|
|
3103
|
+
};
|
|
3104
|
+
|
|
3105
|
+
function cursor(property, value) {
|
|
3106
|
+
if (property === 'cursor' && values.hasOwnProperty(value)) {
|
|
3107
|
+
return prefixes.map(function (prefix) {
|
|
3108
|
+
return prefix + value;
|
|
3109
|
+
});
|
|
3110
|
+
}
|
|
3111
|
+
}
|
|
3112
|
+
module.exports = exports['default'];
|
|
3113
|
+
});
|
|
3114
|
+
|
|
3115
|
+
const cursor = /*@__PURE__*/getDefaultExportFromCjs(cursor_1);
|
|
3116
|
+
|
|
3117
|
+
var isPrefixedValue_1 = createCommonjsModule(function (module, exports) {
|
|
3118
|
+
'use strict';
|
|
3119
|
+
|
|
3120
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3121
|
+
value: true
|
|
3122
|
+
});
|
|
3123
|
+
exports.default = isPrefixedValue;
|
|
3124
|
+
var regex = /-webkit-|-moz-|-ms-/;
|
|
3125
|
+
|
|
3126
|
+
function isPrefixedValue(value) {
|
|
3127
|
+
return typeof value === 'string' && regex.test(value);
|
|
3128
|
+
}
|
|
3129
|
+
module.exports = exports['default'];
|
|
3130
|
+
});
|
|
3131
|
+
|
|
3132
|
+
const isPrefixedValue = /*@__PURE__*/getDefaultExportFromCjs(isPrefixedValue_1);
|
|
3133
|
+
|
|
3134
|
+
var crossFade_1 = createCommonjsModule(function (module, exports) {
|
|
3135
|
+
'use strict';
|
|
3136
|
+
|
|
3137
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3138
|
+
value: true
|
|
3139
|
+
});
|
|
3140
|
+
exports.default = crossFade;
|
|
3141
|
+
|
|
3142
|
+
|
|
3143
|
+
|
|
3144
|
+
var _isPrefixedValue2 = _interopRequireDefault(isPrefixedValue_1);
|
|
3145
|
+
|
|
3146
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
3147
|
+
|
|
3148
|
+
// http://caniuse.com/#search=cross-fade
|
|
3149
|
+
var prefixes = ['-webkit-', ''];
|
|
3150
|
+
function crossFade(property, value) {
|
|
3151
|
+
if (typeof value === 'string' && !(0, _isPrefixedValue2.default)(value) && value.indexOf('cross-fade(') > -1) {
|
|
3152
|
+
return prefixes.map(function (prefix) {
|
|
3153
|
+
return value.replace(/cross-fade\(/g, prefix + 'cross-fade(');
|
|
3154
|
+
});
|
|
3155
|
+
}
|
|
3156
|
+
}
|
|
3157
|
+
module.exports = exports['default'];
|
|
3158
|
+
});
|
|
3159
|
+
|
|
3160
|
+
const crossFade = /*@__PURE__*/getDefaultExportFromCjs(crossFade_1);
|
|
3161
|
+
|
|
3162
|
+
var filter_1 = createCommonjsModule(function (module, exports) {
|
|
3163
|
+
'use strict';
|
|
3164
|
+
|
|
3165
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3166
|
+
value: true
|
|
3167
|
+
});
|
|
3168
|
+
exports.default = filter;
|
|
3169
|
+
|
|
3170
|
+
|
|
3171
|
+
|
|
3172
|
+
var _isPrefixedValue2 = _interopRequireDefault(isPrefixedValue_1);
|
|
3173
|
+
|
|
3174
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
3175
|
+
|
|
3176
|
+
// http://caniuse.com/#feat=css-filter-function
|
|
3177
|
+
var prefixes = ['-webkit-', ''];
|
|
3178
|
+
function filter(property, value) {
|
|
3179
|
+
if (typeof value === 'string' && !(0, _isPrefixedValue2.default)(value) && value.indexOf('filter(') > -1) {
|
|
3180
|
+
return prefixes.map(function (prefix) {
|
|
3181
|
+
return value.replace(/filter\(/g, prefix + 'filter(');
|
|
3182
|
+
});
|
|
3183
|
+
}
|
|
3184
|
+
}
|
|
3185
|
+
module.exports = exports['default'];
|
|
3186
|
+
});
|
|
3187
|
+
|
|
3188
|
+
const filter = /*@__PURE__*/getDefaultExportFromCjs(filter_1);
|
|
3189
|
+
|
|
3190
|
+
var flex_1 = createCommonjsModule(function (module, exports) {
|
|
3191
|
+
'use strict';
|
|
3192
|
+
|
|
3193
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3194
|
+
value: true
|
|
3195
|
+
});
|
|
3196
|
+
exports.default = flex;
|
|
3197
|
+
var values = {
|
|
3198
|
+
flex: ['-webkit-box', '-moz-box', '-ms-flexbox', '-webkit-flex', 'flex'],
|
|
3199
|
+
'inline-flex': ['-webkit-inline-box', '-moz-inline-box', '-ms-inline-flexbox', '-webkit-inline-flex', 'inline-flex']
|
|
3200
|
+
};
|
|
3201
|
+
|
|
3202
|
+
function flex(property, value) {
|
|
3203
|
+
if (property === 'display' && values.hasOwnProperty(value)) {
|
|
3204
|
+
return values[value];
|
|
3205
|
+
}
|
|
3206
|
+
}
|
|
3207
|
+
module.exports = exports['default'];
|
|
3208
|
+
});
|
|
3209
|
+
|
|
3210
|
+
const flex = /*@__PURE__*/getDefaultExportFromCjs(flex_1);
|
|
3211
|
+
|
|
3212
|
+
var flexboxOld_1 = createCommonjsModule(function (module, exports) {
|
|
3213
|
+
'use strict';
|
|
3214
|
+
|
|
3215
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3216
|
+
value: true
|
|
3217
|
+
});
|
|
3218
|
+
exports.default = flexboxOld;
|
|
3219
|
+
var alternativeValues = {
|
|
3220
|
+
'space-around': 'justify',
|
|
3221
|
+
'space-between': 'justify',
|
|
3222
|
+
'flex-start': 'start',
|
|
3223
|
+
'flex-end': 'end',
|
|
3224
|
+
'wrap-reverse': 'multiple',
|
|
3225
|
+
wrap: 'multiple'
|
|
3226
|
+
};
|
|
3227
|
+
|
|
3228
|
+
var alternativeProps = {
|
|
3229
|
+
alignItems: 'WebkitBoxAlign',
|
|
3230
|
+
justifyContent: 'WebkitBoxPack',
|
|
3231
|
+
flexWrap: 'WebkitBoxLines'
|
|
3232
|
+
};
|
|
3233
|
+
|
|
3234
|
+
function flexboxOld(property, value, style) {
|
|
3235
|
+
if (property === 'flexDirection' && typeof value === 'string') {
|
|
3236
|
+
if (value.indexOf('column') > -1) {
|
|
3237
|
+
style.WebkitBoxOrient = 'vertical';
|
|
3238
|
+
} else {
|
|
3239
|
+
style.WebkitBoxOrient = 'horizontal';
|
|
3240
|
+
}
|
|
3241
|
+
if (value.indexOf('reverse') > -1) {
|
|
3242
|
+
style.WebkitBoxDirection = 'reverse';
|
|
3243
|
+
} else {
|
|
3244
|
+
style.WebkitBoxDirection = 'normal';
|
|
3245
|
+
}
|
|
3246
|
+
}
|
|
3247
|
+
if (alternativeProps.hasOwnProperty(property)) {
|
|
3248
|
+
style[alternativeProps[property]] = alternativeValues[value] || value;
|
|
3249
|
+
}
|
|
3250
|
+
}
|
|
3251
|
+
module.exports = exports['default'];
|
|
3252
|
+
});
|
|
3253
|
+
|
|
3254
|
+
const flexboxOld = /*@__PURE__*/getDefaultExportFromCjs(flexboxOld_1);
|
|
3255
|
+
|
|
3256
|
+
var gradient_1 = createCommonjsModule(function (module, exports) {
|
|
3257
|
+
'use strict';
|
|
3258
|
+
|
|
3259
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3260
|
+
value: true
|
|
3261
|
+
});
|
|
3262
|
+
exports.default = gradient;
|
|
3263
|
+
|
|
3264
|
+
|
|
3265
|
+
|
|
3266
|
+
var _isPrefixedValue2 = _interopRequireDefault(isPrefixedValue_1);
|
|
3267
|
+
|
|
3268
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
3269
|
+
|
|
3270
|
+
var prefixes = ['-webkit-', '-moz-', ''];
|
|
3271
|
+
|
|
3272
|
+
var values = /linear-gradient|radial-gradient|repeating-linear-gradient|repeating-radial-gradient/;
|
|
3273
|
+
|
|
3274
|
+
function gradient(property, value) {
|
|
3275
|
+
if (typeof value === 'string' && !(0, _isPrefixedValue2.default)(value) && values.test(value)) {
|
|
3276
|
+
return prefixes.map(function (prefix) {
|
|
3277
|
+
return prefix + value;
|
|
3278
|
+
});
|
|
3279
|
+
}
|
|
3280
|
+
}
|
|
3281
|
+
module.exports = exports['default'];
|
|
3282
|
+
});
|
|
3283
|
+
|
|
3284
|
+
const gradient = /*@__PURE__*/getDefaultExportFromCjs(gradient_1);
|
|
3285
|
+
|
|
3286
|
+
var imageSet_1 = createCommonjsModule(function (module, exports) {
|
|
3287
|
+
'use strict';
|
|
3288
|
+
|
|
3289
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3290
|
+
value: true
|
|
3291
|
+
});
|
|
3292
|
+
exports.default = imageSet;
|
|
3293
|
+
|
|
3294
|
+
|
|
3295
|
+
|
|
3296
|
+
var _isPrefixedValue2 = _interopRequireDefault(isPrefixedValue_1);
|
|
3297
|
+
|
|
3298
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
3299
|
+
|
|
3300
|
+
// http://caniuse.com/#feat=css-image-set
|
|
3301
|
+
var prefixes = ['-webkit-', ''];
|
|
3302
|
+
function imageSet(property, value) {
|
|
3303
|
+
if (typeof value === 'string' && !(0, _isPrefixedValue2.default)(value) && value.indexOf('image-set(') > -1) {
|
|
3304
|
+
return prefixes.map(function (prefix) {
|
|
3305
|
+
return value.replace(/image-set\(/g, prefix + 'image-set(');
|
|
3306
|
+
});
|
|
3307
|
+
}
|
|
3308
|
+
}
|
|
3309
|
+
module.exports = exports['default'];
|
|
3310
|
+
});
|
|
3311
|
+
|
|
3312
|
+
const imageSet = /*@__PURE__*/getDefaultExportFromCjs(imageSet_1);
|
|
3313
|
+
|
|
3314
|
+
var position_1 = createCommonjsModule(function (module, exports) {
|
|
3315
|
+
'use strict';
|
|
3316
|
+
|
|
3317
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3318
|
+
value: true
|
|
3319
|
+
});
|
|
3320
|
+
exports.default = position;
|
|
3321
|
+
function position(property, value) {
|
|
3322
|
+
if (property === 'position' && value === 'sticky') {
|
|
3323
|
+
return ['-webkit-sticky', 'sticky'];
|
|
3324
|
+
}
|
|
3325
|
+
}
|
|
3326
|
+
module.exports = exports['default'];
|
|
3327
|
+
});
|
|
3328
|
+
|
|
3329
|
+
const position = /*@__PURE__*/getDefaultExportFromCjs(position_1);
|
|
3330
|
+
|
|
3331
|
+
var sizing_1 = createCommonjsModule(function (module, exports) {
|
|
3332
|
+
'use strict';
|
|
3333
|
+
|
|
3334
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3335
|
+
value: true
|
|
3336
|
+
});
|
|
3337
|
+
exports.default = sizing;
|
|
3338
|
+
var prefixes = ['-webkit-', '-moz-', ''];
|
|
3339
|
+
|
|
3340
|
+
var properties = {
|
|
3341
|
+
maxHeight: true,
|
|
3342
|
+
maxWidth: true,
|
|
3343
|
+
width: true,
|
|
3344
|
+
height: true,
|
|
3345
|
+
columnWidth: true,
|
|
3346
|
+
minWidth: true,
|
|
3347
|
+
minHeight: true
|
|
3348
|
+
};
|
|
3349
|
+
var values = {
|
|
3350
|
+
'min-content': true,
|
|
3351
|
+
'max-content': true,
|
|
3352
|
+
'fill-available': true,
|
|
3353
|
+
'fit-content': true,
|
|
3354
|
+
'contain-floats': true
|
|
3355
|
+
};
|
|
3356
|
+
|
|
3357
|
+
function sizing(property, value) {
|
|
3358
|
+
if (properties.hasOwnProperty(property) && values.hasOwnProperty(value)) {
|
|
3359
|
+
return prefixes.map(function (prefix) {
|
|
3360
|
+
return prefix + value;
|
|
3361
|
+
});
|
|
3362
|
+
}
|
|
3363
|
+
}
|
|
3364
|
+
module.exports = exports['default'];
|
|
3365
|
+
});
|
|
3366
|
+
|
|
3367
|
+
const sizing = /*@__PURE__*/getDefaultExportFromCjs(sizing_1);
|
|
3368
|
+
|
|
3369
|
+
/* eslint-disable no-var, prefer-template */
|
|
3370
|
+
var uppercasePattern = /[A-Z]/g;
|
|
3371
|
+
var msPattern = /^ms-/;
|
|
3372
|
+
var cache = {};
|
|
3373
|
+
|
|
3374
|
+
function toHyphenLower(match) {
|
|
3375
|
+
return '-' + match.toLowerCase()
|
|
3376
|
+
}
|
|
3377
|
+
|
|
3378
|
+
function hyphenateStyleName(name) {
|
|
3379
|
+
if (cache.hasOwnProperty(name)) {
|
|
3380
|
+
return cache[name]
|
|
3381
|
+
}
|
|
3382
|
+
|
|
3383
|
+
var hName = name.replace(uppercasePattern, toHyphenLower);
|
|
3384
|
+
return (cache[name] = msPattern.test(hName) ? '-' + hName : hName)
|
|
3385
|
+
}
|
|
3386
|
+
|
|
3387
|
+
const hyphenateStyleName$1 = /*#__PURE__*/Object.freeze({
|
|
3388
|
+
__proto__: null,
|
|
3389
|
+
'default': hyphenateStyleName
|
|
3390
|
+
});
|
|
3391
|
+
|
|
3392
|
+
const _hyphenateStyleName = /*@__PURE__*/getAugmentedNamespace(hyphenateStyleName$1);
|
|
3393
|
+
|
|
3394
|
+
var hyphenateProperty_1 = createCommonjsModule(function (module, exports) {
|
|
3395
|
+
'use strict';
|
|
3396
|
+
|
|
3397
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3398
|
+
value: true
|
|
3399
|
+
});
|
|
3400
|
+
exports.default = hyphenateProperty;
|
|
3401
|
+
|
|
3402
|
+
|
|
3403
|
+
|
|
3404
|
+
var _hyphenateStyleName2 = _interopRequireDefault(_hyphenateStyleName);
|
|
3405
|
+
|
|
3406
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
3407
|
+
|
|
3408
|
+
function hyphenateProperty(property) {
|
|
3409
|
+
return (0, _hyphenateStyleName2.default)(property);
|
|
3410
|
+
}
|
|
3411
|
+
module.exports = exports['default'];
|
|
3412
|
+
});
|
|
3413
|
+
|
|
3414
|
+
const hyphenateProperty = /*@__PURE__*/getDefaultExportFromCjs(hyphenateProperty_1);
|
|
3415
|
+
|
|
3416
|
+
var transition_1 = createCommonjsModule(function (module, exports) {
|
|
3417
|
+
'use strict';
|
|
3418
|
+
|
|
3419
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3420
|
+
value: true
|
|
3421
|
+
});
|
|
3422
|
+
exports.default = transition;
|
|
3423
|
+
|
|
3424
|
+
|
|
3425
|
+
|
|
3426
|
+
var _hyphenateProperty2 = _interopRequireDefault(hyphenateProperty_1);
|
|
3427
|
+
|
|
3428
|
+
|
|
3429
|
+
|
|
3430
|
+
var _isPrefixedValue2 = _interopRequireDefault(isPrefixedValue_1);
|
|
3431
|
+
|
|
3432
|
+
|
|
3433
|
+
|
|
3434
|
+
var _capitalizeString2 = _interopRequireDefault(capitalizeString_1);
|
|
3435
|
+
|
|
3436
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
3437
|
+
|
|
3438
|
+
var properties = {
|
|
3439
|
+
transition: true,
|
|
3440
|
+
transitionProperty: true,
|
|
3441
|
+
WebkitTransition: true,
|
|
3442
|
+
WebkitTransitionProperty: true,
|
|
3443
|
+
MozTransition: true,
|
|
3444
|
+
MozTransitionProperty: true
|
|
3445
|
+
};
|
|
3446
|
+
|
|
3447
|
+
|
|
3448
|
+
var prefixMapping = {
|
|
3449
|
+
Webkit: '-webkit-',
|
|
3450
|
+
Moz: '-moz-',
|
|
3451
|
+
ms: '-ms-'
|
|
3452
|
+
};
|
|
3453
|
+
|
|
3454
|
+
function prefixValue(value, propertyPrefixMap) {
|
|
3455
|
+
if ((0, _isPrefixedValue2.default)(value)) {
|
|
3456
|
+
return value;
|
|
3457
|
+
}
|
|
3458
|
+
|
|
3459
|
+
// only split multi values, not cubic beziers
|
|
3460
|
+
var multipleValues = value.split(/,(?![^()]*(?:\([^()]*\))?\))/g);
|
|
3461
|
+
|
|
3462
|
+
for (var i = 0, len = multipleValues.length; i < len; ++i) {
|
|
3463
|
+
var singleValue = multipleValues[i];
|
|
3464
|
+
var values = [singleValue];
|
|
3465
|
+
for (var property in propertyPrefixMap) {
|
|
3466
|
+
var dashCaseProperty = (0, _hyphenateProperty2.default)(property);
|
|
3467
|
+
|
|
3468
|
+
if (singleValue.indexOf(dashCaseProperty) > -1 && dashCaseProperty !== 'order') {
|
|
3469
|
+
var prefixes = propertyPrefixMap[property];
|
|
3470
|
+
for (var j = 0, pLen = prefixes.length; j < pLen; ++j) {
|
|
3471
|
+
// join all prefixes and create a new value
|
|
3472
|
+
values.unshift(singleValue.replace(dashCaseProperty, prefixMapping[prefixes[j]] + dashCaseProperty));
|
|
3473
|
+
}
|
|
3474
|
+
}
|
|
3475
|
+
}
|
|
3476
|
+
|
|
3477
|
+
multipleValues[i] = values.join(',');
|
|
3478
|
+
}
|
|
3479
|
+
|
|
3480
|
+
return multipleValues.join(',');
|
|
3481
|
+
}
|
|
3482
|
+
|
|
3483
|
+
function transition(property, value, style, propertyPrefixMap) {
|
|
3484
|
+
// also check for already prefixed transitions
|
|
3485
|
+
if (typeof value === 'string' && properties.hasOwnProperty(property)) {
|
|
3486
|
+
var outputValue = prefixValue(value, propertyPrefixMap);
|
|
3487
|
+
// if the property is already prefixed
|
|
3488
|
+
var webkitOutput = outputValue.split(/,(?![^()]*(?:\([^()]*\))?\))/g).filter(function (val) {
|
|
3489
|
+
return !/-moz-|-ms-/.test(val);
|
|
3490
|
+
}).join(',');
|
|
3491
|
+
|
|
3492
|
+
if (property.indexOf('Webkit') > -1) {
|
|
3493
|
+
return webkitOutput;
|
|
3494
|
+
}
|
|
3495
|
+
|
|
3496
|
+
var mozOutput = outputValue.split(/,(?![^()]*(?:\([^()]*\))?\))/g).filter(function (val) {
|
|
3497
|
+
return !/-webkit-|-ms-/.test(val);
|
|
3498
|
+
}).join(',');
|
|
3499
|
+
|
|
3500
|
+
if (property.indexOf('Moz') > -1) {
|
|
3501
|
+
return mozOutput;
|
|
3502
|
+
}
|
|
3503
|
+
|
|
3504
|
+
style['Webkit' + (0, _capitalizeString2.default)(property)] = webkitOutput;
|
|
3505
|
+
style['Moz' + (0, _capitalizeString2.default)(property)] = mozOutput;
|
|
3506
|
+
return outputValue;
|
|
3507
|
+
}
|
|
3508
|
+
}
|
|
3509
|
+
module.exports = exports['default'];
|
|
3510
|
+
});
|
|
3511
|
+
|
|
3512
|
+
const transition = /*@__PURE__*/getDefaultExportFromCjs(transition_1);
|
|
3513
|
+
|
|
3514
|
+
var prefixer_1 = createCommonjsModule(function (module, exports) {
|
|
3515
|
+
'use strict';
|
|
3516
|
+
|
|
3517
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3518
|
+
value: true
|
|
3519
|
+
});
|
|
3520
|
+
exports.default = prefixer;
|
|
3521
|
+
|
|
3522
|
+
|
|
3523
|
+
|
|
3524
|
+
var _staticData2 = _interopRequireDefault(staticData);
|
|
3525
|
+
|
|
3526
|
+
|
|
3527
|
+
|
|
3528
|
+
var _prefixProperty2 = _interopRequireDefault(prefixProperty_1);
|
|
3529
|
+
|
|
3530
|
+
|
|
3531
|
+
|
|
3532
|
+
var _prefixValue2 = _interopRequireDefault(prefixValue_1);
|
|
3533
|
+
|
|
3534
|
+
|
|
3535
|
+
|
|
3536
|
+
var _cursor2 = _interopRequireDefault(cursor_1);
|
|
3537
|
+
|
|
3538
|
+
|
|
3539
|
+
|
|
3540
|
+
var _crossFade2 = _interopRequireDefault(crossFade_1);
|
|
3541
|
+
|
|
3542
|
+
|
|
3543
|
+
|
|
3544
|
+
var _filter2 = _interopRequireDefault(filter_1);
|
|
3545
|
+
|
|
3546
|
+
|
|
3547
|
+
|
|
3548
|
+
var _flex2 = _interopRequireDefault(flex_1);
|
|
3549
|
+
|
|
3550
|
+
|
|
3551
|
+
|
|
3552
|
+
var _flexboxOld2 = _interopRequireDefault(flexboxOld_1);
|
|
3553
|
+
|
|
3554
|
+
|
|
3555
|
+
|
|
3556
|
+
var _gradient2 = _interopRequireDefault(gradient_1);
|
|
3557
|
+
|
|
3558
|
+
|
|
3559
|
+
|
|
3560
|
+
var _imageSet2 = _interopRequireDefault(imageSet_1);
|
|
3561
|
+
|
|
3562
|
+
|
|
3563
|
+
|
|
3564
|
+
var _position2 = _interopRequireDefault(position_1);
|
|
3565
|
+
|
|
3566
|
+
|
|
3567
|
+
|
|
3568
|
+
var _sizing2 = _interopRequireDefault(sizing_1);
|
|
3569
|
+
|
|
3570
|
+
|
|
3571
|
+
|
|
3572
|
+
var _transition2 = _interopRequireDefault(transition_1);
|
|
3573
|
+
|
|
3574
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
3575
|
+
|
|
3576
|
+
var plugins = [_crossFade2.default, _cursor2.default, _filter2.default, _flexboxOld2.default, _gradient2.default, _imageSet2.default, _position2.default, _sizing2.default, _transition2.default, _flex2.default]; // custom facade for inline-style-prefixer
|
|
3577
|
+
|
|
3578
|
+
var prefixMap = _staticData2.default.prefixMap;
|
|
3579
|
+
|
|
3580
|
+
function prefixer(style) {
|
|
3581
|
+
for (var property in style) {
|
|
3582
|
+
var value = style[property];
|
|
3583
|
+
|
|
3584
|
+
var processedValue = (0, _prefixValue2.default)(plugins, property, value, style, prefixMap);
|
|
3585
|
+
|
|
3586
|
+
// only modify the value if it was touched
|
|
3587
|
+
// by any plugin to prevent unnecessary mutations
|
|
3588
|
+
if (processedValue) {
|
|
3589
|
+
style[property] = processedValue;
|
|
3590
|
+
}
|
|
3591
|
+
|
|
3592
|
+
(0, _prefixProperty2.default)(prefixMap, property, style);
|
|
3593
|
+
}
|
|
3594
|
+
return style;
|
|
3595
|
+
}
|
|
3596
|
+
});
|
|
3597
|
+
|
|
3598
|
+
const prefixer = /*@__PURE__*/getDefaultExportFromCjs(prefixer_1);
|
|
3599
|
+
|
|
3600
|
+
var plugins = createCommonjsModule(function (module, exports) {
|
|
3601
|
+
'use strict';
|
|
3602
|
+
|
|
3603
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3604
|
+
value: true
|
|
3605
|
+
});
|
|
3606
|
+
|
|
3607
|
+
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
|
3608
|
+
|
|
3609
|
+
exports.PluginSet = PluginSet;
|
|
3610
|
+
exports.fallbacks = fallbacks;
|
|
3611
|
+
exports.contentWrap = contentWrap;
|
|
3612
|
+
exports.prefixes = prefixes;
|
|
3613
|
+
|
|
3614
|
+
|
|
3615
|
+
|
|
3616
|
+
var _objectAssign2 = _interopRequireDefault(objectAssign);
|
|
3617
|
+
|
|
3618
|
+
|
|
3619
|
+
|
|
3620
|
+
|
|
3621
|
+
|
|
3622
|
+
var _prefixer2 = _interopRequireDefault(prefixer_1);
|
|
3623
|
+
|
|
3624
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
3625
|
+
|
|
3626
|
+
var isDev = function (x) {
|
|
3627
|
+
return x === 'development' || !x;
|
|
3628
|
+
}("development");
|
|
3629
|
+
|
|
3630
|
+
function PluginSet(initial) {
|
|
3631
|
+
this.fns = initial || [];
|
|
3632
|
+
}
|
|
3633
|
+
|
|
3634
|
+
(0, _objectAssign2.default)(PluginSet.prototype, {
|
|
3635
|
+
add: function add() {
|
|
3636
|
+
var _this = this;
|
|
3637
|
+
|
|
3638
|
+
for (var _len = arguments.length, fns = Array(_len), _key = 0; _key < _len; _key++) {
|
|
3639
|
+
fns[_key] = arguments[_key];
|
|
3640
|
+
}
|
|
3641
|
+
|
|
3642
|
+
fns.forEach(function (fn) {
|
|
3643
|
+
if (_this.fns.indexOf(fn) >= 0) {
|
|
3644
|
+
if (isDev) {
|
|
3645
|
+
console.warn('adding the same plugin again, ignoring'); //eslint-disable-line no-console
|
|
3646
|
+
}
|
|
3647
|
+
} else {
|
|
3648
|
+
_this.fns = [fn].concat(_this.fns);
|
|
3649
|
+
}
|
|
3650
|
+
});
|
|
3651
|
+
},
|
|
3652
|
+
remove: function remove(fn) {
|
|
3653
|
+
this.fns = this.fns.filter(function (x) {
|
|
3654
|
+
return x !== fn;
|
|
3655
|
+
});
|
|
3656
|
+
},
|
|
3657
|
+
clear: function clear() {
|
|
3658
|
+
this.fns = [];
|
|
3659
|
+
},
|
|
3660
|
+
transform: function transform(o) {
|
|
3661
|
+
return this.fns.reduce(function (o, fn) {
|
|
3662
|
+
return fn(o);
|
|
3663
|
+
}, o);
|
|
3664
|
+
}
|
|
3665
|
+
});
|
|
3666
|
+
|
|
3667
|
+
function fallbacks(node) {
|
|
3668
|
+
var hasArray = Object.keys(node.style).map(function (x) {
|
|
3669
|
+
return Array.isArray(node.style[x]);
|
|
3670
|
+
}).indexOf(true) >= 0;
|
|
3671
|
+
if (hasArray) {
|
|
3672
|
+
var style = node.style;
|
|
3673
|
+
|
|
3674
|
+
var flattened = Object.keys(style).reduce(function (o, key) {
|
|
3675
|
+
o[key] = Array.isArray(style[key]) ? style[key].join('; ' + (0, CSSPropertyOperations.processStyleName)(key) + ': ') : style[key];
|
|
3676
|
+
return o;
|
|
3677
|
+
}, {});
|
|
3678
|
+
// todo -
|
|
3679
|
+
// flatten arrays which haven't been flattened yet
|
|
3680
|
+
return (0, _objectAssign2.default)({}, node, { style: flattened });
|
|
3681
|
+
}
|
|
3682
|
+
return node;
|
|
3683
|
+
}
|
|
3684
|
+
|
|
3685
|
+
var contentValues = ['normal', 'none', 'counter', 'open-quote', 'close-quote', 'no-open-quote', 'no-close-quote', 'initial', 'inherit'];
|
|
3686
|
+
|
|
3687
|
+
function contentWrap(node) {
|
|
3688
|
+
if (node.style.content) {
|
|
3689
|
+
var cont = node.style.content;
|
|
3690
|
+
if (contentValues.indexOf(cont) >= 0) {
|
|
3691
|
+
return node;
|
|
3692
|
+
}
|
|
3693
|
+
if (/^(attr|calc|counters?|url)\(/.test(cont)) {
|
|
3694
|
+
return node;
|
|
3695
|
+
}
|
|
3696
|
+
if (cont.charAt(0) === cont.charAt(cont.length - 1) && (cont.charAt(0) === '"' || cont.charAt(0) === "'")) {
|
|
3697
|
+
return node;
|
|
3698
|
+
}
|
|
3699
|
+
return _extends({}, node, { style: _extends({}, node.style, { content: '"' + cont + '"' }) });
|
|
3700
|
+
}
|
|
3701
|
+
return node;
|
|
3702
|
+
}
|
|
3703
|
+
|
|
3704
|
+
function prefixes(node) {
|
|
3705
|
+
return (0, _objectAssign2.default)({}, node, { style: (0, _prefixer2.default)(_extends({}, node.style)) });
|
|
3706
|
+
}
|
|
3707
|
+
});
|
|
3708
|
+
|
|
3709
|
+
const plugins$1 = /*@__PURE__*/getDefaultExportFromCjs(plugins);
|
|
3710
|
+
|
|
3711
|
+
var hash = createCommonjsModule(function (module, exports) {
|
|
3712
|
+
"use strict";
|
|
3713
|
+
|
|
3714
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3715
|
+
value: true
|
|
3716
|
+
});
|
|
3717
|
+
exports.default = doHash;
|
|
3718
|
+
// murmurhash2 via https://gist.github.com/raycmorgan/588423
|
|
3719
|
+
|
|
3720
|
+
function doHash(str, seed) {
|
|
3721
|
+
var m = 0x5bd1e995;
|
|
3722
|
+
var r = 24;
|
|
3723
|
+
var h = seed ^ str.length;
|
|
3724
|
+
var length = str.length;
|
|
3725
|
+
var currentIndex = 0;
|
|
3726
|
+
|
|
3727
|
+
while (length >= 4) {
|
|
3728
|
+
var k = UInt32(str, currentIndex);
|
|
3729
|
+
|
|
3730
|
+
k = Umul32(k, m);
|
|
3731
|
+
k ^= k >>> r;
|
|
3732
|
+
k = Umul32(k, m);
|
|
3733
|
+
|
|
3734
|
+
h = Umul32(h, m);
|
|
3735
|
+
h ^= k;
|
|
3736
|
+
|
|
3737
|
+
currentIndex += 4;
|
|
3738
|
+
length -= 4;
|
|
3739
|
+
}
|
|
3740
|
+
|
|
3741
|
+
switch (length) {
|
|
3742
|
+
case 3:
|
|
3743
|
+
h ^= UInt16(str, currentIndex);
|
|
3744
|
+
h ^= str.charCodeAt(currentIndex + 2) << 16;
|
|
3745
|
+
h = Umul32(h, m);
|
|
3746
|
+
break;
|
|
3747
|
+
|
|
3748
|
+
case 2:
|
|
3749
|
+
h ^= UInt16(str, currentIndex);
|
|
3750
|
+
h = Umul32(h, m);
|
|
3751
|
+
break;
|
|
3752
|
+
|
|
3753
|
+
case 1:
|
|
3754
|
+
h ^= str.charCodeAt(currentIndex);
|
|
3755
|
+
h = Umul32(h, m);
|
|
3756
|
+
break;
|
|
3757
|
+
}
|
|
3758
|
+
|
|
3759
|
+
h ^= h >>> 13;
|
|
3760
|
+
h = Umul32(h, m);
|
|
3761
|
+
h ^= h >>> 15;
|
|
3762
|
+
|
|
3763
|
+
return h >>> 0;
|
|
3764
|
+
}
|
|
3765
|
+
|
|
3766
|
+
function UInt32(str, pos) {
|
|
3767
|
+
return str.charCodeAt(pos++) + (str.charCodeAt(pos++) << 8) + (str.charCodeAt(pos++) << 16) + (str.charCodeAt(pos) << 24);
|
|
3768
|
+
}
|
|
3769
|
+
|
|
3770
|
+
function UInt16(str, pos) {
|
|
3771
|
+
return str.charCodeAt(pos++) + (str.charCodeAt(pos++) << 8);
|
|
3772
|
+
}
|
|
3773
|
+
|
|
3774
|
+
function Umul32(n, m) {
|
|
3775
|
+
n = n | 0;
|
|
3776
|
+
m = m | 0;
|
|
3777
|
+
var nlo = n & 0xffff;
|
|
3778
|
+
var nhi = n >>> 16;
|
|
3779
|
+
var res = nlo * m + ((nhi * m & 0xffff) << 16) | 0;
|
|
3780
|
+
return res;
|
|
3781
|
+
}
|
|
3782
|
+
});
|
|
3783
|
+
|
|
3784
|
+
const hash$1 = /*@__PURE__*/getDefaultExportFromCjs(hash);
|
|
3785
|
+
|
|
3786
|
+
var lib = createCommonjsModule(function (module, exports) {
|
|
3787
|
+
'use strict';
|
|
3788
|
+
|
|
3789
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3790
|
+
value: true
|
|
3791
|
+
});
|
|
3792
|
+
exports.compose = exports.merge = exports.$ = exports.style = exports.presets = exports.keyframes = exports.fontFace = exports.insertGlobal = exports.insertRule = exports.plugins = exports.styleSheet = undefined;
|
|
3793
|
+
exports.speedy = speedy;
|
|
3794
|
+
exports.simulations = simulations;
|
|
3795
|
+
exports.simulate = simulate;
|
|
3796
|
+
exports.cssLabels = cssLabels;
|
|
3797
|
+
exports.isLikeRule = isLikeRule;
|
|
3798
|
+
exports.idFor = idFor;
|
|
3799
|
+
exports.css = css;
|
|
3800
|
+
exports.rehydrate = rehydrate;
|
|
3801
|
+
exports.flush = flush;
|
|
3802
|
+
exports.select = select;
|
|
3803
|
+
exports.parent = parent;
|
|
3804
|
+
exports.media = media;
|
|
3805
|
+
exports.pseudo = pseudo;
|
|
3806
|
+
exports.active = active;
|
|
3807
|
+
exports.any = any;
|
|
3808
|
+
exports.checked = checked;
|
|
3809
|
+
exports.disabled = disabled;
|
|
3810
|
+
exports.empty = empty;
|
|
3811
|
+
exports.enabled = enabled;
|
|
3812
|
+
exports._default = _default;
|
|
3813
|
+
exports.first = first;
|
|
3814
|
+
exports.firstChild = firstChild;
|
|
3815
|
+
exports.firstOfType = firstOfType;
|
|
3816
|
+
exports.fullscreen = fullscreen;
|
|
3817
|
+
exports.focus = focus;
|
|
3818
|
+
exports.hover = hover;
|
|
3819
|
+
exports.indeterminate = indeterminate;
|
|
3820
|
+
exports.inRange = inRange;
|
|
3821
|
+
exports.invalid = invalid;
|
|
3822
|
+
exports.lastChild = lastChild;
|
|
3823
|
+
exports.lastOfType = lastOfType;
|
|
3824
|
+
exports.left = left;
|
|
3825
|
+
exports.link = link;
|
|
3826
|
+
exports.onlyChild = onlyChild;
|
|
3827
|
+
exports.onlyOfType = onlyOfType;
|
|
3828
|
+
exports.optional = optional;
|
|
3829
|
+
exports.outOfRange = outOfRange;
|
|
3830
|
+
exports.readOnly = readOnly;
|
|
3831
|
+
exports.readWrite = readWrite;
|
|
3832
|
+
exports.required = required;
|
|
3833
|
+
exports.right = right;
|
|
3834
|
+
exports.root = root;
|
|
3835
|
+
exports.scope = scope;
|
|
3836
|
+
exports.target = target;
|
|
3837
|
+
exports.valid = valid;
|
|
3838
|
+
exports.visited = visited;
|
|
3839
|
+
exports.dir = dir;
|
|
3840
|
+
exports.lang = lang;
|
|
3841
|
+
exports.not = not;
|
|
3842
|
+
exports.nthChild = nthChild;
|
|
3843
|
+
exports.nthLastChild = nthLastChild;
|
|
3844
|
+
exports.nthLastOfType = nthLastOfType;
|
|
3845
|
+
exports.nthOfType = nthOfType;
|
|
3846
|
+
exports.after = after;
|
|
3847
|
+
exports.before = before;
|
|
3848
|
+
exports.firstLetter = firstLetter;
|
|
3849
|
+
exports.firstLine = firstLine;
|
|
3850
|
+
exports.selection = selection;
|
|
3851
|
+
exports.backdrop = backdrop;
|
|
3852
|
+
exports.placeholder = placeholder;
|
|
3853
|
+
exports.cssFor = cssFor;
|
|
3854
|
+
exports.attribsFor = attribsFor;
|
|
3855
|
+
|
|
3856
|
+
|
|
3857
|
+
|
|
3858
|
+
var _objectAssign2 = _interopRequireDefault(objectAssign);
|
|
3859
|
+
|
|
3860
|
+
|
|
3861
|
+
|
|
3862
|
+
|
|
3863
|
+
|
|
3864
|
+
|
|
3865
|
+
|
|
3866
|
+
var _clean2 = _interopRequireDefault(clean_1);
|
|
3867
|
+
|
|
3868
|
+
|
|
3869
|
+
|
|
3870
|
+
|
|
3871
|
+
|
|
3872
|
+
var _hash2 = _interopRequireDefault(hash);
|
|
3873
|
+
|
|
3874
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
3875
|
+
|
|
3876
|
+
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
|
|
3877
|
+
|
|
3878
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
3879
|
+
/* stylesheet */
|
|
3880
|
+
|
|
3881
|
+
|
|
3882
|
+
var styleSheet = exports.styleSheet = new sheet.StyleSheet();
|
|
3883
|
+
// an isomorphic StyleSheet shim. hides all the nitty gritty.
|
|
3884
|
+
|
|
3885
|
+
// /**************** LIFTOFF IN 3... 2... 1... ****************/
|
|
3886
|
+
styleSheet.inject(); //eslint-disable-line indent
|
|
3887
|
+
// /**************** TO THE MOOOOOOON ****************/
|
|
3888
|
+
|
|
3889
|
+
// convenience function to toggle speedy
|
|
3890
|
+
function speedy(bool) {
|
|
3891
|
+
return styleSheet.speedy(bool);
|
|
3892
|
+
}
|
|
3893
|
+
|
|
3894
|
+
// plugins
|
|
3895
|
+
// we include these by default
|
|
3896
|
+
var plugins$1 = exports.plugins = styleSheet.plugins = new plugins.PluginSet([plugins.prefixes, plugins.contentWrap, plugins.fallbacks]);
|
|
3897
|
+
plugins$1.media = new plugins.PluginSet(); // neat! media, font-face, keyframes
|
|
3898
|
+
plugins$1.fontFace = new plugins.PluginSet();
|
|
3899
|
+
plugins$1.keyframes = new plugins.PluginSet([plugins.prefixes, plugins.fallbacks]);
|
|
3900
|
+
|
|
3901
|
+
// define some constants
|
|
3902
|
+
|
|
3903
|
+
var isDev = "development" === 'development' || !"development";
|
|
3904
|
+
var isTest = "development" === 'test';
|
|
3905
|
+
var isBrowser = typeof window !== 'undefined';
|
|
3906
|
+
|
|
3907
|
+
/**** simulations ****/
|
|
3908
|
+
|
|
3909
|
+
// a flag to enable simulation meta tags on dom nodes
|
|
3910
|
+
// defaults to true in dev mode. recommend *not* to
|
|
3911
|
+
// toggle often.
|
|
3912
|
+
var canSimulate = isDev;
|
|
3913
|
+
|
|
3914
|
+
// we use these flags for issuing warnings when simulate is called
|
|
3915
|
+
// in prod / in incorrect order
|
|
3916
|
+
var warned1 = false,
|
|
3917
|
+
warned2 = false;
|
|
3918
|
+
|
|
3919
|
+
// toggles simulation activity. shouldn't be needed in most cases
|
|
3920
|
+
function simulations() {
|
|
3921
|
+
var bool = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
3922
|
+
|
|
3923
|
+
canSimulate = !!bool;
|
|
3924
|
+
}
|
|
3925
|
+
|
|
3926
|
+
// use this on dom nodes to 'simulate' pseudoclasses
|
|
3927
|
+
// <div {...hover({ color: 'red' })} {...simulate('hover', 'visited')}>...</div>
|
|
3928
|
+
// you can even send in some weird ones, as long as it's in simple format
|
|
3929
|
+
// and matches an existing rule on the element
|
|
3930
|
+
// eg simulate('nthChild2', ':hover:active') etc
|
|
3931
|
+
function simulate() {
|
|
3932
|
+
for (var _len = arguments.length, pseudos = Array(_len), _key = 0; _key < _len; _key++) {
|
|
3933
|
+
pseudos[_key] = arguments[_key];
|
|
3934
|
+
}
|
|
3935
|
+
|
|
3936
|
+
pseudos = (0, _clean2.default)(pseudos);
|
|
3937
|
+
if (!pseudos) return {};
|
|
3938
|
+
if (!canSimulate) {
|
|
3939
|
+
if (!warned1) {
|
|
3940
|
+
console.warn('can\'t simulate without once calling simulations(true)'); //eslint-disable-line no-console
|
|
3941
|
+
warned1 = true;
|
|
3942
|
+
}
|
|
3943
|
+
if (!isDev && !isTest && !warned2) {
|
|
3944
|
+
console.warn('don\'t use simulation outside dev'); //eslint-disable-line no-console
|
|
3945
|
+
warned2 = true;
|
|
3946
|
+
}
|
|
3947
|
+
return {};
|
|
3948
|
+
}
|
|
3949
|
+
return pseudos.reduce(function (o, p) {
|
|
3950
|
+
return o['data-simulate-' + simple(p)] = '', o;
|
|
3951
|
+
}, {});
|
|
3952
|
+
}
|
|
3953
|
+
|
|
3954
|
+
/**** labels ****/
|
|
3955
|
+
// toggle for debug labels.
|
|
3956
|
+
// *shouldn't* have to mess with this manually
|
|
3957
|
+
var hasLabels = isDev;
|
|
3958
|
+
|
|
3959
|
+
function cssLabels(bool) {
|
|
3960
|
+
hasLabels = !!bool;
|
|
3961
|
+
}
|
|
3962
|
+
|
|
3963
|
+
// takes a string, converts to lowercase, strips out nonalphanumeric.
|
|
3964
|
+
function simple(str) {
|
|
3965
|
+
var char = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
3966
|
+
|
|
3967
|
+
return str.toLowerCase().replace(/[^a-z0-9]/g, char);
|
|
3968
|
+
}
|
|
3969
|
+
|
|
3970
|
+
// hashes a string to something 'unique'
|
|
3971
|
+
// we use this to generate ids for styles
|
|
3972
|
+
|
|
3973
|
+
|
|
3974
|
+
function hashify(obj) {
|
|
3975
|
+
var str = JSON.stringify(obj);
|
|
3976
|
+
var toRet = (0, _hash2.default)(str).toString(36);
|
|
3977
|
+
if (obj.label && obj.label.length > 0 && isDev) {
|
|
3978
|
+
return simple(obj.label.join('.'), '-') + '-' + toRet;
|
|
3979
|
+
}
|
|
3980
|
+
return toRet;
|
|
3981
|
+
}
|
|
3982
|
+
|
|
3983
|
+
// of shape { 'data-css-<id>': '' }
|
|
3984
|
+
function isLikeRule(rule) {
|
|
3985
|
+
var keys = Object.keys(rule).filter(function (x) {
|
|
3986
|
+
return x !== 'toString';
|
|
3987
|
+
});
|
|
3988
|
+
if (keys.length !== 1) {
|
|
3989
|
+
return false;
|
|
3990
|
+
}
|
|
3991
|
+
return !!/data\-css\-([a-zA-Z0-9\-_]+)/.exec(keys[0]);
|
|
3992
|
+
}
|
|
3993
|
+
|
|
3994
|
+
// extracts id from a { 'data-css-<id>': ''} like object
|
|
3995
|
+
function idFor(rule) {
|
|
3996
|
+
var keys = Object.keys(rule).filter(function (x) {
|
|
3997
|
+
return x !== 'toString';
|
|
3998
|
+
});
|
|
3999
|
+
if (keys.length !== 1) throw new Error('not a rule');
|
|
4000
|
+
var regex = /data\-css\-([a-zA-Z0-9\-_]+)/;
|
|
4001
|
+
var match = regex.exec(keys[0]);
|
|
4002
|
+
if (!match) throw new Error('not a rule');
|
|
4003
|
+
return match[1];
|
|
4004
|
+
}
|
|
4005
|
+
|
|
4006
|
+
// from https://github.com/j2css/j2c/blob/5d381c2d721d04b54fabe6a165d587247c3087cb/src/helpers.js#L28-L61
|
|
4007
|
+
|
|
4008
|
+
// "Tokenizes" the selectors into parts relevant for the next function.
|
|
4009
|
+
// Strings and comments are matched, but ignored afterwards.
|
|
4010
|
+
// This is not a full tokenizers. It only recognizes comas, parentheses,
|
|
4011
|
+
// strings and comments.
|
|
4012
|
+
// regexp generated by scripts/regexps.js then trimmed by hand
|
|
4013
|
+
var selectorTokenizer = /[(),]|"(?:\\.|[^"\n])*"|'(?:\\.|[^'\n])*'|\/\*[\s\S]*?\*\//g;
|
|
4014
|
+
|
|
4015
|
+
/**
|
|
4016
|
+
* This will split a coma-separated selector list into individual selectors,
|
|
4017
|
+
* ignoring comas in strings, comments and in :pseudo-selectors(parameter, lists).
|
|
4018
|
+
*
|
|
4019
|
+
* @param {string} selector
|
|
4020
|
+
* @return {string[]}
|
|
4021
|
+
*/
|
|
4022
|
+
|
|
4023
|
+
function splitSelector(selector) {
|
|
4024
|
+
if (selector.indexOf(',') === -1) {
|
|
4025
|
+
return [selector];
|
|
4026
|
+
}
|
|
4027
|
+
|
|
4028
|
+
var indices = [],
|
|
4029
|
+
res = [],
|
|
4030
|
+
inParen = 0,
|
|
4031
|
+
o;
|
|
4032
|
+
/*eslint-disable no-cond-assign*/
|
|
4033
|
+
while (o = selectorTokenizer.exec(selector)) {
|
|
4034
|
+
/*eslint-enable no-cond-assign*/
|
|
4035
|
+
switch (o[0]) {
|
|
4036
|
+
case '(':
|
|
4037
|
+
inParen++;break;
|
|
4038
|
+
case ')':
|
|
4039
|
+
inParen--;break;
|
|
4040
|
+
case ',':
|
|
4041
|
+
if (inParen) break;indices.push(o.index);
|
|
4042
|
+
}
|
|
4043
|
+
}
|
|
4044
|
+
for (o = indices.length; o--;) {
|
|
4045
|
+
res.unshift(selector.slice(indices[o] + 1));
|
|
4046
|
+
selector = selector.slice(0, indices[o]);
|
|
4047
|
+
}
|
|
4048
|
+
res.unshift(selector);
|
|
4049
|
+
return res;
|
|
4050
|
+
}
|
|
4051
|
+
|
|
4052
|
+
function selector(id, path) {
|
|
4053
|
+
if (!id) {
|
|
4054
|
+
return path.replace(/\&/g, '');
|
|
4055
|
+
}
|
|
4056
|
+
if (!path) return '.css-' + id + ',[data-css-' + id + ']';
|
|
4057
|
+
|
|
4058
|
+
var x = splitSelector(path).map(function (x) {
|
|
4059
|
+
return x.indexOf('&') >= 0 ? [x.replace(/\&/mg, '.css-' + id), x.replace(/\&/mg, '[data-css-' + id + ']')].join(',') // todo - make sure each sub selector has an &
|
|
4060
|
+
: '.css-' + id + x + ',[data-css-' + id + ']' + x;
|
|
4061
|
+
}).join(',');
|
|
4062
|
+
|
|
4063
|
+
if (canSimulate && /^\&\:/.exec(path) && !/\s/.exec(path)) {
|
|
4064
|
+
x += ',.css-' + id + '[data-simulate-' + simple(path) + '],[data-css-' + id + '][data-simulate-' + simple(path) + ']';
|
|
4065
|
+
}
|
|
4066
|
+
return x;
|
|
4067
|
+
}
|
|
4068
|
+
|
|
4069
|
+
// end https://github.com/j2css/j2c/blob/5d381c2d721d04b54fabe6a165d587247c3087cb/src/helpers.js#L28-L61
|
|
4070
|
+
|
|
4071
|
+
|
|
4072
|
+
function toCSS(_ref) {
|
|
4073
|
+
var selector = _ref.selector,
|
|
4074
|
+
style = _ref.style;
|
|
4075
|
+
|
|
4076
|
+
var result = plugins$1.transform({ selector: selector, style: style });
|
|
4077
|
+
return result.selector + '{' + (0, CSSPropertyOperations.createMarkupForStyles)(result.style) + '}';
|
|
4078
|
+
}
|
|
4079
|
+
|
|
4080
|
+
function deconstruct(style) {
|
|
4081
|
+
// we can be sure it's not infinitely nested here
|
|
4082
|
+
var plain = void 0,
|
|
4083
|
+
selects = void 0,
|
|
4084
|
+
medias = void 0,
|
|
4085
|
+
supports = void 0;
|
|
4086
|
+
Object.keys(style).forEach(function (key) {
|
|
4087
|
+
if (key.indexOf('&') >= 0) {
|
|
4088
|
+
selects = selects || {};
|
|
4089
|
+
selects[key] = style[key];
|
|
4090
|
+
} else if (key.indexOf('@media') === 0) {
|
|
4091
|
+
medias = medias || {};
|
|
4092
|
+
medias[key] = deconstruct(style[key]);
|
|
4093
|
+
} else if (key.indexOf('@supports') === 0) {
|
|
4094
|
+
supports = supports || {};
|
|
4095
|
+
supports[key] = deconstruct(style[key]);
|
|
4096
|
+
} else if (key === 'label') {
|
|
4097
|
+
if (style.label.length > 0) {
|
|
4098
|
+
plain = plain || {};
|
|
4099
|
+
plain.label = hasLabels ? style.label.join('.') : '';
|
|
4100
|
+
}
|
|
4101
|
+
} else {
|
|
4102
|
+
plain = plain || {};
|
|
4103
|
+
plain[key] = style[key];
|
|
4104
|
+
}
|
|
4105
|
+
});
|
|
4106
|
+
return { plain: plain, selects: selects, medias: medias, supports: supports };
|
|
4107
|
+
}
|
|
4108
|
+
|
|
4109
|
+
function deconstructedStyleToCSS(id, style) {
|
|
4110
|
+
var css = [];
|
|
4111
|
+
|
|
4112
|
+
// plugins here
|
|
4113
|
+
var plain = style.plain,
|
|
4114
|
+
selects = style.selects,
|
|
4115
|
+
medias = style.medias,
|
|
4116
|
+
supports = style.supports;
|
|
4117
|
+
|
|
4118
|
+
if (plain) {
|
|
4119
|
+
css.push(toCSS({ style: plain, selector: selector(id) }));
|
|
4120
|
+
}
|
|
4121
|
+
if (selects) {
|
|
4122
|
+
Object.keys(selects).forEach(function (key) {
|
|
4123
|
+
return css.push(toCSS({ style: selects[key], selector: selector(id, key) }));
|
|
4124
|
+
});
|
|
4125
|
+
}
|
|
4126
|
+
if (medias) {
|
|
4127
|
+
Object.keys(medias).forEach(function (key) {
|
|
4128
|
+
return css.push(key + '{' + deconstructedStyleToCSS(id, medias[key]).join('') + '}');
|
|
4129
|
+
});
|
|
4130
|
+
}
|
|
4131
|
+
if (supports) {
|
|
4132
|
+
Object.keys(supports).forEach(function (key) {
|
|
4133
|
+
return css.push(key + '{' + deconstructedStyleToCSS(id, supports[key]).join('') + '}');
|
|
4134
|
+
});
|
|
4135
|
+
}
|
|
4136
|
+
return css;
|
|
4137
|
+
}
|
|
4138
|
+
|
|
4139
|
+
// this cache to track which rules have
|
|
4140
|
+
// been inserted into the stylesheet
|
|
4141
|
+
var inserted = styleSheet.inserted = {};
|
|
4142
|
+
|
|
4143
|
+
// and helpers to insert rules into said styleSheet
|
|
4144
|
+
function insert(spec) {
|
|
4145
|
+
if (!inserted[spec.id]) {
|
|
4146
|
+
inserted[spec.id] = true;
|
|
4147
|
+
var deconstructed = deconstruct(spec.style);
|
|
4148
|
+
var rules = deconstructedStyleToCSS(spec.id, deconstructed);
|
|
4149
|
+
inserted[spec.id] = isBrowser ? true : rules;
|
|
4150
|
+
rules.forEach(function (cssRule) {
|
|
4151
|
+
return styleSheet.insert(cssRule);
|
|
4152
|
+
});
|
|
4153
|
+
}
|
|
4154
|
+
}
|
|
4155
|
+
|
|
4156
|
+
// a simple cache to store generated rules
|
|
4157
|
+
var registered = styleSheet.registered = {};
|
|
4158
|
+
function register(spec) {
|
|
4159
|
+
if (!registered[spec.id]) {
|
|
4160
|
+
registered[spec.id] = spec;
|
|
4161
|
+
}
|
|
4162
|
+
}
|
|
4163
|
+
|
|
4164
|
+
function _getRegistered(rule) {
|
|
4165
|
+
if (isLikeRule(rule)) {
|
|
4166
|
+
var ret = registered[idFor(rule)];
|
|
4167
|
+
if (ret == null) {
|
|
4168
|
+
throw new Error('[glamor] an unexpected rule cache miss occurred. This is probably a sign of multiple glamor instances in your app. See https://github.com/threepointone/glamor/issues/79');
|
|
4169
|
+
}
|
|
4170
|
+
return ret;
|
|
4171
|
+
}
|
|
4172
|
+
return rule;
|
|
4173
|
+
}
|
|
4174
|
+
|
|
4175
|
+
// todo - perf
|
|
4176
|
+
var ruleCache = {};
|
|
4177
|
+
function toRule(spec) {
|
|
4178
|
+
register(spec);
|
|
4179
|
+
insert(spec);
|
|
4180
|
+
|
|
4181
|
+
if (ruleCache[spec.id]) {
|
|
4182
|
+
return ruleCache[spec.id];
|
|
4183
|
+
}
|
|
4184
|
+
|
|
4185
|
+
var ret = _defineProperty({}, 'data-css-' + spec.id, hasLabels ? spec.label || '' : '');
|
|
4186
|
+
Object.defineProperty(ret, 'toString', {
|
|
4187
|
+
enumerable: false, value: function value() {
|
|
4188
|
+
return 'css-' + spec.id;
|
|
4189
|
+
}
|
|
4190
|
+
});
|
|
4191
|
+
ruleCache[spec.id] = ret;
|
|
4192
|
+
return ret;
|
|
4193
|
+
}
|
|
4194
|
+
|
|
4195
|
+
function log() {
|
|
4196
|
+
//eslint-disable-line no-unused-vars
|
|
4197
|
+
console.log(this); //eslint-disable-line no-console
|
|
4198
|
+
return this;
|
|
4199
|
+
}
|
|
4200
|
+
|
|
4201
|
+
function isSelector(key) {
|
|
4202
|
+
var possibles = [':', '.', '[', '>', ' '],
|
|
4203
|
+
found = false,
|
|
4204
|
+
ch = key.charAt(0);
|
|
4205
|
+
for (var i = 0; i < possibles.length; i++) {
|
|
4206
|
+
if (ch === possibles[i]) {
|
|
4207
|
+
found = true;
|
|
4208
|
+
break;
|
|
4209
|
+
}
|
|
4210
|
+
}
|
|
4211
|
+
return found || key.indexOf('&') >= 0;
|
|
4212
|
+
}
|
|
4213
|
+
|
|
4214
|
+
function joinSelectors(a, b) {
|
|
4215
|
+
var as = splitSelector(a).map(function (a) {
|
|
4216
|
+
return !(a.indexOf('&') >= 0) ? '&' + a : a;
|
|
4217
|
+
});
|
|
4218
|
+
var bs = splitSelector(b).map(function (b) {
|
|
4219
|
+
return !(b.indexOf('&') >= 0) ? '&' + b : b;
|
|
4220
|
+
});
|
|
4221
|
+
|
|
4222
|
+
return bs.reduce(function (arr, b) {
|
|
4223
|
+
return arr.concat(as.map(function (a) {
|
|
4224
|
+
return b.replace(/\&/g, a);
|
|
4225
|
+
}));
|
|
4226
|
+
}, []).join(',');
|
|
4227
|
+
}
|
|
4228
|
+
|
|
4229
|
+
function joinMediaQueries(a, b) {
|
|
4230
|
+
return a ? '@media ' + a.substring(6) + ' and ' + b.substring(6) : b;
|
|
4231
|
+
}
|
|
4232
|
+
|
|
4233
|
+
function isMediaQuery(key) {
|
|
4234
|
+
return key.indexOf('@media') === 0;
|
|
4235
|
+
}
|
|
4236
|
+
|
|
4237
|
+
function isSupports(key) {
|
|
4238
|
+
return key.indexOf('@supports') === 0;
|
|
4239
|
+
}
|
|
4240
|
+
|
|
4241
|
+
function joinSupports(a, b) {
|
|
4242
|
+
return a ? '@supports ' + a.substring(9) + ' and ' + b.substring(9) : b;
|
|
4243
|
+
}
|
|
4244
|
+
|
|
4245
|
+
// flatten a nested array
|
|
4246
|
+
function flatten(inArr) {
|
|
4247
|
+
var arr = [];
|
|
4248
|
+
for (var i = 0; i < inArr.length; i++) {
|
|
4249
|
+
if (Array.isArray(inArr[i])) arr = arr.concat(flatten(inArr[i]));else arr = arr.concat(inArr[i]);
|
|
4250
|
+
}
|
|
4251
|
+
return arr;
|
|
4252
|
+
}
|
|
4253
|
+
|
|
4254
|
+
var prefixedPseudoSelectors = {
|
|
4255
|
+
'::placeholder': ['::-webkit-input-placeholder', '::-moz-placeholder', '::-ms-input-placeholder'],
|
|
4256
|
+
':fullscreen': [':-webkit-full-screen', ':-moz-full-screen', ':-ms-fullscreen']
|
|
4257
|
+
|
|
4258
|
+
// mutable! modifies dest.
|
|
4259
|
+
};function build(dest, _ref2) {
|
|
4260
|
+
var _ref2$selector = _ref2.selector,
|
|
4261
|
+
selector = _ref2$selector === undefined ? '' : _ref2$selector,
|
|
4262
|
+
_ref2$mq = _ref2.mq,
|
|
4263
|
+
mq = _ref2$mq === undefined ? '' : _ref2$mq,
|
|
4264
|
+
_ref2$supp = _ref2.supp,
|
|
4265
|
+
supp = _ref2$supp === undefined ? '' : _ref2$supp,
|
|
4266
|
+
_ref2$src = _ref2.src,
|
|
4267
|
+
src = _ref2$src === undefined ? {} : _ref2$src;
|
|
4268
|
+
|
|
4269
|
+
|
|
4270
|
+
if (!Array.isArray(src)) {
|
|
4271
|
+
src = [src];
|
|
4272
|
+
}
|
|
4273
|
+
src = flatten(src);
|
|
4274
|
+
|
|
4275
|
+
src.forEach(function (_src) {
|
|
4276
|
+
if (isLikeRule(_src)) {
|
|
4277
|
+
var reg = _getRegistered(_src);
|
|
4278
|
+
if (reg.type !== 'css') {
|
|
4279
|
+
throw new Error('cannot merge this rule');
|
|
4280
|
+
}
|
|
4281
|
+
_src = reg.style;
|
|
4282
|
+
}
|
|
4283
|
+
_src = (0, _clean2.default)(_src);
|
|
4284
|
+
if (_src && _src.composes) {
|
|
4285
|
+
build(dest, { selector: selector, mq: mq, supp: supp, src: _src.composes });
|
|
4286
|
+
}
|
|
4287
|
+
Object.keys(_src || {}).forEach(function (key) {
|
|
4288
|
+
if (isSelector(key)) {
|
|
4289
|
+
|
|
4290
|
+
if (prefixedPseudoSelectors[key]) {
|
|
4291
|
+
prefixedPseudoSelectors[key].forEach(function (p) {
|
|
4292
|
+
return build(dest, { selector: joinSelectors(selector, p), mq: mq, supp: supp, src: _src[key] });
|
|
4293
|
+
});
|
|
4294
|
+
}
|
|
4295
|
+
|
|
4296
|
+
build(dest, { selector: joinSelectors(selector, key), mq: mq, supp: supp, src: _src[key] });
|
|
4297
|
+
} else if (isMediaQuery(key)) {
|
|
4298
|
+
build(dest, { selector: selector, mq: joinMediaQueries(mq, key), supp: supp, src: _src[key] });
|
|
4299
|
+
} else if (isSupports(key)) {
|
|
4300
|
+
build(dest, { selector: selector, mq: mq, supp: joinSupports(supp, key), src: _src[key] });
|
|
4301
|
+
} else if (key === 'composes') {
|
|
4302
|
+
// ignore, we already dealth with it
|
|
4303
|
+
} else {
|
|
4304
|
+
var _dest = dest;
|
|
4305
|
+
if (supp) {
|
|
4306
|
+
_dest[supp] = _dest[supp] || {};
|
|
4307
|
+
_dest = _dest[supp];
|
|
4308
|
+
}
|
|
4309
|
+
if (mq) {
|
|
4310
|
+
_dest[mq] = _dest[mq] || {};
|
|
4311
|
+
_dest = _dest[mq];
|
|
4312
|
+
}
|
|
4313
|
+
if (selector) {
|
|
4314
|
+
_dest[selector] = _dest[selector] || {};
|
|
4315
|
+
_dest = _dest[selector];
|
|
4316
|
+
}
|
|
4317
|
+
|
|
4318
|
+
if (key === 'label') {
|
|
4319
|
+
if (hasLabels) {
|
|
4320
|
+
dest.label = dest.label.concat(_src.label);
|
|
4321
|
+
}
|
|
4322
|
+
} else {
|
|
4323
|
+
_dest[key] = _src[key];
|
|
4324
|
+
}
|
|
4325
|
+
}
|
|
4326
|
+
});
|
|
4327
|
+
});
|
|
4328
|
+
}
|
|
4329
|
+
|
|
4330
|
+
function _css(rules) {
|
|
4331
|
+
var style = { label: [] };
|
|
4332
|
+
build(style, { src: rules }); // mutative! but worth it.
|
|
4333
|
+
|
|
4334
|
+
var spec = {
|
|
4335
|
+
id: hashify(style),
|
|
4336
|
+
style: style, label: hasLabels ? style.label.join('.') : '',
|
|
4337
|
+
type: 'css'
|
|
4338
|
+
};
|
|
4339
|
+
return toRule(spec);
|
|
4340
|
+
}
|
|
4341
|
+
|
|
4342
|
+
var nullrule = {
|
|
4343
|
+
// 'data-css-nil': ''
|
|
4344
|
+
};
|
|
4345
|
+
Object.defineProperty(nullrule, 'toString', {
|
|
4346
|
+
enumerable: false, value: function value() {
|
|
4347
|
+
return 'css-nil';
|
|
4348
|
+
}
|
|
4349
|
+
});
|
|
4350
|
+
|
|
4351
|
+
var inputCaches = typeof WeakMap !== 'undefined' ? [nullrule, new WeakMap(), new WeakMap(), new WeakMap()] : [nullrule];
|
|
4352
|
+
|
|
4353
|
+
var warnedWeakMapError = false;
|
|
4354
|
+
function multiIndexCache(fn) {
|
|
4355
|
+
return function (args) {
|
|
4356
|
+
if (inputCaches[args.length]) {
|
|
4357
|
+
var coi = inputCaches[args.length];
|
|
4358
|
+
var ctr = 0;
|
|
4359
|
+
while (ctr < args.length - 1) {
|
|
4360
|
+
if (!coi.has(args[ctr])) {
|
|
4361
|
+
coi.set(args[ctr], new WeakMap());
|
|
4362
|
+
}
|
|
4363
|
+
coi = coi.get(args[ctr]);
|
|
4364
|
+
ctr++;
|
|
4365
|
+
}
|
|
4366
|
+
if (coi.has(args[args.length - 1])) {
|
|
4367
|
+
var ret = coi.get(args[ctr]);
|
|
4368
|
+
|
|
4369
|
+
if (registered[ret.toString().substring(4)]) {
|
|
4370
|
+
// make sure it hasn't been flushed
|
|
4371
|
+
return ret;
|
|
4372
|
+
}
|
|
4373
|
+
}
|
|
4374
|
+
}
|
|
4375
|
+
var value = fn(args);
|
|
4376
|
+
if (inputCaches[args.length]) {
|
|
4377
|
+
var _ctr = 0,
|
|
4378
|
+
_coi = inputCaches[args.length];
|
|
4379
|
+
while (_ctr < args.length - 1) {
|
|
4380
|
+
_coi = _coi.get(args[_ctr]);
|
|
4381
|
+
_ctr++;
|
|
4382
|
+
}
|
|
4383
|
+
try {
|
|
4384
|
+
_coi.set(args[_ctr], value);
|
|
4385
|
+
} catch (err) {
|
|
4386
|
+
if (isDev && !warnedWeakMapError) {
|
|
4387
|
+
var _console;
|
|
4388
|
+
|
|
4389
|
+
warnedWeakMapError = true;
|
|
4390
|
+
(_console = console).warn.apply(_console, ['failed setting the WeakMap cache for args:'].concat(_toConsumableArray(args))); // eslint-disable-line no-console
|
|
4391
|
+
console.warn('this should NOT happen, please file a bug on the github repo.'); // eslint-disable-line no-console
|
|
4392
|
+
}
|
|
4393
|
+
}
|
|
4394
|
+
}
|
|
4395
|
+
return value;
|
|
4396
|
+
};
|
|
4397
|
+
}
|
|
4398
|
+
|
|
4399
|
+
var cachedCss = typeof WeakMap !== 'undefined' ? multiIndexCache(_css) : _css;
|
|
4400
|
+
|
|
4401
|
+
function css() {
|
|
4402
|
+
for (var _len2 = arguments.length, rules = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
4403
|
+
rules[_key2] = arguments[_key2];
|
|
4404
|
+
}
|
|
4405
|
+
|
|
4406
|
+
if (rules[0] && rules[0].length && rules[0].raw) {
|
|
4407
|
+
throw new Error('you forgot to include glamor/babel in your babel plugins.');
|
|
4408
|
+
}
|
|
4409
|
+
|
|
4410
|
+
rules = (0, _clean2.default)(rules);
|
|
4411
|
+
if (!rules) {
|
|
4412
|
+
return nullrule;
|
|
4413
|
+
}
|
|
4414
|
+
|
|
4415
|
+
return cachedCss(rules);
|
|
4416
|
+
}
|
|
4417
|
+
|
|
4418
|
+
css.insert = function (css) {
|
|
4419
|
+
var spec = {
|
|
4420
|
+
id: hashify(css),
|
|
4421
|
+
css: css,
|
|
4422
|
+
type: 'raw'
|
|
4423
|
+
};
|
|
4424
|
+
register(spec);
|
|
4425
|
+
if (!inserted[spec.id]) {
|
|
4426
|
+
styleSheet.insert(spec.css);
|
|
4427
|
+
inserted[spec.id] = isBrowser ? true : [spec.css];
|
|
4428
|
+
}
|
|
4429
|
+
};
|
|
4430
|
+
|
|
4431
|
+
var insertRule = exports.insertRule = css.insert;
|
|
4432
|
+
|
|
4433
|
+
css.global = function (selector, style) {
|
|
4434
|
+
style = (0, _clean2.default)(style);
|
|
4435
|
+
if (style) {
|
|
4436
|
+
return css.insert(toCSS({ selector: selector, style: style }));
|
|
4437
|
+
}
|
|
4438
|
+
};
|
|
4439
|
+
|
|
4440
|
+
var insertGlobal = exports.insertGlobal = css.global;
|
|
4441
|
+
|
|
4442
|
+
function insertKeyframe(spec) {
|
|
4443
|
+
if (!inserted[spec.id]) {
|
|
4444
|
+
var inner = Object.keys(spec.keyframes).map(function (kf) {
|
|
4445
|
+
var result = plugins$1.keyframes.transform({ id: spec.id, name: kf, style: spec.keyframes[kf] });
|
|
4446
|
+
return result.name + '{' + (0, CSSPropertyOperations.createMarkupForStyles)(result.style) + '}';
|
|
4447
|
+
}).join('');
|
|
4448
|
+
|
|
4449
|
+
var rules = ['-webkit-', '-moz-', '-o-', ''].map(function (prefix) {
|
|
4450
|
+
return '@' + prefix + 'keyframes ' + (spec.name + '_' + spec.id) + '{' + inner + '}';
|
|
4451
|
+
});
|
|
4452
|
+
rules.forEach(function (rule) {
|
|
4453
|
+
return styleSheet.insert(rule);
|
|
4454
|
+
});
|
|
4455
|
+
|
|
4456
|
+
inserted[spec.id] = isBrowser ? true : rules;
|
|
4457
|
+
}
|
|
4458
|
+
}
|
|
4459
|
+
css.keyframes = function (name, kfs) {
|
|
4460
|
+
if (!kfs) {
|
|
4461
|
+
kfs = name, name = 'animation';
|
|
4462
|
+
}
|
|
4463
|
+
|
|
4464
|
+
// do not ignore empty keyframe definitions for now.
|
|
4465
|
+
kfs = (0, _clean2.default)(kfs) || {};
|
|
4466
|
+
var spec = {
|
|
4467
|
+
id: hashify({ name: name, kfs: kfs }),
|
|
4468
|
+
type: 'keyframes',
|
|
4469
|
+
name: name,
|
|
4470
|
+
keyframes: kfs
|
|
4471
|
+
};
|
|
4472
|
+
register(spec);
|
|
4473
|
+
insertKeyframe(spec);
|
|
4474
|
+
return name + '_' + spec.id;
|
|
4475
|
+
};
|
|
4476
|
+
|
|
4477
|
+
// we don't go all out for fonts as much, giving a simple font loading strategy
|
|
4478
|
+
// use a fancier lib if you need moar power
|
|
4479
|
+
css.fontFace = function (font) {
|
|
4480
|
+
font = (0, _clean2.default)(font);
|
|
4481
|
+
var spec = {
|
|
4482
|
+
id: hashify(font),
|
|
4483
|
+
type: 'font-face',
|
|
4484
|
+
font: font
|
|
4485
|
+
};
|
|
4486
|
+
register(spec);
|
|
4487
|
+
insertFontFace(spec);
|
|
4488
|
+
|
|
4489
|
+
return font.fontFamily;
|
|
4490
|
+
};
|
|
4491
|
+
|
|
4492
|
+
var fontFace = exports.fontFace = css.fontFace;
|
|
4493
|
+
var keyframes = exports.keyframes = css.keyframes;
|
|
4494
|
+
|
|
4495
|
+
function insertFontFace(spec) {
|
|
4496
|
+
if (!inserted[spec.id]) {
|
|
4497
|
+
var rule = '@font-face{' + (0, CSSPropertyOperations.createMarkupForStyles)(spec.font) + '}';
|
|
4498
|
+
styleSheet.insert(rule);
|
|
4499
|
+
inserted[spec.id] = isBrowser ? true : [rule];
|
|
4500
|
+
}
|
|
4501
|
+
}
|
|
4502
|
+
|
|
4503
|
+
// rehydrate the insertion cache with ids sent from
|
|
4504
|
+
// renderStatic / renderStaticOptimized
|
|
4505
|
+
function rehydrate(ids) {
|
|
4506
|
+
// load up ids
|
|
4507
|
+
(0, _objectAssign2.default)(inserted, ids.reduce(function (o, i) {
|
|
4508
|
+
return o[i] = true, o;
|
|
4509
|
+
}, {}));
|
|
4510
|
+
// assume css loaded separately
|
|
4511
|
+
}
|
|
4512
|
+
|
|
4513
|
+
// clears out the cache and empties the stylesheet
|
|
4514
|
+
// best for tests, though there might be some value for SSR.
|
|
4515
|
+
|
|
4516
|
+
function flush() {
|
|
4517
|
+
inserted = styleSheet.inserted = {};
|
|
4518
|
+
registered = styleSheet.registered = {};
|
|
4519
|
+
ruleCache = {};
|
|
4520
|
+
styleSheet.flush();
|
|
4521
|
+
styleSheet.inject();
|
|
4522
|
+
}
|
|
4523
|
+
|
|
4524
|
+
var presets = exports.presets = {
|
|
4525
|
+
mobile: '(min-width: 400px)',
|
|
4526
|
+
Mobile: '@media (min-width: 400px)',
|
|
4527
|
+
phablet: '(min-width: 550px)',
|
|
4528
|
+
Phablet: '@media (min-width: 550px)',
|
|
4529
|
+
tablet: '(min-width: 750px)',
|
|
4530
|
+
Tablet: '@media (min-width: 750px)',
|
|
4531
|
+
desktop: '(min-width: 1000px)',
|
|
4532
|
+
Desktop: '@media (min-width: 1000px)',
|
|
4533
|
+
hd: '(min-width: 1200px)',
|
|
4534
|
+
Hd: '@media (min-width: 1200px)'
|
|
4535
|
+
};
|
|
4536
|
+
|
|
4537
|
+
var style = exports.style = css;
|
|
4538
|
+
|
|
4539
|
+
function select(selector) {
|
|
4540
|
+
for (var _len3 = arguments.length, styles = Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
|
|
4541
|
+
styles[_key3 - 1] = arguments[_key3];
|
|
4542
|
+
}
|
|
4543
|
+
|
|
4544
|
+
if (!selector) {
|
|
4545
|
+
return style(styles);
|
|
4546
|
+
}
|
|
4547
|
+
return css(_defineProperty({}, selector, styles));
|
|
4548
|
+
}
|
|
4549
|
+
var $ = exports.$ = select;
|
|
4550
|
+
|
|
4551
|
+
function parent(selector) {
|
|
4552
|
+
for (var _len4 = arguments.length, styles = Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
|
|
4553
|
+
styles[_key4 - 1] = arguments[_key4];
|
|
4554
|
+
}
|
|
4555
|
+
|
|
4556
|
+
return css(_defineProperty({}, selector + ' &', styles));
|
|
4557
|
+
}
|
|
4558
|
+
|
|
4559
|
+
var merge = exports.merge = css;
|
|
4560
|
+
var compose = exports.compose = css;
|
|
4561
|
+
|
|
4562
|
+
function media(query) {
|
|
4563
|
+
for (var _len5 = arguments.length, rules = Array(_len5 > 1 ? _len5 - 1 : 0), _key5 = 1; _key5 < _len5; _key5++) {
|
|
4564
|
+
rules[_key5 - 1] = arguments[_key5];
|
|
4565
|
+
}
|
|
4566
|
+
|
|
4567
|
+
return css(_defineProperty({}, '@media ' + query, rules));
|
|
4568
|
+
}
|
|
4569
|
+
|
|
4570
|
+
function pseudo(selector) {
|
|
4571
|
+
for (var _len6 = arguments.length, styles = Array(_len6 > 1 ? _len6 - 1 : 0), _key6 = 1; _key6 < _len6; _key6++) {
|
|
4572
|
+
styles[_key6 - 1] = arguments[_key6];
|
|
4573
|
+
}
|
|
4574
|
+
|
|
4575
|
+
return css(_defineProperty({}, selector, styles));
|
|
4576
|
+
}
|
|
4577
|
+
|
|
4578
|
+
// allllll the pseudoclasses
|
|
4579
|
+
|
|
4580
|
+
function active(x) {
|
|
4581
|
+
return pseudo(':active', x);
|
|
4582
|
+
}
|
|
4583
|
+
|
|
4584
|
+
function any(x) {
|
|
4585
|
+
return pseudo(':any', x);
|
|
4586
|
+
}
|
|
4587
|
+
|
|
4588
|
+
function checked(x) {
|
|
4589
|
+
return pseudo(':checked', x);
|
|
4590
|
+
}
|
|
4591
|
+
|
|
4592
|
+
function disabled(x) {
|
|
4593
|
+
return pseudo(':disabled', x);
|
|
4594
|
+
}
|
|
4595
|
+
|
|
4596
|
+
function empty(x) {
|
|
4597
|
+
return pseudo(':empty', x);
|
|
4598
|
+
}
|
|
4599
|
+
|
|
4600
|
+
function enabled(x) {
|
|
4601
|
+
return pseudo(':enabled', x);
|
|
4602
|
+
}
|
|
4603
|
+
|
|
4604
|
+
function _default(x) {
|
|
4605
|
+
return pseudo(':default', x); // note '_default' name
|
|
4606
|
+
}
|
|
4607
|
+
|
|
4608
|
+
function first(x) {
|
|
4609
|
+
return pseudo(':first', x);
|
|
4610
|
+
}
|
|
4611
|
+
|
|
4612
|
+
function firstChild(x) {
|
|
4613
|
+
return pseudo(':first-child', x);
|
|
4614
|
+
}
|
|
4615
|
+
|
|
4616
|
+
function firstOfType(x) {
|
|
4617
|
+
return pseudo(':first-of-type', x);
|
|
4618
|
+
}
|
|
4619
|
+
|
|
4620
|
+
function fullscreen(x) {
|
|
4621
|
+
return pseudo(':fullscreen', x);
|
|
4622
|
+
}
|
|
4623
|
+
|
|
4624
|
+
function focus(x) {
|
|
4625
|
+
return pseudo(':focus', x);
|
|
4626
|
+
}
|
|
4627
|
+
|
|
4628
|
+
function hover(x) {
|
|
4629
|
+
return pseudo(':hover', x);
|
|
4630
|
+
}
|
|
4631
|
+
|
|
4632
|
+
function indeterminate(x) {
|
|
4633
|
+
return pseudo(':indeterminate', x);
|
|
4634
|
+
}
|
|
4635
|
+
|
|
4636
|
+
function inRange(x) {
|
|
4637
|
+
return pseudo(':in-range', x);
|
|
4638
|
+
}
|
|
4639
|
+
|
|
4640
|
+
function invalid(x) {
|
|
4641
|
+
return pseudo(':invalid', x);
|
|
4642
|
+
}
|
|
4643
|
+
|
|
4644
|
+
function lastChild(x) {
|
|
4645
|
+
return pseudo(':last-child', x);
|
|
4646
|
+
}
|
|
4647
|
+
|
|
4648
|
+
function lastOfType(x) {
|
|
4649
|
+
return pseudo(':last-of-type', x);
|
|
4650
|
+
}
|
|
4651
|
+
|
|
4652
|
+
function left(x) {
|
|
4653
|
+
return pseudo(':left', x);
|
|
4654
|
+
}
|
|
4655
|
+
|
|
4656
|
+
function link(x) {
|
|
4657
|
+
return pseudo(':link', x);
|
|
4658
|
+
}
|
|
4659
|
+
|
|
4660
|
+
function onlyChild(x) {
|
|
4661
|
+
return pseudo(':only-child', x);
|
|
4662
|
+
}
|
|
4663
|
+
|
|
4664
|
+
function onlyOfType(x) {
|
|
4665
|
+
return pseudo(':only-of-type', x);
|
|
4666
|
+
}
|
|
4667
|
+
|
|
4668
|
+
function optional(x) {
|
|
4669
|
+
return pseudo(':optional', x);
|
|
4670
|
+
}
|
|
4671
|
+
|
|
4672
|
+
function outOfRange(x) {
|
|
4673
|
+
return pseudo(':out-of-range', x);
|
|
4674
|
+
}
|
|
4675
|
+
|
|
4676
|
+
function readOnly(x) {
|
|
4677
|
+
return pseudo(':read-only', x);
|
|
4678
|
+
}
|
|
4679
|
+
|
|
4680
|
+
function readWrite(x) {
|
|
4681
|
+
return pseudo(':read-write', x);
|
|
4682
|
+
}
|
|
4683
|
+
|
|
4684
|
+
function required(x) {
|
|
4685
|
+
return pseudo(':required', x);
|
|
4686
|
+
}
|
|
4687
|
+
|
|
4688
|
+
function right(x) {
|
|
4689
|
+
return pseudo(':right', x);
|
|
4690
|
+
}
|
|
4691
|
+
|
|
4692
|
+
function root(x) {
|
|
4693
|
+
return pseudo(':root', x);
|
|
4694
|
+
}
|
|
4695
|
+
|
|
4696
|
+
function scope(x) {
|
|
4697
|
+
return pseudo(':scope', x);
|
|
4698
|
+
}
|
|
4699
|
+
|
|
4700
|
+
function target(x) {
|
|
4701
|
+
return pseudo(':target', x);
|
|
4702
|
+
}
|
|
4703
|
+
|
|
4704
|
+
function valid(x) {
|
|
4705
|
+
return pseudo(':valid', x);
|
|
4706
|
+
}
|
|
4707
|
+
|
|
4708
|
+
function visited(x) {
|
|
4709
|
+
return pseudo(':visited', x);
|
|
4710
|
+
}
|
|
4711
|
+
|
|
4712
|
+
// parameterized pseudoclasses
|
|
4713
|
+
function dir(p, x) {
|
|
4714
|
+
return pseudo(':dir(' + p + ')', x);
|
|
4715
|
+
}
|
|
4716
|
+
function lang(p, x) {
|
|
4717
|
+
return pseudo(':lang(' + p + ')', x);
|
|
4718
|
+
}
|
|
4719
|
+
function not(p, x) {
|
|
4720
|
+
// should this be a plugin?
|
|
4721
|
+
var selector = p.split(',').map(function (x) {
|
|
4722
|
+
return x.trim();
|
|
4723
|
+
}).map(function (x) {
|
|
4724
|
+
return ':not(' + x + ')';
|
|
4725
|
+
});
|
|
4726
|
+
if (selector.length === 1) {
|
|
4727
|
+
return pseudo(':not(' + p + ')', x);
|
|
4728
|
+
}
|
|
4729
|
+
return select(selector.join(''), x);
|
|
4730
|
+
}
|
|
4731
|
+
function nthChild(p, x) {
|
|
4732
|
+
return pseudo(':nth-child(' + p + ')', x);
|
|
4733
|
+
}
|
|
4734
|
+
function nthLastChild(p, x) {
|
|
4735
|
+
return pseudo(':nth-last-child(' + p + ')', x);
|
|
4736
|
+
}
|
|
4737
|
+
function nthLastOfType(p, x) {
|
|
4738
|
+
return pseudo(':nth-last-of-type(' + p + ')', x);
|
|
4739
|
+
}
|
|
4740
|
+
function nthOfType(p, x) {
|
|
4741
|
+
return pseudo(':nth-of-type(' + p + ')', x);
|
|
4742
|
+
}
|
|
4743
|
+
|
|
4744
|
+
// pseudoelements
|
|
4745
|
+
function after(x) {
|
|
4746
|
+
return pseudo('::after', x);
|
|
4747
|
+
}
|
|
4748
|
+
function before(x) {
|
|
4749
|
+
return pseudo('::before', x);
|
|
4750
|
+
}
|
|
4751
|
+
function firstLetter(x) {
|
|
4752
|
+
return pseudo('::first-letter', x);
|
|
4753
|
+
}
|
|
4754
|
+
function firstLine(x) {
|
|
4755
|
+
return pseudo('::first-line', x);
|
|
4756
|
+
}
|
|
4757
|
+
function selection(x) {
|
|
4758
|
+
return pseudo('::selection', x);
|
|
4759
|
+
}
|
|
4760
|
+
function backdrop(x) {
|
|
4761
|
+
return pseudo('::backdrop', x);
|
|
4762
|
+
}
|
|
4763
|
+
function placeholder(x) {
|
|
4764
|
+
// https://github.com/threepointone/glamor/issues/14
|
|
4765
|
+
return css({ '::placeholder': x });
|
|
4766
|
+
}
|
|
4767
|
+
|
|
4768
|
+
/*** helpers for web components ***/
|
|
4769
|
+
// https://github.com/threepointone/glamor/issues/16
|
|
4770
|
+
|
|
4771
|
+
function cssFor() {
|
|
4772
|
+
for (var _len7 = arguments.length, rules = Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {
|
|
4773
|
+
rules[_key7] = arguments[_key7];
|
|
4774
|
+
}
|
|
4775
|
+
|
|
4776
|
+
rules = (0, _clean2.default)(rules);
|
|
4777
|
+
return rules ? rules.map(function (r) {
|
|
4778
|
+
var style = { label: [] };
|
|
4779
|
+
build(style, { src: r }); // mutative! but worth it.
|
|
4780
|
+
return deconstructedStyleToCSS(hashify(style), deconstruct(style)).join('');
|
|
4781
|
+
}).join('') : '';
|
|
4782
|
+
}
|
|
4783
|
+
|
|
4784
|
+
function attribsFor() {
|
|
4785
|
+
for (var _len8 = arguments.length, rules = Array(_len8), _key8 = 0; _key8 < _len8; _key8++) {
|
|
4786
|
+
rules[_key8] = arguments[_key8];
|
|
4787
|
+
}
|
|
4788
|
+
|
|
4789
|
+
rules = (0, _clean2.default)(rules);
|
|
4790
|
+
var htmlAttributes = rules ? rules.map(function (rule) {
|
|
4791
|
+
idFor(rule); // throwaway check for rule
|
|
4792
|
+
var key = Object.keys(rule)[0],
|
|
4793
|
+
value = rule[key];
|
|
4794
|
+
return key + '="' + (value || '') + '"';
|
|
4795
|
+
}).join(' ') : '';
|
|
4796
|
+
|
|
4797
|
+
return htmlAttributes;
|
|
4798
|
+
}
|
|
4799
|
+
});
|
|
4800
|
+
|
|
4801
|
+
const index = /*@__PURE__*/getDefaultExportFromCjs(lib);
|
|
4802
|
+
|
|
4803
|
+
export { color as c, lib as l };
|