@thednp/color-picker 2.0.1 → 2.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -14
- package/dist/css/color-picker.css +3 -6
- package/dist/css/color-picker.css.map +1 -0
- package/dist/css/color-picker.min.css +1 -2
- package/dist/css/color-picker.min.css.map +1 -0
- package/dist/css/color-picker.rtl.css +3 -6
- package/dist/css/color-picker.rtl.css.map +1 -0
- package/dist/css/color-picker.rtl.min.css +1 -2
- package/dist/css/color-picker.rtl.min.css.map +1 -0
- package/dist/js/color-picker.cjs +2 -2
- package/dist/js/color-picker.cjs.map +1 -1
- package/dist/js/color-picker.d.ts +307 -300
- package/dist/js/color-picker.js +2 -2
- package/dist/js/color-picker.js.map +1 -1
- package/dist/js/color-picker.mjs +423 -382
- package/dist/js/color-picker.mjs.map +1 -1
- package/package.json +39 -50
- package/.eslintrc.cjs +0 -199
- package/.lgtm.yml +0 -9
- package/.prettierrc.json +0 -15
- package/.stylelintrc.json +0 -236
- package/compile.cjs +0 -51
- package/cypress/e2e/color-palette.cy.ts +0 -128
- package/cypress/e2e/color-picker.cy.ts +0 -909
- package/cypress/fixtures/colorNamesFrench.js +0 -3
- package/cypress/fixtures/componentLabelsFrench.js +0 -21
- package/cypress/fixtures/format.js +0 -3
- package/cypress/fixtures/getMarkup.js +0 -35
- package/cypress/fixtures/getRandomInt.js +0 -6
- package/cypress/fixtures/sampleWebcolors.js +0 -18
- package/cypress/fixtures/testSample.js +0 -8
- 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 -30
- package/dts.config.ts +0 -15
- package/src/scss/_variables.scss +0 -6
- package/src/scss/color-picker.rtl.scss +0 -27
- package/src/scss/color-picker.scss +0 -536
- package/src/ts/colorPalette.ts +0 -89
- package/src/ts/index.ts +0 -1236
- package/src/ts/interface/ColorNames.ts +0 -20
- package/src/ts/interface/colorPickerLabels.ts +0 -20
- package/src/ts/interface/colorPickerOptions.ts +0 -11
- package/src/ts/interface/paletteOptions.ts +0 -6
- package/src/ts/util/colorNames.ts +0 -21
- package/src/ts/util/colorPickerLabels.ts +0 -24
- package/src/ts/util/getColorControls.ts +0 -90
- package/src/ts/util/getColorForm.ts +0 -75
- package/src/ts/util/getColorMenu.ts +0 -83
- package/src/ts/util/isValidJSON.ts +0 -19
- package/src/ts/util/setMarkup.ts +0 -130
- package/src/ts/util/vHidden.ts +0 -2
- package/tsconfig.json +0 -29
- package/vite.config.mts +0 -35
package/dist/js/color-picker.mjs
CHANGED
@@ -1,147 +1,89 @@
|
|
1
|
-
const
|
2
|
-
mt ? mt.brands.some((o) => Jt.test(o.brand)) : Jt.test(vt);
|
3
|
-
const Xt = /(iPhone|iPod|iPad)/;
|
4
|
-
mt ? mt.brands.some((o) => Xt.test(o.brand)) : (
|
5
|
-
/* istanbul ignore next */
|
6
|
-
Xt.test(vt)
|
7
|
-
);
|
8
|
-
vt && vt.includes("Firefox");
|
9
|
-
const { head: kt } = document;
|
10
|
-
["webkitPerspective", "perspective"].some((o) => o in kt.style);
|
11
|
-
const Bt = (o, t, e, s) => {
|
1
|
+
const jt = "aria-description", Lt = "aria-expanded", Ae = "aria-hidden", wt = "aria-selected", tt = "aria-valuenow", et = "aria-valuetext", He = "change", Ne = "focusin", Ee = "focusout", qt = "keydown", Te = "keyup", At = "click", Me = "pointerdown", ie = "pointermove", Re = "pointerup", Oe = "resize", De = "scroll", Fe = "touchmove", B = "ArrowDown", ot = "ArrowUp", ht = "ArrowLeft", W = "ArrowRight", Ie = "Enter", Ve = "Escape", Gt = "Space", Ke = "transitionDuration", Be = "transitionProperty", Z = "tabindex", ae = (o, t, e, s) => {
|
12
2
|
const r = s || !1;
|
13
|
-
o.addEventListener(
|
14
|
-
|
3
|
+
o.addEventListener(
|
4
|
+
t,
|
5
|
+
e,
|
6
|
+
r
|
7
|
+
);
|
8
|
+
}, le = (o, t, e, s) => {
|
15
9
|
const r = s || !1;
|
16
|
-
o.removeEventListener(
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
}, Je = () => {
|
23
|
-
};
|
24
|
-
(() => {
|
25
|
-
let o = !1;
|
26
|
-
try {
|
27
|
-
const t = Object.defineProperty({}, "passive", {
|
28
|
-
get: () => (o = !0, o)
|
29
|
-
});
|
30
|
-
We(document, Te, Je, t);
|
31
|
-
} catch {
|
32
|
-
}
|
33
|
-
return o;
|
34
|
-
})();
|
35
|
-
["webkitTransform", "transform"].some((o) => o in kt.style);
|
36
|
-
["webkitAnimation", "animation"].some((o) => o in kt.style);
|
37
|
-
["webkitTransition", "transition"].some((o) => o in kt.style);
|
38
|
-
const yt = (o, t) => o.getAttribute(t), m = (o, t, e) => o.setAttribute(t, e), Pt = (o, t) => o.removeAttribute(t), q = (o, ...t) => {
|
10
|
+
o.removeEventListener(
|
11
|
+
t,
|
12
|
+
e,
|
13
|
+
r
|
14
|
+
);
|
15
|
+
}, vt = (o, t) => o.getAttribute(t), v = (o, t, e) => o.setAttribute(t, e), kt = (o, t) => o.removeAttribute(t), j = (o, ...t) => {
|
39
16
|
o.classList.add(...t);
|
40
17
|
}, O = (o, ...t) => {
|
41
18
|
o.classList.remove(...t);
|
42
|
-
},
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
*
|
47
|
-
* @param element target element
|
48
|
-
* @param component the component's name or a unique key
|
49
|
-
* @param instance the component instance
|
50
|
-
*/
|
19
|
+
}, R = (o, t) => o.classList.contains(t), It = (o) => o != null && typeof o == "object" || !1, ct = (o) => It(o) && typeof o.nodeType == "number" && [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11].some(
|
20
|
+
(t) => o.nodeType === t
|
21
|
+
) || !1, z = (o) => ct(o) && o.nodeType === 1 || !1, X = /* @__PURE__ */ new Map(), lt = {
|
22
|
+
data: X,
|
51
23
|
set: (o, t, e) => {
|
52
|
-
|
24
|
+
z(o) && (X.has(t) || X.set(t, /* @__PURE__ */ new Map()), X.get(t).set(o, e));
|
53
25
|
},
|
54
|
-
|
55
|
-
* Returns all instances for specified component.
|
56
|
-
*
|
57
|
-
* @param component the component's name or a unique key
|
58
|
-
* @returns all the component instances
|
59
|
-
*/
|
60
|
-
getAllFor: (o) => W.get(o) || null,
|
61
|
-
/**
|
62
|
-
* Returns the instance associated with the target.
|
63
|
-
*
|
64
|
-
* @param element target element
|
65
|
-
* @param component the component's name or a unique key
|
66
|
-
* @returns the instance
|
67
|
-
*/
|
26
|
+
getAllFor: (o) => X.get(o) || null,
|
68
27
|
get: (o, t) => {
|
69
|
-
if (!
|
70
|
-
const e =
|
28
|
+
if (!z(o) || !t) return null;
|
29
|
+
const e = lt.getAllFor(t);
|
71
30
|
return o && e && e.get(o) || null;
|
72
31
|
},
|
73
|
-
/**
|
74
|
-
* Removes web components data.
|
75
|
-
*
|
76
|
-
* @param element target element
|
77
|
-
* @param component the component's name or a unique key
|
78
|
-
*/
|
79
32
|
remove: (o, t) => {
|
80
|
-
const e =
|
81
|
-
!e || !
|
33
|
+
const e = lt.getAllFor(t);
|
34
|
+
!e || !z(o) || (e.delete(o), e.size === 0 && X.delete(t));
|
82
35
|
}
|
83
|
-
},
|
36
|
+
}, je = (o, t) => lt.get(o, t), qe = (o) => o?.trim().replace(
|
37
|
+
/(?:^\w|[A-Z]|\b\w)/g,
|
38
|
+
(t, e) => e === 0 ? t.toLowerCase() : t.toUpperCase()
|
39
|
+
).replace(/\s+/g, ""), q = (o) => typeof o == "string" || !1, Ge = (o) => It(o) && o.constructor.name === "Window" || !1, ce = (o) => ct(o) && o.nodeType === 9 || !1, K = (o) => ce(o) ? o : ct(o) ? o.ownerDocument : Ge(o) ? o.document : globalThis.document, V = (o, ...t) => Object.assign(o, ...t), x = (o) => {
|
84
40
|
if (!o) return;
|
85
|
-
if (
|
86
|
-
return
|
41
|
+
if (q(o))
|
42
|
+
return K().createElement(o);
|
87
43
|
const { tagName: t } = o, e = x(t);
|
88
44
|
if (!e) return;
|
89
45
|
const s = { ...o };
|
90
|
-
return delete s.tagName,
|
91
|
-
},
|
46
|
+
return delete s.tagName, V(e, s);
|
47
|
+
}, Ht = (o, t) => {
|
92
48
|
if (!o || !t) return;
|
93
|
-
if (
|
94
|
-
return
|
95
|
-
const { tagName: e } = t, s =
|
49
|
+
if (q(t))
|
50
|
+
return K().createElementNS(o, t);
|
51
|
+
const { tagName: e } = t, s = Ht(o, e);
|
96
52
|
if (!s) return;
|
97
53
|
const r = { ...t };
|
98
|
-
return delete r.tagName,
|
99
|
-
},
|
100
|
-
const
|
101
|
-
return
|
102
|
-
},
|
103
|
-
const t =
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
/* istanbul ignore next */
|
108
|
-
0
|
109
|
-
);
|
110
|
-
return Number.isNaN(r) ? (
|
111
|
-
/* istanbul ignore next */
|
112
|
-
0
|
113
|
-
) : r;
|
114
|
-
}, _ = (o, t) => o.focus(t), Yt = (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), to = (o, t, e, s) => {
|
54
|
+
return delete r.tagName, V(s, r);
|
55
|
+
}, We = (o, t) => o.dispatchEvent(t), Nt = (o, t, e) => {
|
56
|
+
const s = getComputedStyle(o, e), r = t.replace("webkit", "Webkit").replace(/([A-Z])/g, "-$1").toLowerCase();
|
57
|
+
return s.getPropertyValue(r);
|
58
|
+
}, Ue = (o) => {
|
59
|
+
const t = Nt(o, Be), e = Nt(o, Ke), s = e.includes("ms") ? 1 : 1e3, r = t && t !== "none" ? parseFloat(e) * s : 0;
|
60
|
+
return Number.isNaN(r) ? 0 : r;
|
61
|
+
}, U = (o, t) => o.focus(t), Wt = (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), _e = (o, t, e, s) => {
|
62
|
+
if (!z(o)) return t;
|
115
63
|
const r = { ...e }, n = { ...o.dataset }, i = { ...t }, a = {}, l = "title";
|
116
64
|
return pt(n).forEach(([c, h]) => {
|
117
|
-
const b = c;
|
118
|
-
a[b] =
|
65
|
+
const b = qe(c);
|
66
|
+
a[b] = Wt(h);
|
119
67
|
}), pt(r).forEach(([c, h]) => {
|
120
|
-
r[c] =
|
68
|
+
r[c] = Wt(h);
|
121
69
|
}), pt(t).forEach(([c, h]) => {
|
122
|
-
c in r ? i[c] = r[c] : c in a ? i[c] = a[c] : i[c] = c === l ?
|
70
|
+
c in r ? i[c] = r[c] : c in a ? i[c] = a[c] : i[c] = c === l ? vt(o, l) : h;
|
123
71
|
}), i;
|
124
|
-
},
|
72
|
+
}, Ut = (o) => Object.fromEntries(o), ze = (o) => o.offsetHeight, D = (o, t) => {
|
125
73
|
pt(t).forEach(([e, s]) => {
|
126
|
-
if (s &&
|
74
|
+
if (s && q(e) && e.includes("--"))
|
127
75
|
o.style.setProperty(e, s);
|
128
76
|
else {
|
129
77
|
const r = {};
|
130
|
-
r[e] = s,
|
78
|
+
r[e] = s, V(o.style, r);
|
131
79
|
}
|
132
80
|
});
|
133
|
-
},
|
81
|
+
}, Xe = (o) => It(o) && o.constructor.name === "Map" || !1, he = (o) => o.toUpperCase(), ge = (o) => z(o) && "offsetWidth" in o || !1, gt = (o, t) => {
|
134
82
|
const { width: e, height: s, top: r, right: n, bottom: i, left: a } = o.getBoundingClientRect();
|
135
83
|
let l = 1, c = 1;
|
136
|
-
if (t &&
|
84
|
+
if (t && ge(o)) {
|
137
85
|
const { offsetWidth: h, offsetHeight: b } = o;
|
138
|
-
l = h > 0 ? Math.round(e) / h : (
|
139
|
-
/* istanbul ignore next */
|
140
|
-
1
|
141
|
-
), c = b > 0 ? Math.round(s) / b : (
|
142
|
-
/* istanbul ignore next */
|
143
|
-
1
|
144
|
-
);
|
86
|
+
l = h > 0 ? Math.round(e) / h : 1, c = b > 0 ? Math.round(s) / b : 1;
|
145
87
|
}
|
146
88
|
return {
|
147
89
|
width: e / l,
|
@@ -153,28 +95,30 @@ const yt = (o, t) => o.getAttribute(t), m = (o, t, e) => o.setAttribute(t, e), P
|
|
153
95
|
x: a / l,
|
154
96
|
y: r / c
|
155
97
|
};
|
156
|
-
},
|
157
|
-
let
|
158
|
-
const J = /* @__PURE__ */ new Map(),
|
159
|
-
let e = t ?
|
98
|
+
}, yt = (o) => K(o).documentElement, Je = (o) => o ? ce(o) ? o.defaultView : ct(o) ? o?.ownerDocument?.defaultView : o : window;
|
99
|
+
let _t = 0, zt = 0;
|
100
|
+
const J = /* @__PURE__ */ new Map(), ue = (o, t) => {
|
101
|
+
let e = t ? _t : zt;
|
160
102
|
if (t) {
|
161
|
-
const s =
|
162
|
-
J.has(s) || J.set(s, r),
|
103
|
+
const s = ue(o), r = J.get(s) || /* @__PURE__ */ new Map();
|
104
|
+
J.has(s) || J.set(s, r), Xe(r) && !r.has(t) ? (r.set(t, e), _t += 1) : e = r.get(t);
|
163
105
|
} else {
|
164
106
|
const s = o.id || o;
|
165
|
-
J.has(s) ? e = J.get(s) : (J.set(s, e),
|
107
|
+
J.has(s) ? e = J.get(s) : (J.set(s, e), zt += 1);
|
166
108
|
}
|
167
109
|
return e;
|
168
|
-
},
|
169
|
-
var t;
|
170
|
-
return o ? be(o) ? o.defaultView : Z(o) ? (t = o?.ownerDocument) == null ? void 0 : t.defaultView : o : window;
|
171
|
-
}, Lt = (o) => Array.isArray(o) || !1, fe = (o, t) => o ? o.closest(t) || // break out of `ShadowRoot`
|
172
|
-
fe(o.getRootNode().host, t) : null, z = (o, t) => at(o) ? o : (Z(t) ? t : V()).querySelector(o), st = (o, t) => (t && Z(t) ? t : V()).getElementsByClassName(
|
110
|
+
}, xt = (o) => Array.isArray(o) || !1, be = (o, t) => !o || !t ? null : o.closest(t) || be(o.getRootNode().host, t) || null, _ = (o, t) => z(o) ? o : (z(t) ? t : K()).querySelector(o), st = (o, t) => (t && ct(t) ? t : K()).getElementsByClassName(
|
173
111
|
o
|
174
|
-
),
|
112
|
+
), Vt = [
|
113
|
+
"transparent",
|
114
|
+
"currentColor",
|
115
|
+
"inherit",
|
116
|
+
"revert",
|
117
|
+
"initial"
|
118
|
+
], m = (o) => {
|
175
119
|
const t = Math.floor(o);
|
176
120
|
return o - t < 0.5 ? t : Math.round(o);
|
177
|
-
},
|
121
|
+
}, mt = [
|
178
122
|
[
|
179
123
|
"aliceblue",
|
180
124
|
{
|
@@ -1359,13 +1303,13 @@ fe(o.getRootNode().host, t) : null, z = (o, t) => at(o) ? o : (Z(t) ? t : V()).q
|
|
1359
1303
|
b: 50
|
1360
1304
|
}
|
1361
1305
|
]
|
1362
|
-
],
|
1363
|
-
CSS_UNIT: new RegExp(
|
1364
|
-
ANGLES:
|
1365
|
-
CSS_ANGLE:
|
1366
|
-
CSS_INTEGER:
|
1367
|
-
CSS_NUMBER:
|
1368
|
-
CSS_UNIT2:
|
1306
|
+
], pe = "deg|rad|grad|turn", de = "[-\\+]?\\d+%?", fe = "[-\\+]?\\d*\\.\\d+%?", me = `[-\\+]?\\d*\\.?\\d+(?:${pe})?`, dt = `(?:${fe})|(?:${de})`, Et = `(?:${dt})|(?:${me}?)`, Ze = "(?:[\\s|\\(\\s|\\s\\(\\s]+)?", Qe = "(?:[\\s|\\)\\s]+)?", Xt = "(?:[,|\\s]+)", Ye = "(?:[,|\\/\\s]*)?", rt = `${Ze}(${Et})${Xt}(${dt})${Xt}(${dt})${Ye}(${dt})?${Qe}`, I = {
|
1307
|
+
CSS_UNIT: new RegExp(Et),
|
1308
|
+
ANGLES: pe,
|
1309
|
+
CSS_ANGLE: me,
|
1310
|
+
CSS_INTEGER: de,
|
1311
|
+
CSS_NUMBER: fe,
|
1312
|
+
CSS_UNIT2: Et,
|
1369
1313
|
PERMISSIVE_MATCH: rt,
|
1370
1314
|
hwb: new RegExp(`hwb${rt}`),
|
1371
1315
|
rgb: new RegExp(`rgb(?:a)?${rt}`),
|
@@ -1375,21 +1319,16 @@ fe(o.getRootNode().host, t) : null, z = (o, t) => at(o) ? o : (Z(t) ? t : V()).q
|
|
1375
1319
|
hex6: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,
|
1376
1320
|
hex4: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
|
1377
1321
|
hex8: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/
|
1378
|
-
},
|
1322
|
+
}, ve = (o) => Vt.includes(o), nt = (o, t) => o !== null && typeof o == "object" && Object.keys(t).every((e) => e in o), $e = (o) => `${o}`.includes(".") && parseFloat(o) === 1, Kt = (o) => typeof o == "string" && o.includes("%"), H = (o) => !!I.CSS_UNIT.exec(`${o}`), we = ["rgb", "hex", "hsl", "hsv", "hwb"], ke = (o) => Vt.includes(o) || ["#", ...we].some((t) => o.includes(t)) ? !1 : mt.some(([t]) => o === t), Jt = 1e-6, to = (o, t) => Math.abs(o * t - t) < Jt ? 1 : o < Jt ? 0 : o, E = (o, t) => {
|
1379
1323
|
let e = o;
|
1380
|
-
|
1381
|
-
|
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);
|
1386
|
-
}, Ot = (o) => {
|
1324
|
+
return $e(o) && (e = "100%"), Kt(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), to(e, t));
|
1325
|
+
}, Tt = (o) => {
|
1387
1326
|
let t = parseFloat(o);
|
1388
1327
|
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]] =
|
1328
|
+
}, ut = (o) => Math.min(1, Math.max(0, o)), G = (o) => o.length === 1 ? `0${o}` : String(o), ye = (o) => {
|
1329
|
+
const [[, t]] = mt.filter(([e]) => e === o.toLowerCase());
|
1391
1330
|
return t;
|
1392
|
-
}, N = (o) => parseInt(o, 16),
|
1331
|
+
}, N = (o) => parseInt(o, 16), Mt = (o) => N(o) / 255, xe = (o) => m(o * 255).toString(16), Zt = (o, t, e) => {
|
1393
1332
|
const s = Math.max(o, t, e), r = Math.min(o, t, e);
|
1394
1333
|
let n = 0, i = 0;
|
1395
1334
|
const a = (s + r) / 2;
|
@@ -1403,16 +1342,16 @@ fe(o.getRootNode().host, t) : null, z = (o, t) => at(o) ? o : (Z(t) ? t : V()).q
|
|
1403
1342
|
}, ft = (o, t, e) => {
|
1404
1343
|
let s = e;
|
1405
1344
|
return s < 0 && (s += 1), s > 1 && (s -= 1), s < 1 / 6 ? o + (t - o) * (6 * s) : s < 1 / 2 ? t : s < 2 / 3 ? o + (t - o) * (2 / 3 - s) * 6 : o;
|
1406
|
-
},
|
1345
|
+
}, at = (o, t, e) => {
|
1407
1346
|
let s = 0, r = 0, n = 0;
|
1408
1347
|
if (t === 0)
|
1409
1348
|
r = e, n = e, s = e;
|
1410
|
-
else
|
1349
|
+
else {
|
1411
1350
|
const i = e < 0.5 ? e * (1 + t) : e + t - e * t, a = 2 * e - i;
|
1412
1351
|
s = ft(a, i, o + 1 / 3), r = ft(a, i, o), n = ft(a, i, o - 1 / 3);
|
1413
1352
|
}
|
1414
1353
|
return { r: s, g: r, b: n };
|
1415
|
-
},
|
1354
|
+
}, Qt = (o, t, e) => {
|
1416
1355
|
let s = 0, r = 0;
|
1417
1356
|
const n = Math.min(o, t, e), i = Math.max(o, t, e), a = 1 - i;
|
1418
1357
|
if (i === n) return { h: 0, w: n, b: a };
|
@@ -1423,45 +1362,45 @@ fe(o.getRootNode().host, t) : null, z = (o, t) => at(o) ? o : (Z(t) ? t : V()).q
|
|
1423
1362
|
w: n,
|
1424
1363
|
b: a
|
1425
1364
|
};
|
1426
|
-
},
|
1365
|
+
}, Se = (o, t, e) => {
|
1427
1366
|
if (t + e >= 1) {
|
1428
1367
|
const i = t / (t + e);
|
1429
1368
|
return { r: i, g: i, b: i };
|
1430
1369
|
}
|
1431
|
-
let { r: s, g: r, b: n } =
|
1370
|
+
let { r: s, g: r, b: n } = at(o, 1, 0.5);
|
1432
1371
|
return [s, r, n] = [s, r, n].map((i) => i * (1 - t - e) + t), { r: s, g: r, b: n };
|
1433
|
-
},
|
1372
|
+
}, Yt = (o, t, e) => {
|
1434
1373
|
const s = Math.max(o, t, e), r = Math.min(o, t, e);
|
1435
1374
|
let n = 0;
|
1436
1375
|
const i = s, a = s - r, l = s === 0 ? 0 : a / s;
|
1437
1376
|
return s === r ? n = 0 : (o === s && (n = (t - e) / a + (t < e ? 6 : 0)), t === s && (n = (e - o) / a + 2), e === s && (n = (o - t) / a + 4), n /= 6), { h: n, s: l, v: i };
|
1438
|
-
},
|
1377
|
+
}, Rt = (o, t, e) => {
|
1439
1378
|
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
1379
|
return { r: u, g: d, b: g };
|
1441
|
-
},
|
1380
|
+
}, St = (o, t, e, s) => {
|
1442
1381
|
const r = [
|
1443
|
-
G(
|
1444
|
-
G(
|
1445
|
-
G(
|
1382
|
+
G(m(o).toString(16)),
|
1383
|
+
G(m(t).toString(16)),
|
1384
|
+
G(m(e).toString(16))
|
1446
1385
|
];
|
1447
1386
|
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
|
-
},
|
1387
|
+
}, Ct = (o, t, e, s, r) => {
|
1449
1388
|
const n = [
|
1450
|
-
G(
|
1451
|
-
G(
|
1452
|
-
G(
|
1453
|
-
G(
|
1389
|
+
G(m(o).toString(16)),
|
1390
|
+
G(m(t).toString(16)),
|
1391
|
+
G(m(e).toString(16)),
|
1392
|
+
G(xe(s))
|
1454
1393
|
];
|
1455
1394
|
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
|
-
},
|
1395
|
+
}, Ce = (o) => {
|
1457
1396
|
const t = String(o).trim().toLowerCase();
|
1458
|
-
if (
|
1459
|
-
return Object.assign(
|
1397
|
+
if (ke(t))
|
1398
|
+
return Object.assign(ye(t), {
|
1460
1399
|
a: 1,
|
1461
1400
|
format: "rgb",
|
1462
1401
|
ok: !0
|
1463
1402
|
});
|
1464
|
-
if (
|
1403
|
+
if (ve(t))
|
1465
1404
|
return {
|
1466
1405
|
r: 0,
|
1467
1406
|
g: 0,
|
@@ -1503,7 +1442,7 @@ fe(o.getRootNode().host, t) : null, z = (o, t) => at(o) ? o : (Z(t) ? t : V()).q
|
|
1503
1442
|
r: N(e),
|
1504
1443
|
g: N(s),
|
1505
1444
|
b: N(r),
|
1506
|
-
a:
|
1445
|
+
a: Mt(n),
|
1507
1446
|
format: "hex",
|
1508
1447
|
ok: !0
|
1509
1448
|
} : ([, e, s, r] = I.hex6.exec(t) || [], e && s && r ? {
|
@@ -1517,7 +1456,7 @@ fe(o.getRootNode().host, t) : null, z = (o, t) => at(o) ? o : (Z(t) ? t : V()).q
|
|
1517
1456
|
r: N(e + e),
|
1518
1457
|
g: N(s + s),
|
1519
1458
|
b: N(r + r),
|
1520
|
-
a:
|
1459
|
+
a: Mt(n + n),
|
1521
1460
|
format: "hex",
|
1522
1461
|
ok: !0
|
1523
1462
|
} : ([, e, s, r] = I.hex3.exec(t) || [], e && s && r ? {
|
@@ -1535,49 +1474,56 @@ fe(o.getRootNode().host, t) : null, z = (o, t) => at(o) ? o : (Z(t) ? t : V()).q
|
|
1535
1474
|
format: "rgb",
|
1536
1475
|
ok: !o
|
1537
1476
|
})))))));
|
1538
|
-
},
|
1477
|
+
}, eo = (o, t, e) => ({
|
1478
|
+
r: E(o, 255),
|
1479
|
+
g: E(t, 255),
|
1480
|
+
b: E(e, 255)
|
1481
|
+
}), te = (o) => {
|
1539
1482
|
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
|
1544
|
-
|
1483
|
+
if ((!e || typeof e == "string") && (e = Ce(e), d = e.ok || d), nt(e, t) && H(e.r) && H(e.g) && H(e.b)) {
|
1484
|
+
if (["format", "ok", "originalInput"].every((g) => g in e))
|
1485
|
+
return { ...e };
|
1486
|
+
({ r: h, g: b, b: l } = e), t = eo(h, b, l), u = "format" in e ? e.format : "rgb";
|
1487
|
+
}
|
1488
|
+
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 = Rt(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 = at(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 = Se(c, a, l), u = "hwb"), H(e.a) && (s = e.a, s = Kt(s) || parseFloat(`${s}`) > 1 ? E(s, 100) : s), {
|
1489
|
+
...t,
|
1490
|
+
a: Tt(s),
|
1545
1491
|
format: u,
|
1546
1492
|
ok: d
|
1547
1493
|
};
|
1548
|
-
},
|
1494
|
+
}, oo = "1.0.13";
|
1549
1495
|
class y {
|
1550
1496
|
// bring main utilities to front
|
1551
1497
|
static matchers = I;
|
1552
|
-
static isOnePointZero =
|
1553
|
-
static isPercentage =
|
1498
|
+
static isOnePointZero = $e;
|
1499
|
+
static isPercentage = Kt;
|
1554
1500
|
static isValidCSSUnit = H;
|
1555
|
-
static isNonColor =
|
1556
|
-
static isColorName =
|
1501
|
+
static isNonColor = ve;
|
1502
|
+
static isColorName = ke;
|
1557
1503
|
static isColorType = nt;
|
1558
1504
|
static pad2 = G;
|
1559
1505
|
static clamp01 = ut;
|
1560
|
-
static bound01 =
|
1561
|
-
static boundAlpha =
|
1562
|
-
static getRGBFromName =
|
1563
|
-
static convertHexToDecimal =
|
1564
|
-
static convertDecimalToHex =
|
1565
|
-
static rgbToHsl =
|
1566
|
-
static rgbToHex =
|
1567
|
-
static rgbToHsv =
|
1568
|
-
static rgbToHwb =
|
1569
|
-
static rgbaToHex =
|
1570
|
-
static hslToRgb =
|
1571
|
-
static hsvToRgb =
|
1506
|
+
static bound01 = E;
|
1507
|
+
static boundAlpha = Tt;
|
1508
|
+
static getRGBFromName = ye;
|
1509
|
+
static convertHexToDecimal = Mt;
|
1510
|
+
static convertDecimalToHex = xe;
|
1511
|
+
static rgbToHsl = Zt;
|
1512
|
+
static rgbToHex = St;
|
1513
|
+
static rgbToHsv = Yt;
|
1514
|
+
static rgbToHwb = Qt;
|
1515
|
+
static rgbaToHex = Ct;
|
1516
|
+
static hslToRgb = Rt;
|
1517
|
+
static hsvToRgb = Rt;
|
1572
1518
|
static hueToRgb = ft;
|
1573
|
-
static hwbToRgb =
|
1519
|
+
static hwbToRgb = Se;
|
1574
1520
|
static parseIntFromHex = N;
|
1575
|
-
static stringInputToObject =
|
1576
|
-
static inputToRGB =
|
1577
|
-
static roundPart =
|
1578
|
-
static webColors =
|
1579
|
-
static nonColors =
|
1580
|
-
static version =
|
1521
|
+
static stringInputToObject = Ce;
|
1522
|
+
static inputToRGB = te;
|
1523
|
+
static roundPart = m;
|
1524
|
+
static webColors = mt;
|
1525
|
+
static nonColors = Vt;
|
1526
|
+
static version = oo;
|
1581
1527
|
// main public properties
|
1582
1528
|
r;
|
1583
1529
|
g;
|
@@ -1588,7 +1534,7 @@ class y {
|
|
1588
1534
|
originalInput;
|
1589
1535
|
// main public methods
|
1590
1536
|
constructor(t, e) {
|
1591
|
-
const s = e &&
|
1537
|
+
const s = e && we.includes(e) ? e : "", { r, g: n, b: i, a, ok: l, format: c } = te(t);
|
1592
1538
|
this.originalInput = t, this.r = r, this.g = n, this.b = i, this.a = a, this.ok = l, this.format = s || c;
|
1593
1539
|
}
|
1594
1540
|
/**
|
@@ -1624,7 +1570,7 @@ class y {
|
|
1624
1570
|
* Returns the web colour name closest to the current colour.
|
1625
1571
|
*/
|
1626
1572
|
get name() {
|
1627
|
-
const { r: t, g: e, b: s } = this.toRgb(), [r] =
|
1573
|
+
const { r: t, g: e, b: s } = this.toRgb(), [r] = mt.map(([n, i]) => {
|
1628
1574
|
const a = (
|
1629
1575
|
// ((rgb.r - r) ** 2 + (rgb.g - g) ** 2 + (rgb.b - b) ** 2) ** 0.5; // standard
|
1630
1576
|
(((i.r - t) * 0.3) ** 2 + ((i.g - e) * 0.6) ** 2 + ((i.b - s) * 0.1) ** 2) ** 0.5
|
@@ -1638,7 +1584,7 @@ class y {
|
|
1638
1584
|
*/
|
1639
1585
|
toRgb() {
|
1640
1586
|
let { r: t, g: e, b: s, a: r } = this;
|
1641
|
-
return [t, e, s] = [t, e, s].map((n) =>
|
1587
|
+
return [t, e, s] = [t, e, s].map((n) => m(n * 255 * 100) / 100), r = m(r * 100) / 100, {
|
1642
1588
|
r: t,
|
1643
1589
|
g: e,
|
1644
1590
|
b: s,
|
@@ -1651,7 +1597,7 @@ class y {
|
|
1651
1597
|
* * rgba(255,255,255,0.5)
|
1652
1598
|
*/
|
1653
1599
|
toRgbString() {
|
1654
|
-
const { r: t, g: e, b: s, a: r } = this.toRgb(), [n, i, a] = [t, e, s].map(
|
1600
|
+
const { r: t, g: e, b: s, a: r } = this.toRgb(), [n, i, a] = [t, e, s].map(m);
|
1655
1601
|
return r === 1 ? `rgb(${n}, ${i}, ${a})` : `rgba(${n}, ${i}, ${a}, ${r})`;
|
1656
1602
|
}
|
1657
1603
|
/**
|
@@ -1660,7 +1606,7 @@ class y {
|
|
1660
1606
|
* * rgb(255 255 255 / 50%)
|
1661
1607
|
*/
|
1662
1608
|
toRgbCSS4String() {
|
1663
|
-
const { r: t, g: e, b: s, a: r } = this.toRgb(), [n, i, a] = [t, e, s].map(
|
1609
|
+
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
1610
|
return `rgb(${n} ${i} ${a}${l})`;
|
1665
1611
|
}
|
1666
1612
|
/**
|
@@ -1668,8 +1614,8 @@ class y {
|
|
1668
1614
|
* it will find a 3 characters shorthand of the decimal value.
|
1669
1615
|
*/
|
1670
1616
|
toHex(t) {
|
1671
|
-
|
1672
|
-
return n === 1 ?
|
1617
|
+
let { r: e, g: s, b: r, a: n } = this;
|
1618
|
+
return [e, s, r] = [e, s, r].map((i) => m(i * 255)), n = m(n * 100) / 100, n === 1 ? St(e, s, r, t) : Ct(e, s, r, n, t);
|
1673
1619
|
}
|
1674
1620
|
/**
|
1675
1621
|
* Returns the CSS valid hexadecimal vaue of the colour. When the parameter is *true*
|
@@ -1682,8 +1628,8 @@ class y {
|
|
1682
1628
|
* Returns the HEX8 value of the colour.
|
1683
1629
|
*/
|
1684
1630
|
toHex8(t) {
|
1685
|
-
|
1686
|
-
return
|
1631
|
+
let { r: e, g: s, b: r, a: n } = this;
|
1632
|
+
return [e, s, r] = [e, s, r].map((i) => m(i * 255)), n = m(n * 100) / 100, n === 1 ? St(e, s, r, t) : Ct(e, s, r, n, t);
|
1687
1633
|
}
|
1688
1634
|
/**
|
1689
1635
|
* Returns the HEX8 value of the colour.
|
@@ -1695,7 +1641,7 @@ class y {
|
|
1695
1641
|
* Returns the colour as a HSVA object.
|
1696
1642
|
*/
|
1697
1643
|
toHsv() {
|
1698
|
-
const { r: t, g: e, b: s, a: r } = this, { h: n, s: i, v: a } =
|
1644
|
+
const { r: t, g: e, b: s, a: r } = this, { h: n, s: i, v: a } = Yt(t, e, s);
|
1699
1645
|
return {
|
1700
1646
|
h: n,
|
1701
1647
|
s: i,
|
@@ -1707,7 +1653,7 @@ class y {
|
|
1707
1653
|
* Returns the colour as an HSLA object.
|
1708
1654
|
*/
|
1709
1655
|
toHsl() {
|
1710
|
-
const { r: t, g: e, b: s, a: r } = this, { h: n, s: i, l: a } =
|
1656
|
+
const { r: t, g: e, b: s, a: r } = this, { h: n, s: i, l: a } = Zt(t, e, s);
|
1711
1657
|
return {
|
1712
1658
|
h: n,
|
1713
1659
|
s: i,
|
@@ -1722,7 +1668,7 @@ class y {
|
|
1722
1668
|
*/
|
1723
1669
|
toHslString() {
|
1724
1670
|
let { h: t, s: e, l: s, a: r } = this.toHsl();
|
1725
|
-
return t =
|
1671
|
+
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
1672
|
}
|
1727
1673
|
/**
|
1728
1674
|
* Returns the HSLA values concatenated into a CSS4 Module format string.
|
@@ -1731,15 +1677,15 @@ class y {
|
|
1731
1677
|
*/
|
1732
1678
|
toHslCSS4String() {
|
1733
1679
|
let { h: t, s: e, l: s, a: r } = this.toHsl();
|
1734
|
-
t =
|
1735
|
-
const n = r < 100 ? ` / ${
|
1680
|
+
t = m(t * 360), e = m(e * 100), s = m(s * 100), r = m(r * 100);
|
1681
|
+
const n = r < 100 ? ` / ${m(r)}%` : "";
|
1736
1682
|
return `hsl(${t}deg ${e}% ${s}%${n})`;
|
1737
1683
|
}
|
1738
1684
|
/**
|
1739
1685
|
* Returns the colour as an HWBA object.
|
1740
1686
|
*/
|
1741
1687
|
toHwb() {
|
1742
|
-
const { r: t, g: e, b: s, a: r } = this, { h: n, w: i, b: a } =
|
1688
|
+
const { r: t, g: e, b: s, a: r } = this, { h: n, w: i, b: a } = Qt(t, e, s);
|
1743
1689
|
return {
|
1744
1690
|
h: n,
|
1745
1691
|
w: i,
|
@@ -1752,22 +1698,22 @@ class y {
|
|
1752
1698
|
*/
|
1753
1699
|
toHwbString() {
|
1754
1700
|
let { h: t, w: e, b: s, a: r } = this.toHwb();
|
1755
|
-
t =
|
1756
|
-
const n = r < 100 ? ` / ${
|
1701
|
+
t = m(t * 360), e = m(e * 100), s = m(s * 100), r = m(r * 100);
|
1702
|
+
const n = r < 100 ? ` / ${m(r)}%` : "";
|
1757
1703
|
return `hwb(${t}deg ${e}% ${s}%${n})`;
|
1758
1704
|
}
|
1759
1705
|
/**
|
1760
1706
|
* Sets the alpha value of the current colour.
|
1761
1707
|
*/
|
1762
1708
|
setAlpha(t) {
|
1763
|
-
return typeof t != "number" ? this : (this.a =
|
1709
|
+
return typeof t != "number" ? this : (this.a = Tt(t), this);
|
1764
1710
|
}
|
1765
1711
|
/**
|
1766
1712
|
* Saturate the colour with a given amount.
|
1767
1713
|
*/
|
1768
1714
|
saturate(t) {
|
1769
1715
|
if (typeof t != "number") return this;
|
1770
|
-
const { h: e, s, l: r } = this.toHsl(), { r: n, g: i, b: a } =
|
1716
|
+
const { h: e, s, l: r } = this.toHsl(), { r: n, g: i, b: a } = at(e, ut(s + t / 100), r);
|
1771
1717
|
return Object.assign(this, { r: n, g: i, b: a }), this;
|
1772
1718
|
}
|
1773
1719
|
/**
|
@@ -1788,7 +1734,7 @@ class y {
|
|
1788
1734
|
*/
|
1789
1735
|
lighten(t) {
|
1790
1736
|
if (typeof t != "number") return this;
|
1791
|
-
const { h: e, s, l: r } = this.toHsl(), { r: n, g: i, b: a } =
|
1737
|
+
const { h: e, s, l: r } = this.toHsl(), { r: n, g: i, b: a } = at(e, s, ut(r + t / 100));
|
1792
1738
|
return Object.assign(this, { r: n, g: i, b: a }), this;
|
1793
1739
|
}
|
1794
1740
|
/**
|
@@ -1803,7 +1749,11 @@ class y {
|
|
1803
1749
|
*/
|
1804
1750
|
spin(t) {
|
1805
1751
|
if (typeof t != "number") return this;
|
1806
|
-
const { h: e, s, l: r } = this.toHsl(), { r: n, g: i, b: a } =
|
1752
|
+
const { h: e, s, l: r } = this.toHsl(), { r: n, g: i, b: a } = at(
|
1753
|
+
ut((e * 360 + t) % 360 / 360),
|
1754
|
+
s,
|
1755
|
+
r
|
1756
|
+
);
|
1807
1757
|
return Object.assign(this, { r: n, g: i, b: a }), this;
|
1808
1758
|
}
|
1809
1759
|
/** Returns a clone of the current `Color` instance. */
|
@@ -1818,7 +1768,7 @@ class y {
|
|
1818
1768
|
return e === "hex" ? this.toHexString(t) : e === "hsl" ? this.toHslString() : e === "hwb" ? this.toHwbString() : this.toRgbString();
|
1819
1769
|
}
|
1820
1770
|
}
|
1821
|
-
class
|
1771
|
+
class Ot {
|
1822
1772
|
static Color = y;
|
1823
1773
|
hue;
|
1824
1774
|
hueSteps;
|
@@ -1839,7 +1789,9 @@ class It {
|
|
1839
1789
|
else if (t.length === 3)
|
1840
1790
|
[e, s, r] = t;
|
1841
1791
|
else if (t.length === 2 && ([s, r] = t, [s, r].some((g) => g < 1)))
|
1842
|
-
throw TypeError(
|
1792
|
+
throw TypeError(
|
1793
|
+
"ColorPalette: the two minimum arguments must be numbers higher than 0."
|
1794
|
+
);
|
1843
1795
|
const a = [], l = 360 / s, c = y.roundPart((r - (r % 2 ? 1 : 0)) / 2), h = [0.25, 0.2, 0.15, 0.11, 0.09, 0.075], b = [
|
1844
1796
|
[1, 2, 3],
|
1845
1797
|
[4, 5],
|
@@ -1853,16 +1805,18 @@ class It {
|
|
1853
1805
|
for (let g = 1; g < r - c; g += 1)
|
1854
1806
|
n = [0.5 - d * g, ...n];
|
1855
1807
|
for (let g = 0; g < s; g += 1) {
|
1856
|
-
const p = (e + g * l) % 360
|
1808
|
+
const p = (e + g * l) % 360;
|
1857
1809
|
n.forEach((f) => {
|
1858
|
-
const
|
1859
|
-
a.push(
|
1810
|
+
const $ = new y({ h: p, s: 100, l: f * 100 });
|
1811
|
+
a.push(
|
1812
|
+
i < 100 ? $.saturate(i - 100) : $
|
1813
|
+
);
|
1860
1814
|
});
|
1861
1815
|
}
|
1862
1816
|
this.hue = e, this.hueSteps = s, this.lightSteps = r, this.saturation = i, this.colors = a;
|
1863
1817
|
}
|
1864
1818
|
}
|
1865
|
-
const
|
1819
|
+
const Dt = {
|
1866
1820
|
pickerLabel: "Colour Picker",
|
1867
1821
|
appearanceLabel: "Colour Appearance",
|
1868
1822
|
valueLabel: "Colour Value",
|
@@ -1898,23 +1852,23 @@ const Kt = {
|
|
1898
1852
|
"violet",
|
1899
1853
|
"magenta",
|
1900
1854
|
"pink"
|
1901
|
-
],
|
1902
|
-
if (!
|
1855
|
+
], ee = (o) => {
|
1856
|
+
if (!q(o)) return !1;
|
1903
1857
|
try {
|
1904
1858
|
JSON.parse(o);
|
1905
1859
|
} catch {
|
1906
1860
|
return !1;
|
1907
1861
|
}
|
1908
1862
|
return !0;
|
1909
|
-
},
|
1863
|
+
}, Ft = "v-hidden", so = (o) => {
|
1910
1864
|
const { format: t, id: e, componentLabels: s } = o, r = x({
|
1911
1865
|
tagName: "div",
|
1912
1866
|
className: `color-form ${t}`
|
1913
1867
|
});
|
1914
1868
|
let n = ["hex"];
|
1915
1869
|
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
|
-
|
1870
|
+
const [a] = t === "hex" ? ["#"] : he(i).split(""), l = `color_${t}_${i}_${e}`, c = s[`${i}Label`], h = x({ tagName: "label" });
|
1871
|
+
v(h, "for", l), h.append(
|
1918
1872
|
x({
|
1919
1873
|
tagName: "span",
|
1920
1874
|
ariaHidden: "true",
|
@@ -1922,7 +1876,7 @@ const Kt = {
|
|
1922
1876
|
}),
|
1923
1877
|
x({
|
1924
1878
|
tagName: "span",
|
1925
|
-
className:
|
1879
|
+
className: Ft,
|
1926
1880
|
innerText: c
|
1927
1881
|
})
|
1928
1882
|
);
|
@@ -1937,14 +1891,21 @@ const Kt = {
|
|
1937
1891
|
spellcheck: !1
|
1938
1892
|
});
|
1939
1893
|
let u = "100", d = "1";
|
1940
|
-
i !== "alpha" && (t === "rgb" ? (u = "255", d = "1") : i === "hue" && (u = "360", d = "1")),
|
1894
|
+
i !== "alpha" && (t === "rgb" ? (u = "255", d = "1") : i === "hue" && (u = "360", d = "1")), V(b, {
|
1941
1895
|
min: "0",
|
1942
1896
|
max: u,
|
1943
1897
|
step: d
|
1944
1898
|
}), r.append(h, b);
|
1945
1899
|
}), r;
|
1946
|
-
},
|
1947
|
-
const { format: t, componentLabels: e } = o, {
|
1900
|
+
}, ro = (o) => {
|
1901
|
+
const { format: t, componentLabels: e } = o, {
|
1902
|
+
hueLabel: s,
|
1903
|
+
alphaLabel: r,
|
1904
|
+
lightnessLabel: n,
|
1905
|
+
saturationLabel: i,
|
1906
|
+
whitenessLabel: a,
|
1907
|
+
blacknessLabel: l
|
1908
|
+
} = e, c = t === "hsl" ? 360 : 100, h = t === "hsl" ? 100 : 360, b = 100;
|
1948
1909
|
let u = t === "hsl" ? `${s} & ${n}` : `${n} & ${i}`;
|
1949
1910
|
u = t === "hwb" ? `${a} & ${l}` : u;
|
1950
1911
|
const d = t === "hsl" ? `${i}` : `${s}`, g = x({
|
@@ -1973,13 +1934,13 @@ const Kt = {
|
|
1973
1934
|
min: 0,
|
1974
1935
|
max: b
|
1975
1936
|
}
|
1976
|
-
].forEach((
|
1977
|
-
const { i: S, c: L, l:
|
1937
|
+
].forEach((w) => {
|
1938
|
+
const { i: S, c: L, l: C, min: P, max: M } = w, T = x({
|
1978
1939
|
tagName: "div",
|
1979
1940
|
className: "color-control",
|
1980
1941
|
role: "presentation"
|
1981
1942
|
});
|
1982
|
-
|
1943
|
+
T.append(
|
1983
1944
|
x({
|
1984
1945
|
tagName: "div",
|
1985
1946
|
className: `visual-control visual-control${S}`
|
@@ -1989,53 +1950,61 @@ const Kt = {
|
|
1989
1950
|
tagName: "div",
|
1990
1951
|
className: `${L} knob`,
|
1991
1952
|
ariaLive: "polite",
|
1992
|
-
ariaLabel:
|
1953
|
+
ariaLabel: C,
|
1993
1954
|
role: "slider",
|
1994
1955
|
tabIndex: 0,
|
1995
|
-
ariaValueMin: `${
|
1956
|
+
ariaValueMin: `${P}`,
|
1996
1957
|
ariaValueMax: `${M}`
|
1997
1958
|
});
|
1998
|
-
|
1959
|
+
T.append(A), g.append(T);
|
1999
1960
|
}), g;
|
2000
|
-
},
|
2001
|
-
const { input: s, format: r, componentLabels: n } = o, { defaultsLabel: i, presetsLabel: a } = n, l = e === "color-options", c = t instanceof
|
1961
|
+
}, oe = (o, t, e) => {
|
1962
|
+
const { input: s, format: r, componentLabels: n } = o, { defaultsLabel: i, presetsLabel: a } = n, l = e === "color-options", c = t instanceof Ot, 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
1963
|
let f = 2;
|
2003
1964
|
f = p && u > g * 2 ? 3 : f, f = p && u > g * 3 ? 4 : f, f = p && u > g * 4 ? 5 : f;
|
2004
|
-
const
|
1965
|
+
const $ = f - (u <= g * 3 ? 1 : 2), w = p && u > $ * g;
|
2005
1966
|
let S = e;
|
2006
|
-
S +=
|
1967
|
+
S += w ? " scrollable" : "", S += p ? " multiline" : "";
|
2007
1968
|
const L = p ? "1px" : "0.25rem";
|
2008
|
-
let
|
2009
|
-
|
2010
|
-
const
|
1969
|
+
let C = p ? 1.75 : 2;
|
1970
|
+
C = g > 5 && p ? 1.5 : C;
|
1971
|
+
const P = `${$ * C}rem`, M = `calc(${f} * ${C}rem + ${f - 1} * ${L})`, T = x({
|
2011
1972
|
tagName: "ul",
|
2012
1973
|
className: S,
|
2013
1974
|
role: "listbox",
|
2014
1975
|
ariaLabel: h
|
2015
1976
|
});
|
2016
|
-
return
|
2017
|
-
"--grid-item-size": `${
|
1977
|
+
return w && D(T, {
|
1978
|
+
"--grid-item-size": `${C}rem`,
|
2018
1979
|
"--grid-fit": `${g}`,
|
2019
1980
|
"--grid-gap": L,
|
2020
|
-
"--grid-height":
|
1981
|
+
"--grid-height": P,
|
2021
1982
|
"--grid-hover-height": M
|
2022
1983
|
}), b.forEach((A) => {
|
2023
|
-
let [F,
|
2024
|
-
A instanceof y && (F = A.toHexString(),
|
2025
|
-
const
|
1984
|
+
let [F, Y] = typeof A == "string" ? A.trim().split(":") : [];
|
1985
|
+
A instanceof y && (F = A.toHexString(), Y = F);
|
1986
|
+
const Bt = new y(A instanceof y ? A : F, r).toString() === vt(s, "value"), $t = x({
|
2026
1987
|
tagName: "li",
|
2027
|
-
className: `color-option${
|
2028
|
-
innerText: `${
|
1988
|
+
className: `color-option${Bt ? " active" : ""}`,
|
1989
|
+
innerText: `${Y || F}`,
|
2029
1990
|
tabIndex: 0,
|
2030
1991
|
role: "option",
|
2031
|
-
ariaSelected:
|
1992
|
+
ariaSelected: Bt ? "true" : "false"
|
2032
1993
|
});
|
2033
|
-
|
2034
|
-
}),
|
2035
|
-
},
|
2036
|
-
const {
|
1994
|
+
v($t, "data-value", `${F}`), l && D($t, { backgroundColor: F }), T.append($t);
|
1995
|
+
}), T;
|
1996
|
+
}, no = (o) => {
|
1997
|
+
const {
|
1998
|
+
input: t,
|
1999
|
+
parent: e,
|
2000
|
+
format: s,
|
2001
|
+
id: r,
|
2002
|
+
componentLabels: n,
|
2003
|
+
colorKeywords: i,
|
2004
|
+
colorPresets: a
|
2005
|
+
} = o, l = vt(t, "value") || "#fff", { nonColors: c } = y, { toggleLabel: h, pickerLabel: b, formatLabel: u, hexLabel: d } = n, g = c.includes(l) ? "#fff" : l;
|
2037
2006
|
o.color = new y(g, s);
|
2038
|
-
const p = s === "hex" ? d :
|
2007
|
+
const p = s === "hex" ? d : he(s), f = x({
|
2039
2008
|
id: `picker-btn-${r}`,
|
2040
2009
|
tagName: "button",
|
2041
2010
|
type: "button",
|
@@ -2046,81 +2015,91 @@ const Kt = {
|
|
2046
2015
|
f.append(
|
2047
2016
|
x({
|
2048
2017
|
tagName: "span",
|
2049
|
-
className:
|
2018
|
+
className: Ft,
|
2050
2019
|
innerText: `${b}. ${u}: ${p}`
|
2051
2020
|
})
|
2052
2021
|
);
|
2053
|
-
const
|
2054
|
-
|
2055
|
-
|
2056
|
-
|
2057
|
-
|
2058
|
-
|
2059
|
-
|
2022
|
+
const $ = x(
|
2023
|
+
{
|
2024
|
+
tagName: "div",
|
2025
|
+
className: "color-dropdown picker",
|
2026
|
+
role: "group",
|
2027
|
+
ariaLabelledBy: `picker-btn-${r}`
|
2028
|
+
}
|
2029
|
+
), w = ro(o), S = so(o);
|
2030
|
+
if ($.append(w, S), t.before(f), e.append($), i || a) {
|
2060
2031
|
const L = x({
|
2061
2032
|
tagName: "div",
|
2062
2033
|
className: "color-dropdown scrollable menu"
|
2063
2034
|
});
|
2064
|
-
a && L.append(
|
2065
|
-
|
2035
|
+
a && L.append(oe(o, a, "color-options")), i && i.length && L.append(
|
2036
|
+
oe(o, i, "color-defaults")
|
2037
|
+
);
|
2038
|
+
const C = x({
|
2066
2039
|
tagName: "button",
|
2067
2040
|
type: "button",
|
2068
2041
|
className: "menu-toggle btn-appearance",
|
2069
2042
|
tabIndex: -1,
|
2070
2043
|
ariaExpanded: "false",
|
2071
2044
|
ariaHasPopup: "true"
|
2072
|
-
}),
|
2045
|
+
}), P = encodeURI("http://www.w3.org/2000/svg"), M = Ht(P, {
|
2073
2046
|
tagName: "svg"
|
2074
2047
|
});
|
2075
|
-
|
2076
|
-
const
|
2048
|
+
v(M, "xmlns", P), v(M, "viewBox", "0 0 512 512"), v(M, Ae, "true");
|
2049
|
+
const T = Ht(P, {
|
2077
2050
|
tagName: "path"
|
2078
2051
|
});
|
2079
|
-
|
2052
|
+
v(
|
2053
|
+
T,
|
2054
|
+
"d",
|
2055
|
+
"M98,158l157,156L411,158l27,27L255,368L71,185L98,158z"
|
2056
|
+
), v(T, "fill", "#fff"), M.append(T), C.append(
|
2080
2057
|
x({
|
2081
2058
|
tagName: "span",
|
2082
|
-
className:
|
2059
|
+
className: Ft,
|
2083
2060
|
innerText: `${h}`
|
2084
2061
|
}),
|
2085
2062
|
M
|
2086
|
-
), e.append(
|
2063
|
+
), e.append(C, L);
|
2087
2064
|
}
|
2088
|
-
i && c.includes(l) && (o.value = l),
|
2089
|
-
},
|
2090
|
-
componentLabels:
|
2065
|
+
i && c.includes(l) && (o.value = l), v(t, Z, "-1");
|
2066
|
+
}, io = "2.0.3", Q = "color-picker", ao = `[data-function="${Q}"]`, se = `.${Q}`, lo = {
|
2067
|
+
componentLabels: Dt,
|
2091
2068
|
colorLabels: it,
|
2092
2069
|
format: "rgb",
|
2093
2070
|
colorPresets: !1,
|
2094
2071
|
colorKeywords: !1
|
2095
|
-
}, { roundPart: k, nonColors: bt } = y,
|
2096
|
-
const e = t ?
|
2097
|
-
e(s,
|
2098
|
-
},
|
2099
|
-
const e = t ?
|
2100
|
-
e(o.controls,
|
2101
|
-
|
2102
|
-
|
2103
|
-
},
|
2072
|
+
}, { roundPart: k, nonColors: bt } = y, co = (o) => je(o, Q), ho = (o) => new go(o), re = (o, t) => {
|
2073
|
+
const e = t ? ae : le, { input: s, pickerToggle: r, menuToggle: n } = o;
|
2074
|
+
e(s, Ne, o.showPicker), e(r, At, o.togglePicker), n && e(n, At, o.toggleMenu);
|
2075
|
+
}, Pe = (o, t) => {
|
2076
|
+
const e = t ? ae : le, { input: s, colorMenu: r, parent: n } = o, i = K(s), a = Je(i);
|
2077
|
+
e(o.controls, Me, o.pointerDown), o.controlKnobs.forEach((l) => e(l, qt, o.handleKnobs)), e(a, De, o.handleScroll), e(a, Oe, o.update), [s, ...o.inputs].forEach(
|
2078
|
+
(l) => e(l, He, o.changeHandler)
|
2079
|
+
), r && (e(r, At, o.menuClickHandler), e(r, qt, o.menuKeyHandler)), e(i, ie, o.pointerMove), e(i, Re, o.pointerUp), e(n, Ee, o.handleFocusOut), e(i, Te, o.handleDismiss);
|
2080
|
+
}, ne = (o) => {
|
2081
|
+
We(o.input, new CustomEvent("colorpicker.change"));
|
2082
|
+
}, Le = (o) => {
|
2104
2083
|
o && ["bottom", "top"].forEach((t) => O(o, t));
|
2105
|
-
},
|
2084
|
+
}, Pt = (o, t) => {
|
2106
2085
|
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
|
-
|
2086
|
+
R(i, "open") || j(i, "open"), l && (O(l, "show"), Le(l)), j(t, "bottom"), ze(t), j(t, "show"), a && o.update(), o.isOpen || (Pe(o, !0), o.updateDropdownPosition(), o.isOpen = !0, v(o.input, Z, "0"), r && v(r, Z, "0")), v(h, Lt, "true"), c && v(c, Lt, "false");
|
2108
2087
|
};
|
2109
|
-
class
|
2088
|
+
class go {
|
2110
2089
|
// bring utils to staic
|
2111
2090
|
static Color = y;
|
2112
|
-
static ColorPalette =
|
2113
|
-
static getInstance =
|
2114
|
-
static init =
|
2115
|
-
static selector =
|
2091
|
+
static ColorPalette = Ot;
|
2092
|
+
static getInstance = co;
|
2093
|
+
static init = ho;
|
2094
|
+
static selector = ao;
|
2116
2095
|
// utils important for render
|
2117
2096
|
static roundPart = k;
|
2118
2097
|
static setElementStyle = D;
|
2119
|
-
static setAttribute =
|
2098
|
+
static setAttribute = v;
|
2120
2099
|
static getBoundingClientRect = gt;
|
2121
|
-
static version =
|
2100
|
+
static version = io;
|
2122
2101
|
static colorNames = it;
|
2123
|
-
static colorPickerLabels =
|
2102
|
+
static colorPickerLabels = Dt;
|
2124
2103
|
id;
|
2125
2104
|
input;
|
2126
2105
|
color;
|
@@ -2129,7 +2108,9 @@ class mo {
|
|
2129
2108
|
dragElement;
|
2130
2109
|
isOpen = !1;
|
2131
2110
|
controlPositions;
|
2132
|
-
colorLabels =
|
2111
|
+
colorLabels = Ut(
|
2112
|
+
it.map((t) => [t, t])
|
2113
|
+
);
|
2133
2114
|
colorKeywords;
|
2134
2115
|
colorPresets;
|
2135
2116
|
componentLabels;
|
@@ -2149,37 +2130,73 @@ class mo {
|
|
2149
2130
|
* @param config instance options
|
2150
2131
|
*/
|
2151
2132
|
constructor(t, e) {
|
2152
|
-
const s =
|
2153
|
-
if (typeof t > "u")
|
2154
|
-
|
2133
|
+
const s = _(t);
|
2134
|
+
if (typeof t > "u")
|
2135
|
+
throw new TypeError("ColorPicker target not specified.");
|
2136
|
+
if (!ge(s))
|
2137
|
+
throw new TypeError(`ColorPicker target "${t}" cannot be found.`);
|
2155
2138
|
this.input = s;
|
2156
|
-
const r =
|
2157
|
-
if (!r)
|
2158
|
-
|
2139
|
+
const r = be(s, se);
|
2140
|
+
if (!r)
|
2141
|
+
throw new TypeError("ColorPicker requires a specific markup to work.");
|
2142
|
+
this.parent = r, this.id = ue(s, Q), this.dragElement = void 0, this.isOpen = !1, this.controlPositions = {
|
2159
2143
|
c1x: 0,
|
2160
2144
|
c1y: 0,
|
2161
2145
|
c2y: 0,
|
2162
2146
|
c3y: 0
|
2163
2147
|
}, this.colorKeywords = !1, this.colorPresets = !1;
|
2164
|
-
const {
|
2148
|
+
const {
|
2149
|
+
format: n,
|
2150
|
+
componentLabels: i,
|
2151
|
+
colorLabels: a,
|
2152
|
+
colorKeywords: l,
|
2153
|
+
colorPresets: c
|
2154
|
+
} = _e(
|
2165
2155
|
s,
|
2166
|
-
|
2156
|
+
lo,
|
2167
2157
|
e || {}
|
2168
2158
|
);
|
2169
2159
|
let h = it;
|
2170
|
-
|
2171
|
-
|
2172
|
-
|
2160
|
+
xt(a) && a.length === 17 ? h = a : q(a) && a.split(",").length === 17 && (h = a.split(",")), V(
|
2161
|
+
this.colorLabels,
|
2162
|
+
Ut(
|
2163
|
+
h.map((p, f) => [it[f], p])
|
2164
|
+
)
|
2165
|
+
);
|
2166
|
+
const b = q(i) && ee(i) ? JSON.parse(i) : i;
|
2167
|
+
if (this.componentLabels = V(
|
2168
|
+
{ ...Dt },
|
2169
|
+
b
|
2170
|
+
), this.color = new y(s.value || "#fff", n), this.format = n, xt(l) && l.length ? this.colorKeywords = l : q(l) && l.length && (this.colorKeywords = l.split(",").map((p) => p.trim())), xt(c) && c.length)
|
2173
2171
|
this.colorPresets = c;
|
2174
|
-
else if (c &&
|
2175
|
-
const { hue: p, hueSteps: f, lightSteps:
|
2176
|
-
|
2177
|
-
|
2178
|
-
|
2179
|
-
|
2180
|
-
|
2181
|
-
|
2182
|
-
|
2172
|
+
else if (c && ee(c)) {
|
2173
|
+
const { hue: p, hueSteps: f, lightSteps: $, saturation: w } = JSON.parse(
|
2174
|
+
c
|
2175
|
+
);
|
2176
|
+
this.colorPresets = new Ot(
|
2177
|
+
p,
|
2178
|
+
f,
|
2179
|
+
$,
|
2180
|
+
w
|
2181
|
+
);
|
2182
|
+
} else q(c) && (this.colorPresets = c.split(",").map((p) => p.trim()));
|
2183
|
+
no(this);
|
2184
|
+
const [u, d] = st(
|
2185
|
+
"color-dropdown",
|
2186
|
+
r
|
2187
|
+
);
|
2188
|
+
this.pickerToggle = _(".picker-toggle", r), this.menuToggle = _(".menu-toggle", r), this.colorPicker = u, this.colorMenu = d, this.inputs = [
|
2189
|
+
...st("color-input", r)
|
2190
|
+
];
|
2191
|
+
const [g] = st(
|
2192
|
+
"color-controls",
|
2193
|
+
r
|
2194
|
+
);
|
2195
|
+
this.controls = g, this.controlKnobs = [
|
2196
|
+
...st("knob", g)
|
2197
|
+
], this.visuals = [
|
2198
|
+
...st("visual-control", g)
|
2199
|
+
], this.update(), re(this, !0), lt.set(s, Q, this);
|
2183
2200
|
}
|
2184
2201
|
/** Returns the current colour value */
|
2185
2202
|
get value() {
|
@@ -2257,10 +2274,10 @@ class mo {
|
|
2257
2274
|
}
|
2258
2275
|
/** Updates `ColorPicker` visuals. */
|
2259
2276
|
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:
|
2277
|
+
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({
|
2278
|
+
h: a * 360,
|
2279
|
+
s: 100,
|
2280
|
+
l: 50,
|
2264
2281
|
a: u
|
2265
2282
|
}).toRgbString(), p = `linear-gradient(
|
2266
2283
|
rgb(255,0,0) 0%, rgb(255,255,0) 16.67%,
|
@@ -2291,7 +2308,7 @@ class mo {
|
|
2291
2308
|
* @this {ColorPicker}
|
2292
2309
|
*/
|
2293
2310
|
handleDismiss = ({ code: t }) => {
|
2294
|
-
this.isOpen && t ===
|
2311
|
+
this.isOpen && t === Ve && this.hide();
|
2295
2312
|
};
|
2296
2313
|
/**
|
2297
2314
|
* The `ColorPicker` *scroll* event listener when open.
|
@@ -2299,8 +2316,8 @@ class mo {
|
|
2299
2316
|
* @param e
|
2300
2317
|
*/
|
2301
2318
|
handleScroll = (t) => {
|
2302
|
-
const { activeElement: e } =
|
2303
|
-
this.updateDropdownPosition(), ([
|
2319
|
+
const { activeElement: e } = K(this.input);
|
2320
|
+
this.updateDropdownPosition(), ([ie, Fe].includes(t.type) && this.dragElement || e && this.controlKnobs.includes(e)) && (t.stopPropagation(), t.preventDefault());
|
2304
2321
|
};
|
2305
2322
|
/**
|
2306
2323
|
* The `ColorPicker` keyboard event listener for menu navigation.
|
@@ -2308,8 +2325,8 @@ class mo {
|
|
2308
2325
|
* @param e
|
2309
2326
|
*/
|
2310
2327
|
menuKeyHandler = (t) => {
|
2311
|
-
const { target: e, code: s } = t, { previousElementSibling: r, nextElementSibling: n, parentElement: i } = e, a = i &&
|
2312
|
-
[
|
2328
|
+
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(Nt(i, "--grid-fit")), h = l.indexOf(e), b = h > -1 && c && l[h - c], u = h > -1 && c && l[h + c];
|
2329
|
+
[B, ot, Gt].includes(s) && t.preventDefault(), a ? b && s === ot ? U(b) : u && s === B ? U(u) : r && s === ht ? U(r) : n && s === W && U(n) : r && [ht, ot].includes(s) ? U(r) : n && [W, B].includes(s) && U(n), [Ie, Gt].includes(s) && this.menuClickHandler(t);
|
2313
2330
|
};
|
2314
2331
|
/**
|
2315
2332
|
* The `ColorPicker` click event listener for the colour menu presets / defaults.
|
@@ -2318,18 +2335,21 @@ class mo {
|
|
2318
2335
|
* @this {ColorPicker}
|
2319
2336
|
*/
|
2320
2337
|
menuClickHandler = (t) => {
|
2321
|
-
const { target: e } = t, { colorMenu: s } = this, r = (
|
2338
|
+
const { target: e } = t, { colorMenu: s } = this, r = (vt(
|
2339
|
+
e,
|
2340
|
+
"data-value"
|
2341
|
+
) || "").trim();
|
2322
2342
|
if (!r.length) return;
|
2323
|
-
const n =
|
2343
|
+
const n = _("li.active", s);
|
2324
2344
|
let i = r;
|
2325
2345
|
i = bt.includes(i) ? "white" : i, i = i === "transparent" ? "rgba(0,0,0,0)" : i;
|
2326
2346
|
const { r: a, g: l, b: c, a: h } = new y(i);
|
2327
|
-
|
2347
|
+
V(this.color, {
|
2328
2348
|
r: a,
|
2329
2349
|
g: l,
|
2330
2350
|
b: c,
|
2331
2351
|
a: h
|
2332
|
-
}), this.update(), n !== e && (n && (O(n, "active"),
|
2352
|
+
}), this.update(), n !== e && (n && (O(n, "active"), kt(n, wt)), j(e, "active"), v(e, wt, "true"), bt.includes(r) && (this.value = r), ne(this));
|
2333
2353
|
};
|
2334
2354
|
/**
|
2335
2355
|
* The `ColorPicker` *touchstart* / *mousedown* events listener for control knobs.
|
@@ -2338,10 +2358,10 @@ class mo {
|
|
2338
2358
|
*/
|
2339
2359
|
pointerDown = (t) => {
|
2340
2360
|
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 S =
|
2344
|
-
S && (O(S, "active"),
|
2361
|
+
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 = yt(l), $ = s - f.scrollLeft - p.left, w = r - f.scrollTop - p.top;
|
2362
|
+
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) {
|
2363
|
+
const S = _("li.active", n);
|
2364
|
+
S && (O(S, "active"), kt(S, wt));
|
2345
2365
|
}
|
2346
2366
|
t.preventDefault();
|
2347
2367
|
};
|
@@ -2352,7 +2372,7 @@ class mo {
|
|
2352
2372
|
* @this
|
2353
2373
|
*/
|
2354
2374
|
pointerUp = ({ target: t }) => {
|
2355
|
-
const { parent: e } = this, s =
|
2375
|
+
const { parent: e } = this, s = K(e), r = _(`${se}.open`, s) !== null, n = s.getSelection();
|
2356
2376
|
!this.dragElement && (!n || !n.toString().length) && !e.contains(t) && this.hide(r), this.dragElement = void 0;
|
2357
2377
|
};
|
2358
2378
|
/**
|
@@ -2363,7 +2383,7 @@ class mo {
|
|
2363
2383
|
pointerMove = (t) => {
|
2364
2384
|
const { dragElement: e, visuals: s } = this, [r, n, i] = s, { pageX: a, pageY: l } = t;
|
2365
2385
|
if (!e) return;
|
2366
|
-
const c = gt(e), h =
|
2386
|
+
const c = gt(e), h = yt(r), b = a - h.scrollLeft - c.left, u = l - h.scrollTop - c.top;
|
2367
2387
|
e === r && this.changeControl1(b, u), e === n && this.changeControl2(u), e === i && this.changeAlpha(u);
|
2368
2388
|
};
|
2369
2389
|
/**
|
@@ -2373,45 +2393,52 @@ class mo {
|
|
2373
2393
|
*/
|
2374
2394
|
handleKnobs = (t) => {
|
2375
2395
|
const { target: e, code: s } = t;
|
2376
|
-
if (![ot,
|
2396
|
+
if (![ot, B, ht, W].includes(s)) return;
|
2377
2397
|
t.preventDefault();
|
2378
|
-
const { controlKnobs: r, visuals: n } = this, { offsetWidth: i, offsetHeight: a } = n[0], [l, c, h] = r, { activeElement: b } =
|
2398
|
+
const { controlKnobs: r, visuals: n } = this, { offsetWidth: i, offsetHeight: a } = n[0], [l, c, h] = r, { activeElement: b } = K(l), u = r.find((g) => g === b), d = a / 360;
|
2379
2399
|
if (u) {
|
2380
2400
|
let g = 0, p = 0;
|
2381
2401
|
if (e === l) {
|
2382
2402
|
const f = i / 100;
|
2383
|
-
[ht,
|
2384
|
-
} else e === c ? (this.controlPositions.c2y += [
|
2403
|
+
[ht, W].includes(s) ? this.controlPositions.c1x += s === W ? f : -f : [ot, B].includes(s) && (this.controlPositions.c1y += s === B ? d : -d), g = this.controlPositions.c1x, p = this.controlPositions.c1y, this.changeControl1(g, p);
|
2404
|
+
} else e === c ? (this.controlPositions.c2y += [B, W].includes(s) ? d : -d, p = this.controlPositions.c2y, this.changeControl2(p)) : e === h && (this.controlPositions.c3y += [B, W].includes(s) ? d : -d, p = this.controlPositions.c3y, this.changeAlpha(p));
|
2385
2405
|
this.handleScroll(t);
|
2386
2406
|
}
|
2387
2407
|
};
|
2388
2408
|
/** The event listener of the colour form inputs. */
|
2389
2409
|
changeHandler = () => {
|
2390
2410
|
let t;
|
2391
|
-
const {
|
2411
|
+
const {
|
2412
|
+
inputs: e,
|
2413
|
+
format: s,
|
2414
|
+
value: r,
|
2415
|
+
input: n,
|
2416
|
+
controlPositions: i,
|
2417
|
+
visuals: a
|
2418
|
+
} = this, { activeElement: l } = K(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
2419
|
if (l === n || l && e.includes(l)) {
|
2393
2420
|
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
2421
|
h: u,
|
2395
2422
|
s: d,
|
2396
2423
|
l: g,
|
2397
|
-
a:
|
2424
|
+
a: $
|
2398
2425
|
} : s === "hwb" ? t = {
|
2399
2426
|
h: u,
|
2400
2427
|
w: d,
|
2401
2428
|
b: g,
|
2402
|
-
a:
|
2429
|
+
a: $
|
2403
2430
|
} : t = {
|
2404
2431
|
r: u,
|
2405
2432
|
g: d,
|
2406
2433
|
b: g,
|
2407
|
-
a:
|
2434
|
+
a: $
|
2408
2435
|
};
|
2409
|
-
const { r:
|
2410
|
-
|
2411
|
-
r:
|
2436
|
+
const { r: w, g: S, b: L, a: C } = new y(t);
|
2437
|
+
V(this.color, {
|
2438
|
+
r: w,
|
2412
2439
|
g: S,
|
2413
2440
|
b: L,
|
2414
|
-
a:
|
2441
|
+
a: C
|
2415
2442
|
}), this.setControlPositions(), this.updateAppearance(), this.updateInputs(), this.updateControls(), this.updateVisuals(), l === n && f && (this.value = r);
|
2416
2443
|
}
|
2417
2444
|
};
|
@@ -2428,12 +2455,12 @@ class mo {
|
|
2428
2455
|
const { controlPositions: n, visuals: i } = this, { offsetHeight: a, offsetWidth: l } = i[0];
|
2429
2456
|
t > l ? s = l : t >= 0 && (s = t), e > a ? r = a : e >= 0 && (r = e);
|
2430
2457
|
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,
|
2458
|
+
h: c * 360,
|
2459
|
+
s: h * 100,
|
2460
|
+
v: b * 100,
|
2434
2461
|
a: u
|
2435
2462
|
});
|
2436
|
-
|
2463
|
+
V(this.color, {
|
2437
2464
|
r: d,
|
2438
2465
|
g,
|
2439
2466
|
b: p,
|
@@ -2452,12 +2479,12 @@ class mo {
|
|
2452
2479
|
let i = 0;
|
2453
2480
|
t > r ? i = r : t >= 0 && (i = t);
|
2454
2481
|
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,
|
2482
|
+
h: a * 360,
|
2483
|
+
s: l * 100,
|
2484
|
+
v: c * 100,
|
2458
2485
|
a: h
|
2459
2486
|
});
|
2460
|
-
|
2487
|
+
V(this.color, {
|
2461
2488
|
r: b,
|
2462
2489
|
g: u,
|
2463
2490
|
b: d,
|
@@ -2487,10 +2514,10 @@ class mo {
|
|
2487
2514
|
};
|
2488
2515
|
/** Updates the open dropdown position on *scroll* event. */
|
2489
2516
|
updateDropdownPosition() {
|
2490
|
-
const { input: t, colorPicker: e, colorMenu: s } = this, r = gt(t), { top: n, bottom: i } = r, { offsetHeight: a } = t, l =
|
2517
|
+
const { input: t, colorPicker: e, colorMenu: s } = this, r = gt(t), { top: n, bottom: i } = r, { offsetHeight: a } = t, l = yt(t).clientHeight, h = R(e, "show") ? e : s;
|
2491
2518
|
if (!h) return;
|
2492
2519
|
const { offsetHeight: b } = h, u = l - i, d = n, g = n + b + a > l, p = n - b < 0;
|
2493
|
-
(
|
2520
|
+
(R(h, "bottom") || !p) && u < d && g ? (O(h, "bottom"), j(h, "top")) : (O(h, "top"), j(h, "bottom"));
|
2494
2521
|
}
|
2495
2522
|
/** Updates control knobs' positions. */
|
2496
2523
|
setControlPositions() {
|
@@ -2501,17 +2528,25 @@ class mo {
|
|
2501
2528
|
updateAppearance() {
|
2502
2529
|
const { componentLabels: t, color: e, parent: s, hsv: r, hex: n, format: i, controlKnobs: a } = this, { appearanceLabel: l, hexLabel: c, valueLabel: h } = t;
|
2503
2530
|
let { r: b, g: u, b: d } = e.toRgb();
|
2504
|
-
const [g, p, f] = a,
|
2505
|
-
let
|
2531
|
+
const [g, p, f] = a, $ = k(r.h * 360), w = e.a, S = k(r.s * 100), L = k(r.v * 100), C = this.appearance;
|
2532
|
+
let P = `${c} ${n.split("").join(" ")}`;
|
2506
2533
|
if (i === "hwb") {
|
2507
|
-
const { hwb: A } = this, F = k(A.w * 100),
|
2508
|
-
|
2534
|
+
const { hwb: A } = this, F = k(A.w * 100), Y = k(A.b * 100);
|
2535
|
+
P = `HWB: ${$}°, ${F}%, ${Y}%`, v(g, et, `${F}% & ${Y}%`), v(g, tt, `${F}`), v(
|
2536
|
+
p,
|
2537
|
+
jt,
|
2538
|
+
`${h}: ${P}. ${l}: ${C}.`
|
2539
|
+
), v(p, et, `${$}%`), v(p, tt, `${$}`);
|
2509
2540
|
} else
|
2510
|
-
[b, u, d] = [b, u, d].map(k),
|
2511
|
-
|
2512
|
-
|
2513
|
-
|
2514
|
-
|
2541
|
+
[b, u, d] = [b, u, d].map(k), P = i === "hsl" ? `HSL: ${$}°, ${S}%, ${L}%` : P, P = i === "rgb" ? `RGB: ${b}, ${u}, ${d}` : P, v(g, et, `${L}% & ${S}%`), v(g, tt, `${L}`), v(
|
2542
|
+
p,
|
2543
|
+
jt,
|
2544
|
+
`${h}: ${P}. ${l}: ${C}.`
|
2545
|
+
), v(p, et, `${$}°`), v(p, tt, `${$}`);
|
2546
|
+
const M = k(w * 100);
|
2547
|
+
v(f, et, `${M}%`), v(f, tt, `${M}`);
|
2548
|
+
const T = e.toString();
|
2549
|
+
D(this.input, { backgroundColor: T }), this.isDark ? (R(s, "txt-light") && O(s, "txt-light"), R(s, "txt-dark") || j(s, "txt-dark")) : (R(s, "txt-dark") && O(s, "txt-dark"), R(s, "txt-light") || j(s, "txt-light"));
|
2515
2550
|
}
|
2516
2551
|
/** Updates the control knobs actual positions. */
|
2517
2552
|
updateControls() {
|
@@ -2536,13 +2571,13 @@ class mo {
|
|
2536
2571
|
const g = k(i.l * 100), p = k(i.s * 100);
|
2537
2572
|
d = this.color.toHslString(), a.value = `${u}`, l.value = `${p}`, c.value = `${g}`, h.value = `${b}`;
|
2538
2573
|
} 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 = `${
|
2574
|
+
const { w: g, b: p } = this.hwb, f = k(g * 100), $ = k(p * 100);
|
2575
|
+
d = this.color.toHwbString(), a.value = `${u}`, l.value = `${f}`, c.value = `${$}`, h.value = `${b}`;
|
2541
2576
|
} else if (s === "rgb") {
|
2542
2577
|
let { r: g, g: p, b: f } = this.rgb;
|
2543
2578
|
[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
2579
|
}
|
2545
|
-
this.value = d, !t && d !== e &&
|
2580
|
+
this.value = d, !t && d !== e && ne(this);
|
2546
2581
|
}
|
2547
2582
|
/**
|
2548
2583
|
* Toggle the `ColorPicker` dropdown visibility.
|
@@ -2552,12 +2587,12 @@ class mo {
|
|
2552
2587
|
togglePicker = (t) => {
|
2553
2588
|
t && t.preventDefault();
|
2554
2589
|
const { colorPicker: e } = this;
|
2555
|
-
this.isOpen &&
|
2590
|
+
this.isOpen && R(e, "show") ? this.hide(!0) : Pt(this, e);
|
2556
2591
|
};
|
2557
2592
|
/** Shows the `ColorPicker` dropdown. */
|
2558
2593
|
showPicker = () => {
|
2559
2594
|
const { colorPicker: t } = this;
|
2560
|
-
["top", "bottom"].some((e) =>
|
2595
|
+
["top", "bottom"].some((e) => R(t, e)) || Pt(this, t);
|
2561
2596
|
};
|
2562
2597
|
/**
|
2563
2598
|
* Toggles the visibility of the `ColorPicker` presets menu.
|
@@ -2568,7 +2603,7 @@ class mo {
|
|
2568
2603
|
toggleMenu = (t) => {
|
2569
2604
|
t && t.preventDefault();
|
2570
2605
|
const { colorMenu: e } = this;
|
2571
|
-
this.isOpen &&
|
2606
|
+
this.isOpen && R(e, "show") ? this.hide(!0) : Pt(this, e);
|
2572
2607
|
};
|
2573
2608
|
/**
|
2574
2609
|
* Hides the currently open `ColorPicker` dropdown.
|
@@ -2576,22 +2611,28 @@ class mo {
|
|
2576
2611
|
* @param {boolean=} focusPrevented
|
2577
2612
|
*/
|
2578
2613
|
hide(t) {
|
2579
|
-
if (this.isOpen)
|
2580
|
-
|
2581
|
-
|
2582
|
-
|
2583
|
-
|
2584
|
-
|
2614
|
+
if (!this.isOpen) return;
|
2615
|
+
const {
|
2616
|
+
pickerToggle: e,
|
2617
|
+
menuToggle: s,
|
2618
|
+
colorPicker: r,
|
2619
|
+
colorMenu: n,
|
2620
|
+
parent: i,
|
2621
|
+
input: a
|
2622
|
+
} = this, l = R(r, "show"), c = l ? r : n, h = l ? e : s, b = c && Ue(c);
|
2623
|
+
this.value = this.color.toString(!0), c && (O(c, "show"), v(h, Lt, "false"), setTimeout(() => {
|
2624
|
+
Le(c), _(".show", i) || (O(i, "open"), Pe(this), this.isOpen = !1);
|
2625
|
+
}, b)), t || U(e), v(a, Z, "-1"), h === s && v(s, Z, "-1");
|
2585
2626
|
}
|
2586
2627
|
/** Removes `ColorPicker` from target `<input>`. */
|
2587
2628
|
dispose() {
|
2588
2629
|
const { input: t, parent: e } = this;
|
2589
|
-
this.hide(!0),
|
2630
|
+
this.hide(!0), re(this), [...e.children].forEach((s) => {
|
2590
2631
|
s !== t && s.remove();
|
2591
|
-
}),
|
2632
|
+
}), kt(t, Z), D(t, { backgroundColor: "" }), ["txt-light", "txt-dark"].forEach((s) => O(e, s)), lt.remove(t, Q);
|
2592
2633
|
}
|
2593
2634
|
}
|
2594
2635
|
export {
|
2595
|
-
|
2636
|
+
go as default
|
2596
2637
|
};
|
2597
2638
|
//# sourceMappingURL=color-picker.mjs.map
|