@thednp/color-picker 2.0.0 → 2.0.2
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +4 -4
- package/dist/css/color-picker.css +7 -7
- package/dist/css/color-picker.min.css +2 -2
- package/dist/css/color-picker.rtl.css +7 -7
- package/dist/css/color-picker.rtl.min.css +2 -2
- package/dist/js/color-picker.cjs +2 -2
- package/dist/js/color-picker.cjs.map +1 -1
- package/dist/js/color-picker.js +2 -2
- package/dist/js/color-picker.js.map +1 -1
- package/dist/js/color-picker.mjs +243 -239
- package/dist/js/color-picker.mjs.map +1 -1
- package/package.json +32 -35
- package/src/scss/color-picker.scss +6 -4
- package/src/ts/colorPalette.ts +2 -2
- package/src/ts/index.ts +20 -19
- package/test/color-palette.test.ts +137 -0
- package/test/color-picker.test.ts +705 -0
- package/{cypress → test}/fixtures/getMarkup.js +8 -7
- package/test/fixtures/swipe.ts +33 -0
- package/test/fixtures/write.ts +37 -0
- package/tsconfig.json +45 -27
- package/{vite.config.ts → vite.config.mts} +5 -12
- package/vitest.config-ui.ts +26 -0
- package/vitest.config.ts +26 -0
- package/cypress/e2e/color-palette.cy.ts +0 -128
- package/cypress/e2e/color-picker.cy.ts +0 -909
- package/cypress/plugins/esbuild-istanbul.ts +0 -50
- package/cypress/plugins/tsCompile.ts +0 -34
- package/cypress/support/commands.ts +0 -0
- package/cypress/support/e2e.ts +0 -21
- package/cypress/test.html +0 -23
- package/cypress.config.ts +0 -29
- /package/{compile.js → compile.cjs} +0 -0
- /package/{cypress → test}/fixtures/colorNamesFrench.js +0 -0
- /package/{cypress → test}/fixtures/componentLabelsFrench.js +0 -0
- /package/{cypress → test}/fixtures/format.js +0 -0
- /package/{cypress → test}/fixtures/getRandomInt.js +0 -0
- /package/{cypress → test}/fixtures/sampleWebcolors.js +0 -0
- /package/{cypress → test}/fixtures/testSample.js +0 -0
package/dist/js/color-picker.mjs
CHANGED
@@ -1,25 +1,27 @@
|
|
1
|
-
const _t = "aria-description", Nt = "aria-expanded",
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
1
|
+
const _t = "aria-description", Nt = "aria-expanded", Te = "aria-hidden", xt = "aria-selected", tt = "aria-valuenow", et = "aria-valuetext", Me = "change", Re = "DOMContentLoaded", Oe = "focusin", De = "focusout", zt = "keydown", Fe = "keyup", Et = "click", Ie = "pointerdown", be = "pointermove", Ke = "pointerup", Ve = "resize", Be = "scroll", je = "touchmove", j = "ArrowDown", ot = "ArrowUp", ht = "ArrowLeft", U = "ArrowRight", qe = "Enter", Ge = "Escape", Jt = "Space", Ue = "transitionDuration", We = "transitionProperty", X = "tabindex", _e = navigator.userAgentData, mt = _e, { userAgent: ze } = navigator, vt = ze, Xt = /iPhone|iPad|iPod|Android/i;
|
2
|
+
/* istanbul ignore else @preserve */
|
3
|
+
mt ? mt.brands.some((o) => Xt.test(o.brand)) : Xt.test(vt);
|
4
|
+
const Yt = /(iPhone|iPod|iPad)/;
|
5
|
+
mt ? mt.brands.some((o) => Yt.test(o.brand)) : (
|
6
|
+
/* istanbul ignore next @preserve */
|
7
|
+
Yt.test(vt)
|
7
8
|
);
|
8
9
|
vt && vt.includes("Firefox");
|
9
|
-
const { head:
|
10
|
-
["webkitPerspective", "perspective"].some((o) => o in
|
10
|
+
const { head: wt } = document;
|
11
|
+
["webkitPerspective", "perspective"].some((o) => o in wt.style);
|
11
12
|
const Bt = (o, t, e, s) => {
|
12
13
|
const r = s || !1;
|
13
14
|
o.addEventListener(t, e, r);
|
14
15
|
}, jt = (o, t, e, s) => {
|
15
16
|
const r = s || !1;
|
16
17
|
o.removeEventListener(t, e, r);
|
17
|
-
},
|
18
|
+
}, Je = (o, t, e, s) => {
|
18
19
|
const r = (n) => {
|
20
|
+
/* istanbul ignore else @preserve */
|
19
21
|
(n.target === o || n.currentTarget === o) && (e.apply(o, [n]), jt(o, t, r, s));
|
20
22
|
};
|
21
23
|
Bt(o, t, r, s);
|
22
|
-
},
|
24
|
+
}, Xe = () => {
|
23
25
|
};
|
24
26
|
(() => {
|
25
27
|
let o = !1;
|
@@ -27,20 +29,20 @@ const Bt = (o, t, e, s) => {
|
|
27
29
|
const t = Object.defineProperty({}, "passive", {
|
28
30
|
get: () => (o = !0, o)
|
29
31
|
});
|
30
|
-
|
32
|
+
Je(document, Re, Xe, t);
|
31
33
|
} catch {
|
32
34
|
}
|
33
35
|
return o;
|
34
36
|
})();
|
35
|
-
["webkitTransform", "transform"].some((o) => o in
|
36
|
-
["webkitAnimation", "animation"].some((o) => o in
|
37
|
-
["webkitTransition", "transition"].some((o) => o in
|
38
|
-
const
|
37
|
+
["webkitTransform", "transform"].some((o) => o in wt.style);
|
38
|
+
["webkitAnimation", "animation"].some((o) => o in wt.style);
|
39
|
+
["webkitTransition", "transition"].some((o) => o in wt.style);
|
40
|
+
const kt = (o, t) => o.getAttribute(t), v = (o, t, e) => o.setAttribute(t, e), Pt = (o, t) => o.removeAttribute(t), q = (o, ...t) => {
|
39
41
|
o.classList.add(...t);
|
40
42
|
}, O = (o, ...t) => {
|
41
43
|
o.classList.remove(...t);
|
42
|
-
},
|
43
|
-
data:
|
44
|
+
}, R = (o, t) => o.classList.contains(t), qt = (o) => o != null && typeof o == "object" || !1, Z = (o) => qt(o) && typeof o.nodeType == "number" && [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11].some((t) => o.nodeType === t) || !1, at = (o) => Z(o) && o.nodeType === 1 || !1, z = /* @__PURE__ */ new Map(), ct = {
|
45
|
+
data: z,
|
44
46
|
/**
|
45
47
|
* Sets web components data.
|
46
48
|
*
|
@@ -49,7 +51,7 @@ const yt = (o, t) => o.getAttribute(t), m = (o, t, e) => o.setAttribute(t, e), P
|
|
49
51
|
* @param instance the component instance
|
50
52
|
*/
|
51
53
|
set: (o, t, e) => {
|
52
|
-
at(o) && (
|
54
|
+
at(o) && (z.has(t) || z.set(t, /* @__PURE__ */ new Map()), z.get(t).set(o, e));
|
53
55
|
},
|
54
56
|
/**
|
55
57
|
* Returns all instances for specified component.
|
@@ -57,7 +59,7 @@ const yt = (o, t) => o.getAttribute(t), m = (o, t, e) => o.setAttribute(t, e), P
|
|
57
59
|
* @param component the component's name or a unique key
|
58
60
|
* @returns all the component instances
|
59
61
|
*/
|
60
|
-
getAllFor: (o) =>
|
62
|
+
getAllFor: (o) => z.get(o) || null,
|
61
63
|
/**
|
62
64
|
* Returns the instance associated with the target.
|
63
65
|
*
|
@@ -78,9 +80,9 @@ const yt = (o, t) => o.getAttribute(t), m = (o, t, e) => o.setAttribute(t, e), P
|
|
78
80
|
*/
|
79
81
|
remove: (o, t) => {
|
80
82
|
const e = ct.getAllFor(t);
|
81
|
-
!e || !at(o) || (e.delete(o), e.size === 0 &&
|
83
|
+
!e || !at(o) || (e.delete(o), e.size === 0 && z.delete(t));
|
82
84
|
}
|
83
|
-
},
|
85
|
+
}, Ye = (o, t) => ct.get(o, t), B = (o) => typeof o == "string" || !1, Ze = (o) => qt(o) && o.constructor.name === "Window" || !1, pe = (o) => Z(o) && o.nodeType === 9 || !1, V = (o) => Ze(o) ? o.document : pe(o) ? o : Z(o) ? o.ownerDocument : window.document, K = (o, ...t) => Object.assign(o, ...t), x = (o) => {
|
84
86
|
if (!o) return;
|
85
87
|
if (B(o))
|
86
88
|
return V().createElement(o);
|
@@ -88,19 +90,19 @@ const yt = (o, t) => o.getAttribute(t), m = (o, t, e) => o.setAttribute(t, e), P
|
|
88
90
|
if (!e) return;
|
89
91
|
const s = { ...o };
|
90
92
|
return delete s.tagName, K(e, s);
|
91
|
-
},
|
93
|
+
}, Tt = (o, t) => {
|
92
94
|
if (!o || !t) return;
|
93
95
|
if (B(t))
|
94
96
|
return V().createElementNS(o, t);
|
95
|
-
const { tagName: e } = t, s =
|
97
|
+
const { tagName: e } = t, s = Tt(o, e);
|
96
98
|
if (!s) return;
|
97
99
|
const r = { ...t };
|
98
100
|
return delete r.tagName, K(s, r);
|
99
|
-
},
|
101
|
+
}, Qe = (o, t) => o.dispatchEvent(t), Mt = (o, t) => {
|
100
102
|
const e = getComputedStyle(o), s = t.replace("webkit", "Webkit").replace(/([A-Z])/g, "-$1").toLowerCase();
|
101
103
|
return e.getPropertyValue(s);
|
102
|
-
},
|
103
|
-
const t =
|
104
|
+
}, to = (o) => {
|
105
|
+
const t = Mt(o, We), e = Mt(o, Ue), s = e.includes("ms") ? (
|
104
106
|
/* istanbul ignore next */
|
105
107
|
1
|
106
108
|
) : 1e3, r = t && t !== "none" ? parseFloat(e) * s : (
|
@@ -111,17 +113,17 @@ const yt = (o, t) => o.getAttribute(t), m = (o, t, e) => o.setAttribute(t, e), P
|
|
111
113
|
/* istanbul ignore next */
|
112
114
|
0
|
113
115
|
) : r;
|
114
|
-
},
|
116
|
+
}, W = (o, t) => o.focus(t), Zt = (o) => ["true", !0].includes(o) ? !0 : ["false", !1].includes(o) ? !1 : ["null", "", null, void 0].includes(o) ? null : o !== "" && !Number.isNaN(+o) ? +o : o, pt = (o) => Object.entries(o), eo = (o, t, e, s) => {
|
115
117
|
const r = { ...e }, n = { ...o.dataset }, i = { ...t }, a = {}, l = "title";
|
116
118
|
return pt(n).forEach(([c, h]) => {
|
117
119
|
const b = c;
|
118
|
-
a[b] =
|
120
|
+
a[b] = Zt(h);
|
119
121
|
}), pt(r).forEach(([c, h]) => {
|
120
|
-
r[c] =
|
122
|
+
r[c] = Zt(h);
|
121
123
|
}), pt(t).forEach(([c, h]) => {
|
122
|
-
c in r ? i[c] = r[c] : c in a ? i[c] = a[c] : i[c] = c === l ?
|
124
|
+
c in r ? i[c] = r[c] : c in a ? i[c] = a[c] : i[c] = c === l ? kt(o, l) : h;
|
123
125
|
}), i;
|
124
|
-
},
|
126
|
+
}, Qt = (o) => Object.fromEntries(o), oo = (o) => o.offsetHeight, D = (o, t) => {
|
125
127
|
pt(t).forEach(([e, s]) => {
|
126
128
|
if (s && B(e) && e.includes("--"))
|
127
129
|
o.style.setProperty(e, s);
|
@@ -130,7 +132,7 @@ const yt = (o, t) => o.getAttribute(t), m = (o, t, e) => o.setAttribute(t, e), P
|
|
130
132
|
r[e] = s, K(o.style, r);
|
131
133
|
}
|
132
134
|
});
|
133
|
-
},
|
135
|
+
}, so = (o) => qt(o) && o.constructor.name === "Map" || !1, de = (o) => o.toUpperCase(), gt = (o, t) => {
|
134
136
|
const { width: e, height: s, top: r, right: n, bottom: i, left: a } = o.getBoundingClientRect();
|
135
137
|
let l = 1, c = 1;
|
136
138
|
if (t && at(o)) {
|
@@ -153,28 +155,28 @@ const yt = (o, t) => o.getAttribute(t), m = (o, t, e) => o.setAttribute(t, e), P
|
|
153
155
|
x: a / l,
|
154
156
|
y: r / c
|
155
157
|
};
|
156
|
-
},
|
157
|
-
let
|
158
|
-
const J = /* @__PURE__ */ new Map(),
|
159
|
-
let e = t ?
|
158
|
+
}, St = (o) => V(o).documentElement;
|
159
|
+
let te = 0, ee = 0;
|
160
|
+
const J = /* @__PURE__ */ new Map(), fe = (o, t) => {
|
161
|
+
let e = t ? te : ee;
|
160
162
|
if (t) {
|
161
|
-
const s =
|
162
|
-
J.has(s) || J.set(s, r),
|
163
|
+
const s = fe(o), r = J.get(s) || /* @__PURE__ */ new Map();
|
164
|
+
J.has(s) || J.set(s, r), so(r) && !r.has(t) ? (r.set(t, e), te += 1) : e = r.get(t);
|
163
165
|
} else {
|
164
166
|
const s = o.id || o;
|
165
|
-
J.has(s) ? e = J.get(s) : (J.set(s, e),
|
167
|
+
J.has(s) ? e = J.get(s) : (J.set(s, e), ee += 1);
|
166
168
|
}
|
167
169
|
return e;
|
168
|
-
},
|
170
|
+
}, ro = (o) => {
|
169
171
|
var t;
|
170
|
-
return o ?
|
171
|
-
},
|
172
|
-
|
172
|
+
return o ? pe(o) ? o.defaultView : Z(o) ? (t = o?.ownerDocument) == null ? void 0 : t.defaultView : o : window;
|
173
|
+
}, Ct = (o) => Array.isArray(o) || !1, me = (o, t) => o ? o.closest(t) || // break out of `ShadowRoot`
|
174
|
+
me(o.getRootNode().host, t) : null, _ = (o, t) => at(o) ? o : (Z(t) ? t : V()).querySelector(o), st = (o, t) => (t && Z(t) ? t : V()).getElementsByClassName(
|
173
175
|
o
|
174
|
-
), Gt = ["transparent", "currentColor", "inherit", "revert", "initial"],
|
176
|
+
), Gt = ["transparent", "currentColor", "inherit", "revert", "initial"], m = (o) => {
|
175
177
|
const t = Math.floor(o);
|
176
178
|
return o - t < 0.5 ? t : Math.round(o);
|
177
|
-
},
|
179
|
+
}, $t = [
|
178
180
|
[
|
179
181
|
"aliceblue",
|
180
182
|
{
|
@@ -1359,11 +1361,11 @@ fe(o.getRootNode().host, t) : null, z = (o, t) => at(o) ? o : (Z(t) ? t : V()).q
|
|
1359
1361
|
b: 50
|
1360
1362
|
}
|
1361
1363
|
]
|
1362
|
-
],
|
1364
|
+
], ve = "deg|rad|grad|turn", $e = "[-\\+]?\\d+%?", we = "[-\\+]?\\d*\\.\\d+%?", ke = `[-\\+]?\\d*\\.?\\d+(?:${ve})?`, dt = `(?:${we})|(?:${$e})`, Rt = `(?:${dt})|(?:${ke}?)`, no = "(?:[\\s|\\(\\s|\\s\\(\\s]+)?", io = "(?:[\\s|\\)\\s]+)?", oe = "(?:[,|\\s]+)", ao = "(?:[,|\\/\\s]*)?", rt = `${no}(${Rt})${oe}(${dt})${oe}(${dt})${ao}(${dt})?${io}`, I = {
|
1363
1365
|
CSS_UNIT: new RegExp(Rt),
|
1364
|
-
ANGLES:
|
1365
|
-
CSS_ANGLE:
|
1366
|
-
CSS_INTEGER:
|
1366
|
+
ANGLES: ve,
|
1367
|
+
CSS_ANGLE: ke,
|
1368
|
+
CSS_INTEGER: $e,
|
1367
1369
|
CSS_NUMBER: we,
|
1368
1370
|
CSS_UNIT2: Rt,
|
1369
1371
|
PERMISSIVE_MATCH: rt,
|
@@ -1375,21 +1377,16 @@ fe(o.getRootNode().host, t) : null, z = (o, t) => at(o) ? o : (Z(t) ? t : V()).q
|
|
1375
1377
|
hex6: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,
|
1376
1378
|
hex4: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
|
1377
1379
|
hex8: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/
|
1378
|
-
},
|
1380
|
+
}, ye = (o) => Gt.includes(o), nt = (o, t) => o !== null && typeof o == "object" && Object.keys(t).every((e) => e in o), xe = (o) => `${o}`.includes(".") && parseFloat(o) === 1, Ut = (o) => typeof o == "string" && o.includes("%"), H = (o) => !!I.CSS_UNIT.exec(`${o}`), Pe = ["rgb", "hex", "hsl", "hsv", "hwb"], Se = (o) => Gt.includes(o) || ["#", ...Pe].some((t) => o.includes(t)) ? !1 : $t.some(([t]) => o === t), se = 1e-6, lo = (o, t) => Math.abs(o * t - t) < se ? 1 : o < se ? 0 : o, E = (o, t) => {
|
1379
1381
|
let e = o;
|
1380
|
-
|
1381
|
-
Math.max(o, 1) === 1)
|
1382
|
-
return o;
|
1383
|
-
ye(o) && (e = "100%");
|
1384
|
-
const s = $t(e);
|
1385
|
-
return e = t === 360 ? parseFloat(e) : Math.min(t, Math.max(0, parseFloat(e))), s && (e = e * t / 100), Math.abs(e - t) < 1e-6 ? 1 : (t === 360 ? e = (e < 0 ? e % t + t : e % t) / t : e = e % t / t, e);
|
1382
|
+
return xe(o) && (e = "100%"), Ut(e) ? Number.parseFloat(e) / 100 : (e = typeof e != "number" ? Number.parseFloat(e) : e, t === 360 ? e = (e < 0 ? e % t + t : e > 360 ? e % t : e) / t : (e = Math.min(t, Math.max(0, e)), e = e / t), lo(e, t));
|
1386
1383
|
}, Ot = (o) => {
|
1387
1384
|
let t = parseFloat(o);
|
1388
1385
|
return (Number.isNaN(t) || t < 0 || t > 1) && (t = 1), t;
|
1389
|
-
}, ut = (o) => Math.min(1, Math.max(0, o)), G = (o) => o.length === 1 ? `0${o}` : String(o),
|
1390
|
-
const [[, t]] =
|
1386
|
+
}, ut = (o) => Math.min(1, Math.max(0, o)), G = (o) => o.length === 1 ? `0${o}` : String(o), Ce = (o) => {
|
1387
|
+
const [[, t]] = $t.filter(([e]) => e === o.toLowerCase());
|
1391
1388
|
return t;
|
1392
|
-
}, N = (o) => parseInt(o, 16), Dt = (o) => N(o) / 255,
|
1389
|
+
}, N = (o) => parseInt(o, 16), Dt = (o) => N(o) / 255, Le = (o) => m(o * 255).toString(16), re = (o, t, e) => {
|
1393
1390
|
const s = Math.max(o, t, e), r = Math.min(o, t, e);
|
1394
1391
|
let n = 0, i = 0;
|
1395
1392
|
const a = (s + r) / 2;
|
@@ -1407,12 +1404,12 @@ fe(o.getRootNode().host, t) : null, z = (o, t) => at(o) ? o : (Z(t) ? t : V()).q
|
|
1407
1404
|
let s = 0, r = 0, n = 0;
|
1408
1405
|
if (t === 0)
|
1409
1406
|
r = e, n = e, s = e;
|
1410
|
-
else
|
1407
|
+
else {
|
1411
1408
|
const i = e < 0.5 ? e * (1 + t) : e + t - e * t, a = 2 * e - i;
|
1412
1409
|
s = ft(a, i, o + 1 / 3), r = ft(a, i, o), n = ft(a, i, o - 1 / 3);
|
1413
1410
|
}
|
1414
1411
|
return { r: s, g: r, b: n };
|
1415
|
-
},
|
1412
|
+
}, ne = (o, t, e) => {
|
1416
1413
|
let s = 0, r = 0;
|
1417
1414
|
const n = Math.min(o, t, e), i = Math.max(o, t, e), a = 1 - i;
|
1418
1415
|
if (i === n) return { h: 0, w: n, b: a };
|
@@ -1423,14 +1420,14 @@ fe(o.getRootNode().host, t) : null, z = (o, t) => at(o) ? o : (Z(t) ? t : V()).q
|
|
1423
1420
|
w: n,
|
1424
1421
|
b: a
|
1425
1422
|
};
|
1426
|
-
},
|
1423
|
+
}, Ae = (o, t, e) => {
|
1427
1424
|
if (t + e >= 1) {
|
1428
1425
|
const i = t / (t + e);
|
1429
1426
|
return { r: i, g: i, b: i };
|
1430
1427
|
}
|
1431
1428
|
let { r: s, g: r, b: n } = lt(o, 1, 0.5);
|
1432
1429
|
return [s, r, n] = [s, r, n].map((i) => i * (1 - t - e) + t), { r: s, g: r, b: n };
|
1433
|
-
},
|
1430
|
+
}, ie = (o, t, e) => {
|
1434
1431
|
const s = Math.max(o, t, e), r = Math.min(o, t, e);
|
1435
1432
|
let n = 0;
|
1436
1433
|
const i = s, a = s - r, l = s === 0 ? 0 : a / s;
|
@@ -1438,30 +1435,30 @@ fe(o.getRootNode().host, t) : null, z = (o, t) => at(o) ? o : (Z(t) ? t : V()).q
|
|
1438
1435
|
}, Ft = (o, t, e) => {
|
1439
1436
|
const s = o * 6, r = t, n = e, i = Math.floor(s), a = s - i, l = n * (1 - r), c = n * (1 - a * r), h = n * (1 - (1 - a) * r), b = i % 6, u = [n, c, l, l, h, n][b], d = [h, n, n, c, l, l][b], g = [l, l, h, n, n, c][b];
|
1440
1437
|
return { r: u, g: d, b: g };
|
1441
|
-
},
|
1438
|
+
}, Lt = (o, t, e, s) => {
|
1442
1439
|
const r = [
|
1443
|
-
G(
|
1444
|
-
G(
|
1445
|
-
G(
|
1440
|
+
G(m(o).toString(16)),
|
1441
|
+
G(m(t).toString(16)),
|
1442
|
+
G(m(e).toString(16))
|
1446
1443
|
];
|
1447
1444
|
return s && r[0].charAt(0) === r[0].charAt(1) && r[1].charAt(0) === r[1].charAt(1) && r[2].charAt(0) === r[2].charAt(1) ? r[0].charAt(0) + r[1].charAt(0) + r[2].charAt(0) : r.join("");
|
1448
1445
|
}, At = (o, t, e, s, r) => {
|
1449
1446
|
const n = [
|
1450
|
-
G(
|
1451
|
-
G(
|
1452
|
-
G(
|
1453
|
-
G(
|
1447
|
+
G(m(o).toString(16)),
|
1448
|
+
G(m(t).toString(16)),
|
1449
|
+
G(m(e).toString(16)),
|
1450
|
+
G(Le(s))
|
1454
1451
|
];
|
1455
1452
|
return r && n[0].charAt(0) === n[0].charAt(1) && n[1].charAt(0) === n[1].charAt(1) && n[2].charAt(0) === n[2].charAt(1) && n[3].charAt(0) === n[3].charAt(1) ? n[0].charAt(0) + n[1].charAt(0) + n[2].charAt(0) + n[3].charAt(0) : n.join("");
|
1456
|
-
},
|
1453
|
+
}, He = (o) => {
|
1457
1454
|
const t = String(o).trim().toLowerCase();
|
1458
1455
|
if (Se(t))
|
1459
|
-
return Object.assign(
|
1456
|
+
return Object.assign(Ce(t), {
|
1460
1457
|
a: 1,
|
1461
1458
|
format: "rgb",
|
1462
1459
|
ok: !0
|
1463
1460
|
});
|
1464
|
-
if (
|
1461
|
+
if (ye(t))
|
1465
1462
|
return {
|
1466
1463
|
r: 0,
|
1467
1464
|
g: 0,
|
@@ -1535,49 +1532,56 @@ fe(o.getRootNode().host, t) : null, z = (o, t) => at(o) ? o : (Z(t) ? t : V()).q
|
|
1535
1532
|
format: "rgb",
|
1536
1533
|
ok: !o
|
1537
1534
|
})))))));
|
1538
|
-
},
|
1535
|
+
}, co = (o, t, e) => ({
|
1536
|
+
r: E(o, 255),
|
1537
|
+
g: E(t, 255),
|
1538
|
+
b: E(e, 255)
|
1539
|
+
}), ae = (o) => {
|
1539
1540
|
let t = { r: 0, g: 0, b: 0 }, e = o, s = 1, r, n, i, a, l, c, h, b, u = "rgb", d = !1;
|
1540
|
-
|
1541
|
-
|
1542
|
-
|
1543
|
-
b: t
|
1541
|
+
if ((!e || typeof e == "string") && (e = He(e), d = e.ok || d), nt(e, t) && H(e.r) && H(e.g) && H(e.b)) {
|
1542
|
+
if (["format", "ok", "originalInput"].every((g) => g in e))
|
1543
|
+
return { ...e };
|
1544
|
+
({ r: h, g: b, b: l } = e), t = co(h, b, l), u = "format" in e ? e.format : "rgb";
|
1545
|
+
}
|
1546
|
+
return nt(e, { h: 0, s: 0, v: 0 }) && H(e.h) && H(e.s) && H(e.v) && ({ h: c, s: r, v: n } = e, c = E(c, 360), r = E(r, 100), n = E(n, 100), t = Ft(c, r, n), u = "hsv"), nt(e, { h: 0, s: 0, l: 0 }) && H(e.h) && H(e.s) && H(e.l) && ({ h: c, s: r, l: i } = e, c = E(c, 360), r = E(r, 100), i = E(i, 100), t = lt(c, r, i), u = "hsl"), nt(e, { h: 0, w: 0, b: 0 }) && H(e.h) && H(e.w) && H(e.b) && ({ h: c, w: a, b: l } = e, c = E(c, 360), a = E(a, 100), l = E(l, 100), t = Ae(c, a, l), u = "hwb"), H(e.a) && (s = e.a, s = Ut(s) || parseFloat(`${s}`) > 1 ? E(s, 100) : s), {
|
1547
|
+
...t,
|
1544
1548
|
a: Ot(s),
|
1545
1549
|
format: u,
|
1546
1550
|
ok: d
|
1547
1551
|
};
|
1548
|
-
},
|
1552
|
+
}, ho = "1.0.11";
|
1549
1553
|
class y {
|
1550
1554
|
// bring main utilities to front
|
1551
1555
|
static matchers = I;
|
1552
|
-
static isOnePointZero =
|
1553
|
-
static isPercentage =
|
1556
|
+
static isOnePointZero = xe;
|
1557
|
+
static isPercentage = Ut;
|
1554
1558
|
static isValidCSSUnit = H;
|
1555
|
-
static isNonColor =
|
1559
|
+
static isNonColor = ye;
|
1556
1560
|
static isColorName = Se;
|
1557
1561
|
static isColorType = nt;
|
1558
1562
|
static pad2 = G;
|
1559
1563
|
static clamp01 = ut;
|
1560
|
-
static bound01 =
|
1564
|
+
static bound01 = E;
|
1561
1565
|
static boundAlpha = Ot;
|
1562
|
-
static getRGBFromName =
|
1566
|
+
static getRGBFromName = Ce;
|
1563
1567
|
static convertHexToDecimal = Dt;
|
1564
|
-
static convertDecimalToHex =
|
1565
|
-
static rgbToHsl =
|
1566
|
-
static rgbToHex =
|
1567
|
-
static rgbToHsv =
|
1568
|
-
static rgbToHwb =
|
1568
|
+
static convertDecimalToHex = Le;
|
1569
|
+
static rgbToHsl = re;
|
1570
|
+
static rgbToHex = Lt;
|
1571
|
+
static rgbToHsv = ie;
|
1572
|
+
static rgbToHwb = ne;
|
1569
1573
|
static rgbaToHex = At;
|
1570
1574
|
static hslToRgb = Ft;
|
1571
1575
|
static hsvToRgb = Ft;
|
1572
1576
|
static hueToRgb = ft;
|
1573
|
-
static hwbToRgb =
|
1577
|
+
static hwbToRgb = Ae;
|
1574
1578
|
static parseIntFromHex = N;
|
1575
|
-
static stringInputToObject =
|
1576
|
-
static inputToRGB =
|
1577
|
-
static roundPart =
|
1578
|
-
static webColors =
|
1579
|
+
static stringInputToObject = He;
|
1580
|
+
static inputToRGB = ae;
|
1581
|
+
static roundPart = m;
|
1582
|
+
static webColors = $t;
|
1579
1583
|
static nonColors = Gt;
|
1580
|
-
static version =
|
1584
|
+
static version = ho;
|
1581
1585
|
// main public properties
|
1582
1586
|
r;
|
1583
1587
|
g;
|
@@ -1588,7 +1592,7 @@ class y {
|
|
1588
1592
|
originalInput;
|
1589
1593
|
// main public methods
|
1590
1594
|
constructor(t, e) {
|
1591
|
-
const s = e &&
|
1595
|
+
const s = e && Pe.includes(e) ? e : "", { r, g: n, b: i, a, ok: l, format: c } = ae(t);
|
1592
1596
|
this.originalInput = t, this.r = r, this.g = n, this.b = i, this.a = a, this.ok = l, this.format = s || c;
|
1593
1597
|
}
|
1594
1598
|
/**
|
@@ -1624,7 +1628,7 @@ class y {
|
|
1624
1628
|
* Returns the web colour name closest to the current colour.
|
1625
1629
|
*/
|
1626
1630
|
get name() {
|
1627
|
-
const { r: t, g: e, b: s } = this.toRgb(), [r] =
|
1631
|
+
const { r: t, g: e, b: s } = this.toRgb(), [r] = $t.map(([n, i]) => {
|
1628
1632
|
const a = (
|
1629
1633
|
// ((rgb.r - r) ** 2 + (rgb.g - g) ** 2 + (rgb.b - b) ** 2) ** 0.5; // standard
|
1630
1634
|
(((i.r - t) * 0.3) ** 2 + ((i.g - e) * 0.6) ** 2 + ((i.b - s) * 0.1) ** 2) ** 0.5
|
@@ -1638,7 +1642,7 @@ class y {
|
|
1638
1642
|
*/
|
1639
1643
|
toRgb() {
|
1640
1644
|
let { r: t, g: e, b: s, a: r } = this;
|
1641
|
-
return [t, e, s] = [t, e, s].map((n) =>
|
1645
|
+
return [t, e, s] = [t, e, s].map((n) => m(n * 255 * 100) / 100), r = m(r * 100) / 100, {
|
1642
1646
|
r: t,
|
1643
1647
|
g: e,
|
1644
1648
|
b: s,
|
@@ -1651,7 +1655,7 @@ class y {
|
|
1651
1655
|
* * rgba(255,255,255,0.5)
|
1652
1656
|
*/
|
1653
1657
|
toRgbString() {
|
1654
|
-
const { r: t, g: e, b: s, a: r } = this.toRgb(), [n, i, a] = [t, e, s].map(
|
1658
|
+
const { r: t, g: e, b: s, a: r } = this.toRgb(), [n, i, a] = [t, e, s].map(m);
|
1655
1659
|
return r === 1 ? `rgb(${n}, ${i}, ${a})` : `rgba(${n}, ${i}, ${a}, ${r})`;
|
1656
1660
|
}
|
1657
1661
|
/**
|
@@ -1660,7 +1664,7 @@ class y {
|
|
1660
1664
|
* * rgb(255 255 255 / 50%)
|
1661
1665
|
*/
|
1662
1666
|
toRgbCSS4String() {
|
1663
|
-
const { r: t, g: e, b: s, a: r } = this.toRgb(), [n, i, a] = [t, e, s].map(
|
1667
|
+
const { r: t, g: e, b: s, a: r } = this.toRgb(), [n, i, a] = [t, e, s].map(m), l = r === 1 ? "" : ` / ${m(r * 100)}%`;
|
1664
1668
|
return `rgb(${n} ${i} ${a}${l})`;
|
1665
1669
|
}
|
1666
1670
|
/**
|
@@ -1668,8 +1672,8 @@ class y {
|
|
1668
1672
|
* it will find a 3 characters shorthand of the decimal value.
|
1669
1673
|
*/
|
1670
1674
|
toHex(t) {
|
1671
|
-
|
1672
|
-
return n === 1 ?
|
1675
|
+
let { r: e, g: s, b: r, a: n } = this;
|
1676
|
+
return [e, s, r] = [e, s, r].map((i) => m(i * 255)), n = m(n * 100) / 100, n === 1 ? Lt(e, s, r, t) : At(e, s, r, n, t);
|
1673
1677
|
}
|
1674
1678
|
/**
|
1675
1679
|
* Returns the CSS valid hexadecimal vaue of the colour. When the parameter is *true*
|
@@ -1682,8 +1686,8 @@ class y {
|
|
1682
1686
|
* Returns the HEX8 value of the colour.
|
1683
1687
|
*/
|
1684
1688
|
toHex8(t) {
|
1685
|
-
|
1686
|
-
return At(e, s, r, n, t);
|
1689
|
+
let { r: e, g: s, b: r, a: n } = this;
|
1690
|
+
return [e, s, r] = [e, s, r].map((i) => m(i * 255)), n = m(n * 100) / 100, n === 1 ? Lt(e, s, r, t) : At(e, s, r, n, t);
|
1687
1691
|
}
|
1688
1692
|
/**
|
1689
1693
|
* Returns the HEX8 value of the colour.
|
@@ -1695,7 +1699,7 @@ class y {
|
|
1695
1699
|
* Returns the colour as a HSVA object.
|
1696
1700
|
*/
|
1697
1701
|
toHsv() {
|
1698
|
-
const { r: t, g: e, b: s, a: r } = this, { h: n, s: i, v: a } =
|
1702
|
+
const { r: t, g: e, b: s, a: r } = this, { h: n, s: i, v: a } = ie(t, e, s);
|
1699
1703
|
return {
|
1700
1704
|
h: n,
|
1701
1705
|
s: i,
|
@@ -1707,7 +1711,7 @@ class y {
|
|
1707
1711
|
* Returns the colour as an HSLA object.
|
1708
1712
|
*/
|
1709
1713
|
toHsl() {
|
1710
|
-
const { r: t, g: e, b: s, a: r } = this, { h: n, s: i, l: a } =
|
1714
|
+
const { r: t, g: e, b: s, a: r } = this, { h: n, s: i, l: a } = re(t, e, s);
|
1711
1715
|
return {
|
1712
1716
|
h: n,
|
1713
1717
|
s: i,
|
@@ -1722,7 +1726,7 @@ class y {
|
|
1722
1726
|
*/
|
1723
1727
|
toHslString() {
|
1724
1728
|
let { h: t, s: e, l: s, a: r } = this.toHsl();
|
1725
|
-
return t =
|
1729
|
+
return t = m(t * 360), e = m(e * 100), s = m(s * 100), r = m(r * 100) / 100, r === 1 ? `hsl(${t}, ${e}%, ${s}%)` : `hsla(${t}, ${e}%, ${s}%, ${r})`;
|
1726
1730
|
}
|
1727
1731
|
/**
|
1728
1732
|
* Returns the HSLA values concatenated into a CSS4 Module format string.
|
@@ -1731,15 +1735,15 @@ class y {
|
|
1731
1735
|
*/
|
1732
1736
|
toHslCSS4String() {
|
1733
1737
|
let { h: t, s: e, l: s, a: r } = this.toHsl();
|
1734
|
-
t =
|
1735
|
-
const n = r < 100 ? ` / ${
|
1738
|
+
t = m(t * 360), e = m(e * 100), s = m(s * 100), r = m(r * 100);
|
1739
|
+
const n = r < 100 ? ` / ${m(r)}%` : "";
|
1736
1740
|
return `hsl(${t}deg ${e}% ${s}%${n})`;
|
1737
1741
|
}
|
1738
1742
|
/**
|
1739
1743
|
* Returns the colour as an HWBA object.
|
1740
1744
|
*/
|
1741
1745
|
toHwb() {
|
1742
|
-
const { r: t, g: e, b: s, a: r } = this, { h: n, w: i, b: a } =
|
1746
|
+
const { r: t, g: e, b: s, a: r } = this, { h: n, w: i, b: a } = ne(t, e, s);
|
1743
1747
|
return {
|
1744
1748
|
h: n,
|
1745
1749
|
w: i,
|
@@ -1752,8 +1756,8 @@ class y {
|
|
1752
1756
|
*/
|
1753
1757
|
toHwbString() {
|
1754
1758
|
let { h: t, w: e, b: s, a: r } = this.toHwb();
|
1755
|
-
t =
|
1756
|
-
const n = r < 100 ? ` / ${
|
1759
|
+
t = m(t * 360), e = m(e * 100), s = m(s * 100), r = m(r * 100);
|
1760
|
+
const n = r < 100 ? ` / ${m(r)}%` : "";
|
1757
1761
|
return `hwb(${t}deg ${e}% ${s}%${n})`;
|
1758
1762
|
}
|
1759
1763
|
/**
|
@@ -1853,10 +1857,10 @@ class It {
|
|
1853
1857
|
for (let g = 1; g < r - c; g += 1)
|
1854
1858
|
n = [0.5 - d * g, ...n];
|
1855
1859
|
for (let g = 0; g < s; g += 1) {
|
1856
|
-
const p = (e + g * l) % 360
|
1860
|
+
const p = (e + g * l) % 360;
|
1857
1861
|
n.forEach((f) => {
|
1858
|
-
const
|
1859
|
-
a.push(i < 100 ?
|
1862
|
+
const $ = new y({ h: p, s: 100, l: f * 100 });
|
1863
|
+
a.push(i < 100 ? $.saturate(i - 100) : $);
|
1860
1864
|
});
|
1861
1865
|
}
|
1862
1866
|
this.hue = e, this.hueSteps = s, this.lightSteps = r, this.saturation = i, this.colors = a;
|
@@ -1898,7 +1902,7 @@ const Kt = {
|
|
1898
1902
|
"violet",
|
1899
1903
|
"magenta",
|
1900
1904
|
"pink"
|
1901
|
-
],
|
1905
|
+
], le = (o) => {
|
1902
1906
|
if (!B(o)) return !1;
|
1903
1907
|
try {
|
1904
1908
|
JSON.parse(o);
|
@@ -1906,15 +1910,15 @@ const Kt = {
|
|
1906
1910
|
return !1;
|
1907
1911
|
}
|
1908
1912
|
return !0;
|
1909
|
-
}, Vt = "v-hidden",
|
1913
|
+
}, Vt = "v-hidden", go = (o) => {
|
1910
1914
|
const { format: t, id: e, componentLabels: s } = o, r = x({
|
1911
1915
|
tagName: "div",
|
1912
1916
|
className: `color-form ${t}`
|
1913
1917
|
});
|
1914
1918
|
let n = ["hex"];
|
1915
1919
|
return t === "rgb" ? n = ["red", "green", "blue", "alpha"] : t === "hsl" ? n = ["hue", "saturation", "lightness", "alpha"] : t === "hwb" && (n = ["hue", "whiteness", "blackness", "alpha"]), n.forEach((i) => {
|
1916
|
-
const [a] = t === "hex" ? ["#"] :
|
1917
|
-
|
1920
|
+
const [a] = t === "hex" ? ["#"] : de(i).split(""), l = `color_${t}_${i}_${e}`, c = s[`${i}Label`], h = x({ tagName: "label" });
|
1921
|
+
v(h, "for", l), h.append(
|
1918
1922
|
x({
|
1919
1923
|
tagName: "span",
|
1920
1924
|
ariaHidden: "true",
|
@@ -1943,7 +1947,7 @@ const Kt = {
|
|
1943
1947
|
step: d
|
1944
1948
|
}), r.append(h, b);
|
1945
1949
|
}), r;
|
1946
|
-
},
|
1950
|
+
}, uo = (o) => {
|
1947
1951
|
const { format: t, componentLabels: e } = o, { hueLabel: s, alphaLabel: r, lightnessLabel: n, saturationLabel: i, whitenessLabel: a, blacknessLabel: l } = e, c = t === "hsl" ? 360 : 100, h = t === "hsl" ? 100 : 360, b = 100;
|
1948
1952
|
let u = t === "hsl" ? `${s} & ${n}` : `${n} & ${i}`;
|
1949
1953
|
u = t === "hwb" ? `${a} & ${l}` : u;
|
@@ -1973,48 +1977,48 @@ const Kt = {
|
|
1973
1977
|
min: 0,
|
1974
1978
|
max: b
|
1975
1979
|
}
|
1976
|
-
].forEach((
|
1977
|
-
const { i:
|
1980
|
+
].forEach((w) => {
|
1981
|
+
const { i: P, c: L, l: S, min: C, max: M } = w, T = x({
|
1978
1982
|
tagName: "div",
|
1979
1983
|
className: "color-control",
|
1980
1984
|
role: "presentation"
|
1981
1985
|
});
|
1982
|
-
|
1986
|
+
T.append(
|
1983
1987
|
x({
|
1984
1988
|
tagName: "div",
|
1985
|
-
className: `visual-control visual-control${
|
1989
|
+
className: `visual-control visual-control${P}`
|
1986
1990
|
})
|
1987
1991
|
);
|
1988
1992
|
const A = x({
|
1989
1993
|
tagName: "div",
|
1990
1994
|
className: `${L} knob`,
|
1991
1995
|
ariaLive: "polite",
|
1992
|
-
ariaLabel:
|
1996
|
+
ariaLabel: S,
|
1993
1997
|
role: "slider",
|
1994
1998
|
tabIndex: 0,
|
1995
1999
|
ariaValueMin: `${C}`,
|
1996
2000
|
ariaValueMax: `${M}`
|
1997
2001
|
});
|
1998
|
-
|
2002
|
+
T.append(A), g.append(T);
|
1999
2003
|
}), g;
|
2000
|
-
},
|
2004
|
+
}, ce = (o, t, e) => {
|
2001
2005
|
const { input: s, format: r, componentLabels: n } = o, { defaultsLabel: i, presetsLabel: a } = n, l = e === "color-options", c = t instanceof It, h = l ? a : i, b = c ? t.colors : t, u = b.length, { lightSteps: d } = c ? t : { lightSteps: null }, g = d || [9, 10].find((A) => u >= A * 2 && !(u % A)) || 5, p = l && u > g;
|
2002
2006
|
let f = 2;
|
2003
2007
|
f = p && u > g * 2 ? 3 : f, f = p && u > g * 3 ? 4 : f, f = p && u > g * 4 ? 5 : f;
|
2004
|
-
const
|
2005
|
-
let
|
2006
|
-
|
2008
|
+
const $ = f - (u <= g * 3 ? 1 : 2), w = p && u > $ * g;
|
2009
|
+
let P = e;
|
2010
|
+
P += w ? " scrollable" : "", P += p ? " multiline" : "";
|
2007
2011
|
const L = p ? "1px" : "0.25rem";
|
2008
|
-
let
|
2009
|
-
|
2010
|
-
const C = `${
|
2012
|
+
let S = p ? 1.75 : 2;
|
2013
|
+
S = g > 5 && p ? 1.5 : S;
|
2014
|
+
const C = `${$ * S}rem`, M = `calc(${f} * ${S}rem + ${f - 1} * ${L})`, T = x({
|
2011
2015
|
tagName: "ul",
|
2012
|
-
className:
|
2016
|
+
className: P,
|
2013
2017
|
role: "listbox",
|
2014
2018
|
ariaLabel: h
|
2015
2019
|
});
|
2016
|
-
return
|
2017
|
-
"--grid-item-size": `${
|
2020
|
+
return w && D(T, {
|
2021
|
+
"--grid-item-size": `${S}rem`,
|
2018
2022
|
"--grid-fit": `${g}`,
|
2019
2023
|
"--grid-gap": L,
|
2020
2024
|
"--grid-height": C,
|
@@ -2022,20 +2026,20 @@ const Kt = {
|
|
2022
2026
|
}), b.forEach((A) => {
|
2023
2027
|
let [F, Q] = typeof A == "string" ? A.trim().split(":") : [];
|
2024
2028
|
A instanceof y && (F = A.toHexString(), Q = F);
|
2025
|
-
const
|
2029
|
+
const Wt = new y(A instanceof y ? A : F, r).toString() === kt(s, "value"), yt = x({
|
2026
2030
|
tagName: "li",
|
2027
|
-
className: `color-option${
|
2031
|
+
className: `color-option${Wt ? " active" : ""}`,
|
2028
2032
|
innerText: `${Q || F}`,
|
2029
2033
|
tabIndex: 0,
|
2030
2034
|
role: "option",
|
2031
|
-
ariaSelected:
|
2035
|
+
ariaSelected: Wt ? "true" : "false"
|
2032
2036
|
});
|
2033
|
-
|
2034
|
-
}),
|
2035
|
-
},
|
2036
|
-
const { input: t, parent: e, format: s, id: r, componentLabels: n, colorKeywords: i, colorPresets: a } = o, l =
|
2037
|
+
v(yt, "data-value", `${F}`), l && D(yt, { backgroundColor: F }), T.append(yt);
|
2038
|
+
}), T;
|
2039
|
+
}, bo = (o) => {
|
2040
|
+
const { input: t, parent: e, format: s, id: r, componentLabels: n, colorKeywords: i, colorPresets: a } = o, l = kt(t, "value") || "#fff", { nonColors: c } = y, { toggleLabel: h, pickerLabel: b, formatLabel: u, hexLabel: d } = n, g = c.includes(l) ? "#fff" : l;
|
2037
2041
|
o.color = new y(g, s);
|
2038
|
-
const p = s === "hex" ? d :
|
2042
|
+
const p = s === "hex" ? d : de(s), f = x({
|
2039
2043
|
id: `picker-btn-${r}`,
|
2040
2044
|
tagName: "button",
|
2041
2045
|
type: "button",
|
@@ -2050,75 +2054,75 @@ const Kt = {
|
|
2050
2054
|
innerText: `${b}. ${u}: ${p}`
|
2051
2055
|
})
|
2052
2056
|
);
|
2053
|
-
const
|
2057
|
+
const $ = x({
|
2054
2058
|
tagName: "div",
|
2055
2059
|
className: "color-dropdown picker",
|
2056
2060
|
role: "group",
|
2057
2061
|
ariaLabelledBy: `picker-btn-${r}`
|
2058
|
-
}),
|
2059
|
-
if (
|
2062
|
+
}), w = uo(o), P = go(o);
|
2063
|
+
if ($.append(w, P), t.before(f), e.append($), i || a) {
|
2060
2064
|
const L = x({
|
2061
2065
|
tagName: "div",
|
2062
2066
|
className: "color-dropdown scrollable menu"
|
2063
2067
|
});
|
2064
|
-
a && L.append(
|
2065
|
-
const
|
2068
|
+
a && L.append(ce(o, a, "color-options")), i && i.length && L.append(ce(o, i, "color-defaults"));
|
2069
|
+
const S = x({
|
2066
2070
|
tagName: "button",
|
2067
2071
|
type: "button",
|
2068
2072
|
className: "menu-toggle btn-appearance",
|
2069
2073
|
tabIndex: -1,
|
2070
2074
|
ariaExpanded: "false",
|
2071
2075
|
ariaHasPopup: "true"
|
2072
|
-
}), C = encodeURI("http://www.w3.org/2000/svg"), M =
|
2076
|
+
}), C = encodeURI("http://www.w3.org/2000/svg"), M = Tt(C, {
|
2073
2077
|
tagName: "svg"
|
2074
2078
|
});
|
2075
|
-
|
2076
|
-
const
|
2079
|
+
v(M, "xmlns", C), v(M, "viewBox", "0 0 512 512"), v(M, Te, "true");
|
2080
|
+
const T = Tt(C, {
|
2077
2081
|
tagName: "path"
|
2078
2082
|
});
|
2079
|
-
|
2083
|
+
v(T, "d", "M98,158l157,156L411,158l27,27L255,368L71,185L98,158z"), v(T, "fill", "#fff"), M.append(T), S.append(
|
2080
2084
|
x({
|
2081
2085
|
tagName: "span",
|
2082
2086
|
className: Vt,
|
2083
2087
|
innerText: `${h}`
|
2084
2088
|
}),
|
2085
2089
|
M
|
2086
|
-
), e.append(
|
2090
|
+
), e.append(S, L);
|
2087
2091
|
}
|
2088
|
-
i && c.includes(l) && (o.value = l),
|
2089
|
-
},
|
2092
|
+
i && c.includes(l) && (o.value = l), v(t, X, "-1");
|
2093
|
+
}, po = "2.0.2", Y = "color-picker", fo = `[data-function="${Y}"]`, he = `.${Y}`, mo = {
|
2090
2094
|
componentLabels: Kt,
|
2091
2095
|
colorLabels: it,
|
2092
2096
|
format: "rgb",
|
2093
2097
|
colorPresets: !1,
|
2094
2098
|
colorKeywords: !1
|
2095
|
-
}, { roundPart: k, nonColors: bt } = y,
|
2099
|
+
}, { roundPart: k, nonColors: bt } = y, vo = (o) => Ye(o, Y), $o = (o) => new wo(o), ge = (o, t) => {
|
2096
2100
|
const e = t ? Bt : jt, { input: s, pickerToggle: r, menuToggle: n } = o;
|
2097
|
-
e(s,
|
2098
|
-
},
|
2099
|
-
const e = t ? Bt : jt, { input: s, colorMenu: r, parent: n } = o, i = V(s), a =
|
2100
|
-
e(o.controls,
|
2101
|
-
},
|
2102
|
-
|
2103
|
-
},
|
2101
|
+
e(s, Oe, o.showPicker), e(r, Et, o.togglePicker), n && e(n, Et, o.toggleMenu);
|
2102
|
+
}, Ne = (o, t) => {
|
2103
|
+
const e = t ? Bt : jt, { input: s, colorMenu: r, parent: n } = o, i = V(s), a = ro(i);
|
2104
|
+
e(o.controls, Ie, o.pointerDown), o.controlKnobs.forEach((l) => e(l, zt, o.handleKnobs)), e(a, Be, o.handleScroll), e(a, Ve, o.update), [s, ...o.inputs].forEach((l) => e(l, Me, o.changeHandler)), r && (e(r, Et, o.menuClickHandler), e(r, zt, o.menuKeyHandler)), e(i, be, o.pointerMove), e(i, Ke, o.pointerUp), e(n, De, o.handleFocusOut), e(i, Fe, o.handleDismiss);
|
2105
|
+
}, ue = (o) => {
|
2106
|
+
Qe(o.input, new CustomEvent("colorpicker.change"));
|
2107
|
+
}, Ee = (o) => {
|
2104
2108
|
o && ["bottom", "top"].forEach((t) => O(o, t));
|
2105
2109
|
}, Ht = (o, t) => {
|
2106
2110
|
const { colorPicker: e, colorMenu: s, menuToggle: r, pickerToggle: n, parent: i } = o, a = t === e, l = a ? s : e, c = a ? r : n, h = a ? n : r;
|
2107
|
-
|
2111
|
+
R(i, "open") || q(i, "open"), l && (O(l, "show"), Ee(l)), q(t, "bottom"), oo(t), q(t, "show"), a && o.update(), o.isOpen || (Ne(o, !0), o.updateDropdownPosition(), o.isOpen = !0, v(o.input, X, "0"), r && v(r, X, "0")), v(h, Nt, "true"), c && v(c, Nt, "false");
|
2108
2112
|
};
|
2109
|
-
class
|
2113
|
+
class wo {
|
2110
2114
|
// bring utils to staic
|
2111
2115
|
static Color = y;
|
2112
2116
|
static ColorPalette = It;
|
2113
|
-
static getInstance =
|
2114
|
-
static init =
|
2115
|
-
static selector =
|
2117
|
+
static getInstance = vo;
|
2118
|
+
static init = $o;
|
2119
|
+
static selector = fo;
|
2116
2120
|
// utils important for render
|
2117
2121
|
static roundPart = k;
|
2118
2122
|
static setElementStyle = D;
|
2119
|
-
static setAttribute =
|
2123
|
+
static setAttribute = v;
|
2120
2124
|
static getBoundingClientRect = gt;
|
2121
|
-
static version =
|
2125
|
+
static version = po;
|
2122
2126
|
static colorNames = it;
|
2123
2127
|
static colorPickerLabels = Kt;
|
2124
2128
|
id;
|
@@ -2129,7 +2133,7 @@ class mo {
|
|
2129
2133
|
dragElement;
|
2130
2134
|
isOpen = !1;
|
2131
2135
|
controlPositions;
|
2132
|
-
colorLabels =
|
2136
|
+
colorLabels = Qt(it.map((t) => [t, t]));
|
2133
2137
|
colorKeywords;
|
2134
2138
|
colorPresets;
|
2135
2139
|
componentLabels;
|
@@ -2149,37 +2153,37 @@ class mo {
|
|
2149
2153
|
* @param config instance options
|
2150
2154
|
*/
|
2151
2155
|
constructor(t, e) {
|
2152
|
-
const s =
|
2156
|
+
const s = _(t);
|
2153
2157
|
if (typeof t > "u") throw new TypeError("ColorPicker target not specified.");
|
2154
2158
|
if (B(t) && !s) throw new TypeError(`ColorPicker target "${t}" cannot be found.`);
|
2155
2159
|
this.input = s;
|
2156
|
-
const r =
|
2160
|
+
const r = me(s, he);
|
2157
2161
|
if (!r) throw new TypeError("ColorPicker requires a specific markup to work.");
|
2158
|
-
this.parent = r, this.id =
|
2162
|
+
this.parent = r, this.id = fe(s, Y), this.dragElement = void 0, this.isOpen = !1, this.controlPositions = {
|
2159
2163
|
c1x: 0,
|
2160
2164
|
c1y: 0,
|
2161
2165
|
c2y: 0,
|
2162
2166
|
c3y: 0
|
2163
2167
|
}, this.colorKeywords = !1, this.colorPresets = !1;
|
2164
|
-
const { format: n, componentLabels: i, colorLabels: a, colorKeywords: l, colorPresets: c } =
|
2168
|
+
const { format: n, componentLabels: i, colorLabels: a, colorKeywords: l, colorPresets: c } = eo(
|
2165
2169
|
s,
|
2166
|
-
|
2170
|
+
mo,
|
2167
2171
|
e || {}
|
2168
2172
|
);
|
2169
2173
|
let h = it;
|
2170
|
-
|
2171
|
-
const b = B(i) &&
|
2172
|
-
if (this.componentLabels = K({ ...Kt }, b), this.color = new y(s.value || "#fff", n), this.format = n,
|
2174
|
+
Ct(a) && a.length === 17 ? h = a : B(a) && a.split(",").length === 17 && (h = a.split(",")), K(this.colorLabels, Qt(h.map((p, f) => [it[f], p])));
|
2175
|
+
const b = B(i) && le(i) ? JSON.parse(i) : i;
|
2176
|
+
if (this.componentLabels = K({ ...Kt }, b), this.color = new y(s.value || "#fff", n), this.format = n, Ct(l) && l.length ? this.colorKeywords = l : B(l) && l.length && (this.colorKeywords = l.split(",").map((p) => p.trim())), Ct(c) && c.length)
|
2173
2177
|
this.colorPresets = c;
|
2174
|
-
else if (c &&
|
2175
|
-
const { hue: p, hueSteps: f, lightSteps:
|
2176
|
-
this.colorPresets = new It(p, f, w
|
2178
|
+
else if (c && le(c)) {
|
2179
|
+
const { hue: p, hueSteps: f, lightSteps: $, saturation: w } = JSON.parse(c);
|
2180
|
+
this.colorPresets = new It(p, f, $, w);
|
2177
2181
|
} else B(c) && (this.colorPresets = c.split(",").map((p) => p.trim()));
|
2178
|
-
|
2182
|
+
bo(this);
|
2179
2183
|
const [u, d] = st("color-dropdown", r);
|
2180
|
-
this.pickerToggle =
|
2184
|
+
this.pickerToggle = _(".picker-toggle", r), this.menuToggle = _(".menu-toggle", r), this.colorPicker = u, this.colorMenu = d, this.inputs = [...st("color-input", r)];
|
2181
2185
|
const [g] = st("color-controls", r);
|
2182
|
-
this.controls = g, this.controlKnobs = [...st("knob", g)], this.visuals = [...st("visual-control", g)], this.update(),
|
2186
|
+
this.controls = g, this.controlKnobs = [...st("knob", g)], this.visuals = [...st("visual-control", g)], this.update(), ge(this, !0), ct.set(s, Y, this);
|
2183
2187
|
}
|
2184
2188
|
/** Returns the current colour value */
|
2185
2189
|
get value() {
|
@@ -2257,10 +2261,10 @@ class mo {
|
|
2257
2261
|
}
|
2258
2262
|
/** Updates `ColorPicker` visuals. */
|
2259
2263
|
updateVisuals() {
|
2260
|
-
const { controlPositions: t, visuals: e } = this, [s, r, n] = e, { offsetHeight: i } = s, a = t.c2y / i, { r: l, g: c, b: h } = new y({ h: a, s:
|
2261
|
-
h: a,
|
2262
|
-
s:
|
2263
|
-
l:
|
2264
|
+
const { controlPositions: t, visuals: e } = this, [s, r, n] = e, { offsetHeight: i } = s, a = t.c2y / i, { r: l, g: c, b: h } = new y({ h: a * 360, s: 100, l: 50 }).toRgb(), b = "linear-gradient(rgb(255,255,255) 0%, rgb(255,255,255) 100%)", u = 1 - t.c3y / i, d = k(u * 100) / 100, g = new y({
|
2265
|
+
h: a * 360,
|
2266
|
+
s: 100,
|
2267
|
+
l: 50,
|
2264
2268
|
a: u
|
2265
2269
|
}).toRgbString(), p = `linear-gradient(
|
2266
2270
|
rgb(255,0,0) 0%, rgb(255,255,0) 16.67%,
|
@@ -2291,7 +2295,7 @@ class mo {
|
|
2291
2295
|
* @this {ColorPicker}
|
2292
2296
|
*/
|
2293
2297
|
handleDismiss = ({ code: t }) => {
|
2294
|
-
this.isOpen && t ===
|
2298
|
+
this.isOpen && t === Ge && this.hide();
|
2295
2299
|
};
|
2296
2300
|
/**
|
2297
2301
|
* The `ColorPicker` *scroll* event listener when open.
|
@@ -2300,7 +2304,7 @@ class mo {
|
|
2300
2304
|
*/
|
2301
2305
|
handleScroll = (t) => {
|
2302
2306
|
const { activeElement: e } = V(this.input);
|
2303
|
-
this.updateDropdownPosition(), ([
|
2307
|
+
this.updateDropdownPosition(), ([be, je].includes(t.type) && this.dragElement || e && this.controlKnobs.includes(e)) && (t.stopPropagation(), t.preventDefault());
|
2304
2308
|
};
|
2305
2309
|
/**
|
2306
2310
|
* The `ColorPicker` keyboard event listener for menu navigation.
|
@@ -2308,8 +2312,8 @@ class mo {
|
|
2308
2312
|
* @param e
|
2309
2313
|
*/
|
2310
2314
|
menuKeyHandler = (t) => {
|
2311
|
-
const { target: e, code: s } = t, { previousElementSibling: r, nextElementSibling: n, parentElement: i } = e, a = i &&
|
2312
|
-
[j, ot,
|
2315
|
+
const { target: e, code: s } = t, { previousElementSibling: r, nextElementSibling: n, parentElement: i } = e, a = i && R(i, "color-options"), l = i ? [...i.children] : [], c = a && Number(Mt(i, "--grid-fit")), h = l.indexOf(e), b = h > -1 && c && l[h - c], u = h > -1 && c && l[h + c];
|
2316
|
+
[j, ot, Jt].includes(s) && t.preventDefault(), a ? b && s === ot ? W(b) : u && s === j ? W(u) : r && s === ht ? W(r) : n && s === U && W(n) : r && [ht, ot].includes(s) ? W(r) : n && [U, j].includes(s) && W(n), [qe, Jt].includes(s) && this.menuClickHandler(t);
|
2313
2317
|
};
|
2314
2318
|
/**
|
2315
2319
|
* The `ColorPicker` click event listener for the colour menu presets / defaults.
|
@@ -2318,9 +2322,9 @@ class mo {
|
|
2318
2322
|
* @this {ColorPicker}
|
2319
2323
|
*/
|
2320
2324
|
menuClickHandler = (t) => {
|
2321
|
-
const { target: e } = t, { colorMenu: s } = this, r = (
|
2325
|
+
const { target: e } = t, { colorMenu: s } = this, r = (kt(e, "data-value") || "").trim();
|
2322
2326
|
if (!r.length) return;
|
2323
|
-
const n =
|
2327
|
+
const n = _("li.active", s);
|
2324
2328
|
let i = r;
|
2325
2329
|
i = bt.includes(i) ? "white" : i, i = i === "transparent" ? "rgba(0,0,0,0)" : i;
|
2326
2330
|
const { r: a, g: l, b: c, a: h } = new y(i);
|
@@ -2329,7 +2333,7 @@ class mo {
|
|
2329
2333
|
g: l,
|
2330
2334
|
b: c,
|
2331
2335
|
a: h
|
2332
|
-
}), this.update(), n !== e && (n && (O(n, "active"), Pt(n,
|
2336
|
+
}), this.update(), n !== e && (n && (O(n, "active"), Pt(n, xt)), q(e, "active"), v(e, xt, "true"), bt.includes(r) && (this.value = r), ue(this));
|
2333
2337
|
};
|
2334
2338
|
/**
|
2335
2339
|
* The `ColorPicker` *touchstart* / *mousedown* events listener for control knobs.
|
@@ -2338,10 +2342,10 @@ class mo {
|
|
2338
2342
|
*/
|
2339
2343
|
pointerDown = (t) => {
|
2340
2344
|
if (t.button !== 0) return;
|
2341
|
-
const { target: e, pageX: s, pageY: r } = t, { colorMenu: n, visuals: i, controlKnobs: a } = this, [l, c, h] = i, [b, u, d] = a, g = a.includes(e) ? e.previousElementSibling : e, p = gt(g), f =
|
2342
|
-
if (e === l || e === b ? (this.dragElement = g, this.changeControl1(w
|
2343
|
-
const
|
2344
|
-
|
2345
|
+
const { target: e, pageX: s, pageY: r } = t, { colorMenu: n, visuals: i, controlKnobs: a } = this, [l, c, h] = i, [b, u, d] = a, g = a.includes(e) ? e.previousElementSibling : e, p = gt(g), f = St(l), $ = s - f.scrollLeft - p.left, w = r - f.scrollTop - p.top;
|
2346
|
+
if (e === l || e === b ? (this.dragElement = g, this.changeControl1($, w)) : e === c || e === u ? (this.dragElement = g, this.changeControl2(w)) : (e === h || e === d) && (this.dragElement = g, this.changeAlpha(w)), n) {
|
2347
|
+
const P = _("li.active", n);
|
2348
|
+
P && (O(P, "active"), Pt(P, xt));
|
2345
2349
|
}
|
2346
2350
|
t.preventDefault();
|
2347
2351
|
};
|
@@ -2352,7 +2356,7 @@ class mo {
|
|
2352
2356
|
* @this
|
2353
2357
|
*/
|
2354
2358
|
pointerUp = ({ target: t }) => {
|
2355
|
-
const { parent: e } = this, s = V(e), r =
|
2359
|
+
const { parent: e } = this, s = V(e), r = _(`${he}.open`, s) !== null, n = s.getSelection();
|
2356
2360
|
!this.dragElement && (!n || !n.toString().length) && !e.contains(t) && this.hide(r), this.dragElement = void 0;
|
2357
2361
|
};
|
2358
2362
|
/**
|
@@ -2363,7 +2367,7 @@ class mo {
|
|
2363
2367
|
pointerMove = (t) => {
|
2364
2368
|
const { dragElement: e, visuals: s } = this, [r, n, i] = s, { pageX: a, pageY: l } = t;
|
2365
2369
|
if (!e) return;
|
2366
|
-
const c = gt(e), h =
|
2370
|
+
const c = gt(e), h = St(r), b = a - h.scrollLeft - c.left, u = l - h.scrollTop - c.top;
|
2367
2371
|
e === r && this.changeControl1(b, u), e === n && this.changeControl2(u), e === i && this.changeAlpha(u);
|
2368
2372
|
};
|
2369
2373
|
/**
|
@@ -2388,30 +2392,30 @@ class mo {
|
|
2388
2392
|
/** The event listener of the colour form inputs. */
|
2389
2393
|
changeHandler = () => {
|
2390
2394
|
let t;
|
2391
|
-
const { inputs: e, format: s, value: r, input: n, controlPositions: i, visuals: a } = this, { activeElement: l } = V(n), { offsetHeight: c } = a[0], [h, , , b] = e, [u, d, g, p] = s === "rgb" ? e.map((
|
2395
|
+
const { inputs: e, format: s, value: r, input: n, controlPositions: i, visuals: a } = this, { activeElement: l } = V(n), { offsetHeight: c } = a[0], [h, , , b] = e, [u, d, g, p] = s === "rgb" ? e.map((w) => parseFloat(w.value) / (w === b ? 100 : 1)) : e.map((w) => parseFloat(w.value) / (w !== h ? 100 : 360)), f = this.hasNonColor && bt.includes(r), $ = b ? p : 1 - i.c3y / c;
|
2392
2396
|
if (l === n || l && e.includes(l)) {
|
2393
2397
|
l === n ? f ? t = r === "transparent" ? "rgba(0,0,0,0)" : "rgb(0,0,0)" : t = r : s === "hex" ? t = h.value : s === "hsl" ? t = {
|
2394
2398
|
h: u,
|
2395
2399
|
s: d,
|
2396
2400
|
l: g,
|
2397
|
-
a:
|
2401
|
+
a: $
|
2398
2402
|
} : s === "hwb" ? t = {
|
2399
2403
|
h: u,
|
2400
2404
|
w: d,
|
2401
2405
|
b: g,
|
2402
|
-
a:
|
2406
|
+
a: $
|
2403
2407
|
} : t = {
|
2404
2408
|
r: u,
|
2405
2409
|
g: d,
|
2406
2410
|
b: g,
|
2407
|
-
a:
|
2411
|
+
a: $
|
2408
2412
|
};
|
2409
|
-
const { r:
|
2413
|
+
const { r: w, g: P, b: L, a: S } = new y(t);
|
2410
2414
|
K(this.color, {
|
2411
|
-
r:
|
2412
|
-
g:
|
2415
|
+
r: w,
|
2416
|
+
g: P,
|
2413
2417
|
b: L,
|
2414
|
-
a:
|
2418
|
+
a: S
|
2415
2419
|
}), this.setControlPositions(), this.updateAppearance(), this.updateInputs(), this.updateControls(), this.updateVisuals(), l === n && f && (this.value = r);
|
2416
2420
|
}
|
2417
2421
|
};
|
@@ -2428,9 +2432,9 @@ class mo {
|
|
2428
2432
|
const { controlPositions: n, visuals: i } = this, { offsetHeight: a, offsetWidth: l } = i[0];
|
2429
2433
|
t > l ? s = l : t >= 0 && (s = t), e > a ? r = a : e >= 0 && (r = e);
|
2430
2434
|
const c = n.c2y / a, h = s / l, b = 1 - r / a, u = 1 - n.c3y / a, { r: d, g, b: p, a: f } = new y({
|
2431
|
-
h: c,
|
2432
|
-
s: h,
|
2433
|
-
v: b,
|
2435
|
+
h: c * 360,
|
2436
|
+
s: h * 100,
|
2437
|
+
v: b * 100,
|
2434
2438
|
a: u
|
2435
2439
|
});
|
2436
2440
|
K(this.color, {
|
@@ -2452,9 +2456,9 @@ class mo {
|
|
2452
2456
|
let i = 0;
|
2453
2457
|
t > r ? i = r : t >= 0 && (i = t);
|
2454
2458
|
const a = i / r, l = e.c1x / n, c = 1 - e.c1y / r, h = 1 - e.c3y / r, { r: b, g: u, b: d, a: g } = new y({
|
2455
|
-
h: a,
|
2456
|
-
s: l,
|
2457
|
-
v: c,
|
2459
|
+
h: a * 360,
|
2460
|
+
s: l * 100,
|
2461
|
+
v: c * 100,
|
2458
2462
|
a: h
|
2459
2463
|
});
|
2460
2464
|
K(this.color, {
|
@@ -2487,10 +2491,10 @@ class mo {
|
|
2487
2491
|
};
|
2488
2492
|
/** Updates the open dropdown position on *scroll* event. */
|
2489
2493
|
updateDropdownPosition() {
|
2490
|
-
const { input: t, colorPicker: e, colorMenu: s } = this, r = gt(t), { top: n, bottom: i } = r, { offsetHeight: a } = t, l =
|
2494
|
+
const { input: t, colorPicker: e, colorMenu: s } = this, r = gt(t), { top: n, bottom: i } = r, { offsetHeight: a } = t, l = St(t).clientHeight, h = R(e, "show") ? e : s;
|
2491
2495
|
if (!h) return;
|
2492
2496
|
const { offsetHeight: b } = h, u = l - i, d = n, g = n + b + a > l, p = n - b < 0;
|
2493
|
-
(
|
2497
|
+
(R(h, "bottom") || !p) && u < d && g ? (O(h, "bottom"), q(h, "top")) : (O(h, "top"), q(h, "bottom"));
|
2494
2498
|
}
|
2495
2499
|
/** Updates control knobs' positions. */
|
2496
2500
|
setControlPositions() {
|
@@ -2501,17 +2505,17 @@ class mo {
|
|
2501
2505
|
updateAppearance() {
|
2502
2506
|
const { componentLabels: t, color: e, parent: s, hsv: r, hex: n, format: i, controlKnobs: a } = this, { appearanceLabel: l, hexLabel: c, valueLabel: h } = t;
|
2503
2507
|
let { r: b, g: u, b: d } = e.toRgb();
|
2504
|
-
const [g, p, f] = a,
|
2508
|
+
const [g, p, f] = a, $ = k(r.h * 360), w = e.a, P = k(r.s * 100), L = k(r.v * 100), S = this.appearance;
|
2505
2509
|
let C = `${c} ${n.split("").join(" ")}`;
|
2506
2510
|
if (i === "hwb") {
|
2507
2511
|
const { hwb: A } = this, F = k(A.w * 100), Q = k(A.b * 100);
|
2508
|
-
C = `HWB: ${
|
2512
|
+
C = `HWB: ${$}°, ${F}%, ${Q}%`, v(g, et, `${F}% & ${Q}%`), v(g, tt, `${F}`), v(p, _t, `${h}: ${C}. ${l}: ${S}.`), v(p, et, `${$}%`), v(p, tt, `${$}`);
|
2509
2513
|
} else
|
2510
|
-
[b, u, d] = [b, u, d].map(k), C = i === "hsl" ? `HSL: ${
|
2511
|
-
const M = k(
|
2512
|
-
|
2513
|
-
const
|
2514
|
-
D(this.input, { backgroundColor:
|
2514
|
+
[b, u, d] = [b, u, d].map(k), C = i === "hsl" ? `HSL: ${$}°, ${P}%, ${L}%` : C, C = i === "rgb" ? `RGB: ${b}, ${u}, ${d}` : C, v(g, et, `${L}% & ${P}%`), v(g, tt, `${L}`), v(p, _t, `${h}: ${C}. ${l}: ${S}.`), v(p, et, `${$}°`), v(p, tt, `${$}`);
|
2515
|
+
const M = k(w * 100);
|
2516
|
+
v(f, et, `${M}%`), v(f, tt, `${M}`);
|
2517
|
+
const T = e.toString();
|
2518
|
+
D(this.input, { backgroundColor: T }), this.isDark ? (R(s, "txt-light") && O(s, "txt-light"), R(s, "txt-dark") || q(s, "txt-dark")) : (R(s, "txt-dark") && O(s, "txt-dark"), R(s, "txt-light") || q(s, "txt-light"));
|
2515
2519
|
}
|
2516
2520
|
/** Updates the control knobs actual positions. */
|
2517
2521
|
updateControls() {
|
@@ -2536,13 +2540,13 @@ class mo {
|
|
2536
2540
|
const g = k(i.l * 100), p = k(i.s * 100);
|
2537
2541
|
d = this.color.toHslString(), a.value = `${u}`, l.value = `${p}`, c.value = `${g}`, h.value = `${b}`;
|
2538
2542
|
} else if (s === "hwb") {
|
2539
|
-
const { w: g, b: p } = this.hwb, f = k(g * 100),
|
2540
|
-
d = this.color.toHwbString(), a.value = `${u}`, l.value = `${f}`, c.value = `${
|
2543
|
+
const { w: g, b: p } = this.hwb, f = k(g * 100), $ = k(p * 100);
|
2544
|
+
d = this.color.toHwbString(), a.value = `${u}`, l.value = `${f}`, c.value = `${$}`, h.value = `${b}`;
|
2541
2545
|
} else if (s === "rgb") {
|
2542
2546
|
let { r: g, g: p, b: f } = this.rgb;
|
2543
2547
|
[g, p, f] = [g, p, f].map(k), d = this.color.toRgbString(), a.value = `${g}`, l.value = `${p}`, c.value = `${f}`, h.value = `${b}`;
|
2544
2548
|
}
|
2545
|
-
this.value = d, !t && d !== e &&
|
2549
|
+
this.value = d, !t && d !== e && ue(this);
|
2546
2550
|
}
|
2547
2551
|
/**
|
2548
2552
|
* Toggle the `ColorPicker` dropdown visibility.
|
@@ -2552,12 +2556,12 @@ class mo {
|
|
2552
2556
|
togglePicker = (t) => {
|
2553
2557
|
t && t.preventDefault();
|
2554
2558
|
const { colorPicker: e } = this;
|
2555
|
-
this.isOpen &&
|
2559
|
+
this.isOpen && R(e, "show") ? this.hide(!0) : Ht(this, e);
|
2556
2560
|
};
|
2557
2561
|
/** Shows the `ColorPicker` dropdown. */
|
2558
2562
|
showPicker = () => {
|
2559
2563
|
const { colorPicker: t } = this;
|
2560
|
-
["top", "bottom"].some((e) =>
|
2564
|
+
["top", "bottom"].some((e) => R(t, e)) || Ht(this, t);
|
2561
2565
|
};
|
2562
2566
|
/**
|
2563
2567
|
* Toggles the visibility of the `ColorPicker` presets menu.
|
@@ -2568,7 +2572,7 @@ class mo {
|
|
2568
2572
|
toggleMenu = (t) => {
|
2569
2573
|
t && t.preventDefault();
|
2570
2574
|
const { colorMenu: e } = this;
|
2571
|
-
this.isOpen &&
|
2575
|
+
this.isOpen && R(e, "show") ? this.hide(!0) : Ht(this, e);
|
2572
2576
|
};
|
2573
2577
|
/**
|
2574
2578
|
* Hides the currently open `ColorPicker` dropdown.
|
@@ -2577,21 +2581,21 @@ class mo {
|
|
2577
2581
|
*/
|
2578
2582
|
hide(t) {
|
2579
2583
|
if (this.isOpen) {
|
2580
|
-
const { pickerToggle: e, menuToggle: s, colorPicker: r, colorMenu: n, parent: i, input: a } = this, l =
|
2581
|
-
this.value = this.color.toString(!0), c && (O(c, "show"),
|
2582
|
-
|
2583
|
-
}, b)), t ||
|
2584
|
+
const { pickerToggle: e, menuToggle: s, colorPicker: r, colorMenu: n, parent: i, input: a } = this, l = R(r, "show"), c = l ? r : n, h = l ? e : s, b = c && to(c);
|
2585
|
+
this.value = this.color.toString(!0), c && (O(c, "show"), v(h, Nt, "false"), setTimeout(() => {
|
2586
|
+
Ee(c), _(".show", i) || (O(i, "open"), Ne(this), this.isOpen = !1);
|
2587
|
+
}, b)), t || W(e), v(a, X, "-1"), h === s && v(s, X, "-1");
|
2584
2588
|
}
|
2585
2589
|
}
|
2586
2590
|
/** Removes `ColorPicker` from target `<input>`. */
|
2587
2591
|
dispose() {
|
2588
2592
|
const { input: t, parent: e } = this;
|
2589
|
-
this.hide(!0),
|
2593
|
+
this.hide(!0), ge(this), [...e.children].forEach((s) => {
|
2590
2594
|
s !== t && s.remove();
|
2591
2595
|
}), Pt(t, X), D(t, { backgroundColor: "" }), ["txt-light", "txt-dark"].forEach((s) => O(e, s)), ct.remove(t, Y);
|
2592
2596
|
}
|
2593
2597
|
}
|
2594
2598
|
export {
|
2595
|
-
|
2599
|
+
wo as default
|
2596
2600
|
};
|
2597
2601
|
//# sourceMappingURL=color-picker.mjs.map
|