@thednp/color-picker 2.0.0-alpha8 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.cjs +0 -0
- package/.lgtm.yml +0 -0
- package/.prettierrc.json +0 -0
- package/.stylelintrc.json +0 -0
- package/LICENSE +0 -0
- package/README.md +5 -5
- package/compile.js +6 -3
- package/cypress/e2e/color-palette.cy.ts +0 -0
- package/cypress/e2e/color-picker.cy.ts +58 -69
- package/cypress/fixtures/colorNamesFrench.js +0 -0
- package/cypress/fixtures/componentLabelsFrench.js +0 -0
- package/cypress/fixtures/format.js +0 -0
- package/cypress/fixtures/getMarkup.js +8 -1
- package/cypress/fixtures/getRandomInt.js +0 -0
- package/cypress/fixtures/sampleWebcolors.js +0 -0
- package/cypress/fixtures/testSample.js +0 -0
- package/cypress/plugins/esbuild-istanbul.ts +0 -0
- package/cypress/plugins/tsCompile.ts +0 -0
- package/cypress/support/commands.ts +0 -0
- package/cypress/support/e2e.ts +0 -0
- package/cypress/test.html +0 -0
- package/cypress.config.ts +0 -0
- package/dist/css/color-picker.css +7 -15
- package/dist/css/color-picker.min.css +2 -2
- package/dist/css/color-picker.rtl.css +7 -15
- 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.d.ts +34 -14
- package/dist/js/color-picker.js +2 -2
- package/dist/js/color-picker.js.map +1 -1
- package/dist/js/color-picker.mjs +278 -314
- package/dist/js/color-picker.mjs.map +1 -1
- package/dts.config.ts +0 -0
- package/package.json +117 -114
- package/src/scss/_variables.scss +0 -0
- package/src/scss/color-picker.rtl.scss +0 -0
- package/src/scss/color-picker.scss +10 -12
- package/src/ts/colorPalette.ts +0 -0
- package/src/ts/index.ts +15 -15
- package/src/ts/interface/ColorNames.ts +20 -0
- package/src/ts/interface/colorPickerLabels.ts +0 -0
- package/src/ts/interface/colorPickerOptions.ts +0 -0
- package/src/ts/interface/paletteOptions.ts +0 -0
- package/src/ts/util/colorNames.ts +0 -0
- package/src/ts/util/colorPickerLabels.ts +0 -0
- package/src/ts/util/getColorControls.ts +0 -0
- package/src/ts/util/getColorForm.ts +0 -0
- package/src/ts/util/getColorMenu.ts +0 -0
- package/src/ts/util/isValidJSON.ts +0 -0
- package/src/ts/util/setMarkup.ts +6 -4
- package/src/ts/util/vHidden.ts +0 -0
- package/tsconfig.json +1 -1
- package/vite.config.ts +0 -0
- package/cypress/fixtures/getCEMarkup.js +0 -29
package/dist/js/color-picker.mjs
CHANGED
@@ -1,41 +1,25 @@
|
|
1
|
-
const
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
n.apply(s, [o]), typeof i == "object" && i.once && jt(s, t, n, i);
|
6
|
-
});
|
7
|
-
});
|
8
|
-
}, ue = (o, t, e, s) => {
|
9
|
-
J[t] || (J[t] = /* @__PURE__ */ new Map());
|
10
|
-
const r = J[t];
|
11
|
-
r.has(o) || r.set(o, /* @__PURE__ */ new Map());
|
12
|
-
const n = r.get(o), { size: i } = n;
|
13
|
-
n.set(e, s), i || o.addEventListener(t, ge, s);
|
14
|
-
}, jt = (o, t, e, s) => {
|
15
|
-
const r = J[t], n = r && r.get(o), i = n && n.get(e), a = i !== void 0 ? i : s;
|
16
|
-
n && n.has(e) && n.delete(e), r && (!n || !n.size) && r.delete(o), (!r || !r.size) && delete J[t], (!n || !n.size) && o.removeEventListener(t, ge, a);
|
17
|
-
}, Ut = "aria-description", Et = "aria-expanded", Me = "aria-hidden", St = "aria-selected", et = "aria-valuenow", ot = "aria-valuetext", Te = "change", Re = "DOMContentLoaded", Oe = "focusin", De = "focusout", _t = "keydown", Fe = "keyup", Mt = "click", Ie = "pointerdown", be = "pointermove", Ke = "pointerup", Ve = "resize", Be = "scroll", je = "touchmove", j = "ArrowDown", st = "ArrowUp", ht = "ArrowLeft", G = "ArrowRight", qe = "Enter", ze = "Escape", Wt = "Space", Ge = "transitionDuration", Ue = "transitionProperty", Y = "tabindex", _e = navigator.userAgentData, vt = _e, { userAgent: We } = navigator, wt = We, Xt = /iPhone|iPad|iPod|Android/i;
|
18
|
-
vt ? vt.brands.some((o) => Xt.test(o.brand)) : Xt.test(wt);
|
19
|
-
const Jt = /(iPhone|iPod|iPad)/;
|
20
|
-
vt ? vt.brands.some((o) => Jt.test(o.brand)) : (
|
1
|
+
const _t = "aria-description", Nt = "aria-expanded", Ee = "aria-hidden", St = "aria-selected", tt = "aria-valuenow", et = "aria-valuetext", Me = "change", Te = "DOMContentLoaded", Re = "focusin", Oe = "focusout", zt = "keydown", De = "keyup", Et = "click", Fe = "pointerdown", ue = "pointermove", Ie = "pointerup", Ke = "resize", Ve = "scroll", Be = "touchmove", j = "ArrowDown", ot = "ArrowUp", ht = "ArrowLeft", U = "ArrowRight", je = "Enter", qe = "Escape", Wt = "Space", Ge = "transitionDuration", Ue = "transitionProperty", X = "tabindex", _e = navigator.userAgentData, mt = _e, { userAgent: ze } = navigator, vt = ze, Jt = /iPhone|iPad|iPod|Android/i;
|
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)) : (
|
21
5
|
/* istanbul ignore next */
|
22
|
-
|
6
|
+
Xt.test(vt)
|
23
7
|
);
|
24
|
-
|
25
|
-
const { head:
|
26
|
-
["webkitPerspective", "perspective"].some((o) => o in
|
27
|
-
const
|
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) => {
|
28
12
|
const r = s || !1;
|
29
13
|
o.addEventListener(t, e, r);
|
30
|
-
},
|
14
|
+
}, jt = (o, t, e, s) => {
|
31
15
|
const r = s || !1;
|
32
16
|
o.removeEventListener(t, e, r);
|
33
|
-
},
|
17
|
+
}, We = (o, t, e, s) => {
|
34
18
|
const r = (n) => {
|
35
|
-
(n.target === o || n.currentTarget === o) && (e.apply(o, [n]),
|
19
|
+
(n.target === o || n.currentTarget === o) && (e.apply(o, [n]), jt(o, t, r, s));
|
36
20
|
};
|
37
|
-
|
38
|
-
},
|
21
|
+
Bt(o, t, r, s);
|
22
|
+
}, Je = () => {
|
39
23
|
};
|
40
24
|
(() => {
|
41
25
|
let o = !1;
|
@@ -43,19 +27,19 @@ const Xe = (o, t, e, s) => {
|
|
43
27
|
const t = Object.defineProperty({}, "passive", {
|
44
28
|
get: () => (o = !0, o)
|
45
29
|
});
|
46
|
-
|
30
|
+
We(document, Te, Je, t);
|
47
31
|
} catch {
|
48
32
|
}
|
49
33
|
return o;
|
50
34
|
})();
|
51
|
-
["webkitTransform", "transform"].some((o) => o in
|
52
|
-
["webkitAnimation", "animation"].some((o) => o in
|
53
|
-
["webkitTransition", "transition"].some((o) => o in
|
54
|
-
const
|
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) => {
|
55
39
|
o.classList.add(...t);
|
56
40
|
}, O = (o, ...t) => {
|
57
41
|
o.classList.remove(...t);
|
58
|
-
}, T = (o, t) => o.classList.contains(t), qt = (o) => o != null && typeof o == "object" || !1,
|
42
|
+
}, T = (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, W = /* @__PURE__ */ new Map(), ct = {
|
59
43
|
data: W,
|
60
44
|
/**
|
61
45
|
* Sets web components data.
|
@@ -82,8 +66,7 @@ const xt = (o, t) => o.getAttribute(t), m = (o, t, e) => o.setAttribute(t, e), C
|
|
82
66
|
* @returns the instance
|
83
67
|
*/
|
84
68
|
get: (o, t) => {
|
85
|
-
if (!at(o) || !t)
|
86
|
-
return null;
|
69
|
+
if (!at(o) || !t) return null;
|
87
70
|
const e = ct.getAllFor(t);
|
88
71
|
return o && e && e.get(o) || null;
|
89
72
|
},
|
@@ -97,31 +80,27 @@ const xt = (o, t) => o.getAttribute(t), m = (o, t, e) => o.setAttribute(t, e), C
|
|
97
80
|
const e = ct.getAllFor(t);
|
98
81
|
!e || !at(o) || (e.delete(o), e.size === 0 && W.delete(t));
|
99
82
|
}
|
100
|
-
},
|
101
|
-
if (!o)
|
102
|
-
|
103
|
-
|
104
|
-
return K().createElement(o);
|
83
|
+
}, Xe = (o, t) => ct.get(o, t), B = (o) => typeof o == "string" || !1, Ye = (o) => qt(o) && o.constructor.name === "Window" || !1, be = (o) => Z(o) && o.nodeType === 9 || !1, V = (o) => Ye(o) ? o.document : be(o) ? o : Z(o) ? o.ownerDocument : window.document, K = (o, ...t) => Object.assign(o, ...t), x = (o) => {
|
84
|
+
if (!o) return;
|
85
|
+
if (B(o))
|
86
|
+
return V().createElement(o);
|
105
87
|
const { tagName: t } = o, e = x(t);
|
106
|
-
if (!e)
|
107
|
-
return;
|
88
|
+
if (!e) return;
|
108
89
|
const s = { ...o };
|
109
|
-
return delete s.tagName,
|
110
|
-
},
|
111
|
-
if (!o || !t)
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
if (!s)
|
117
|
-
return;
|
90
|
+
return delete s.tagName, K(e, s);
|
91
|
+
}, Mt = (o, t) => {
|
92
|
+
if (!o || !t) return;
|
93
|
+
if (B(t))
|
94
|
+
return V().createElementNS(o, t);
|
95
|
+
const { tagName: e } = t, s = Mt(o, e);
|
96
|
+
if (!s) return;
|
118
97
|
const r = { ...t };
|
119
|
-
return delete r.tagName,
|
120
|
-
},
|
98
|
+
return delete r.tagName, K(s, r);
|
99
|
+
}, Ze = (o, t) => o.dispatchEvent(t), Tt = (o, t) => {
|
121
100
|
const e = getComputedStyle(o), s = t.replace("webkit", "Webkit").replace(/([A-Z])/g, "-$1").toLowerCase();
|
122
101
|
return e.getPropertyValue(s);
|
123
|
-
},
|
124
|
-
const t =
|
102
|
+
}, Qe = (o) => {
|
103
|
+
const t = Tt(o, Ue), e = Tt(o, Ge), s = e.includes("ms") ? (
|
125
104
|
/* istanbul ignore next */
|
126
105
|
1
|
127
106
|
) : 1e3, r = t && t !== "none" ? parseFloat(e) * s : (
|
@@ -132,26 +111,26 @@ const xt = (o, t) => o.getAttribute(t), m = (o, t, e) => o.setAttribute(t, e), C
|
|
132
111
|
/* istanbul ignore next */
|
133
112
|
0
|
134
113
|
) : r;
|
135
|
-
},
|
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) => {
|
136
115
|
const r = { ...e }, n = { ...o.dataset }, i = { ...t }, a = {}, l = "title";
|
137
116
|
return pt(n).forEach(([c, h]) => {
|
138
|
-
const b =
|
117
|
+
const b = c;
|
139
118
|
a[b] = Yt(h);
|
140
119
|
}), pt(r).forEach(([c, h]) => {
|
141
120
|
r[c] = Yt(h);
|
142
121
|
}), pt(t).forEach(([c, h]) => {
|
143
|
-
c in r ? i[c] = r[c] : c in a ? i[c] = a[c] : i[c] = c === l ?
|
122
|
+
c in r ? i[c] = r[c] : c in a ? i[c] = a[c] : i[c] = c === l ? yt(o, l) : h;
|
144
123
|
}), i;
|
145
|
-
},
|
124
|
+
}, Zt = (o) => Object.fromEntries(o), eo = (o) => o.offsetHeight, D = (o, t) => {
|
146
125
|
pt(t).forEach(([e, s]) => {
|
147
|
-
if (s &&
|
126
|
+
if (s && B(e) && e.includes("--"))
|
148
127
|
o.style.setProperty(e, s);
|
149
128
|
else {
|
150
129
|
const r = {};
|
151
|
-
r[e] = s,
|
130
|
+
r[e] = s, K(o.style, r);
|
152
131
|
}
|
153
132
|
});
|
154
|
-
},
|
133
|
+
}, oo = (o) => qt(o) && o.constructor.name === "Map" || !1, pe = (o) => o.toUpperCase(), gt = (o, t) => {
|
155
134
|
const { width: e, height: s, top: r, right: n, bottom: i, left: a } = o.getBoundingClientRect();
|
156
135
|
let l = 1, c = 1;
|
157
136
|
if (t && at(o)) {
|
@@ -174,28 +153,28 @@ const xt = (o, t) => o.getAttribute(t), m = (o, t, e) => o.setAttribute(t, e), C
|
|
174
153
|
x: a / l,
|
175
154
|
y: r / c
|
176
155
|
};
|
177
|
-
},
|
178
|
-
let
|
179
|
-
const
|
180
|
-
let e = t ?
|
156
|
+
}, Ct = (o) => V(o).documentElement;
|
157
|
+
let Qt = 0, te = 0;
|
158
|
+
const J = /* @__PURE__ */ new Map(), de = (o, t) => {
|
159
|
+
let e = t ? Qt : te;
|
181
160
|
if (t) {
|
182
|
-
const s =
|
183
|
-
|
161
|
+
const s = de(o), r = J.get(s) || /* @__PURE__ */ new Map();
|
162
|
+
J.has(s) || J.set(s, r), oo(r) && !r.has(t) ? (r.set(t, e), Qt += 1) : e = r.get(t);
|
184
163
|
} else {
|
185
164
|
const s = o.id || o;
|
186
|
-
|
165
|
+
J.has(s) ? e = J.get(s) : (J.set(s, e), te += 1);
|
187
166
|
}
|
188
167
|
return e;
|
189
|
-
},
|
168
|
+
}, so = (o) => {
|
190
169
|
var t;
|
191
|
-
return o ?
|
192
|
-
},
|
193
|
-
|
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(
|
194
173
|
o
|
195
|
-
),
|
174
|
+
), Gt = ["transparent", "currentColor", "inherit", "revert", "initial"], v = (o) => {
|
196
175
|
const t = Math.floor(o);
|
197
176
|
return o - t < 0.5 ? t : Math.round(o);
|
198
|
-
},
|
177
|
+
}, wt = [
|
199
178
|
[
|
200
179
|
"aliceblue",
|
201
180
|
{
|
@@ -1380,37 +1359,37 @@ me(o.getRootNode().host, t) : null, _ = (o, t) => at(o) ? o : (Q(t) ? t : K()).q
|
|
1380
1359
|
b: 50
|
1381
1360
|
}
|
1382
1361
|
]
|
1383
|
-
],
|
1384
|
-
CSS_UNIT: new RegExp(
|
1385
|
-
ANGLES:
|
1386
|
-
CSS_ANGLE:
|
1387
|
-
CSS_INTEGER:
|
1388
|
-
CSS_NUMBER:
|
1389
|
-
CSS_UNIT2:
|
1390
|
-
PERMISSIVE_MATCH:
|
1391
|
-
hwb: new RegExp(`hwb${
|
1392
|
-
rgb: new RegExp(`rgb(?:a)?${
|
1393
|
-
hsl: new RegExp(`hsl(?:a)?${
|
1394
|
-
hsv: new RegExp(`hsv(?:a)?${
|
1362
|
+
], me = "deg|rad|grad|turn", ve = "[-\\+]?\\d+%?", we = "[-\\+]?\\d*\\.\\d+%?", $e = `[-\\+]?\\d*\\.?\\d+(?:${me})?`, dt = `(?:${we})|(?:${ve})`, Rt = `(?:${dt})|(?:${$e}?)`, ro = "(?:[\\s|\\(\\s|\\s\\(\\s]+)?", no = "(?:[\\s|\\)\\s]+)?", ee = "(?:[,|\\s]+)", io = "(?:[,|\\/\\s]*)?", rt = `${ro}(${Rt})${ee}(${dt})${ee}(${dt})${io}(${dt})?${no}`, I = {
|
1363
|
+
CSS_UNIT: new RegExp(Rt),
|
1364
|
+
ANGLES: me,
|
1365
|
+
CSS_ANGLE: $e,
|
1366
|
+
CSS_INTEGER: ve,
|
1367
|
+
CSS_NUMBER: we,
|
1368
|
+
CSS_UNIT2: Rt,
|
1369
|
+
PERMISSIVE_MATCH: rt,
|
1370
|
+
hwb: new RegExp(`hwb${rt}`),
|
1371
|
+
rgb: new RegExp(`rgb(?:a)?${rt}`),
|
1372
|
+
hsl: new RegExp(`hsl(?:a)?${rt}`),
|
1373
|
+
hsv: new RegExp(`hsv(?:a)?${rt}`),
|
1395
1374
|
hex3: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
|
1396
1375
|
hex6: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,
|
1397
1376
|
hex4: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
|
1398
1377
|
hex8: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/
|
1399
|
-
},
|
1378
|
+
}, ke = (o) => Gt.includes(o), nt = (o, t) => o !== null && typeof o == "object" && Object.keys(t).every((e) => e in o), ye = (o) => `${o}`.includes(".") && parseFloat(o) === 1, $t = (o) => typeof o == "string" && o.includes("%"), H = (o) => !!I.CSS_UNIT.exec(`${o}`), xe = ["rgb", "hex", "hsl", "hsv", "hwb"], Se = (o) => Gt.includes(o) || ["#", ...xe].some((t) => o.includes(t)) ? !1 : wt.some(([t]) => o === t), R = (o, t) => {
|
1400
1379
|
let e = o;
|
1401
1380
|
if (typeof o == "number" && Math.min(o, 0) === 0 && // round values to 6 decimals Math.round(N * (10 ** 6)) / 10 ** 6
|
1402
1381
|
Math.max(o, 1) === 1)
|
1403
1382
|
return o;
|
1404
|
-
|
1405
|
-
const s =
|
1383
|
+
ye(o) && (e = "100%");
|
1384
|
+
const s = $t(e);
|
1406
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);
|
1407
|
-
},
|
1386
|
+
}, Ot = (o) => {
|
1408
1387
|
let t = parseFloat(o);
|
1409
1388
|
return (Number.isNaN(t) || t < 0 || t > 1) && (t = 1), t;
|
1410
|
-
}, ut = (o) => Math.min(1, Math.max(0, o)),
|
1411
|
-
const [[, t]] =
|
1389
|
+
}, ut = (o) => Math.min(1, Math.max(0, o)), G = (o) => o.length === 1 ? `0${o}` : String(o), Pe = (o) => {
|
1390
|
+
const [[, t]] = wt.filter(([e]) => e === o.toLowerCase());
|
1412
1391
|
return t;
|
1413
|
-
},
|
1392
|
+
}, N = (o) => parseInt(o, 16), Dt = (o) => N(o) / 255, Ce = (o) => v(o * 255).toString(16), oe = (o, t, e) => {
|
1414
1393
|
const s = Math.max(o, t, e), r = Math.min(o, t, e);
|
1415
1394
|
let n = 0, i = 0;
|
1416
1395
|
const a = (s + r) / 2;
|
@@ -1433,11 +1412,10 @@ me(o.getRootNode().host, t) : null, _ = (o, t) => at(o) ? o : (Q(t) ? t : K()).q
|
|
1433
1412
|
s = ft(a, i, o + 1 / 3), r = ft(a, i, o), n = ft(a, i, o - 1 / 3);
|
1434
1413
|
}
|
1435
1414
|
return { r: s, g: r, b: n };
|
1436
|
-
},
|
1415
|
+
}, se = (o, t, e) => {
|
1437
1416
|
let s = 0, r = 0;
|
1438
1417
|
const n = Math.min(o, t, e), i = Math.max(o, t, e), a = 1 - i;
|
1439
|
-
if (i === n)
|
1440
|
-
return { h: 0, w: n, b: a };
|
1418
|
+
if (i === n) return { h: 0, w: n, b: a };
|
1441
1419
|
o === n ? (s = t - e, r = 3) : (s = t === n ? e - o : o - t, r = t === n ? 5 : 1);
|
1442
1420
|
const l = (r - s / (i - n)) / 6;
|
1443
1421
|
return {
|
@@ -1445,45 +1423,45 @@ me(o.getRootNode().host, t) : null, _ = (o, t) => at(o) ? o : (Q(t) ? t : K()).q
|
|
1445
1423
|
w: n,
|
1446
1424
|
b: a
|
1447
1425
|
};
|
1448
|
-
},
|
1426
|
+
}, Le = (o, t, e) => {
|
1449
1427
|
if (t + e >= 1) {
|
1450
1428
|
const i = t / (t + e);
|
1451
1429
|
return { r: i, g: i, b: i };
|
1452
1430
|
}
|
1453
1431
|
let { r: s, g: r, b: n } = lt(o, 1, 0.5);
|
1454
1432
|
return [s, r, n] = [s, r, n].map((i) => i * (1 - t - e) + t), { r: s, g: r, b: n };
|
1455
|
-
},
|
1433
|
+
}, re = (o, t, e) => {
|
1456
1434
|
const s = Math.max(o, t, e), r = Math.min(o, t, e);
|
1457
1435
|
let n = 0;
|
1458
1436
|
const i = s, a = s - r, l = s === 0 ? 0 : a / s;
|
1459
1437
|
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 };
|
1460
|
-
},
|
1438
|
+
}, Ft = (o, t, e) => {
|
1461
1439
|
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];
|
1462
1440
|
return { r: u, g: d, b: g };
|
1463
|
-
},
|
1441
|
+
}, ne = (o, t, e, s) => {
|
1464
1442
|
const r = [
|
1465
|
-
|
1466
|
-
|
1467
|
-
|
1443
|
+
G(v(o).toString(16)),
|
1444
|
+
G(v(t).toString(16)),
|
1445
|
+
G(v(e).toString(16))
|
1468
1446
|
];
|
1469
1447
|
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("");
|
1470
|
-
},
|
1448
|
+
}, At = (o, t, e, s, r) => {
|
1471
1449
|
const n = [
|
1472
|
-
|
1473
|
-
|
1474
|
-
|
1475
|
-
|
1450
|
+
G(v(o).toString(16)),
|
1451
|
+
G(v(t).toString(16)),
|
1452
|
+
G(v(e).toString(16)),
|
1453
|
+
G(Ce(s))
|
1476
1454
|
];
|
1477
1455
|
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("");
|
1478
|
-
},
|
1456
|
+
}, Ae = (o) => {
|
1479
1457
|
const t = String(o).trim().toLowerCase();
|
1480
1458
|
if (Se(t))
|
1481
|
-
return Object.assign(
|
1459
|
+
return Object.assign(Pe(t), {
|
1482
1460
|
a: 1,
|
1483
1461
|
format: "rgb",
|
1484
1462
|
ok: !0
|
1485
1463
|
});
|
1486
|
-
if (
|
1464
|
+
if (ke(t))
|
1487
1465
|
return {
|
1488
1466
|
r: 0,
|
1489
1467
|
g: 0,
|
@@ -1522,30 +1500,30 @@ me(o.getRootNode().host, t) : null, _ = (o, t) => at(o) ? o : (Q(t) ? t : K()).q
|
|
1522
1500
|
format: "hwb",
|
1523
1501
|
ok: !0
|
1524
1502
|
} : ([, e, s, r, n] = I.hex8.exec(t) || [], e && s && r && n ? {
|
1525
|
-
r:
|
1526
|
-
g:
|
1527
|
-
b:
|
1528
|
-
a:
|
1503
|
+
r: N(e),
|
1504
|
+
g: N(s),
|
1505
|
+
b: N(r),
|
1506
|
+
a: Dt(n),
|
1529
1507
|
format: "hex",
|
1530
1508
|
ok: !0
|
1531
1509
|
} : ([, e, s, r] = I.hex6.exec(t) || [], e && s && r ? {
|
1532
|
-
r:
|
1533
|
-
g:
|
1534
|
-
b:
|
1510
|
+
r: N(e),
|
1511
|
+
g: N(s),
|
1512
|
+
b: N(r),
|
1535
1513
|
a: 1,
|
1536
1514
|
format: "hex",
|
1537
1515
|
ok: !0
|
1538
1516
|
} : ([, e, s, r, n] = I.hex4.exec(t) || [], e && s && r && n ? {
|
1539
|
-
r:
|
1540
|
-
g:
|
1541
|
-
b:
|
1542
|
-
a:
|
1517
|
+
r: N(e + e),
|
1518
|
+
g: N(s + s),
|
1519
|
+
b: N(r + r),
|
1520
|
+
a: Dt(n + n),
|
1543
1521
|
format: "hex",
|
1544
1522
|
ok: !0
|
1545
1523
|
} : ([, e, s, r] = I.hex3.exec(t) || [], e && s && r ? {
|
1546
|
-
r:
|
1547
|
-
g:
|
1548
|
-
b:
|
1524
|
+
r: N(e + e),
|
1525
|
+
g: N(s + s),
|
1526
|
+
b: N(r + r),
|
1549
1527
|
a: 1,
|
1550
1528
|
format: "hex",
|
1551
1529
|
ok: !0
|
@@ -1557,49 +1535,49 @@ me(o.getRootNode().host, t) : null, _ = (o, t) => at(o) ? o : (Q(t) ? t : K()).q
|
|
1557
1535
|
format: "rgb",
|
1558
1536
|
ok: !o
|
1559
1537
|
})))))));
|
1560
|
-
},
|
1538
|
+
}, ie = (o) => {
|
1561
1539
|
let t = { r: 0, g: 0, b: 0 }, e = o, s = 1, r, n, i, a, l, c, h, b, u = "rgb", d = !1;
|
1562
|
-
return (!e || typeof e == "string") && (e =
|
1540
|
+
return (!e || typeof e == "string") && (e = Ae(e), d = e.ok), nt(e, t) && H(e.r) && H(e.g) && H(e.b) && ({ r: h, g: b, b: l } = e, [h, b, l] = [h, b, l].map((g) => R(g, $t(g) ? 100 : 255)), t = { r: h, g: b, b: l }, u = "format" in e ? e.format : "rgb"), 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 = R(c, 360), r = R(r, 100), n = R(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 = R(c, 360), r = R(r, 100), i = R(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 = R(c, 360), a = R(a, 100), l = R(l, 100), t = Le(c, a, l), u = "hwb"), H(e.a) && (s = e.a, s = $t(s) || parseFloat(`${s}`) > 1 ? R(s, 100) : s), {
|
1563
1541
|
r: t.r,
|
1564
1542
|
g: t.g,
|
1565
1543
|
b: t.b,
|
1566
|
-
a:
|
1544
|
+
a: Ot(s),
|
1567
1545
|
format: u,
|
1568
1546
|
ok: d
|
1569
1547
|
};
|
1570
|
-
},
|
1548
|
+
}, ao = "1.0.9";
|
1571
1549
|
class y {
|
1572
1550
|
// bring main utilities to front
|
1573
1551
|
static matchers = I;
|
1574
|
-
static isOnePointZero =
|
1575
|
-
static isPercentage =
|
1576
|
-
static isValidCSSUnit =
|
1577
|
-
static isNonColor =
|
1552
|
+
static isOnePointZero = ye;
|
1553
|
+
static isPercentage = $t;
|
1554
|
+
static isValidCSSUnit = H;
|
1555
|
+
static isNonColor = ke;
|
1578
1556
|
static isColorName = Se;
|
1579
|
-
static isColorType =
|
1580
|
-
static pad2 =
|
1557
|
+
static isColorType = nt;
|
1558
|
+
static pad2 = G;
|
1581
1559
|
static clamp01 = ut;
|
1582
1560
|
static bound01 = R;
|
1583
|
-
static boundAlpha =
|
1584
|
-
static getRGBFromName =
|
1585
|
-
static convertHexToDecimal =
|
1586
|
-
static convertDecimalToHex =
|
1587
|
-
static rgbToHsl =
|
1588
|
-
static rgbToHex =
|
1589
|
-
static rgbToHsv =
|
1590
|
-
static rgbToHwb =
|
1591
|
-
static rgbaToHex =
|
1592
|
-
static hslToRgb =
|
1593
|
-
static hsvToRgb =
|
1561
|
+
static boundAlpha = Ot;
|
1562
|
+
static getRGBFromName = Pe;
|
1563
|
+
static convertHexToDecimal = Dt;
|
1564
|
+
static convertDecimalToHex = Ce;
|
1565
|
+
static rgbToHsl = oe;
|
1566
|
+
static rgbToHex = ne;
|
1567
|
+
static rgbToHsv = re;
|
1568
|
+
static rgbToHwb = se;
|
1569
|
+
static rgbaToHex = At;
|
1570
|
+
static hslToRgb = Ft;
|
1571
|
+
static hsvToRgb = Ft;
|
1594
1572
|
static hueToRgb = ft;
|
1595
|
-
static hwbToRgb =
|
1596
|
-
static parseIntFromHex =
|
1597
|
-
static stringInputToObject =
|
1598
|
-
static inputToRGB =
|
1573
|
+
static hwbToRgb = Le;
|
1574
|
+
static parseIntFromHex = N;
|
1575
|
+
static stringInputToObject = Ae;
|
1576
|
+
static inputToRGB = ie;
|
1599
1577
|
static roundPart = v;
|
1600
|
-
static webColors =
|
1601
|
-
static nonColors =
|
1602
|
-
static version =
|
1578
|
+
static webColors = wt;
|
1579
|
+
static nonColors = Gt;
|
1580
|
+
static version = ao;
|
1603
1581
|
// main public properties
|
1604
1582
|
r;
|
1605
1583
|
g;
|
@@ -1610,7 +1588,7 @@ class y {
|
|
1610
1588
|
originalInput;
|
1611
1589
|
// main public methods
|
1612
1590
|
constructor(t, e) {
|
1613
|
-
const s = e &&
|
1591
|
+
const s = e && xe.includes(e) ? e : "", { r, g: n, b: i, a, ok: l, format: c } = ie(t);
|
1614
1592
|
this.originalInput = t, this.r = r, this.g = n, this.b = i, this.a = a, this.ok = l, this.format = s || c;
|
1615
1593
|
}
|
1616
1594
|
/**
|
@@ -1646,7 +1624,7 @@ class y {
|
|
1646
1624
|
* Returns the web colour name closest to the current colour.
|
1647
1625
|
*/
|
1648
1626
|
get name() {
|
1649
|
-
const { r: t, g: e, b: s } = this.toRgb(), [r] =
|
1627
|
+
const { r: t, g: e, b: s } = this.toRgb(), [r] = wt.map(([n, i]) => {
|
1650
1628
|
const a = (
|
1651
1629
|
// ((rgb.r - r) ** 2 + (rgb.g - g) ** 2 + (rgb.b - b) ** 2) ** 0.5; // standard
|
1652
1630
|
(((i.r - t) * 0.3) ** 2 + ((i.g - e) * 0.6) ** 2 + ((i.b - s) * 0.1) ** 2) ** 0.5
|
@@ -1691,7 +1669,7 @@ class y {
|
|
1691
1669
|
*/
|
1692
1670
|
toHex(t) {
|
1693
1671
|
const { r: e, g: s, b: r, a: n } = this.toRgb();
|
1694
|
-
return n === 1 ?
|
1672
|
+
return n === 1 ? ne(e, s, r, t) : At(e, s, r, n, t);
|
1695
1673
|
}
|
1696
1674
|
/**
|
1697
1675
|
* Returns the CSS valid hexadecimal vaue of the colour. When the parameter is *true*
|
@@ -1705,7 +1683,7 @@ class y {
|
|
1705
1683
|
*/
|
1706
1684
|
toHex8(t) {
|
1707
1685
|
const { r: e, g: s, b: r, a: n } = this.toRgb();
|
1708
|
-
return
|
1686
|
+
return At(e, s, r, n, t);
|
1709
1687
|
}
|
1710
1688
|
/**
|
1711
1689
|
* Returns the HEX8 value of the colour.
|
@@ -1717,7 +1695,7 @@ class y {
|
|
1717
1695
|
* Returns the colour as a HSVA object.
|
1718
1696
|
*/
|
1719
1697
|
toHsv() {
|
1720
|
-
const { r: t, g: e, b: s, a: r } = this, { h: n, s: i, v: a } =
|
1698
|
+
const { r: t, g: e, b: s, a: r } = this, { h: n, s: i, v: a } = re(t, e, s);
|
1721
1699
|
return {
|
1722
1700
|
h: n,
|
1723
1701
|
s: i,
|
@@ -1729,7 +1707,7 @@ class y {
|
|
1729
1707
|
* Returns the colour as an HSLA object.
|
1730
1708
|
*/
|
1731
1709
|
toHsl() {
|
1732
|
-
const { r: t, g: e, b: s, a: r } = this, { h: n, s: i, l: a } =
|
1710
|
+
const { r: t, g: e, b: s, a: r } = this, { h: n, s: i, l: a } = oe(t, e, s);
|
1733
1711
|
return {
|
1734
1712
|
h: n,
|
1735
1713
|
s: i,
|
@@ -1761,7 +1739,7 @@ class y {
|
|
1761
1739
|
* Returns the colour as an HWBA object.
|
1762
1740
|
*/
|
1763
1741
|
toHwb() {
|
1764
|
-
const { r: t, g: e, b: s, a: r } = this, { h: n, w: i, b: a } =
|
1742
|
+
const { r: t, g: e, b: s, a: r } = this, { h: n, w: i, b: a } = se(t, e, s);
|
1765
1743
|
return {
|
1766
1744
|
h: n,
|
1767
1745
|
w: i,
|
@@ -1782,14 +1760,13 @@ class y {
|
|
1782
1760
|
* Sets the alpha value of the current colour.
|
1783
1761
|
*/
|
1784
1762
|
setAlpha(t) {
|
1785
|
-
return typeof t != "number" ? this : (this.a =
|
1763
|
+
return typeof t != "number" ? this : (this.a = Ot(t), this);
|
1786
1764
|
}
|
1787
1765
|
/**
|
1788
1766
|
* Saturate the colour with a given amount.
|
1789
1767
|
*/
|
1790
1768
|
saturate(t) {
|
1791
|
-
if (typeof t != "number")
|
1792
|
-
return this;
|
1769
|
+
if (typeof t != "number") return this;
|
1793
1770
|
const { h: e, s, l: r } = this.toHsl(), { r: n, g: i, b: a } = lt(e, ut(s + t / 100), r);
|
1794
1771
|
return Object.assign(this, { r: n, g: i, b: a }), this;
|
1795
1772
|
}
|
@@ -1810,8 +1787,7 @@ class y {
|
|
1810
1787
|
* Increase the colour lightness with a given amount.
|
1811
1788
|
*/
|
1812
1789
|
lighten(t) {
|
1813
|
-
if (typeof t != "number")
|
1814
|
-
return this;
|
1790
|
+
if (typeof t != "number") return this;
|
1815
1791
|
const { h: e, s, l: r } = this.toHsl(), { r: n, g: i, b: a } = lt(e, s, ut(r + t / 100));
|
1816
1792
|
return Object.assign(this, { r: n, g: i, b: a }), this;
|
1817
1793
|
}
|
@@ -1826,8 +1802,7 @@ class y {
|
|
1826
1802
|
* Values outside of this range will be wrapped into this range.
|
1827
1803
|
*/
|
1828
1804
|
spin(t) {
|
1829
|
-
if (typeof t != "number")
|
1830
|
-
return this;
|
1805
|
+
if (typeof t != "number") return this;
|
1831
1806
|
const { h: e, s, l: r } = this.toHsl(), { r: n, g: i, b: a } = lt(ut((e * 360 + t) % 360 / 360), s, r);
|
1832
1807
|
return Object.assign(this, { r: n, g: i, b: a }), this;
|
1833
1808
|
}
|
@@ -1843,7 +1818,7 @@ class y {
|
|
1843
1818
|
return e === "hex" ? this.toHexString(t) : e === "hsl" ? this.toHslString() : e === "hwb" ? this.toHwbString() : this.toRgbString();
|
1844
1819
|
}
|
1845
1820
|
}
|
1846
|
-
class
|
1821
|
+
class It {
|
1847
1822
|
static Color = y;
|
1848
1823
|
hue;
|
1849
1824
|
hueSteps;
|
@@ -1887,7 +1862,7 @@ class Kt {
|
|
1887
1862
|
this.hue = e, this.hueSteps = s, this.lightSteps = r, this.saturation = i, this.colors = a;
|
1888
1863
|
}
|
1889
1864
|
}
|
1890
|
-
const
|
1865
|
+
const Kt = {
|
1891
1866
|
pickerLabel: "Colour Picker",
|
1892
1867
|
appearanceLabel: "Colour Appearance",
|
1893
1868
|
valueLabel: "Colour Value",
|
@@ -1905,7 +1880,7 @@ const Vt = {
|
|
1905
1880
|
redLabel: "Red",
|
1906
1881
|
greenLabel: "Green",
|
1907
1882
|
blueLabel: "Blue"
|
1908
|
-
},
|
1883
|
+
}, it = [
|
1909
1884
|
"white",
|
1910
1885
|
"black",
|
1911
1886
|
"grey",
|
@@ -1923,23 +1898,22 @@ const Vt = {
|
|
1923
1898
|
"violet",
|
1924
1899
|
"magenta",
|
1925
1900
|
"pink"
|
1926
|
-
],
|
1927
|
-
if (!
|
1928
|
-
return !1;
|
1901
|
+
], ae = (o) => {
|
1902
|
+
if (!B(o)) return !1;
|
1929
1903
|
try {
|
1930
1904
|
JSON.parse(o);
|
1931
1905
|
} catch {
|
1932
1906
|
return !1;
|
1933
1907
|
}
|
1934
1908
|
return !0;
|
1935
|
-
},
|
1909
|
+
}, Vt = "v-hidden", lo = (o) => {
|
1936
1910
|
const { format: t, id: e, componentLabels: s } = o, r = x({
|
1937
1911
|
tagName: "div",
|
1938
1912
|
className: `color-form ${t}`
|
1939
1913
|
});
|
1940
1914
|
let n = ["hex"];
|
1941
1915
|
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) => {
|
1942
|
-
const [a] = t === "hex" ? ["#"] :
|
1916
|
+
const [a] = t === "hex" ? ["#"] : pe(i).split(""), l = `color_${t}_${i}_${e}`, c = s[`${i}Label`], h = x({ tagName: "label" });
|
1943
1917
|
m(h, "for", l), h.append(
|
1944
1918
|
x({
|
1945
1919
|
tagName: "span",
|
@@ -1948,7 +1922,7 @@ const Vt = {
|
|
1948
1922
|
}),
|
1949
1923
|
x({
|
1950
1924
|
tagName: "span",
|
1951
|
-
className:
|
1925
|
+
className: Vt,
|
1952
1926
|
innerText: c
|
1953
1927
|
})
|
1954
1928
|
);
|
@@ -1963,13 +1937,13 @@ const Vt = {
|
|
1963
1937
|
spellcheck: !1
|
1964
1938
|
});
|
1965
1939
|
let u = "100", d = "1";
|
1966
|
-
i !== "alpha" && (t === "rgb" ? (u = "255", d = "1") : i === "hue" && (u = "360", d = "1")),
|
1940
|
+
i !== "alpha" && (t === "rgb" ? (u = "255", d = "1") : i === "hue" && (u = "360", d = "1")), K(b, {
|
1967
1941
|
min: "0",
|
1968
1942
|
max: u,
|
1969
1943
|
step: d
|
1970
1944
|
}), r.append(h, b);
|
1971
1945
|
}), r;
|
1972
|
-
},
|
1946
|
+
}, co = (o) => {
|
1973
1947
|
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;
|
1974
1948
|
let u = t === "hsl" ? `${s} & ${n}` : `${n} & ${i}`;
|
1975
1949
|
u = t === "hwb" ? `${a} & ${l}` : u;
|
@@ -2000,7 +1974,7 @@ const Vt = {
|
|
2000
1974
|
max: b
|
2001
1975
|
}
|
2002
1976
|
].forEach(($) => {
|
2003
|
-
const { i:
|
1977
|
+
const { i: S, c: L, l: P, min: C, max: M } = $, E = x({
|
2004
1978
|
tagName: "div",
|
2005
1979
|
className: "color-control",
|
2006
1980
|
role: "presentation"
|
@@ -2008,14 +1982,14 @@ const Vt = {
|
|
2008
1982
|
E.append(
|
2009
1983
|
x({
|
2010
1984
|
tagName: "div",
|
2011
|
-
className: `visual-control visual-control${
|
1985
|
+
className: `visual-control visual-control${S}`
|
2012
1986
|
})
|
2013
1987
|
);
|
2014
1988
|
const A = x({
|
2015
1989
|
tagName: "div",
|
2016
1990
|
className: `${L} knob`,
|
2017
1991
|
ariaLive: "polite",
|
2018
|
-
ariaLabel:
|
1992
|
+
ariaLabel: P,
|
2019
1993
|
role: "slider",
|
2020
1994
|
tabIndex: 0,
|
2021
1995
|
ariaValueMin: `${C}`,
|
@@ -2023,47 +1997,48 @@ const Vt = {
|
|
2023
1997
|
});
|
2024
1998
|
E.append(A), g.append(E);
|
2025
1999
|
}), g;
|
2026
|
-
},
|
2027
|
-
const { input: s, format: r, componentLabels: n } = o, { defaultsLabel: i, presetsLabel: a } = n, l = e === "color-options", c = t instanceof
|
2000
|
+
}, le = (o, t, e) => {
|
2001
|
+
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;
|
2028
2002
|
let f = 2;
|
2029
2003
|
f = p && u > g * 2 ? 3 : f, f = p && u > g * 3 ? 4 : f, f = p && u > g * 4 ? 5 : f;
|
2030
2004
|
const w = f - (u <= g * 3 ? 1 : 2), $ = p && u > w * g;
|
2031
|
-
let
|
2032
|
-
|
2005
|
+
let S = e;
|
2006
|
+
S += $ ? " scrollable" : "", S += p ? " multiline" : "";
|
2033
2007
|
const L = p ? "1px" : "0.25rem";
|
2034
|
-
let
|
2035
|
-
|
2036
|
-
const C = `${w *
|
2008
|
+
let P = p ? 1.75 : 2;
|
2009
|
+
P = g > 5 && p ? 1.5 : P;
|
2010
|
+
const C = `${w * P}rem`, M = `calc(${f} * ${P}rem + ${f - 1} * ${L})`, E = x({
|
2037
2011
|
tagName: "ul",
|
2038
|
-
className:
|
2012
|
+
className: S,
|
2039
2013
|
role: "listbox",
|
2040
2014
|
ariaLabel: h
|
2041
2015
|
});
|
2042
2016
|
return $ && D(E, {
|
2043
|
-
"--grid-item-size": `${
|
2017
|
+
"--grid-item-size": `${P}rem`,
|
2044
2018
|
"--grid-fit": `${g}`,
|
2045
2019
|
"--grid-gap": L,
|
2046
2020
|
"--grid-height": C,
|
2047
2021
|
"--grid-hover-height": M
|
2048
2022
|
}), b.forEach((A) => {
|
2049
|
-
let [F,
|
2050
|
-
A instanceof y && (F = A.toHexString(),
|
2051
|
-
const
|
2023
|
+
let [F, Q] = typeof A == "string" ? A.trim().split(":") : [];
|
2024
|
+
A instanceof y && (F = A.toHexString(), Q = F);
|
2025
|
+
const Ut = new y(A instanceof y ? A : F, r).toString() === yt(s, "value"), xt = x({
|
2052
2026
|
tagName: "li",
|
2053
|
-
className: `color-option${
|
2054
|
-
innerText: `${
|
2027
|
+
className: `color-option${Ut ? " active" : ""}`,
|
2028
|
+
innerText: `${Q || F}`,
|
2055
2029
|
tabIndex: 0,
|
2056
2030
|
role: "option",
|
2057
|
-
ariaSelected:
|
2031
|
+
ariaSelected: Ut ? "true" : "false"
|
2058
2032
|
});
|
2059
|
-
m(
|
2033
|
+
m(xt, "data-value", `${F}`), l && D(xt, { backgroundColor: F }), E.append(xt);
|
2060
2034
|
}), E;
|
2061
|
-
},
|
2062
|
-
const { input: t, parent: e, format: s, id: r, componentLabels: n, colorKeywords: i, colorPresets: a } = o, l =
|
2035
|
+
}, ho = (o) => {
|
2036
|
+
const { input: t, parent: e, format: s, id: r, componentLabels: n, colorKeywords: i, colorPresets: a } = o, l = yt(t, "value") || "#fff", { nonColors: c } = y, { toggleLabel: h, pickerLabel: b, formatLabel: u, hexLabel: d } = n, g = c.includes(l) ? "#fff" : l;
|
2063
2037
|
o.color = new y(g, s);
|
2064
|
-
const p = s === "hex" ? d :
|
2038
|
+
const p = s === "hex" ? d : pe(s), f = x({
|
2065
2039
|
id: `picker-btn-${r}`,
|
2066
2040
|
tagName: "button",
|
2041
|
+
type: "button",
|
2067
2042
|
className: "picker-toggle btn-appearance",
|
2068
2043
|
ariaExpanded: "false",
|
2069
2044
|
ariaHasPopup: "true"
|
@@ -2071,7 +2046,7 @@ const Vt = {
|
|
2071
2046
|
f.append(
|
2072
2047
|
x({
|
2073
2048
|
tagName: "span",
|
2074
|
-
className:
|
2049
|
+
className: Vt,
|
2075
2050
|
innerText: `${b}. ${u}: ${p}`
|
2076
2051
|
})
|
2077
2052
|
);
|
@@ -2080,71 +2055,72 @@ const Vt = {
|
|
2080
2055
|
className: "color-dropdown picker",
|
2081
2056
|
role: "group",
|
2082
2057
|
ariaLabelledBy: `picker-btn-${r}`
|
2083
|
-
}), $ =
|
2084
|
-
if (w.append($,
|
2058
|
+
}), $ = co(o), S = lo(o);
|
2059
|
+
if (w.append($, S), t.before(f), e.append(w), i || a) {
|
2085
2060
|
const L = x({
|
2086
2061
|
tagName: "div",
|
2087
2062
|
className: "color-dropdown scrollable menu"
|
2088
2063
|
});
|
2089
|
-
a && L.append(
|
2090
|
-
const
|
2064
|
+
a && L.append(le(o, a, "color-options")), i && i.length && L.append(le(o, i, "color-defaults"));
|
2065
|
+
const P = x({
|
2091
2066
|
tagName: "button",
|
2067
|
+
type: "button",
|
2092
2068
|
className: "menu-toggle btn-appearance",
|
2093
2069
|
tabIndex: -1,
|
2094
2070
|
ariaExpanded: "false",
|
2095
2071
|
ariaHasPopup: "true"
|
2096
|
-
}), C = encodeURI("http://www.w3.org/2000/svg"), M =
|
2072
|
+
}), C = encodeURI("http://www.w3.org/2000/svg"), M = Mt(C, {
|
2097
2073
|
tagName: "svg"
|
2098
2074
|
});
|
2099
|
-
m(M, "xmlns", C), m(M, "viewBox", "0 0 512 512"), m(M,
|
2100
|
-
const E =
|
2075
|
+
m(M, "xmlns", C), m(M, "viewBox", "0 0 512 512"), m(M, Ee, "true");
|
2076
|
+
const E = Mt(C, {
|
2101
2077
|
tagName: "path"
|
2102
2078
|
});
|
2103
|
-
m(E, "d", "M98,158l157,156L411,158l27,27L255,368L71,185L98,158z"), m(E, "fill", "#fff"), M.append(E),
|
2079
|
+
m(E, "d", "M98,158l157,156L411,158l27,27L255,368L71,185L98,158z"), m(E, "fill", "#fff"), M.append(E), P.append(
|
2104
2080
|
x({
|
2105
2081
|
tagName: "span",
|
2106
|
-
className:
|
2082
|
+
className: Vt,
|
2107
2083
|
innerText: `${h}`
|
2108
2084
|
}),
|
2109
2085
|
M
|
2110
|
-
), e.append(
|
2086
|
+
), e.append(P, L);
|
2111
2087
|
}
|
2112
|
-
i && c.includes(l) && (o.value = l), m(t,
|
2113
|
-
},
|
2114
|
-
componentLabels:
|
2115
|
-
colorLabels:
|
2088
|
+
i && c.includes(l) && (o.value = l), m(t, X, "-1");
|
2089
|
+
}, go = "2.0.0", Y = "color-picker", uo = `[data-function="${Y}"]`, ce = `.${Y}`, bo = {
|
2090
|
+
componentLabels: Kt,
|
2091
|
+
colorLabels: it,
|
2116
2092
|
format: "rgb",
|
2117
2093
|
colorPresets: !1,
|
2118
2094
|
colorKeywords: !1
|
2119
|
-
}, { roundPart: k, nonColors: bt } = y,
|
2120
|
-
const e = t ?
|
2121
|
-
e(s,
|
2095
|
+
}, { roundPart: k, nonColors: bt } = y, po = (o) => Xe(o, Y), fo = (o) => new mo(o), he = (o, t) => {
|
2096
|
+
const e = t ? Bt : jt, { input: s, pickerToggle: r, menuToggle: n } = o;
|
2097
|
+
e(s, Re, o.showPicker), e(r, Et, o.togglePicker), n && e(n, Et, o.toggleMenu);
|
2122
2098
|
}, He = (o, t) => {
|
2123
|
-
const e = t ?
|
2124
|
-
e(o.controls,
|
2125
|
-
},
|
2126
|
-
|
2127
|
-
},
|
2099
|
+
const e = t ? Bt : jt, { input: s, colorMenu: r, parent: n } = o, i = V(s), a = so(i);
|
2100
|
+
e(o.controls, Fe, o.pointerDown), o.controlKnobs.forEach((l) => e(l, zt, o.handleKnobs)), e(a, Ve, o.handleScroll), e(a, Ke, 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, ue, o.pointerMove), e(i, Ie, o.pointerUp), e(n, Oe, o.handleFocusOut), e(i, De, o.handleDismiss);
|
2101
|
+
}, ge = (o) => {
|
2102
|
+
Ze(o.input, new CustomEvent("colorpicker.change"));
|
2103
|
+
}, Ne = (o) => {
|
2128
2104
|
o && ["bottom", "top"].forEach((t) => O(o, t));
|
2129
2105
|
}, Ht = (o, t) => {
|
2130
2106
|
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;
|
2131
|
-
T(i, "open") || q(i, "open"), l && (O(l, "show"),
|
2107
|
+
T(i, "open") || q(i, "open"), l && (O(l, "show"), Ne(l)), q(t, "bottom"), eo(t), q(t, "show"), a && o.update(), o.isOpen || (He(o, !0), o.updateDropdownPosition(), o.isOpen = !0, m(o.input, X, "0"), r && m(r, X, "0")), m(h, Nt, "true"), c && m(c, Nt, "false");
|
2132
2108
|
};
|
2133
|
-
class
|
2109
|
+
class mo {
|
2134
2110
|
// bring utils to staic
|
2135
2111
|
static Color = y;
|
2136
|
-
static ColorPalette =
|
2137
|
-
static getInstance =
|
2138
|
-
static init =
|
2139
|
-
static selector =
|
2112
|
+
static ColorPalette = It;
|
2113
|
+
static getInstance = po;
|
2114
|
+
static init = fo;
|
2115
|
+
static selector = uo;
|
2140
2116
|
// utils important for render
|
2141
2117
|
static roundPart = k;
|
2142
2118
|
static setElementStyle = D;
|
2143
2119
|
static setAttribute = m;
|
2144
2120
|
static getBoundingClientRect = gt;
|
2145
|
-
static version =
|
2146
|
-
static colorNames =
|
2147
|
-
static colorPickerLabels =
|
2121
|
+
static version = go;
|
2122
|
+
static colorNames = it;
|
2123
|
+
static colorPickerLabels = Kt;
|
2148
2124
|
id;
|
2149
2125
|
input;
|
2150
2126
|
color;
|
@@ -2153,7 +2129,7 @@ class ko {
|
|
2153
2129
|
dragElement;
|
2154
2130
|
isOpen = !1;
|
2155
2131
|
controlPositions;
|
2156
|
-
colorLabels =
|
2132
|
+
colorLabels = Zt(it.map((t) => [t, t]));
|
2157
2133
|
colorKeywords;
|
2158
2134
|
colorPresets;
|
2159
2135
|
componentLabels;
|
@@ -2173,43 +2149,37 @@ class ko {
|
|
2173
2149
|
* @param config instance options
|
2174
2150
|
*/
|
2175
2151
|
constructor(t, e) {
|
2176
|
-
const s =
|
2177
|
-
if (typeof t > "u")
|
2178
|
-
|
2179
|
-
if (V(t) && !s)
|
2180
|
-
throw new TypeError(`ColorPicker target "${t}" cannot be found.`);
|
2152
|
+
const s = z(t);
|
2153
|
+
if (typeof t > "u") throw new TypeError("ColorPicker target not specified.");
|
2154
|
+
if (B(t) && !s) throw new TypeError(`ColorPicker target "${t}" cannot be found.`);
|
2181
2155
|
this.input = s;
|
2182
|
-
const r =
|
2183
|
-
if (!r)
|
2184
|
-
|
2185
|
-
this.parent = r, this.id = fe(s, Z), this.dragElement = void 0, this.isOpen = !1, this.controlPositions = {
|
2156
|
+
const r = fe(s, ce);
|
2157
|
+
if (!r) throw new TypeError("ColorPicker requires a specific markup to work.");
|
2158
|
+
this.parent = r, this.id = de(s, Y), this.dragElement = void 0, this.isOpen = !1, this.controlPositions = {
|
2186
2159
|
c1x: 0,
|
2187
2160
|
c1y: 0,
|
2188
2161
|
c2y: 0,
|
2189
2162
|
c3y: 0
|
2190
|
-
}, this.
|
2191
|
-
const { format: n, componentLabels: i, colorLabels: a, colorKeywords: l, colorPresets: c } =
|
2163
|
+
}, this.colorKeywords = !1, this.colorPresets = !1;
|
2164
|
+
const { format: n, componentLabels: i, colorLabels: a, colorKeywords: l, colorPresets: c } = to(
|
2192
2165
|
s,
|
2193
|
-
|
2166
|
+
bo,
|
2194
2167
|
e || {}
|
2195
2168
|
);
|
2196
|
-
let h =
|
2197
|
-
|
2198
|
-
|
2199
|
-
})
|
2200
|
-
const b = V(i) && ie(i) ? JSON.parse(i) : i;
|
2201
|
-
if (this.componentLabels = B({ ...Vt }, b), this.color = new y(s.value || "#fff", n), this.format = n, At(l) && l.length ? this.colorKeywords = l : V(l) && l.length && (this.colorKeywords = l.split(",").map((p) => p.trim())), At(c) && c.length)
|
2169
|
+
let h = it;
|
2170
|
+
Lt(a) && a.length === 17 ? h = a : B(a) && a.split(",").length === 17 && (h = a.split(",")), K(this.colorLabels, Zt(h.map((p, f) => [it[f], p])));
|
2171
|
+
const b = B(i) && ae(i) ? JSON.parse(i) : i;
|
2172
|
+
if (this.componentLabels = K({ ...Kt }, b), this.color = new y(s.value || "#fff", n), this.format = n, Lt(l) && l.length ? this.colorKeywords = l : B(l) && l.length && (this.colorKeywords = l.split(",").map((p) => p.trim())), Lt(c) && c.length)
|
2202
2173
|
this.colorPresets = c;
|
2203
|
-
else if (c &&
|
2174
|
+
else if (c && ae(c)) {
|
2204
2175
|
const { hue: p, hueSteps: f, lightSteps: w, saturation: $ } = JSON.parse(c);
|
2205
|
-
this.colorPresets = new
|
2206
|
-
} else
|
2207
|
-
|
2208
|
-
|
2209
|
-
|
2210
|
-
|
2211
|
-
|
2212
|
-
this.controls = g, this.controlKnobs = [...rt("knob", g)], this.visuals = [...rt("visual-control", g)], this.update(), ce(this, !0), ct.set(s, Z, this);
|
2176
|
+
this.colorPresets = new It(p, f, w, $);
|
2177
|
+
} else B(c) && (this.colorPresets = c.split(",").map((p) => p.trim()));
|
2178
|
+
ho(this);
|
2179
|
+
const [u, d] = st("color-dropdown", r);
|
2180
|
+
this.pickerToggle = z(".picker-toggle", r), this.menuToggle = z(".menu-toggle", r), this.colorPicker = u, this.colorMenu = d, this.inputs = [...st("color-input", r)];
|
2181
|
+
const [g] = st("color-controls", r);
|
2182
|
+
this.controls = g, this.controlKnobs = [...st("knob", g)], this.visuals = [...st("visual-control", g)], this.update(), he(this, !0), ct.set(s, Y, this);
|
2213
2183
|
}
|
2214
2184
|
/** Returns the current colour value */
|
2215
2185
|
get value() {
|
@@ -2282,8 +2252,7 @@ class ko {
|
|
2282
2252
|
else if (n >= 45 && n < 75) {
|
2283
2253
|
const b = n > 46 && n < 54 && c < 80 && a > 90, u = n >= 54 && n < 75 && c < 80;
|
2284
2254
|
h = b ? t.gold : t.yellow, h = u ? t.olive : h;
|
2285
|
-
} else
|
2286
|
-
n >= 75 && n < 155 ? h = c < 68 ? t.green : t.lime : n >= 155 && n < 175 ? h = t.teal : n >= 175 && n < 195 ? h = t.cyan : n >= 195 && n < 255 ? h = t.blue : n >= 255 && n < 270 ? h = t.violet : n >= 270 && n < 295 ? h = t.magenta : n >= 295 && n < 345 && (h = t.pink);
|
2255
|
+
} else n >= 75 && n < 155 ? h = c < 68 ? t.green : t.lime : n >= 155 && n < 175 ? h = t.teal : n >= 175 && n < 195 ? h = t.cyan : n >= 195 && n < 255 ? h = t.blue : n >= 255 && n < 270 ? h = t.violet : n >= 270 && n < 295 ? h = t.magenta : n >= 295 && n < 345 && (h = t.pink);
|
2287
2256
|
return h;
|
2288
2257
|
}
|
2289
2258
|
/** Updates `ColorPicker` visuals. */
|
@@ -2322,17 +2291,16 @@ class ko {
|
|
2322
2291
|
* @this {ColorPicker}
|
2323
2292
|
*/
|
2324
2293
|
handleDismiss = ({ code: t }) => {
|
2325
|
-
this.isOpen && t ===
|
2294
|
+
this.isOpen && t === qe && this.hide();
|
2326
2295
|
};
|
2327
2296
|
/**
|
2328
2297
|
* The `ColorPicker` *scroll* event listener when open.
|
2329
2298
|
*
|
2330
2299
|
* @param e
|
2331
|
-
* @this {ColorPicker}
|
2332
2300
|
*/
|
2333
2301
|
handleScroll = (t) => {
|
2334
|
-
const { activeElement: e } =
|
2335
|
-
this.updateDropdownPosition(), ([
|
2302
|
+
const { activeElement: e } = V(this.input);
|
2303
|
+
this.updateDropdownPosition(), ([ue, Be].includes(t.type) && this.dragElement || e && this.controlKnobs.includes(e)) && (t.stopPropagation(), t.preventDefault());
|
2336
2304
|
};
|
2337
2305
|
/**
|
2338
2306
|
* The `ColorPicker` keyboard event listener for menu navigation.
|
@@ -2340,8 +2308,8 @@ class ko {
|
|
2340
2308
|
* @param e
|
2341
2309
|
*/
|
2342
2310
|
menuKeyHandler = (t) => {
|
2343
|
-
const { target: e, code: s } = t, { previousElementSibling: r, nextElementSibling: n, parentElement: i } = e, a = i && T(i, "color-options"), l = i ? [...i.children] : [], c = a &&
|
2344
|
-
[j,
|
2311
|
+
const { target: e, code: s } = t, { previousElementSibling: r, nextElementSibling: n, parentElement: i } = e, a = i && T(i, "color-options"), l = i ? [...i.children] : [], c = a && Tt(i, "grid-template-columns").split(" ").length, h = l.indexOf(e), b = h > -1 && c && l[h - c], u = h > -1 && c && l[h + c];
|
2312
|
+
[j, ot, Wt].includes(s) && t.preventDefault(), a ? b && s === ot ? _(b) : u && s === j ? _(u) : r && s === ht ? _(r) : n && s === U && _(n) : r && [ht, ot].includes(s) ? _(r) : n && [U, j].includes(s) && _(n), [je, Wt].includes(s) && this.menuClickHandler(t);
|
2345
2313
|
};
|
2346
2314
|
/**
|
2347
2315
|
* The `ColorPicker` click event listener for the colour menu presets / defaults.
|
@@ -2350,19 +2318,18 @@ class ko {
|
|
2350
2318
|
* @this {ColorPicker}
|
2351
2319
|
*/
|
2352
2320
|
menuClickHandler = (t) => {
|
2353
|
-
const { target: e } = t, { colorMenu: s } = this, r = (
|
2354
|
-
if (!r.length)
|
2355
|
-
|
2356
|
-
const n = _("li.active", s);
|
2321
|
+
const { target: e } = t, { colorMenu: s } = this, r = (yt(e, "data-value") || "").trim();
|
2322
|
+
if (!r.length) return;
|
2323
|
+
const n = z("li.active", s);
|
2357
2324
|
let i = r;
|
2358
2325
|
i = bt.includes(i) ? "white" : i, i = i === "transparent" ? "rgba(0,0,0,0)" : i;
|
2359
2326
|
const { r: a, g: l, b: c, a: h } = new y(i);
|
2360
|
-
|
2327
|
+
K(this.color, {
|
2361
2328
|
r: a,
|
2362
2329
|
g: l,
|
2363
2330
|
b: c,
|
2364
2331
|
a: h
|
2365
|
-
}), this.update(), n !== e && (n && (O(n, "active"),
|
2332
|
+
}), this.update(), n !== e && (n && (O(n, "active"), Pt(n, St)), q(e, "active"), m(e, St, "true"), bt.includes(r) && (this.value = r), ge(this));
|
2366
2333
|
};
|
2367
2334
|
/**
|
2368
2335
|
* The `ColorPicker` *touchstart* / *mousedown* events listener for control knobs.
|
@@ -2370,10 +2337,11 @@ class ko {
|
|
2370
2337
|
* @param e
|
2371
2338
|
*/
|
2372
2339
|
pointerDown = (t) => {
|
2373
|
-
|
2340
|
+
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 = Ct(l), w = s - f.scrollLeft - p.left, $ = r - f.scrollTop - p.top;
|
2374
2342
|
if (e === l || e === b ? (this.dragElement = g, this.changeControl1(w, $)) : e === c || e === u ? (this.dragElement = g, this.changeControl2($)) : (e === h || e === d) && (this.dragElement = g, this.changeAlpha($)), n) {
|
2375
|
-
const
|
2376
|
-
|
2343
|
+
const S = z("li.active", n);
|
2344
|
+
S && (O(S, "active"), Pt(S, St));
|
2377
2345
|
}
|
2378
2346
|
t.preventDefault();
|
2379
2347
|
};
|
@@ -2384,7 +2352,7 @@ class ko {
|
|
2384
2352
|
* @this
|
2385
2353
|
*/
|
2386
2354
|
pointerUp = ({ target: t }) => {
|
2387
|
-
const { parent: e } = this, s =
|
2355
|
+
const { parent: e } = this, s = V(e), r = z(`${ce}.open`, s) !== null, n = s.getSelection();
|
2388
2356
|
!this.dragElement && (!n || !n.toString().length) && !e.contains(t) && this.hide(r), this.dragElement = void 0;
|
2389
2357
|
};
|
2390
2358
|
/**
|
@@ -2394,9 +2362,8 @@ class ko {
|
|
2394
2362
|
*/
|
2395
2363
|
pointerMove = (t) => {
|
2396
2364
|
const { dragElement: e, visuals: s } = this, [r, n, i] = s, { pageX: a, pageY: l } = t;
|
2397
|
-
if (!e)
|
2398
|
-
|
2399
|
-
const c = gt(e), h = Lt(r), b = a - h.scrollLeft - c.left, u = l - h.scrollTop - c.top;
|
2365
|
+
if (!e) return;
|
2366
|
+
const c = gt(e), h = Ct(r), b = a - h.scrollLeft - c.left, u = l - h.scrollTop - c.top;
|
2400
2367
|
e === r && this.changeControl1(b, u), e === n && this.changeControl2(u), e === i && this.changeAlpha(u);
|
2401
2368
|
};
|
2402
2369
|
/**
|
@@ -2406,24 +2373,22 @@ class ko {
|
|
2406
2373
|
*/
|
2407
2374
|
handleKnobs = (t) => {
|
2408
2375
|
const { target: e, code: s } = t;
|
2409
|
-
if (![
|
2410
|
-
return;
|
2376
|
+
if (![ot, j, ht, U].includes(s)) return;
|
2411
2377
|
t.preventDefault();
|
2412
|
-
const { controlKnobs: r, visuals: n } = this, { offsetWidth: i, offsetHeight: a } = n[0], [l, c, h] = r, { activeElement: b } =
|
2378
|
+
const { controlKnobs: r, visuals: n } = this, { offsetWidth: i, offsetHeight: a } = n[0], [l, c, h] = r, { activeElement: b } = V(l), u = r.find((g) => g === b), d = a / 360;
|
2413
2379
|
if (u) {
|
2414
2380
|
let g = 0, p = 0;
|
2415
2381
|
if (e === l) {
|
2416
2382
|
const f = i / 100;
|
2417
|
-
[ht,
|
2418
|
-
} else
|
2419
|
-
e === c ? (this.controlPositions.c2y += [j, G].includes(s) ? d : -d, p = this.controlPositions.c2y, this.changeControl2(p)) : e === h && (this.controlPositions.c3y += [j, G].includes(s) ? d : -d, p = this.controlPositions.c3y, this.changeAlpha(p));
|
2383
|
+
[ht, U].includes(s) ? this.controlPositions.c1x += s === U ? f : -f : [ot, j].includes(s) && (this.controlPositions.c1y += s === j ? d : -d), g = this.controlPositions.c1x, p = this.controlPositions.c1y, this.changeControl1(g, p);
|
2384
|
+
} else e === c ? (this.controlPositions.c2y += [j, U].includes(s) ? d : -d, p = this.controlPositions.c2y, this.changeControl2(p)) : e === h && (this.controlPositions.c3y += [j, U].includes(s) ? d : -d, p = this.controlPositions.c3y, this.changeAlpha(p));
|
2420
2385
|
this.handleScroll(t);
|
2421
2386
|
}
|
2422
2387
|
};
|
2423
2388
|
/** The event listener of the colour form inputs. */
|
2424
2389
|
changeHandler = () => {
|
2425
2390
|
let t;
|
2426
|
-
const { inputs: e, format: s, value: r, input: n, controlPositions: i, visuals: a } = this, { activeElement: l } =
|
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(($) => parseFloat($.value) / ($ === b ? 100 : 1)) : e.map(($) => parseFloat($.value) / ($ !== h ? 100 : 360)), f = this.hasNonColor && bt.includes(r), w = b ? p : 1 - i.c3y / c;
|
2427
2392
|
if (l === n || l && e.includes(l)) {
|
2428
2393
|
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 = {
|
2429
2394
|
h: u,
|
@@ -2441,12 +2406,12 @@ class ko {
|
|
2441
2406
|
b: g,
|
2442
2407
|
a: w
|
2443
2408
|
};
|
2444
|
-
const { r: $, g:
|
2445
|
-
|
2409
|
+
const { r: $, g: S, b: L, a: P } = new y(t);
|
2410
|
+
K(this.color, {
|
2446
2411
|
r: $,
|
2447
|
-
g:
|
2412
|
+
g: S,
|
2448
2413
|
b: L,
|
2449
|
-
a:
|
2414
|
+
a: P
|
2450
2415
|
}), this.setControlPositions(), this.updateAppearance(), this.updateInputs(), this.updateControls(), this.updateVisuals(), l === n && f && (this.value = r);
|
2451
2416
|
}
|
2452
2417
|
};
|
@@ -2468,7 +2433,7 @@ class ko {
|
|
2468
2433
|
v: b,
|
2469
2434
|
a: u
|
2470
2435
|
});
|
2471
|
-
|
2436
|
+
K(this.color, {
|
2472
2437
|
r: d,
|
2473
2438
|
g,
|
2474
2439
|
b: p,
|
@@ -2492,7 +2457,7 @@ class ko {
|
|
2492
2457
|
v: c,
|
2493
2458
|
a: h
|
2494
2459
|
});
|
2495
|
-
|
2460
|
+
K(this.color, {
|
2496
2461
|
r: b,
|
2497
2462
|
g: u,
|
2498
2463
|
b: d,
|
@@ -2522,9 +2487,8 @@ class ko {
|
|
2522
2487
|
};
|
2523
2488
|
/** Updates the open dropdown position on *scroll* event. */
|
2524
2489
|
updateDropdownPosition() {
|
2525
|
-
const { input: t, colorPicker: e, colorMenu: s } = this, r = gt(t), { top: n, bottom: i } = r, { offsetHeight: a } = t, l =
|
2526
|
-
if (!h)
|
2527
|
-
return;
|
2490
|
+
const { input: t, colorPicker: e, colorMenu: s } = this, r = gt(t), { top: n, bottom: i } = r, { offsetHeight: a } = t, l = Ct(t).clientHeight, h = T(e, "show") ? e : s;
|
2491
|
+
if (!h) return;
|
2528
2492
|
const { offsetHeight: b } = h, u = l - i, d = n, g = n + b + a > l, p = n - b < 0;
|
2529
2493
|
(T(h, "bottom") || !p) && u < d && g ? (O(h, "bottom"), q(h, "top")) : (O(h, "top"), q(h, "bottom"));
|
2530
2494
|
}
|
@@ -2537,15 +2501,15 @@ class ko {
|
|
2537
2501
|
updateAppearance() {
|
2538
2502
|
const { componentLabels: t, color: e, parent: s, hsv: r, hex: n, format: i, controlKnobs: a } = this, { appearanceLabel: l, hexLabel: c, valueLabel: h } = t;
|
2539
2503
|
let { r: b, g: u, b: d } = e.toRgb();
|
2540
|
-
const [g, p, f] = a, w = k(r.h * 360), $ = e.a,
|
2504
|
+
const [g, p, f] = a, w = k(r.h * 360), $ = e.a, S = k(r.s * 100), L = k(r.v * 100), P = this.appearance;
|
2541
2505
|
let C = `${c} ${n.split("").join(" ")}`;
|
2542
2506
|
if (i === "hwb") {
|
2543
|
-
const { hwb: A } = this, F = k(A.w * 100),
|
2544
|
-
C = `HWB: ${w}°, ${F}%, ${
|
2507
|
+
const { hwb: A } = this, F = k(A.w * 100), Q = k(A.b * 100);
|
2508
|
+
C = `HWB: ${w}°, ${F}%, ${Q}%`, m(g, et, `${F}% & ${Q}%`), m(g, tt, `${F}`), m(p, _t, `${h}: ${C}. ${l}: ${P}.`), m(p, et, `${w}%`), m(p, tt, `${w}`);
|
2545
2509
|
} else
|
2546
|
-
[b, u, d] = [b, u, d].map(k), C = i === "hsl" ? `HSL: ${w}°, ${
|
2510
|
+
[b, u, d] = [b, u, d].map(k), C = i === "hsl" ? `HSL: ${w}°, ${S}%, ${L}%` : C, C = i === "rgb" ? `RGB: ${b}, ${u}, ${d}` : C, m(g, et, `${L}% & ${S}%`), m(g, tt, `${L}`), m(p, _t, `${h}: ${C}. ${l}: ${P}.`), m(p, et, `${w}°`), m(p, tt, `${w}`);
|
2547
2511
|
const M = k($ * 100);
|
2548
|
-
m(f,
|
2512
|
+
m(f, et, `${M}%`), m(f, tt, `${M}`);
|
2549
2513
|
const E = e.toString();
|
2550
2514
|
D(this.input, { backgroundColor: E }), this.isDark ? (T(s, "txt-light") && O(s, "txt-light"), T(s, "txt-dark") || q(s, "txt-dark")) : (T(s, "txt-dark") && O(s, "txt-dark"), T(s, "txt-light") || q(s, "txt-light"));
|
2551
2515
|
}
|
@@ -2578,7 +2542,7 @@ class ko {
|
|
2578
2542
|
let { r: g, g: p, b: f } = this.rgb;
|
2579
2543
|
[g, p, f] = [g, p, f].map(k), d = this.color.toRgbString(), a.value = `${g}`, l.value = `${p}`, c.value = `${f}`, h.value = `${b}`;
|
2580
2544
|
}
|
2581
|
-
this.value = d, !t && d !== e &&
|
2545
|
+
this.value = d, !t && d !== e && ge(this);
|
2582
2546
|
}
|
2583
2547
|
/**
|
2584
2548
|
* Toggle the `ColorPicker` dropdown visibility.
|
@@ -2613,21 +2577,21 @@ class ko {
|
|
2613
2577
|
*/
|
2614
2578
|
hide(t) {
|
2615
2579
|
if (this.isOpen) {
|
2616
|
-
const { pickerToggle: e, menuToggle: s, colorPicker: r, colorMenu: n, parent: i, input: a } = this, l = T(r, "show"), c = l ? r : n, h = l ? e : s, b = c &&
|
2617
|
-
this.value = this.color.toString(!0), c && (O(c, "show"), m(h,
|
2618
|
-
|
2619
|
-
}, b)), t ||
|
2580
|
+
const { pickerToggle: e, menuToggle: s, colorPicker: r, colorMenu: n, parent: i, input: a } = this, l = T(r, "show"), c = l ? r : n, h = l ? e : s, b = c && Qe(c);
|
2581
|
+
this.value = this.color.toString(!0), c && (O(c, "show"), m(h, Nt, "false"), setTimeout(() => {
|
2582
|
+
Ne(c), z(".show", i) || (O(i, "open"), He(this), this.isOpen = !1);
|
2583
|
+
}, b)), t || _(e), m(a, X, "-1"), h === s && m(s, X, "-1");
|
2620
2584
|
}
|
2621
2585
|
}
|
2622
2586
|
/** Removes `ColorPicker` from target `<input>`. */
|
2623
2587
|
dispose() {
|
2624
2588
|
const { input: t, parent: e } = this;
|
2625
|
-
this.hide(!0),
|
2589
|
+
this.hide(!0), he(this), [...e.children].forEach((s) => {
|
2626
2590
|
s !== t && s.remove();
|
2627
|
-
}),
|
2591
|
+
}), Pt(t, X), D(t, { backgroundColor: "" }), ["txt-light", "txt-dark"].forEach((s) => O(e, s)), ct.remove(t, Y);
|
2628
2592
|
}
|
2629
2593
|
}
|
2630
2594
|
export {
|
2631
|
-
|
2595
|
+
mo as default
|
2632
2596
|
};
|
2633
2597
|
//# sourceMappingURL=color-picker.mjs.map
|