@thednp/color-picker 2.0.0-alpha9 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- 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 +0 -0
- package/cypress/e2e/color-palette.cy.ts +0 -0
- package/cypress/e2e/color-picker.cy.ts +0 -0
- 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 +0 -0
- 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 +1 -1
- package/dist/css/color-picker.min.css +1 -1
- package/dist/css/color-picker.rtl.css +1 -1
- package/dist/css/color-picker.rtl.min.css +1 -1
- package/dist/js/color-picker.cjs +2 -2
- package/dist/js/color-picker.cjs.map +1 -1
- package/dist/js/color-picker.d.ts +11 -7
- package/dist/js/color-picker.js +2 -2
- package/dist/js/color-picker.js.map +1 -1
- package/dist/js/color-picker.mjs +254 -289
- package/dist/js/color-picker.mjs.map +1 -1
- package/dts.config.ts +0 -0
- package/package.json +54 -52
- package/src/scss/_variables.scss +0 -0
- package/src/scss/color-picker.rtl.scss +0 -0
- package/src/scss/color-picker.scss +4 -2
- package/src/ts/colorPalette.ts +0 -0
- package/src/ts/index.ts +4 -4
- 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/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
|
-
}, be = (o, t, e, s) => {
|
9
|
-
Z[t] || (Z[t] = /* @__PURE__ */ new Map());
|
10
|
-
const r = Z[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, ue, s);
|
14
|
-
}, jt = (o, t, e, s) => {
|
15
|
-
const r = Z[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 Z[t], (!n || !n.size) && o.removeEventListener(t, ue, a);
|
17
|
-
}, Ut = "aria-description", Et = "aria-expanded", Te = "aria-hidden", St = "aria-selected", et = "aria-valuenow", ot = "aria-valuetext", Re = "change", Oe = "DOMContentLoaded", De = "focusin", Fe = "focusout", _t = "keydown", Ie = "keyup", Mt = "click", Ke = "pointerdown", pe = "pointermove", Ve = "pointerup", Be = "resize", je = "scroll", qe = "touchmove", j = "ArrowDown", st = "ArrowUp", gt = "ArrowLeft", G = "ArrowRight", ze = "Enter", Ge = "Escape", Wt = "Space", Ue = "transitionDuration", _e = "transitionProperty", X = "tabindex", We = navigator.userAgentData, vt = We, { userAgent: Je } = navigator, wt = Je, Jt = /iPhone|iPad|iPod|Android/i;
|
18
|
-
vt ? vt.brands.some((o) => Jt.test(o.brand)) : Jt.test(wt);
|
19
|
-
const Zt = /(iPhone|iPod|iPad)/;
|
20
|
-
vt ? vt.brands.some((o) => Zt.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 Ze = (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.
|
@@ -65,7 +49,7 @@ const xt = (o, t) => o.getAttribute(t), m = (o, t, e) => o.setAttribute(t, e), C
|
|
65
49
|
* @param instance the component instance
|
66
50
|
*/
|
67
51
|
set: (o, t, e) => {
|
68
|
-
|
52
|
+
at(o) && (W.has(t) || W.set(t, /* @__PURE__ */ new Map()), W.get(t).set(o, e));
|
69
53
|
},
|
70
54
|
/**
|
71
55
|
* Returns all instances for specified component.
|
@@ -82,9 +66,8 @@ 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 (!
|
86
|
-
|
87
|
-
const e = ht.getAllFor(t);
|
69
|
+
if (!at(o) || !t) return null;
|
70
|
+
const e = ct.getAllFor(t);
|
88
71
|
return o && e && e.get(o) || null;
|
89
72
|
},
|
90
73
|
/**
|
@@ -94,34 +77,30 @@ const xt = (o, t) => o.getAttribute(t), m = (o, t, e) => o.setAttribute(t, e), C
|
|
94
77
|
* @param component the component's name or a unique key
|
95
78
|
*/
|
96
79
|
remove: (o, t) => {
|
97
|
-
const e =
|
98
|
-
!e || !
|
80
|
+
const e = ct.getAllFor(t);
|
81
|
+
!e || !at(o) || (e.delete(o), e.size === 0 && W.delete(t));
|
99
82
|
}
|
100
|
-
},
|
101
|
-
if (!o)
|
102
|
-
return;
|
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;
|
103
85
|
if (B(o))
|
104
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
90
|
return delete s.tagName, K(e, s);
|
110
|
-
},
|
111
|
-
if (!o || !t)
|
112
|
-
return;
|
91
|
+
}, Mt = (o, t) => {
|
92
|
+
if (!o || !t) return;
|
113
93
|
if (B(t))
|
114
94
|
return V().createElementNS(o, t);
|
115
|
-
const { tagName: e } = t, s =
|
116
|
-
if (!s)
|
117
|
-
return;
|
95
|
+
const { tagName: e } = t, s = Mt(o, e);
|
96
|
+
if (!s) return;
|
118
97
|
const r = { ...t };
|
119
98
|
return delete r.tagName, K(s, r);
|
120
|
-
},
|
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,18 +111,18 @@ 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
|
-
return
|
138
|
-
const b =
|
139
|
-
a[b] =
|
140
|
-
}),
|
141
|
-
r[c] =
|
142
|
-
}),
|
143
|
-
c in r ? i[c] = r[c] : c in a ? i[c] = a[c] : i[c] = c === l ?
|
116
|
+
return pt(n).forEach(([c, h]) => {
|
117
|
+
const b = c;
|
118
|
+
a[b] = Yt(h);
|
119
|
+
}), pt(r).forEach(([c, h]) => {
|
120
|
+
r[c] = Yt(h);
|
121
|
+
}), pt(t).forEach(([c, h]) => {
|
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
|
-
},
|
146
|
-
|
124
|
+
}, Zt = (o) => Object.fromEntries(o), eo = (o) => o.offsetHeight, D = (o, t) => {
|
125
|
+
pt(t).forEach(([e, s]) => {
|
147
126
|
if (s && B(e) && e.includes("--"))
|
148
127
|
o.style.setProperty(e, s);
|
149
128
|
else {
|
@@ -151,10 +130,10 @@ const xt = (o, t) => o.getAttribute(t), m = (o, t, e) => o.setAttribute(t, e), C
|
|
151
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
|
-
if (t &&
|
136
|
+
if (t && at(o)) {
|
158
137
|
const { offsetWidth: h, offsetHeight: b } = o;
|
159
138
|
l = h > 0 ? Math.round(e) / h : (
|
160
139
|
/* istanbul ignore next */
|
@@ -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
|
-
},
|
156
|
+
}, Ct = (o) => V(o).documentElement;
|
178
157
|
let Qt = 0, te = 0;
|
179
|
-
const J = /* @__PURE__ */ new Map(),
|
158
|
+
const J = /* @__PURE__ */ new Map(), de = (o, t) => {
|
180
159
|
let e = t ? Qt : te;
|
181
160
|
if (t) {
|
182
|
-
const s =
|
183
|
-
J.has(s) || J.set(s, r),
|
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 @@ ve(o.getRootNode().host, t) : null, _ = (o, t) => lt(o) ? o : (Q(t) ? t : V()).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
|
-
},
|
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
|
-
}, N = (o) => parseInt(o, 16),
|
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;
|
@@ -1421,23 +1400,22 @@ ve(o.getRootNode().host, t) : null, _ = (o, t) => lt(o) ? o : (Q(t) ? t : V()).q
|
|
1421
1400
|
i = a > 0.5 ? l / (2 - s - r) : l / (s + r), s === o && (n = (t - e) / l + (t < e ? 6 : 0)), s === t && (n = (e - o) / l + 2), s === e && (n = (o - t) / l + 4), n /= 6;
|
1422
1401
|
}
|
1423
1402
|
return { h: n, s: i, l: a };
|
1424
|
-
},
|
1403
|
+
}, ft = (o, t, e) => {
|
1425
1404
|
let s = e;
|
1426
1405
|
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;
|
1427
|
-
},
|
1406
|
+
}, lt = (o, t, e) => {
|
1428
1407
|
let s = 0, r = 0, n = 0;
|
1429
1408
|
if (t === 0)
|
1430
1409
|
r = e, n = e, s = e;
|
1431
1410
|
else if (e) {
|
1432
1411
|
const i = e < 0.5 ? e * (1 + t) : e + t - e * t, a = 2 * e - i;
|
1433
|
-
s =
|
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 @@ ve(o.getRootNode().host, t) : null, _ = (o, t) => lt(o) ? o : (Q(t) ? t : V()).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
|
-
let { r: s, g: r, b: n } =
|
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
|
-
if (
|
1481
|
-
return Object.assign(
|
1458
|
+
if (Se(t))
|
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,
|
@@ -1525,7 +1503,7 @@ ve(o.getRootNode().host, t) : null, _ = (o, t) => lt(o) ? o : (Q(t) ? t : V()).q
|
|
1525
1503
|
r: N(e),
|
1526
1504
|
g: N(s),
|
1527
1505
|
b: N(r),
|
1528
|
-
a:
|
1506
|
+
a: Dt(n),
|
1529
1507
|
format: "hex",
|
1530
1508
|
ok: !0
|
1531
1509
|
} : ([, e, s, r] = I.hex6.exec(t) || [], e && s && r ? {
|
@@ -1539,7 +1517,7 @@ ve(o.getRootNode().host, t) : null, _ = (o, t) => lt(o) ? o : (Q(t) ? t : V()).q
|
|
1539
1517
|
r: N(e + e),
|
1540
1518
|
g: N(s + s),
|
1541
1519
|
b: N(r + r),
|
1542
|
-
a:
|
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 ? {
|
@@ -1559,47 +1537,47 @@ ve(o.getRootNode().host, t) : null, _ = (o, t) => lt(o) ? o : (Q(t) ? t : V()).q
|
|
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 =
|
1552
|
+
static isOnePointZero = ye;
|
1553
|
+
static isPercentage = $t;
|
1576
1554
|
static isValidCSSUnit = H;
|
1577
|
-
static isNonColor =
|
1578
|
-
static isColorName =
|
1579
|
-
static isColorType =
|
1580
|
-
static pad2 =
|
1581
|
-
static clamp01 =
|
1555
|
+
static isNonColor = ke;
|
1556
|
+
static isColorName = Se;
|
1557
|
+
static isColorType = nt;
|
1558
|
+
static pad2 = G;
|
1559
|
+
static clamp01 = ut;
|
1582
1560
|
static bound01 = R;
|
1583
|
-
static boundAlpha =
|
1584
|
-
static getRGBFromName =
|
1585
|
-
static convertHexToDecimal =
|
1586
|
-
static convertDecimalToHex =
|
1561
|
+
static boundAlpha = Ot;
|
1562
|
+
static getRGBFromName = Pe;
|
1563
|
+
static convertHexToDecimal = Dt;
|
1564
|
+
static convertDecimalToHex = Ce;
|
1587
1565
|
static rgbToHsl = oe;
|
1588
1566
|
static rgbToHex = ne;
|
1589
1567
|
static rgbToHsv = re;
|
1590
1568
|
static rgbToHwb = se;
|
1591
|
-
static rgbaToHex =
|
1592
|
-
static hslToRgb =
|
1593
|
-
static hsvToRgb =
|
1594
|
-
static hueToRgb =
|
1595
|
-
static hwbToRgb =
|
1569
|
+
static rgbaToHex = At;
|
1570
|
+
static hslToRgb = Ft;
|
1571
|
+
static hsvToRgb = Ft;
|
1572
|
+
static hueToRgb = ft;
|
1573
|
+
static hwbToRgb = Le;
|
1596
1574
|
static parseIntFromHex = N;
|
1597
|
-
static stringInputToObject =
|
1575
|
+
static stringInputToObject = Ae;
|
1598
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 ? ne(e, s, r, t) :
|
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.
|
@@ -1782,15 +1760,14 @@ 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
|
-
|
1793
|
-
const { h: e, s, l: r } = this.toHsl(), { r: n, g: i, b: a } = ct(e, bt(s + t / 100), r);
|
1769
|
+
if (typeof t != "number") return this;
|
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
|
}
|
1796
1773
|
/**
|
@@ -1810,9 +1787,8 @@ class y {
|
|
1810
1787
|
* Increase the colour lightness with a given amount.
|
1811
1788
|
*/
|
1812
1789
|
lighten(t) {
|
1813
|
-
if (typeof t != "number")
|
1814
|
-
|
1815
|
-
const { h: e, s, l: r } = this.toHsl(), { r: n, g: i, b: a } = ct(e, s, bt(r + t / 100));
|
1790
|
+
if (typeof t != "number") return this;
|
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
|
}
|
1818
1794
|
/**
|
@@ -1826,9 +1802,8 @@ 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
|
-
|
1831
|
-
const { h: e, s, l: r } = this.toHsl(), { r: n, g: i, b: a } = ct(bt((e * 360 + t) % 360 / 360), s, r);
|
1805
|
+
if (typeof t != "number") return this;
|
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
|
}
|
1834
1809
|
/** Returns a clone of the current `Color` instance. */
|
@@ -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",
|
@@ -1924,22 +1899,21 @@ const Vt = {
|
|
1924
1899
|
"magenta",
|
1925
1900
|
"pink"
|
1926
1901
|
], ae = (o) => {
|
1927
|
-
if (!B(o))
|
1928
|
-
return !1;
|
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
|
);
|
@@ -1969,7 +1943,7 @@ const Vt = {
|
|
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}`,
|
@@ -2024,46 +1998,47 @@ const Vt = {
|
|
2024
1998
|
E.append(A), g.append(E);
|
2025
1999
|
}), g;
|
2026
2000
|
}, le = (o, t, e) => {
|
2027
|
-
const { input: s, format: r, componentLabels: n } = o, { defaultsLabel: i, presetsLabel: a } = n, l = e === "color-options", c = t instanceof
|
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
2064
|
a && L.append(le(o, a, "color-options")), i && i.length && L.append(le(o, i, "color-defaults"));
|
2090
|
-
const
|
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
2088
|
i && c.includes(l) && (o.value = l), m(t, X, "-1");
|
2113
|
-
},
|
2114
|
-
componentLabels:
|
2115
|
-
colorLabels:
|
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:
|
2120
|
-
const e = t ?
|
2121
|
-
e(s,
|
2122
|
-
},
|
2123
|
-
const e = t ?
|
2124
|
-
e(o.controls,
|
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);
|
2098
|
+
}, He = (o, t) => {
|
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);
|
2125
2101
|
}, ge = (o) => {
|
2126
|
-
|
2127
|
-
},
|
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
|
-
static getBoundingClientRect =
|
2145
|
-
static version =
|
2146
|
-
static colorNames =
|
2147
|
-
static colorPickerLabels =
|
2120
|
+
static getBoundingClientRect = gt;
|
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 yo {
|
|
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,41 +2149,37 @@ class yo {
|
|
2173
2149
|
* @param config instance options
|
2174
2150
|
*/
|
2175
2151
|
constructor(t, e) {
|
2176
|
-
const s =
|
2177
|
-
if (typeof t > "u")
|
2178
|
-
|
2179
|
-
if (B(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 = me(s, Y), 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
2163
|
}, this.colorKeywords = !1, this.colorPresets = !1;
|
2191
|
-
const { format: n, componentLabels: i, colorLabels: a, colorKeywords: l, colorPresets: c } =
|
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
|
-
|
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])));
|
2198
2171
|
const b = B(i) && ae(i) ? JSON.parse(i) : i;
|
2199
|
-
if (this.componentLabels = K({ ...
|
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)
|
2200
2173
|
this.colorPresets = c;
|
2201
2174
|
else if (c && ae(c)) {
|
2202
2175
|
const { hue: p, hueSteps: f, lightSteps: w, saturation: $ } = JSON.parse(c);
|
2203
|
-
this.colorPresets = new
|
2204
|
-
} else
|
2205
|
-
|
2206
|
-
|
2207
|
-
|
2208
|
-
|
2209
|
-
|
2210
|
-
this.controls = g, this.controlKnobs = [...rt("knob", g)], this.visuals = [...rt("visual-control", g)], this.update(), he(this, !0), ht.set(s, Y, 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);
|
2211
2183
|
}
|
2212
2184
|
/** Returns the current colour value */
|
2213
2185
|
get value() {
|
@@ -2223,7 +2195,7 @@ class yo {
|
|
2223
2195
|
}
|
2224
2196
|
/** Check if the colour presets include any non-colour. */
|
2225
2197
|
get hasNonColor() {
|
2226
|
-
return this.colorKeywords instanceof Array && this.colorKeywords.some((t) =>
|
2198
|
+
return this.colorKeywords instanceof Array && this.colorKeywords.some((t) => bt.includes(t));
|
2227
2199
|
}
|
2228
2200
|
/** Returns hexadecimal value of the current colour. */
|
2229
2201
|
get hex() {
|
@@ -2280,8 +2252,7 @@ class yo {
|
|
2280
2252
|
else if (n >= 45 && n < 75) {
|
2281
2253
|
const b = n > 46 && n < 54 && c < 80 && a > 90, u = n >= 54 && n < 75 && c < 80;
|
2282
2254
|
h = b ? t.gold : t.yellow, h = u ? t.olive : h;
|
2283
|
-
} else
|
2284
|
-
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);
|
2285
2256
|
return h;
|
2286
2257
|
}
|
2287
2258
|
/** Updates `ColorPicker` visuals. */
|
@@ -2320,7 +2291,7 @@ class yo {
|
|
2320
2291
|
* @this {ColorPicker}
|
2321
2292
|
*/
|
2322
2293
|
handleDismiss = ({ code: t }) => {
|
2323
|
-
this.isOpen && t ===
|
2294
|
+
this.isOpen && t === qe && this.hide();
|
2324
2295
|
};
|
2325
2296
|
/**
|
2326
2297
|
* The `ColorPicker` *scroll* event listener when open.
|
@@ -2329,7 +2300,7 @@ class yo {
|
|
2329
2300
|
*/
|
2330
2301
|
handleScroll = (t) => {
|
2331
2302
|
const { activeElement: e } = V(this.input);
|
2332
|
-
this.updateDropdownPosition(), ([
|
2303
|
+
this.updateDropdownPosition(), ([ue, Be].includes(t.type) && this.dragElement || e && this.controlKnobs.includes(e)) && (t.stopPropagation(), t.preventDefault());
|
2333
2304
|
};
|
2334
2305
|
/**
|
2335
2306
|
* The `ColorPicker` keyboard event listener for menu navigation.
|
@@ -2337,8 +2308,8 @@ class yo {
|
|
2337
2308
|
* @param e
|
2338
2309
|
*/
|
2339
2310
|
menuKeyHandler = (t) => {
|
2340
|
-
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 &&
|
2341
|
-
[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);
|
2342
2313
|
};
|
2343
2314
|
/**
|
2344
2315
|
* The `ColorPicker` click event listener for the colour menu presets / defaults.
|
@@ -2347,19 +2318,18 @@ class yo {
|
|
2347
2318
|
* @this {ColorPicker}
|
2348
2319
|
*/
|
2349
2320
|
menuClickHandler = (t) => {
|
2350
|
-
const { target: e } = t, { colorMenu: s } = this, r = (
|
2351
|
-
if (!r.length)
|
2352
|
-
|
2353
|
-
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);
|
2354
2324
|
let i = r;
|
2355
|
-
i =
|
2325
|
+
i = bt.includes(i) ? "white" : i, i = i === "transparent" ? "rgba(0,0,0,0)" : i;
|
2356
2326
|
const { r: a, g: l, b: c, a: h } = new y(i);
|
2357
2327
|
K(this.color, {
|
2358
2328
|
r: a,
|
2359
2329
|
g: l,
|
2360
2330
|
b: c,
|
2361
2331
|
a: h
|
2362
|
-
}), 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));
|
2363
2333
|
};
|
2364
2334
|
/**
|
2365
2335
|
* The `ColorPicker` *touchstart* / *mousedown* events listener for control knobs.
|
@@ -2367,12 +2337,11 @@ class yo {
|
|
2367
2337
|
* @param e
|
2368
2338
|
*/
|
2369
2339
|
pointerDown = (t) => {
|
2370
|
-
if (t.button !== 0)
|
2371
|
-
|
2372
|
-
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 = ut(g), f = Lt(l), w = s - f.scrollLeft - p.left, $ = r - f.scrollTop - p.top;
|
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;
|
2373
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) {
|
2374
|
-
const
|
2375
|
-
|
2343
|
+
const S = z("li.active", n);
|
2344
|
+
S && (O(S, "active"), Pt(S, St));
|
2376
2345
|
}
|
2377
2346
|
t.preventDefault();
|
2378
2347
|
};
|
@@ -2383,7 +2352,7 @@ class yo {
|
|
2383
2352
|
* @this
|
2384
2353
|
*/
|
2385
2354
|
pointerUp = ({ target: t }) => {
|
2386
|
-
const { parent: e } = this, s = V(e), r =
|
2355
|
+
const { parent: e } = this, s = V(e), r = z(`${ce}.open`, s) !== null, n = s.getSelection();
|
2387
2356
|
!this.dragElement && (!n || !n.toString().length) && !e.contains(t) && this.hide(r), this.dragElement = void 0;
|
2388
2357
|
};
|
2389
2358
|
/**
|
@@ -2393,9 +2362,8 @@ class yo {
|
|
2393
2362
|
*/
|
2394
2363
|
pointerMove = (t) => {
|
2395
2364
|
const { dragElement: e, visuals: s } = this, [r, n, i] = s, { pageX: a, pageY: l } = t;
|
2396
|
-
if (!e)
|
2397
|
-
|
2398
|
-
const c = ut(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;
|
2399
2367
|
e === r && this.changeControl1(b, u), e === n && this.changeControl2(u), e === i && this.changeAlpha(u);
|
2400
2368
|
};
|
2401
2369
|
/**
|
@@ -2405,24 +2373,22 @@ class yo {
|
|
2405
2373
|
*/
|
2406
2374
|
handleKnobs = (t) => {
|
2407
2375
|
const { target: e, code: s } = t;
|
2408
|
-
if (![
|
2409
|
-
return;
|
2376
|
+
if (![ot, j, ht, U].includes(s)) return;
|
2410
2377
|
t.preventDefault();
|
2411
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;
|
2412
2379
|
if (u) {
|
2413
2380
|
let g = 0, p = 0;
|
2414
2381
|
if (e === l) {
|
2415
2382
|
const f = i / 100;
|
2416
|
-
[
|
2417
|
-
} else
|
2418
|
-
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));
|
2419
2385
|
this.handleScroll(t);
|
2420
2386
|
}
|
2421
2387
|
};
|
2422
2388
|
/** The event listener of the colour form inputs. */
|
2423
2389
|
changeHandler = () => {
|
2424
2390
|
let t;
|
2425
|
-
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 &&
|
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;
|
2426
2392
|
if (l === n || l && e.includes(l)) {
|
2427
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 = {
|
2428
2394
|
h: u,
|
@@ -2440,12 +2406,12 @@ class yo {
|
|
2440
2406
|
b: g,
|
2441
2407
|
a: w
|
2442
2408
|
};
|
2443
|
-
const { r: $, g:
|
2409
|
+
const { r: $, g: S, b: L, a: P } = new y(t);
|
2444
2410
|
K(this.color, {
|
2445
2411
|
r: $,
|
2446
|
-
g:
|
2412
|
+
g: S,
|
2447
2413
|
b: L,
|
2448
|
-
a:
|
2414
|
+
a: P
|
2449
2415
|
}), this.setControlPositions(), this.updateAppearance(), this.updateInputs(), this.updateControls(), this.updateVisuals(), l === n && f && (this.value = r);
|
2450
2416
|
}
|
2451
2417
|
};
|
@@ -2521,9 +2487,8 @@ class yo {
|
|
2521
2487
|
};
|
2522
2488
|
/** Updates the open dropdown position on *scroll* event. */
|
2523
2489
|
updateDropdownPosition() {
|
2524
|
-
const { input: t, colorPicker: e, colorMenu: s } = this, r =
|
2525
|
-
if (!h)
|
2526
|
-
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;
|
2527
2492
|
const { offsetHeight: b } = h, u = l - i, d = n, g = n + b + a > l, p = n - b < 0;
|
2528
2493
|
(T(h, "bottom") || !p) && u < d && g ? (O(h, "bottom"), q(h, "top")) : (O(h, "top"), q(h, "bottom"));
|
2529
2494
|
}
|
@@ -2536,15 +2501,15 @@ class yo {
|
|
2536
2501
|
updateAppearance() {
|
2537
2502
|
const { componentLabels: t, color: e, parent: s, hsv: r, hex: n, format: i, controlKnobs: a } = this, { appearanceLabel: l, hexLabel: c, valueLabel: h } = t;
|
2538
2503
|
let { r: b, g: u, b: d } = e.toRgb();
|
2539
|
-
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;
|
2540
2505
|
let C = `${c} ${n.split("").join(" ")}`;
|
2541
2506
|
if (i === "hwb") {
|
2542
|
-
const { hwb: A } = this, F = k(A.w * 100),
|
2543
|
-
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}`);
|
2544
2509
|
} else
|
2545
|
-
[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}`);
|
2546
2511
|
const M = k($ * 100);
|
2547
|
-
m(f,
|
2512
|
+
m(f, et, `${M}%`), m(f, tt, `${M}`);
|
2548
2513
|
const E = e.toString();
|
2549
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"));
|
2550
2515
|
}
|
@@ -2587,12 +2552,12 @@ class yo {
|
|
2587
2552
|
togglePicker = (t) => {
|
2588
2553
|
t && t.preventDefault();
|
2589
2554
|
const { colorPicker: e } = this;
|
2590
|
-
this.isOpen && T(e, "show") ? this.hide(!0) :
|
2555
|
+
this.isOpen && T(e, "show") ? this.hide(!0) : Ht(this, e);
|
2591
2556
|
};
|
2592
2557
|
/** Shows the `ColorPicker` dropdown. */
|
2593
2558
|
showPicker = () => {
|
2594
2559
|
const { colorPicker: t } = this;
|
2595
|
-
["top", "bottom"].some((e) => T(t, e)) ||
|
2560
|
+
["top", "bottom"].some((e) => T(t, e)) || Ht(this, t);
|
2596
2561
|
};
|
2597
2562
|
/**
|
2598
2563
|
* Toggles the visibility of the `ColorPicker` presets menu.
|
@@ -2603,7 +2568,7 @@ class yo {
|
|
2603
2568
|
toggleMenu = (t) => {
|
2604
2569
|
t && t.preventDefault();
|
2605
2570
|
const { colorMenu: e } = this;
|
2606
|
-
this.isOpen && T(e, "show") ? this.hide(!0) :
|
2571
|
+
this.isOpen && T(e, "show") ? this.hide(!0) : Ht(this, e);
|
2607
2572
|
};
|
2608
2573
|
/**
|
2609
2574
|
* Hides the currently open `ColorPicker` dropdown.
|
@@ -2612,10 +2577,10 @@ class yo {
|
|
2612
2577
|
*/
|
2613
2578
|
hide(t) {
|
2614
2579
|
if (this.isOpen) {
|
2615
|
-
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 &&
|
2616
|
-
this.value = this.color.toString(!0), c && (O(c, "show"), m(h,
|
2617
|
-
|
2618
|
-
}, 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");
|
2619
2584
|
}
|
2620
2585
|
}
|
2621
2586
|
/** Removes `ColorPicker` from target `<input>`. */
|
@@ -2623,10 +2588,10 @@ class yo {
|
|
2623
2588
|
const { input: t, parent: e } = this;
|
2624
2589
|
this.hide(!0), he(this), [...e.children].forEach((s) => {
|
2625
2590
|
s !== t && s.remove();
|
2626
|
-
}),
|
2591
|
+
}), Pt(t, X), D(t, { backgroundColor: "" }), ["txt-light", "txt-dark"].forEach((s) => O(e, s)), ct.remove(t, Y);
|
2627
2592
|
}
|
2628
2593
|
}
|
2629
2594
|
export {
|
2630
|
-
|
2595
|
+
mo as default
|
2631
2596
|
};
|
2632
2597
|
//# sourceMappingURL=color-picker.mjs.map
|