sun-card-design 1.1.3 → 1.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/mobile/sun-card-design-mobile.es32.js +2 -2
- package/dist/mobile/sun-card-design-mobile.es33.js +2 -2
- package/dist/mobile/sun-card-design-mobile.es34.js +2 -2
- package/dist/mobile/sun-card-design-mobile.es35.js +2 -2
- package/dist/mobile/sun-card-design-mobile.es36.js +2 -2
- package/dist/mobile/sun-card-design-mobile.es37.js +2 -2
- package/dist/mobile/sun-card-design-mobile.es38.js +2 -2
- package/dist/mobile/sun-card-design-mobile.es49.js +1 -1
- package/dist/mobile/sun-card-design-mobile.es68.js +2 -2
- package/dist/mobile/sun-card-design-mobile.es70.js +2 -2
- package/dist/mobile/sun-card-design-mobile.es72.js +4 -4
- package/dist/mobile/sun-card-design-mobile.es73.js +12 -31
- package/dist/mobile/sun-card-design-mobile.es74.js +173 -2
- package/dist/mobile/sun-card-design-mobile.es75.js +35 -139
- package/dist/mobile/sun-card-design-mobile.es76.js +2 -2
- package/dist/mobile/sun-card-design-mobile.es77.js +146 -2
- package/dist/mobile/sun-card-design-mobile.es78.js +2 -2
- package/dist/mobile/sun-card-design-mobile.es79.js +2 -2
- package/dist/mobile/sun-card-design-mobile.es80.js +2 -2
- package/dist/mobile/sun-card-design-mobile.es81.js +2 -2
- package/dist/mobile/sun-card-design-mobile.es82.js +2 -2
- package/dist/mobile/sun-card-design-mobile.es83.js +2 -2
- package/dist/mobile/sun-card-design-mobile.es84.js +2 -175
- package/dist/mobile/sun-card-design-mobile.es85.js +2 -10
- package/dist/mobile/sun-card-design-mobile.es86.js +133 -94
- package/dist/mobile/sun-card-design-mobile.es87.js +110 -12
- package/dist/mobile/sun-card-design-mobile.es88.js +150 -145
- package/dist/mobile/sun-card-design-mobile.es89.js +36 -99
- package/dist/pc/sun-card-design-pc.es32.js +2 -2
- package/dist/pc/sun-card-design-pc.es33.js +2 -2
- package/dist/pc/sun-card-design-pc.es34.js +2 -2
- package/dist/pc/sun-card-design-pc.es35.js +2 -2
- package/dist/pc/sun-card-design-pc.es36.js +2 -2
- package/dist/pc/sun-card-design-pc.es37.js +2 -2
- package/dist/pc/sun-card-design-pc.es38.js +2 -2
- package/dist/pc/sun-card-design-pc.es68.js +2 -2
- package/dist/pc/sun-card-design-pc.es70.js +2 -2
- package/dist/pc/sun-card-design-pc.es72.js +4 -4
- package/dist/pc/sun-card-design-pc.es73.js +12 -31
- package/dist/pc/sun-card-design-pc.es74.js +2 -175
- package/dist/pc/sun-card-design-pc.es75.js +145 -9
- package/dist/pc/sun-card-design-pc.es76.js +2 -107
- package/dist/pc/sun-card-design-pc.es77.js +2 -2
- package/dist/pc/sun-card-design-pc.es78.js +2 -146
- package/dist/pc/sun-card-design-pc.es79.js +2 -2
- package/dist/pc/sun-card-design-pc.es80.js +2 -2
- package/dist/pc/sun-card-design-pc.es81.js +2 -2
- package/dist/pc/sun-card-design-pc.es82.js +2 -2
- package/dist/pc/sun-card-design-pc.es83.js +2 -2
- package/dist/pc/sun-card-design-pc.es84.js +173 -2
- package/dist/pc/sun-card-design-pc.es85.js +42 -2
- package/dist/pc/sun-card-design-pc.es86.js +146 -2
- package/dist/pc/sun-card-design-pc.es87.js +110 -12
- package/dist/pc/sun-card-design-pc.es88.js +150 -145
- package/dist/pc/sun-card-design-pc.es89.js +36 -99
- package/package.json +4 -3
|
@@ -1,109 +1,148 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { rgbToRgb, hsvToRgb, hslToRgb, convertHexToDecimal, parseIntFromHex } from "./sun-card-design-mobile.es87.js";
|
|
2
|
+
import { names } from "./sun-card-design-mobile.es88.js";
|
|
3
|
+
import { convertToPercentage, boundAlpha } from "./sun-card-design-mobile.es89.js";
|
|
4
|
+
function inputToRGB(color) {
|
|
5
|
+
var rgb = { r: 0, g: 0, b: 0 };
|
|
6
|
+
var a = 1;
|
|
7
|
+
var s = null;
|
|
8
|
+
var v = null;
|
|
9
|
+
var l = null;
|
|
10
|
+
var ok = false;
|
|
11
|
+
var format = false;
|
|
12
|
+
if (typeof color === "string") {
|
|
13
|
+
color = stringInputToObject(color);
|
|
14
|
+
}
|
|
15
|
+
if (typeof color === "object") {
|
|
16
|
+
if (isValidCSSUnit(color.r) && isValidCSSUnit(color.g) && isValidCSSUnit(color.b)) {
|
|
17
|
+
rgb = rgbToRgb(color.r, color.g, color.b);
|
|
18
|
+
ok = true;
|
|
19
|
+
format = String(color.r).substr(-1) === "%" ? "prgb" : "rgb";
|
|
20
|
+
} else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.v)) {
|
|
21
|
+
s = convertToPercentage(color.s);
|
|
22
|
+
v = convertToPercentage(color.v);
|
|
23
|
+
rgb = hsvToRgb(color.h, s, v);
|
|
24
|
+
ok = true;
|
|
25
|
+
format = "hsv";
|
|
26
|
+
} else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.l)) {
|
|
27
|
+
s = convertToPercentage(color.s);
|
|
28
|
+
l = convertToPercentage(color.l);
|
|
29
|
+
rgb = hslToRgb(color.h, s, l);
|
|
30
|
+
ok = true;
|
|
31
|
+
format = "hsl";
|
|
32
|
+
}
|
|
33
|
+
if (Object.prototype.hasOwnProperty.call(color, "a")) {
|
|
34
|
+
a = color.a;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
a = boundAlpha(a);
|
|
38
|
+
return {
|
|
39
|
+
ok,
|
|
40
|
+
format: color.format || format,
|
|
41
|
+
r: Math.min(255, Math.max(rgb.r, 0)),
|
|
42
|
+
g: Math.min(255, Math.max(rgb.g, 0)),
|
|
43
|
+
b: Math.min(255, Math.max(rgb.b, 0)),
|
|
44
|
+
a
|
|
45
|
+
};
|
|
3
46
|
}
|
|
4
|
-
|
|
5
|
-
|
|
47
|
+
var CSS_INTEGER = "[-\\+]?\\d+%?";
|
|
48
|
+
var CSS_NUMBER = "[-\\+]?\\d*\\.\\d+%?";
|
|
49
|
+
var CSS_UNIT = "(?:".concat(CSS_NUMBER, ")|(?:").concat(CSS_INTEGER, ")");
|
|
50
|
+
var PERMISSIVE_MATCH3 = "[\\s|\\(]+(".concat(CSS_UNIT, ")[,|\\s]+(").concat(CSS_UNIT, ")[,|\\s]+(").concat(CSS_UNIT, ")\\s*\\)?");
|
|
51
|
+
var PERMISSIVE_MATCH4 = "[\\s|\\(]+(".concat(CSS_UNIT, ")[,|\\s]+(").concat(CSS_UNIT, ")[,|\\s]+(").concat(CSS_UNIT, ")[,|\\s]+(").concat(CSS_UNIT, ")\\s*\\)?");
|
|
52
|
+
var matchers = {
|
|
53
|
+
CSS_UNIT: new RegExp(CSS_UNIT),
|
|
54
|
+
rgb: new RegExp("rgb" + PERMISSIVE_MATCH3),
|
|
55
|
+
rgba: new RegExp("rgba" + PERMISSIVE_MATCH4),
|
|
56
|
+
hsl: new RegExp("hsl" + PERMISSIVE_MATCH3),
|
|
57
|
+
hsla: new RegExp("hsla" + PERMISSIVE_MATCH4),
|
|
58
|
+
hsv: new RegExp("hsv" + PERMISSIVE_MATCH3),
|
|
59
|
+
hsva: new RegExp("hsva" + PERMISSIVE_MATCH4),
|
|
60
|
+
hex3: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
|
|
61
|
+
hex6: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,
|
|
62
|
+
hex4: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
|
|
63
|
+
hex8: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/
|
|
64
|
+
};
|
|
65
|
+
function stringInputToObject(color) {
|
|
66
|
+
color = color.trim().toLowerCase();
|
|
67
|
+
if (color.length === 0) {
|
|
6
68
|
return false;
|
|
7
69
|
}
|
|
8
|
-
|
|
9
|
-
|
|
70
|
+
var named = false;
|
|
71
|
+
if (names[color]) {
|
|
72
|
+
color = names[color];
|
|
73
|
+
named = true;
|
|
74
|
+
} else if (color === "transparent") {
|
|
75
|
+
return { r: 0, g: 0, b: 0, a: 0, format: "name" };
|
|
10
76
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
var MARK_KEY = "vc-icon-key";
|
|
15
|
-
var containerCache = /* @__PURE__ */ new Map();
|
|
16
|
-
function getMark() {
|
|
17
|
-
var _ref = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, mark = _ref.mark;
|
|
18
|
-
if (mark) {
|
|
19
|
-
return mark.startsWith("data-") ? mark : "data-".concat(mark);
|
|
77
|
+
var match = matchers.rgb.exec(color);
|
|
78
|
+
if (match) {
|
|
79
|
+
return { r: match[1], g: match[2], b: match[3] };
|
|
20
80
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
if (option.attachTo) {
|
|
25
|
-
return option.attachTo;
|
|
81
|
+
match = matchers.rgba.exec(color);
|
|
82
|
+
if (match) {
|
|
83
|
+
return { r: match[1], g: match[2], b: match[3], a: match[4] };
|
|
26
84
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
function getOrder(prepend) {
|
|
31
|
-
if (prepend === "queue") {
|
|
32
|
-
return "prependQueue";
|
|
85
|
+
match = matchers.hsl.exec(color);
|
|
86
|
+
if (match) {
|
|
87
|
+
return { h: match[1], s: match[2], l: match[3] };
|
|
33
88
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
return Array.from((containerCache.get(container) || container).children).filter(function(node) {
|
|
38
|
-
return node.tagName === "STYLE";
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
function injectCSS(css) {
|
|
42
|
-
var option = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
43
|
-
if (!canUseDom()) {
|
|
44
|
-
return null;
|
|
89
|
+
match = matchers.hsla.exec(color);
|
|
90
|
+
if (match) {
|
|
91
|
+
return { h: match[1], s: match[2], l: match[3], a: match[4] };
|
|
45
92
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
if (csp && csp.nonce) {
|
|
50
|
-
styleNode.nonce = csp.nonce;
|
|
93
|
+
match = matchers.hsv.exec(color);
|
|
94
|
+
if (match) {
|
|
95
|
+
return { h: match[1], s: match[2], v: match[3] };
|
|
51
96
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
if (prepend) {
|
|
56
|
-
if (prepend === "queue") {
|
|
57
|
-
var existStyle = findStyles(container).filter(function(node) {
|
|
58
|
-
return ["prepend", "prependQueue"].includes(node.getAttribute(APPEND_ORDER));
|
|
59
|
-
});
|
|
60
|
-
if (existStyle.length) {
|
|
61
|
-
container.insertBefore(styleNode, existStyle[existStyle.length - 1].nextSibling);
|
|
62
|
-
return styleNode;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
container.insertBefore(styleNode, firstChild);
|
|
66
|
-
} else {
|
|
67
|
-
container.appendChild(styleNode);
|
|
97
|
+
match = matchers.hsva.exec(color);
|
|
98
|
+
if (match) {
|
|
99
|
+
return { h: match[1], s: match[2], v: match[3], a: match[4] };
|
|
68
100
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
function syncRealContainer(container, option) {
|
|
79
|
-
var cachedRealContainer = containerCache.get(container);
|
|
80
|
-
if (!cachedRealContainer || !contains(document, cachedRealContainer)) {
|
|
81
|
-
var placeholderStyle = injectCSS("", option);
|
|
82
|
-
var parentNode = placeholderStyle.parentNode;
|
|
83
|
-
containerCache.set(container, parentNode);
|
|
84
|
-
container.removeChild(placeholderStyle);
|
|
101
|
+
match = matchers.hex8.exec(color);
|
|
102
|
+
if (match) {
|
|
103
|
+
return {
|
|
104
|
+
r: parseIntFromHex(match[1]),
|
|
105
|
+
g: parseIntFromHex(match[2]),
|
|
106
|
+
b: parseIntFromHex(match[3]),
|
|
107
|
+
a: convertHexToDecimal(match[4]),
|
|
108
|
+
format: named ? "name" : "hex8"
|
|
109
|
+
};
|
|
85
110
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
111
|
+
match = matchers.hex6.exec(color);
|
|
112
|
+
if (match) {
|
|
113
|
+
return {
|
|
114
|
+
r: parseIntFromHex(match[1]),
|
|
115
|
+
g: parseIntFromHex(match[2]),
|
|
116
|
+
b: parseIntFromHex(match[3]),
|
|
117
|
+
format: named ? "name" : "hex"
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
match = matchers.hex4.exec(color);
|
|
121
|
+
if (match) {
|
|
122
|
+
return {
|
|
123
|
+
r: parseIntFromHex(match[1] + match[1]),
|
|
124
|
+
g: parseIntFromHex(match[2] + match[2]),
|
|
125
|
+
b: parseIntFromHex(match[3] + match[3]),
|
|
126
|
+
a: convertHexToDecimal(match[4] + match[4]),
|
|
127
|
+
format: named ? "name" : "hex8"
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
match = matchers.hex3.exec(color);
|
|
131
|
+
if (match) {
|
|
132
|
+
return {
|
|
133
|
+
r: parseIntFromHex(match[1] + match[1]),
|
|
134
|
+
g: parseIntFromHex(match[2] + match[2]),
|
|
135
|
+
b: parseIntFromHex(match[3] + match[3]),
|
|
136
|
+
format: named ? "name" : "hex"
|
|
137
|
+
};
|
|
100
138
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
139
|
+
return false;
|
|
140
|
+
}
|
|
141
|
+
function isValidCSSUnit(color) {
|
|
142
|
+
return Boolean(matchers.CSS_UNIT.exec(String(color)));
|
|
104
143
|
}
|
|
105
144
|
export {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
145
|
+
inputToRGB,
|
|
146
|
+
isValidCSSUnit,
|
|
147
|
+
stringInputToObject
|
|
109
148
|
};
|
|
@@ -1,14 +1,112 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
import { bound01, pad2 } from "./sun-card-design-mobile.es89.js";
|
|
2
|
+
function rgbToRgb(r, g, b) {
|
|
3
|
+
return {
|
|
4
|
+
r: bound01(r, 255) * 255,
|
|
5
|
+
g: bound01(g, 255) * 255,
|
|
6
|
+
b: bound01(b, 255) * 255
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
function hue2rgb(p, q, t) {
|
|
10
|
+
if (t < 0) {
|
|
11
|
+
t += 1;
|
|
12
|
+
}
|
|
13
|
+
if (t > 1) {
|
|
14
|
+
t -= 1;
|
|
15
|
+
}
|
|
16
|
+
if (t < 1 / 6) {
|
|
17
|
+
return p + (q - p) * (6 * t);
|
|
18
|
+
}
|
|
19
|
+
if (t < 1 / 2) {
|
|
20
|
+
return q;
|
|
21
|
+
}
|
|
22
|
+
if (t < 2 / 3) {
|
|
23
|
+
return p + (q - p) * (2 / 3 - t) * 6;
|
|
24
|
+
}
|
|
25
|
+
return p;
|
|
26
|
+
}
|
|
27
|
+
function hslToRgb(h, s, l) {
|
|
28
|
+
var r;
|
|
29
|
+
var g;
|
|
30
|
+
var b;
|
|
31
|
+
h = bound01(h, 360);
|
|
32
|
+
s = bound01(s, 100);
|
|
33
|
+
l = bound01(l, 100);
|
|
34
|
+
if (s === 0) {
|
|
35
|
+
g = l;
|
|
36
|
+
b = l;
|
|
37
|
+
r = l;
|
|
38
|
+
} else {
|
|
39
|
+
var q = l < 0.5 ? l * (1 + s) : l + s - l * s;
|
|
40
|
+
var p = 2 * l - q;
|
|
41
|
+
r = hue2rgb(p, q, h + 1 / 3);
|
|
42
|
+
g = hue2rgb(p, q, h);
|
|
43
|
+
b = hue2rgb(p, q, h - 1 / 3);
|
|
44
|
+
}
|
|
45
|
+
return { r: r * 255, g: g * 255, b: b * 255 };
|
|
46
|
+
}
|
|
47
|
+
function rgbToHsv(r, g, b) {
|
|
48
|
+
r = bound01(r, 255);
|
|
49
|
+
g = bound01(g, 255);
|
|
50
|
+
b = bound01(b, 255);
|
|
51
|
+
var max = Math.max(r, g, b);
|
|
52
|
+
var min = Math.min(r, g, b);
|
|
53
|
+
var h = 0;
|
|
54
|
+
var v = max;
|
|
55
|
+
var d = max - min;
|
|
56
|
+
var s = max === 0 ? 0 : d / max;
|
|
57
|
+
if (max === min) {
|
|
58
|
+
h = 0;
|
|
59
|
+
} else {
|
|
60
|
+
switch (max) {
|
|
61
|
+
case r:
|
|
62
|
+
h = (g - b) / d + (g < b ? 6 : 0);
|
|
63
|
+
break;
|
|
64
|
+
case g:
|
|
65
|
+
h = (b - r) / d + 2;
|
|
66
|
+
break;
|
|
67
|
+
case b:
|
|
68
|
+
h = (r - g) / d + 4;
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
71
|
+
h /= 6;
|
|
72
|
+
}
|
|
73
|
+
return { h, s, v };
|
|
74
|
+
}
|
|
75
|
+
function hsvToRgb(h, s, v) {
|
|
76
|
+
h = bound01(h, 360) * 6;
|
|
77
|
+
s = bound01(s, 100);
|
|
78
|
+
v = bound01(v, 100);
|
|
79
|
+
var i = Math.floor(h);
|
|
80
|
+
var f = h - i;
|
|
81
|
+
var p = v * (1 - s);
|
|
82
|
+
var q = v * (1 - f * s);
|
|
83
|
+
var t = v * (1 - (1 - f) * s);
|
|
84
|
+
var mod = i % 6;
|
|
85
|
+
var r = [v, q, p, p, t, v][mod];
|
|
86
|
+
var g = [t, v, v, q, p, p][mod];
|
|
87
|
+
var b = [p, p, t, v, v, q][mod];
|
|
88
|
+
return { r: r * 255, g: g * 255, b: b * 255 };
|
|
89
|
+
}
|
|
90
|
+
function rgbToHex(r, g, b, allow3Char) {
|
|
91
|
+
var hex = [
|
|
92
|
+
pad2(Math.round(r).toString(16)),
|
|
93
|
+
pad2(Math.round(g).toString(16)),
|
|
94
|
+
pad2(Math.round(b).toString(16))
|
|
95
|
+
];
|
|
96
|
+
return hex.join("");
|
|
97
|
+
}
|
|
98
|
+
function convertHexToDecimal(h) {
|
|
99
|
+
return parseIntFromHex(h) / 255;
|
|
100
|
+
}
|
|
101
|
+
function parseIntFromHex(val) {
|
|
102
|
+
return parseInt(val, 16);
|
|
103
|
+
}
|
|
12
104
|
export {
|
|
13
|
-
|
|
105
|
+
convertHexToDecimal,
|
|
106
|
+
hslToRgb,
|
|
107
|
+
hsvToRgb,
|
|
108
|
+
parseIntFromHex,
|
|
109
|
+
rgbToHex,
|
|
110
|
+
rgbToHsv,
|
|
111
|
+
rgbToRgb
|
|
14
112
|
};
|
|
@@ -1,148 +1,153 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
1
|
+
var names = {
|
|
2
|
+
aliceblue: "#f0f8ff",
|
|
3
|
+
antiquewhite: "#faebd7",
|
|
4
|
+
aqua: "#00ffff",
|
|
5
|
+
aquamarine: "#7fffd4",
|
|
6
|
+
azure: "#f0ffff",
|
|
7
|
+
beige: "#f5f5dc",
|
|
8
|
+
bisque: "#ffe4c4",
|
|
9
|
+
black: "#000000",
|
|
10
|
+
blanchedalmond: "#ffebcd",
|
|
11
|
+
blue: "#0000ff",
|
|
12
|
+
blueviolet: "#8a2be2",
|
|
13
|
+
brown: "#a52a2a",
|
|
14
|
+
burlywood: "#deb887",
|
|
15
|
+
cadetblue: "#5f9ea0",
|
|
16
|
+
chartreuse: "#7fff00",
|
|
17
|
+
chocolate: "#d2691e",
|
|
18
|
+
coral: "#ff7f50",
|
|
19
|
+
cornflowerblue: "#6495ed",
|
|
20
|
+
cornsilk: "#fff8dc",
|
|
21
|
+
crimson: "#dc143c",
|
|
22
|
+
cyan: "#00ffff",
|
|
23
|
+
darkblue: "#00008b",
|
|
24
|
+
darkcyan: "#008b8b",
|
|
25
|
+
darkgoldenrod: "#b8860b",
|
|
26
|
+
darkgray: "#a9a9a9",
|
|
27
|
+
darkgreen: "#006400",
|
|
28
|
+
darkgrey: "#a9a9a9",
|
|
29
|
+
darkkhaki: "#bdb76b",
|
|
30
|
+
darkmagenta: "#8b008b",
|
|
31
|
+
darkolivegreen: "#556b2f",
|
|
32
|
+
darkorange: "#ff8c00",
|
|
33
|
+
darkorchid: "#9932cc",
|
|
34
|
+
darkred: "#8b0000",
|
|
35
|
+
darksalmon: "#e9967a",
|
|
36
|
+
darkseagreen: "#8fbc8f",
|
|
37
|
+
darkslateblue: "#483d8b",
|
|
38
|
+
darkslategray: "#2f4f4f",
|
|
39
|
+
darkslategrey: "#2f4f4f",
|
|
40
|
+
darkturquoise: "#00ced1",
|
|
41
|
+
darkviolet: "#9400d3",
|
|
42
|
+
deeppink: "#ff1493",
|
|
43
|
+
deepskyblue: "#00bfff",
|
|
44
|
+
dimgray: "#696969",
|
|
45
|
+
dimgrey: "#696969",
|
|
46
|
+
dodgerblue: "#1e90ff",
|
|
47
|
+
firebrick: "#b22222",
|
|
48
|
+
floralwhite: "#fffaf0",
|
|
49
|
+
forestgreen: "#228b22",
|
|
50
|
+
fuchsia: "#ff00ff",
|
|
51
|
+
gainsboro: "#dcdcdc",
|
|
52
|
+
ghostwhite: "#f8f8ff",
|
|
53
|
+
goldenrod: "#daa520",
|
|
54
|
+
gold: "#ffd700",
|
|
55
|
+
gray: "#808080",
|
|
56
|
+
green: "#008000",
|
|
57
|
+
greenyellow: "#adff2f",
|
|
58
|
+
grey: "#808080",
|
|
59
|
+
honeydew: "#f0fff0",
|
|
60
|
+
hotpink: "#ff69b4",
|
|
61
|
+
indianred: "#cd5c5c",
|
|
62
|
+
indigo: "#4b0082",
|
|
63
|
+
ivory: "#fffff0",
|
|
64
|
+
khaki: "#f0e68c",
|
|
65
|
+
lavenderblush: "#fff0f5",
|
|
66
|
+
lavender: "#e6e6fa",
|
|
67
|
+
lawngreen: "#7cfc00",
|
|
68
|
+
lemonchiffon: "#fffacd",
|
|
69
|
+
lightblue: "#add8e6",
|
|
70
|
+
lightcoral: "#f08080",
|
|
71
|
+
lightcyan: "#e0ffff",
|
|
72
|
+
lightgoldenrodyellow: "#fafad2",
|
|
73
|
+
lightgray: "#d3d3d3",
|
|
74
|
+
lightgreen: "#90ee90",
|
|
75
|
+
lightgrey: "#d3d3d3",
|
|
76
|
+
lightpink: "#ffb6c1",
|
|
77
|
+
lightsalmon: "#ffa07a",
|
|
78
|
+
lightseagreen: "#20b2aa",
|
|
79
|
+
lightskyblue: "#87cefa",
|
|
80
|
+
lightslategray: "#778899",
|
|
81
|
+
lightslategrey: "#778899",
|
|
82
|
+
lightsteelblue: "#b0c4de",
|
|
83
|
+
lightyellow: "#ffffe0",
|
|
84
|
+
lime: "#00ff00",
|
|
85
|
+
limegreen: "#32cd32",
|
|
86
|
+
linen: "#faf0e6",
|
|
87
|
+
magenta: "#ff00ff",
|
|
88
|
+
maroon: "#800000",
|
|
89
|
+
mediumaquamarine: "#66cdaa",
|
|
90
|
+
mediumblue: "#0000cd",
|
|
91
|
+
mediumorchid: "#ba55d3",
|
|
92
|
+
mediumpurple: "#9370db",
|
|
93
|
+
mediumseagreen: "#3cb371",
|
|
94
|
+
mediumslateblue: "#7b68ee",
|
|
95
|
+
mediumspringgreen: "#00fa9a",
|
|
96
|
+
mediumturquoise: "#48d1cc",
|
|
97
|
+
mediumvioletred: "#c71585",
|
|
98
|
+
midnightblue: "#191970",
|
|
99
|
+
mintcream: "#f5fffa",
|
|
100
|
+
mistyrose: "#ffe4e1",
|
|
101
|
+
moccasin: "#ffe4b5",
|
|
102
|
+
navajowhite: "#ffdead",
|
|
103
|
+
navy: "#000080",
|
|
104
|
+
oldlace: "#fdf5e6",
|
|
105
|
+
olive: "#808000",
|
|
106
|
+
olivedrab: "#6b8e23",
|
|
107
|
+
orange: "#ffa500",
|
|
108
|
+
orangered: "#ff4500",
|
|
109
|
+
orchid: "#da70d6",
|
|
110
|
+
palegoldenrod: "#eee8aa",
|
|
111
|
+
palegreen: "#98fb98",
|
|
112
|
+
paleturquoise: "#afeeee",
|
|
113
|
+
palevioletred: "#db7093",
|
|
114
|
+
papayawhip: "#ffefd5",
|
|
115
|
+
peachpuff: "#ffdab9",
|
|
116
|
+
peru: "#cd853f",
|
|
117
|
+
pink: "#ffc0cb",
|
|
118
|
+
plum: "#dda0dd",
|
|
119
|
+
powderblue: "#b0e0e6",
|
|
120
|
+
purple: "#800080",
|
|
121
|
+
rebeccapurple: "#663399",
|
|
122
|
+
red: "#ff0000",
|
|
123
|
+
rosybrown: "#bc8f8f",
|
|
124
|
+
royalblue: "#4169e1",
|
|
125
|
+
saddlebrown: "#8b4513",
|
|
126
|
+
salmon: "#fa8072",
|
|
127
|
+
sandybrown: "#f4a460",
|
|
128
|
+
seagreen: "#2e8b57",
|
|
129
|
+
seashell: "#fff5ee",
|
|
130
|
+
sienna: "#a0522d",
|
|
131
|
+
silver: "#c0c0c0",
|
|
132
|
+
skyblue: "#87ceeb",
|
|
133
|
+
slateblue: "#6a5acd",
|
|
134
|
+
slategray: "#708090",
|
|
135
|
+
slategrey: "#708090",
|
|
136
|
+
snow: "#fffafa",
|
|
137
|
+
springgreen: "#00ff7f",
|
|
138
|
+
steelblue: "#4682b4",
|
|
139
|
+
tan: "#d2b48c",
|
|
140
|
+
teal: "#008080",
|
|
141
|
+
thistle: "#d8bfd8",
|
|
142
|
+
tomato: "#ff6347",
|
|
143
|
+
turquoise: "#40e0d0",
|
|
144
|
+
violet: "#ee82ee",
|
|
145
|
+
wheat: "#f5deb3",
|
|
146
|
+
white: "#ffffff",
|
|
147
|
+
whitesmoke: "#f5f5f5",
|
|
148
|
+
yellow: "#ffff00",
|
|
149
|
+
yellowgreen: "#9acd32"
|
|
64
150
|
};
|
|
65
|
-
function stringInputToObject(color) {
|
|
66
|
-
color = color.trim().toLowerCase();
|
|
67
|
-
if (color.length === 0) {
|
|
68
|
-
return false;
|
|
69
|
-
}
|
|
70
|
-
var named = false;
|
|
71
|
-
if (names[color]) {
|
|
72
|
-
color = names[color];
|
|
73
|
-
named = true;
|
|
74
|
-
} else if (color === "transparent") {
|
|
75
|
-
return { r: 0, g: 0, b: 0, a: 0, format: "name" };
|
|
76
|
-
}
|
|
77
|
-
var match = matchers.rgb.exec(color);
|
|
78
|
-
if (match) {
|
|
79
|
-
return { r: match[1], g: match[2], b: match[3] };
|
|
80
|
-
}
|
|
81
|
-
match = matchers.rgba.exec(color);
|
|
82
|
-
if (match) {
|
|
83
|
-
return { r: match[1], g: match[2], b: match[3], a: match[4] };
|
|
84
|
-
}
|
|
85
|
-
match = matchers.hsl.exec(color);
|
|
86
|
-
if (match) {
|
|
87
|
-
return { h: match[1], s: match[2], l: match[3] };
|
|
88
|
-
}
|
|
89
|
-
match = matchers.hsla.exec(color);
|
|
90
|
-
if (match) {
|
|
91
|
-
return { h: match[1], s: match[2], l: match[3], a: match[4] };
|
|
92
|
-
}
|
|
93
|
-
match = matchers.hsv.exec(color);
|
|
94
|
-
if (match) {
|
|
95
|
-
return { h: match[1], s: match[2], v: match[3] };
|
|
96
|
-
}
|
|
97
|
-
match = matchers.hsva.exec(color);
|
|
98
|
-
if (match) {
|
|
99
|
-
return { h: match[1], s: match[2], v: match[3], a: match[4] };
|
|
100
|
-
}
|
|
101
|
-
match = matchers.hex8.exec(color);
|
|
102
|
-
if (match) {
|
|
103
|
-
return {
|
|
104
|
-
r: parseIntFromHex(match[1]),
|
|
105
|
-
g: parseIntFromHex(match[2]),
|
|
106
|
-
b: parseIntFromHex(match[3]),
|
|
107
|
-
a: convertHexToDecimal(match[4]),
|
|
108
|
-
format: named ? "name" : "hex8"
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
match = matchers.hex6.exec(color);
|
|
112
|
-
if (match) {
|
|
113
|
-
return {
|
|
114
|
-
r: parseIntFromHex(match[1]),
|
|
115
|
-
g: parseIntFromHex(match[2]),
|
|
116
|
-
b: parseIntFromHex(match[3]),
|
|
117
|
-
format: named ? "name" : "hex"
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
match = matchers.hex4.exec(color);
|
|
121
|
-
if (match) {
|
|
122
|
-
return {
|
|
123
|
-
r: parseIntFromHex(match[1] + match[1]),
|
|
124
|
-
g: parseIntFromHex(match[2] + match[2]),
|
|
125
|
-
b: parseIntFromHex(match[3] + match[3]),
|
|
126
|
-
a: convertHexToDecimal(match[4] + match[4]),
|
|
127
|
-
format: named ? "name" : "hex8"
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
match = matchers.hex3.exec(color);
|
|
131
|
-
if (match) {
|
|
132
|
-
return {
|
|
133
|
-
r: parseIntFromHex(match[1] + match[1]),
|
|
134
|
-
g: parseIntFromHex(match[2] + match[2]),
|
|
135
|
-
b: parseIntFromHex(match[3] + match[3]),
|
|
136
|
-
format: named ? "name" : "hex"
|
|
137
|
-
};
|
|
138
|
-
}
|
|
139
|
-
return false;
|
|
140
|
-
}
|
|
141
|
-
function isValidCSSUnit(color) {
|
|
142
|
-
return Boolean(matchers.CSS_UNIT.exec(String(color)));
|
|
143
|
-
}
|
|
144
151
|
export {
|
|
145
|
-
|
|
146
|
-
isValidCSSUnit,
|
|
147
|
-
stringInputToObject
|
|
152
|
+
names
|
|
148
153
|
};
|