@ryanhelsing/ry-ui 1.0.3 → 1.0.4
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/AGENT.md +460 -0
- package/AGENTS.md +2 -1
- package/README.md +26 -7
- package/dist/components/ry-button-group.d.ts +32 -0
- package/dist/components/ry-button-group.d.ts.map +1 -0
- package/dist/components/ry-field.d.ts +7 -1
- package/dist/components/ry-field.d.ts.map +1 -1
- package/dist/components/ry-split.d.ts +28 -0
- package/dist/components/ry-split.d.ts.map +1 -0
- package/dist/core/ry-transform.d.ts.map +1 -1
- package/dist/css/ry-structure.css +120 -2
- package/dist/css/ry-theme.css +125 -0
- package/dist/css/ry-tokens.css +8 -0
- package/dist/css/ry-ui.css +253 -2
- package/dist/ry-ui.d.ts +2 -0
- package/dist/ry-ui.d.ts.map +1 -1
- package/dist/ry-ui.js +584 -411
- package/dist/ry-ui.js.map +1 -1
- package/docs/components/button-group.md +36 -0
- package/docs/components/forms.md +9 -5
- package/docs/components/layout.md +29 -1
- package/package.json +4 -2
package/dist/ry-ui.js
CHANGED
|
@@ -89,7 +89,7 @@ class u extends HTMLElement {
|
|
|
89
89
|
this.on(t, "keydown", a), i?.focus();
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
|
-
const
|
|
92
|
+
const H = [
|
|
93
93
|
// Layout
|
|
94
94
|
"page",
|
|
95
95
|
"header",
|
|
@@ -119,6 +119,7 @@ const D = [
|
|
|
119
119
|
"alert",
|
|
120
120
|
"card",
|
|
121
121
|
"button",
|
|
122
|
+
"button-group",
|
|
122
123
|
"badge",
|
|
123
124
|
"field",
|
|
124
125
|
"switch",
|
|
@@ -148,13 +149,13 @@ const D = [
|
|
|
148
149
|
"pricing-card",
|
|
149
150
|
"carousel"
|
|
150
151
|
], B = new RegExp(
|
|
151
|
-
`<(/?)(${
|
|
152
|
+
`<(/?)(${H.join("|")})(\\s|>|/)`,
|
|
152
153
|
"g"
|
|
153
154
|
);
|
|
154
155
|
function M(h) {
|
|
155
156
|
return h.replace(B, "<$1ry-$2$3");
|
|
156
157
|
}
|
|
157
|
-
function
|
|
158
|
+
function C() {
|
|
158
159
|
document.querySelectorAll("ry").forEach((h) => {
|
|
159
160
|
const t = M(h.innerHTML), e = document.createElement("template");
|
|
160
161
|
e.innerHTML = t, h.replaceWith(e.content);
|
|
@@ -163,7 +164,7 @@ function E() {
|
|
|
163
164
|
e.innerHTML = t, h.replaceWith(e.content);
|
|
164
165
|
});
|
|
165
166
|
}
|
|
166
|
-
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded",
|
|
167
|
+
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", C) : C();
|
|
167
168
|
class R extends u {
|
|
168
169
|
setup() {
|
|
169
170
|
this.#t(), this.$$('[data-ry-target="trigger"]').forEach((t) => {
|
|
@@ -428,6 +429,139 @@ class N extends u {
|
|
|
428
429
|
}
|
|
429
430
|
customElements.define("ry-button", N);
|
|
430
431
|
class O extends u {
|
|
432
|
+
static get observedAttributes() {
|
|
433
|
+
return ["value"];
|
|
434
|
+
}
|
|
435
|
+
get value() {
|
|
436
|
+
return this.getAttribute("value") ?? "";
|
|
437
|
+
}
|
|
438
|
+
set value(t) {
|
|
439
|
+
this.setAttribute("value", t);
|
|
440
|
+
}
|
|
441
|
+
setup() {
|
|
442
|
+
this.setAttribute("role", "group"), this.#e(), this.on(this, "click", this.#t);
|
|
443
|
+
}
|
|
444
|
+
attributeChangedCallback(t, e, s) {
|
|
445
|
+
t === "value" && e !== s && this.#e();
|
|
446
|
+
}
|
|
447
|
+
#t = (t) => {
|
|
448
|
+
const e = t.target.closest("ry-button, ry-toggle-button");
|
|
449
|
+
if (!e || !this.contains(e)) return;
|
|
450
|
+
const s = e.getAttribute("value");
|
|
451
|
+
s != null && this.value !== s && (this.value = s, this.emit("change", { value: s }));
|
|
452
|
+
};
|
|
453
|
+
#e() {
|
|
454
|
+
const t = this.value;
|
|
455
|
+
if (t)
|
|
456
|
+
for (const e of this.querySelectorAll("ry-button, ry-toggle-button"))
|
|
457
|
+
e.getAttribute("value") === t ? (e.setAttribute("pressed", ""), e.setAttribute("aria-pressed", "true")) : (e.removeAttribute("pressed"), e.removeAttribute("aria-pressed"));
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
customElements.define("ry-button-group", O);
|
|
461
|
+
class K extends u {
|
|
462
|
+
#t = null;
|
|
463
|
+
#e = !1;
|
|
464
|
+
#i = 0;
|
|
465
|
+
#s = 0;
|
|
466
|
+
setup() {
|
|
467
|
+
if (!this.hasAttribute("resizable")) return;
|
|
468
|
+
this.#f(), this.#t = document.createElement("div"), this.#t.setAttribute("data-ry-target", "handle"), this.#t.className = "ry-split__handle", this.#t.setAttribute("role", "separator"), this.#t.setAttribute("aria-orientation", "vertical"), this.#t.setAttribute("tabindex", "0");
|
|
469
|
+
const t = this.lastElementChild;
|
|
470
|
+
t && this.insertBefore(this.#t, t), this.on(this.#t, "mousedown", this.#d), this.on(this.#t, "touchstart", this.#n), this.on(this.#t, "keydown", this.#b), this.on(this.#t, "dblclick", this.#k);
|
|
471
|
+
}
|
|
472
|
+
#r() {
|
|
473
|
+
return this.lastElementChild;
|
|
474
|
+
}
|
|
475
|
+
#a() {
|
|
476
|
+
const t = this.#r();
|
|
477
|
+
return t ? t.getBoundingClientRect().width : 300;
|
|
478
|
+
}
|
|
479
|
+
#o() {
|
|
480
|
+
const t = getComputedStyle(this).getPropertyValue("--ry-split-min-width").trim();
|
|
481
|
+
return t ? parseFloat(t) : 100;
|
|
482
|
+
}
|
|
483
|
+
#c() {
|
|
484
|
+
const t = getComputedStyle(this).getPropertyValue("--ry-split-max-width").trim();
|
|
485
|
+
return t ? parseFloat(t) : this.getBoundingClientRect().width * 0.8;
|
|
486
|
+
}
|
|
487
|
+
#h(t) {
|
|
488
|
+
const e = this.#o(), s = this.#c(), i = Math.round(Math.max(e, Math.min(s, t)));
|
|
489
|
+
this.style.setProperty("--ry-split-width", `${i}px`);
|
|
490
|
+
}
|
|
491
|
+
#d = (t) => {
|
|
492
|
+
t.preventDefault(), this.#p(t.clientX);
|
|
493
|
+
const e = (i) => this.#u(i.clientX), s = () => {
|
|
494
|
+
document.removeEventListener("mousemove", e), document.removeEventListener("mouseup", s), this.#m();
|
|
495
|
+
};
|
|
496
|
+
document.addEventListener("mousemove", e), document.addEventListener("mouseup", s);
|
|
497
|
+
};
|
|
498
|
+
#n = (t) => {
|
|
499
|
+
const e = t.touches[0];
|
|
500
|
+
if (!e) return;
|
|
501
|
+
t.preventDefault(), this.#p(e.clientX);
|
|
502
|
+
const s = (r) => {
|
|
503
|
+
const a = r.touches[0];
|
|
504
|
+
a && this.#u(a.clientX);
|
|
505
|
+
}, i = () => {
|
|
506
|
+
document.removeEventListener("touchmove", s), document.removeEventListener("touchend", i), this.#m();
|
|
507
|
+
};
|
|
508
|
+
document.addEventListener("touchmove", s, { passive: !1 }), document.addEventListener("touchend", i);
|
|
509
|
+
};
|
|
510
|
+
#p(t) {
|
|
511
|
+
this.#e = !0, this.#i = t, this.#s = this.#a(), this.setAttribute("data-ry-resizing", ""), document.body.style.cursor = "col-resize", document.body.style.userSelect = "none";
|
|
512
|
+
}
|
|
513
|
+
#u(t) {
|
|
514
|
+
if (!this.#e) return;
|
|
515
|
+
const e = this.#i - t;
|
|
516
|
+
this.#h(this.#s + e);
|
|
517
|
+
}
|
|
518
|
+
#m() {
|
|
519
|
+
this.#e = !1, this.removeAttribute("data-ry-resizing"), document.body.style.cursor = "", document.body.style.userSelect = "", this.#l(), this.emit("resize", { width: this.#a() });
|
|
520
|
+
}
|
|
521
|
+
#b = (t) => {
|
|
522
|
+
const e = t.shiftKey ? 50 : 10;
|
|
523
|
+
let s = this.#a();
|
|
524
|
+
t.key === "ArrowLeft" ? (t.preventDefault(), this.#h(s + e), this.#l()) : t.key === "ArrowRight" ? (t.preventDefault(), this.#h(s - e), this.#l()) : t.key === "Home" ? (t.preventDefault(), this.#h(this.#o()), this.#l()) : t.key === "End" && (t.preventDefault(), this.#h(this.#c()), this.#l());
|
|
525
|
+
};
|
|
526
|
+
#k = () => {
|
|
527
|
+
this.style.removeProperty("--ry-split-width"), this.#v(), this.emit("resize", { width: this.#a() });
|
|
528
|
+
};
|
|
529
|
+
// Persistence
|
|
530
|
+
#g() {
|
|
531
|
+
const t = this.getAttribute("persist");
|
|
532
|
+
return t ? `ry-split:${t}` : null;
|
|
533
|
+
}
|
|
534
|
+
#l() {
|
|
535
|
+
const t = this.#g();
|
|
536
|
+
if (t)
|
|
537
|
+
try {
|
|
538
|
+
localStorage.setItem(t, String(this.#a()));
|
|
539
|
+
} catch {
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
#f() {
|
|
543
|
+
const t = this.#g();
|
|
544
|
+
if (t)
|
|
545
|
+
try {
|
|
546
|
+
const e = localStorage.getItem(t);
|
|
547
|
+
if (e) {
|
|
548
|
+
const s = parseFloat(e);
|
|
549
|
+
isNaN(s) || this.style.setProperty("--ry-split-width", `${s}px`);
|
|
550
|
+
}
|
|
551
|
+
} catch {
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
#v() {
|
|
555
|
+
const t = this.#g();
|
|
556
|
+
if (t)
|
|
557
|
+
try {
|
|
558
|
+
localStorage.removeItem(t);
|
|
559
|
+
} catch {
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
customElements.define("ry-split", K);
|
|
564
|
+
class q extends u {
|
|
431
565
|
#t = ["light", "dark"];
|
|
432
566
|
#e = 0;
|
|
433
567
|
setup() {
|
|
@@ -467,8 +601,8 @@ class O extends u {
|
|
|
467
601
|
}
|
|
468
602
|
}
|
|
469
603
|
}
|
|
470
|
-
customElements.define("ry-theme-toggle",
|
|
471
|
-
class
|
|
604
|
+
customElements.define("ry-theme-toggle", q);
|
|
605
|
+
class z extends u {
|
|
472
606
|
setup() {
|
|
473
607
|
this.#t();
|
|
474
608
|
const t = this.$("[close]");
|
|
@@ -488,26 +622,63 @@ class K extends u {
|
|
|
488
622
|
}, 200), this.emit("close");
|
|
489
623
|
}
|
|
490
624
|
}
|
|
491
|
-
customElements.define("ry-alert",
|
|
492
|
-
class
|
|
625
|
+
customElements.define("ry-alert", z);
|
|
626
|
+
class U extends u {
|
|
627
|
+
static get observedAttributes() {
|
|
628
|
+
return ["label", "error", "hint"];
|
|
629
|
+
}
|
|
493
630
|
setup() {
|
|
494
631
|
this.#t();
|
|
495
632
|
}
|
|
633
|
+
attributeChangedCallback(t, e, s) {
|
|
634
|
+
e !== s && (t === "error" ? this.#e(s) : t === "hint" ? this.#i(s) : t === "label" && this.#s(s));
|
|
635
|
+
}
|
|
496
636
|
#t() {
|
|
497
|
-
|
|
498
|
-
const t = this.getAttribute("label");
|
|
637
|
+
const t = this.$("input, textarea, select");
|
|
499
638
|
if (!t) return;
|
|
500
|
-
const e =
|
|
501
|
-
if (!
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
639
|
+
const e = t.id || `ry-field-${Math.random().toString(36).slice(2, 9)}`;
|
|
640
|
+
if (t.id = e, !this.$('[data-ry-target="label"]')) {
|
|
641
|
+
const a = this.getAttribute("label");
|
|
642
|
+
if (a) {
|
|
643
|
+
const n = document.createElement("label");
|
|
644
|
+
n.setAttribute("data-ry-target", "label"), n.className = "ry-label", n.setAttribute("for", e), n.textContent = a, this.insertBefore(n, t);
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
if (!this.$('[data-ry-target="error"]')) {
|
|
648
|
+
const a = document.createElement("div");
|
|
649
|
+
a.setAttribute("data-ry-target", "error"), a.className = "ry-field__error", a.setAttribute("role", "alert");
|
|
650
|
+
const n = this.getAttribute("error");
|
|
651
|
+
n && (a.textContent = n), t.insertAdjacentElement("afterend", a);
|
|
652
|
+
}
|
|
653
|
+
if (!this.$('[data-ry-target="hint"]')) {
|
|
654
|
+
const a = document.createElement("div");
|
|
655
|
+
a.setAttribute("data-ry-target", "hint"), a.className = "ry-field__hint";
|
|
656
|
+
const n = this.getAttribute("hint");
|
|
657
|
+
n && (a.textContent = n);
|
|
658
|
+
const o = this.$('[data-ry-target="error"]');
|
|
659
|
+
o ? o.insertAdjacentElement("afterend", a) : t.insertAdjacentElement("afterend", a);
|
|
660
|
+
}
|
|
661
|
+
const s = this.$('[data-ry-target="error"]'), i = this.$('[data-ry-target="hint"]'), r = [];
|
|
662
|
+
s && (s.id = `${e}-error`, r.push(s.id)), i && (i.id = `${e}-hint`, r.push(i.id)), r.length && t.setAttribute("aria-describedby", r.join(" "));
|
|
663
|
+
}
|
|
664
|
+
#e(t) {
|
|
665
|
+
const e = this.$('[data-ry-target="error"]');
|
|
666
|
+
e && (e.textContent = t ?? "");
|
|
667
|
+
const s = this.$("input, textarea, select");
|
|
668
|
+
s && (t ? s.setAttribute("aria-invalid", "true") : s.removeAttribute("aria-invalid"));
|
|
669
|
+
}
|
|
670
|
+
#i(t) {
|
|
671
|
+
const e = this.$('[data-ry-target="hint"]');
|
|
672
|
+
e && (e.textContent = t ?? "");
|
|
673
|
+
}
|
|
674
|
+
#s(t) {
|
|
675
|
+
const e = this.$('[data-ry-target="label"]');
|
|
676
|
+
e && (e.textContent = t ?? "");
|
|
506
677
|
}
|
|
507
678
|
}
|
|
508
|
-
customElements.define("ry-field",
|
|
679
|
+
customElements.define("ry-field", U);
|
|
509
680
|
let V = 0;
|
|
510
|
-
class
|
|
681
|
+
class W extends u {
|
|
511
682
|
#t = null;
|
|
512
683
|
static observedAttributes = ["checked", "disabled"];
|
|
513
684
|
setup() {
|
|
@@ -560,16 +731,16 @@ class z extends u {
|
|
|
560
731
|
this.#t && (this.#t.value = t);
|
|
561
732
|
}
|
|
562
733
|
}
|
|
563
|
-
customElements.define("ry-switch",
|
|
564
|
-
let
|
|
565
|
-
class
|
|
734
|
+
customElements.define("ry-switch", W);
|
|
735
|
+
let Y = 0;
|
|
736
|
+
class X extends u {
|
|
566
737
|
#t = null;
|
|
567
738
|
#e = null;
|
|
568
739
|
#i = null;
|
|
569
740
|
setup() {
|
|
570
|
-
this.#i = `ry-tooltip-${++
|
|
741
|
+
this.#i = `ry-tooltip-${++Y}`, this.#s();
|
|
571
742
|
const t = this.firstElementChild;
|
|
572
|
-
t && (t.setAttribute("aria-describedby", this.#i), this.on(t, "mouseenter", this.#r), this.on(t, "mouseleave", this.#o), this.on(t, "focusin", this.#r), this.on(t, "focusout", this.#o)), this.on(document, "keydown", this.#
|
|
743
|
+
t && (t.setAttribute("aria-describedby", this.#i), this.on(t, "mouseenter", this.#r), this.on(t, "mouseleave", this.#o), this.on(t, "focusin", this.#r), this.on(t, "focusout", this.#o)), this.on(document, "keydown", this.#c);
|
|
573
744
|
}
|
|
574
745
|
#s() {
|
|
575
746
|
this.#e = document.createElement("div"), this.#e.id = this.#i, this.#e.setAttribute("data-ry-target", "content"), this.#e.className = "ry-tooltip__content", this.#e.setAttribute("role", "tooltip"), this.#e.textContent = this.getAttribute("content") ?? "", this.appendChild(this.#e);
|
|
@@ -586,15 +757,15 @@ class Y extends u {
|
|
|
586
757
|
#o = () => {
|
|
587
758
|
this.#t && (clearTimeout(this.#t), this.#t = null), this.state = "closed";
|
|
588
759
|
};
|
|
589
|
-
#
|
|
760
|
+
#c = (t) => {
|
|
590
761
|
t.key === "Escape" && this.state === "open" && this.#o();
|
|
591
762
|
};
|
|
592
763
|
teardown() {
|
|
593
764
|
this.#t && clearTimeout(this.#t);
|
|
594
765
|
}
|
|
595
766
|
}
|
|
596
|
-
customElements.define("ry-tooltip",
|
|
597
|
-
class
|
|
767
|
+
customElements.define("ry-tooltip", X);
|
|
768
|
+
class G extends u {
|
|
598
769
|
#t = null;
|
|
599
770
|
#e = 0;
|
|
600
771
|
setup() {
|
|
@@ -639,8 +810,8 @@ class W extends u {
|
|
|
639
810
|
this.state === "open" ? this.close() : this.open();
|
|
640
811
|
}
|
|
641
812
|
}
|
|
642
|
-
customElements.define("ry-drawer",
|
|
643
|
-
const
|
|
813
|
+
customElements.define("ry-drawer", G);
|
|
814
|
+
const J = 4e3;
|
|
644
815
|
class f extends u {
|
|
645
816
|
#t = null;
|
|
646
817
|
static observedAttributes = ["variant", "duration"];
|
|
@@ -670,7 +841,7 @@ class f extends u {
|
|
|
670
841
|
this.#s();
|
|
671
842
|
const t = this.$("[close]");
|
|
672
843
|
t && this.on(t, "click", () => this.dismiss());
|
|
673
|
-
const e = parseInt(this.getAttribute("duration") ?? String(
|
|
844
|
+
const e = parseInt(this.getAttribute("duration") ?? String(J), 10);
|
|
674
845
|
e > 0 && (this.#t = setTimeout(() => this.dismiss(), e)), requestAnimationFrame(() => {
|
|
675
846
|
this.state = "visible";
|
|
676
847
|
});
|
|
@@ -776,17 +947,17 @@ const w = {
|
|
|
776
947
|
function p(h) {
|
|
777
948
|
return w[h] ?? "";
|
|
778
949
|
}
|
|
779
|
-
function
|
|
950
|
+
function Dt(h, t) {
|
|
780
951
|
w[h] = t;
|
|
781
952
|
}
|
|
782
|
-
function
|
|
953
|
+
function It(h) {
|
|
783
954
|
Object.assign(w, h);
|
|
784
955
|
}
|
|
785
|
-
function
|
|
956
|
+
function Ht() {
|
|
786
957
|
return Object.keys(w);
|
|
787
958
|
}
|
|
788
|
-
let
|
|
789
|
-
class
|
|
959
|
+
let Z = 0;
|
|
960
|
+
class Q extends u {
|
|
790
961
|
#t = null;
|
|
791
962
|
#e = -1;
|
|
792
963
|
#i = "";
|
|
@@ -799,12 +970,12 @@ class J extends u {
|
|
|
799
970
|
}
|
|
800
971
|
static observedAttributes = ["value", "disabled"];
|
|
801
972
|
setup() {
|
|
802
|
-
this.#t = `ry-select-${++
|
|
973
|
+
this.#t = `ry-select-${++Z}`, this.#o(), this.hasAttribute("tabindex") || this.setAttribute("tabindex", "0"), this.on(this, "click", this.#c), this.on(this, "keydown", this.#h), this.on(document, "click", this.#d), this.#a && this.on(this, "ry:remove", this.#n), this.hasAttribute("data-ry-state") || (this.state = "closed");
|
|
803
974
|
const t = this.getAttribute("value");
|
|
804
975
|
if (t)
|
|
805
976
|
if (this.#a)
|
|
806
977
|
for (const e of t.split(",").map((s) => s.trim()).filter(Boolean))
|
|
807
|
-
this.#
|
|
978
|
+
this.#l(e);
|
|
808
979
|
else
|
|
809
980
|
this.value = t;
|
|
810
981
|
}
|
|
@@ -862,20 +1033,20 @@ class J extends u {
|
|
|
862
1033
|
`;
|
|
863
1034
|
this._options = t;
|
|
864
1035
|
}
|
|
865
|
-
#
|
|
1036
|
+
#c = (t) => {
|
|
866
1037
|
if (this.hasAttribute("disabled")) return;
|
|
867
1038
|
const e = t.target, s = e.closest('[data-ry-target="option"]');
|
|
868
1039
|
if (s instanceof HTMLElement && !s.hasAttribute("data-disabled")) {
|
|
869
1040
|
if (this.#a) {
|
|
870
1041
|
const r = s.dataset.value ?? "";
|
|
871
|
-
this.#
|
|
1042
|
+
this.#l(r);
|
|
872
1043
|
} else
|
|
873
1044
|
this.#$(s), this.close();
|
|
874
1045
|
return;
|
|
875
1046
|
}
|
|
876
1047
|
e.closest('[data-ry-target="trigger"]') && this.toggle();
|
|
877
1048
|
};
|
|
878
|
-
#
|
|
1049
|
+
#h = (t) => {
|
|
879
1050
|
if (this.hasAttribute("disabled")) return;
|
|
880
1051
|
const e = this.state === "open";
|
|
881
1052
|
switch (t.key) {
|
|
@@ -886,7 +1057,7 @@ class J extends u {
|
|
|
886
1057
|
if (i)
|
|
887
1058
|
if (this.#a) {
|
|
888
1059
|
const r = i.dataset.value ?? "";
|
|
889
|
-
this.#
|
|
1060
|
+
this.#l(r);
|
|
890
1061
|
} else
|
|
891
1062
|
this.#$(i), this.close();
|
|
892
1063
|
} else
|
|
@@ -896,13 +1067,13 @@ class J extends u {
|
|
|
896
1067
|
e && (t.preventDefault(), this.close());
|
|
897
1068
|
break;
|
|
898
1069
|
case "ArrowDown":
|
|
899
|
-
t.preventDefault(), e ? this.#
|
|
1070
|
+
t.preventDefault(), e ? this.#m() : this.open();
|
|
900
1071
|
break;
|
|
901
1072
|
case "ArrowUp":
|
|
902
1073
|
t.preventDefault(), e && this.#b();
|
|
903
1074
|
break;
|
|
904
1075
|
case "Home":
|
|
905
|
-
e && (t.preventDefault(), this.#
|
|
1076
|
+
e && (t.preventDefault(), this.#k());
|
|
906
1077
|
break;
|
|
907
1078
|
case "End":
|
|
908
1079
|
e && (t.preventDefault(), this.#g());
|
|
@@ -910,7 +1081,7 @@ class J extends u {
|
|
|
910
1081
|
case "Backspace":
|
|
911
1082
|
if (this.#a && this.#r.size > 0) {
|
|
912
1083
|
const s = [...this.#r], i = s[s.length - 1];
|
|
913
|
-
i && this.#
|
|
1084
|
+
i && this.#l(i);
|
|
914
1085
|
}
|
|
915
1086
|
break;
|
|
916
1087
|
default:
|
|
@@ -918,13 +1089,13 @@ class J extends u {
|
|
|
918
1089
|
break;
|
|
919
1090
|
}
|
|
920
1091
|
};
|
|
921
|
-
#
|
|
1092
|
+
#d = (t) => {
|
|
922
1093
|
const e = t.target;
|
|
923
1094
|
!this.contains(e) && this.state === "open" && this.close();
|
|
924
1095
|
};
|
|
925
1096
|
#n = (t) => {
|
|
926
1097
|
const e = t.detail.value;
|
|
927
|
-
this.#r.has(e) && this.#
|
|
1098
|
+
this.#r.has(e) && this.#l(e);
|
|
928
1099
|
};
|
|
929
1100
|
#p(t) {
|
|
930
1101
|
this.#s && clearTimeout(this.#s), this.#i += t.toLowerCase();
|
|
@@ -955,7 +1126,7 @@ class J extends u {
|
|
|
955
1126
|
const i = this.$('[data-ry-target="trigger"]');
|
|
956
1127
|
i && i.setAttribute("aria-activedescendant", s.id);
|
|
957
1128
|
}
|
|
958
|
-
#
|
|
1129
|
+
#m() {
|
|
959
1130
|
const t = this.$$('[data-ry-target="option"]:not([data-disabled])'), e = Math.min(this.#e + 1, t.length - 1);
|
|
960
1131
|
this.#u(e);
|
|
961
1132
|
}
|
|
@@ -963,7 +1134,7 @@ class J extends u {
|
|
|
963
1134
|
const t = Math.max(this.#e - 1, 0);
|
|
964
1135
|
this.#u(t);
|
|
965
1136
|
}
|
|
966
|
-
#
|
|
1137
|
+
#k() {
|
|
967
1138
|
this.#u(0);
|
|
968
1139
|
}
|
|
969
1140
|
#g() {
|
|
@@ -971,7 +1142,7 @@ class J extends u {
|
|
|
971
1142
|
this.#u(t.length - 1);
|
|
972
1143
|
}
|
|
973
1144
|
// --- Multi-select methods ---
|
|
974
|
-
#
|
|
1145
|
+
#l(t) {
|
|
975
1146
|
const e = this.getAttribute("max-selections");
|
|
976
1147
|
if (this.#r.has(t))
|
|
977
1148
|
this.#r.delete(t);
|
|
@@ -979,9 +1150,9 @@ class J extends u {
|
|
|
979
1150
|
if (e && this.#r.size >= parseInt(e, 10)) return;
|
|
980
1151
|
this.#r.add(t);
|
|
981
1152
|
}
|
|
982
|
-
this.#
|
|
1153
|
+
this.#f(), this.#v(), this.#y(), this.setAttribute("value", [...this.#r].join(",")), this.emit("change", { value: this.value, label: "" });
|
|
983
1154
|
}
|
|
984
|
-
#
|
|
1155
|
+
#f() {
|
|
985
1156
|
const t = this.$('[data-ry-target="tags"]'), e = this.$('[data-ry-target="value"]');
|
|
986
1157
|
if (t) {
|
|
987
1158
|
t.innerHTML = "";
|
|
@@ -994,20 +1165,20 @@ class J extends u {
|
|
|
994
1165
|
e && (this.#r.size > 0 ? e.style.display = "none" : e.style.display = "");
|
|
995
1166
|
}
|
|
996
1167
|
}
|
|
997
|
-
#
|
|
1168
|
+
#v() {
|
|
998
1169
|
const t = this.$('[data-ry-target="native"]');
|
|
999
1170
|
if (t)
|
|
1000
1171
|
for (const e of t.options)
|
|
1001
1172
|
e.selected = this.#r.has(e.value);
|
|
1002
1173
|
}
|
|
1003
|
-
#
|
|
1174
|
+
#y() {
|
|
1004
1175
|
this.$$('[data-ry-target="option"]').forEach((t) => {
|
|
1005
1176
|
const e = t.dataset.value ?? "";
|
|
1006
1177
|
this.#r.has(e) ? t.setAttribute("aria-selected", "true") : t.removeAttribute("aria-selected");
|
|
1007
1178
|
});
|
|
1008
1179
|
}
|
|
1009
1180
|
#M() {
|
|
1010
|
-
this.#r.clear(), this.#
|
|
1181
|
+
this.#r.clear(), this.#f(), this.#v(), this.#y(), this.setAttribute("value", ""), this.emit("change", { value: "", label: "" });
|
|
1011
1182
|
}
|
|
1012
1183
|
// --- Single-select method ---
|
|
1013
1184
|
#$(t) {
|
|
@@ -1022,7 +1193,7 @@ class J extends u {
|
|
|
1022
1193
|
if (this.state === "open") return;
|
|
1023
1194
|
this.state = "open";
|
|
1024
1195
|
const t = this.$('[data-ry-target="trigger"]');
|
|
1025
|
-
if (t && t.setAttribute("aria-expanded", "true"), this.#
|
|
1196
|
+
if (t && t.setAttribute("aria-expanded", "true"), this.#I(), this.#a)
|
|
1026
1197
|
this.#u(0);
|
|
1027
1198
|
else {
|
|
1028
1199
|
const e = this.getAttribute("value");
|
|
@@ -1034,7 +1205,7 @@ class J extends u {
|
|
|
1034
1205
|
}
|
|
1035
1206
|
this.emit("open");
|
|
1036
1207
|
}
|
|
1037
|
-
#
|
|
1208
|
+
#I() {
|
|
1038
1209
|
const t = this.$('[data-ry-target="dropdown"]');
|
|
1039
1210
|
if (!t) return;
|
|
1040
1211
|
this.removeAttribute("data-ry-position");
|
|
@@ -1060,7 +1231,7 @@ class J extends u {
|
|
|
1060
1231
|
this.#r.clear();
|
|
1061
1232
|
for (const e of t.split(",").map((s) => s.trim()).filter(Boolean))
|
|
1062
1233
|
this.#r.add(e);
|
|
1063
|
-
this.#
|
|
1234
|
+
this.#f(), this.#v(), this.#y(), this.setAttribute("value", t);
|
|
1064
1235
|
} else {
|
|
1065
1236
|
const e = this.$(`[data-ry-target="option"][data-value="${t}"]`);
|
|
1066
1237
|
e && this.#$(e);
|
|
@@ -1073,11 +1244,11 @@ class J extends u {
|
|
|
1073
1244
|
this.#s && clearTimeout(this.#s);
|
|
1074
1245
|
}
|
|
1075
1246
|
}
|
|
1076
|
-
class
|
|
1247
|
+
class tt extends HTMLElement {
|
|
1077
1248
|
}
|
|
1078
|
-
customElements.define("ry-option",
|
|
1079
|
-
customElements.define("ry-select",
|
|
1080
|
-
class
|
|
1249
|
+
customElements.define("ry-option", tt);
|
|
1250
|
+
customElements.define("ry-select", Q);
|
|
1251
|
+
class et extends u {
|
|
1081
1252
|
#t = "";
|
|
1082
1253
|
static get observedAttributes() {
|
|
1083
1254
|
return ["language", "title", "line-numbers"];
|
|
@@ -1124,9 +1295,9 @@ class Q extends u {
|
|
|
1124
1295
|
case "html":
|
|
1125
1296
|
return this.#o(t);
|
|
1126
1297
|
case "json":
|
|
1127
|
-
return this.#
|
|
1298
|
+
return this.#c(t);
|
|
1128
1299
|
default:
|
|
1129
|
-
return this.#
|
|
1300
|
+
return this.#d(t);
|
|
1130
1301
|
}
|
|
1131
1302
|
}
|
|
1132
1303
|
#r(t) {
|
|
@@ -1189,7 +1360,7 @@ class Q extends u {
|
|
|
1189
1360
|
const b = s[0];
|
|
1190
1361
|
b && e.push({ type: "text", value: b }), s = s.slice(1);
|
|
1191
1362
|
}
|
|
1192
|
-
return e.map((i) => this.#
|
|
1363
|
+
return e.map((i) => this.#h(i)).join("");
|
|
1193
1364
|
}
|
|
1194
1365
|
#a(t) {
|
|
1195
1366
|
const e = [];
|
|
@@ -1243,7 +1414,7 @@ class Q extends u {
|
|
|
1243
1414
|
const c = s[0];
|
|
1244
1415
|
c && e.push({ type: "text", value: c }), s = s.slice(1);
|
|
1245
1416
|
}
|
|
1246
|
-
return e.map((r) => this.#
|
|
1417
|
+
return e.map((r) => this.#h(r)).join("");
|
|
1247
1418
|
}
|
|
1248
1419
|
#o(t) {
|
|
1249
1420
|
const e = [];
|
|
@@ -1289,9 +1460,9 @@ class Q extends u {
|
|
|
1289
1460
|
const l = s[0];
|
|
1290
1461
|
l && e.push({ type: "text", value: l }), s = s.slice(1);
|
|
1291
1462
|
}
|
|
1292
|
-
return e.map((i) => this.#
|
|
1463
|
+
return e.map((i) => this.#h(i)).join("");
|
|
1293
1464
|
}
|
|
1294
|
-
#
|
|
1465
|
+
#c(t) {
|
|
1295
1466
|
const e = [];
|
|
1296
1467
|
let s = t;
|
|
1297
1468
|
for (; s.length > 0; ) {
|
|
@@ -1323,10 +1494,10 @@ class Q extends u {
|
|
|
1323
1494
|
const l = s[0];
|
|
1324
1495
|
l && e.push({ type: "text", value: l }), s = s.slice(1);
|
|
1325
1496
|
}
|
|
1326
|
-
return e.map((i) => this.#
|
|
1497
|
+
return e.map((i) => this.#h(i)).join("");
|
|
1327
1498
|
}
|
|
1328
|
-
#
|
|
1329
|
-
const e = this.#
|
|
1499
|
+
#h(t) {
|
|
1500
|
+
const e = this.#d(t.value);
|
|
1330
1501
|
switch (t.type) {
|
|
1331
1502
|
case "keyword":
|
|
1332
1503
|
return `<span class="ry-code__keyword">${e}</span>`;
|
|
@@ -1354,7 +1525,7 @@ class Q extends u {
|
|
|
1354
1525
|
return e;
|
|
1355
1526
|
}
|
|
1356
1527
|
}
|
|
1357
|
-
#
|
|
1528
|
+
#d(t) {
|
|
1358
1529
|
return t.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
1359
1530
|
}
|
|
1360
1531
|
#n(t) {
|
|
@@ -1376,8 +1547,8 @@ class Q extends u {
|
|
|
1376
1547
|
this.#t = t, this.#e();
|
|
1377
1548
|
}
|
|
1378
1549
|
}
|
|
1379
|
-
customElements.define("ry-code",
|
|
1380
|
-
class
|
|
1550
|
+
customElements.define("ry-code", et);
|
|
1551
|
+
class st extends u {
|
|
1381
1552
|
setup() {
|
|
1382
1553
|
const t = this.$("template");
|
|
1383
1554
|
if (!t) return;
|
|
@@ -1421,8 +1592,8 @@ class tt extends u {
|
|
|
1421
1592
|
`).trim();
|
|
1422
1593
|
}
|
|
1423
1594
|
}
|
|
1424
|
-
customElements.define("ry-example",
|
|
1425
|
-
class
|
|
1595
|
+
customElements.define("ry-example", st);
|
|
1596
|
+
class it extends u {
|
|
1426
1597
|
static get observedAttributes() {
|
|
1427
1598
|
return ["name", "size", "label"];
|
|
1428
1599
|
}
|
|
@@ -1455,24 +1626,24 @@ class et extends u {
|
|
|
1455
1626
|
this.setAttribute("size", String(t));
|
|
1456
1627
|
}
|
|
1457
1628
|
}
|
|
1458
|
-
customElements.define("ry-icon",
|
|
1459
|
-
const
|
|
1460
|
-
function
|
|
1629
|
+
customElements.define("ry-icon", it);
|
|
1630
|
+
const rt = ["form", "section", "fieldset", "ry-section"], m = /* @__PURE__ */ new Map(), E = /* @__PURE__ */ new Set();
|
|
1631
|
+
function at(h) {
|
|
1461
1632
|
let t = h.parentElement;
|
|
1462
1633
|
for (; t; ) {
|
|
1463
|
-
if (
|
|
1634
|
+
if (rt.some((e) => t.matches(e)))
|
|
1464
1635
|
return t;
|
|
1465
1636
|
t = t.parentElement;
|
|
1466
1637
|
}
|
|
1467
1638
|
return null;
|
|
1468
1639
|
}
|
|
1469
|
-
function
|
|
1470
|
-
if (
|
|
1640
|
+
function nt(h) {
|
|
1641
|
+
if (E.has(h)) return;
|
|
1471
1642
|
const t = m.get(h);
|
|
1472
1643
|
if (!t || t.size < 2) return;
|
|
1473
1644
|
const e = /* @__PURE__ */ new Map();
|
|
1474
1645
|
for (const s of t) {
|
|
1475
|
-
const i =
|
|
1646
|
+
const i = at(s), r = e.get(i) ?? [];
|
|
1476
1647
|
r.push(s), e.set(i, r);
|
|
1477
1648
|
}
|
|
1478
1649
|
if (e.size > 1) {
|
|
@@ -1485,10 +1656,10 @@ function rt(h) {
|
|
|
1485
1656
|
s.push("(no container)");
|
|
1486
1657
|
console.warn(
|
|
1487
1658
|
`ry-toggle-button: Buttons with name="${h}" span multiple containers (${s.join(", ")}). Intentional?`
|
|
1488
|
-
),
|
|
1659
|
+
), E.add(h);
|
|
1489
1660
|
}
|
|
1490
1661
|
}
|
|
1491
|
-
class
|
|
1662
|
+
class ot extends u {
|
|
1492
1663
|
static observedAttributes = ["pressed", "disabled", "name", "value"];
|
|
1493
1664
|
#t = !1;
|
|
1494
1665
|
setup() {
|
|
@@ -1499,12 +1670,12 @@ class at extends u {
|
|
|
1499
1670
|
}
|
|
1500
1671
|
#e() {
|
|
1501
1672
|
const t = this.name;
|
|
1502
|
-
t && (m.has(t) || m.set(t, /* @__PURE__ */ new Set()), m.get(t).add(this), this.#t = !0, queueMicrotask(() =>
|
|
1673
|
+
t && (m.has(t) || m.set(t, /* @__PURE__ */ new Set()), m.get(t).add(this), this.#t = !0, queueMicrotask(() => nt(t)));
|
|
1503
1674
|
}
|
|
1504
1675
|
#i() {
|
|
1505
1676
|
if (!this.#t) return;
|
|
1506
1677
|
const t = this.name;
|
|
1507
|
-
t && m.has(t) && (m.get(t).delete(this), m.get(t).size === 0 && (m.delete(t),
|
|
1678
|
+
t && m.has(t) && (m.get(t).delete(this), m.get(t).size === 0 && (m.delete(t), E.delete(t))), this.#t = !1;
|
|
1508
1679
|
}
|
|
1509
1680
|
#s = (t) => {
|
|
1510
1681
|
if (this.disabled) {
|
|
@@ -1560,8 +1731,8 @@ class at extends u {
|
|
|
1560
1731
|
this.setAttribute("icon", t);
|
|
1561
1732
|
}
|
|
1562
1733
|
}
|
|
1563
|
-
customElements.define("ry-toggle-button",
|
|
1564
|
-
class
|
|
1734
|
+
customElements.define("ry-toggle-button", ot);
|
|
1735
|
+
class ht extends u {
|
|
1565
1736
|
#t = !1;
|
|
1566
1737
|
#e = null;
|
|
1567
1738
|
#i = null;
|
|
@@ -1570,7 +1741,7 @@ class nt extends u {
|
|
|
1570
1741
|
#a = /* @__PURE__ */ new Map();
|
|
1571
1742
|
static observedAttributes = ["min", "max", "step", "value", "start", "end", "disabled"];
|
|
1572
1743
|
setup() {
|
|
1573
|
-
this.#o(), this.#
|
|
1744
|
+
this.#o(), this.#h(), this.#f();
|
|
1574
1745
|
}
|
|
1575
1746
|
#o() {
|
|
1576
1747
|
const t = this.hasAttribute("range"), e = this.hasAttribute("labeled"), s = this.hasAttribute("tooltip");
|
|
@@ -1590,9 +1761,9 @@ class nt extends u {
|
|
|
1590
1761
|
<div data-ry-target="thumb-value" class="ry-slider__thumb" tabindex="0" role="slider" aria-label="Value">
|
|
1591
1762
|
${s ? '<span data-ry-target="tooltip-value" class="ry-slider__tooltip"></span>' : ""}
|
|
1592
1763
|
</div>
|
|
1593
|
-
`, i += "</div>", e && (i += this.#
|
|
1764
|
+
`, i += "</div>", e && (i += this.#c()), this.innerHTML = i, this.#i = this.$('[data-ry-target="track"]'), this.#s = this.$('[data-ry-target="fill"]'), t ? (this.#r.set("start", this.$('[data-ry-target="thumb-start"]')), this.#r.set("end", this.$('[data-ry-target="thumb-end"]')), s && (this.#a.set("start", this.$('[data-ry-target="tooltip-start"]')), this.#a.set("end", this.$('[data-ry-target="tooltip-end"]')))) : (this.#r.set("value", this.$('[data-ry-target="thumb-value"]')), s && this.#a.set("value", this.$('[data-ry-target="tooltip-value"]')));
|
|
1594
1765
|
}
|
|
1595
|
-
#
|
|
1766
|
+
#c() {
|
|
1596
1767
|
const t = this.min, e = this.max, s = this.getAttribute("labels")?.split(","), i = this.getAttribute("label-type") || "number";
|
|
1597
1768
|
let r = [];
|
|
1598
1769
|
if (s)
|
|
@@ -1613,34 +1784,34 @@ class nt extends u {
|
|
|
1613
1784
|
</div>
|
|
1614
1785
|
`;
|
|
1615
1786
|
}
|
|
1616
|
-
#
|
|
1617
|
-
this.#i && this.on(this.#i, "pointerdown", this.#
|
|
1787
|
+
#h() {
|
|
1788
|
+
this.#i && this.on(this.#i, "pointerdown", this.#d);
|
|
1618
1789
|
for (const [t, e] of this.#r)
|
|
1619
|
-
this.on(e, "pointerdown", (s) => this.#n(s, t)), this.on(e, "keydown", (s) => this.#
|
|
1790
|
+
this.on(e, "pointerdown", (s) => this.#n(s, t)), this.on(e, "keydown", (s) => this.#m(s, t));
|
|
1620
1791
|
this.on(document, "pointermove", this.#p), this.on(document, "pointerup", this.#u);
|
|
1621
1792
|
}
|
|
1622
|
-
#
|
|
1793
|
+
#d = (t) => {
|
|
1623
1794
|
if (this.disabled) return;
|
|
1624
|
-
const e = this.#
|
|
1795
|
+
const e = this.#k(t);
|
|
1625
1796
|
if (this.hasAttribute("range")) {
|
|
1626
1797
|
const i = Math.abs(e - this.start), r = Math.abs(e - this.end);
|
|
1627
1798
|
i < r ? (this.start = e, this.#e = "start") : (this.end = e, this.#e = "end");
|
|
1628
1799
|
} else
|
|
1629
1800
|
this.value = e, this.#e = "value";
|
|
1630
|
-
this.#t = !0, this.#
|
|
1801
|
+
this.#t = !0, this.#f(), this.#y();
|
|
1631
1802
|
};
|
|
1632
1803
|
#n = (t, e) => {
|
|
1633
1804
|
this.disabled || (t.stopPropagation(), this.#t = !0, this.#e = e, t.target.setPointerCapture(t.pointerId));
|
|
1634
1805
|
};
|
|
1635
1806
|
#p = (t) => {
|
|
1636
1807
|
if (!this.#t || !this.#e) return;
|
|
1637
|
-
const e = this.#
|
|
1638
|
-
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.#
|
|
1808
|
+
const e = this.#k(t);
|
|
1809
|
+
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.#f(), this.#y();
|
|
1639
1810
|
};
|
|
1640
1811
|
#u = () => {
|
|
1641
1812
|
this.#t && (this.#t = !1, this.#e = null, this.#M());
|
|
1642
1813
|
};
|
|
1643
|
-
#
|
|
1814
|
+
#m = (t, e) => {
|
|
1644
1815
|
if (this.disabled) return;
|
|
1645
1816
|
const s = this.step || 1, i = (this.max - this.min) / 10;
|
|
1646
1817
|
let r = 0;
|
|
@@ -1669,13 +1840,13 @@ class nt extends u {
|
|
|
1669
1840
|
return;
|
|
1670
1841
|
}
|
|
1671
1842
|
t.preventDefault();
|
|
1672
|
-
const a = this.#
|
|
1673
|
-
e === "start" ? this.start = Math.min(a, this.end) : e === "end" ? this.end = Math.max(a, this.start) : this.value = a, this.#
|
|
1843
|
+
const a = this.#l(this.#b(e) + r);
|
|
1844
|
+
e === "start" ? this.start = Math.min(a, this.end) : e === "end" ? this.end = Math.max(a, this.start) : this.value = a, this.#f(), this.#y(), this.#M();
|
|
1674
1845
|
};
|
|
1675
1846
|
#b(t) {
|
|
1676
1847
|
return t === "start" ? this.start : t === "end" ? this.end : this.value;
|
|
1677
1848
|
}
|
|
1678
|
-
#
|
|
1849
|
+
#k(t) {
|
|
1679
1850
|
if (!this.#i) return this.min;
|
|
1680
1851
|
const e = this.#i.getBoundingClientRect(), s = this.hasAttribute("vertical"), i = this.hasAttribute("reversed");
|
|
1681
1852
|
let r;
|
|
@@ -1685,14 +1856,14 @@ class nt extends u {
|
|
|
1685
1856
|
}
|
|
1686
1857
|
#g(t) {
|
|
1687
1858
|
const e = this.step;
|
|
1688
|
-
if (e === 0) return this.#
|
|
1859
|
+
if (e === 0) return this.#l(t);
|
|
1689
1860
|
const s = Math.round((t - this.min) / e) * e + this.min;
|
|
1690
|
-
return this.#
|
|
1861
|
+
return this.#l(s);
|
|
1691
1862
|
}
|
|
1692
|
-
#
|
|
1863
|
+
#l(t) {
|
|
1693
1864
|
return Math.max(this.min, Math.min(this.max, t));
|
|
1694
1865
|
}
|
|
1695
|
-
#
|
|
1866
|
+
#f() {
|
|
1696
1867
|
const t = this.hasAttribute("range"), e = this.hasAttribute("vertical"), s = this.hasAttribute("reversed"), i = (r) => {
|
|
1697
1868
|
let a = (r - this.min) / (this.max - this.min) * 100;
|
|
1698
1869
|
return s && (a = 100 - a), a;
|
|
@@ -1701,22 +1872,22 @@ class nt extends u {
|
|
|
1701
1872
|
const r = i(this.start), a = i(this.end), n = Math.min(r, a), o = Math.max(r, a);
|
|
1702
1873
|
this.#s && (e ? (this.#s.style.bottom = `${n}%`, this.#s.style.height = `${o - n}%`, this.#s.style.left = "", this.#s.style.width = "") : (this.#s.style.left = `${n}%`, this.#s.style.width = `${o - n}%`, this.#s.style.bottom = "", this.#s.style.height = ""));
|
|
1703
1874
|
const l = this.#r.get("start"), c = this.#r.get("end");
|
|
1704
|
-
l && (e ? (l.style.bottom = `${r}%`, l.style.left = "") : (l.style.left = `${r}%`, l.style.bottom = "")), c && (e ? (c.style.bottom = `${a}%`, c.style.left = "") : (c.style.left = `${a}%`, c.style.bottom = "")), this.#
|
|
1875
|
+
l && (e ? (l.style.bottom = `${r}%`, l.style.left = "") : (l.style.left = `${r}%`, l.style.bottom = "")), c && (e ? (c.style.bottom = `${a}%`, c.style.left = "") : (c.style.left = `${a}%`, c.style.bottom = "")), this.#v("start", this.start), this.#v("end", this.end), l?.setAttribute("aria-valuenow", String(this.start)), l?.setAttribute("aria-valuemin", String(this.min)), l?.setAttribute("aria-valuemax", String(this.end)), c?.setAttribute("aria-valuenow", String(this.end)), c?.setAttribute("aria-valuemin", String(this.start)), c?.setAttribute("aria-valuemax", String(this.max));
|
|
1705
1876
|
} else {
|
|
1706
1877
|
const r = i(this.value);
|
|
1707
1878
|
this.#s && (e ? (this.#s.style.bottom = "0", this.#s.style.height = `${r}%`, this.#s.style.left = "", this.#s.style.width = "") : (this.#s.style.left = "0", this.#s.style.width = `${r}%`, this.#s.style.bottom = "", this.#s.style.height = ""));
|
|
1708
1879
|
const a = this.#r.get("value");
|
|
1709
|
-
a && (e ? (a.style.bottom = `${r}%`, a.style.left = "") : (a.style.left = `${r}%`, a.style.bottom = "")), this.#
|
|
1880
|
+
a && (e ? (a.style.bottom = `${r}%`, a.style.left = "") : (a.style.left = `${r}%`, a.style.bottom = "")), this.#v("value", this.value), a?.setAttribute("aria-valuenow", String(this.value)), a?.setAttribute("aria-valuemin", String(this.min)), a?.setAttribute("aria-valuemax", String(this.max));
|
|
1710
1881
|
}
|
|
1711
1882
|
}
|
|
1712
|
-
#
|
|
1883
|
+
#v(t, e) {
|
|
1713
1884
|
const s = this.#a.get(t);
|
|
1714
1885
|
if (s) {
|
|
1715
1886
|
const i = this.step === 0 ? 2 : String(this.step).split(".")[1]?.length || 0;
|
|
1716
1887
|
s.textContent = e.toFixed(i);
|
|
1717
1888
|
}
|
|
1718
1889
|
}
|
|
1719
|
-
#
|
|
1890
|
+
#y() {
|
|
1720
1891
|
this.hasAttribute("range") ? this.emit("input", { start: this.start, end: this.end }) : this.emit("input", { value: this.value });
|
|
1721
1892
|
}
|
|
1722
1893
|
#M() {
|
|
@@ -1745,19 +1916,19 @@ class nt extends u {
|
|
|
1745
1916
|
return parseFloat(this.getAttribute("value") ?? String(this.min));
|
|
1746
1917
|
}
|
|
1747
1918
|
set value(t) {
|
|
1748
|
-
this.setAttribute("value", String(this.#
|
|
1919
|
+
this.setAttribute("value", String(this.#l(t)));
|
|
1749
1920
|
}
|
|
1750
1921
|
get start() {
|
|
1751
1922
|
return parseFloat(this.getAttribute("start") ?? String(this.min));
|
|
1752
1923
|
}
|
|
1753
1924
|
set start(t) {
|
|
1754
|
-
this.setAttribute("start", String(this.#
|
|
1925
|
+
this.setAttribute("start", String(this.#l(t)));
|
|
1755
1926
|
}
|
|
1756
1927
|
get end() {
|
|
1757
1928
|
return parseFloat(this.getAttribute("end") ?? String(this.max));
|
|
1758
1929
|
}
|
|
1759
1930
|
set end(t) {
|
|
1760
|
-
this.setAttribute("end", String(this.#
|
|
1931
|
+
this.setAttribute("end", String(this.#l(t)));
|
|
1761
1932
|
}
|
|
1762
1933
|
get disabled() {
|
|
1763
1934
|
return this.hasAttribute("disabled");
|
|
@@ -1766,8 +1937,8 @@ class nt extends u {
|
|
|
1766
1937
|
t ? this.setAttribute("disabled", "") : this.removeAttribute("disabled");
|
|
1767
1938
|
}
|
|
1768
1939
|
}
|
|
1769
|
-
customElements.define("ry-slider",
|
|
1770
|
-
class
|
|
1940
|
+
customElements.define("ry-slider", ht);
|
|
1941
|
+
class lt extends u {
|
|
1771
1942
|
#t = !1;
|
|
1772
1943
|
#e = 0;
|
|
1773
1944
|
#i = 0;
|
|
@@ -1776,7 +1947,7 @@ class ot extends u {
|
|
|
1776
1947
|
#a = null;
|
|
1777
1948
|
static observedAttributes = ["min", "max", "step", "value", "disabled", "label", "labels", "description"];
|
|
1778
1949
|
setup() {
|
|
1779
|
-
this.#o(), this.#
|
|
1950
|
+
this.#o(), this.#c(), this.#l();
|
|
1780
1951
|
}
|
|
1781
1952
|
#o() {
|
|
1782
1953
|
const t = this.getAttribute("label"), e = this.getAttribute("description"), s = e ? ` title="${e}"` : "";
|
|
@@ -1790,19 +1961,19 @@ class ot extends u {
|
|
|
1790
1961
|
${t ? `<span data-ry-target="label" class="ry-knob__label"${s}>${t}</span>` : ""}
|
|
1791
1962
|
`, this.#s = this.$('[data-ry-target="ring"]'), this.#r = this.$('[data-ry-target="indicator"]'), this.#a = this.$('[data-ry-target="display"]');
|
|
1792
1963
|
}
|
|
1793
|
-
#
|
|
1794
|
-
this.#s && (this.on(this.#s, "mousedown", this.#
|
|
1964
|
+
#c() {
|
|
1965
|
+
this.#s && (this.on(this.#s, "mousedown", this.#h), this.on(document, "mousemove", this.#d), this.on(document, "mouseup", this.#n), this.on(this.#s, "touchstart", this.#p), this.on(document, "touchmove", this.#u), this.on(document, "touchend", this.#m), this.on(this.#s, "wheel", this.#b), this.on(this, "keydown", this.#k));
|
|
1795
1966
|
}
|
|
1796
|
-
#
|
|
1967
|
+
#h = (t) => {
|
|
1797
1968
|
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", ""));
|
|
1798
1969
|
};
|
|
1799
|
-
#
|
|
1970
|
+
#d = (t) => {
|
|
1800
1971
|
if (!this.#t) return;
|
|
1801
1972
|
const e = this.#e - t.clientY, s = (this.max - this.min) / 100;
|
|
1802
1973
|
this.#g(this.#i + e * s);
|
|
1803
1974
|
};
|
|
1804
1975
|
#n = () => {
|
|
1805
|
-
this.#t && (this.#t = !1, this.#s?.classList.remove("ry-knob__ring--dragging"), this.removeAttribute("data-dragging"), this.#
|
|
1976
|
+
this.#t && (this.#t = !1, this.#s?.classList.remove("ry-knob__ring--dragging"), this.removeAttribute("data-dragging"), this.#y());
|
|
1806
1977
|
};
|
|
1807
1978
|
#p = (t) => {
|
|
1808
1979
|
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", ""));
|
|
@@ -1815,16 +1986,16 @@ class ot extends u {
|
|
|
1815
1986
|
const s = this.#e - e.clientY, i = (this.max - this.min) / 100;
|
|
1816
1987
|
this.#g(this.#i + s * i);
|
|
1817
1988
|
};
|
|
1818
|
-
#
|
|
1819
|
-
this.#t && (this.#t = !1, this.#s?.classList.remove("ry-knob__ring--dragging"), this.removeAttribute("data-dragging"), this.#
|
|
1989
|
+
#m = () => {
|
|
1990
|
+
this.#t && (this.#t = !1, this.#s?.classList.remove("ry-knob__ring--dragging"), this.removeAttribute("data-dragging"), this.#y());
|
|
1820
1991
|
};
|
|
1821
1992
|
#b = (t) => {
|
|
1822
1993
|
if (this.disabled) return;
|
|
1823
1994
|
t.preventDefault();
|
|
1824
1995
|
const e = this.step || (this.max - this.min) / 50, s = t.deltaY < 0 ? e : -e;
|
|
1825
|
-
this.#g(this.value + s), this.#
|
|
1996
|
+
this.#g(this.value + s), this.#y();
|
|
1826
1997
|
};
|
|
1827
|
-
#
|
|
1998
|
+
#k = (t) => {
|
|
1828
1999
|
if (this.disabled) return;
|
|
1829
2000
|
const e = this.step || 1, s = (this.max - this.min) / 10;
|
|
1830
2001
|
let i = 0;
|
|
@@ -1844,26 +2015,26 @@ class ot extends u {
|
|
|
1844
2015
|
i = -s;
|
|
1845
2016
|
break;
|
|
1846
2017
|
case "Home":
|
|
1847
|
-
this.#g(this.min), this.#
|
|
2018
|
+
this.#g(this.min), this.#y();
|
|
1848
2019
|
return;
|
|
1849
2020
|
case "End":
|
|
1850
|
-
this.#g(this.max), this.#
|
|
2021
|
+
this.#g(this.max), this.#y();
|
|
1851
2022
|
return;
|
|
1852
2023
|
default:
|
|
1853
2024
|
return;
|
|
1854
2025
|
}
|
|
1855
|
-
t.preventDefault(), this.#g(this.value + i), this.#
|
|
2026
|
+
t.preventDefault(), this.#g(this.value + i), this.#y();
|
|
1856
2027
|
};
|
|
1857
2028
|
#g(t) {
|
|
1858
2029
|
let e = Math.max(this.min, Math.min(this.max, t));
|
|
1859
2030
|
const s = this.step;
|
|
1860
|
-
s > 0 && (e = Math.round((e - this.min) / s) * s + this.min, e = Math.max(this.min, Math.min(this.max, e))), this.value = e, this.#
|
|
2031
|
+
s > 0 && (e = Math.round((e - this.min) / s) * s + this.min, e = Math.max(this.min, Math.min(this.max, e))), this.value = e, this.#l(), this.#v();
|
|
1861
2032
|
}
|
|
1862
|
-
#
|
|
2033
|
+
#l() {
|
|
1863
2034
|
const t = (this.value - this.min) / (this.max - this.min), e = -135 + t * 270;
|
|
1864
|
-
this.#s && (this.#s.style.setProperty("--knob-rotation", `${e}deg`), this.#s.style.setProperty("--knob-percent", String(t))), this.#a && (this.#a.textContent = this.#
|
|
2035
|
+
this.#s && (this.#s.style.setProperty("--knob-rotation", `${e}deg`), this.#s.style.setProperty("--knob-percent", String(t))), this.#a && (this.#a.textContent = this.#f(this.value)), this.setAttribute("aria-valuenow", String(this.value)), this.setAttribute("aria-valuemin", String(this.min)), this.setAttribute("aria-valuemax", String(this.max));
|
|
1865
2036
|
}
|
|
1866
|
-
#
|
|
2037
|
+
#f(t) {
|
|
1867
2038
|
const e = this.getAttribute("labels");
|
|
1868
2039
|
if (e) {
|
|
1869
2040
|
const i = e.split(","), r = Math.round(t);
|
|
@@ -1871,16 +2042,16 @@ class ot extends u {
|
|
|
1871
2042
|
}
|
|
1872
2043
|
return this.step >= 1 ? Math.round(t).toString() : Math.abs(t) >= 1e3 ? (t / 1e3).toFixed(1) + "k" : Math.abs(t) >= 100 ? Math.round(t).toString() : Math.abs(t) >= 10 ? t.toFixed(1) : t.toFixed(2);
|
|
1873
2044
|
}
|
|
1874
|
-
#
|
|
2045
|
+
#v() {
|
|
1875
2046
|
const t = (this.value - this.min) / (this.max - this.min);
|
|
1876
2047
|
this.emit("input", { value: this.value, percent: t });
|
|
1877
2048
|
}
|
|
1878
|
-
#
|
|
2049
|
+
#y() {
|
|
1879
2050
|
const t = (this.value - this.min) / (this.max - this.min);
|
|
1880
2051
|
this.emit("change", { value: this.value, percent: t });
|
|
1881
2052
|
}
|
|
1882
2053
|
attributeChangedCallback(t, e, s) {
|
|
1883
|
-
e !== s && t === "value" && this.#s && this.#
|
|
2054
|
+
e !== s && t === "value" && this.#s && this.#l();
|
|
1884
2055
|
}
|
|
1885
2056
|
// --- Public API ---
|
|
1886
2057
|
get min() {
|
|
@@ -1914,9 +2085,9 @@ class ot extends u {
|
|
|
1914
2085
|
t ? this.setAttribute("disabled", "") : this.removeAttribute("disabled");
|
|
1915
2086
|
}
|
|
1916
2087
|
}
|
|
1917
|
-
customElements.define("ry-knob",
|
|
2088
|
+
customElements.define("ry-knob", lt);
|
|
1918
2089
|
const S = 15, T = 3;
|
|
1919
|
-
class
|
|
2090
|
+
class ct extends u {
|
|
1920
2091
|
#t = null;
|
|
1921
2092
|
#e = null;
|
|
1922
2093
|
#i = null;
|
|
@@ -1924,17 +2095,17 @@ class ht extends u {
|
|
|
1924
2095
|
#r = null;
|
|
1925
2096
|
#a = !1;
|
|
1926
2097
|
#o = 0;
|
|
1927
|
-
#l = 0;
|
|
1928
2098
|
#c = 0;
|
|
1929
|
-
#h =
|
|
2099
|
+
#h = 0;
|
|
2100
|
+
#d = !1;
|
|
1930
2101
|
#n = null;
|
|
1931
2102
|
#p = null;
|
|
1932
2103
|
static observedAttributes = ["min", "max", "step", "value", "disabled", "arrows", "icons", "drag", "editable", "wrap", "label", "prefix", "suffix"];
|
|
1933
2104
|
setup() {
|
|
1934
|
-
this.#u(), this.#b(), this.#
|
|
2105
|
+
this.#u(), this.#b(), this.#k(), this.#A();
|
|
1935
2106
|
}
|
|
1936
2107
|
#u() {
|
|
1937
|
-
const t = this.getAttribute("arrows") ?? "both", e = this.getAttribute("label"), s = t === "stacked" || t === "stacked-end" || t === "stacked-start", [i, r] = this.#
|
|
2108
|
+
const t = this.getAttribute("arrows") ?? "both", e = this.getAttribute("label"), s = t === "stacked" || t === "stacked-end" || t === "stacked-start", [i, r] = this.#m(s), a = t !== "end" && t !== "none", n = t !== "start" && t !== "none", o = this.getAttribute("prefix"), l = this.getAttribute("suffix"), c = a ? `<button data-ry-target="decrement" class="ry-number-select__btn ry-number-select__decrement" aria-label="Decrease" tabindex="-1" type="button">${i}</button>` : "", d = n ? `<button data-ry-target="increment" class="ry-number-select__btn ry-number-select__increment" aria-label="Increase" tabindex="-1" type="button">${r}</button>` : "", g = `
|
|
1938
2109
|
<div data-ry-target="display" class="ry-number-select__display" tabindex="0" role="spinbutton"
|
|
1939
2110
|
aria-valuenow="${this.value}" aria-valuemin="${this.min}" aria-valuemax="${this.max}"
|
|
1940
2111
|
${e ? `aria-label="${e}"` : ""}>
|
|
@@ -1954,20 +2125,20 @@ class ht extends u {
|
|
|
1954
2125
|
} else
|
|
1955
2126
|
this.innerHTML = `${c}${g}${d}${b}`;
|
|
1956
2127
|
}
|
|
1957
|
-
#
|
|
2128
|
+
#m(t) {
|
|
1958
2129
|
const e = this.getAttribute("icons") ?? "plus-minus";
|
|
1959
2130
|
return e === "chevron" ? t ? [p("chevron-down") ?? "▾", p("chevron-up") ?? "▴"] : [p("chevron-left") ?? "‹", p("chevron-right") ?? "›"] : e === "arrow" ? t ? [p("chevron-down") ?? "▼", p("chevron-up") ?? "▲"] : [p("chevron-left") ?? "◀", p("chevron-right") ?? "▶"] : [p("minus") ?? "−", p("plus") ?? "+"];
|
|
1960
2131
|
}
|
|
1961
2132
|
#b() {
|
|
1962
2133
|
this.#t = this.$('[data-ry-target="display"]'), this.#e = this.$('[data-ry-target="value"]'), this.#i = this.$('[data-ry-target="input"]'), this.#s = this.$('[data-ry-target="decrement"]'), this.#r = this.$('[data-ry-target="increment"]');
|
|
1963
2134
|
}
|
|
1964
|
-
#
|
|
2135
|
+
#k() {
|
|
1965
2136
|
this.#s && (this.on(this.#s, "mousedown", (t) => {
|
|
1966
2137
|
t.preventDefault(), this.#g(-1);
|
|
1967
|
-
}), this.on(this.#s, "mouseup", () => this.#
|
|
2138
|
+
}), this.on(this.#s, "mouseup", () => this.#l()), this.on(this.#s, "mouseleave", () => this.#l())), this.#r && (this.on(this.#r, "mousedown", (t) => {
|
|
1968
2139
|
t.preventDefault(), this.#g(1);
|
|
1969
|
-
}), this.on(this.#r, "mouseup", () => this.#
|
|
1970
|
-
t.key === "Enter" && (t.preventDefault(), this.#
|
|
2140
|
+
}), this.on(this.#r, "mouseup", () => this.#l()), this.on(this.#r, "mouseleave", () => this.#l())), this.#t && this.on(this.#t, "mousedown", this.#I), this.on(document, "mousemove", this.#Y), this.on(document, "mouseup", this.#C), this.#t && this.on(this.#t, "touchstart", this.#X), this.on(document, "touchmove", this.#G), this.on(document, "touchend", this.#K), this.#t && this.on(this.#t, "keydown", this.#q), this.on(this, "wheel", this.#J), this.#t && this.on(this.#t, "dblclick", () => this.#E()), this.#i && (this.on(this.#i, "blur", () => this.#z()), this.on(this.#i, "keydown", (t) => {
|
|
2141
|
+
t.key === "Enter" && (t.preventDefault(), this.#z()), t.key === "Escape" && (t.preventDefault(), this.#P()), t.stopPropagation();
|
|
1971
2142
|
}));
|
|
1972
2143
|
}
|
|
1973
2144
|
// --- Button hold-to-repeat ---
|
|
@@ -1982,48 +2153,48 @@ class ht extends u {
|
|
|
1982
2153
|
i();
|
|
1983
2154
|
}, 400);
|
|
1984
2155
|
}
|
|
1985
|
-
#
|
|
2156
|
+
#l() {
|
|
1986
2157
|
this.#n && (clearTimeout(this.#n), this.#n = null), this.#p && (clearTimeout(this.#p), this.#p = null);
|
|
1987
2158
|
}
|
|
1988
2159
|
// --- Drag helpers ---
|
|
1989
|
-
get #
|
|
2160
|
+
get #f() {
|
|
1990
2161
|
const t = this.getAttribute("drag");
|
|
1991
2162
|
if (t === "x" || t === "y" || t === "none") return t;
|
|
1992
2163
|
const e = this.getAttribute("arrows");
|
|
1993
2164
|
return e === "stacked" || e === "stacked-end" || e === "stacked-start" ? "y" : "x";
|
|
1994
2165
|
}
|
|
1995
|
-
#
|
|
1996
|
-
return this.#
|
|
2166
|
+
#v(t, e) {
|
|
2167
|
+
return this.#f === "y" ? this.#c - e : t - this.#o;
|
|
1997
2168
|
}
|
|
1998
|
-
#
|
|
1999
|
-
return this.#
|
|
2169
|
+
#y(t, e) {
|
|
2170
|
+
return this.#f === "y" ? Math.abs(e - this.#c) : Math.abs(t - this.#o);
|
|
2000
2171
|
}
|
|
2001
2172
|
#M(t, e) {
|
|
2002
2173
|
if (!this.#e) return;
|
|
2003
|
-
const s = t / e * 4, i = this.#
|
|
2174
|
+
const s = t / e * 4, i = this.#f;
|
|
2004
2175
|
this.#e.style.transform = i === "y" ? `translateY(${-s}px)` : `translateX(${s}px)`;
|
|
2005
2176
|
}
|
|
2006
2177
|
#$(t, e, s) {
|
|
2007
|
-
const i = this.#
|
|
2178
|
+
const i = this.#v(t, e), r = this.step || 1, a = s ? r * 10 : r, n = s ? S * 2 : S, o = Math.round(i / n), l = this.#h + o * a, c = i - o * n;
|
|
2008
2179
|
this.#M(c, n);
|
|
2009
|
-
const d = this.hasAttribute("wrap") ? this.#
|
|
2180
|
+
const d = this.hasAttribute("wrap") ? this.#U(l) : this.#T(l), g = this.#F(d);
|
|
2010
2181
|
g !== this.value && (this.value = g, this.#A(), this.#x());
|
|
2011
2182
|
}
|
|
2012
2183
|
// --- Mouse drag ---
|
|
2013
|
-
#
|
|
2014
|
-
this.disabled || this.#
|
|
2184
|
+
#I = (t) => {
|
|
2185
|
+
this.disabled || this.#d || this.#f === "none" || (t.preventDefault(), this.#a = !0, this.#o = t.clientX, this.#c = t.clientY, this.#h = this.value, this.setAttribute("data-dragging", ""));
|
|
2015
2186
|
};
|
|
2016
|
-
#
|
|
2187
|
+
#Y = (t) => {
|
|
2017
2188
|
this.#a && this.#$(t.clientX, t.clientY, t.shiftKey);
|
|
2018
2189
|
};
|
|
2019
|
-
#
|
|
2190
|
+
#C = (t) => {
|
|
2020
2191
|
if (!this.#a) return;
|
|
2021
|
-
const e = this.#
|
|
2022
|
-
this.#a = !1, this.removeAttribute("data-dragging"), this.#e && (this.#e.style.transform = ""), e < T && this.hasAttribute("editable") ? this.#
|
|
2192
|
+
const e = this.#y(t.clientX, t.clientY);
|
|
2193
|
+
this.#a = !1, this.removeAttribute("data-dragging"), this.#e && (this.#e.style.transform = ""), e < T && this.hasAttribute("editable") ? this.#E() : e >= T && this.#_();
|
|
2023
2194
|
};
|
|
2024
2195
|
// --- Touch drag ---
|
|
2025
2196
|
#X = (t) => {
|
|
2026
|
-
this.disabled || this.#
|
|
2197
|
+
this.disabled || this.#d || this.#f === "none" || (t.preventDefault(), this.#a = !0, this.#o = t.touches[0]?.clientX ?? 0, this.#c = t.touches[0]?.clientY ?? 0, this.#h = this.value, this.setAttribute("data-dragging", ""));
|
|
2027
2198
|
};
|
|
2028
2199
|
#G = (t) => {
|
|
2029
2200
|
if (!this.#a) return;
|
|
@@ -2036,7 +2207,7 @@ class ht extends u {
|
|
|
2036
2207
|
};
|
|
2037
2208
|
// --- Keyboard ---
|
|
2038
2209
|
#q = (t) => {
|
|
2039
|
-
if (this.disabled || this.#
|
|
2210
|
+
if (this.disabled || this.#d) return;
|
|
2040
2211
|
const e = this.step || 1, s = e * 10;
|
|
2041
2212
|
let i = 0;
|
|
2042
2213
|
switch (t.key) {
|
|
@@ -2061,28 +2232,28 @@ class ht extends u {
|
|
|
2061
2232
|
i = this.max - this.value;
|
|
2062
2233
|
break;
|
|
2063
2234
|
case "Enter":
|
|
2064
|
-
this.hasAttribute("editable") && this.#
|
|
2235
|
+
this.hasAttribute("editable") && this.#E();
|
|
2065
2236
|
return;
|
|
2066
2237
|
default:
|
|
2067
|
-
this.hasAttribute("editable") && /^[0-9.\-]$/.test(t.key) && (this.#
|
|
2238
|
+
this.hasAttribute("editable") && /^[0-9.\-]$/.test(t.key) && (this.#E(t.key), t.preventDefault());
|
|
2068
2239
|
return;
|
|
2069
2240
|
}
|
|
2070
2241
|
t.preventDefault(), this.#R(i), this.#x(), this.#_();
|
|
2071
2242
|
};
|
|
2072
2243
|
// --- Wheel ---
|
|
2073
2244
|
#J = (t) => {
|
|
2074
|
-
if (this.disabled || this.#
|
|
2245
|
+
if (this.disabled || this.#d || !this.matches(":hover") && !this.contains(document.activeElement)) return;
|
|
2075
2246
|
t.preventDefault();
|
|
2076
2247
|
const e = this.step || 1, s = t.shiftKey ? e * 10 : e, i = t.deltaY < 0 ? s : -s;
|
|
2077
2248
|
this.#R(i), this.#x(), this.#_();
|
|
2078
2249
|
};
|
|
2079
2250
|
// --- Edit mode ---
|
|
2080
|
-
#
|
|
2081
|
-
this.disabled || this.#
|
|
2251
|
+
#E(t) {
|
|
2252
|
+
this.disabled || this.#d || (this.#d = !0, this.state = "editing", this.#e && (this.#e.style.display = "none"), this.#i && (this.#i.style.display = "block", this.#i.value = t ?? this.#j(this.value), this.#i.focus(), t ? this.#i.setSelectionRange(1, 1) : this.#i.select()));
|
|
2082
2253
|
}
|
|
2083
|
-
#
|
|
2084
|
-
if (!this.#
|
|
2085
|
-
this.#
|
|
2254
|
+
#z() {
|
|
2255
|
+
if (!this.#d) return;
|
|
2256
|
+
this.#d = !1, this.state = "";
|
|
2086
2257
|
const t = parseFloat(this.#i?.value ?? "");
|
|
2087
2258
|
if (!isNaN(t)) {
|
|
2088
2259
|
const e = this.#T(t), s = this.#F(e);
|
|
@@ -2091,17 +2262,17 @@ class ht extends u {
|
|
|
2091
2262
|
this.#e && (this.#e.style.display = ""), this.#i && (this.#i.style.display = "none"), this.#A(), this.#t?.focus();
|
|
2092
2263
|
}
|
|
2093
2264
|
#P() {
|
|
2094
|
-
this.#
|
|
2265
|
+
this.#d && (this.#d = !1, this.state = "", this.#e && (this.#e.style.display = ""), this.#i && (this.#i.style.display = "none"), this.#t?.focus());
|
|
2095
2266
|
}
|
|
2096
2267
|
// --- Value management ---
|
|
2097
2268
|
#R(t) {
|
|
2098
2269
|
let e = this.value + t;
|
|
2099
|
-
this.hasAttribute("wrap") ? e = this.#
|
|
2270
|
+
this.hasAttribute("wrap") ? e = this.#U(e) : e = this.#T(e), e = this.#F(e), this.value = e, this.#A();
|
|
2100
2271
|
}
|
|
2101
2272
|
#T(t) {
|
|
2102
2273
|
return Math.max(this.min, Math.min(this.max, t));
|
|
2103
2274
|
}
|
|
2104
|
-
#
|
|
2275
|
+
#U(t) {
|
|
2105
2276
|
const e = this.step || 1, s = this.max - this.min + e;
|
|
2106
2277
|
let i = t;
|
|
2107
2278
|
for (; i > this.max; ) i -= s;
|
|
@@ -2121,9 +2292,9 @@ class ht extends u {
|
|
|
2121
2292
|
return t.toFixed(s);
|
|
2122
2293
|
}
|
|
2123
2294
|
#A() {
|
|
2124
|
-
this.#e && (this.#e.textContent = this.#j(this.value)), this.#
|
|
2295
|
+
this.#e && (this.#e.textContent = this.#j(this.value)), this.#V();
|
|
2125
2296
|
}
|
|
2126
|
-
#
|
|
2297
|
+
#V() {
|
|
2127
2298
|
this.#t && (this.#t.setAttribute("aria-valuenow", String(this.value)), this.#t.setAttribute("aria-valuemin", String(this.min)), this.#t.setAttribute("aria-valuemax", String(this.max)));
|
|
2128
2299
|
}
|
|
2129
2300
|
#x() {
|
|
@@ -2158,7 +2329,7 @@ class ht extends u {
|
|
|
2158
2329
|
this.setAttribute("step", String(t));
|
|
2159
2330
|
}
|
|
2160
2331
|
get drag() {
|
|
2161
|
-
return this.#
|
|
2332
|
+
return this.#f;
|
|
2162
2333
|
}
|
|
2163
2334
|
set drag(t) {
|
|
2164
2335
|
this.setAttribute("drag", t);
|
|
@@ -2173,10 +2344,10 @@ class ht extends u {
|
|
|
2173
2344
|
e !== s && t === "value" && this.#t && this.#A();
|
|
2174
2345
|
}
|
|
2175
2346
|
teardown() {
|
|
2176
|
-
this.#
|
|
2347
|
+
this.#l();
|
|
2177
2348
|
}
|
|
2178
2349
|
}
|
|
2179
|
-
customElements.define("ry-number-select",
|
|
2350
|
+
customElements.define("ry-number-select", ct);
|
|
2180
2351
|
function v(h) {
|
|
2181
2352
|
const t = h.h / 360, e = h.s / 100, s = h.v / 100;
|
|
2182
2353
|
let i = 0, r = 0, a = 0;
|
|
@@ -2237,7 +2408,7 @@ function L(h) {
|
|
|
2237
2408
|
l: Math.round(s * 100)
|
|
2238
2409
|
};
|
|
2239
2410
|
}
|
|
2240
|
-
function
|
|
2411
|
+
function dt(h) {
|
|
2241
2412
|
const t = h.s / 100, e = h.l / 100, s = e + t * Math.min(e, 1 - e), i = s === 0 ? 0 : 2 * (1 - e / s);
|
|
2242
2413
|
return {
|
|
2243
2414
|
h: h.h,
|
|
@@ -2245,11 +2416,11 @@ function lt(h) {
|
|
|
2245
2416
|
v: Math.round(s * 100)
|
|
2246
2417
|
};
|
|
2247
2418
|
}
|
|
2248
|
-
function
|
|
2419
|
+
function D(h) {
|
|
2249
2420
|
const t = (e) => e.toString(16).padStart(2, "0");
|
|
2250
2421
|
return `#${t(h.r)}${t(h.g)}${t(h.b)}`;
|
|
2251
2422
|
}
|
|
2252
|
-
function
|
|
2423
|
+
function ut(h) {
|
|
2253
2424
|
const t = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(h);
|
|
2254
2425
|
if (!t) {
|
|
2255
2426
|
const e = /^#?([a-f\d])([a-f\d])([a-f\d])$/i.exec(h);
|
|
@@ -2277,7 +2448,7 @@ function A(h) {
|
|
|
2277
2448
|
}, n = parseInt(i[4], 16) / 255;
|
|
2278
2449
|
return { hsv: $(a), alpha: Math.round(n * 100) };
|
|
2279
2450
|
}
|
|
2280
|
-
const r =
|
|
2451
|
+
const r = ut(t);
|
|
2281
2452
|
return r ? { hsv: $(r), alpha: 100 } : null;
|
|
2282
2453
|
}
|
|
2283
2454
|
const e = /^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d.]+))?\s*\)$/.exec(t);
|
|
@@ -2296,11 +2467,11 @@ function A(h) {
|
|
|
2296
2467
|
s: parseFloat(s[2]),
|
|
2297
2468
|
l: parseFloat(s[3])
|
|
2298
2469
|
}, r = s[4] ? parseFloat(s[4]) * 100 : 100;
|
|
2299
|
-
return { hsv:
|
|
2470
|
+
return { hsv: dt(i), alpha: r };
|
|
2300
2471
|
}
|
|
2301
2472
|
return null;
|
|
2302
2473
|
}
|
|
2303
|
-
class
|
|
2474
|
+
class pt extends u {
|
|
2304
2475
|
#t = 0;
|
|
2305
2476
|
#e = 100;
|
|
2306
2477
|
#i = 100;
|
|
@@ -2308,21 +2479,21 @@ class dt extends u {
|
|
|
2308
2479
|
#r = !1;
|
|
2309
2480
|
#a = !1;
|
|
2310
2481
|
#o = !1;
|
|
2311
|
-
#l = null;
|
|
2312
2482
|
#c = null;
|
|
2313
2483
|
#h = null;
|
|
2484
|
+
#d = null;
|
|
2314
2485
|
#n = null;
|
|
2315
2486
|
#p = null;
|
|
2316
2487
|
#u = null;
|
|
2317
|
-
#
|
|
2488
|
+
#m = null;
|
|
2318
2489
|
#b = null;
|
|
2319
|
-
#
|
|
2490
|
+
#k = null;
|
|
2320
2491
|
#g = null;
|
|
2321
2492
|
static observedAttributes = ["value", "format", "opacity", "disabled", "swatches", "inline"];
|
|
2322
2493
|
setup() {
|
|
2323
|
-
this.#
|
|
2494
|
+
this.#l(), this.#f(), this.#v(), this.#A();
|
|
2324
2495
|
}
|
|
2325
|
-
#
|
|
2496
|
+
#l() {
|
|
2326
2497
|
const t = this.hasAttribute("inline"), e = this.hasAttribute("opacity"), s = this.getAttribute("swatches");
|
|
2327
2498
|
let i = `
|
|
2328
2499
|
<div data-ry-target="grid" class="ry-color-picker__grid">
|
|
@@ -2362,16 +2533,16 @@ class dt extends u {
|
|
|
2362
2533
|
<span data-ry-target="trigger-color" class="ry-color-picker__trigger-color"></span>
|
|
2363
2534
|
</button>
|
|
2364
2535
|
<div data-ry-target="panel" class="ry-color-picker__panel">${i}</div>
|
|
2365
|
-
`, this.#
|
|
2536
|
+
`, this.#c = this.$('[data-ry-target="trigger"]'), this.#h = this.$('[data-ry-target="panel"]'), this.#d = this.$('[data-ry-target="grid"]'), this.#n = this.$('[data-ry-target="grid-handle"]'), this.#p = this.$('[data-ry-target="hue-slider"]'), this.#u = this.$('[data-ry-target="hue-handle"]'), this.#m = this.$('[data-ry-target="alpha-slider"]'), this.#b = this.$('[data-ry-target="alpha-handle"]'), this.#k = this.$('[data-ry-target="preview"]'), this.#g = this.$('[data-ry-target="input"]');
|
|
2366
2537
|
}
|
|
2367
|
-
#
|
|
2368
|
-
this.#
|
|
2538
|
+
#f() {
|
|
2539
|
+
this.#c && this.on(this.#c, "click", this.#y), this.on(document, "click", this.#M), this.on(document, "keydown", this.#$), this.#d && this.on(this.#d, "pointerdown", this.#Y), this.#n && this.on(this.#n, "keydown", this.#X), this.#p && this.on(this.#p, "pointerdown", this.#G), this.#u && this.on(this.#u, "keydown", this.#q), this.#m && this.on(this.#m, "pointerdown", this.#J), this.#b && this.on(this.#b, "keydown", this.#z), this.on(document, "pointermove", this.#P), this.on(document, "pointerup", this.#R), this.#g && (this.on(this.#g, "change", this.#T), this.on(this.#g, "keydown", this.#U));
|
|
2369
2540
|
const t = this.$('[data-ry-target="format-toggle"]');
|
|
2370
2541
|
t && this.on(t, "click", this.#F);
|
|
2371
2542
|
const e = this.$('[data-ry-target="swatches"]');
|
|
2372
2543
|
e && this.on(e, "click", this.#j);
|
|
2373
2544
|
}
|
|
2374
|
-
#
|
|
2545
|
+
#v() {
|
|
2375
2546
|
const t = this.getAttribute("value");
|
|
2376
2547
|
if (t) {
|
|
2377
2548
|
const e = A(t);
|
|
@@ -2381,35 +2552,35 @@ class dt extends u {
|
|
|
2381
2552
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2382
2553
|
// Dropdown handlers
|
|
2383
2554
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2384
|
-
#
|
|
2555
|
+
#y = () => {
|
|
2385
2556
|
this.disabled || (this.state === "open" ? this.close() : this.open());
|
|
2386
2557
|
};
|
|
2387
2558
|
#M = (t) => {
|
|
2388
2559
|
this.state === "open" && (this.contains(t.target) || this.close());
|
|
2389
2560
|
};
|
|
2390
2561
|
#$ = (t) => {
|
|
2391
|
-
t.key === "Escape" && this.state === "open" && (this.close(), this.#
|
|
2562
|
+
t.key === "Escape" && this.state === "open" && (this.close(), this.#c?.focus());
|
|
2392
2563
|
};
|
|
2393
2564
|
open() {
|
|
2394
|
-
this.hasAttribute("inline") || (this.#
|
|
2565
|
+
this.hasAttribute("inline") || (this.#I(), this.state = "open");
|
|
2395
2566
|
}
|
|
2396
2567
|
close() {
|
|
2397
2568
|
this.hasAttribute("inline") || (this.state = "closed", this.removeAttribute("data-ry-position"));
|
|
2398
2569
|
}
|
|
2399
|
-
#
|
|
2400
|
-
if (!this.#
|
|
2401
|
-
const t = this.#
|
|
2570
|
+
#I() {
|
|
2571
|
+
if (!this.#h || !this.#c) return;
|
|
2572
|
+
const t = this.#c.getBoundingClientRect(), e = 320, i = window.innerHeight - t.bottom, r = t.top;
|
|
2402
2573
|
i < e && r > i ? this.setAttribute("data-ry-position", "top") : this.setAttribute("data-ry-position", "bottom");
|
|
2403
2574
|
}
|
|
2404
2575
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2405
2576
|
// Grid handlers
|
|
2406
2577
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2407
|
-
#
|
|
2408
|
-
this.disabled || (t.preventDefault(), this.#r = !0, this.#n?.focus(), this.#
|
|
2578
|
+
#Y = (t) => {
|
|
2579
|
+
this.disabled || (t.preventDefault(), this.#r = !0, this.#n?.focus(), this.#C(t));
|
|
2409
2580
|
};
|
|
2410
|
-
#
|
|
2411
|
-
if (!this.#
|
|
2412
|
-
const e = this.#
|
|
2581
|
+
#C(t) {
|
|
2582
|
+
if (!this.#d) return;
|
|
2583
|
+
const e = this.#d.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));
|
|
2413
2584
|
this.#e = Math.round(s * 100), this.#i = Math.round((1 - i) * 100), this.#A(), this.#L();
|
|
2414
2585
|
}
|
|
2415
2586
|
#X = (t) => {
|
|
@@ -2430,7 +2601,7 @@ class dt extends u {
|
|
|
2430
2601
|
this.#i = Math.max(0, this.#i - e), s = !0;
|
|
2431
2602
|
break;
|
|
2432
2603
|
}
|
|
2433
|
-
s && (t.preventDefault(), this.#A(), this.#L(), this.#
|
|
2604
|
+
s && (t.preventDefault(), this.#A(), this.#L(), this.#w());
|
|
2434
2605
|
};
|
|
2435
2606
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2436
2607
|
// Hue handlers
|
|
@@ -2457,20 +2628,20 @@ class dt extends u {
|
|
|
2457
2628
|
this.#t = (this.#t - e + 360) % 360, s = !0;
|
|
2458
2629
|
break;
|
|
2459
2630
|
}
|
|
2460
|
-
s && (t.preventDefault(), this.#A(), this.#L(), this.#
|
|
2631
|
+
s && (t.preventDefault(), this.#A(), this.#L(), this.#w());
|
|
2461
2632
|
};
|
|
2462
2633
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2463
2634
|
// Alpha handlers
|
|
2464
2635
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2465
2636
|
#J = (t) => {
|
|
2466
|
-
this.disabled || (t.preventDefault(), this.#o = !0, this.#b?.focus(), this.#
|
|
2637
|
+
this.disabled || (t.preventDefault(), this.#o = !0, this.#b?.focus(), this.#E(t));
|
|
2467
2638
|
};
|
|
2468
|
-
#
|
|
2469
|
-
if (!this.#
|
|
2470
|
-
const e = this.#
|
|
2639
|
+
#E(t) {
|
|
2640
|
+
if (!this.#m) return;
|
|
2641
|
+
const e = this.#m.getBoundingClientRect(), s = Math.max(0, Math.min(1, (t.clientX - e.left) / e.width));
|
|
2471
2642
|
this.#s = Math.round(s * 100), this.#A(), this.#L();
|
|
2472
2643
|
}
|
|
2473
|
-
#
|
|
2644
|
+
#z = (t) => {
|
|
2474
2645
|
if (this.disabled) return;
|
|
2475
2646
|
const e = t.shiftKey ? 10 : 1;
|
|
2476
2647
|
let s = !1;
|
|
@@ -2484,16 +2655,16 @@ class dt extends u {
|
|
|
2484
2655
|
this.#s = Math.max(0, this.#s - e), s = !0;
|
|
2485
2656
|
break;
|
|
2486
2657
|
}
|
|
2487
|
-
s && (t.preventDefault(), this.#A(), this.#L(), this.#
|
|
2658
|
+
s && (t.preventDefault(), this.#A(), this.#L(), this.#w());
|
|
2488
2659
|
};
|
|
2489
2660
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2490
2661
|
// Pointer move/up
|
|
2491
2662
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2492
2663
|
#P = (t) => {
|
|
2493
|
-
this.#r ? this.#
|
|
2664
|
+
this.#r ? this.#C(t) : this.#a ? this.#K(t) : this.#o && this.#E(t);
|
|
2494
2665
|
};
|
|
2495
2666
|
#R = () => {
|
|
2496
|
-
(this.#r || this.#a || this.#o) && (this.#r = !1, this.#a = !1, this.#o = !1, this.#
|
|
2667
|
+
(this.#r || this.#a || this.#o) && (this.#r = !1, this.#a = !1, this.#o = !1, this.#w());
|
|
2497
2668
|
};
|
|
2498
2669
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2499
2670
|
// Input handlers
|
|
@@ -2501,9 +2672,9 @@ class dt extends u {
|
|
|
2501
2672
|
#T = () => {
|
|
2502
2673
|
if (!this.#g) return;
|
|
2503
2674
|
const t = A(this.#g.value);
|
|
2504
|
-
t ? (this.#t = t.hsv.h, this.#e = t.hsv.s, this.#i = t.hsv.v, this.hasAttribute("opacity") && (this.#s = t.alpha), this.#A(), this.#
|
|
2675
|
+
t ? (this.#t = t.hsv.h, this.#e = t.hsv.s, this.#i = t.hsv.v, this.hasAttribute("opacity") && (this.#s = t.alpha), this.#A(), this.#w()) : this.#W();
|
|
2505
2676
|
};
|
|
2506
|
-
#
|
|
2677
|
+
#U = (t) => {
|
|
2507
2678
|
t.key === "Enter" && (t.preventDefault(), this.#T());
|
|
2508
2679
|
};
|
|
2509
2680
|
// ───────────────────────────────────────────────────────────────────────────
|
|
@@ -2513,7 +2684,7 @@ class dt extends u {
|
|
|
2513
2684
|
const t = ["hex", "rgb", "hsl"], e = this.format, s = t.indexOf(e), i = t[(s + 1) % t.length];
|
|
2514
2685
|
this.format = i;
|
|
2515
2686
|
const r = this.$('[data-ry-target="format-toggle"]');
|
|
2516
|
-
r && (r.textContent = i.toUpperCase()), this.#
|
|
2687
|
+
r && (r.textContent = i.toUpperCase()), this.#W();
|
|
2517
2688
|
};
|
|
2518
2689
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2519
2690
|
// Swatches
|
|
@@ -2524,7 +2695,7 @@ class dt extends u {
|
|
|
2524
2695
|
const s = e.dataset.color;
|
|
2525
2696
|
if (s) {
|
|
2526
2697
|
const i = A(s);
|
|
2527
|
-
i && (this.#t = i.hsv.h, this.#e = i.hsv.s, this.#i = i.hsv.v, this.hasAttribute("opacity") && (this.#s = i.alpha), this.#A(), this.#L(), this.#
|
|
2698
|
+
i && (this.#t = i.hsv.h, this.#e = i.hsv.s, this.#i = i.hsv.v, this.hasAttribute("opacity") && (this.#s = i.alpha), this.#A(), this.#L(), this.#w());
|
|
2528
2699
|
}
|
|
2529
2700
|
}
|
|
2530
2701
|
};
|
|
@@ -2532,9 +2703,9 @@ class dt extends u {
|
|
|
2532
2703
|
// Update methods
|
|
2533
2704
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2534
2705
|
#A() {
|
|
2535
|
-
this.#
|
|
2706
|
+
this.#V(), this.#x(), this.#_(), this.#H(), this.#N(), this.#W(), this.#Z();
|
|
2536
2707
|
}
|
|
2537
|
-
#
|
|
2708
|
+
#V() {
|
|
2538
2709
|
const t = this.$('[data-ry-target="trigger-color"]');
|
|
2539
2710
|
if (t) {
|
|
2540
2711
|
const e = v({ h: this.#t, s: this.#e, v: this.#i }), s = this.hasAttribute("opacity") ? this.#s / 100 : 1;
|
|
@@ -2542,19 +2713,19 @@ class dt extends u {
|
|
|
2542
2713
|
}
|
|
2543
2714
|
}
|
|
2544
2715
|
#x() {
|
|
2545
|
-
if (this.#
|
|
2716
|
+
if (this.#d) {
|
|
2546
2717
|
const t = v({ h: this.#t, s: 100, v: 100 });
|
|
2547
|
-
this.#
|
|
2718
|
+
this.#d.style.setProperty("--grid-hue-color", `rgb(${t.r}, ${t.g}, ${t.b})`);
|
|
2548
2719
|
}
|
|
2549
2720
|
this.#n && (this.#n.style.left = `${this.#e}%`, this.#n.style.top = `${100 - this.#i}%`);
|
|
2550
2721
|
}
|
|
2551
2722
|
#_() {
|
|
2552
2723
|
this.#u && (this.#u.style.left = `${this.#t / 360 * 100}%`);
|
|
2553
2724
|
}
|
|
2554
|
-
#
|
|
2555
|
-
if (this.#
|
|
2725
|
+
#H() {
|
|
2726
|
+
if (this.#m) {
|
|
2556
2727
|
const t = v({ h: this.#t, s: this.#e, v: this.#i });
|
|
2557
|
-
this.#
|
|
2728
|
+
this.#m.style.setProperty("--alpha-color", `rgb(${t.r}, ${t.g}, ${t.b})`);
|
|
2558
2729
|
}
|
|
2559
2730
|
this.#b && (this.#b.style.left = `${this.#s}%`);
|
|
2560
2731
|
}
|
|
@@ -2565,7 +2736,7 @@ class dt extends u {
|
|
|
2565
2736
|
t.style.backgroundColor = `rgba(${e.r}, ${e.g}, ${e.b}, ${s})`;
|
|
2566
2737
|
}
|
|
2567
2738
|
}
|
|
2568
|
-
#
|
|
2739
|
+
#W() {
|
|
2569
2740
|
this.#g && (this.#g.value = this.#O());
|
|
2570
2741
|
}
|
|
2571
2742
|
#Z() {
|
|
@@ -2576,7 +2747,7 @@ class dt extends u {
|
|
|
2576
2747
|
const t = this.format, e = v({ h: this.#t, s: this.#e, v: this.#i }), s = this.hasAttribute("opacity");
|
|
2577
2748
|
switch (t) {
|
|
2578
2749
|
case "hex": {
|
|
2579
|
-
const i =
|
|
2750
|
+
const i = D(e);
|
|
2580
2751
|
if (s && this.#s < 100) {
|
|
2581
2752
|
const r = Math.round(this.#s / 100 * 255).toString(16).padStart(2, "0");
|
|
2582
2753
|
return i + r;
|
|
@@ -2590,7 +2761,7 @@ class dt extends u {
|
|
|
2590
2761
|
return s ? `hsla(${i.h}, ${i.s}%, ${i.l}%, ${(this.#s / 100).toFixed(2)})` : `hsl(${i.h}, ${i.s}%, ${i.l}%)`;
|
|
2591
2762
|
}
|
|
2592
2763
|
default:
|
|
2593
|
-
return
|
|
2764
|
+
return D(e);
|
|
2594
2765
|
}
|
|
2595
2766
|
}
|
|
2596
2767
|
// ───────────────────────────────────────────────────────────────────────────
|
|
@@ -2599,16 +2770,16 @@ class dt extends u {
|
|
|
2599
2770
|
#L() {
|
|
2600
2771
|
this.emit("input", { value: this.value, hsv: this.hsv, rgb: this.rgb });
|
|
2601
2772
|
}
|
|
2602
|
-
#
|
|
2773
|
+
#w() {
|
|
2603
2774
|
this.emit("change", { value: this.value, hsv: this.hsv, rgb: this.rgb });
|
|
2604
2775
|
}
|
|
2605
2776
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2606
2777
|
// Attribute changed
|
|
2607
2778
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2608
2779
|
attributeChangedCallback(t, e, s) {
|
|
2609
|
-
if (e !== s && t === "value" && this.#
|
|
2780
|
+
if (e !== s && t === "value" && this.#d && s) {
|
|
2610
2781
|
const i = A(s);
|
|
2611
|
-
i && (this.#t = i.hsv.h, this.#e = i.hsv.s, this.#i = i.hsv.v, this.hasAttribute("opacity") && (this.#s = i.alpha), this.#
|
|
2782
|
+
i && (this.#t = i.hsv.h, this.#e = i.hsv.s, this.#i = i.hsv.v, this.hasAttribute("opacity") && (this.#s = i.alpha), this.#V(), this.#x(), this.#_(), this.#H(), this.#N());
|
|
2612
2783
|
}
|
|
2613
2784
|
}
|
|
2614
2785
|
// ───────────────────────────────────────────────────────────────────────────
|
|
@@ -2661,15 +2832,15 @@ class dt extends u {
|
|
|
2661
2832
|
return this.format = e, s;
|
|
2662
2833
|
}
|
|
2663
2834
|
}
|
|
2664
|
-
customElements.define("ry-color-picker",
|
|
2665
|
-
class
|
|
2835
|
+
customElements.define("ry-color-picker", pt);
|
|
2836
|
+
class gt extends u {
|
|
2666
2837
|
#t = null;
|
|
2667
2838
|
#e = null;
|
|
2668
2839
|
#i = null;
|
|
2669
2840
|
#s = null;
|
|
2670
2841
|
static observedAttributes = ["value", "format", "opacity", "disabled", "placeholder"];
|
|
2671
2842
|
setup() {
|
|
2672
|
-
this.#r(), this.#a(), this.#
|
|
2843
|
+
this.#r(), this.#a(), this.#f(), this.state = "closed";
|
|
2673
2844
|
}
|
|
2674
2845
|
#r() {
|
|
2675
2846
|
const t = this.hasAttribute("opacity"), e = this.getAttribute("format") || "hex", s = this.getAttribute("value") || "#000000", i = this.getAttribute("placeholder") || "#000000";
|
|
@@ -2701,15 +2872,15 @@ class ut extends u {
|
|
|
2701
2872
|
`, 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"]');
|
|
2702
2873
|
}
|
|
2703
2874
|
#a() {
|
|
2704
|
-
this.#t && this.on(this.#t, "click", this.#o), this.#e && (this.on(this.#e, "input", this.#
|
|
2875
|
+
this.#t && this.on(this.#t, "click", this.#o), this.#e && (this.on(this.#e, "input", this.#h), this.on(this.#e, "keydown", this.#p), this.on(this.#e, "focus", this.#c)), this.#s && (this.on(this.#s, "ry:input", this.#u), this.on(this.#s, "ry:change", this.#m)), this.on(document, "click", this.#b), this.on(document, "keydown", this.#k);
|
|
2705
2876
|
}
|
|
2706
2877
|
#o = () => {
|
|
2707
2878
|
this.disabled || (this.state === "open" ? this.close() : this.open());
|
|
2708
2879
|
};
|
|
2709
|
-
#
|
|
2880
|
+
#c = () => {
|
|
2710
2881
|
this.disabled || this.open();
|
|
2711
2882
|
};
|
|
2712
|
-
#
|
|
2883
|
+
#h = () => {
|
|
2713
2884
|
if (!this.#e || !this.#s) return;
|
|
2714
2885
|
let t = this.#e.value;
|
|
2715
2886
|
const e = this.#e.selectionStart ?? t.length, r = "#" + t.replace(/[^#a-fA-F0-9]/g, "").replace(/#/g, "").slice(0, 6);
|
|
@@ -2718,10 +2889,10 @@ class ut extends u {
|
|
|
2718
2889
|
const n = Math.min(e, r.length);
|
|
2719
2890
|
this.#e.setSelectionRange(n, n);
|
|
2720
2891
|
}
|
|
2721
|
-
const a = this.#
|
|
2722
|
-
a && (this.#s.setColor(a), this.#
|
|
2892
|
+
const a = this.#d(r);
|
|
2893
|
+
a && (this.#s.setColor(a), this.#l(), this.#n(r) && this.#v(), this.emit("input", { value: this.value }));
|
|
2723
2894
|
};
|
|
2724
|
-
#
|
|
2895
|
+
#d(t) {
|
|
2725
2896
|
let e = t;
|
|
2726
2897
|
e.startsWith("#") || (e = "#" + e);
|
|
2727
2898
|
const s = e.slice(1);
|
|
@@ -2739,18 +2910,18 @@ class ut extends u {
|
|
|
2739
2910
|
return !!(/^#[a-fA-F0-9]{6}$/.test(t) || /^#[a-fA-F0-9]{3}$/.test(t));
|
|
2740
2911
|
}
|
|
2741
2912
|
#p = (t) => {
|
|
2742
|
-
t.key === "Enter" && (t.preventDefault(), this.#
|
|
2913
|
+
t.key === "Enter" && (t.preventDefault(), this.#h(), this.emit("change", { value: this.value }));
|
|
2743
2914
|
};
|
|
2744
2915
|
#u = () => {
|
|
2745
|
-
!this.#s || !this.#e || (document.activeElement !== this.#e && (this.#e.value = this.#s.value), this.#
|
|
2916
|
+
!this.#s || !this.#e || (document.activeElement !== this.#e && (this.#e.value = this.#s.value), this.#l(), this.#v(), this.emit("input", { value: this.value }));
|
|
2746
2917
|
};
|
|
2747
|
-
#
|
|
2918
|
+
#m = () => {
|
|
2748
2919
|
this.emit("change", { value: this.value });
|
|
2749
2920
|
};
|
|
2750
2921
|
#b = (t) => {
|
|
2751
2922
|
this.state === "open" && (this.contains(t.target) || this.close());
|
|
2752
2923
|
};
|
|
2753
|
-
#
|
|
2924
|
+
#k = (t) => {
|
|
2754
2925
|
t.key === "Escape" && this.state === "open" && (this.close(), this.#t?.focus());
|
|
2755
2926
|
};
|
|
2756
2927
|
open() {
|
|
@@ -2764,38 +2935,38 @@ class ut extends u {
|
|
|
2764
2935
|
const t = this.getBoundingClientRect(), e = 280, i = window.innerHeight - t.bottom, r = t.top;
|
|
2765
2936
|
i < e && r > i ? this.setAttribute("data-ry-position", "top") : this.setAttribute("data-ry-position", "bottom");
|
|
2766
2937
|
}
|
|
2767
|
-
#
|
|
2938
|
+
#l() {
|
|
2768
2939
|
const t = this.$('[data-ry-target="swatch-color"]');
|
|
2769
2940
|
if (t && this.#s) {
|
|
2770
2941
|
const e = this.#s.rgb, s = this.hasAttribute("opacity") ? this.#s.alpha / 100 : 1;
|
|
2771
2942
|
t.style.backgroundColor = `rgba(${e.r}, ${e.g}, ${e.b}, ${s})`;
|
|
2772
2943
|
}
|
|
2773
2944
|
}
|
|
2774
|
-
#
|
|
2945
|
+
#f() {
|
|
2775
2946
|
const t = this.getAttribute("value") || "#000000";
|
|
2776
2947
|
if (this.#s) {
|
|
2777
2948
|
if (this.#s.setColor(t), this.#e) {
|
|
2778
2949
|
const e = this.#s.value;
|
|
2779
2950
|
this.#e.value = e.startsWith("#") ? e : "#" + e;
|
|
2780
2951
|
}
|
|
2781
|
-
this.#
|
|
2952
|
+
this.#l();
|
|
2782
2953
|
}
|
|
2783
2954
|
}
|
|
2784
|
-
#
|
|
2955
|
+
#v() {
|
|
2785
2956
|
if (this.#s) {
|
|
2786
2957
|
const t = this.#s.value;
|
|
2787
2958
|
this.getAttribute("value") !== t && this.setAttribute("value", t);
|
|
2788
2959
|
}
|
|
2789
2960
|
}
|
|
2790
2961
|
attributeChangedCallback(t, e, s) {
|
|
2791
|
-
e !== s && (t === "value" && this.#s && this.#e && s && (this.#s.setColor(s), document.activeElement !== this.#e && (this.#e.value = this.#s.value), this.#
|
|
2962
|
+
e !== s && (t === "value" && this.#s && this.#e && s && (this.#s.setColor(s), document.activeElement !== this.#e && (this.#e.value = this.#s.value), this.#l()), t === "disabled" && this.#e && (s !== null ? this.#e.setAttribute("disabled", "") : this.#e.removeAttribute("disabled")));
|
|
2792
2963
|
}
|
|
2793
2964
|
// Public API
|
|
2794
2965
|
get value() {
|
|
2795
2966
|
return this.#s?.value ?? this.getAttribute("value") ?? "#000000";
|
|
2796
2967
|
}
|
|
2797
2968
|
set value(t) {
|
|
2798
|
-
this.#s?.setColor(t) && (this.#e && (this.#e.value = this.#s.value), this.#
|
|
2969
|
+
this.#s?.setColor(t) && (this.#e && (this.#e.value = this.#s.value), this.#l(), this.#v());
|
|
2799
2970
|
}
|
|
2800
2971
|
get disabled() {
|
|
2801
2972
|
return this.hasAttribute("disabled");
|
|
@@ -2813,7 +2984,7 @@ class ut extends u {
|
|
|
2813
2984
|
return this.#s?.hsv ?? { h: 0, s: 0, v: 0 };
|
|
2814
2985
|
}
|
|
2815
2986
|
}
|
|
2816
|
-
customElements.define("ry-color-input",
|
|
2987
|
+
customElements.define("ry-color-input", gt);
|
|
2817
2988
|
function x(h) {
|
|
2818
2989
|
const t = h.trim().toLowerCase();
|
|
2819
2990
|
if (t.startsWith("#")) {
|
|
@@ -2846,19 +3017,19 @@ function x(h) {
|
|
|
2846
3017
|
}
|
|
2847
3018
|
return null;
|
|
2848
3019
|
}
|
|
2849
|
-
function
|
|
3020
|
+
function ft(h) {
|
|
2850
3021
|
const t = (e) => Math.max(0, Math.min(255, e)).toString(16).padStart(2, "0");
|
|
2851
3022
|
return `#${t(h.r)}${t(h.g)}${t(h.b)}`;
|
|
2852
3023
|
}
|
|
2853
|
-
function
|
|
3024
|
+
function yt(h, t, e) {
|
|
2854
3025
|
return {
|
|
2855
3026
|
r: Math.round(h.r + (t.r - h.r) * e),
|
|
2856
3027
|
g: Math.round(h.g + (t.g - h.g) * e),
|
|
2857
3028
|
b: Math.round(h.b + (t.b - h.b) * e)
|
|
2858
3029
|
};
|
|
2859
3030
|
}
|
|
2860
|
-
const
|
|
2861
|
-
class
|
|
3031
|
+
const I = "linear-gradient(90deg, #000000 0%, #ffffff 100%)", bt = 50;
|
|
3032
|
+
class mt extends u {
|
|
2862
3033
|
#t = "linear";
|
|
2863
3034
|
#e = 90;
|
|
2864
3035
|
#i = "circle";
|
|
@@ -2866,28 +3037,28 @@ class yt extends u {
|
|
|
2866
3037
|
#r = null;
|
|
2867
3038
|
#a = 0;
|
|
2868
3039
|
#o = null;
|
|
2869
|
-
#
|
|
2870
|
-
#
|
|
2871
|
-
#
|
|
3040
|
+
#c = !1;
|
|
3041
|
+
#h = null;
|
|
3042
|
+
#d = !1;
|
|
2872
3043
|
// Cached DOM refs
|
|
2873
3044
|
#n = null;
|
|
2874
3045
|
#p = null;
|
|
2875
3046
|
#u = null;
|
|
2876
3047
|
static observedAttributes = ["value", "disabled", "output"];
|
|
2877
3048
|
setup() {
|
|
2878
|
-
this.#
|
|
3049
|
+
this.#m(), this.#Y(), this.#X(), this.#x();
|
|
2879
3050
|
}
|
|
2880
3051
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2881
3052
|
// Parsing / Serialization
|
|
2882
3053
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2883
|
-
#
|
|
2884
|
-
const t = this.getAttribute("value") ||
|
|
2885
|
-
this.#b(t) || this.#b(
|
|
3054
|
+
#m() {
|
|
3055
|
+
const t = this.getAttribute("value") || I;
|
|
3056
|
+
this.#b(t) || this.#b(I);
|
|
2886
3057
|
}
|
|
2887
3058
|
#b(t) {
|
|
2888
3059
|
const e = t.trim();
|
|
2889
3060
|
if (!e.startsWith("linear-gradient(") && !e.startsWith("radial-gradient("))
|
|
2890
|
-
return x(e) ? (this.#t = "solid", this.#s = [this.#
|
|
3061
|
+
return x(e) ? (this.#t = "solid", this.#s = [this.#l(e, 0), this.#l(e, 100)], this.#r = this.#s[0].id, !0) : !1;
|
|
2891
3062
|
let s, i;
|
|
2892
3063
|
e.startsWith("linear-gradient(") ? (s = "linear", i = e.slice(16, -1)) : (s = "radial", i = e.slice(16, -1));
|
|
2893
3064
|
let r = 90, a = "circle", n = i;
|
|
@@ -2899,7 +3070,7 @@ class yt extends u {
|
|
|
2899
3070
|
const g = /^to\s+\w+(?:\s+\w+)?\s*,\s*/.exec(i);
|
|
2900
3071
|
if (g) {
|
|
2901
3072
|
const b = g[0].trim().replace(/,\s*$/, "");
|
|
2902
|
-
r = this.#
|
|
3073
|
+
r = this.#k(b), n = i.slice(g[0].length);
|
|
2903
3074
|
}
|
|
2904
3075
|
}
|
|
2905
3076
|
} else {
|
|
@@ -2909,10 +3080,10 @@ class yt extends u {
|
|
|
2909
3080
|
const o = [], l = /(#[a-fA-F0-9]{3,8}|rgba?\([^)]+\)|hsla?\([^)]+\)|[a-z]+)\s+([\d.]+)%/g;
|
|
2910
3081
|
let c;
|
|
2911
3082
|
for (; (c = l.exec(n)) !== null; )
|
|
2912
|
-
o.push(this.#
|
|
3083
|
+
o.push(this.#l(c[1], parseFloat(c[2])));
|
|
2913
3084
|
return o.length < 2 ? !1 : (this.#t = s, this.#e = r, this.#i = a, this.#s = o, this.#r = o[0].id, !0);
|
|
2914
3085
|
}
|
|
2915
|
-
#
|
|
3086
|
+
#k(t) {
|
|
2916
3087
|
return {
|
|
2917
3088
|
"to top": 0,
|
|
2918
3089
|
"to top right": 45,
|
|
@@ -2933,22 +3104,22 @@ class yt extends u {
|
|
|
2933
3104
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2934
3105
|
// Stop management
|
|
2935
3106
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2936
|
-
#
|
|
3107
|
+
#l(t, e) {
|
|
2937
3108
|
return { id: `stop-${this.#a++}`, color: t, position: e };
|
|
2938
3109
|
}
|
|
2939
3110
|
/** CSS left value clamped so the stop handle stays within the bar */
|
|
2940
|
-
#
|
|
3111
|
+
#f(t) {
|
|
2941
3112
|
const e = "calc(var(--ry-gradient-picker-stop-size, 16px) / 2)";
|
|
2942
3113
|
return `clamp(${e}, ${t}%, calc(100% - ${e}))`;
|
|
2943
3114
|
}
|
|
2944
|
-
#
|
|
2945
|
-
const s = this.#
|
|
2946
|
-
this.#s.push(s), this.#$(), this.#r = s.id, this.#
|
|
3115
|
+
#v(t, e) {
|
|
3116
|
+
const s = this.#l(t, e);
|
|
3117
|
+
this.#s.push(s), this.#$(), this.#r = s.id, this.#C(), this.#x();
|
|
2947
3118
|
}
|
|
2948
|
-
#
|
|
3119
|
+
#y(t) {
|
|
2949
3120
|
if (this.#s.length <= 2) return !1;
|
|
2950
3121
|
const e = this.#s.findIndex((s) => s.id === t);
|
|
2951
|
-
return e === -1 ? !1 : (this.#s.splice(e, 1), this.#r === t && (this.#r = this.#s[Math.min(e, this.#s.length - 1)]?.id ?? null), this.#
|
|
3122
|
+
return e === -1 ? !1 : (this.#s.splice(e, 1), this.#r === t && (this.#r = this.#s[Math.min(e, this.#s.length - 1)]?.id ?? null), this.#C(), this.#x(), !0);
|
|
2952
3123
|
}
|
|
2953
3124
|
#M(t) {
|
|
2954
3125
|
this.#r !== t && (this.#r = t, this.#O(), this.#L());
|
|
@@ -2956,13 +3127,13 @@ class yt extends u {
|
|
|
2956
3127
|
#$() {
|
|
2957
3128
|
this.#s.sort((t, e) => t.position - e.position);
|
|
2958
3129
|
}
|
|
2959
|
-
#
|
|
3130
|
+
#I() {
|
|
2960
3131
|
return this.#s.find((t) => t.id === this.#r) ?? null;
|
|
2961
3132
|
}
|
|
2962
3133
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2963
3134
|
// Markup
|
|
2964
3135
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2965
|
-
#
|
|
3136
|
+
#Y() {
|
|
2966
3137
|
const t = this.hasAttribute("output"), e = p("copy"), s = p("gradient-solid"), i = p("gradient-linear"), r = p("gradient-radial"), a = p("shape-circle"), n = p("shape-ellipse");
|
|
2967
3138
|
let o = "";
|
|
2968
3139
|
t && (o = `
|
|
@@ -2989,14 +3160,14 @@ class yt extends u {
|
|
|
2989
3160
|
</div>
|
|
2990
3161
|
<ry-color-picker data-ry-target="picker" inline opacity></ry-color-picker>
|
|
2991
3162
|
${o}
|
|
2992
|
-
`, this.#n = this.$('[data-ry-target="bar"]'), this.#p = this.$('[data-ry-target="picker"]'), this.#u = this.$('[data-ry-target="output"]'), this.#
|
|
3163
|
+
`, this.#n = this.$('[data-ry-target="bar"]'), this.#p = this.$('[data-ry-target="picker"]'), this.#u = this.$('[data-ry-target="output"]'), this.#C();
|
|
2993
3164
|
}
|
|
2994
|
-
#
|
|
3165
|
+
#C() {
|
|
2995
3166
|
if (this.#n) {
|
|
2996
3167
|
this.#n.querySelectorAll('[data-ry-target="stop"]').forEach((t) => t.remove());
|
|
2997
3168
|
for (const t of this.#s) {
|
|
2998
3169
|
const e = document.createElement("div");
|
|
2999
|
-
e.setAttribute("data-ry-target", "stop"), e.setAttribute("data-stop-id", t.id), e.classList.add("ry-gradient-picker__stop"), e.tabIndex = 0, e.style.left = this.#
|
|
3170
|
+
e.setAttribute("data-ry-target", "stop"), e.setAttribute("data-stop-id", t.id), e.classList.add("ry-gradient-picker__stop"), e.tabIndex = 0, e.style.left = this.#f(t.position), e.style.setProperty("--stop-color", t.color), t.id === this.#r && e.setAttribute("data-selected", ""), this.#n.appendChild(e);
|
|
3000
3171
|
}
|
|
3001
3172
|
}
|
|
3002
3173
|
}
|
|
@@ -3006,13 +3177,13 @@ class yt extends u {
|
|
|
3006
3177
|
#X() {
|
|
3007
3178
|
this.#n && (this.on(this.#n, "pointerdown", this.#G), this.on(this.#n, "pointermove", this.#K), this.on(this.#n, "pointerup", this.#q), this.on(this.#n, "lostpointercapture", this.#q));
|
|
3008
3179
|
const t = this.$('[data-ry-target="type-solid"]'), e = this.$('[data-ry-target="type-linear"]'), s = this.$('[data-ry-target="type-radial"]');
|
|
3009
|
-
t && this.on(t, "click", () => this.#
|
|
3180
|
+
t && this.on(t, "click", () => this.#E("solid")), e && this.on(e, "click", () => this.#E("linear")), s && this.on(s, "click", () => this.#E("radial"));
|
|
3010
3181
|
const i = this.$('[data-ry-target="angle-select"]');
|
|
3011
|
-
i && this.on(i, "ry:input", this.#
|
|
3182
|
+
i && this.on(i, "ry:input", this.#z);
|
|
3012
3183
|
const r = this.$('[data-ry-target="shape-circle"]'), a = this.$('[data-ry-target="shape-ellipse"]');
|
|
3013
3184
|
r && this.on(r, "click", () => this.#P("circle")), a && this.on(a, "click", () => this.#P("ellipse")), this.#p && (this.on(this.#p, "ry:input", this.#R), this.on(this.#p, "ry:change", this.#T)), this.#u && (this.on(this.#u, "keydown", this.#F), this.on(this.#u, "blur", this.#j));
|
|
3014
3185
|
const n = this.$('[data-ry-target="copy-btn"]');
|
|
3015
|
-
n && this.on(n, "click", this.#
|
|
3186
|
+
n && this.on(n, "click", this.#U), this.#n && this.on(this.#n, "keydown", this.#J);
|
|
3016
3187
|
}
|
|
3017
3188
|
// ───────────────────────────────────────────────────────────────────────────
|
|
3018
3189
|
// Bar / Stop interaction handlers
|
|
@@ -3023,26 +3194,26 @@ class yt extends u {
|
|
|
3023
3194
|
if (s) {
|
|
3024
3195
|
const i = s.getAttribute("data-stop-id");
|
|
3025
3196
|
if (!i) return;
|
|
3026
|
-
t.preventDefault(), this.#o = i, this.#
|
|
3197
|
+
t.preventDefault(), this.#o = i, this.#c = !1, this.#h = this.#n.getBoundingClientRect(), this.#M(i), this.#n.setPointerCapture(t.pointerId), s.focus();
|
|
3027
3198
|
} else {
|
|
3028
3199
|
if (t.preventDefault(), !this.#n) return;
|
|
3029
|
-
const i = this.#n.getBoundingClientRect(), r = Math.round(Math.max(0, Math.min(100, (t.clientX - i.left) / i.width * 100))), a = this.#
|
|
3030
|
-
this.#
|
|
3200
|
+
const i = this.#n.getBoundingClientRect(), r = Math.round(Math.max(0, Math.min(100, (t.clientX - i.left) / i.width * 100))), a = this.#V(r);
|
|
3201
|
+
this.#v(a, r), this.#n.querySelector(`[data-stop-id="${this.#r}"]`)?.focus(), this.#o = this.#r, this.#c = !1, this.#h = i, this.#n.setPointerCapture(t.pointerId), this.#D();
|
|
3031
3202
|
}
|
|
3032
3203
|
};
|
|
3033
3204
|
#K = (t) => {
|
|
3034
|
-
if (!this.#o || !this.#
|
|
3205
|
+
if (!this.#o || !this.#h) return;
|
|
3035
3206
|
const e = this.#s.find((n) => n.id === this.#o);
|
|
3036
3207
|
if (!e) return;
|
|
3037
|
-
const s = Math.max(0, Math.min(1, (t.clientX - this.#
|
|
3208
|
+
const s = Math.max(0, Math.min(1, (t.clientX - this.#h.left) / this.#h.width));
|
|
3038
3209
|
e.position = Math.round(s * 100);
|
|
3039
|
-
const i = this.#
|
|
3040
|
-
this.#
|
|
3210
|
+
const i = this.#h.top + this.#h.height / 2, r = Math.abs(t.clientY - i);
|
|
3211
|
+
this.#c = r > bt && this.#s.length > 2;
|
|
3041
3212
|
const a = this.#n?.querySelector(`[data-stop-id="${e.id}"]`);
|
|
3042
|
-
a && (a.style.left = this.#
|
|
3213
|
+
a && (a.style.left = this.#f(e.position), this.#c ? (a.style.opacity = "0.3", a.style.transform = "translate(-50%, -50%) scale(0.7)") : (a.style.opacity = "", a.style.transform = "")), this.#$(), this.#N(), this.#H(), this.#w(), this.#D();
|
|
3043
3214
|
};
|
|
3044
3215
|
#q = () => {
|
|
3045
|
-
this.#o && (this.#
|
|
3216
|
+
this.#o && (this.#c && this.#y(this.#o), this.#o = null, this.#c = !1, this.#h = null, this.#S(), this.#B());
|
|
3046
3217
|
};
|
|
3047
3218
|
#J = (t) => {
|
|
3048
3219
|
if (this.disabled) return;
|
|
@@ -3063,30 +3234,30 @@ class yt extends u {
|
|
|
3063
3234
|
break;
|
|
3064
3235
|
case "Delete":
|
|
3065
3236
|
case "Backspace":
|
|
3066
|
-
this.#
|
|
3237
|
+
this.#y(i) && (this.#D(), this.#B()), t.preventDefault();
|
|
3067
3238
|
return;
|
|
3068
3239
|
}
|
|
3069
|
-
n && (t.preventDefault(), this.#$(), this.#
|
|
3240
|
+
n && (t.preventDefault(), this.#$(), this.#W(), this.#N(), this.#H(), this.#w(), this.#S(), this.#D(), this.#B());
|
|
3070
3241
|
};
|
|
3071
3242
|
// ───────────────────────────────────────────────────────────────────────────
|
|
3072
3243
|
// Type / Angle / Shape handlers
|
|
3073
3244
|
// ───────────────────────────────────────────────────────────────────────────
|
|
3074
|
-
#
|
|
3075
|
-
this.#t !== t && (this.#t = t, this.setAttribute("data-ry-type", t), this.#_(), this.#
|
|
3245
|
+
#E(t) {
|
|
3246
|
+
this.#t !== t && (this.#t = t, this.setAttribute("data-ry-type", t), this.#_(), this.#H(), this.#w(), this.#S(), this.#D(), this.#B());
|
|
3076
3247
|
}
|
|
3077
|
-
#
|
|
3248
|
+
#z = (t) => {
|
|
3078
3249
|
const e = t.detail;
|
|
3079
|
-
this.#e = e.value, this.#
|
|
3250
|
+
this.#e = e.value, this.#H(), this.#w(), this.#S(), this.#D();
|
|
3080
3251
|
};
|
|
3081
3252
|
#P(t) {
|
|
3082
|
-
this.#i !== t && (this.#i = t, this.#_(), this.#
|
|
3253
|
+
this.#i !== t && (this.#i = t, this.#_(), this.#w(), this.#S(), this.#D(), this.#B());
|
|
3083
3254
|
}
|
|
3084
3255
|
// ───────────────────────────────────────────────────────────────────────────
|
|
3085
3256
|
// Color picker handlers
|
|
3086
3257
|
// ───────────────────────────────────────────────────────────────────────────
|
|
3087
3258
|
#R = () => {
|
|
3088
|
-
const t = this.#
|
|
3089
|
-
!t || !this.#p || (t.color = this.#p.value, this.#Z(t), this.#N(), this.#
|
|
3259
|
+
const t = this.#I();
|
|
3260
|
+
!t || !this.#p || (t.color = this.#p.value, this.#Z(t), this.#N(), this.#H(), this.#w(), this.#D());
|
|
3090
3261
|
};
|
|
3091
3262
|
#T = () => {
|
|
3092
3263
|
this.#S(), this.#B();
|
|
@@ -3094,7 +3265,7 @@ class yt extends u {
|
|
|
3094
3265
|
// ───────────────────────────────────────────────────────────────────────────
|
|
3095
3266
|
// Copy handler
|
|
3096
3267
|
// ───────────────────────────────────────────────────────────────────────────
|
|
3097
|
-
#
|
|
3268
|
+
#U = () => {
|
|
3098
3269
|
const t = this.#g();
|
|
3099
3270
|
navigator.clipboard.writeText(t).then(() => {
|
|
3100
3271
|
const e = this.$('[data-ry-target="copy-btn"]');
|
|
@@ -3113,12 +3284,12 @@ class yt extends u {
|
|
|
3113
3284
|
#A() {
|
|
3114
3285
|
if (!this.#u) return;
|
|
3115
3286
|
const t = this.#u.value.trim();
|
|
3116
|
-
t && this.#b(t) ? (this.#
|
|
3287
|
+
t && this.#b(t) ? (this.#C(), this.#x(), this.#S(), this.#D(), this.#B()) : this.#w();
|
|
3117
3288
|
}
|
|
3118
3289
|
// ───────────────────────────────────────────────────────────────────────────
|
|
3119
3290
|
// Color interpolation
|
|
3120
3291
|
// ───────────────────────────────────────────────────────────────────────────
|
|
3121
|
-
#
|
|
3292
|
+
#V(t) {
|
|
3122
3293
|
if (this.#s.length === 0) return "#808080";
|
|
3123
3294
|
if (this.#s.length === 1) return this.#s[0].color;
|
|
3124
3295
|
const e = [...this.#s].sort((l, c) => l.position - c.position);
|
|
@@ -3133,13 +3304,13 @@ class yt extends u {
|
|
|
3133
3304
|
const r = i.position - s.position;
|
|
3134
3305
|
if (r === 0) return s.color;
|
|
3135
3306
|
const a = (t - s.position) / r, n = x(s.color), o = x(i.color);
|
|
3136
|
-
return !n || !o ? s.color :
|
|
3307
|
+
return !n || !o ? s.color : ft(yt(n, o, a));
|
|
3137
3308
|
}
|
|
3138
3309
|
// ───────────────────────────────────────────────────────────────────────────
|
|
3139
3310
|
// Update methods
|
|
3140
3311
|
// ───────────────────────────────────────────────────────────────────────────
|
|
3141
3312
|
#x() {
|
|
3142
|
-
this.setAttribute("data-ry-type", this.#t), this.#_(), this.#N(), this.#
|
|
3313
|
+
this.setAttribute("data-ry-type", this.#t), this.#_(), this.#N(), this.#H(), this.#W(), this.#O(), this.#L(), this.#w();
|
|
3143
3314
|
}
|
|
3144
3315
|
#_() {
|
|
3145
3316
|
const t = this.$('[data-ry-target="type-solid"]'), e = this.$('[data-ry-target="type-linear"]'), s = this.$('[data-ry-target="type-radial"]');
|
|
@@ -3149,7 +3320,7 @@ class yt extends u {
|
|
|
3149
3320
|
const a = this.$('[data-ry-target="angle-select"]');
|
|
3150
3321
|
a && a.setAttribute("value", String(this.#e));
|
|
3151
3322
|
}
|
|
3152
|
-
#
|
|
3323
|
+
#H() {
|
|
3153
3324
|
if (!this.#p) return;
|
|
3154
3325
|
const t = this.#p.querySelector('[data-ry-target="preview-color"]');
|
|
3155
3326
|
t && (t.style.backgroundImage = this.#t === "solid" ? "" : this.#g());
|
|
@@ -3159,11 +3330,11 @@ class yt extends u {
|
|
|
3159
3330
|
const t = this.#s.map((e) => `${e.color} ${e.position}%`).join(", ");
|
|
3160
3331
|
this.#n.style.backgroundImage = `linear-gradient(to right, ${t})`;
|
|
3161
3332
|
}
|
|
3162
|
-
#
|
|
3333
|
+
#W() {
|
|
3163
3334
|
if (this.#n)
|
|
3164
3335
|
for (const t of this.#s) {
|
|
3165
3336
|
const e = this.#n.querySelector(`[data-stop-id="${t.id}"]`);
|
|
3166
|
-
e && (e.style.left = this.#
|
|
3337
|
+
e && (e.style.left = this.#f(t.position));
|
|
3167
3338
|
}
|
|
3168
3339
|
}
|
|
3169
3340
|
#Z(t) {
|
|
@@ -3178,20 +3349,20 @@ class yt extends u {
|
|
|
3178
3349
|
e.getAttribute("data-stop-id") === this.#r ? e.setAttribute("data-selected", "") : e.removeAttribute("data-selected");
|
|
3179
3350
|
}
|
|
3180
3351
|
#L() {
|
|
3181
|
-
const t = this.#
|
|
3352
|
+
const t = this.#I();
|
|
3182
3353
|
!t || !this.#p || this.#p.setColor(t.color);
|
|
3183
3354
|
}
|
|
3184
|
-
#
|
|
3355
|
+
#w() {
|
|
3185
3356
|
this.#u && document.activeElement !== this.#u && (this.#u.value = this.#g());
|
|
3186
3357
|
}
|
|
3187
3358
|
#S() {
|
|
3188
3359
|
const t = this.#g();
|
|
3189
|
-
this.getAttribute("value") !== t && (this.#
|
|
3360
|
+
this.getAttribute("value") !== t && (this.#d = !0, this.setAttribute("value", t), this.#d = !1);
|
|
3190
3361
|
}
|
|
3191
3362
|
// ───────────────────────────────────────────────────────────────────────────
|
|
3192
3363
|
// Events
|
|
3193
3364
|
// ───────────────────────────────────────────────────────────────────────────
|
|
3194
|
-
#
|
|
3365
|
+
#D() {
|
|
3195
3366
|
this.emit("input", {
|
|
3196
3367
|
value: this.#g(),
|
|
3197
3368
|
type: this.#t,
|
|
@@ -3213,7 +3384,7 @@ class yt extends u {
|
|
|
3213
3384
|
// Attribute changed
|
|
3214
3385
|
// ───────────────────────────────────────────────────────────────────────────
|
|
3215
3386
|
attributeChangedCallback(t, e, s) {
|
|
3216
|
-
e === s || this.#
|
|
3387
|
+
e === s || this.#d || t === "value" && this.#n && s && this.#b(s) && (this.#C(), this.#x());
|
|
3217
3388
|
}
|
|
3218
3389
|
// ───────────────────────────────────────────────────────────────────────────
|
|
3219
3390
|
// Public API
|
|
@@ -3222,19 +3393,19 @@ class yt extends u {
|
|
|
3222
3393
|
return this.#g();
|
|
3223
3394
|
}
|
|
3224
3395
|
set value(t) {
|
|
3225
|
-
this.#b(t) && (this.#
|
|
3396
|
+
this.#b(t) && (this.#C(), this.#x(), this.#S());
|
|
3226
3397
|
}
|
|
3227
3398
|
get type() {
|
|
3228
3399
|
return this.#t;
|
|
3229
3400
|
}
|
|
3230
3401
|
set type(t) {
|
|
3231
|
-
this.#
|
|
3402
|
+
this.#E(t);
|
|
3232
3403
|
}
|
|
3233
3404
|
get angle() {
|
|
3234
3405
|
return this.#e;
|
|
3235
3406
|
}
|
|
3236
3407
|
set angle(t) {
|
|
3237
|
-
this.#e = (t % 360 + 360) % 360, this.#_(), this.#
|
|
3408
|
+
this.#e = (t % 360 + 360) % 360, this.#_(), this.#w(), this.#S();
|
|
3238
3409
|
}
|
|
3239
3410
|
get shape() {
|
|
3240
3411
|
return this.#i;
|
|
@@ -3246,7 +3417,7 @@ class yt extends u {
|
|
|
3246
3417
|
return this.#s.map((t) => ({ ...t }));
|
|
3247
3418
|
}
|
|
3248
3419
|
get selectedStop() {
|
|
3249
|
-
const t = this.#
|
|
3420
|
+
const t = this.#I();
|
|
3250
3421
|
return t ? { ...t } : null;
|
|
3251
3422
|
}
|
|
3252
3423
|
get disabled() {
|
|
@@ -3256,16 +3427,16 @@ class yt extends u {
|
|
|
3256
3427
|
t ? this.setAttribute("disabled", "") : this.removeAttribute("disabled");
|
|
3257
3428
|
}
|
|
3258
3429
|
addStop(t, e) {
|
|
3259
|
-
this.#
|
|
3430
|
+
this.#v(t, e), this.#S(), this.#D(), this.#B();
|
|
3260
3431
|
}
|
|
3261
3432
|
removeStop(t) {
|
|
3262
|
-
const e = this.#
|
|
3263
|
-
return e && (this.#
|
|
3433
|
+
const e = this.#y(t);
|
|
3434
|
+
return e && (this.#w(), this.#S(), this.#B()), e;
|
|
3264
3435
|
}
|
|
3265
3436
|
}
|
|
3266
|
-
customElements.define("ry-gradient-picker",
|
|
3267
|
-
let
|
|
3268
|
-
const
|
|
3437
|
+
customElements.define("ry-gradient-picker", mt);
|
|
3438
|
+
let vt = 0;
|
|
3439
|
+
const At = 5;
|
|
3269
3440
|
function _(h) {
|
|
3270
3441
|
return p(h).replace(/width="24"/g, 'width="16"').replace(/height="24"/g, 'height="16"').replace(/viewBox/, 'class="ry-tree__icon" viewBox');
|
|
3271
3442
|
}
|
|
@@ -3278,9 +3449,9 @@ class k extends u {
|
|
|
3278
3449
|
#r = null;
|
|
3279
3450
|
#a = null;
|
|
3280
3451
|
#o = null;
|
|
3281
|
-
#
|
|
3452
|
+
#c = null;
|
|
3282
3453
|
setup() {
|
|
3283
|
-
this.#
|
|
3454
|
+
this.#h(), this.on(this, "click", (t) => {
|
|
3284
3455
|
const s = t.target.closest('[data-ry-target="file"]');
|
|
3285
3456
|
s && (this.$$("[data-ry-selected]").forEach((i) => i.removeAttribute("data-ry-selected")), s.setAttribute("data-ry-selected", ""), this.emit("select", {
|
|
3286
3457
|
label: s.dataset.ryLabel ?? ""
|
|
@@ -3293,25 +3464,25 @@ class k extends u {
|
|
|
3293
3464
|
label: i,
|
|
3294
3465
|
open: e.checked
|
|
3295
3466
|
});
|
|
3296
|
-
}), this.hasAttribute("sortable") && this.#
|
|
3467
|
+
}), this.hasAttribute("sortable") && this.#m();
|
|
3297
3468
|
}
|
|
3298
3469
|
// ── Build ──────────────────────────────────────────────────
|
|
3299
|
-
#
|
|
3470
|
+
#h() {
|
|
3300
3471
|
if (this.$(".ry-tree__root")) return;
|
|
3301
3472
|
const t = Array.from(this.children), e = document.createElement("ul");
|
|
3302
3473
|
e.className = "ry-tree__root";
|
|
3303
3474
|
for (const s of t)
|
|
3304
|
-
e.appendChild(this.#
|
|
3475
|
+
e.appendChild(this.#d(s));
|
|
3305
3476
|
this.innerHTML = "", this.appendChild(e);
|
|
3306
3477
|
}
|
|
3307
|
-
#
|
|
3478
|
+
#d(t) {
|
|
3308
3479
|
const e = document.createElement("li");
|
|
3309
3480
|
e.className = "ry-tree__item";
|
|
3310
3481
|
const s = t.getAttribute("label") ?? "", i = t.hasAttribute("open"), r = t.hasAttribute("selected"), a = Array.from(t.children).filter(
|
|
3311
3482
|
(o) => o.tagName === "RY-TREE-ITEM"
|
|
3312
3483
|
);
|
|
3313
3484
|
if (a.length > 0) {
|
|
3314
|
-
const o = `ry-tree-${++
|
|
3485
|
+
const o = `ry-tree-${++vt}`, l = document.createElement("input");
|
|
3315
3486
|
l.type = "checkbox", l.id = o, l.className = "ry-tree__toggle", i && (l.checked = !0);
|
|
3316
3487
|
const c = document.createElement("label");
|
|
3317
3488
|
c.htmlFor = o, c.className = "ry-tree__label", c.setAttribute("data-ry-target", "folder"), c.dataset.ryLabel = s, c.innerHTML = `
|
|
@@ -3324,7 +3495,7 @@ class k extends u {
|
|
|
3324
3495
|
const g = document.createElement("ul");
|
|
3325
3496
|
g.className = "ry-tree__children";
|
|
3326
3497
|
for (const b of a)
|
|
3327
|
-
g.appendChild(this.#
|
|
3498
|
+
g.appendChild(this.#d(b));
|
|
3328
3499
|
d.appendChild(g), e.appendChild(l), e.appendChild(c), e.appendChild(d);
|
|
3329
3500
|
} else {
|
|
3330
3501
|
const o = document.createElement("div");
|
|
@@ -3375,8 +3546,8 @@ class k extends u {
|
|
|
3375
3546
|
return e;
|
|
3376
3547
|
}
|
|
3377
3548
|
// ── Drag and Drop ──────────────────────────────────────────
|
|
3378
|
-
#
|
|
3379
|
-
this.on(this, "pointerdown", this.#b), this.on(document, "pointermove", this.#
|
|
3549
|
+
#m() {
|
|
3550
|
+
this.on(this, "pointerdown", this.#b), this.on(document, "pointermove", this.#k), this.on(document, "pointerup", this.#g);
|
|
3380
3551
|
}
|
|
3381
3552
|
#b = (t) => {
|
|
3382
3553
|
const s = t.target.closest(".ry-tree__label, .ry-tree__file");
|
|
@@ -3384,42 +3555,42 @@ class k extends u {
|
|
|
3384
3555
|
const i = s.closest(".ry-tree__item");
|
|
3385
3556
|
i && (this.#t = !0, this.#i = t.clientX, this.#s = t.clientY, this.#r = i);
|
|
3386
3557
|
};
|
|
3387
|
-
#
|
|
3558
|
+
#k = (t) => {
|
|
3388
3559
|
if (!this.#t && !this.#e) return;
|
|
3389
3560
|
if (this.#t && !this.#e) {
|
|
3390
3561
|
const c = t.clientX - this.#i, d = t.clientY - this.#s;
|
|
3391
|
-
if (Math.hypot(c, d) <
|
|
3392
|
-
this.#t = !1, this.#e = !0, this.#
|
|
3562
|
+
if (Math.hypot(c, d) < At) return;
|
|
3563
|
+
this.#t = !1, this.#e = !0, this.#l(t);
|
|
3393
3564
|
}
|
|
3394
3565
|
if (!this.#e || !this.#a) return;
|
|
3395
3566
|
this.#a.style.left = `${t.clientX + 12}px`, this.#a.style.top = `${t.clientY - 14}px`, this.#a.style.display = "none";
|
|
3396
3567
|
const e = document.elementFromPoint(t.clientX, t.clientY);
|
|
3397
3568
|
if (this.#a.style.display = "", !e) {
|
|
3398
|
-
this.#
|
|
3569
|
+
this.#y();
|
|
3399
3570
|
return;
|
|
3400
3571
|
}
|
|
3401
3572
|
const s = e.closest(".ry-tree__label, .ry-tree__file");
|
|
3402
3573
|
if (!s) {
|
|
3403
|
-
this.#
|
|
3574
|
+
this.#y();
|
|
3404
3575
|
return;
|
|
3405
3576
|
}
|
|
3406
3577
|
const i = s.closest(".ry-tree__item");
|
|
3407
3578
|
if (!i || i === this.#r) {
|
|
3408
|
-
this.#
|
|
3579
|
+
this.#y();
|
|
3409
3580
|
return;
|
|
3410
3581
|
}
|
|
3411
3582
|
if (this.#r?.contains(i)) {
|
|
3412
|
-
this.#
|
|
3583
|
+
this.#y();
|
|
3413
3584
|
return;
|
|
3414
3585
|
}
|
|
3415
3586
|
const r = s.getBoundingClientRect(), a = t.clientY - r.top, n = r.height, o = i.querySelector(":scope > .ry-tree__toggle") !== null;
|
|
3416
3587
|
let l;
|
|
3417
|
-
o && a > n * 0.25 && a < n * 0.75 ? l = "inside" : a < n * 0.5 ? l = "before" : l = "after", this.#
|
|
3588
|
+
o && a > n * 0.25 && a < n * 0.75 ? l = "inside" : a < n * 0.5 ? l = "before" : l = "after", this.#v(i, l);
|
|
3418
3589
|
};
|
|
3419
3590
|
#g = () => {
|
|
3420
|
-
this.#e && this.#
|
|
3591
|
+
this.#e && this.#f(), this.#t = !1, this.#e = !1, this.#r = null;
|
|
3421
3592
|
};
|
|
3422
|
-
#
|
|
3593
|
+
#l(t) {
|
|
3423
3594
|
if (!this.#r) return;
|
|
3424
3595
|
t.preventDefault(), this.#r.setAttribute("data-ry-dragging", ""), this.#r.classList.add("ry-tree__item--collapsed");
|
|
3425
3596
|
const e = this.#r.querySelector(".ry-tree__label, .ry-tree__file");
|
|
@@ -3427,16 +3598,16 @@ class k extends u {
|
|
|
3427
3598
|
const s = e.cloneNode(!0);
|
|
3428
3599
|
s.className = "ry-tree__ghost", s.style.display = "flex", s.style.alignItems = "center", s.style.gap = "var(--ry-space-2, 0.5rem)", s.style.padding = "var(--ry-space-1, 0.25rem) var(--ry-space-2, 0.5rem)", s.style.height = "28px", s.style.fontSize = "var(--ry-text-sm, 0.875rem)", s.style.whiteSpace = "nowrap", s.style.left = `${t.clientX + 12}px`, s.style.top = `${t.clientY - 14}px`, document.body.appendChild(s), this.#a = s;
|
|
3429
3600
|
}
|
|
3430
|
-
#
|
|
3601
|
+
#f() {
|
|
3431
3602
|
this.#a?.parentNode && this.#a.parentNode.removeChild(this.#a), this.#a = null, this.#r?.classList.remove("ry-tree__item--collapsed"), this.#r?.removeAttribute("data-ry-dragging");
|
|
3432
|
-
const t = this.#o, e = this.#
|
|
3433
|
-
this.#
|
|
3603
|
+
const t = this.#o, e = this.#c;
|
|
3604
|
+
this.#y(), this.#r && t && e && this.#M(this.#r, t, e);
|
|
3434
3605
|
}
|
|
3435
|
-
#
|
|
3436
|
-
this.#o === t && this.#
|
|
3606
|
+
#v(t, e) {
|
|
3607
|
+
this.#o === t && this.#c === e || (this.#y(), t.setAttribute("data-ry-drop-target", e), this.#o = t, this.#c = e);
|
|
3437
3608
|
}
|
|
3438
|
-
#
|
|
3439
|
-
this.#o?.removeAttribute("data-ry-drop-target"), this.#o = null, this.#
|
|
3609
|
+
#y() {
|
|
3610
|
+
this.#o?.removeAttribute("data-ry-drop-target"), this.#o = null, this.#c = null;
|
|
3440
3611
|
}
|
|
3441
3612
|
#M(t, e, s) {
|
|
3442
3613
|
if (s === "inside" && e.contains(t)) return;
|
|
@@ -3464,12 +3635,12 @@ class k extends u {
|
|
|
3464
3635
|
return e?.dataset.ryLabel ?? s?.dataset.ryLabel ?? "";
|
|
3465
3636
|
}
|
|
3466
3637
|
}
|
|
3467
|
-
class
|
|
3638
|
+
class kt extends u {
|
|
3468
3639
|
// Declarative container consumed by RyTree#build
|
|
3469
3640
|
}
|
|
3470
3641
|
customElements.define("ry-tree", k);
|
|
3471
|
-
customElements.define("ry-tree-item",
|
|
3472
|
-
class
|
|
3642
|
+
customElements.define("ry-tree-item", kt);
|
|
3643
|
+
class wt extends u {
|
|
3473
3644
|
setup() {
|
|
3474
3645
|
this.#t();
|
|
3475
3646
|
}
|
|
@@ -3490,8 +3661,8 @@ class At extends u {
|
|
|
3490
3661
|
return this.$('[data-ry-target="label"]')?.textContent?.trim() ?? "";
|
|
3491
3662
|
}
|
|
3492
3663
|
}
|
|
3493
|
-
customElements.define("ry-tag",
|
|
3494
|
-
class
|
|
3664
|
+
customElements.define("ry-tag", wt);
|
|
3665
|
+
class $t extends u {
|
|
3495
3666
|
#t = [];
|
|
3496
3667
|
setup() {
|
|
3497
3668
|
this.#e(), this.#i();
|
|
@@ -3526,7 +3697,7 @@ class kt extends u {
|
|
|
3526
3697
|
else if (t.key === "Tab")
|
|
3527
3698
|
return;
|
|
3528
3699
|
}
|
|
3529
|
-
t.key === "Backspace" && !e.value && this.#t.length > 0 && this.#
|
|
3700
|
+
t.key === "Backspace" && !e.value && this.#t.length > 0 && this.#c();
|
|
3530
3701
|
};
|
|
3531
3702
|
#r = (t) => {
|
|
3532
3703
|
t.preventDefault();
|
|
@@ -3538,7 +3709,7 @@ class kt extends u {
|
|
|
3538
3709
|
};
|
|
3539
3710
|
#a = (t) => {
|
|
3540
3711
|
const e = t.detail.value, s = this.#t.indexOf(e);
|
|
3541
|
-
s >= 0 && (this.#t.splice(s, 1), this.#
|
|
3712
|
+
s >= 0 && (this.#t.splice(s, 1), this.#h(), this.emit("change", { values: [...this.#t] }));
|
|
3542
3713
|
};
|
|
3543
3714
|
#o(t) {
|
|
3544
3715
|
const e = this.getAttribute("max-tags");
|
|
@@ -3549,16 +3720,16 @@ class kt extends u {
|
|
|
3549
3720
|
const i = document.createElement("ry-tag");
|
|
3550
3721
|
i.setAttribute("removable", ""), i.setAttribute("size", "sm"), i.setAttribute("data-value", t), i.textContent = t, s.appendChild(i);
|
|
3551
3722
|
}
|
|
3552
|
-
this.#
|
|
3723
|
+
this.#h(), this.emit("add", { value: t }), this.emit("change", { values: [...this.#t] });
|
|
3553
3724
|
}
|
|
3554
|
-
#
|
|
3725
|
+
#c() {
|
|
3555
3726
|
const e = this.$('[data-ry-target="tags"]')?.lastElementChild;
|
|
3556
3727
|
if (e) {
|
|
3557
3728
|
const s = e.dataset.value ?? "";
|
|
3558
|
-
e.remove(), this.#t.pop(), this.#
|
|
3729
|
+
e.remove(), this.#t.pop(), this.#h(), this.emit("remove", { value: s, label: s }), this.emit("change", { values: [...this.#t] });
|
|
3559
3730
|
}
|
|
3560
3731
|
}
|
|
3561
|
-
#
|
|
3732
|
+
#h() {
|
|
3562
3733
|
const t = this.$('[data-ry-target="hidden"]'), e = this.getAttribute("delimiter") ?? ",";
|
|
3563
3734
|
t && (t.value = this.#t.join(e));
|
|
3564
3735
|
}
|
|
@@ -3570,11 +3741,11 @@ class kt extends u {
|
|
|
3570
3741
|
return [...this.#t];
|
|
3571
3742
|
}
|
|
3572
3743
|
}
|
|
3573
|
-
customElements.define("ry-tag-input",
|
|
3574
|
-
class
|
|
3744
|
+
customElements.define("ry-tag-input", $t);
|
|
3745
|
+
class xt extends u {
|
|
3575
3746
|
}
|
|
3576
|
-
customElements.define("ry-hero",
|
|
3577
|
-
class
|
|
3747
|
+
customElements.define("ry-hero", xt);
|
|
3748
|
+
class _t extends u {
|
|
3578
3749
|
setup() {
|
|
3579
3750
|
this.#t();
|
|
3580
3751
|
}
|
|
@@ -3587,8 +3758,8 @@ class $t extends u {
|
|
|
3587
3758
|
`;
|
|
3588
3759
|
}
|
|
3589
3760
|
}
|
|
3590
|
-
customElements.define("ry-stat",
|
|
3591
|
-
class
|
|
3761
|
+
customElements.define("ry-stat", _t);
|
|
3762
|
+
class Mt extends u {
|
|
3592
3763
|
setup() {
|
|
3593
3764
|
this.#t();
|
|
3594
3765
|
}
|
|
@@ -3602,17 +3773,17 @@ class xt extends u {
|
|
|
3602
3773
|
s.setAttribute("data-ry-target", "icon"), s.className = "ry-feature__icon", s.innerHTML = e, this.insertBefore(s, this.firstChild);
|
|
3603
3774
|
}
|
|
3604
3775
|
}
|
|
3605
|
-
class
|
|
3606
|
-
}
|
|
3607
|
-
customElements.define("ry-feature", xt);
|
|
3608
|
-
customElements.define("ry-feature-grid", _t);
|
|
3609
|
-
class Mt extends u {
|
|
3776
|
+
class Et extends u {
|
|
3610
3777
|
}
|
|
3778
|
+
customElements.define("ry-feature", Mt);
|
|
3779
|
+
customElements.define("ry-feature-grid", Et);
|
|
3611
3780
|
class Ct extends u {
|
|
3612
3781
|
}
|
|
3613
|
-
|
|
3614
|
-
|
|
3615
|
-
|
|
3782
|
+
class St extends u {
|
|
3783
|
+
}
|
|
3784
|
+
customElements.define("ry-pricing", Ct);
|
|
3785
|
+
customElements.define("ry-pricing-card", St);
|
|
3786
|
+
class Tt extends u {
|
|
3616
3787
|
#t = 0;
|
|
3617
3788
|
#e = 0;
|
|
3618
3789
|
#i = null;
|
|
@@ -3647,18 +3818,18 @@ class Et extends u {
|
|
|
3647
3818
|
}
|
|
3648
3819
|
this.appendChild(a);
|
|
3649
3820
|
}
|
|
3650
|
-
this.on(r, "pointerdown", this.#
|
|
3821
|
+
this.on(r, "pointerdown", this.#c), this.on(r, "pointermove", this.#h), this.on(r, "pointerup", this.#d), this.on(r, "pointercancel", this.#d), this.hasAttribute("pause-on-hover") && (this.on(this, "mouseenter", () => this.#p()), this.on(this, "mouseleave", () => this.#n())), this.goTo(0);
|
|
3651
3822
|
}
|
|
3652
3823
|
#o = (t) => {
|
|
3653
3824
|
t.key === "ArrowLeft" ? (t.preventDefault(), this.prev()) : t.key === "ArrowRight" && (t.preventDefault(), this.next());
|
|
3654
3825
|
};
|
|
3655
|
-
#
|
|
3826
|
+
#c = (t) => {
|
|
3656
3827
|
this.#s = t.clientX, this.#r = !0, t.currentTarget.setPointerCapture(t.pointerId);
|
|
3657
3828
|
};
|
|
3658
|
-
#
|
|
3829
|
+
#h = (t) => {
|
|
3659
3830
|
this.#r && t.preventDefault();
|
|
3660
3831
|
};
|
|
3661
|
-
#
|
|
3832
|
+
#d = (t) => {
|
|
3662
3833
|
if (!this.#r) return;
|
|
3663
3834
|
this.#r = !1;
|
|
3664
3835
|
const e = t.clientX - this.#s, s = 50;
|
|
@@ -3692,50 +3863,52 @@ class Et extends u {
|
|
|
3692
3863
|
this.#p();
|
|
3693
3864
|
}
|
|
3694
3865
|
}
|
|
3695
|
-
customElements.define("ry-carousel",
|
|
3866
|
+
customElements.define("ry-carousel", Tt);
|
|
3696
3867
|
window.RyToast = f;
|
|
3697
3868
|
console.log("ry-ui loaded");
|
|
3698
3869
|
export {
|
|
3699
3870
|
R as RyAccordion,
|
|
3700
|
-
|
|
3871
|
+
z as RyAlert,
|
|
3701
3872
|
N as RyButton,
|
|
3702
|
-
|
|
3703
|
-
|
|
3704
|
-
|
|
3705
|
-
|
|
3706
|
-
|
|
3873
|
+
O as RyButtonGroup,
|
|
3874
|
+
Tt as RyCarousel,
|
|
3875
|
+
et as RyCode,
|
|
3876
|
+
gt as RyColorInput,
|
|
3877
|
+
pt as RyColorPicker,
|
|
3878
|
+
G as RyDrawer,
|
|
3707
3879
|
j as RyDropdown,
|
|
3708
3880
|
u as RyElement,
|
|
3709
|
-
|
|
3710
|
-
|
|
3711
|
-
|
|
3712
|
-
|
|
3713
|
-
|
|
3714
|
-
|
|
3715
|
-
|
|
3716
|
-
|
|
3881
|
+
st as RyExample,
|
|
3882
|
+
Mt as RyFeature,
|
|
3883
|
+
Et as RyFeatureGrid,
|
|
3884
|
+
U as RyField,
|
|
3885
|
+
mt as RyGradientPicker,
|
|
3886
|
+
xt as RyHero,
|
|
3887
|
+
it as RyIcon,
|
|
3888
|
+
lt as RyKnob,
|
|
3717
3889
|
P as RyModal,
|
|
3718
|
-
|
|
3719
|
-
|
|
3720
|
-
|
|
3721
|
-
|
|
3722
|
-
|
|
3723
|
-
|
|
3724
|
-
|
|
3890
|
+
ct as RyNumberSelect,
|
|
3891
|
+
Ct as RyPricing,
|
|
3892
|
+
St as RyPricingCard,
|
|
3893
|
+
Q as RySelect,
|
|
3894
|
+
ht as RySlider,
|
|
3895
|
+
K as RySplit,
|
|
3896
|
+
_t as RyStat,
|
|
3897
|
+
W as RySwitch,
|
|
3725
3898
|
F as RyTabs,
|
|
3726
|
-
|
|
3727
|
-
|
|
3728
|
-
|
|
3899
|
+
wt as RyTag,
|
|
3900
|
+
$t as RyTagInput,
|
|
3901
|
+
q as RyThemeToggle,
|
|
3729
3902
|
f as RyToast,
|
|
3730
|
-
|
|
3731
|
-
|
|
3903
|
+
ot as RyToggleButton,
|
|
3904
|
+
X as RyTooltip,
|
|
3732
3905
|
k as RyTree,
|
|
3733
|
-
|
|
3906
|
+
kt as RyTreeItem,
|
|
3734
3907
|
p as getIcon,
|
|
3735
|
-
|
|
3736
|
-
|
|
3737
|
-
|
|
3738
|
-
|
|
3908
|
+
Ht as getIconNames,
|
|
3909
|
+
C as processTransforms,
|
|
3910
|
+
Dt as registerIcon,
|
|
3911
|
+
It as registerIcons,
|
|
3739
3912
|
M as transform
|
|
3740
3913
|
};
|
|
3741
3914
|
//# sourceMappingURL=ry-ui.js.map
|