@ryanhelsing/ry-ui 1.0.0 → 1.0.1
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/USING_CDN.md +390 -0
- package/dist/components/ry-example.d.ts +7 -0
- package/dist/components/ry-example.d.ts.map +1 -1
- package/dist/css/ry-structure.css +30 -0
- package/dist/css/ry-theme.css +14 -0
- package/dist/css/ry-ui.css +8 -0
- package/dist/ry-ui.js +87 -73
- package/dist/ry-ui.js.map +1 -1
- package/dist/themes/dark.css +92 -0
- package/dist/themes/light.css +38 -0
- package/dist/themes/ocean.css +48 -0
- package/package.json +6 -4
package/dist/ry-ui.js
CHANGED
|
@@ -89,7 +89,7 @@ class d extends HTMLElement {
|
|
|
89
89
|
this.on(t, "keydown", a), i?.focus();
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
|
-
const
|
|
92
|
+
const E = [
|
|
93
93
|
// Layout
|
|
94
94
|
"page",
|
|
95
95
|
"header",
|
|
@@ -135,7 +135,7 @@ const C = [
|
|
|
135
135
|
"color-picker",
|
|
136
136
|
"color-input"
|
|
137
137
|
], S = new RegExp(
|
|
138
|
-
`<(/?)(${
|
|
138
|
+
`<(/?)(${E.join("|")})(\\s|>|/)`,
|
|
139
139
|
"g"
|
|
140
140
|
);
|
|
141
141
|
function k(o) {
|
|
@@ -449,7 +449,7 @@ class F extends d {
|
|
|
449
449
|
}
|
|
450
450
|
}
|
|
451
451
|
customElements.define("ry-theme-toggle", F);
|
|
452
|
-
class
|
|
452
|
+
class j extends d {
|
|
453
453
|
setup() {
|
|
454
454
|
this.#t();
|
|
455
455
|
const t = this.$("[close]");
|
|
@@ -469,8 +469,8 @@ class B extends d {
|
|
|
469
469
|
}, 200), this.emit("close");
|
|
470
470
|
}
|
|
471
471
|
}
|
|
472
|
-
customElements.define("ry-alert",
|
|
473
|
-
class
|
|
472
|
+
customElements.define("ry-alert", j);
|
|
473
|
+
class B extends d {
|
|
474
474
|
setup() {
|
|
475
475
|
this.#t();
|
|
476
476
|
}
|
|
@@ -486,7 +486,7 @@ class j extends d {
|
|
|
486
486
|
i.setAttribute("data-ry-target", "label"), i.className = "ry-label", i.setAttribute("for", s), i.textContent = t, this.insertBefore(i, e);
|
|
487
487
|
}
|
|
488
488
|
}
|
|
489
|
-
customElements.define("ry-field",
|
|
489
|
+
customElements.define("ry-field", B);
|
|
490
490
|
let R = 0;
|
|
491
491
|
class P extends d {
|
|
492
492
|
#t = null;
|
|
@@ -575,7 +575,7 @@ class K extends d {
|
|
|
575
575
|
}
|
|
576
576
|
}
|
|
577
577
|
customElements.define("ry-tooltip", K);
|
|
578
|
-
class
|
|
578
|
+
class N extends d {
|
|
579
579
|
#t = null;
|
|
580
580
|
#e = 0;
|
|
581
581
|
setup() {
|
|
@@ -620,8 +620,8 @@ class W extends d {
|
|
|
620
620
|
this.state === "open" ? this.close() : this.open();
|
|
621
621
|
}
|
|
622
622
|
}
|
|
623
|
-
customElements.define("ry-drawer",
|
|
624
|
-
const
|
|
623
|
+
customElements.define("ry-drawer", N);
|
|
624
|
+
const U = 4e3;
|
|
625
625
|
class p extends d {
|
|
626
626
|
#t = null;
|
|
627
627
|
static observedAttributes = ["variant", "duration"];
|
|
@@ -651,7 +651,7 @@ class p extends d {
|
|
|
651
651
|
this.#s();
|
|
652
652
|
const t = this.$("[close]");
|
|
653
653
|
t && this.on(t, "click", () => this.dismiss());
|
|
654
|
-
const e = parseInt(this.getAttribute("duration") ?? String(
|
|
654
|
+
const e = parseInt(this.getAttribute("duration") ?? String(U), 10);
|
|
655
655
|
e > 0 && (this.#t = setTimeout(() => this.dismiss(), e)), requestAnimationFrame(() => {
|
|
656
656
|
this.state = "visible";
|
|
657
657
|
});
|
|
@@ -684,8 +684,8 @@ class p extends d {
|
|
|
684
684
|
}
|
|
685
685
|
}
|
|
686
686
|
customElements.define("ry-toast", p);
|
|
687
|
-
let
|
|
688
|
-
class
|
|
687
|
+
let W = 0;
|
|
688
|
+
class V extends d {
|
|
689
689
|
#t = null;
|
|
690
690
|
#e = -1;
|
|
691
691
|
#i = "";
|
|
@@ -694,7 +694,7 @@ class N extends d {
|
|
|
694
694
|
_options = [];
|
|
695
695
|
static observedAttributes = ["value", "disabled"];
|
|
696
696
|
setup() {
|
|
697
|
-
this.#t = `ry-select-${++
|
|
697
|
+
this.#t = `ry-select-${++W}`, this.#r(), this.hasAttribute("tabindex") || this.setAttribute("tabindex", "0"), this.on(this, "click", this.#n), this.on(this, "keydown", this.#l), this.on(document, "click", this.#c), this.hasAttribute("data-ry-state") || (this.state = "closed");
|
|
698
698
|
const t = this.getAttribute("value");
|
|
699
699
|
t && (this.value = t);
|
|
700
700
|
}
|
|
@@ -757,10 +757,10 @@ class N extends d {
|
|
|
757
757
|
t.preventDefault(), e ? this.#u() : this.open();
|
|
758
758
|
break;
|
|
759
759
|
case "ArrowUp":
|
|
760
|
-
t.preventDefault(), e && this.#
|
|
760
|
+
t.preventDefault(), e && this.#f();
|
|
761
761
|
break;
|
|
762
762
|
case "Home":
|
|
763
|
-
e && (t.preventDefault(), this.#
|
|
763
|
+
e && (t.preventDefault(), this.#b());
|
|
764
764
|
break;
|
|
765
765
|
case "End":
|
|
766
766
|
e && (t.preventDefault(), this.#g());
|
|
@@ -806,11 +806,11 @@ class N extends d {
|
|
|
806
806
|
const t = this.$$('[data-ry-target="option"]:not([data-disabled])'), e = Math.min(this.#e + 1, t.length - 1);
|
|
807
807
|
this.#a(e);
|
|
808
808
|
}
|
|
809
|
-
#
|
|
809
|
+
#f() {
|
|
810
810
|
const t = Math.max(this.#e - 1, 0);
|
|
811
811
|
this.#a(t);
|
|
812
812
|
}
|
|
813
|
-
#
|
|
813
|
+
#b() {
|
|
814
814
|
this.#a(0);
|
|
815
815
|
}
|
|
816
816
|
#g() {
|
|
@@ -867,10 +867,10 @@ class N extends d {
|
|
|
867
867
|
this.#s && clearTimeout(this.#s);
|
|
868
868
|
}
|
|
869
869
|
}
|
|
870
|
-
class
|
|
870
|
+
class q extends HTMLElement {
|
|
871
871
|
}
|
|
872
|
-
customElements.define("ry-option",
|
|
873
|
-
customElements.define("ry-select",
|
|
872
|
+
customElements.define("ry-option", q);
|
|
873
|
+
customElements.define("ry-select", V);
|
|
874
874
|
const v = {
|
|
875
875
|
// Close / X
|
|
876
876
|
close: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M18 6L6 18"/><path d="M6 6l12 12"/></svg>',
|
|
@@ -994,9 +994,9 @@ class z extends d {
|
|
|
994
994
|
let s = t;
|
|
995
995
|
for (; s.length > 0; ) {
|
|
996
996
|
if (s.startsWith("/*")) {
|
|
997
|
-
const
|
|
998
|
-
if (
|
|
999
|
-
e.push({ type: "comment", value: s.slice(0,
|
|
997
|
+
const b = s.indexOf("*/");
|
|
998
|
+
if (b !== -1) {
|
|
999
|
+
e.push({ type: "comment", value: s.slice(0, b + 2) }), s = s.slice(b + 2);
|
|
1000
1000
|
continue;
|
|
1001
1001
|
}
|
|
1002
1002
|
}
|
|
@@ -1042,8 +1042,8 @@ class z extends d {
|
|
|
1042
1042
|
}
|
|
1043
1043
|
const $ = s.match(/^([\w-]+)/);
|
|
1044
1044
|
if ($?.[1]) {
|
|
1045
|
-
const
|
|
1046
|
-
["inherit", "initial", "unset", "none", "auto", "transparent", "solid", "dashed", "dotted", "flex", "grid", "block", "inline", "inline-block", "absolute", "relative", "fixed", "sticky"].includes(
|
|
1045
|
+
const b = $[1];
|
|
1046
|
+
["inherit", "initial", "unset", "none", "auto", "transparent", "solid", "dashed", "dotted", "flex", "grid", "block", "inline", "inline-block", "absolute", "relative", "fixed", "sticky"].includes(b) ? e.push({ type: "keyword", value: b }) : e.push({ type: "value", value: b }), s = s.slice(b.length);
|
|
1047
1047
|
continue;
|
|
1048
1048
|
}
|
|
1049
1049
|
const x = s[0];
|
|
@@ -1241,20 +1241,34 @@ class Y extends d {
|
|
|
1241
1241
|
setup() {
|
|
1242
1242
|
const t = this.$("template");
|
|
1243
1243
|
if (!t) return;
|
|
1244
|
-
const e = this.#
|
|
1244
|
+
const e = this.$('script[slot="js"]'), s = e ? this.#e(e.textContent ?? "") : null, i = this.#e(t.innerHTML), r = k(i), a = this.hasAttribute("stacked");
|
|
1245
1245
|
this.innerHTML = `
|
|
1246
1246
|
<div data-ry-target="preview" class="ry-example__preview"></div>
|
|
1247
1247
|
<div data-ry-target="code" class="ry-example__code"></div>
|
|
1248
|
-
|
|
1248
|
+
${s ? '<div data-ry-target="usage" class="ry-example__usage"></div>' : ""}
|
|
1249
|
+
`, a && this.setAttribute("data-stacked", "");
|
|
1250
|
+
const n = document.createElement("ry-code");
|
|
1251
|
+
n.setAttribute("language", "html"), n.setAttribute("title", this.getAttribute("title") ?? "Example"), n.textContent = i, this.$('[data-ry-target="code"]').appendChild(n);
|
|
1252
|
+
const l = document.createElement("template");
|
|
1253
|
+
l.innerHTML = r, this.$('[data-ry-target="preview"]').appendChild(l.content), s && this.#t(s);
|
|
1254
|
+
}
|
|
1255
|
+
#t(t) {
|
|
1256
|
+
const e = this.$('[data-ry-target="usage"]');
|
|
1257
|
+
if (!e) return;
|
|
1258
|
+
const s = document.createElement("button");
|
|
1259
|
+
s.className = "ry-example__usage-toggle", s.type = "button", s.innerHTML = '<span>JS Usage</span><ry-icon name="chevron-down" size="16"></ry-icon>', s.setAttribute("aria-expanded", "false");
|
|
1260
|
+
const i = document.createElement("div");
|
|
1261
|
+
i.className = "ry-example__usage-panel", i.hidden = !0;
|
|
1249
1262
|
const r = document.createElement("ry-code");
|
|
1250
|
-
r.setAttribute("language", "
|
|
1251
|
-
|
|
1252
|
-
|
|
1263
|
+
r.setAttribute("language", "js"), r.setAttribute("title", "JavaScript"), r.textContent = t, i.appendChild(r), e.appendChild(s), e.appendChild(i), this.on(s, "click", () => {
|
|
1264
|
+
const a = s.getAttribute("aria-expanded") === "true";
|
|
1265
|
+
s.setAttribute("aria-expanded", String(!a)), i.hidden = a;
|
|
1266
|
+
});
|
|
1253
1267
|
}
|
|
1254
1268
|
/**
|
|
1255
1269
|
* Normalize indentation by removing common leading whitespace
|
|
1256
1270
|
*/
|
|
1257
|
-
#
|
|
1271
|
+
#e(t) {
|
|
1258
1272
|
const e = t.split(`
|
|
1259
1273
|
`);
|
|
1260
1274
|
for (; e.length && !e[0].trim(); ) e.shift();
|
|
@@ -1463,7 +1477,7 @@ class tt extends d {
|
|
|
1463
1477
|
this.#i && this.on(this.#i, "pointerdown", this.#a);
|
|
1464
1478
|
for (const [t, e] of this.#r)
|
|
1465
1479
|
this.on(e, "pointerdown", (s) => this.#u(s, t)), this.on(e, "keydown", (s) => this.#g(s, t));
|
|
1466
|
-
this.on(document, "pointermove", this.#
|
|
1480
|
+
this.on(document, "pointermove", this.#f), this.on(document, "pointerup", this.#b);
|
|
1467
1481
|
}
|
|
1468
1482
|
#a = (t) => {
|
|
1469
1483
|
if (this.disabled) return;
|
|
@@ -1478,12 +1492,12 @@ class tt extends d {
|
|
|
1478
1492
|
#u = (t, e) => {
|
|
1479
1493
|
this.disabled || (t.stopPropagation(), this.#t = !0, this.#e = e, t.target.setPointerCapture(t.pointerId));
|
|
1480
1494
|
};
|
|
1481
|
-
#
|
|
1495
|
+
#f = (t) => {
|
|
1482
1496
|
if (!this.#t || !this.#e) return;
|
|
1483
1497
|
const e = this.#w(t);
|
|
1484
1498
|
this.hasAttribute("range") ? this.#e === "start" ? this.start = Math.min(e, this.end) : this.#e === "end" && (this.end = Math.max(e, this.start)) : this.value = e, this.#k(), this.#m();
|
|
1485
1499
|
};
|
|
1486
|
-
#
|
|
1500
|
+
#b = () => {
|
|
1487
1501
|
this.#t && (this.#t = !1, this.#e = null, this.#x());
|
|
1488
1502
|
};
|
|
1489
1503
|
#g = (t, e) => {
|
|
@@ -1637,7 +1651,7 @@ class et extends d {
|
|
|
1637
1651
|
`, this.#s = this.$('[data-ry-target="ring"]'), this.#r = this.$('[data-ry-target="indicator"]'), this.#n = this.$('[data-ry-target="display"]');
|
|
1638
1652
|
}
|
|
1639
1653
|
#c() {
|
|
1640
|
-
this.#s && (this.on(this.#s, "mousedown", this.#p), this.on(document, "mousemove", this.#a), this.on(document, "mouseup", this.#u), this.on(this.#s, "touchstart", this.#
|
|
1654
|
+
this.#s && (this.on(this.#s, "mousedown", this.#p), this.on(document, "mousemove", this.#a), this.on(document, "mouseup", this.#u), this.on(this.#s, "touchstart", this.#f), this.on(document, "touchmove", this.#b), this.on(document, "touchend", this.#g), this.on(this.#s, "wheel", this.#o), this.on(this, "keydown", this.#w));
|
|
1641
1655
|
}
|
|
1642
1656
|
#p = (t) => {
|
|
1643
1657
|
this.disabled || (t.preventDefault(), this.#t = !0, this.#e = t.clientY, this.#i = this.value, this.#s?.classList.add("ry-knob__ring--dragging"), this.setAttribute("data-dragging", ""));
|
|
@@ -1650,10 +1664,10 @@ class et extends d {
|
|
|
1650
1664
|
#u = () => {
|
|
1651
1665
|
this.#t && (this.#t = !1, this.#s?.classList.remove("ry-knob__ring--dragging"), this.removeAttribute("data-dragging"), this.#m());
|
|
1652
1666
|
};
|
|
1653
|
-
#
|
|
1667
|
+
#f = (t) => {
|
|
1654
1668
|
this.disabled || (t.preventDefault(), this.#t = !0, this.#e = t.touches[0]?.clientY ?? 0, this.#i = this.value, this.#s?.classList.add("ry-knob__ring--dragging"), this.setAttribute("data-dragging", ""));
|
|
1655
1669
|
};
|
|
1656
|
-
#
|
|
1670
|
+
#b = (t) => {
|
|
1657
1671
|
if (!this.#t) return;
|
|
1658
1672
|
t.preventDefault();
|
|
1659
1673
|
const e = t.touches[0];
|
|
@@ -1761,7 +1775,7 @@ class et extends d {
|
|
|
1761
1775
|
}
|
|
1762
1776
|
}
|
|
1763
1777
|
customElements.define("ry-knob", et);
|
|
1764
|
-
function
|
|
1778
|
+
function f(o) {
|
|
1765
1779
|
const t = o.h / 360, e = o.s / 100, s = o.v / 100;
|
|
1766
1780
|
let i = 0, r = 0, a = 0;
|
|
1767
1781
|
const n = Math.floor(t * 6), l = t * 6 - n, h = s * (1 - e), c = s * (1 - l * e), u = s * (1 - (1 - l) * e);
|
|
@@ -1829,7 +1843,7 @@ function st(o) {
|
|
|
1829
1843
|
v: Math.round(s * 100)
|
|
1830
1844
|
};
|
|
1831
1845
|
}
|
|
1832
|
-
function
|
|
1846
|
+
function C(o) {
|
|
1833
1847
|
const t = (e) => e.toString(16).padStart(2, "0");
|
|
1834
1848
|
return `#${t(o.r)}${t(o.g)}${t(o.b)}`;
|
|
1835
1849
|
}
|
|
@@ -1896,8 +1910,8 @@ class rt extends d {
|
|
|
1896
1910
|
#p = null;
|
|
1897
1911
|
#a = null;
|
|
1898
1912
|
#u = null;
|
|
1899
|
-
#b = null;
|
|
1900
1913
|
#f = null;
|
|
1914
|
+
#b = null;
|
|
1901
1915
|
#g = null;
|
|
1902
1916
|
#o = null;
|
|
1903
1917
|
#w = null;
|
|
@@ -1946,10 +1960,10 @@ class rt extends d {
|
|
|
1946
1960
|
<span data-ry-target="trigger-color" class="ry-color-picker__trigger-color"></span>
|
|
1947
1961
|
</button>
|
|
1948
1962
|
<div data-ry-target="panel" class="ry-color-picker__panel">${i}</div>
|
|
1949
|
-
`, this.#c = this.$('[data-ry-target="trigger"]'), this.#p = this.$('[data-ry-target="panel"]'), this.#a = this.$('[data-ry-target="grid"]'), this.#u = this.$('[data-ry-target="grid-handle"]'), this.#
|
|
1963
|
+
`, this.#c = this.$('[data-ry-target="trigger"]'), this.#p = this.$('[data-ry-target="panel"]'), this.#a = this.$('[data-ry-target="grid"]'), this.#u = this.$('[data-ry-target="grid-handle"]'), this.#f = this.$('[data-ry-target="hue-slider"]'), this.#b = this.$('[data-ry-target="hue-handle"]'), this.#g = this.$('[data-ry-target="alpha-slider"]'), this.#o = this.$('[data-ry-target="alpha-handle"]'), this.#w = this.$('[data-ry-target="preview"]'), this.#h = this.$('[data-ry-target="input"]');
|
|
1950
1964
|
}
|
|
1951
1965
|
#k() {
|
|
1952
|
-
this.#c && this.on(this.#c, "click", this.#m), this.on(document, "click", this.#x), this.on(document, "keydown", this.#
|
|
1966
|
+
this.#c && this.on(this.#c, "click", this.#m), this.on(document, "click", this.#x), this.on(document, "keydown", this.#j), this.#a && this.on(this.#a, "pointerdown", this.#R), this.#u && this.on(this.#u, "keydown", this.#P), this.#f && this.on(this.#f, "pointerdown", this.#O), this.#b && this.on(this.#b, "keydown", this.#K), this.#g && this.on(this.#g, "pointerdown", this.#N), this.#o && this.on(this.#o, "keydown", this.#U), this.on(document, "pointermove", this.#W), this.on(document, "pointerup", this.#V), this.#h && (this.on(this.#h, "change", this.#T), this.on(this.#h, "keydown", this.#q));
|
|
1953
1967
|
const t = this.$('[data-ry-target="format-toggle"]');
|
|
1954
1968
|
t && this.on(t, "click", this.#z);
|
|
1955
1969
|
const e = this.$('[data-ry-target="swatches"]');
|
|
@@ -1971,16 +1985,16 @@ class rt extends d {
|
|
|
1971
1985
|
#x = (t) => {
|
|
1972
1986
|
this.state === "open" && (this.contains(t.target) || this.close());
|
|
1973
1987
|
};
|
|
1974
|
-
#
|
|
1988
|
+
#j = (t) => {
|
|
1975
1989
|
t.key === "Escape" && this.state === "open" && (this.close(), this.#c?.focus());
|
|
1976
1990
|
};
|
|
1977
1991
|
open() {
|
|
1978
|
-
this.hasAttribute("inline") || (this.#
|
|
1992
|
+
this.hasAttribute("inline") || (this.#B(), this.state = "open");
|
|
1979
1993
|
}
|
|
1980
1994
|
close() {
|
|
1981
1995
|
this.hasAttribute("inline") || (this.state = "closed", this.removeAttribute("data-ry-position"));
|
|
1982
1996
|
}
|
|
1983
|
-
#
|
|
1997
|
+
#B() {
|
|
1984
1998
|
if (!this.#p || !this.#c) return;
|
|
1985
1999
|
const t = this.#c.getBoundingClientRect(), e = 320, i = window.innerHeight - t.bottom, r = t.top;
|
|
1986
2000
|
i < e && r > i ? this.setAttribute("data-ry-position", "top") : this.setAttribute("data-ry-position", "bottom");
|
|
@@ -1989,9 +2003,9 @@ class rt extends d {
|
|
|
1989
2003
|
// Grid handlers
|
|
1990
2004
|
// ───────────────────────────────────────────────────────────────────────────
|
|
1991
2005
|
#R = (t) => {
|
|
1992
|
-
this.disabled || (t.preventDefault(), this.#r = !0, this.#u?.focus(), this.#
|
|
2006
|
+
this.disabled || (t.preventDefault(), this.#r = !0, this.#u?.focus(), this.#C(t));
|
|
1993
2007
|
};
|
|
1994
|
-
#
|
|
2008
|
+
#C(t) {
|
|
1995
2009
|
if (!this.#a) return;
|
|
1996
2010
|
const e = this.#a.getBoundingClientRect(), s = Math.max(0, Math.min(1, (t.clientX - e.left) / e.width)), i = Math.max(0, Math.min(1, (t.clientY - e.top) / e.height));
|
|
1997
2011
|
this.#e = Math.round(s * 100), this.#i = Math.round((1 - i) * 100), this.#y(), this.#A();
|
|
@@ -2020,11 +2034,11 @@ class rt extends d {
|
|
|
2020
2034
|
// Hue handlers
|
|
2021
2035
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2022
2036
|
#O = (t) => {
|
|
2023
|
-
this.disabled || (t.preventDefault(), this.#n = !0, this.#
|
|
2037
|
+
this.disabled || (t.preventDefault(), this.#n = !0, this.#b?.focus(), this.#E(t));
|
|
2024
2038
|
};
|
|
2025
|
-
#
|
|
2026
|
-
if (!this.#
|
|
2027
|
-
const e = this.#
|
|
2039
|
+
#E(t) {
|
|
2040
|
+
if (!this.#f) return;
|
|
2041
|
+
const e = this.#f.getBoundingClientRect(), s = Math.max(0, Math.min(1, (t.clientX - e.left) / e.width));
|
|
2028
2042
|
this.#t = Math.round(s * 360), this.#y(), this.#A();
|
|
2029
2043
|
}
|
|
2030
2044
|
#K = (t) => {
|
|
@@ -2046,7 +2060,7 @@ class rt extends d {
|
|
|
2046
2060
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2047
2061
|
// Alpha handlers
|
|
2048
2062
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2049
|
-
#
|
|
2063
|
+
#N = (t) => {
|
|
2050
2064
|
this.disabled || (t.preventDefault(), this.#l = !0, this.#o?.focus(), this.#S(t));
|
|
2051
2065
|
};
|
|
2052
2066
|
#S(t) {
|
|
@@ -2054,7 +2068,7 @@ class rt extends d {
|
|
|
2054
2068
|
const e = this.#g.getBoundingClientRect(), s = Math.max(0, Math.min(1, (t.clientX - e.left) / e.width));
|
|
2055
2069
|
this.#s = Math.round(s * 100), this.#y(), this.#A();
|
|
2056
2070
|
}
|
|
2057
|
-
#
|
|
2071
|
+
#U = (t) => {
|
|
2058
2072
|
if (this.disabled) return;
|
|
2059
2073
|
const e = t.shiftKey ? 10 : 1;
|
|
2060
2074
|
let s = !1;
|
|
@@ -2073,10 +2087,10 @@ class rt extends d {
|
|
|
2073
2087
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2074
2088
|
// Pointer move/up
|
|
2075
2089
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2076
|
-
#
|
|
2077
|
-
this.#r ? this.#
|
|
2090
|
+
#W = (t) => {
|
|
2091
|
+
this.#r ? this.#C(t) : this.#n ? this.#E(t) : this.#l && this.#S(t);
|
|
2078
2092
|
};
|
|
2079
|
-
#
|
|
2093
|
+
#V = () => {
|
|
2080
2094
|
(this.#r || this.#n || this.#l) && (this.#r = !1, this.#n = !1, this.#l = !1, this.#$());
|
|
2081
2095
|
};
|
|
2082
2096
|
// ───────────────────────────────────────────────────────────────────────────
|
|
@@ -2087,7 +2101,7 @@ class rt extends d {
|
|
|
2087
2101
|
const t = m(this.#h.value);
|
|
2088
2102
|
t ? (this.#t = t.hsv.h, this.#e = t.hsv.s, this.#i = t.hsv.v, this.hasAttribute("opacity") && (this.#s = t.alpha), this.#y(), this.#$()) : this.#M();
|
|
2089
2103
|
};
|
|
2090
|
-
#
|
|
2104
|
+
#q = (t) => {
|
|
2091
2105
|
t.key === "Enter" && (t.preventDefault(), this.#T());
|
|
2092
2106
|
};
|
|
2093
2107
|
// ───────────────────────────────────────────────────────────────────────────
|
|
@@ -2121,23 +2135,23 @@ class rt extends d {
|
|
|
2121
2135
|
#H() {
|
|
2122
2136
|
const t = this.$('[data-ry-target="trigger-color"]');
|
|
2123
2137
|
if (t) {
|
|
2124
|
-
const e =
|
|
2138
|
+
const e = f({ h: this.#t, s: this.#e, v: this.#i }), s = this.hasAttribute("opacity") ? this.#s / 100 : 1;
|
|
2125
2139
|
t.style.backgroundColor = `rgba(${e.r}, ${e.g}, ${e.b}, ${s})`;
|
|
2126
2140
|
}
|
|
2127
2141
|
}
|
|
2128
2142
|
#L() {
|
|
2129
2143
|
if (this.#a) {
|
|
2130
|
-
const t =
|
|
2144
|
+
const t = f({ h: this.#t, s: 100, v: 100 });
|
|
2131
2145
|
this.#a.style.setProperty("--grid-hue-color", `rgb(${t.r}, ${t.g}, ${t.b})`);
|
|
2132
2146
|
}
|
|
2133
2147
|
this.#u && (this.#u.style.left = `${this.#e}%`, this.#u.style.top = `${100 - this.#i}%`);
|
|
2134
2148
|
}
|
|
2135
2149
|
#I() {
|
|
2136
|
-
this.#
|
|
2150
|
+
this.#b && (this.#b.style.left = `${this.#t / 360 * 100}%`);
|
|
2137
2151
|
}
|
|
2138
2152
|
#D() {
|
|
2139
2153
|
if (this.#g) {
|
|
2140
|
-
const t =
|
|
2154
|
+
const t = f({ h: this.#t, s: this.#e, v: this.#i });
|
|
2141
2155
|
this.#g.style.setProperty("--alpha-color", `rgb(${t.r}, ${t.g}, ${t.b})`);
|
|
2142
2156
|
}
|
|
2143
2157
|
this.#o && (this.#o.style.left = `${this.#s}%`);
|
|
@@ -2145,7 +2159,7 @@ class rt extends d {
|
|
|
2145
2159
|
#F() {
|
|
2146
2160
|
const t = this.$('[data-ry-target="preview-color"]');
|
|
2147
2161
|
if (t) {
|
|
2148
|
-
const e =
|
|
2162
|
+
const e = f({ h: this.#t, s: this.#e, v: this.#i }), s = this.hasAttribute("opacity") ? this.#s / 100 : 1;
|
|
2149
2163
|
t.style.backgroundColor = `rgba(${e.r}, ${e.g}, ${e.b}, ${s})`;
|
|
2150
2164
|
}
|
|
2151
2165
|
}
|
|
@@ -2157,10 +2171,10 @@ class rt extends d {
|
|
|
2157
2171
|
this.getAttribute("value") !== t && this.setAttribute("value", t);
|
|
2158
2172
|
}
|
|
2159
2173
|
#_() {
|
|
2160
|
-
const t = this.format, e =
|
|
2174
|
+
const t = this.format, e = f({ h: this.#t, s: this.#e, v: this.#i }), s = this.hasAttribute("opacity");
|
|
2161
2175
|
switch (t) {
|
|
2162
2176
|
case "hex": {
|
|
2163
|
-
const i =
|
|
2177
|
+
const i = C(e);
|
|
2164
2178
|
if (s && this.#s < 100) {
|
|
2165
2179
|
const r = Math.round(this.#s / 100 * 255).toString(16).padStart(2, "0");
|
|
2166
2180
|
return i + r;
|
|
@@ -2174,7 +2188,7 @@ class rt extends d {
|
|
|
2174
2188
|
return s ? `hsla(${i.h}, ${i.s}%, ${i.l}%, ${(this.#s / 100).toFixed(2)})` : `hsl(${i.h}, ${i.s}%, ${i.l}%)`;
|
|
2175
2189
|
}
|
|
2176
2190
|
default:
|
|
2177
|
-
return
|
|
2191
|
+
return C(e);
|
|
2178
2192
|
}
|
|
2179
2193
|
}
|
|
2180
2194
|
// ───────────────────────────────────────────────────────────────────────────
|
|
@@ -2221,7 +2235,7 @@ class rt extends d {
|
|
|
2221
2235
|
return { h: this.#t, s: this.#e, v: this.#i };
|
|
2222
2236
|
}
|
|
2223
2237
|
get rgb() {
|
|
2224
|
-
return
|
|
2238
|
+
return f(this.hsv);
|
|
2225
2239
|
}
|
|
2226
2240
|
get hsl() {
|
|
2227
2241
|
return M(this.hsv);
|
|
@@ -2285,7 +2299,7 @@ class at extends d {
|
|
|
2285
2299
|
`, this.#t = this.$('[data-ry-target="swatch"]'), this.#e = this.$('[data-ry-target="input"]'), this.#i = this.$('[data-ry-target="panel"]'), this.#s = this.$('[data-ry-target="picker"]');
|
|
2286
2300
|
}
|
|
2287
2301
|
#n() {
|
|
2288
|
-
this.#t && this.on(this.#t, "click", this.#l), this.#e && (this.on(this.#e, "input", this.#p), this.on(this.#e, "keydown", this.#
|
|
2302
|
+
this.#t && this.on(this.#t, "click", this.#l), this.#e && (this.on(this.#e, "input", this.#p), this.on(this.#e, "keydown", this.#f), this.on(this.#e, "focus", this.#c)), this.#s && (this.on(this.#s, "ry:input", this.#b), this.on(this.#s, "ry:change", this.#g)), this.on(document, "click", this.#o), this.on(document, "keydown", this.#w);
|
|
2289
2303
|
}
|
|
2290
2304
|
#l = () => {
|
|
2291
2305
|
this.disabled || (this.state === "open" ? this.close() : this.open());
|
|
@@ -2322,10 +2336,10 @@ class at extends d {
|
|
|
2322
2336
|
#u(t) {
|
|
2323
2337
|
return !!(/^#[a-fA-F0-9]{6}$/.test(t) || /^#[a-fA-F0-9]{3}$/.test(t));
|
|
2324
2338
|
}
|
|
2325
|
-
#
|
|
2339
|
+
#f = (t) => {
|
|
2326
2340
|
t.key === "Enter" && (t.preventDefault(), this.#p(), this.emit("change", { value: this.value }));
|
|
2327
2341
|
};
|
|
2328
|
-
#
|
|
2342
|
+
#b = () => {
|
|
2329
2343
|
!this.#s || !this.#e || (document.activeElement !== this.#e && (this.#e.value = this.#s.value), this.#d(), this.#v(), this.emit("input", { value: this.value }));
|
|
2330
2344
|
};
|
|
2331
2345
|
#g = () => {
|
|
@@ -2402,20 +2416,20 @@ window.RyToast = p;
|
|
|
2402
2416
|
console.log("ry-ui loaded");
|
|
2403
2417
|
export {
|
|
2404
2418
|
T as RyAccordion,
|
|
2405
|
-
|
|
2419
|
+
j as RyAlert,
|
|
2406
2420
|
D as RyButton,
|
|
2407
2421
|
z as RyCode,
|
|
2408
2422
|
at as RyColorInput,
|
|
2409
2423
|
rt as RyColorPicker,
|
|
2410
|
-
|
|
2424
|
+
N as RyDrawer,
|
|
2411
2425
|
I as RyDropdown,
|
|
2412
2426
|
d as RyElement,
|
|
2413
2427
|
Y as RyExample,
|
|
2414
|
-
|
|
2428
|
+
B as RyField,
|
|
2415
2429
|
G as RyIcon,
|
|
2416
2430
|
et as RyKnob,
|
|
2417
2431
|
H as RyModal,
|
|
2418
|
-
|
|
2432
|
+
V as RySelect,
|
|
2419
2433
|
tt as RySlider,
|
|
2420
2434
|
P as RySwitch,
|
|
2421
2435
|
L as RyTabs,
|