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