@luzmo/lucero 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/accordion/index.cjs +43 -0
- package/lib/accordion/index.js +182 -0
- package/lib/action-bar/index.cjs +39 -0
- package/lib/action-bar/index.js +108 -0
- package/lib/action-button/index.cjs +24 -0
- package/lib/action-button/index.js +162 -0
- package/lib/action-group/index.cjs +18 -0
- package/lib/action-group/index.js +29 -0
- package/lib/action-group-BoIH8s8R.js +259 -0
- package/lib/action-group-D4MxBrq8.cjs +20 -0
- package/lib/action-menu/index.cjs +56 -0
- package/lib/action-menu/index.js +127 -0
- package/lib/async-directive-CV2MII86.cjs +22 -0
- package/lib/async-directive-FGzMycjH.js +82 -0
- package/lib/avatar/index.cjs +24 -0
- package/lib/avatar/index.js +82 -0
- package/lib/base-BCmA9Wxv.cjs +30 -0
- package/lib/base-BjTwmyRF.cjs +22 -0
- package/lib/base-D76d76ww.js +26 -0
- package/lib/base-nYalvNMy.js +390 -0
- package/lib/button/index.cjs +20 -0
- package/lib/button/index.js +128 -0
- package/lib/button-base-B0iB_JTv.cjs +25 -0
- package/lib/button-base-DgtT6sU5.js +143 -0
- package/lib/button-group/index.cjs +18 -0
- package/lib/button-group/index.js +60 -0
- package/lib/checkbox/index.cjs +25 -0
- package/lib/checkbox/index.js +97 -0
- package/lib/checkbox-mixin-DegQlk5C.js +71 -0
- package/lib/checkbox-mixin-H0Hm-VLk.cjs +27 -0
- package/lib/clear-button-Ap5H3UyH.js +54 -0
- package/lib/clear-button-D0djuaLb.cjs +18 -0
- package/lib/close-button-BrfeZvjk.cjs +18 -0
- package/lib/close-button-CGISEF33.js +52 -0
- package/lib/color-Bg3tYsAQ.js +178 -0
- package/lib/color-DphK4hwx.cjs +18 -0
- package/lib/color-area/index.cjs +80 -0
- package/lib/color-area/index.js +373 -0
- package/lib/color-field/index.cjs +23 -0
- package/lib/color-field/index.js +81 -0
- package/lib/color-handle/index.cjs +24 -0
- package/lib/color-handle/index.js +74 -0
- package/lib/color-loupe/index.cjs +18 -0
- package/lib/color-loupe/index.js +29 -0
- package/lib/color-loupe-BICpNqFs.cjs +56 -0
- package/lib/color-loupe-DBEApMDT.js +82 -0
- package/lib/color-menu/index.cjs +86 -0
- package/lib/color-menu/index.js +204 -0
- package/lib/color-picker/index.cjs +48 -0
- package/lib/color-picker/index.js +142 -0
- package/lib/color-slider/index.cjs +57 -0
- package/lib/color-slider/index.js +318 -0
- package/lib/condition-attribute-with-id-DrQYZzFS.cjs +18 -0
- package/lib/condition-attribute-with-id-Dv4lSRbe.js +31 -0
- package/lib/dependency-manger-C5HCkMMB.cjs +18 -0
- package/lib/dependency-manger-CEXvGQUV.js +54 -0
- package/lib/directive-C7oCP5Bh.cjs +22 -0
- package/lib/directive-helpers-BLDZnGQv.js +28 -0
- package/lib/directive-helpers-C2vOfhFx.cjs +22 -0
- package/lib/directive-oAbCiebi.js +44 -0
- package/lib/divider/index.cjs +18 -0
- package/lib/divider/index.js +62 -0
- package/lib/divider.module-CXMNveQc.cjs +18 -0
- package/lib/divider.module-DwOuLGU3.js +21 -0
- package/lib/element-resolution-BvRLGqIU.cjs +18 -0
- package/lib/element-resolution-FCUT-wql.js +91 -0
- package/lib/field-group/index.cjs +18 -0
- package/lib/field-group/index.js +29 -0
- package/lib/field-group-CBWafIUV.js +67 -0
- package/lib/field-group-TUFvhJkk.cjs +23 -0
- package/lib/field-label/index.cjs +18 -0
- package/lib/field-label/index.js +29 -0
- package/lib/field-label-BK_tk8vP.js +107 -0
- package/lib/field-label-BrJaeORz.cjs +25 -0
- package/lib/focus-group-DHeTq18L.js +218 -0
- package/lib/focus-group-DnxZUBhQ.cjs +18 -0
- package/lib/focus-visible-B0P9aY_G.cjs +18 -0
- package/lib/focus-visible-DBlJGoEW.js +74 -0
- package/lib/focusable-DbUg-3Vp.js +153 -0
- package/lib/focusable-Dv_6CFaY.cjs +18 -0
- package/lib/focusable-selectors-B4YgbghQ.js +31 -0
- package/lib/focusable-selectors-BgFlyFcY.cjs +18 -0
- package/lib/icon/index.cjs +18 -0
- package/lib/icon/index.js +89 -0
- package/lib/if-defined-CYpcjGCb.js +27 -0
- package/lib/if-defined-Cv6xanXh.cjs +22 -0
- package/lib/index-C1chwzNp.js +727 -0
- package/lib/index-DCKCHDTt.cjs +18 -0
- package/lib/index-ovT-qVzf.js +928 -0
- package/lib/index-yNcLzjhM.cjs +77 -0
- package/lib/index.cjs +18 -0
- package/lib/index.js +133 -0
- package/lib/infield-button/index.cjs +22 -0
- package/lib/infield-button/index.js +65 -0
- package/lib/label/index.cjs +18 -0
- package/lib/label/index.js +52 -0
- package/lib/legend-position/index.cjs +27 -0
- package/lib/legend-position/index.js +85 -0
- package/lib/like-anchor-K8W0QYwC.cjs +32 -0
- package/lib/like-anchor-cDeGGeHh.js +70 -0
- package/lib/lit-html-B3ugcwD9.js +248 -0
- package/lib/lit-html-p4Oxv2-5.cjs +24 -0
- package/lib/manage-help-text-2mSEy-AD.js +92 -0
- package/lib/manage-help-text-iOk-zmy8.cjs +30 -0
- package/lib/menu/index.cjs +18 -0
- package/lib/menu/index.js +32 -0
- package/lib/multi-language-field/index.cjs +39 -0
- package/lib/multi-language-field/index.js +149 -0
- package/lib/mutation-controller-DH7YOCyj.js +52 -0
- package/lib/mutation-controller-DkOMCW-c.cjs +22 -0
- package/lib/number-field/index.cjs +57 -0
- package/lib/number-field/index.js +736 -0
- package/lib/observe-slot-text-BmsCNJig.cjs +18 -0
- package/lib/observe-slot-text-BoFRF-VI.js +87 -0
- package/lib/overlay/index.cjs +73 -0
- package/lib/overlay/index.js +325 -0
- package/lib/overlay-C7QKFqRc.js +2702 -0
- package/lib/overlay-DScraBAi.cjs +47 -0
- package/lib/pending-state-D5KTK4_1.js +61 -0
- package/lib/pending-state-Dbc2HIM2.cjs +26 -0
- package/lib/picker/index.cjs +18 -0
- package/lib/picker/index.js +32 -0
- package/lib/picker--2OCYWnV.js +657 -0
- package/lib/picker-B9W7Haf4.cjs +127 -0
- package/lib/platform-CQzYNWKq.cjs +18 -0
- package/lib/platform-DQYMG7JI.js +54 -0
- package/lib/popover/index.cjs +18 -0
- package/lib/popover/index.js +29 -0
- package/lib/popover-CVbjhSnx.cjs +30 -0
- package/lib/popover-ZRVxogyp.js +68 -0
- package/lib/progress-circle/index.cjs +18 -0
- package/lib/progress-circle/index.js +29 -0
- package/lib/progress-circle-CiJoS8J7.cjs +33 -0
- package/lib/progress-circle-DpXiqW6a.js +98 -0
- package/lib/query-BL-TJj7K.cjs +22 -0
- package/lib/query-D_KR_GUc.js +51 -0
- package/lib/query-assigned-elements-DjfhL1cl.js +36 -0
- package/lib/query-assigned-elements-DsKsfk7G.cjs +22 -0
- package/lib/query-assigned-nodes-BcKWmGzy.cjs +22 -0
- package/lib/query-assigned-nodes-C76XVPWY.js +36 -0
- package/lib/radio/index.cjs +22 -0
- package/lib/radio/index.js +192 -0
- package/lib/random-id-ByCz1xaq.js +26 -0
- package/lib/random-id-CqvckpWe.cjs +18 -0
- package/lib/roving-tabindex-By_fCy_e.cjs +18 -0
- package/lib/roving-tabindex-DOg4z6ZU.js +66 -0
- package/lib/search/index.cjs +45 -0
- package/lib/search/index.js +132 -0
- package/lib/sized-mixin-BSYHt8nT.cjs +18 -0
- package/lib/sized-mixin-Dl0KoEcV.js +63 -0
- package/lib/slider/index.cjs +18 -0
- package/lib/slider/index.js +1159 -0
- package/lib/slottable-request-event-BfUUt1Mh.cjs +18 -0
- package/lib/slottable-request-event-DggLA4Rx.js +31 -0
- package/lib/state-BAO-13Bs.js +29 -0
- package/lib/state-DReJ3hB6.cjs +22 -0
- package/lib/streaming-listener-Bw4jE33f.cjs +18 -0
- package/lib/streaming-listener-DLo0wkMc.js +125 -0
- package/lib/style-map-BjBGQ_u3.cjs +22 -0
- package/lib/style-map-BqvQDFJt.js +53 -0
- package/lib/swatch/index.cjs +49 -0
- package/lib/swatch/index.js +343 -0
- package/lib/switch/index.cjs +22 -0
- package/lib/switch/index.js +74 -0
- package/lib/tags/index.cjs +32 -0
- package/lib/tags/index.js +174 -0
- package/lib/text-field/index.cjs +21 -0
- package/lib/text-field/index.js +62 -0
- package/lib/text-field-C6Aa7XOb.cjs +85 -0
- package/lib/text-field-DPk332j9.js +315 -0
- package/lib/toast/index.cjs +51 -0
- package/lib/toast/index.js +154 -0
- package/lib/tooltip/index.cjs +45 -0
- package/lib/tooltip/index.js +221 -0
- package/lib/unit-input/index.cjs +43 -0
- package/lib/unit-input/index.js +184 -0
- package/lib/when-CDK1Tt5Y.js +28 -0
- package/lib/when-CDZyJPvd.cjs +22 -0
- package/package.json +2 -2
|
@@ -0,0 +1,727 @@
|
|
|
1
|
+
/*! * Lucero - The design system for Luzmo.
|
|
2
|
+
*
|
|
3
|
+
* Copyright © 2025 Luzmo
|
|
4
|
+
* All rights reserved.
|
|
5
|
+
* Lucero (“Luzmo Design System”) must be used according to the Luzmo Terms of Service.
|
|
6
|
+
* This license allows users with a current active Luzmo account to use Lucero.
|
|
7
|
+
* This license terminates automatically if a user no longer has an active Luzmo account.
|
|
8
|
+
* Please view the Luzmo Terms of Service at: https://www.luzmo.com/information-pages/terms-of-use.
|
|
9
|
+
*
|
|
10
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
11
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
12
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
13
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
14
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
15
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
16
|
+
* SOFTWARE.
|
|
17
|
+
* */
|
|
18
|
+
function u(r, e) {
|
|
19
|
+
E(r) && (r = "100%");
|
|
20
|
+
const t = I(r);
|
|
21
|
+
return r = e === 360 ? r : Math.min(e, Math.max(0, parseFloat(r))), t && (r = parseInt(String(r * e), 10) / 100), Math.abs(r - e) < 1e-6 ? 1 : (e === 360 ? r = (r < 0 ? r % e + e : r % e) / parseFloat(String(e)) : r = r % e / parseFloat(String(e)), r);
|
|
22
|
+
}
|
|
23
|
+
function m(r) {
|
|
24
|
+
return Math.min(1, Math.max(0, r));
|
|
25
|
+
}
|
|
26
|
+
function E(r) {
|
|
27
|
+
return typeof r == "string" && r.indexOf(".") !== -1 && parseFloat(r) === 1;
|
|
28
|
+
}
|
|
29
|
+
function I(r) {
|
|
30
|
+
return typeof r == "string" && r.indexOf("%") !== -1;
|
|
31
|
+
}
|
|
32
|
+
function F(r) {
|
|
33
|
+
return r = parseFloat(r), (isNaN(r) || r < 0 || r > 1) && (r = 1), r;
|
|
34
|
+
}
|
|
35
|
+
function p(r) {
|
|
36
|
+
return Number(r) <= 1 ? `${Number(r) * 100}%` : r;
|
|
37
|
+
}
|
|
38
|
+
function l(r) {
|
|
39
|
+
return r.length === 1 ? "0" + r : String(r);
|
|
40
|
+
}
|
|
41
|
+
function B(r, e, t) {
|
|
42
|
+
return {
|
|
43
|
+
r: u(r, 255) * 255,
|
|
44
|
+
g: u(e, 255) * 255,
|
|
45
|
+
b: u(t, 255) * 255
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
function v(r, e, t) {
|
|
49
|
+
r = u(r, 255), e = u(e, 255), t = u(t, 255);
|
|
50
|
+
const n = Math.max(r, e, t), s = Math.min(r, e, t);
|
|
51
|
+
let a = 0, i = 0;
|
|
52
|
+
const h = (n + s) / 2;
|
|
53
|
+
if (n === s)
|
|
54
|
+
i = 0, a = 0;
|
|
55
|
+
else {
|
|
56
|
+
const o = n - s;
|
|
57
|
+
switch (i = h > 0.5 ? o / (2 - n - s) : o / (n + s), n) {
|
|
58
|
+
case r:
|
|
59
|
+
a = (e - t) / o + (e < t ? 6 : 0);
|
|
60
|
+
break;
|
|
61
|
+
case e:
|
|
62
|
+
a = (t - r) / o + 2;
|
|
63
|
+
break;
|
|
64
|
+
case t:
|
|
65
|
+
a = (r - e) / o + 4;
|
|
66
|
+
break;
|
|
67
|
+
}
|
|
68
|
+
a /= 6;
|
|
69
|
+
}
|
|
70
|
+
return { h: a, s: i, l: h };
|
|
71
|
+
}
|
|
72
|
+
function w(r, e, t) {
|
|
73
|
+
return t < 0 && (t += 1), t > 1 && (t -= 1), t < 1 / 6 ? r + (e - r) * (6 * t) : t < 1 / 2 ? e : t < 2 / 3 ? r + (e - r) * (2 / 3 - t) * 6 : r;
|
|
74
|
+
}
|
|
75
|
+
function q(r, e, t) {
|
|
76
|
+
let n, s, a;
|
|
77
|
+
if (r = u(r, 360), e = u(e, 100), t = u(t, 100), e === 0)
|
|
78
|
+
s = t, a = t, n = t;
|
|
79
|
+
else {
|
|
80
|
+
const i = t < 0.5 ? t * (1 + e) : t + e - t * e, h = 2 * t - i;
|
|
81
|
+
n = w(h, i, r + 1 / 3), s = w(h, i, r), a = w(h, i, r - 1 / 3);
|
|
82
|
+
}
|
|
83
|
+
return { r: n * 255, g: s * 255, b: a * 255 };
|
|
84
|
+
}
|
|
85
|
+
function A(r, e, t) {
|
|
86
|
+
r = u(r, 255), e = u(e, 255), t = u(t, 255);
|
|
87
|
+
const n = Math.max(r, e, t), s = Math.min(r, e, t);
|
|
88
|
+
let a = 0;
|
|
89
|
+
const i = n, h = n - s, o = n === 0 ? 0 : h / n;
|
|
90
|
+
if (n === s)
|
|
91
|
+
a = 0;
|
|
92
|
+
else {
|
|
93
|
+
switch (n) {
|
|
94
|
+
case r:
|
|
95
|
+
a = (e - t) / h + (e < t ? 6 : 0);
|
|
96
|
+
break;
|
|
97
|
+
case e:
|
|
98
|
+
a = (t - r) / h + 2;
|
|
99
|
+
break;
|
|
100
|
+
case t:
|
|
101
|
+
a = (r - e) / h + 4;
|
|
102
|
+
break;
|
|
103
|
+
}
|
|
104
|
+
a /= 6;
|
|
105
|
+
}
|
|
106
|
+
return { h: a, s: o, v: i };
|
|
107
|
+
}
|
|
108
|
+
function P(r, e, t) {
|
|
109
|
+
r = u(r, 360) * 6, e = u(e, 100), t = u(t, 100);
|
|
110
|
+
const n = Math.floor(r), s = r - n, a = t * (1 - e), i = t * (1 - s * e), h = t * (1 - (1 - s) * e), o = n % 6, x = [t, i, a, a, h, t][o], M = [h, t, t, i, a, a][o], N = [a, a, h, t, t, i][o];
|
|
111
|
+
return { r: x * 255, g: M * 255, b: N * 255 };
|
|
112
|
+
}
|
|
113
|
+
function H(r, e, t, n) {
|
|
114
|
+
const s = [
|
|
115
|
+
l(Math.round(r).toString(16)),
|
|
116
|
+
l(Math.round(e).toString(16)),
|
|
117
|
+
l(Math.round(t).toString(16))
|
|
118
|
+
];
|
|
119
|
+
return n && s[0].startsWith(s[0].charAt(1)) && s[1].startsWith(s[1].charAt(1)) && s[2].startsWith(s[2].charAt(1)) ? s[0].charAt(0) + s[1].charAt(0) + s[2].charAt(0) : s.join("");
|
|
120
|
+
}
|
|
121
|
+
function j(r, e, t, n, s) {
|
|
122
|
+
const a = [
|
|
123
|
+
l(Math.round(r).toString(16)),
|
|
124
|
+
l(Math.round(e).toString(16)),
|
|
125
|
+
l(Math.round(t).toString(16)),
|
|
126
|
+
l(W(n))
|
|
127
|
+
];
|
|
128
|
+
return s && a[0].startsWith(a[0].charAt(1)) && a[1].startsWith(a[1].charAt(1)) && a[2].startsWith(a[2].charAt(1)) && a[3].startsWith(a[3].charAt(1)) ? a[0].charAt(0) + a[1].charAt(0) + a[2].charAt(0) + a[3].charAt(0) : a.join("");
|
|
129
|
+
}
|
|
130
|
+
function O(r, e, t, n) {
|
|
131
|
+
const s = r / 100, a = e / 100, i = t / 100, h = n / 100, o = 255 * (1 - s) * (1 - h), x = 255 * (1 - a) * (1 - h), M = 255 * (1 - i) * (1 - h);
|
|
132
|
+
return { r: o, g: x, b: M };
|
|
133
|
+
}
|
|
134
|
+
function R(r, e, t) {
|
|
135
|
+
let n = 1 - r / 255, s = 1 - e / 255, a = 1 - t / 255, i = Math.min(n, s, a);
|
|
136
|
+
return i === 1 ? (n = 0, s = 0, a = 0) : (n = (n - i) / (1 - i) * 100, s = (s - i) / (1 - i) * 100, a = (a - i) / (1 - i) * 100), i *= 100, {
|
|
137
|
+
c: Math.round(n),
|
|
138
|
+
m: Math.round(s),
|
|
139
|
+
y: Math.round(a),
|
|
140
|
+
k: Math.round(i)
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
function W(r) {
|
|
144
|
+
return Math.round(parseFloat(r) * 255).toString(16);
|
|
145
|
+
}
|
|
146
|
+
function $(r) {
|
|
147
|
+
return c(r) / 255;
|
|
148
|
+
}
|
|
149
|
+
function c(r) {
|
|
150
|
+
return parseInt(r, 16);
|
|
151
|
+
}
|
|
152
|
+
function G(r) {
|
|
153
|
+
return {
|
|
154
|
+
r: r >> 16,
|
|
155
|
+
g: (r & 65280) >> 8,
|
|
156
|
+
b: r & 255
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
const y = {
|
|
160
|
+
aliceblue: "#f0f8ff",
|
|
161
|
+
antiquewhite: "#faebd7",
|
|
162
|
+
aqua: "#00ffff",
|
|
163
|
+
aquamarine: "#7fffd4",
|
|
164
|
+
azure: "#f0ffff",
|
|
165
|
+
beige: "#f5f5dc",
|
|
166
|
+
bisque: "#ffe4c4",
|
|
167
|
+
black: "#000000",
|
|
168
|
+
blanchedalmond: "#ffebcd",
|
|
169
|
+
blue: "#0000ff",
|
|
170
|
+
blueviolet: "#8a2be2",
|
|
171
|
+
brown: "#a52a2a",
|
|
172
|
+
burlywood: "#deb887",
|
|
173
|
+
cadetblue: "#5f9ea0",
|
|
174
|
+
chartreuse: "#7fff00",
|
|
175
|
+
chocolate: "#d2691e",
|
|
176
|
+
coral: "#ff7f50",
|
|
177
|
+
cornflowerblue: "#6495ed",
|
|
178
|
+
cornsilk: "#fff8dc",
|
|
179
|
+
crimson: "#dc143c",
|
|
180
|
+
cyan: "#00ffff",
|
|
181
|
+
darkblue: "#00008b",
|
|
182
|
+
darkcyan: "#008b8b",
|
|
183
|
+
darkgoldenrod: "#b8860b",
|
|
184
|
+
darkgray: "#a9a9a9",
|
|
185
|
+
darkgreen: "#006400",
|
|
186
|
+
darkgrey: "#a9a9a9",
|
|
187
|
+
darkkhaki: "#bdb76b",
|
|
188
|
+
darkmagenta: "#8b008b",
|
|
189
|
+
darkolivegreen: "#556b2f",
|
|
190
|
+
darkorange: "#ff8c00",
|
|
191
|
+
darkorchid: "#9932cc",
|
|
192
|
+
darkred: "#8b0000",
|
|
193
|
+
darksalmon: "#e9967a",
|
|
194
|
+
darkseagreen: "#8fbc8f",
|
|
195
|
+
darkslateblue: "#483d8b",
|
|
196
|
+
darkslategray: "#2f4f4f",
|
|
197
|
+
darkslategrey: "#2f4f4f",
|
|
198
|
+
darkturquoise: "#00ced1",
|
|
199
|
+
darkviolet: "#9400d3",
|
|
200
|
+
deeppink: "#ff1493",
|
|
201
|
+
deepskyblue: "#00bfff",
|
|
202
|
+
dimgray: "#696969",
|
|
203
|
+
dimgrey: "#696969",
|
|
204
|
+
dodgerblue: "#1e90ff",
|
|
205
|
+
firebrick: "#b22222",
|
|
206
|
+
floralwhite: "#fffaf0",
|
|
207
|
+
forestgreen: "#228b22",
|
|
208
|
+
fuchsia: "#ff00ff",
|
|
209
|
+
gainsboro: "#dcdcdc",
|
|
210
|
+
ghostwhite: "#f8f8ff",
|
|
211
|
+
goldenrod: "#daa520",
|
|
212
|
+
gold: "#ffd700",
|
|
213
|
+
gray: "#808080",
|
|
214
|
+
green: "#008000",
|
|
215
|
+
greenyellow: "#adff2f",
|
|
216
|
+
grey: "#808080",
|
|
217
|
+
honeydew: "#f0fff0",
|
|
218
|
+
hotpink: "#ff69b4",
|
|
219
|
+
indianred: "#cd5c5c",
|
|
220
|
+
indigo: "#4b0082",
|
|
221
|
+
ivory: "#fffff0",
|
|
222
|
+
khaki: "#f0e68c",
|
|
223
|
+
lavenderblush: "#fff0f5",
|
|
224
|
+
lavender: "#e6e6fa",
|
|
225
|
+
lawngreen: "#7cfc00",
|
|
226
|
+
lemonchiffon: "#fffacd",
|
|
227
|
+
lightblue: "#add8e6",
|
|
228
|
+
lightcoral: "#f08080",
|
|
229
|
+
lightcyan: "#e0ffff",
|
|
230
|
+
lightgoldenrodyellow: "#fafad2",
|
|
231
|
+
lightgray: "#d3d3d3",
|
|
232
|
+
lightgreen: "#90ee90",
|
|
233
|
+
lightgrey: "#d3d3d3",
|
|
234
|
+
lightpink: "#ffb6c1",
|
|
235
|
+
lightsalmon: "#ffa07a",
|
|
236
|
+
lightseagreen: "#20b2aa",
|
|
237
|
+
lightskyblue: "#87cefa",
|
|
238
|
+
lightslategray: "#778899",
|
|
239
|
+
lightslategrey: "#778899",
|
|
240
|
+
lightsteelblue: "#b0c4de",
|
|
241
|
+
lightyellow: "#ffffe0",
|
|
242
|
+
lime: "#00ff00",
|
|
243
|
+
limegreen: "#32cd32",
|
|
244
|
+
linen: "#faf0e6",
|
|
245
|
+
magenta: "#ff00ff",
|
|
246
|
+
maroon: "#800000",
|
|
247
|
+
mediumaquamarine: "#66cdaa",
|
|
248
|
+
mediumblue: "#0000cd",
|
|
249
|
+
mediumorchid: "#ba55d3",
|
|
250
|
+
mediumpurple: "#9370db",
|
|
251
|
+
mediumseagreen: "#3cb371",
|
|
252
|
+
mediumslateblue: "#7b68ee",
|
|
253
|
+
mediumspringgreen: "#00fa9a",
|
|
254
|
+
mediumturquoise: "#48d1cc",
|
|
255
|
+
mediumvioletred: "#c71585",
|
|
256
|
+
midnightblue: "#191970",
|
|
257
|
+
mintcream: "#f5fffa",
|
|
258
|
+
mistyrose: "#ffe4e1",
|
|
259
|
+
moccasin: "#ffe4b5",
|
|
260
|
+
navajowhite: "#ffdead",
|
|
261
|
+
navy: "#000080",
|
|
262
|
+
oldlace: "#fdf5e6",
|
|
263
|
+
olive: "#808000",
|
|
264
|
+
olivedrab: "#6b8e23",
|
|
265
|
+
orange: "#ffa500",
|
|
266
|
+
orangered: "#ff4500",
|
|
267
|
+
orchid: "#da70d6",
|
|
268
|
+
palegoldenrod: "#eee8aa",
|
|
269
|
+
palegreen: "#98fb98",
|
|
270
|
+
paleturquoise: "#afeeee",
|
|
271
|
+
palevioletred: "#db7093",
|
|
272
|
+
papayawhip: "#ffefd5",
|
|
273
|
+
peachpuff: "#ffdab9",
|
|
274
|
+
peru: "#cd853f",
|
|
275
|
+
pink: "#ffc0cb",
|
|
276
|
+
plum: "#dda0dd",
|
|
277
|
+
powderblue: "#b0e0e6",
|
|
278
|
+
purple: "#800080",
|
|
279
|
+
rebeccapurple: "#663399",
|
|
280
|
+
red: "#ff0000",
|
|
281
|
+
rosybrown: "#bc8f8f",
|
|
282
|
+
royalblue: "#4169e1",
|
|
283
|
+
saddlebrown: "#8b4513",
|
|
284
|
+
salmon: "#fa8072",
|
|
285
|
+
sandybrown: "#f4a460",
|
|
286
|
+
seagreen: "#2e8b57",
|
|
287
|
+
seashell: "#fff5ee",
|
|
288
|
+
sienna: "#a0522d",
|
|
289
|
+
silver: "#c0c0c0",
|
|
290
|
+
skyblue: "#87ceeb",
|
|
291
|
+
slateblue: "#6a5acd",
|
|
292
|
+
slategray: "#708090",
|
|
293
|
+
slategrey: "#708090",
|
|
294
|
+
snow: "#fffafa",
|
|
295
|
+
springgreen: "#00ff7f",
|
|
296
|
+
steelblue: "#4682b4",
|
|
297
|
+
tan: "#d2b48c",
|
|
298
|
+
teal: "#008080",
|
|
299
|
+
thistle: "#d8bfd8",
|
|
300
|
+
tomato: "#ff6347",
|
|
301
|
+
turquoise: "#40e0d0",
|
|
302
|
+
violet: "#ee82ee",
|
|
303
|
+
wheat: "#f5deb3",
|
|
304
|
+
white: "#ffffff",
|
|
305
|
+
whitesmoke: "#f5f5f5",
|
|
306
|
+
yellow: "#ffff00",
|
|
307
|
+
yellowgreen: "#9acd32"
|
|
308
|
+
};
|
|
309
|
+
function T(r) {
|
|
310
|
+
let e = { r: 0, g: 0, b: 0 }, t = 1, n = null, s = null, a = null, i = !1, h = !1;
|
|
311
|
+
return typeof r == "string" && (r = V(r)), typeof r == "object" && (g(r.r) && g(r.g) && g(r.b) ? (e = B(r.r, r.g, r.b), i = !0, h = String(r.r).substr(-1) === "%" ? "prgb" : "rgb") : g(r.h) && g(r.s) && g(r.v) ? (n = p(r.s), s = p(r.v), e = P(r.h, n, s), i = !0, h = "hsv") : g(r.h) && g(r.s) && g(r.l) ? (n = p(r.s), a = p(r.l), e = q(r.h, n, a), i = !0, h = "hsl") : g(r.c) && g(r.m) && g(r.y) && g(r.k) && (e = O(r.c, r.m, r.y, r.k), i = !0, h = "cmyk"), Object.prototype.hasOwnProperty.call(r, "a") && (t = r.a)), t = F(t), {
|
|
312
|
+
ok: i,
|
|
313
|
+
format: r.format || h,
|
|
314
|
+
r: Math.min(255, Math.max(e.r, 0)),
|
|
315
|
+
g: Math.min(255, Math.max(e.g, 0)),
|
|
316
|
+
b: Math.min(255, Math.max(e.b, 0)),
|
|
317
|
+
a: t
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
const U = "[-\\+]?\\d+%?", D = "[-\\+]?\\d*\\.\\d+%?", b = "(?:" + D + ")|(?:" + U + ")", S = "[\\s|\\(]+(" + b + ")[,|\\s]+(" + b + ")[,|\\s]+(" + b + ")\\s*\\)?", k = (
|
|
321
|
+
// eslint-disable-next-line prettier/prettier
|
|
322
|
+
"[\\s|\\(]+(" + b + ")[,|\\s]+(" + b + ")[,|\\s]+(" + b + ")[,|\\s]+(" + b + ")\\s*\\)?"
|
|
323
|
+
), d = {
|
|
324
|
+
CSS_UNIT: new RegExp(b),
|
|
325
|
+
rgb: new RegExp("rgb" + S),
|
|
326
|
+
rgba: new RegExp("rgba" + k),
|
|
327
|
+
hsl: new RegExp("hsl" + S),
|
|
328
|
+
hsla: new RegExp("hsla" + k),
|
|
329
|
+
hsv: new RegExp("hsv" + S),
|
|
330
|
+
hsva: new RegExp("hsva" + k),
|
|
331
|
+
cmyk: new RegExp("cmyk" + k),
|
|
332
|
+
hex3: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
|
|
333
|
+
hex6: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,
|
|
334
|
+
hex4: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
|
|
335
|
+
hex8: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/
|
|
336
|
+
};
|
|
337
|
+
function V(r) {
|
|
338
|
+
if (r = r.trim().toLowerCase(), r.length === 0)
|
|
339
|
+
return !1;
|
|
340
|
+
let e = !1;
|
|
341
|
+
if (y[r])
|
|
342
|
+
r = y[r], e = !0;
|
|
343
|
+
else if (r === "transparent")
|
|
344
|
+
return { r: 0, g: 0, b: 0, a: 0, format: "name" };
|
|
345
|
+
let t = d.rgb.exec(r);
|
|
346
|
+
return t ? { r: t[1], g: t[2], b: t[3] } : (t = d.rgba.exec(r), t ? { r: t[1], g: t[2], b: t[3], a: t[4] } : (t = d.hsl.exec(r), t ? { h: t[1], s: t[2], l: t[3] } : (t = d.hsla.exec(r), t ? { h: t[1], s: t[2], l: t[3], a: t[4] } : (t = d.hsv.exec(r), t ? { h: t[1], s: t[2], v: t[3] } : (t = d.hsva.exec(r), t ? { h: t[1], s: t[2], v: t[3], a: t[4] } : (t = d.cmyk.exec(r), t ? {
|
|
347
|
+
c: t[1],
|
|
348
|
+
m: t[2],
|
|
349
|
+
y: t[3],
|
|
350
|
+
k: t[4]
|
|
351
|
+
} : (t = d.hex8.exec(r), t ? {
|
|
352
|
+
r: c(t[1]),
|
|
353
|
+
g: c(t[2]),
|
|
354
|
+
b: c(t[3]),
|
|
355
|
+
a: $(t[4]),
|
|
356
|
+
format: e ? "name" : "hex8"
|
|
357
|
+
} : (t = d.hex6.exec(r), t ? {
|
|
358
|
+
r: c(t[1]),
|
|
359
|
+
g: c(t[2]),
|
|
360
|
+
b: c(t[3]),
|
|
361
|
+
format: e ? "name" : "hex"
|
|
362
|
+
} : (t = d.hex4.exec(r), t ? {
|
|
363
|
+
r: c(t[1] + t[1]),
|
|
364
|
+
g: c(t[2] + t[2]),
|
|
365
|
+
b: c(t[3] + t[3]),
|
|
366
|
+
a: $(t[4] + t[4]),
|
|
367
|
+
format: e ? "name" : "hex8"
|
|
368
|
+
} : (t = d.hex3.exec(r), t ? {
|
|
369
|
+
r: c(t[1] + t[1]),
|
|
370
|
+
g: c(t[2] + t[2]),
|
|
371
|
+
b: c(t[3] + t[3]),
|
|
372
|
+
format: e ? "name" : "hex"
|
|
373
|
+
} : !1))))))))));
|
|
374
|
+
}
|
|
375
|
+
function g(r) {
|
|
376
|
+
return typeof r == "number" ? !Number.isNaN(r) : d.CSS_UNIT.test(r);
|
|
377
|
+
}
|
|
378
|
+
class f {
|
|
379
|
+
constructor(e = "", t = {}) {
|
|
380
|
+
if (e instanceof f)
|
|
381
|
+
return e;
|
|
382
|
+
typeof e == "number" && (e = G(e)), this.originalInput = e;
|
|
383
|
+
const n = T(e);
|
|
384
|
+
this.originalInput = e, this.r = n.r, this.g = n.g, this.b = n.b, this.a = n.a, this.roundA = Math.round(100 * this.a) / 100, this.format = t.format ?? n.format, this.gradientType = t.gradientType, this.r < 1 && (this.r = Math.round(this.r)), this.g < 1 && (this.g = Math.round(this.g)), this.b < 1 && (this.b = Math.round(this.b)), this.isValid = n.ok;
|
|
385
|
+
}
|
|
386
|
+
isDark() {
|
|
387
|
+
return this.getBrightness() < 128;
|
|
388
|
+
}
|
|
389
|
+
isLight() {
|
|
390
|
+
return !this.isDark();
|
|
391
|
+
}
|
|
392
|
+
/**
|
|
393
|
+
* Returns the perceived brightness of the color, from 0-255.
|
|
394
|
+
*/
|
|
395
|
+
getBrightness() {
|
|
396
|
+
const e = this.toRgb();
|
|
397
|
+
return (e.r * 299 + e.g * 587 + e.b * 114) / 1e3;
|
|
398
|
+
}
|
|
399
|
+
/**
|
|
400
|
+
* Returns the perceived luminance of a color, from 0-1.
|
|
401
|
+
*/
|
|
402
|
+
getLuminance() {
|
|
403
|
+
const e = this.toRgb();
|
|
404
|
+
let t, n, s;
|
|
405
|
+
const a = e.r / 255, i = e.g / 255, h = e.b / 255;
|
|
406
|
+
return a <= 0.03928 ? t = a / 12.92 : t = Math.pow((a + 0.055) / 1.055, 2.4), i <= 0.03928 ? n = i / 12.92 : n = Math.pow((i + 0.055) / 1.055, 2.4), h <= 0.03928 ? s = h / 12.92 : s = Math.pow((h + 0.055) / 1.055, 2.4), 0.2126 * t + 0.7152 * n + 0.0722 * s;
|
|
407
|
+
}
|
|
408
|
+
/**
|
|
409
|
+
* Returns the alpha value of a color, from 0-1.
|
|
410
|
+
*/
|
|
411
|
+
getAlpha() {
|
|
412
|
+
return this.a;
|
|
413
|
+
}
|
|
414
|
+
/**
|
|
415
|
+
* Sets the alpha value on the current color.
|
|
416
|
+
*
|
|
417
|
+
* @param alpha - The new alpha value. The accepted range is 0-1.
|
|
418
|
+
*/
|
|
419
|
+
setAlpha(e) {
|
|
420
|
+
return this.a = F(e), this.roundA = Math.round(100 * this.a) / 100, this;
|
|
421
|
+
}
|
|
422
|
+
/**
|
|
423
|
+
* Returns whether the color is monochrome.
|
|
424
|
+
*/
|
|
425
|
+
isMonochrome() {
|
|
426
|
+
const { s: e } = this.toHsl();
|
|
427
|
+
return e === 0;
|
|
428
|
+
}
|
|
429
|
+
/**
|
|
430
|
+
* Returns the object as a HSVA object.
|
|
431
|
+
*/
|
|
432
|
+
toHsv() {
|
|
433
|
+
const e = A(this.r, this.g, this.b);
|
|
434
|
+
return { h: e.h * 360, s: e.s, v: e.v, a: this.a };
|
|
435
|
+
}
|
|
436
|
+
/**
|
|
437
|
+
* Returns the hsva values interpolated into a string with the following format:
|
|
438
|
+
* "hsva(xxx, xxx, xxx, xx)".
|
|
439
|
+
*/
|
|
440
|
+
toHsvString() {
|
|
441
|
+
const e = A(this.r, this.g, this.b), t = Math.round(e.h * 360), n = Math.round(e.s * 100), s = Math.round(e.v * 100);
|
|
442
|
+
return this.a === 1 ? `hsv(${t}, ${n}%, ${s}%)` : `hsva(${t}, ${n}%, ${s}%, ${this.roundA})`;
|
|
443
|
+
}
|
|
444
|
+
/**
|
|
445
|
+
* Returns the object as a HSLA object.
|
|
446
|
+
*/
|
|
447
|
+
toHsl() {
|
|
448
|
+
const e = v(this.r, this.g, this.b);
|
|
449
|
+
return { h: e.h * 360, s: e.s, l: e.l, a: this.a };
|
|
450
|
+
}
|
|
451
|
+
/**
|
|
452
|
+
* Returns the hsla values interpolated into a string with the following format:
|
|
453
|
+
* "hsla(xxx, xxx, xxx, xx)".
|
|
454
|
+
*/
|
|
455
|
+
toHslString() {
|
|
456
|
+
const e = v(this.r, this.g, this.b), t = Math.round(e.h * 360), n = Math.round(e.s * 100), s = Math.round(e.l * 100);
|
|
457
|
+
return this.a === 1 ? `hsl(${t}, ${n}%, ${s}%)` : `hsla(${t}, ${n}%, ${s}%, ${this.roundA})`;
|
|
458
|
+
}
|
|
459
|
+
/**
|
|
460
|
+
* Returns the hex value of the color.
|
|
461
|
+
* @param allow3Char will shorten hex value to 3 char if possible
|
|
462
|
+
*/
|
|
463
|
+
toHex(e = !1) {
|
|
464
|
+
return H(this.r, this.g, this.b, e);
|
|
465
|
+
}
|
|
466
|
+
/**
|
|
467
|
+
* Returns the hex value of the color -with a # prefixed.
|
|
468
|
+
* @param allow3Char will shorten hex value to 3 char if possible
|
|
469
|
+
*/
|
|
470
|
+
toHexString(e = !1) {
|
|
471
|
+
return "#" + this.toHex(e);
|
|
472
|
+
}
|
|
473
|
+
/**
|
|
474
|
+
* Returns the hex 8 value of the color.
|
|
475
|
+
* @param allow4Char will shorten hex value to 4 char if possible
|
|
476
|
+
*/
|
|
477
|
+
toHex8(e = !1) {
|
|
478
|
+
return j(this.r, this.g, this.b, this.a, e);
|
|
479
|
+
}
|
|
480
|
+
/**
|
|
481
|
+
* Returns the hex 8 value of the color -with a # prefixed.
|
|
482
|
+
* @param allow4Char will shorten hex value to 4 char if possible
|
|
483
|
+
*/
|
|
484
|
+
toHex8String(e = !1) {
|
|
485
|
+
return "#" + this.toHex8(e);
|
|
486
|
+
}
|
|
487
|
+
/**
|
|
488
|
+
* Returns the shorter hex value of the color depends on its alpha -with a # prefixed.
|
|
489
|
+
* @param allowShortChar will shorten hex value to 3 or 4 char if possible
|
|
490
|
+
*/
|
|
491
|
+
toHexShortString(e = !1) {
|
|
492
|
+
return this.a === 1 ? this.toHexString(e) : this.toHex8String(e);
|
|
493
|
+
}
|
|
494
|
+
/**
|
|
495
|
+
* Returns the object as a RGBA object.
|
|
496
|
+
*/
|
|
497
|
+
toRgb() {
|
|
498
|
+
return {
|
|
499
|
+
r: Math.round(this.r),
|
|
500
|
+
g: Math.round(this.g),
|
|
501
|
+
b: Math.round(this.b),
|
|
502
|
+
a: this.a
|
|
503
|
+
};
|
|
504
|
+
}
|
|
505
|
+
/**
|
|
506
|
+
* Returns the RGBA values interpolated into a string with the following format:
|
|
507
|
+
* "RGBA(xxx, xxx, xxx, xx)".
|
|
508
|
+
*/
|
|
509
|
+
toRgbString() {
|
|
510
|
+
const e = Math.round(this.r), t = Math.round(this.g), n = Math.round(this.b);
|
|
511
|
+
return this.a === 1 ? `rgb(${e}, ${t}, ${n})` : `rgba(${e}, ${t}, ${n}, ${this.roundA})`;
|
|
512
|
+
}
|
|
513
|
+
/**
|
|
514
|
+
* Returns the object as a RGBA object.
|
|
515
|
+
*/
|
|
516
|
+
toPercentageRgb() {
|
|
517
|
+
const e = (t) => `${Math.round(u(t, 255) * 100)}%`;
|
|
518
|
+
return {
|
|
519
|
+
r: e(this.r),
|
|
520
|
+
g: e(this.g),
|
|
521
|
+
b: e(this.b),
|
|
522
|
+
a: this.a
|
|
523
|
+
};
|
|
524
|
+
}
|
|
525
|
+
/**
|
|
526
|
+
* Returns the RGBA relative values interpolated into a string
|
|
527
|
+
*/
|
|
528
|
+
toPercentageRgbString() {
|
|
529
|
+
const e = (t) => Math.round(u(t, 255) * 100);
|
|
530
|
+
return this.a === 1 ? `rgb(${e(this.r)}%, ${e(this.g)}%, ${e(this.b)}%)` : `rgba(${e(this.r)}%, ${e(this.g)}%, ${e(this.b)}%, ${this.roundA})`;
|
|
531
|
+
}
|
|
532
|
+
toCmyk() {
|
|
533
|
+
return {
|
|
534
|
+
...R(this.r, this.g, this.b)
|
|
535
|
+
};
|
|
536
|
+
}
|
|
537
|
+
toCmykString() {
|
|
538
|
+
const { c: e, m: t, y: n, k: s } = R(this.r, this.g, this.b);
|
|
539
|
+
return `cmyk(${e}, ${t}, ${n}, ${s})`;
|
|
540
|
+
}
|
|
541
|
+
/**
|
|
542
|
+
* The 'real' name of the color -if there is one.
|
|
543
|
+
*/
|
|
544
|
+
toName() {
|
|
545
|
+
if (this.a === 0)
|
|
546
|
+
return "transparent";
|
|
547
|
+
if (this.a < 1)
|
|
548
|
+
return !1;
|
|
549
|
+
const e = "#" + H(this.r, this.g, this.b, !1);
|
|
550
|
+
for (const [t, n] of Object.entries(y))
|
|
551
|
+
if (e === n)
|
|
552
|
+
return t;
|
|
553
|
+
return !1;
|
|
554
|
+
}
|
|
555
|
+
toString(e) {
|
|
556
|
+
const t = !!e;
|
|
557
|
+
e = e ?? this.format;
|
|
558
|
+
let n = !1;
|
|
559
|
+
const s = this.a < 1 && this.a >= 0;
|
|
560
|
+
return !t && s && (e.startsWith("hex") || e === "name") ? e === "name" && this.a === 0 ? this.toName() : this.toRgbString() : (e === "rgb" && (n = this.toRgbString()), e === "prgb" && (n = this.toPercentageRgbString()), (e === "hex" || e === "hex6") && (n = this.toHexString()), e === "hex3" && (n = this.toHexString(!0)), e === "hex4" && (n = this.toHex8String(!0)), e === "hex8" && (n = this.toHex8String()), e === "name" && (n = this.toName()), e === "hsl" && (n = this.toHslString()), e === "hsv" && (n = this.toHsvString()), e === "cmyk" && (n = this.toCmykString()), n || this.toHexString());
|
|
561
|
+
}
|
|
562
|
+
toNumber() {
|
|
563
|
+
return (Math.round(this.r) << 16) + (Math.round(this.g) << 8) + Math.round(this.b);
|
|
564
|
+
}
|
|
565
|
+
clone() {
|
|
566
|
+
return new f(this.toString());
|
|
567
|
+
}
|
|
568
|
+
/**
|
|
569
|
+
* Lighten the color a given amount. Providing 100 will always return white.
|
|
570
|
+
* @param amount - valid between 1-100
|
|
571
|
+
*/
|
|
572
|
+
lighten(e = 10) {
|
|
573
|
+
const t = this.toHsl();
|
|
574
|
+
return t.l += e / 100, t.l = m(t.l), new f(t);
|
|
575
|
+
}
|
|
576
|
+
/**
|
|
577
|
+
* Brighten the color a given amount, from 0 to 100.
|
|
578
|
+
* @param amount - valid between 1-100
|
|
579
|
+
*/
|
|
580
|
+
brighten(e = 10) {
|
|
581
|
+
const t = this.toRgb();
|
|
582
|
+
return t.r = Math.max(0, Math.min(255, t.r - Math.round(255 * -(e / 100)))), t.g = Math.max(0, Math.min(255, t.g - Math.round(255 * -(e / 100)))), t.b = Math.max(0, Math.min(255, t.b - Math.round(255 * -(e / 100)))), new f(t);
|
|
583
|
+
}
|
|
584
|
+
/**
|
|
585
|
+
* Darken the color a given amount, from 0 to 100.
|
|
586
|
+
* Providing 100 will always return black.
|
|
587
|
+
* @param amount - valid between 1-100
|
|
588
|
+
*/
|
|
589
|
+
darken(e = 10) {
|
|
590
|
+
const t = this.toHsl();
|
|
591
|
+
return t.l -= e / 100, t.l = m(t.l), new f(t);
|
|
592
|
+
}
|
|
593
|
+
/**
|
|
594
|
+
* Mix the color with pure white, from 0 to 100.
|
|
595
|
+
* Providing 0 will do nothing, providing 100 will always return white.
|
|
596
|
+
* @param amount - valid between 1-100
|
|
597
|
+
*/
|
|
598
|
+
tint(e = 10) {
|
|
599
|
+
return this.mix("white", e);
|
|
600
|
+
}
|
|
601
|
+
/**
|
|
602
|
+
* Mix the color with pure black, from 0 to 100.
|
|
603
|
+
* Providing 0 will do nothing, providing 100 will always return black.
|
|
604
|
+
* @param amount - valid between 1-100
|
|
605
|
+
*/
|
|
606
|
+
shade(e = 10) {
|
|
607
|
+
return this.mix("black", e);
|
|
608
|
+
}
|
|
609
|
+
/**
|
|
610
|
+
* Desaturate the color a given amount, from 0 to 100.
|
|
611
|
+
* Providing 100 will is the same as calling greyscale
|
|
612
|
+
* @param amount - valid between 1-100
|
|
613
|
+
*/
|
|
614
|
+
desaturate(e = 10) {
|
|
615
|
+
const t = this.toHsl();
|
|
616
|
+
return t.s -= e / 100, t.s = m(t.s), new f(t);
|
|
617
|
+
}
|
|
618
|
+
/**
|
|
619
|
+
* Saturate the color a given amount, from 0 to 100.
|
|
620
|
+
* @param amount - valid between 1-100
|
|
621
|
+
*/
|
|
622
|
+
saturate(e = 10) {
|
|
623
|
+
const t = this.toHsl();
|
|
624
|
+
return t.s += e / 100, t.s = m(t.s), new f(t);
|
|
625
|
+
}
|
|
626
|
+
/**
|
|
627
|
+
* Completely desaturates a color into greyscale.
|
|
628
|
+
* Same as calling `desaturate(100)`
|
|
629
|
+
*/
|
|
630
|
+
greyscale() {
|
|
631
|
+
return this.desaturate(100);
|
|
632
|
+
}
|
|
633
|
+
/**
|
|
634
|
+
* Spin takes a positive or negative amount within [-360, 360] indicating the change of hue.
|
|
635
|
+
* Values outside of this range will be wrapped into this range.
|
|
636
|
+
*/
|
|
637
|
+
spin(e) {
|
|
638
|
+
const t = this.toHsl(), n = (t.h + e) % 360;
|
|
639
|
+
return t.h = n < 0 ? 360 + n : n, new f(t);
|
|
640
|
+
}
|
|
641
|
+
/**
|
|
642
|
+
* Mix the current color a given amount with another color, from 0 to 100.
|
|
643
|
+
* 0 means no mixing (return current color).
|
|
644
|
+
*/
|
|
645
|
+
mix(e, t = 50) {
|
|
646
|
+
const n = this.toRgb(), s = new f(e).toRgb(), a = t / 100, i = {
|
|
647
|
+
r: (s.r - n.r) * a + n.r,
|
|
648
|
+
g: (s.g - n.g) * a + n.g,
|
|
649
|
+
b: (s.b - n.b) * a + n.b,
|
|
650
|
+
a: (s.a - n.a) * a + n.a
|
|
651
|
+
};
|
|
652
|
+
return new f(i);
|
|
653
|
+
}
|
|
654
|
+
analogous(e = 6, t = 30) {
|
|
655
|
+
const n = this.toHsl(), s = 360 / t, a = [this];
|
|
656
|
+
for (n.h = (n.h - (s * e >> 1) + 720) % 360; --e; )
|
|
657
|
+
n.h = (n.h + s) % 360, a.push(new f(n));
|
|
658
|
+
return a;
|
|
659
|
+
}
|
|
660
|
+
/**
|
|
661
|
+
* taken from https://github.com/infusion/jQuery-xcolor/blob/master/jquery.xcolor.js
|
|
662
|
+
*/
|
|
663
|
+
complement() {
|
|
664
|
+
const e = this.toHsl();
|
|
665
|
+
return e.h = (e.h + 180) % 360, new f(e);
|
|
666
|
+
}
|
|
667
|
+
monochromatic(e = 6) {
|
|
668
|
+
const t = this.toHsv(), { h: n } = t, { s } = t;
|
|
669
|
+
let { v: a } = t;
|
|
670
|
+
const i = [], h = 1 / e;
|
|
671
|
+
for (; e--; )
|
|
672
|
+
i.push(new f({ h: n, s, v: a })), a = (a + h) % 1;
|
|
673
|
+
return i;
|
|
674
|
+
}
|
|
675
|
+
splitcomplement() {
|
|
676
|
+
const e = this.toHsl(), { h: t } = e;
|
|
677
|
+
return [
|
|
678
|
+
this,
|
|
679
|
+
new f({ h: (t + 72) % 360, s: e.s, l: e.l }),
|
|
680
|
+
new f({ h: (t + 216) % 360, s: e.s, l: e.l })
|
|
681
|
+
];
|
|
682
|
+
}
|
|
683
|
+
/**
|
|
684
|
+
* Compute how the color would appear on a background
|
|
685
|
+
*/
|
|
686
|
+
onBackground(e) {
|
|
687
|
+
const t = this.toRgb(), n = new f(e).toRgb(), s = t.a + n.a * (1 - t.a);
|
|
688
|
+
return new f({
|
|
689
|
+
r: (t.r * t.a + n.r * n.a * (1 - t.a)) / s,
|
|
690
|
+
g: (t.g * t.a + n.g * n.a * (1 - t.a)) / s,
|
|
691
|
+
b: (t.b * t.a + n.b * n.a * (1 - t.a)) / s,
|
|
692
|
+
a: s
|
|
693
|
+
});
|
|
694
|
+
}
|
|
695
|
+
/**
|
|
696
|
+
* Alias for `polyad(3)`
|
|
697
|
+
*/
|
|
698
|
+
triad() {
|
|
699
|
+
return this.polyad(3);
|
|
700
|
+
}
|
|
701
|
+
/**
|
|
702
|
+
* Alias for `polyad(4)`
|
|
703
|
+
*/
|
|
704
|
+
tetrad() {
|
|
705
|
+
return this.polyad(4);
|
|
706
|
+
}
|
|
707
|
+
/**
|
|
708
|
+
* Get polyad colors, like (for 1, 2, 3, 4, 5, 6, 7, 8, etc...)
|
|
709
|
+
* monad, dyad, triad, tetrad, pentad, hexad, heptad, octad, etc...
|
|
710
|
+
*/
|
|
711
|
+
polyad(e) {
|
|
712
|
+
const t = this.toHsl(), { h: n } = t, s = [this], a = 360 / e;
|
|
713
|
+
for (let i = 1; i < e; i++)
|
|
714
|
+
s.push(new f({ h: (n + i * a) % 360, s: t.s, l: t.l }));
|
|
715
|
+
return s;
|
|
716
|
+
}
|
|
717
|
+
/**
|
|
718
|
+
* compare color vs current color
|
|
719
|
+
*/
|
|
720
|
+
equals(e) {
|
|
721
|
+
const t = new f(e);
|
|
722
|
+
return this.format === "cmyk" || t.format === "cmyk" ? this.toCmykString() === t.toCmykString() : this.toRgbString() === t.toRgbString();
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
export {
|
|
726
|
+
f as T
|
|
727
|
+
};
|