@ryanhelsing/ry-ui 1.0.3 → 1.0.5
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 +489 -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-card.d.ts +17 -0
- package/dist/components/ry-card.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 +137 -2
- package/dist/css/ry-theme.css +137 -0
- package/dist/css/ry-tokens.css +8 -0
- package/dist/css/ry-ui.css +282 -2
- package/dist/ry-ui.d.ts +3 -0
- package/dist/ry-ui.d.ts.map +1 -1
- package/dist/ry-ui.js +601 -413
- 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 +55 -2
- 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,22 @@ 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 {
|
|
606
|
+
setup() {
|
|
607
|
+
this.hasAttribute("interactive") && (this.hasAttribute("tabindex") || this.setAttribute("tabindex", "0"), this.setAttribute("role", "link"), this.on(this, "click", this.#t), this.on(this, "keydown", this.#e));
|
|
608
|
+
}
|
|
609
|
+
#t = (t) => {
|
|
610
|
+
if (t.target.closest("a, button, ry-button")) return;
|
|
611
|
+
const s = this.getAttribute("href");
|
|
612
|
+
s && (window.location.href = s), this.emit("click", { originalEvent: t });
|
|
613
|
+
};
|
|
614
|
+
#e = (t) => {
|
|
615
|
+
(t.key === "Enter" || t.key === " ") && (t.preventDefault(), this.click());
|
|
616
|
+
};
|
|
617
|
+
}
|
|
618
|
+
customElements.define("ry-card", z);
|
|
619
|
+
class U extends u {
|
|
472
620
|
setup() {
|
|
473
621
|
this.#t();
|
|
474
622
|
const t = this.$("[close]");
|
|
@@ -488,26 +636,63 @@ class K extends u {
|
|
|
488
636
|
}, 200), this.emit("close");
|
|
489
637
|
}
|
|
490
638
|
}
|
|
491
|
-
customElements.define("ry-alert",
|
|
492
|
-
class
|
|
639
|
+
customElements.define("ry-alert", U);
|
|
640
|
+
class V extends u {
|
|
641
|
+
static get observedAttributes() {
|
|
642
|
+
return ["label", "error", "hint"];
|
|
643
|
+
}
|
|
493
644
|
setup() {
|
|
494
645
|
this.#t();
|
|
495
646
|
}
|
|
647
|
+
attributeChangedCallback(t, e, s) {
|
|
648
|
+
e !== s && (t === "error" ? this.#e(s) : t === "hint" ? this.#i(s) : t === "label" && this.#s(s));
|
|
649
|
+
}
|
|
496
650
|
#t() {
|
|
497
|
-
|
|
498
|
-
const t = this.getAttribute("label");
|
|
651
|
+
const t = this.$("input, textarea, select");
|
|
499
652
|
if (!t) return;
|
|
500
|
-
const e =
|
|
501
|
-
if (!
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
653
|
+
const e = t.id || `ry-field-${Math.random().toString(36).slice(2, 9)}`;
|
|
654
|
+
if (t.id = e, !this.$('[data-ry-target="label"]')) {
|
|
655
|
+
const a = this.getAttribute("label");
|
|
656
|
+
if (a) {
|
|
657
|
+
const n = document.createElement("label");
|
|
658
|
+
n.setAttribute("data-ry-target", "label"), n.className = "ry-label", n.setAttribute("for", e), n.textContent = a, this.insertBefore(n, t);
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
if (!this.$('[data-ry-target="error"]')) {
|
|
662
|
+
const a = document.createElement("div");
|
|
663
|
+
a.setAttribute("data-ry-target", "error"), a.className = "ry-field__error", a.setAttribute("role", "alert");
|
|
664
|
+
const n = this.getAttribute("error");
|
|
665
|
+
n && (a.textContent = n), t.insertAdjacentElement("afterend", a);
|
|
666
|
+
}
|
|
667
|
+
if (!this.$('[data-ry-target="hint"]')) {
|
|
668
|
+
const a = document.createElement("div");
|
|
669
|
+
a.setAttribute("data-ry-target", "hint"), a.className = "ry-field__hint";
|
|
670
|
+
const n = this.getAttribute("hint");
|
|
671
|
+
n && (a.textContent = n);
|
|
672
|
+
const o = this.$('[data-ry-target="error"]');
|
|
673
|
+
o ? o.insertAdjacentElement("afterend", a) : t.insertAdjacentElement("afterend", a);
|
|
674
|
+
}
|
|
675
|
+
const s = this.$('[data-ry-target="error"]'), i = this.$('[data-ry-target="hint"]'), r = [];
|
|
676
|
+
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(" "));
|
|
677
|
+
}
|
|
678
|
+
#e(t) {
|
|
679
|
+
const e = this.$('[data-ry-target="error"]');
|
|
680
|
+
e && (e.textContent = t ?? "");
|
|
681
|
+
const s = this.$("input, textarea, select");
|
|
682
|
+
s && (t ? s.setAttribute("aria-invalid", "true") : s.removeAttribute("aria-invalid"));
|
|
683
|
+
}
|
|
684
|
+
#i(t) {
|
|
685
|
+
const e = this.$('[data-ry-target="hint"]');
|
|
686
|
+
e && (e.textContent = t ?? "");
|
|
687
|
+
}
|
|
688
|
+
#s(t) {
|
|
689
|
+
const e = this.$('[data-ry-target="label"]');
|
|
690
|
+
e && (e.textContent = t ?? "");
|
|
506
691
|
}
|
|
507
692
|
}
|
|
508
|
-
customElements.define("ry-field",
|
|
509
|
-
let
|
|
510
|
-
class
|
|
693
|
+
customElements.define("ry-field", V);
|
|
694
|
+
let W = 0;
|
|
695
|
+
class Y extends u {
|
|
511
696
|
#t = null;
|
|
512
697
|
static observedAttributes = ["checked", "disabled"];
|
|
513
698
|
setup() {
|
|
@@ -515,7 +700,7 @@ class z extends u {
|
|
|
515
700
|
}
|
|
516
701
|
#e() {
|
|
517
702
|
if (this.$('[data-ry-target="track"]')) return;
|
|
518
|
-
const t = `ry-switch-${++
|
|
703
|
+
const t = `ry-switch-${++W}`, e = this.getAttribute("name") ?? "", s = this.hasAttribute("checked"), i = this.hasAttribute("disabled"), r = this.textContent?.trim() ?? "";
|
|
519
704
|
this.innerHTML = `
|
|
520
705
|
<label data-ry-target="wrapper" class="ry-switch__wrapper" for="${t}">
|
|
521
706
|
<input
|
|
@@ -560,16 +745,16 @@ class z extends u {
|
|
|
560
745
|
this.#t && (this.#t.value = t);
|
|
561
746
|
}
|
|
562
747
|
}
|
|
563
|
-
customElements.define("ry-switch",
|
|
564
|
-
let
|
|
565
|
-
class
|
|
748
|
+
customElements.define("ry-switch", Y);
|
|
749
|
+
let X = 0;
|
|
750
|
+
class G extends u {
|
|
566
751
|
#t = null;
|
|
567
752
|
#e = null;
|
|
568
753
|
#i = null;
|
|
569
754
|
setup() {
|
|
570
|
-
this.#i = `ry-tooltip-${++
|
|
755
|
+
this.#i = `ry-tooltip-${++X}`, this.#s();
|
|
571
756
|
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.#
|
|
757
|
+
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
758
|
}
|
|
574
759
|
#s() {
|
|
575
760
|
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 +771,15 @@ class Y extends u {
|
|
|
586
771
|
#o = () => {
|
|
587
772
|
this.#t && (clearTimeout(this.#t), this.#t = null), this.state = "closed";
|
|
588
773
|
};
|
|
589
|
-
#
|
|
774
|
+
#c = (t) => {
|
|
590
775
|
t.key === "Escape" && this.state === "open" && this.#o();
|
|
591
776
|
};
|
|
592
777
|
teardown() {
|
|
593
778
|
this.#t && clearTimeout(this.#t);
|
|
594
779
|
}
|
|
595
780
|
}
|
|
596
|
-
customElements.define("ry-tooltip",
|
|
597
|
-
class
|
|
781
|
+
customElements.define("ry-tooltip", G);
|
|
782
|
+
class J extends u {
|
|
598
783
|
#t = null;
|
|
599
784
|
#e = 0;
|
|
600
785
|
setup() {
|
|
@@ -639,8 +824,8 @@ class W extends u {
|
|
|
639
824
|
this.state === "open" ? this.close() : this.open();
|
|
640
825
|
}
|
|
641
826
|
}
|
|
642
|
-
customElements.define("ry-drawer",
|
|
643
|
-
const
|
|
827
|
+
customElements.define("ry-drawer", J);
|
|
828
|
+
const Z = 4e3;
|
|
644
829
|
class f extends u {
|
|
645
830
|
#t = null;
|
|
646
831
|
static observedAttributes = ["variant", "duration"];
|
|
@@ -670,7 +855,7 @@ class f extends u {
|
|
|
670
855
|
this.#s();
|
|
671
856
|
const t = this.$("[close]");
|
|
672
857
|
t && this.on(t, "click", () => this.dismiss());
|
|
673
|
-
const e = parseInt(this.getAttribute("duration") ?? String(
|
|
858
|
+
const e = parseInt(this.getAttribute("duration") ?? String(Z), 10);
|
|
674
859
|
e > 0 && (this.#t = setTimeout(() => this.dismiss(), e)), requestAnimationFrame(() => {
|
|
675
860
|
this.state = "visible";
|
|
676
861
|
});
|
|
@@ -776,17 +961,17 @@ const w = {
|
|
|
776
961
|
function p(h) {
|
|
777
962
|
return w[h] ?? "";
|
|
778
963
|
}
|
|
779
|
-
function
|
|
964
|
+
function It(h, t) {
|
|
780
965
|
w[h] = t;
|
|
781
966
|
}
|
|
782
|
-
function
|
|
967
|
+
function Ht(h) {
|
|
783
968
|
Object.assign(w, h);
|
|
784
969
|
}
|
|
785
|
-
function
|
|
970
|
+
function Bt() {
|
|
786
971
|
return Object.keys(w);
|
|
787
972
|
}
|
|
788
|
-
let
|
|
789
|
-
class
|
|
973
|
+
let Q = 0;
|
|
974
|
+
class tt extends u {
|
|
790
975
|
#t = null;
|
|
791
976
|
#e = -1;
|
|
792
977
|
#i = "";
|
|
@@ -799,12 +984,12 @@ class J extends u {
|
|
|
799
984
|
}
|
|
800
985
|
static observedAttributes = ["value", "disabled"];
|
|
801
986
|
setup() {
|
|
802
|
-
this.#t = `ry-select-${++
|
|
987
|
+
this.#t = `ry-select-${++Q}`, 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
988
|
const t = this.getAttribute("value");
|
|
804
989
|
if (t)
|
|
805
990
|
if (this.#a)
|
|
806
991
|
for (const e of t.split(",").map((s) => s.trim()).filter(Boolean))
|
|
807
|
-
this.#
|
|
992
|
+
this.#l(e);
|
|
808
993
|
else
|
|
809
994
|
this.value = t;
|
|
810
995
|
}
|
|
@@ -862,20 +1047,20 @@ class J extends u {
|
|
|
862
1047
|
`;
|
|
863
1048
|
this._options = t;
|
|
864
1049
|
}
|
|
865
|
-
#
|
|
1050
|
+
#c = (t) => {
|
|
866
1051
|
if (this.hasAttribute("disabled")) return;
|
|
867
1052
|
const e = t.target, s = e.closest('[data-ry-target="option"]');
|
|
868
1053
|
if (s instanceof HTMLElement && !s.hasAttribute("data-disabled")) {
|
|
869
1054
|
if (this.#a) {
|
|
870
1055
|
const r = s.dataset.value ?? "";
|
|
871
|
-
this.#
|
|
1056
|
+
this.#l(r);
|
|
872
1057
|
} else
|
|
873
1058
|
this.#$(s), this.close();
|
|
874
1059
|
return;
|
|
875
1060
|
}
|
|
876
1061
|
e.closest('[data-ry-target="trigger"]') && this.toggle();
|
|
877
1062
|
};
|
|
878
|
-
#
|
|
1063
|
+
#h = (t) => {
|
|
879
1064
|
if (this.hasAttribute("disabled")) return;
|
|
880
1065
|
const e = this.state === "open";
|
|
881
1066
|
switch (t.key) {
|
|
@@ -886,7 +1071,7 @@ class J extends u {
|
|
|
886
1071
|
if (i)
|
|
887
1072
|
if (this.#a) {
|
|
888
1073
|
const r = i.dataset.value ?? "";
|
|
889
|
-
this.#
|
|
1074
|
+
this.#l(r);
|
|
890
1075
|
} else
|
|
891
1076
|
this.#$(i), this.close();
|
|
892
1077
|
} else
|
|
@@ -896,13 +1081,13 @@ class J extends u {
|
|
|
896
1081
|
e && (t.preventDefault(), this.close());
|
|
897
1082
|
break;
|
|
898
1083
|
case "ArrowDown":
|
|
899
|
-
t.preventDefault(), e ? this.#
|
|
1084
|
+
t.preventDefault(), e ? this.#m() : this.open();
|
|
900
1085
|
break;
|
|
901
1086
|
case "ArrowUp":
|
|
902
1087
|
t.preventDefault(), e && this.#b();
|
|
903
1088
|
break;
|
|
904
1089
|
case "Home":
|
|
905
|
-
e && (t.preventDefault(), this.#
|
|
1090
|
+
e && (t.preventDefault(), this.#k());
|
|
906
1091
|
break;
|
|
907
1092
|
case "End":
|
|
908
1093
|
e && (t.preventDefault(), this.#g());
|
|
@@ -910,7 +1095,7 @@ class J extends u {
|
|
|
910
1095
|
case "Backspace":
|
|
911
1096
|
if (this.#a && this.#r.size > 0) {
|
|
912
1097
|
const s = [...this.#r], i = s[s.length - 1];
|
|
913
|
-
i && this.#
|
|
1098
|
+
i && this.#l(i);
|
|
914
1099
|
}
|
|
915
1100
|
break;
|
|
916
1101
|
default:
|
|
@@ -918,13 +1103,13 @@ class J extends u {
|
|
|
918
1103
|
break;
|
|
919
1104
|
}
|
|
920
1105
|
};
|
|
921
|
-
#
|
|
1106
|
+
#d = (t) => {
|
|
922
1107
|
const e = t.target;
|
|
923
1108
|
!this.contains(e) && this.state === "open" && this.close();
|
|
924
1109
|
};
|
|
925
1110
|
#n = (t) => {
|
|
926
1111
|
const e = t.detail.value;
|
|
927
|
-
this.#r.has(e) && this.#
|
|
1112
|
+
this.#r.has(e) && this.#l(e);
|
|
928
1113
|
};
|
|
929
1114
|
#p(t) {
|
|
930
1115
|
this.#s && clearTimeout(this.#s), this.#i += t.toLowerCase();
|
|
@@ -955,7 +1140,7 @@ class J extends u {
|
|
|
955
1140
|
const i = this.$('[data-ry-target="trigger"]');
|
|
956
1141
|
i && i.setAttribute("aria-activedescendant", s.id);
|
|
957
1142
|
}
|
|
958
|
-
#
|
|
1143
|
+
#m() {
|
|
959
1144
|
const t = this.$$('[data-ry-target="option"]:not([data-disabled])'), e = Math.min(this.#e + 1, t.length - 1);
|
|
960
1145
|
this.#u(e);
|
|
961
1146
|
}
|
|
@@ -963,7 +1148,7 @@ class J extends u {
|
|
|
963
1148
|
const t = Math.max(this.#e - 1, 0);
|
|
964
1149
|
this.#u(t);
|
|
965
1150
|
}
|
|
966
|
-
#
|
|
1151
|
+
#k() {
|
|
967
1152
|
this.#u(0);
|
|
968
1153
|
}
|
|
969
1154
|
#g() {
|
|
@@ -971,7 +1156,7 @@ class J extends u {
|
|
|
971
1156
|
this.#u(t.length - 1);
|
|
972
1157
|
}
|
|
973
1158
|
// --- Multi-select methods ---
|
|
974
|
-
#
|
|
1159
|
+
#l(t) {
|
|
975
1160
|
const e = this.getAttribute("max-selections");
|
|
976
1161
|
if (this.#r.has(t))
|
|
977
1162
|
this.#r.delete(t);
|
|
@@ -979,9 +1164,9 @@ class J extends u {
|
|
|
979
1164
|
if (e && this.#r.size >= parseInt(e, 10)) return;
|
|
980
1165
|
this.#r.add(t);
|
|
981
1166
|
}
|
|
982
|
-
this.#
|
|
1167
|
+
this.#f(), this.#v(), this.#y(), this.setAttribute("value", [...this.#r].join(",")), this.emit("change", { value: this.value, label: "" });
|
|
983
1168
|
}
|
|
984
|
-
#
|
|
1169
|
+
#f() {
|
|
985
1170
|
const t = this.$('[data-ry-target="tags"]'), e = this.$('[data-ry-target="value"]');
|
|
986
1171
|
if (t) {
|
|
987
1172
|
t.innerHTML = "";
|
|
@@ -994,20 +1179,20 @@ class J extends u {
|
|
|
994
1179
|
e && (this.#r.size > 0 ? e.style.display = "none" : e.style.display = "");
|
|
995
1180
|
}
|
|
996
1181
|
}
|
|
997
|
-
#
|
|
1182
|
+
#v() {
|
|
998
1183
|
const t = this.$('[data-ry-target="native"]');
|
|
999
1184
|
if (t)
|
|
1000
1185
|
for (const e of t.options)
|
|
1001
1186
|
e.selected = this.#r.has(e.value);
|
|
1002
1187
|
}
|
|
1003
|
-
#
|
|
1188
|
+
#y() {
|
|
1004
1189
|
this.$$('[data-ry-target="option"]').forEach((t) => {
|
|
1005
1190
|
const e = t.dataset.value ?? "";
|
|
1006
1191
|
this.#r.has(e) ? t.setAttribute("aria-selected", "true") : t.removeAttribute("aria-selected");
|
|
1007
1192
|
});
|
|
1008
1193
|
}
|
|
1009
1194
|
#M() {
|
|
1010
|
-
this.#r.clear(), this.#
|
|
1195
|
+
this.#r.clear(), this.#f(), this.#v(), this.#y(), this.setAttribute("value", ""), this.emit("change", { value: "", label: "" });
|
|
1011
1196
|
}
|
|
1012
1197
|
// --- Single-select method ---
|
|
1013
1198
|
#$(t) {
|
|
@@ -1022,7 +1207,7 @@ class J extends u {
|
|
|
1022
1207
|
if (this.state === "open") return;
|
|
1023
1208
|
this.state = "open";
|
|
1024
1209
|
const t = this.$('[data-ry-target="trigger"]');
|
|
1025
|
-
if (t && t.setAttribute("aria-expanded", "true"), this.#
|
|
1210
|
+
if (t && t.setAttribute("aria-expanded", "true"), this.#I(), this.#a)
|
|
1026
1211
|
this.#u(0);
|
|
1027
1212
|
else {
|
|
1028
1213
|
const e = this.getAttribute("value");
|
|
@@ -1034,7 +1219,7 @@ class J extends u {
|
|
|
1034
1219
|
}
|
|
1035
1220
|
this.emit("open");
|
|
1036
1221
|
}
|
|
1037
|
-
#
|
|
1222
|
+
#I() {
|
|
1038
1223
|
const t = this.$('[data-ry-target="dropdown"]');
|
|
1039
1224
|
if (!t) return;
|
|
1040
1225
|
this.removeAttribute("data-ry-position");
|
|
@@ -1060,7 +1245,7 @@ class J extends u {
|
|
|
1060
1245
|
this.#r.clear();
|
|
1061
1246
|
for (const e of t.split(",").map((s) => s.trim()).filter(Boolean))
|
|
1062
1247
|
this.#r.add(e);
|
|
1063
|
-
this.#
|
|
1248
|
+
this.#f(), this.#v(), this.#y(), this.setAttribute("value", t);
|
|
1064
1249
|
} else {
|
|
1065
1250
|
const e = this.$(`[data-ry-target="option"][data-value="${t}"]`);
|
|
1066
1251
|
e && this.#$(e);
|
|
@@ -1073,11 +1258,11 @@ class J extends u {
|
|
|
1073
1258
|
this.#s && clearTimeout(this.#s);
|
|
1074
1259
|
}
|
|
1075
1260
|
}
|
|
1076
|
-
class
|
|
1261
|
+
class et extends HTMLElement {
|
|
1077
1262
|
}
|
|
1078
|
-
customElements.define("ry-option",
|
|
1079
|
-
customElements.define("ry-select",
|
|
1080
|
-
class
|
|
1263
|
+
customElements.define("ry-option", et);
|
|
1264
|
+
customElements.define("ry-select", tt);
|
|
1265
|
+
class st extends u {
|
|
1081
1266
|
#t = "";
|
|
1082
1267
|
static get observedAttributes() {
|
|
1083
1268
|
return ["language", "title", "line-numbers"];
|
|
@@ -1124,9 +1309,9 @@ class Q extends u {
|
|
|
1124
1309
|
case "html":
|
|
1125
1310
|
return this.#o(t);
|
|
1126
1311
|
case "json":
|
|
1127
|
-
return this.#
|
|
1312
|
+
return this.#c(t);
|
|
1128
1313
|
default:
|
|
1129
|
-
return this.#
|
|
1314
|
+
return this.#d(t);
|
|
1130
1315
|
}
|
|
1131
1316
|
}
|
|
1132
1317
|
#r(t) {
|
|
@@ -1189,7 +1374,7 @@ class Q extends u {
|
|
|
1189
1374
|
const b = s[0];
|
|
1190
1375
|
b && e.push({ type: "text", value: b }), s = s.slice(1);
|
|
1191
1376
|
}
|
|
1192
|
-
return e.map((i) => this.#
|
|
1377
|
+
return e.map((i) => this.#h(i)).join("");
|
|
1193
1378
|
}
|
|
1194
1379
|
#a(t) {
|
|
1195
1380
|
const e = [];
|
|
@@ -1243,7 +1428,7 @@ class Q extends u {
|
|
|
1243
1428
|
const c = s[0];
|
|
1244
1429
|
c && e.push({ type: "text", value: c }), s = s.slice(1);
|
|
1245
1430
|
}
|
|
1246
|
-
return e.map((r) => this.#
|
|
1431
|
+
return e.map((r) => this.#h(r)).join("");
|
|
1247
1432
|
}
|
|
1248
1433
|
#o(t) {
|
|
1249
1434
|
const e = [];
|
|
@@ -1289,9 +1474,9 @@ class Q extends u {
|
|
|
1289
1474
|
const l = s[0];
|
|
1290
1475
|
l && e.push({ type: "text", value: l }), s = s.slice(1);
|
|
1291
1476
|
}
|
|
1292
|
-
return e.map((i) => this.#
|
|
1477
|
+
return e.map((i) => this.#h(i)).join("");
|
|
1293
1478
|
}
|
|
1294
|
-
#
|
|
1479
|
+
#c(t) {
|
|
1295
1480
|
const e = [];
|
|
1296
1481
|
let s = t;
|
|
1297
1482
|
for (; s.length > 0; ) {
|
|
@@ -1323,10 +1508,10 @@ class Q extends u {
|
|
|
1323
1508
|
const l = s[0];
|
|
1324
1509
|
l && e.push({ type: "text", value: l }), s = s.slice(1);
|
|
1325
1510
|
}
|
|
1326
|
-
return e.map((i) => this.#
|
|
1511
|
+
return e.map((i) => this.#h(i)).join("");
|
|
1327
1512
|
}
|
|
1328
|
-
#
|
|
1329
|
-
const e = this.#
|
|
1513
|
+
#h(t) {
|
|
1514
|
+
const e = this.#d(t.value);
|
|
1330
1515
|
switch (t.type) {
|
|
1331
1516
|
case "keyword":
|
|
1332
1517
|
return `<span class="ry-code__keyword">${e}</span>`;
|
|
@@ -1354,7 +1539,7 @@ class Q extends u {
|
|
|
1354
1539
|
return e;
|
|
1355
1540
|
}
|
|
1356
1541
|
}
|
|
1357
|
-
#
|
|
1542
|
+
#d(t) {
|
|
1358
1543
|
return t.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
1359
1544
|
}
|
|
1360
1545
|
#n(t) {
|
|
@@ -1376,8 +1561,8 @@ class Q extends u {
|
|
|
1376
1561
|
this.#t = t, this.#e();
|
|
1377
1562
|
}
|
|
1378
1563
|
}
|
|
1379
|
-
customElements.define("ry-code",
|
|
1380
|
-
class
|
|
1564
|
+
customElements.define("ry-code", st);
|
|
1565
|
+
class it extends u {
|
|
1381
1566
|
setup() {
|
|
1382
1567
|
const t = this.$("template");
|
|
1383
1568
|
if (!t) return;
|
|
@@ -1421,8 +1606,8 @@ class tt extends u {
|
|
|
1421
1606
|
`).trim();
|
|
1422
1607
|
}
|
|
1423
1608
|
}
|
|
1424
|
-
customElements.define("ry-example",
|
|
1425
|
-
class
|
|
1609
|
+
customElements.define("ry-example", it);
|
|
1610
|
+
class rt extends u {
|
|
1426
1611
|
static get observedAttributes() {
|
|
1427
1612
|
return ["name", "size", "label"];
|
|
1428
1613
|
}
|
|
@@ -1455,24 +1640,24 @@ class et extends u {
|
|
|
1455
1640
|
this.setAttribute("size", String(t));
|
|
1456
1641
|
}
|
|
1457
1642
|
}
|
|
1458
|
-
customElements.define("ry-icon",
|
|
1459
|
-
const
|
|
1460
|
-
function
|
|
1643
|
+
customElements.define("ry-icon", rt);
|
|
1644
|
+
const at = ["form", "section", "fieldset", "ry-section"], m = /* @__PURE__ */ new Map(), E = /* @__PURE__ */ new Set();
|
|
1645
|
+
function nt(h) {
|
|
1461
1646
|
let t = h.parentElement;
|
|
1462
1647
|
for (; t; ) {
|
|
1463
|
-
if (
|
|
1648
|
+
if (at.some((e) => t.matches(e)))
|
|
1464
1649
|
return t;
|
|
1465
1650
|
t = t.parentElement;
|
|
1466
1651
|
}
|
|
1467
1652
|
return null;
|
|
1468
1653
|
}
|
|
1469
|
-
function
|
|
1470
|
-
if (
|
|
1654
|
+
function ot(h) {
|
|
1655
|
+
if (E.has(h)) return;
|
|
1471
1656
|
const t = m.get(h);
|
|
1472
1657
|
if (!t || t.size < 2) return;
|
|
1473
1658
|
const e = /* @__PURE__ */ new Map();
|
|
1474
1659
|
for (const s of t) {
|
|
1475
|
-
const i =
|
|
1660
|
+
const i = nt(s), r = e.get(i) ?? [];
|
|
1476
1661
|
r.push(s), e.set(i, r);
|
|
1477
1662
|
}
|
|
1478
1663
|
if (e.size > 1) {
|
|
@@ -1485,10 +1670,10 @@ function rt(h) {
|
|
|
1485
1670
|
s.push("(no container)");
|
|
1486
1671
|
console.warn(
|
|
1487
1672
|
`ry-toggle-button: Buttons with name="${h}" span multiple containers (${s.join(", ")}). Intentional?`
|
|
1488
|
-
),
|
|
1673
|
+
), E.add(h);
|
|
1489
1674
|
}
|
|
1490
1675
|
}
|
|
1491
|
-
class
|
|
1676
|
+
class ht extends u {
|
|
1492
1677
|
static observedAttributes = ["pressed", "disabled", "name", "value"];
|
|
1493
1678
|
#t = !1;
|
|
1494
1679
|
setup() {
|
|
@@ -1499,12 +1684,12 @@ class at extends u {
|
|
|
1499
1684
|
}
|
|
1500
1685
|
#e() {
|
|
1501
1686
|
const t = this.name;
|
|
1502
|
-
t && (m.has(t) || m.set(t, /* @__PURE__ */ new Set()), m.get(t).add(this), this.#t = !0, queueMicrotask(() =>
|
|
1687
|
+
t && (m.has(t) || m.set(t, /* @__PURE__ */ new Set()), m.get(t).add(this), this.#t = !0, queueMicrotask(() => ot(t)));
|
|
1503
1688
|
}
|
|
1504
1689
|
#i() {
|
|
1505
1690
|
if (!this.#t) return;
|
|
1506
1691
|
const t = this.name;
|
|
1507
|
-
t && m.has(t) && (m.get(t).delete(this), m.get(t).size === 0 && (m.delete(t),
|
|
1692
|
+
t && m.has(t) && (m.get(t).delete(this), m.get(t).size === 0 && (m.delete(t), E.delete(t))), this.#t = !1;
|
|
1508
1693
|
}
|
|
1509
1694
|
#s = (t) => {
|
|
1510
1695
|
if (this.disabled) {
|
|
@@ -1560,8 +1745,8 @@ class at extends u {
|
|
|
1560
1745
|
this.setAttribute("icon", t);
|
|
1561
1746
|
}
|
|
1562
1747
|
}
|
|
1563
|
-
customElements.define("ry-toggle-button",
|
|
1564
|
-
class
|
|
1748
|
+
customElements.define("ry-toggle-button", ht);
|
|
1749
|
+
class lt extends u {
|
|
1565
1750
|
#t = !1;
|
|
1566
1751
|
#e = null;
|
|
1567
1752
|
#i = null;
|
|
@@ -1570,7 +1755,7 @@ class nt extends u {
|
|
|
1570
1755
|
#a = /* @__PURE__ */ new Map();
|
|
1571
1756
|
static observedAttributes = ["min", "max", "step", "value", "start", "end", "disabled"];
|
|
1572
1757
|
setup() {
|
|
1573
|
-
this.#o(), this.#
|
|
1758
|
+
this.#o(), this.#h(), this.#f();
|
|
1574
1759
|
}
|
|
1575
1760
|
#o() {
|
|
1576
1761
|
const t = this.hasAttribute("range"), e = this.hasAttribute("labeled"), s = this.hasAttribute("tooltip");
|
|
@@ -1590,9 +1775,9 @@ class nt extends u {
|
|
|
1590
1775
|
<div data-ry-target="thumb-value" class="ry-slider__thumb" tabindex="0" role="slider" aria-label="Value">
|
|
1591
1776
|
${s ? '<span data-ry-target="tooltip-value" class="ry-slider__tooltip"></span>' : ""}
|
|
1592
1777
|
</div>
|
|
1593
|
-
`, i += "</div>", e && (i += this.#
|
|
1778
|
+
`, 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
1779
|
}
|
|
1595
|
-
#
|
|
1780
|
+
#c() {
|
|
1596
1781
|
const t = this.min, e = this.max, s = this.getAttribute("labels")?.split(","), i = this.getAttribute("label-type") || "number";
|
|
1597
1782
|
let r = [];
|
|
1598
1783
|
if (s)
|
|
@@ -1613,34 +1798,34 @@ class nt extends u {
|
|
|
1613
1798
|
</div>
|
|
1614
1799
|
`;
|
|
1615
1800
|
}
|
|
1616
|
-
#
|
|
1617
|
-
this.#i && this.on(this.#i, "pointerdown", this.#
|
|
1801
|
+
#h() {
|
|
1802
|
+
this.#i && this.on(this.#i, "pointerdown", this.#d);
|
|
1618
1803
|
for (const [t, e] of this.#r)
|
|
1619
|
-
this.on(e, "pointerdown", (s) => this.#n(s, t)), this.on(e, "keydown", (s) => this.#
|
|
1804
|
+
this.on(e, "pointerdown", (s) => this.#n(s, t)), this.on(e, "keydown", (s) => this.#m(s, t));
|
|
1620
1805
|
this.on(document, "pointermove", this.#p), this.on(document, "pointerup", this.#u);
|
|
1621
1806
|
}
|
|
1622
|
-
#
|
|
1807
|
+
#d = (t) => {
|
|
1623
1808
|
if (this.disabled) return;
|
|
1624
|
-
const e = this.#
|
|
1809
|
+
const e = this.#k(t);
|
|
1625
1810
|
if (this.hasAttribute("range")) {
|
|
1626
1811
|
const i = Math.abs(e - this.start), r = Math.abs(e - this.end);
|
|
1627
1812
|
i < r ? (this.start = e, this.#e = "start") : (this.end = e, this.#e = "end");
|
|
1628
1813
|
} else
|
|
1629
1814
|
this.value = e, this.#e = "value";
|
|
1630
|
-
this.#t = !0, this.#
|
|
1815
|
+
this.#t = !0, this.#f(), this.#y();
|
|
1631
1816
|
};
|
|
1632
1817
|
#n = (t, e) => {
|
|
1633
1818
|
this.disabled || (t.stopPropagation(), this.#t = !0, this.#e = e, t.target.setPointerCapture(t.pointerId));
|
|
1634
1819
|
};
|
|
1635
1820
|
#p = (t) => {
|
|
1636
1821
|
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.#
|
|
1822
|
+
const e = this.#k(t);
|
|
1823
|
+
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
1824
|
};
|
|
1640
1825
|
#u = () => {
|
|
1641
1826
|
this.#t && (this.#t = !1, this.#e = null, this.#M());
|
|
1642
1827
|
};
|
|
1643
|
-
#
|
|
1828
|
+
#m = (t, e) => {
|
|
1644
1829
|
if (this.disabled) return;
|
|
1645
1830
|
const s = this.step || 1, i = (this.max - this.min) / 10;
|
|
1646
1831
|
let r = 0;
|
|
@@ -1669,13 +1854,13 @@ class nt extends u {
|
|
|
1669
1854
|
return;
|
|
1670
1855
|
}
|
|
1671
1856
|
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.#
|
|
1857
|
+
const a = this.#l(this.#b(e) + r);
|
|
1858
|
+
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
1859
|
};
|
|
1675
1860
|
#b(t) {
|
|
1676
1861
|
return t === "start" ? this.start : t === "end" ? this.end : this.value;
|
|
1677
1862
|
}
|
|
1678
|
-
#
|
|
1863
|
+
#k(t) {
|
|
1679
1864
|
if (!this.#i) return this.min;
|
|
1680
1865
|
const e = this.#i.getBoundingClientRect(), s = this.hasAttribute("vertical"), i = this.hasAttribute("reversed");
|
|
1681
1866
|
let r;
|
|
@@ -1685,14 +1870,14 @@ class nt extends u {
|
|
|
1685
1870
|
}
|
|
1686
1871
|
#g(t) {
|
|
1687
1872
|
const e = this.step;
|
|
1688
|
-
if (e === 0) return this.#
|
|
1873
|
+
if (e === 0) return this.#l(t);
|
|
1689
1874
|
const s = Math.round((t - this.min) / e) * e + this.min;
|
|
1690
|
-
return this.#
|
|
1875
|
+
return this.#l(s);
|
|
1691
1876
|
}
|
|
1692
|
-
#
|
|
1877
|
+
#l(t) {
|
|
1693
1878
|
return Math.max(this.min, Math.min(this.max, t));
|
|
1694
1879
|
}
|
|
1695
|
-
#
|
|
1880
|
+
#f() {
|
|
1696
1881
|
const t = this.hasAttribute("range"), e = this.hasAttribute("vertical"), s = this.hasAttribute("reversed"), i = (r) => {
|
|
1697
1882
|
let a = (r - this.min) / (this.max - this.min) * 100;
|
|
1698
1883
|
return s && (a = 100 - a), a;
|
|
@@ -1701,22 +1886,22 @@ class nt extends u {
|
|
|
1701
1886
|
const r = i(this.start), a = i(this.end), n = Math.min(r, a), o = Math.max(r, a);
|
|
1702
1887
|
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
1888
|
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.#
|
|
1889
|
+
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
1890
|
} else {
|
|
1706
1891
|
const r = i(this.value);
|
|
1707
1892
|
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
1893
|
const a = this.#r.get("value");
|
|
1709
|
-
a && (e ? (a.style.bottom = `${r}%`, a.style.left = "") : (a.style.left = `${r}%`, a.style.bottom = "")), this.#
|
|
1894
|
+
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
1895
|
}
|
|
1711
1896
|
}
|
|
1712
|
-
#
|
|
1897
|
+
#v(t, e) {
|
|
1713
1898
|
const s = this.#a.get(t);
|
|
1714
1899
|
if (s) {
|
|
1715
1900
|
const i = this.step === 0 ? 2 : String(this.step).split(".")[1]?.length || 0;
|
|
1716
1901
|
s.textContent = e.toFixed(i);
|
|
1717
1902
|
}
|
|
1718
1903
|
}
|
|
1719
|
-
#
|
|
1904
|
+
#y() {
|
|
1720
1905
|
this.hasAttribute("range") ? this.emit("input", { start: this.start, end: this.end }) : this.emit("input", { value: this.value });
|
|
1721
1906
|
}
|
|
1722
1907
|
#M() {
|
|
@@ -1745,19 +1930,19 @@ class nt extends u {
|
|
|
1745
1930
|
return parseFloat(this.getAttribute("value") ?? String(this.min));
|
|
1746
1931
|
}
|
|
1747
1932
|
set value(t) {
|
|
1748
|
-
this.setAttribute("value", String(this.#
|
|
1933
|
+
this.setAttribute("value", String(this.#l(t)));
|
|
1749
1934
|
}
|
|
1750
1935
|
get start() {
|
|
1751
1936
|
return parseFloat(this.getAttribute("start") ?? String(this.min));
|
|
1752
1937
|
}
|
|
1753
1938
|
set start(t) {
|
|
1754
|
-
this.setAttribute("start", String(this.#
|
|
1939
|
+
this.setAttribute("start", String(this.#l(t)));
|
|
1755
1940
|
}
|
|
1756
1941
|
get end() {
|
|
1757
1942
|
return parseFloat(this.getAttribute("end") ?? String(this.max));
|
|
1758
1943
|
}
|
|
1759
1944
|
set end(t) {
|
|
1760
|
-
this.setAttribute("end", String(this.#
|
|
1945
|
+
this.setAttribute("end", String(this.#l(t)));
|
|
1761
1946
|
}
|
|
1762
1947
|
get disabled() {
|
|
1763
1948
|
return this.hasAttribute("disabled");
|
|
@@ -1766,8 +1951,8 @@ class nt extends u {
|
|
|
1766
1951
|
t ? this.setAttribute("disabled", "") : this.removeAttribute("disabled");
|
|
1767
1952
|
}
|
|
1768
1953
|
}
|
|
1769
|
-
customElements.define("ry-slider",
|
|
1770
|
-
class
|
|
1954
|
+
customElements.define("ry-slider", lt);
|
|
1955
|
+
class ct extends u {
|
|
1771
1956
|
#t = !1;
|
|
1772
1957
|
#e = 0;
|
|
1773
1958
|
#i = 0;
|
|
@@ -1776,7 +1961,7 @@ class ot extends u {
|
|
|
1776
1961
|
#a = null;
|
|
1777
1962
|
static observedAttributes = ["min", "max", "step", "value", "disabled", "label", "labels", "description"];
|
|
1778
1963
|
setup() {
|
|
1779
|
-
this.#o(), this.#
|
|
1964
|
+
this.#o(), this.#c(), this.#l();
|
|
1780
1965
|
}
|
|
1781
1966
|
#o() {
|
|
1782
1967
|
const t = this.getAttribute("label"), e = this.getAttribute("description"), s = e ? ` title="${e}"` : "";
|
|
@@ -1790,19 +1975,19 @@ class ot extends u {
|
|
|
1790
1975
|
${t ? `<span data-ry-target="label" class="ry-knob__label"${s}>${t}</span>` : ""}
|
|
1791
1976
|
`, this.#s = this.$('[data-ry-target="ring"]'), this.#r = this.$('[data-ry-target="indicator"]'), this.#a = this.$('[data-ry-target="display"]');
|
|
1792
1977
|
}
|
|
1793
|
-
#
|
|
1794
|
-
this.#s && (this.on(this.#s, "mousedown", this.#
|
|
1978
|
+
#c() {
|
|
1979
|
+
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
1980
|
}
|
|
1796
|
-
#
|
|
1981
|
+
#h = (t) => {
|
|
1797
1982
|
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
1983
|
};
|
|
1799
|
-
#
|
|
1984
|
+
#d = (t) => {
|
|
1800
1985
|
if (!this.#t) return;
|
|
1801
1986
|
const e = this.#e - t.clientY, s = (this.max - this.min) / 100;
|
|
1802
1987
|
this.#g(this.#i + e * s);
|
|
1803
1988
|
};
|
|
1804
1989
|
#n = () => {
|
|
1805
|
-
this.#t && (this.#t = !1, this.#s?.classList.remove("ry-knob__ring--dragging"), this.removeAttribute("data-dragging"), this.#
|
|
1990
|
+
this.#t && (this.#t = !1, this.#s?.classList.remove("ry-knob__ring--dragging"), this.removeAttribute("data-dragging"), this.#y());
|
|
1806
1991
|
};
|
|
1807
1992
|
#p = (t) => {
|
|
1808
1993
|
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 +2000,16 @@ class ot extends u {
|
|
|
1815
2000
|
const s = this.#e - e.clientY, i = (this.max - this.min) / 100;
|
|
1816
2001
|
this.#g(this.#i + s * i);
|
|
1817
2002
|
};
|
|
1818
|
-
#
|
|
1819
|
-
this.#t && (this.#t = !1, this.#s?.classList.remove("ry-knob__ring--dragging"), this.removeAttribute("data-dragging"), this.#
|
|
2003
|
+
#m = () => {
|
|
2004
|
+
this.#t && (this.#t = !1, this.#s?.classList.remove("ry-knob__ring--dragging"), this.removeAttribute("data-dragging"), this.#y());
|
|
1820
2005
|
};
|
|
1821
2006
|
#b = (t) => {
|
|
1822
2007
|
if (this.disabled) return;
|
|
1823
2008
|
t.preventDefault();
|
|
1824
2009
|
const e = this.step || (this.max - this.min) / 50, s = t.deltaY < 0 ? e : -e;
|
|
1825
|
-
this.#g(this.value + s), this.#
|
|
2010
|
+
this.#g(this.value + s), this.#y();
|
|
1826
2011
|
};
|
|
1827
|
-
#
|
|
2012
|
+
#k = (t) => {
|
|
1828
2013
|
if (this.disabled) return;
|
|
1829
2014
|
const e = this.step || 1, s = (this.max - this.min) / 10;
|
|
1830
2015
|
let i = 0;
|
|
@@ -1844,26 +2029,26 @@ class ot extends u {
|
|
|
1844
2029
|
i = -s;
|
|
1845
2030
|
break;
|
|
1846
2031
|
case "Home":
|
|
1847
|
-
this.#g(this.min), this.#
|
|
2032
|
+
this.#g(this.min), this.#y();
|
|
1848
2033
|
return;
|
|
1849
2034
|
case "End":
|
|
1850
|
-
this.#g(this.max), this.#
|
|
2035
|
+
this.#g(this.max), this.#y();
|
|
1851
2036
|
return;
|
|
1852
2037
|
default:
|
|
1853
2038
|
return;
|
|
1854
2039
|
}
|
|
1855
|
-
t.preventDefault(), this.#g(this.value + i), this.#
|
|
2040
|
+
t.preventDefault(), this.#g(this.value + i), this.#y();
|
|
1856
2041
|
};
|
|
1857
2042
|
#g(t) {
|
|
1858
2043
|
let e = Math.max(this.min, Math.min(this.max, t));
|
|
1859
2044
|
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.#
|
|
2045
|
+
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
2046
|
}
|
|
1862
|
-
#
|
|
2047
|
+
#l() {
|
|
1863
2048
|
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.#
|
|
2049
|
+
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
2050
|
}
|
|
1866
|
-
#
|
|
2051
|
+
#f(t) {
|
|
1867
2052
|
const e = this.getAttribute("labels");
|
|
1868
2053
|
if (e) {
|
|
1869
2054
|
const i = e.split(","), r = Math.round(t);
|
|
@@ -1871,16 +2056,16 @@ class ot extends u {
|
|
|
1871
2056
|
}
|
|
1872
2057
|
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
2058
|
}
|
|
1874
|
-
#
|
|
2059
|
+
#v() {
|
|
1875
2060
|
const t = (this.value - this.min) / (this.max - this.min);
|
|
1876
2061
|
this.emit("input", { value: this.value, percent: t });
|
|
1877
2062
|
}
|
|
1878
|
-
#
|
|
2063
|
+
#y() {
|
|
1879
2064
|
const t = (this.value - this.min) / (this.max - this.min);
|
|
1880
2065
|
this.emit("change", { value: this.value, percent: t });
|
|
1881
2066
|
}
|
|
1882
2067
|
attributeChangedCallback(t, e, s) {
|
|
1883
|
-
e !== s && t === "value" && this.#s && this.#
|
|
2068
|
+
e !== s && t === "value" && this.#s && this.#l();
|
|
1884
2069
|
}
|
|
1885
2070
|
// --- Public API ---
|
|
1886
2071
|
get min() {
|
|
@@ -1914,9 +2099,9 @@ class ot extends u {
|
|
|
1914
2099
|
t ? this.setAttribute("disabled", "") : this.removeAttribute("disabled");
|
|
1915
2100
|
}
|
|
1916
2101
|
}
|
|
1917
|
-
customElements.define("ry-knob",
|
|
2102
|
+
customElements.define("ry-knob", ct);
|
|
1918
2103
|
const S = 15, T = 3;
|
|
1919
|
-
class
|
|
2104
|
+
class dt extends u {
|
|
1920
2105
|
#t = null;
|
|
1921
2106
|
#e = null;
|
|
1922
2107
|
#i = null;
|
|
@@ -1924,17 +2109,17 @@ class ht extends u {
|
|
|
1924
2109
|
#r = null;
|
|
1925
2110
|
#a = !1;
|
|
1926
2111
|
#o = 0;
|
|
1927
|
-
#l = 0;
|
|
1928
2112
|
#c = 0;
|
|
1929
|
-
#h =
|
|
2113
|
+
#h = 0;
|
|
2114
|
+
#d = !1;
|
|
1930
2115
|
#n = null;
|
|
1931
2116
|
#p = null;
|
|
1932
2117
|
static observedAttributes = ["min", "max", "step", "value", "disabled", "arrows", "icons", "drag", "editable", "wrap", "label", "prefix", "suffix"];
|
|
1933
2118
|
setup() {
|
|
1934
|
-
this.#u(), this.#b(), this.#
|
|
2119
|
+
this.#u(), this.#b(), this.#k(), this.#A();
|
|
1935
2120
|
}
|
|
1936
2121
|
#u() {
|
|
1937
|
-
const t = this.getAttribute("arrows") ?? "both", e = this.getAttribute("label"), s = t === "stacked" || t === "stacked-end" || t === "stacked-start", [i, r] = this.#
|
|
2122
|
+
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
2123
|
<div data-ry-target="display" class="ry-number-select__display" tabindex="0" role="spinbutton"
|
|
1939
2124
|
aria-valuenow="${this.value}" aria-valuemin="${this.min}" aria-valuemax="${this.max}"
|
|
1940
2125
|
${e ? `aria-label="${e}"` : ""}>
|
|
@@ -1954,20 +2139,20 @@ class ht extends u {
|
|
|
1954
2139
|
} else
|
|
1955
2140
|
this.innerHTML = `${c}${g}${d}${b}`;
|
|
1956
2141
|
}
|
|
1957
|
-
#
|
|
2142
|
+
#m(t) {
|
|
1958
2143
|
const e = this.getAttribute("icons") ?? "plus-minus";
|
|
1959
2144
|
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
2145
|
}
|
|
1961
2146
|
#b() {
|
|
1962
2147
|
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
2148
|
}
|
|
1964
|
-
#
|
|
2149
|
+
#k() {
|
|
1965
2150
|
this.#s && (this.on(this.#s, "mousedown", (t) => {
|
|
1966
2151
|
t.preventDefault(), this.#g(-1);
|
|
1967
|
-
}), this.on(this.#s, "mouseup", () => this.#
|
|
2152
|
+
}), this.on(this.#s, "mouseup", () => this.#l()), this.on(this.#s, "mouseleave", () => this.#l())), this.#r && (this.on(this.#r, "mousedown", (t) => {
|
|
1968
2153
|
t.preventDefault(), this.#g(1);
|
|
1969
|
-
}), this.on(this.#r, "mouseup", () => this.#
|
|
1970
|
-
t.key === "Enter" && (t.preventDefault(), this.#
|
|
2154
|
+
}), 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) => {
|
|
2155
|
+
t.key === "Enter" && (t.preventDefault(), this.#z()), t.key === "Escape" && (t.preventDefault(), this.#P()), t.stopPropagation();
|
|
1971
2156
|
}));
|
|
1972
2157
|
}
|
|
1973
2158
|
// --- Button hold-to-repeat ---
|
|
@@ -1982,48 +2167,48 @@ class ht extends u {
|
|
|
1982
2167
|
i();
|
|
1983
2168
|
}, 400);
|
|
1984
2169
|
}
|
|
1985
|
-
#
|
|
2170
|
+
#l() {
|
|
1986
2171
|
this.#n && (clearTimeout(this.#n), this.#n = null), this.#p && (clearTimeout(this.#p), this.#p = null);
|
|
1987
2172
|
}
|
|
1988
2173
|
// --- Drag helpers ---
|
|
1989
|
-
get #
|
|
2174
|
+
get #f() {
|
|
1990
2175
|
const t = this.getAttribute("drag");
|
|
1991
2176
|
if (t === "x" || t === "y" || t === "none") return t;
|
|
1992
2177
|
const e = this.getAttribute("arrows");
|
|
1993
2178
|
return e === "stacked" || e === "stacked-end" || e === "stacked-start" ? "y" : "x";
|
|
1994
2179
|
}
|
|
1995
|
-
#
|
|
1996
|
-
return this.#
|
|
2180
|
+
#v(t, e) {
|
|
2181
|
+
return this.#f === "y" ? this.#c - e : t - this.#o;
|
|
1997
2182
|
}
|
|
1998
|
-
#
|
|
1999
|
-
return this.#
|
|
2183
|
+
#y(t, e) {
|
|
2184
|
+
return this.#f === "y" ? Math.abs(e - this.#c) : Math.abs(t - this.#o);
|
|
2000
2185
|
}
|
|
2001
2186
|
#M(t, e) {
|
|
2002
2187
|
if (!this.#e) return;
|
|
2003
|
-
const s = t / e * 4, i = this.#
|
|
2188
|
+
const s = t / e * 4, i = this.#f;
|
|
2004
2189
|
this.#e.style.transform = i === "y" ? `translateY(${-s}px)` : `translateX(${s}px)`;
|
|
2005
2190
|
}
|
|
2006
2191
|
#$(t, e, s) {
|
|
2007
|
-
const i = this.#
|
|
2192
|
+
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
2193
|
this.#M(c, n);
|
|
2009
|
-
const d = this.hasAttribute("wrap") ? this.#
|
|
2194
|
+
const d = this.hasAttribute("wrap") ? this.#U(l) : this.#T(l), g = this.#F(d);
|
|
2010
2195
|
g !== this.value && (this.value = g, this.#A(), this.#x());
|
|
2011
2196
|
}
|
|
2012
2197
|
// --- Mouse drag ---
|
|
2013
|
-
#
|
|
2014
|
-
this.disabled || this.#
|
|
2198
|
+
#I = (t) => {
|
|
2199
|
+
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
2200
|
};
|
|
2016
|
-
#
|
|
2201
|
+
#Y = (t) => {
|
|
2017
2202
|
this.#a && this.#$(t.clientX, t.clientY, t.shiftKey);
|
|
2018
2203
|
};
|
|
2019
|
-
#
|
|
2204
|
+
#C = (t) => {
|
|
2020
2205
|
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.#
|
|
2206
|
+
const e = this.#y(t.clientX, t.clientY);
|
|
2207
|
+
this.#a = !1, this.removeAttribute("data-dragging"), this.#e && (this.#e.style.transform = ""), e < T && this.hasAttribute("editable") ? this.#E() : e >= T && this.#_();
|
|
2023
2208
|
};
|
|
2024
2209
|
// --- Touch drag ---
|
|
2025
2210
|
#X = (t) => {
|
|
2026
|
-
this.disabled || this.#
|
|
2211
|
+
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
2212
|
};
|
|
2028
2213
|
#G = (t) => {
|
|
2029
2214
|
if (!this.#a) return;
|
|
@@ -2036,7 +2221,7 @@ class ht extends u {
|
|
|
2036
2221
|
};
|
|
2037
2222
|
// --- Keyboard ---
|
|
2038
2223
|
#q = (t) => {
|
|
2039
|
-
if (this.disabled || this.#
|
|
2224
|
+
if (this.disabled || this.#d) return;
|
|
2040
2225
|
const e = this.step || 1, s = e * 10;
|
|
2041
2226
|
let i = 0;
|
|
2042
2227
|
switch (t.key) {
|
|
@@ -2061,28 +2246,28 @@ class ht extends u {
|
|
|
2061
2246
|
i = this.max - this.value;
|
|
2062
2247
|
break;
|
|
2063
2248
|
case "Enter":
|
|
2064
|
-
this.hasAttribute("editable") && this.#
|
|
2249
|
+
this.hasAttribute("editable") && this.#E();
|
|
2065
2250
|
return;
|
|
2066
2251
|
default:
|
|
2067
|
-
this.hasAttribute("editable") && /^[0-9.\-]$/.test(t.key) && (this.#
|
|
2252
|
+
this.hasAttribute("editable") && /^[0-9.\-]$/.test(t.key) && (this.#E(t.key), t.preventDefault());
|
|
2068
2253
|
return;
|
|
2069
2254
|
}
|
|
2070
2255
|
t.preventDefault(), this.#R(i), this.#x(), this.#_();
|
|
2071
2256
|
};
|
|
2072
2257
|
// --- Wheel ---
|
|
2073
2258
|
#J = (t) => {
|
|
2074
|
-
if (this.disabled || this.#
|
|
2259
|
+
if (this.disabled || this.#d || !this.matches(":hover") && !this.contains(document.activeElement)) return;
|
|
2075
2260
|
t.preventDefault();
|
|
2076
2261
|
const e = this.step || 1, s = t.shiftKey ? e * 10 : e, i = t.deltaY < 0 ? s : -s;
|
|
2077
2262
|
this.#R(i), this.#x(), this.#_();
|
|
2078
2263
|
};
|
|
2079
2264
|
// --- Edit mode ---
|
|
2080
|
-
#
|
|
2081
|
-
this.disabled || this.#
|
|
2265
|
+
#E(t) {
|
|
2266
|
+
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
2267
|
}
|
|
2083
|
-
#
|
|
2084
|
-
if (!this.#
|
|
2085
|
-
this.#
|
|
2268
|
+
#z() {
|
|
2269
|
+
if (!this.#d) return;
|
|
2270
|
+
this.#d = !1, this.state = "";
|
|
2086
2271
|
const t = parseFloat(this.#i?.value ?? "");
|
|
2087
2272
|
if (!isNaN(t)) {
|
|
2088
2273
|
const e = this.#T(t), s = this.#F(e);
|
|
@@ -2091,17 +2276,17 @@ class ht extends u {
|
|
|
2091
2276
|
this.#e && (this.#e.style.display = ""), this.#i && (this.#i.style.display = "none"), this.#A(), this.#t?.focus();
|
|
2092
2277
|
}
|
|
2093
2278
|
#P() {
|
|
2094
|
-
this.#
|
|
2279
|
+
this.#d && (this.#d = !1, this.state = "", this.#e && (this.#e.style.display = ""), this.#i && (this.#i.style.display = "none"), this.#t?.focus());
|
|
2095
2280
|
}
|
|
2096
2281
|
// --- Value management ---
|
|
2097
2282
|
#R(t) {
|
|
2098
2283
|
let e = this.value + t;
|
|
2099
|
-
this.hasAttribute("wrap") ? e = this.#
|
|
2284
|
+
this.hasAttribute("wrap") ? e = this.#U(e) : e = this.#T(e), e = this.#F(e), this.value = e, this.#A();
|
|
2100
2285
|
}
|
|
2101
2286
|
#T(t) {
|
|
2102
2287
|
return Math.max(this.min, Math.min(this.max, t));
|
|
2103
2288
|
}
|
|
2104
|
-
#
|
|
2289
|
+
#U(t) {
|
|
2105
2290
|
const e = this.step || 1, s = this.max - this.min + e;
|
|
2106
2291
|
let i = t;
|
|
2107
2292
|
for (; i > this.max; ) i -= s;
|
|
@@ -2121,9 +2306,9 @@ class ht extends u {
|
|
|
2121
2306
|
return t.toFixed(s);
|
|
2122
2307
|
}
|
|
2123
2308
|
#A() {
|
|
2124
|
-
this.#e && (this.#e.textContent = this.#j(this.value)), this.#
|
|
2309
|
+
this.#e && (this.#e.textContent = this.#j(this.value)), this.#V();
|
|
2125
2310
|
}
|
|
2126
|
-
#
|
|
2311
|
+
#V() {
|
|
2127
2312
|
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
2313
|
}
|
|
2129
2314
|
#x() {
|
|
@@ -2158,7 +2343,7 @@ class ht extends u {
|
|
|
2158
2343
|
this.setAttribute("step", String(t));
|
|
2159
2344
|
}
|
|
2160
2345
|
get drag() {
|
|
2161
|
-
return this.#
|
|
2346
|
+
return this.#f;
|
|
2162
2347
|
}
|
|
2163
2348
|
set drag(t) {
|
|
2164
2349
|
this.setAttribute("drag", t);
|
|
@@ -2173,10 +2358,10 @@ class ht extends u {
|
|
|
2173
2358
|
e !== s && t === "value" && this.#t && this.#A();
|
|
2174
2359
|
}
|
|
2175
2360
|
teardown() {
|
|
2176
|
-
this.#
|
|
2361
|
+
this.#l();
|
|
2177
2362
|
}
|
|
2178
2363
|
}
|
|
2179
|
-
customElements.define("ry-number-select",
|
|
2364
|
+
customElements.define("ry-number-select", dt);
|
|
2180
2365
|
function v(h) {
|
|
2181
2366
|
const t = h.h / 360, e = h.s / 100, s = h.v / 100;
|
|
2182
2367
|
let i = 0, r = 0, a = 0;
|
|
@@ -2237,7 +2422,7 @@ function L(h) {
|
|
|
2237
2422
|
l: Math.round(s * 100)
|
|
2238
2423
|
};
|
|
2239
2424
|
}
|
|
2240
|
-
function
|
|
2425
|
+
function ut(h) {
|
|
2241
2426
|
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
2427
|
return {
|
|
2243
2428
|
h: h.h,
|
|
@@ -2245,11 +2430,11 @@ function lt(h) {
|
|
|
2245
2430
|
v: Math.round(s * 100)
|
|
2246
2431
|
};
|
|
2247
2432
|
}
|
|
2248
|
-
function
|
|
2433
|
+
function D(h) {
|
|
2249
2434
|
const t = (e) => e.toString(16).padStart(2, "0");
|
|
2250
2435
|
return `#${t(h.r)}${t(h.g)}${t(h.b)}`;
|
|
2251
2436
|
}
|
|
2252
|
-
function
|
|
2437
|
+
function pt(h) {
|
|
2253
2438
|
const t = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(h);
|
|
2254
2439
|
if (!t) {
|
|
2255
2440
|
const e = /^#?([a-f\d])([a-f\d])([a-f\d])$/i.exec(h);
|
|
@@ -2277,7 +2462,7 @@ function A(h) {
|
|
|
2277
2462
|
}, n = parseInt(i[4], 16) / 255;
|
|
2278
2463
|
return { hsv: $(a), alpha: Math.round(n * 100) };
|
|
2279
2464
|
}
|
|
2280
|
-
const r =
|
|
2465
|
+
const r = pt(t);
|
|
2281
2466
|
return r ? { hsv: $(r), alpha: 100 } : null;
|
|
2282
2467
|
}
|
|
2283
2468
|
const e = /^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d.]+))?\s*\)$/.exec(t);
|
|
@@ -2296,11 +2481,11 @@ function A(h) {
|
|
|
2296
2481
|
s: parseFloat(s[2]),
|
|
2297
2482
|
l: parseFloat(s[3])
|
|
2298
2483
|
}, r = s[4] ? parseFloat(s[4]) * 100 : 100;
|
|
2299
|
-
return { hsv:
|
|
2484
|
+
return { hsv: ut(i), alpha: r };
|
|
2300
2485
|
}
|
|
2301
2486
|
return null;
|
|
2302
2487
|
}
|
|
2303
|
-
class
|
|
2488
|
+
class gt extends u {
|
|
2304
2489
|
#t = 0;
|
|
2305
2490
|
#e = 100;
|
|
2306
2491
|
#i = 100;
|
|
@@ -2308,21 +2493,21 @@ class dt extends u {
|
|
|
2308
2493
|
#r = !1;
|
|
2309
2494
|
#a = !1;
|
|
2310
2495
|
#o = !1;
|
|
2311
|
-
#l = null;
|
|
2312
2496
|
#c = null;
|
|
2313
2497
|
#h = null;
|
|
2498
|
+
#d = null;
|
|
2314
2499
|
#n = null;
|
|
2315
2500
|
#p = null;
|
|
2316
2501
|
#u = null;
|
|
2317
|
-
#
|
|
2502
|
+
#m = null;
|
|
2318
2503
|
#b = null;
|
|
2319
|
-
#
|
|
2504
|
+
#k = null;
|
|
2320
2505
|
#g = null;
|
|
2321
2506
|
static observedAttributes = ["value", "format", "opacity", "disabled", "swatches", "inline"];
|
|
2322
2507
|
setup() {
|
|
2323
|
-
this.#
|
|
2508
|
+
this.#l(), this.#f(), this.#v(), this.#A();
|
|
2324
2509
|
}
|
|
2325
|
-
#
|
|
2510
|
+
#l() {
|
|
2326
2511
|
const t = this.hasAttribute("inline"), e = this.hasAttribute("opacity"), s = this.getAttribute("swatches");
|
|
2327
2512
|
let i = `
|
|
2328
2513
|
<div data-ry-target="grid" class="ry-color-picker__grid">
|
|
@@ -2362,16 +2547,16 @@ class dt extends u {
|
|
|
2362
2547
|
<span data-ry-target="trigger-color" class="ry-color-picker__trigger-color"></span>
|
|
2363
2548
|
</button>
|
|
2364
2549
|
<div data-ry-target="panel" class="ry-color-picker__panel">${i}</div>
|
|
2365
|
-
`, this.#
|
|
2550
|
+
`, 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
2551
|
}
|
|
2367
|
-
#
|
|
2368
|
-
this.#
|
|
2552
|
+
#f() {
|
|
2553
|
+
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
2554
|
const t = this.$('[data-ry-target="format-toggle"]');
|
|
2370
2555
|
t && this.on(t, "click", this.#F);
|
|
2371
2556
|
const e = this.$('[data-ry-target="swatches"]');
|
|
2372
2557
|
e && this.on(e, "click", this.#j);
|
|
2373
2558
|
}
|
|
2374
|
-
#
|
|
2559
|
+
#v() {
|
|
2375
2560
|
const t = this.getAttribute("value");
|
|
2376
2561
|
if (t) {
|
|
2377
2562
|
const e = A(t);
|
|
@@ -2381,35 +2566,35 @@ class dt extends u {
|
|
|
2381
2566
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2382
2567
|
// Dropdown handlers
|
|
2383
2568
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2384
|
-
#
|
|
2569
|
+
#y = () => {
|
|
2385
2570
|
this.disabled || (this.state === "open" ? this.close() : this.open());
|
|
2386
2571
|
};
|
|
2387
2572
|
#M = (t) => {
|
|
2388
2573
|
this.state === "open" && (this.contains(t.target) || this.close());
|
|
2389
2574
|
};
|
|
2390
2575
|
#$ = (t) => {
|
|
2391
|
-
t.key === "Escape" && this.state === "open" && (this.close(), this.#
|
|
2576
|
+
t.key === "Escape" && this.state === "open" && (this.close(), this.#c?.focus());
|
|
2392
2577
|
};
|
|
2393
2578
|
open() {
|
|
2394
|
-
this.hasAttribute("inline") || (this.#
|
|
2579
|
+
this.hasAttribute("inline") || (this.#I(), this.state = "open");
|
|
2395
2580
|
}
|
|
2396
2581
|
close() {
|
|
2397
2582
|
this.hasAttribute("inline") || (this.state = "closed", this.removeAttribute("data-ry-position"));
|
|
2398
2583
|
}
|
|
2399
|
-
#
|
|
2400
|
-
if (!this.#
|
|
2401
|
-
const t = this.#
|
|
2584
|
+
#I() {
|
|
2585
|
+
if (!this.#h || !this.#c) return;
|
|
2586
|
+
const t = this.#c.getBoundingClientRect(), e = 320, i = window.innerHeight - t.bottom, r = t.top;
|
|
2402
2587
|
i < e && r > i ? this.setAttribute("data-ry-position", "top") : this.setAttribute("data-ry-position", "bottom");
|
|
2403
2588
|
}
|
|
2404
2589
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2405
2590
|
// Grid handlers
|
|
2406
2591
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2407
|
-
#
|
|
2408
|
-
this.disabled || (t.preventDefault(), this.#r = !0, this.#n?.focus(), this.#
|
|
2592
|
+
#Y = (t) => {
|
|
2593
|
+
this.disabled || (t.preventDefault(), this.#r = !0, this.#n?.focus(), this.#C(t));
|
|
2409
2594
|
};
|
|
2410
|
-
#
|
|
2411
|
-
if (!this.#
|
|
2412
|
-
const e = this.#
|
|
2595
|
+
#C(t) {
|
|
2596
|
+
if (!this.#d) return;
|
|
2597
|
+
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
2598
|
this.#e = Math.round(s * 100), this.#i = Math.round((1 - i) * 100), this.#A(), this.#L();
|
|
2414
2599
|
}
|
|
2415
2600
|
#X = (t) => {
|
|
@@ -2430,7 +2615,7 @@ class dt extends u {
|
|
|
2430
2615
|
this.#i = Math.max(0, this.#i - e), s = !0;
|
|
2431
2616
|
break;
|
|
2432
2617
|
}
|
|
2433
|
-
s && (t.preventDefault(), this.#A(), this.#L(), this.#
|
|
2618
|
+
s && (t.preventDefault(), this.#A(), this.#L(), this.#w());
|
|
2434
2619
|
};
|
|
2435
2620
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2436
2621
|
// Hue handlers
|
|
@@ -2457,20 +2642,20 @@ class dt extends u {
|
|
|
2457
2642
|
this.#t = (this.#t - e + 360) % 360, s = !0;
|
|
2458
2643
|
break;
|
|
2459
2644
|
}
|
|
2460
|
-
s && (t.preventDefault(), this.#A(), this.#L(), this.#
|
|
2645
|
+
s && (t.preventDefault(), this.#A(), this.#L(), this.#w());
|
|
2461
2646
|
};
|
|
2462
2647
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2463
2648
|
// Alpha handlers
|
|
2464
2649
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2465
2650
|
#J = (t) => {
|
|
2466
|
-
this.disabled || (t.preventDefault(), this.#o = !0, this.#b?.focus(), this.#
|
|
2651
|
+
this.disabled || (t.preventDefault(), this.#o = !0, this.#b?.focus(), this.#E(t));
|
|
2467
2652
|
};
|
|
2468
|
-
#
|
|
2469
|
-
if (!this.#
|
|
2470
|
-
const e = this.#
|
|
2653
|
+
#E(t) {
|
|
2654
|
+
if (!this.#m) return;
|
|
2655
|
+
const e = this.#m.getBoundingClientRect(), s = Math.max(0, Math.min(1, (t.clientX - e.left) / e.width));
|
|
2471
2656
|
this.#s = Math.round(s * 100), this.#A(), this.#L();
|
|
2472
2657
|
}
|
|
2473
|
-
#
|
|
2658
|
+
#z = (t) => {
|
|
2474
2659
|
if (this.disabled) return;
|
|
2475
2660
|
const e = t.shiftKey ? 10 : 1;
|
|
2476
2661
|
let s = !1;
|
|
@@ -2484,16 +2669,16 @@ class dt extends u {
|
|
|
2484
2669
|
this.#s = Math.max(0, this.#s - e), s = !0;
|
|
2485
2670
|
break;
|
|
2486
2671
|
}
|
|
2487
|
-
s && (t.preventDefault(), this.#A(), this.#L(), this.#
|
|
2672
|
+
s && (t.preventDefault(), this.#A(), this.#L(), this.#w());
|
|
2488
2673
|
};
|
|
2489
2674
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2490
2675
|
// Pointer move/up
|
|
2491
2676
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2492
2677
|
#P = (t) => {
|
|
2493
|
-
this.#r ? this.#
|
|
2678
|
+
this.#r ? this.#C(t) : this.#a ? this.#K(t) : this.#o && this.#E(t);
|
|
2494
2679
|
};
|
|
2495
2680
|
#R = () => {
|
|
2496
|
-
(this.#r || this.#a || this.#o) && (this.#r = !1, this.#a = !1, this.#o = !1, this.#
|
|
2681
|
+
(this.#r || this.#a || this.#o) && (this.#r = !1, this.#a = !1, this.#o = !1, this.#w());
|
|
2497
2682
|
};
|
|
2498
2683
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2499
2684
|
// Input handlers
|
|
@@ -2501,9 +2686,9 @@ class dt extends u {
|
|
|
2501
2686
|
#T = () => {
|
|
2502
2687
|
if (!this.#g) return;
|
|
2503
2688
|
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.#
|
|
2689
|
+
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
2690
|
};
|
|
2506
|
-
#
|
|
2691
|
+
#U = (t) => {
|
|
2507
2692
|
t.key === "Enter" && (t.preventDefault(), this.#T());
|
|
2508
2693
|
};
|
|
2509
2694
|
// ───────────────────────────────────────────────────────────────────────────
|
|
@@ -2513,7 +2698,7 @@ class dt extends u {
|
|
|
2513
2698
|
const t = ["hex", "rgb", "hsl"], e = this.format, s = t.indexOf(e), i = t[(s + 1) % t.length];
|
|
2514
2699
|
this.format = i;
|
|
2515
2700
|
const r = this.$('[data-ry-target="format-toggle"]');
|
|
2516
|
-
r && (r.textContent = i.toUpperCase()), this.#
|
|
2701
|
+
r && (r.textContent = i.toUpperCase()), this.#W();
|
|
2517
2702
|
};
|
|
2518
2703
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2519
2704
|
// Swatches
|
|
@@ -2524,7 +2709,7 @@ class dt extends u {
|
|
|
2524
2709
|
const s = e.dataset.color;
|
|
2525
2710
|
if (s) {
|
|
2526
2711
|
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.#
|
|
2712
|
+
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
2713
|
}
|
|
2529
2714
|
}
|
|
2530
2715
|
};
|
|
@@ -2532,9 +2717,9 @@ class dt extends u {
|
|
|
2532
2717
|
// Update methods
|
|
2533
2718
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2534
2719
|
#A() {
|
|
2535
|
-
this.#
|
|
2720
|
+
this.#V(), this.#x(), this.#_(), this.#H(), this.#N(), this.#W(), this.#Z();
|
|
2536
2721
|
}
|
|
2537
|
-
#
|
|
2722
|
+
#V() {
|
|
2538
2723
|
const t = this.$('[data-ry-target="trigger-color"]');
|
|
2539
2724
|
if (t) {
|
|
2540
2725
|
const e = v({ h: this.#t, s: this.#e, v: this.#i }), s = this.hasAttribute("opacity") ? this.#s / 100 : 1;
|
|
@@ -2542,19 +2727,19 @@ class dt extends u {
|
|
|
2542
2727
|
}
|
|
2543
2728
|
}
|
|
2544
2729
|
#x() {
|
|
2545
|
-
if (this.#
|
|
2730
|
+
if (this.#d) {
|
|
2546
2731
|
const t = v({ h: this.#t, s: 100, v: 100 });
|
|
2547
|
-
this.#
|
|
2732
|
+
this.#d.style.setProperty("--grid-hue-color", `rgb(${t.r}, ${t.g}, ${t.b})`);
|
|
2548
2733
|
}
|
|
2549
2734
|
this.#n && (this.#n.style.left = `${this.#e}%`, this.#n.style.top = `${100 - this.#i}%`);
|
|
2550
2735
|
}
|
|
2551
2736
|
#_() {
|
|
2552
2737
|
this.#u && (this.#u.style.left = `${this.#t / 360 * 100}%`);
|
|
2553
2738
|
}
|
|
2554
|
-
#
|
|
2555
|
-
if (this.#
|
|
2739
|
+
#H() {
|
|
2740
|
+
if (this.#m) {
|
|
2556
2741
|
const t = v({ h: this.#t, s: this.#e, v: this.#i });
|
|
2557
|
-
this.#
|
|
2742
|
+
this.#m.style.setProperty("--alpha-color", `rgb(${t.r}, ${t.g}, ${t.b})`);
|
|
2558
2743
|
}
|
|
2559
2744
|
this.#b && (this.#b.style.left = `${this.#s}%`);
|
|
2560
2745
|
}
|
|
@@ -2565,7 +2750,7 @@ class dt extends u {
|
|
|
2565
2750
|
t.style.backgroundColor = `rgba(${e.r}, ${e.g}, ${e.b}, ${s})`;
|
|
2566
2751
|
}
|
|
2567
2752
|
}
|
|
2568
|
-
#
|
|
2753
|
+
#W() {
|
|
2569
2754
|
this.#g && (this.#g.value = this.#O());
|
|
2570
2755
|
}
|
|
2571
2756
|
#Z() {
|
|
@@ -2576,7 +2761,7 @@ class dt extends u {
|
|
|
2576
2761
|
const t = this.format, e = v({ h: this.#t, s: this.#e, v: this.#i }), s = this.hasAttribute("opacity");
|
|
2577
2762
|
switch (t) {
|
|
2578
2763
|
case "hex": {
|
|
2579
|
-
const i =
|
|
2764
|
+
const i = D(e);
|
|
2580
2765
|
if (s && this.#s < 100) {
|
|
2581
2766
|
const r = Math.round(this.#s / 100 * 255).toString(16).padStart(2, "0");
|
|
2582
2767
|
return i + r;
|
|
@@ -2590,7 +2775,7 @@ class dt extends u {
|
|
|
2590
2775
|
return s ? `hsla(${i.h}, ${i.s}%, ${i.l}%, ${(this.#s / 100).toFixed(2)})` : `hsl(${i.h}, ${i.s}%, ${i.l}%)`;
|
|
2591
2776
|
}
|
|
2592
2777
|
default:
|
|
2593
|
-
return
|
|
2778
|
+
return D(e);
|
|
2594
2779
|
}
|
|
2595
2780
|
}
|
|
2596
2781
|
// ───────────────────────────────────────────────────────────────────────────
|
|
@@ -2599,16 +2784,16 @@ class dt extends u {
|
|
|
2599
2784
|
#L() {
|
|
2600
2785
|
this.emit("input", { value: this.value, hsv: this.hsv, rgb: this.rgb });
|
|
2601
2786
|
}
|
|
2602
|
-
#
|
|
2787
|
+
#w() {
|
|
2603
2788
|
this.emit("change", { value: this.value, hsv: this.hsv, rgb: this.rgb });
|
|
2604
2789
|
}
|
|
2605
2790
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2606
2791
|
// Attribute changed
|
|
2607
2792
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2608
2793
|
attributeChangedCallback(t, e, s) {
|
|
2609
|
-
if (e !== s && t === "value" && this.#
|
|
2794
|
+
if (e !== s && t === "value" && this.#d && s) {
|
|
2610
2795
|
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.#
|
|
2796
|
+
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
2797
|
}
|
|
2613
2798
|
}
|
|
2614
2799
|
// ───────────────────────────────────────────────────────────────────────────
|
|
@@ -2661,15 +2846,15 @@ class dt extends u {
|
|
|
2661
2846
|
return this.format = e, s;
|
|
2662
2847
|
}
|
|
2663
2848
|
}
|
|
2664
|
-
customElements.define("ry-color-picker",
|
|
2665
|
-
class
|
|
2849
|
+
customElements.define("ry-color-picker", gt);
|
|
2850
|
+
class ft extends u {
|
|
2666
2851
|
#t = null;
|
|
2667
2852
|
#e = null;
|
|
2668
2853
|
#i = null;
|
|
2669
2854
|
#s = null;
|
|
2670
2855
|
static observedAttributes = ["value", "format", "opacity", "disabled", "placeholder"];
|
|
2671
2856
|
setup() {
|
|
2672
|
-
this.#r(), this.#a(), this.#
|
|
2857
|
+
this.#r(), this.#a(), this.#f(), this.state = "closed";
|
|
2673
2858
|
}
|
|
2674
2859
|
#r() {
|
|
2675
2860
|
const t = this.hasAttribute("opacity"), e = this.getAttribute("format") || "hex", s = this.getAttribute("value") || "#000000", i = this.getAttribute("placeholder") || "#000000";
|
|
@@ -2701,15 +2886,15 @@ class ut extends u {
|
|
|
2701
2886
|
`, 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
2887
|
}
|
|
2703
2888
|
#a() {
|
|
2704
|
-
this.#t && this.on(this.#t, "click", this.#o), this.#e && (this.on(this.#e, "input", this.#
|
|
2889
|
+
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
2890
|
}
|
|
2706
2891
|
#o = () => {
|
|
2707
2892
|
this.disabled || (this.state === "open" ? this.close() : this.open());
|
|
2708
2893
|
};
|
|
2709
|
-
#
|
|
2894
|
+
#c = () => {
|
|
2710
2895
|
this.disabled || this.open();
|
|
2711
2896
|
};
|
|
2712
|
-
#
|
|
2897
|
+
#h = () => {
|
|
2713
2898
|
if (!this.#e || !this.#s) return;
|
|
2714
2899
|
let t = this.#e.value;
|
|
2715
2900
|
const e = this.#e.selectionStart ?? t.length, r = "#" + t.replace(/[^#a-fA-F0-9]/g, "").replace(/#/g, "").slice(0, 6);
|
|
@@ -2718,10 +2903,10 @@ class ut extends u {
|
|
|
2718
2903
|
const n = Math.min(e, r.length);
|
|
2719
2904
|
this.#e.setSelectionRange(n, n);
|
|
2720
2905
|
}
|
|
2721
|
-
const a = this.#
|
|
2722
|
-
a && (this.#s.setColor(a), this.#
|
|
2906
|
+
const a = this.#d(r);
|
|
2907
|
+
a && (this.#s.setColor(a), this.#l(), this.#n(r) && this.#v(), this.emit("input", { value: this.value }));
|
|
2723
2908
|
};
|
|
2724
|
-
#
|
|
2909
|
+
#d(t) {
|
|
2725
2910
|
let e = t;
|
|
2726
2911
|
e.startsWith("#") || (e = "#" + e);
|
|
2727
2912
|
const s = e.slice(1);
|
|
@@ -2739,18 +2924,18 @@ class ut extends u {
|
|
|
2739
2924
|
return !!(/^#[a-fA-F0-9]{6}$/.test(t) || /^#[a-fA-F0-9]{3}$/.test(t));
|
|
2740
2925
|
}
|
|
2741
2926
|
#p = (t) => {
|
|
2742
|
-
t.key === "Enter" && (t.preventDefault(), this.#
|
|
2927
|
+
t.key === "Enter" && (t.preventDefault(), this.#h(), this.emit("change", { value: this.value }));
|
|
2743
2928
|
};
|
|
2744
2929
|
#u = () => {
|
|
2745
|
-
!this.#s || !this.#e || (document.activeElement !== this.#e && (this.#e.value = this.#s.value), this.#
|
|
2930
|
+
!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
2931
|
};
|
|
2747
|
-
#
|
|
2932
|
+
#m = () => {
|
|
2748
2933
|
this.emit("change", { value: this.value });
|
|
2749
2934
|
};
|
|
2750
2935
|
#b = (t) => {
|
|
2751
2936
|
this.state === "open" && (this.contains(t.target) || this.close());
|
|
2752
2937
|
};
|
|
2753
|
-
#
|
|
2938
|
+
#k = (t) => {
|
|
2754
2939
|
t.key === "Escape" && this.state === "open" && (this.close(), this.#t?.focus());
|
|
2755
2940
|
};
|
|
2756
2941
|
open() {
|
|
@@ -2764,38 +2949,38 @@ class ut extends u {
|
|
|
2764
2949
|
const t = this.getBoundingClientRect(), e = 280, i = window.innerHeight - t.bottom, r = t.top;
|
|
2765
2950
|
i < e && r > i ? this.setAttribute("data-ry-position", "top") : this.setAttribute("data-ry-position", "bottom");
|
|
2766
2951
|
}
|
|
2767
|
-
#
|
|
2952
|
+
#l() {
|
|
2768
2953
|
const t = this.$('[data-ry-target="swatch-color"]');
|
|
2769
2954
|
if (t && this.#s) {
|
|
2770
2955
|
const e = this.#s.rgb, s = this.hasAttribute("opacity") ? this.#s.alpha / 100 : 1;
|
|
2771
2956
|
t.style.backgroundColor = `rgba(${e.r}, ${e.g}, ${e.b}, ${s})`;
|
|
2772
2957
|
}
|
|
2773
2958
|
}
|
|
2774
|
-
#
|
|
2959
|
+
#f() {
|
|
2775
2960
|
const t = this.getAttribute("value") || "#000000";
|
|
2776
2961
|
if (this.#s) {
|
|
2777
2962
|
if (this.#s.setColor(t), this.#e) {
|
|
2778
2963
|
const e = this.#s.value;
|
|
2779
2964
|
this.#e.value = e.startsWith("#") ? e : "#" + e;
|
|
2780
2965
|
}
|
|
2781
|
-
this.#
|
|
2966
|
+
this.#l();
|
|
2782
2967
|
}
|
|
2783
2968
|
}
|
|
2784
|
-
#
|
|
2969
|
+
#v() {
|
|
2785
2970
|
if (this.#s) {
|
|
2786
2971
|
const t = this.#s.value;
|
|
2787
2972
|
this.getAttribute("value") !== t && this.setAttribute("value", t);
|
|
2788
2973
|
}
|
|
2789
2974
|
}
|
|
2790
2975
|
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.#
|
|
2976
|
+
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
2977
|
}
|
|
2793
2978
|
// Public API
|
|
2794
2979
|
get value() {
|
|
2795
2980
|
return this.#s?.value ?? this.getAttribute("value") ?? "#000000";
|
|
2796
2981
|
}
|
|
2797
2982
|
set value(t) {
|
|
2798
|
-
this.#s?.setColor(t) && (this.#e && (this.#e.value = this.#s.value), this.#
|
|
2983
|
+
this.#s?.setColor(t) && (this.#e && (this.#e.value = this.#s.value), this.#l(), this.#v());
|
|
2799
2984
|
}
|
|
2800
2985
|
get disabled() {
|
|
2801
2986
|
return this.hasAttribute("disabled");
|
|
@@ -2813,7 +2998,7 @@ class ut extends u {
|
|
|
2813
2998
|
return this.#s?.hsv ?? { h: 0, s: 0, v: 0 };
|
|
2814
2999
|
}
|
|
2815
3000
|
}
|
|
2816
|
-
customElements.define("ry-color-input",
|
|
3001
|
+
customElements.define("ry-color-input", ft);
|
|
2817
3002
|
function x(h) {
|
|
2818
3003
|
const t = h.trim().toLowerCase();
|
|
2819
3004
|
if (t.startsWith("#")) {
|
|
@@ -2846,19 +3031,19 @@ function x(h) {
|
|
|
2846
3031
|
}
|
|
2847
3032
|
return null;
|
|
2848
3033
|
}
|
|
2849
|
-
function
|
|
3034
|
+
function yt(h) {
|
|
2850
3035
|
const t = (e) => Math.max(0, Math.min(255, e)).toString(16).padStart(2, "0");
|
|
2851
3036
|
return `#${t(h.r)}${t(h.g)}${t(h.b)}`;
|
|
2852
3037
|
}
|
|
2853
|
-
function
|
|
3038
|
+
function bt(h, t, e) {
|
|
2854
3039
|
return {
|
|
2855
3040
|
r: Math.round(h.r + (t.r - h.r) * e),
|
|
2856
3041
|
g: Math.round(h.g + (t.g - h.g) * e),
|
|
2857
3042
|
b: Math.round(h.b + (t.b - h.b) * e)
|
|
2858
3043
|
};
|
|
2859
3044
|
}
|
|
2860
|
-
const
|
|
2861
|
-
class
|
|
3045
|
+
const I = "linear-gradient(90deg, #000000 0%, #ffffff 100%)", mt = 50;
|
|
3046
|
+
class vt extends u {
|
|
2862
3047
|
#t = "linear";
|
|
2863
3048
|
#e = 90;
|
|
2864
3049
|
#i = "circle";
|
|
@@ -2866,28 +3051,28 @@ class yt extends u {
|
|
|
2866
3051
|
#r = null;
|
|
2867
3052
|
#a = 0;
|
|
2868
3053
|
#o = null;
|
|
2869
|
-
#
|
|
2870
|
-
#
|
|
2871
|
-
#
|
|
3054
|
+
#c = !1;
|
|
3055
|
+
#h = null;
|
|
3056
|
+
#d = !1;
|
|
2872
3057
|
// Cached DOM refs
|
|
2873
3058
|
#n = null;
|
|
2874
3059
|
#p = null;
|
|
2875
3060
|
#u = null;
|
|
2876
3061
|
static observedAttributes = ["value", "disabled", "output"];
|
|
2877
3062
|
setup() {
|
|
2878
|
-
this.#
|
|
3063
|
+
this.#m(), this.#Y(), this.#X(), this.#x();
|
|
2879
3064
|
}
|
|
2880
3065
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2881
3066
|
// Parsing / Serialization
|
|
2882
3067
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2883
|
-
#
|
|
2884
|
-
const t = this.getAttribute("value") ||
|
|
2885
|
-
this.#b(t) || this.#b(
|
|
3068
|
+
#m() {
|
|
3069
|
+
const t = this.getAttribute("value") || I;
|
|
3070
|
+
this.#b(t) || this.#b(I);
|
|
2886
3071
|
}
|
|
2887
3072
|
#b(t) {
|
|
2888
3073
|
const e = t.trim();
|
|
2889
3074
|
if (!e.startsWith("linear-gradient(") && !e.startsWith("radial-gradient("))
|
|
2890
|
-
return x(e) ? (this.#t = "solid", this.#s = [this.#
|
|
3075
|
+
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
3076
|
let s, i;
|
|
2892
3077
|
e.startsWith("linear-gradient(") ? (s = "linear", i = e.slice(16, -1)) : (s = "radial", i = e.slice(16, -1));
|
|
2893
3078
|
let r = 90, a = "circle", n = i;
|
|
@@ -2899,7 +3084,7 @@ class yt extends u {
|
|
|
2899
3084
|
const g = /^to\s+\w+(?:\s+\w+)?\s*,\s*/.exec(i);
|
|
2900
3085
|
if (g) {
|
|
2901
3086
|
const b = g[0].trim().replace(/,\s*$/, "");
|
|
2902
|
-
r = this.#
|
|
3087
|
+
r = this.#k(b), n = i.slice(g[0].length);
|
|
2903
3088
|
}
|
|
2904
3089
|
}
|
|
2905
3090
|
} else {
|
|
@@ -2909,10 +3094,10 @@ class yt extends u {
|
|
|
2909
3094
|
const o = [], l = /(#[a-fA-F0-9]{3,8}|rgba?\([^)]+\)|hsla?\([^)]+\)|[a-z]+)\s+([\d.]+)%/g;
|
|
2910
3095
|
let c;
|
|
2911
3096
|
for (; (c = l.exec(n)) !== null; )
|
|
2912
|
-
o.push(this.#
|
|
3097
|
+
o.push(this.#l(c[1], parseFloat(c[2])));
|
|
2913
3098
|
return o.length < 2 ? !1 : (this.#t = s, this.#e = r, this.#i = a, this.#s = o, this.#r = o[0].id, !0);
|
|
2914
3099
|
}
|
|
2915
|
-
#
|
|
3100
|
+
#k(t) {
|
|
2916
3101
|
return {
|
|
2917
3102
|
"to top": 0,
|
|
2918
3103
|
"to top right": 45,
|
|
@@ -2933,22 +3118,22 @@ class yt extends u {
|
|
|
2933
3118
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2934
3119
|
// Stop management
|
|
2935
3120
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2936
|
-
#
|
|
3121
|
+
#l(t, e) {
|
|
2937
3122
|
return { id: `stop-${this.#a++}`, color: t, position: e };
|
|
2938
3123
|
}
|
|
2939
3124
|
/** CSS left value clamped so the stop handle stays within the bar */
|
|
2940
|
-
#
|
|
3125
|
+
#f(t) {
|
|
2941
3126
|
const e = "calc(var(--ry-gradient-picker-stop-size, 16px) / 2)";
|
|
2942
3127
|
return `clamp(${e}, ${t}%, calc(100% - ${e}))`;
|
|
2943
3128
|
}
|
|
2944
|
-
#
|
|
2945
|
-
const s = this.#
|
|
2946
|
-
this.#s.push(s), this.#$(), this.#r = s.id, this.#
|
|
3129
|
+
#v(t, e) {
|
|
3130
|
+
const s = this.#l(t, e);
|
|
3131
|
+
this.#s.push(s), this.#$(), this.#r = s.id, this.#C(), this.#x();
|
|
2947
3132
|
}
|
|
2948
|
-
#
|
|
3133
|
+
#y(t) {
|
|
2949
3134
|
if (this.#s.length <= 2) return !1;
|
|
2950
3135
|
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.#
|
|
3136
|
+
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
3137
|
}
|
|
2953
3138
|
#M(t) {
|
|
2954
3139
|
this.#r !== t && (this.#r = t, this.#O(), this.#L());
|
|
@@ -2956,13 +3141,13 @@ class yt extends u {
|
|
|
2956
3141
|
#$() {
|
|
2957
3142
|
this.#s.sort((t, e) => t.position - e.position);
|
|
2958
3143
|
}
|
|
2959
|
-
#
|
|
3144
|
+
#I() {
|
|
2960
3145
|
return this.#s.find((t) => t.id === this.#r) ?? null;
|
|
2961
3146
|
}
|
|
2962
3147
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2963
3148
|
// Markup
|
|
2964
3149
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2965
|
-
#
|
|
3150
|
+
#Y() {
|
|
2966
3151
|
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
3152
|
let o = "";
|
|
2968
3153
|
t && (o = `
|
|
@@ -2989,14 +3174,14 @@ class yt extends u {
|
|
|
2989
3174
|
</div>
|
|
2990
3175
|
<ry-color-picker data-ry-target="picker" inline opacity></ry-color-picker>
|
|
2991
3176
|
${o}
|
|
2992
|
-
`, this.#n = this.$('[data-ry-target="bar"]'), this.#p = this.$('[data-ry-target="picker"]'), this.#u = this.$('[data-ry-target="output"]'), this.#
|
|
3177
|
+
`, this.#n = this.$('[data-ry-target="bar"]'), this.#p = this.$('[data-ry-target="picker"]'), this.#u = this.$('[data-ry-target="output"]'), this.#C();
|
|
2993
3178
|
}
|
|
2994
|
-
#
|
|
3179
|
+
#C() {
|
|
2995
3180
|
if (this.#n) {
|
|
2996
3181
|
this.#n.querySelectorAll('[data-ry-target="stop"]').forEach((t) => t.remove());
|
|
2997
3182
|
for (const t of this.#s) {
|
|
2998
3183
|
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.#
|
|
3184
|
+
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
3185
|
}
|
|
3001
3186
|
}
|
|
3002
3187
|
}
|
|
@@ -3006,13 +3191,13 @@ class yt extends u {
|
|
|
3006
3191
|
#X() {
|
|
3007
3192
|
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
3193
|
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.#
|
|
3194
|
+
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
3195
|
const i = this.$('[data-ry-target="angle-select"]');
|
|
3011
|
-
i && this.on(i, "ry:input", this.#
|
|
3196
|
+
i && this.on(i, "ry:input", this.#z);
|
|
3012
3197
|
const r = this.$('[data-ry-target="shape-circle"]'), a = this.$('[data-ry-target="shape-ellipse"]');
|
|
3013
3198
|
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
3199
|
const n = this.$('[data-ry-target="copy-btn"]');
|
|
3015
|
-
n && this.on(n, "click", this.#
|
|
3200
|
+
n && this.on(n, "click", this.#U), this.#n && this.on(this.#n, "keydown", this.#J);
|
|
3016
3201
|
}
|
|
3017
3202
|
// ───────────────────────────────────────────────────────────────────────────
|
|
3018
3203
|
// Bar / Stop interaction handlers
|
|
@@ -3023,26 +3208,26 @@ class yt extends u {
|
|
|
3023
3208
|
if (s) {
|
|
3024
3209
|
const i = s.getAttribute("data-stop-id");
|
|
3025
3210
|
if (!i) return;
|
|
3026
|
-
t.preventDefault(), this.#o = i, this.#
|
|
3211
|
+
t.preventDefault(), this.#o = i, this.#c = !1, this.#h = this.#n.getBoundingClientRect(), this.#M(i), this.#n.setPointerCapture(t.pointerId), s.focus();
|
|
3027
3212
|
} else {
|
|
3028
3213
|
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.#
|
|
3214
|
+
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);
|
|
3215
|
+
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
3216
|
}
|
|
3032
3217
|
};
|
|
3033
3218
|
#K = (t) => {
|
|
3034
|
-
if (!this.#o || !this.#
|
|
3219
|
+
if (!this.#o || !this.#h) return;
|
|
3035
3220
|
const e = this.#s.find((n) => n.id === this.#o);
|
|
3036
3221
|
if (!e) return;
|
|
3037
|
-
const s = Math.max(0, Math.min(1, (t.clientX - this.#
|
|
3222
|
+
const s = Math.max(0, Math.min(1, (t.clientX - this.#h.left) / this.#h.width));
|
|
3038
3223
|
e.position = Math.round(s * 100);
|
|
3039
|
-
const i = this.#
|
|
3040
|
-
this.#
|
|
3224
|
+
const i = this.#h.top + this.#h.height / 2, r = Math.abs(t.clientY - i);
|
|
3225
|
+
this.#c = r > mt && this.#s.length > 2;
|
|
3041
3226
|
const a = this.#n?.querySelector(`[data-stop-id="${e.id}"]`);
|
|
3042
|
-
a && (a.style.left = this.#
|
|
3227
|
+
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
3228
|
};
|
|
3044
3229
|
#q = () => {
|
|
3045
|
-
this.#o && (this.#
|
|
3230
|
+
this.#o && (this.#c && this.#y(this.#o), this.#o = null, this.#c = !1, this.#h = null, this.#S(), this.#B());
|
|
3046
3231
|
};
|
|
3047
3232
|
#J = (t) => {
|
|
3048
3233
|
if (this.disabled) return;
|
|
@@ -3063,30 +3248,30 @@ class yt extends u {
|
|
|
3063
3248
|
break;
|
|
3064
3249
|
case "Delete":
|
|
3065
3250
|
case "Backspace":
|
|
3066
|
-
this.#
|
|
3251
|
+
this.#y(i) && (this.#D(), this.#B()), t.preventDefault();
|
|
3067
3252
|
return;
|
|
3068
3253
|
}
|
|
3069
|
-
n && (t.preventDefault(), this.#$(), this.#
|
|
3254
|
+
n && (t.preventDefault(), this.#$(), this.#W(), this.#N(), this.#H(), this.#w(), this.#S(), this.#D(), this.#B());
|
|
3070
3255
|
};
|
|
3071
3256
|
// ───────────────────────────────────────────────────────────────────────────
|
|
3072
3257
|
// Type / Angle / Shape handlers
|
|
3073
3258
|
// ───────────────────────────────────────────────────────────────────────────
|
|
3074
|
-
#
|
|
3075
|
-
this.#t !== t && (this.#t = t, this.setAttribute("data-ry-type", t), this.#_(), this.#
|
|
3259
|
+
#E(t) {
|
|
3260
|
+
this.#t !== t && (this.#t = t, this.setAttribute("data-ry-type", t), this.#_(), this.#H(), this.#w(), this.#S(), this.#D(), this.#B());
|
|
3076
3261
|
}
|
|
3077
|
-
#
|
|
3262
|
+
#z = (t) => {
|
|
3078
3263
|
const e = t.detail;
|
|
3079
|
-
this.#e = e.value, this.#
|
|
3264
|
+
this.#e = e.value, this.#H(), this.#w(), this.#S(), this.#D();
|
|
3080
3265
|
};
|
|
3081
3266
|
#P(t) {
|
|
3082
|
-
this.#i !== t && (this.#i = t, this.#_(), this.#
|
|
3267
|
+
this.#i !== t && (this.#i = t, this.#_(), this.#w(), this.#S(), this.#D(), this.#B());
|
|
3083
3268
|
}
|
|
3084
3269
|
// ───────────────────────────────────────────────────────────────────────────
|
|
3085
3270
|
// Color picker handlers
|
|
3086
3271
|
// ───────────────────────────────────────────────────────────────────────────
|
|
3087
3272
|
#R = () => {
|
|
3088
|
-
const t = this.#
|
|
3089
|
-
!t || !this.#p || (t.color = this.#p.value, this.#Z(t), this.#N(), this.#
|
|
3273
|
+
const t = this.#I();
|
|
3274
|
+
!t || !this.#p || (t.color = this.#p.value, this.#Z(t), this.#N(), this.#H(), this.#w(), this.#D());
|
|
3090
3275
|
};
|
|
3091
3276
|
#T = () => {
|
|
3092
3277
|
this.#S(), this.#B();
|
|
@@ -3094,7 +3279,7 @@ class yt extends u {
|
|
|
3094
3279
|
// ───────────────────────────────────────────────────────────────────────────
|
|
3095
3280
|
// Copy handler
|
|
3096
3281
|
// ───────────────────────────────────────────────────────────────────────────
|
|
3097
|
-
#
|
|
3282
|
+
#U = () => {
|
|
3098
3283
|
const t = this.#g();
|
|
3099
3284
|
navigator.clipboard.writeText(t).then(() => {
|
|
3100
3285
|
const e = this.$('[data-ry-target="copy-btn"]');
|
|
@@ -3113,12 +3298,12 @@ class yt extends u {
|
|
|
3113
3298
|
#A() {
|
|
3114
3299
|
if (!this.#u) return;
|
|
3115
3300
|
const t = this.#u.value.trim();
|
|
3116
|
-
t && this.#b(t) ? (this.#
|
|
3301
|
+
t && this.#b(t) ? (this.#C(), this.#x(), this.#S(), this.#D(), this.#B()) : this.#w();
|
|
3117
3302
|
}
|
|
3118
3303
|
// ───────────────────────────────────────────────────────────────────────────
|
|
3119
3304
|
// Color interpolation
|
|
3120
3305
|
// ───────────────────────────────────────────────────────────────────────────
|
|
3121
|
-
#
|
|
3306
|
+
#V(t) {
|
|
3122
3307
|
if (this.#s.length === 0) return "#808080";
|
|
3123
3308
|
if (this.#s.length === 1) return this.#s[0].color;
|
|
3124
3309
|
const e = [...this.#s].sort((l, c) => l.position - c.position);
|
|
@@ -3133,13 +3318,13 @@ class yt extends u {
|
|
|
3133
3318
|
const r = i.position - s.position;
|
|
3134
3319
|
if (r === 0) return s.color;
|
|
3135
3320
|
const a = (t - s.position) / r, n = x(s.color), o = x(i.color);
|
|
3136
|
-
return !n || !o ? s.color :
|
|
3321
|
+
return !n || !o ? s.color : yt(bt(n, o, a));
|
|
3137
3322
|
}
|
|
3138
3323
|
// ───────────────────────────────────────────────────────────────────────────
|
|
3139
3324
|
// Update methods
|
|
3140
3325
|
// ───────────────────────────────────────────────────────────────────────────
|
|
3141
3326
|
#x() {
|
|
3142
|
-
this.setAttribute("data-ry-type", this.#t), this.#_(), this.#N(), this.#
|
|
3327
|
+
this.setAttribute("data-ry-type", this.#t), this.#_(), this.#N(), this.#H(), this.#W(), this.#O(), this.#L(), this.#w();
|
|
3143
3328
|
}
|
|
3144
3329
|
#_() {
|
|
3145
3330
|
const t = this.$('[data-ry-target="type-solid"]'), e = this.$('[data-ry-target="type-linear"]'), s = this.$('[data-ry-target="type-radial"]');
|
|
@@ -3149,7 +3334,7 @@ class yt extends u {
|
|
|
3149
3334
|
const a = this.$('[data-ry-target="angle-select"]');
|
|
3150
3335
|
a && a.setAttribute("value", String(this.#e));
|
|
3151
3336
|
}
|
|
3152
|
-
#
|
|
3337
|
+
#H() {
|
|
3153
3338
|
if (!this.#p) return;
|
|
3154
3339
|
const t = this.#p.querySelector('[data-ry-target="preview-color"]');
|
|
3155
3340
|
t && (t.style.backgroundImage = this.#t === "solid" ? "" : this.#g());
|
|
@@ -3159,11 +3344,11 @@ class yt extends u {
|
|
|
3159
3344
|
const t = this.#s.map((e) => `${e.color} ${e.position}%`).join(", ");
|
|
3160
3345
|
this.#n.style.backgroundImage = `linear-gradient(to right, ${t})`;
|
|
3161
3346
|
}
|
|
3162
|
-
#
|
|
3347
|
+
#W() {
|
|
3163
3348
|
if (this.#n)
|
|
3164
3349
|
for (const t of this.#s) {
|
|
3165
3350
|
const e = this.#n.querySelector(`[data-stop-id="${t.id}"]`);
|
|
3166
|
-
e && (e.style.left = this.#
|
|
3351
|
+
e && (e.style.left = this.#f(t.position));
|
|
3167
3352
|
}
|
|
3168
3353
|
}
|
|
3169
3354
|
#Z(t) {
|
|
@@ -3178,20 +3363,20 @@ class yt extends u {
|
|
|
3178
3363
|
e.getAttribute("data-stop-id") === this.#r ? e.setAttribute("data-selected", "") : e.removeAttribute("data-selected");
|
|
3179
3364
|
}
|
|
3180
3365
|
#L() {
|
|
3181
|
-
const t = this.#
|
|
3366
|
+
const t = this.#I();
|
|
3182
3367
|
!t || !this.#p || this.#p.setColor(t.color);
|
|
3183
3368
|
}
|
|
3184
|
-
#
|
|
3369
|
+
#w() {
|
|
3185
3370
|
this.#u && document.activeElement !== this.#u && (this.#u.value = this.#g());
|
|
3186
3371
|
}
|
|
3187
3372
|
#S() {
|
|
3188
3373
|
const t = this.#g();
|
|
3189
|
-
this.getAttribute("value") !== t && (this.#
|
|
3374
|
+
this.getAttribute("value") !== t && (this.#d = !0, this.setAttribute("value", t), this.#d = !1);
|
|
3190
3375
|
}
|
|
3191
3376
|
// ───────────────────────────────────────────────────────────────────────────
|
|
3192
3377
|
// Events
|
|
3193
3378
|
// ───────────────────────────────────────────────────────────────────────────
|
|
3194
|
-
#
|
|
3379
|
+
#D() {
|
|
3195
3380
|
this.emit("input", {
|
|
3196
3381
|
value: this.#g(),
|
|
3197
3382
|
type: this.#t,
|
|
@@ -3213,7 +3398,7 @@ class yt extends u {
|
|
|
3213
3398
|
// Attribute changed
|
|
3214
3399
|
// ───────────────────────────────────────────────────────────────────────────
|
|
3215
3400
|
attributeChangedCallback(t, e, s) {
|
|
3216
|
-
e === s || this.#
|
|
3401
|
+
e === s || this.#d || t === "value" && this.#n && s && this.#b(s) && (this.#C(), this.#x());
|
|
3217
3402
|
}
|
|
3218
3403
|
// ───────────────────────────────────────────────────────────────────────────
|
|
3219
3404
|
// Public API
|
|
@@ -3222,19 +3407,19 @@ class yt extends u {
|
|
|
3222
3407
|
return this.#g();
|
|
3223
3408
|
}
|
|
3224
3409
|
set value(t) {
|
|
3225
|
-
this.#b(t) && (this.#
|
|
3410
|
+
this.#b(t) && (this.#C(), this.#x(), this.#S());
|
|
3226
3411
|
}
|
|
3227
3412
|
get type() {
|
|
3228
3413
|
return this.#t;
|
|
3229
3414
|
}
|
|
3230
3415
|
set type(t) {
|
|
3231
|
-
this.#
|
|
3416
|
+
this.#E(t);
|
|
3232
3417
|
}
|
|
3233
3418
|
get angle() {
|
|
3234
3419
|
return this.#e;
|
|
3235
3420
|
}
|
|
3236
3421
|
set angle(t) {
|
|
3237
|
-
this.#e = (t % 360 + 360) % 360, this.#_(), this.#
|
|
3422
|
+
this.#e = (t % 360 + 360) % 360, this.#_(), this.#w(), this.#S();
|
|
3238
3423
|
}
|
|
3239
3424
|
get shape() {
|
|
3240
3425
|
return this.#i;
|
|
@@ -3246,7 +3431,7 @@ class yt extends u {
|
|
|
3246
3431
|
return this.#s.map((t) => ({ ...t }));
|
|
3247
3432
|
}
|
|
3248
3433
|
get selectedStop() {
|
|
3249
|
-
const t = this.#
|
|
3434
|
+
const t = this.#I();
|
|
3250
3435
|
return t ? { ...t } : null;
|
|
3251
3436
|
}
|
|
3252
3437
|
get disabled() {
|
|
@@ -3256,16 +3441,16 @@ class yt extends u {
|
|
|
3256
3441
|
t ? this.setAttribute("disabled", "") : this.removeAttribute("disabled");
|
|
3257
3442
|
}
|
|
3258
3443
|
addStop(t, e) {
|
|
3259
|
-
this.#
|
|
3444
|
+
this.#v(t, e), this.#S(), this.#D(), this.#B();
|
|
3260
3445
|
}
|
|
3261
3446
|
removeStop(t) {
|
|
3262
|
-
const e = this.#
|
|
3263
|
-
return e && (this.#
|
|
3447
|
+
const e = this.#y(t);
|
|
3448
|
+
return e && (this.#w(), this.#S(), this.#B()), e;
|
|
3264
3449
|
}
|
|
3265
3450
|
}
|
|
3266
|
-
customElements.define("ry-gradient-picker",
|
|
3267
|
-
let
|
|
3268
|
-
const
|
|
3451
|
+
customElements.define("ry-gradient-picker", vt);
|
|
3452
|
+
let At = 0;
|
|
3453
|
+
const kt = 5;
|
|
3269
3454
|
function _(h) {
|
|
3270
3455
|
return p(h).replace(/width="24"/g, 'width="16"').replace(/height="24"/g, 'height="16"').replace(/viewBox/, 'class="ry-tree__icon" viewBox');
|
|
3271
3456
|
}
|
|
@@ -3278,9 +3463,9 @@ class k extends u {
|
|
|
3278
3463
|
#r = null;
|
|
3279
3464
|
#a = null;
|
|
3280
3465
|
#o = null;
|
|
3281
|
-
#
|
|
3466
|
+
#c = null;
|
|
3282
3467
|
setup() {
|
|
3283
|
-
this.#
|
|
3468
|
+
this.#h(), this.on(this, "click", (t) => {
|
|
3284
3469
|
const s = t.target.closest('[data-ry-target="file"]');
|
|
3285
3470
|
s && (this.$$("[data-ry-selected]").forEach((i) => i.removeAttribute("data-ry-selected")), s.setAttribute("data-ry-selected", ""), this.emit("select", {
|
|
3286
3471
|
label: s.dataset.ryLabel ?? ""
|
|
@@ -3293,25 +3478,25 @@ class k extends u {
|
|
|
3293
3478
|
label: i,
|
|
3294
3479
|
open: e.checked
|
|
3295
3480
|
});
|
|
3296
|
-
}), this.hasAttribute("sortable") && this.#
|
|
3481
|
+
}), this.hasAttribute("sortable") && this.#m();
|
|
3297
3482
|
}
|
|
3298
3483
|
// ── Build ──────────────────────────────────────────────────
|
|
3299
|
-
#
|
|
3484
|
+
#h() {
|
|
3300
3485
|
if (this.$(".ry-tree__root")) return;
|
|
3301
3486
|
const t = Array.from(this.children), e = document.createElement("ul");
|
|
3302
3487
|
e.className = "ry-tree__root";
|
|
3303
3488
|
for (const s of t)
|
|
3304
|
-
e.appendChild(this.#
|
|
3489
|
+
e.appendChild(this.#d(s));
|
|
3305
3490
|
this.innerHTML = "", this.appendChild(e);
|
|
3306
3491
|
}
|
|
3307
|
-
#
|
|
3492
|
+
#d(t) {
|
|
3308
3493
|
const e = document.createElement("li");
|
|
3309
3494
|
e.className = "ry-tree__item";
|
|
3310
3495
|
const s = t.getAttribute("label") ?? "", i = t.hasAttribute("open"), r = t.hasAttribute("selected"), a = Array.from(t.children).filter(
|
|
3311
3496
|
(o) => o.tagName === "RY-TREE-ITEM"
|
|
3312
3497
|
);
|
|
3313
3498
|
if (a.length > 0) {
|
|
3314
|
-
const o = `ry-tree-${++
|
|
3499
|
+
const o = `ry-tree-${++At}`, l = document.createElement("input");
|
|
3315
3500
|
l.type = "checkbox", l.id = o, l.className = "ry-tree__toggle", i && (l.checked = !0);
|
|
3316
3501
|
const c = document.createElement("label");
|
|
3317
3502
|
c.htmlFor = o, c.className = "ry-tree__label", c.setAttribute("data-ry-target", "folder"), c.dataset.ryLabel = s, c.innerHTML = `
|
|
@@ -3324,7 +3509,7 @@ class k extends u {
|
|
|
3324
3509
|
const g = document.createElement("ul");
|
|
3325
3510
|
g.className = "ry-tree__children";
|
|
3326
3511
|
for (const b of a)
|
|
3327
|
-
g.appendChild(this.#
|
|
3512
|
+
g.appendChild(this.#d(b));
|
|
3328
3513
|
d.appendChild(g), e.appendChild(l), e.appendChild(c), e.appendChild(d);
|
|
3329
3514
|
} else {
|
|
3330
3515
|
const o = document.createElement("div");
|
|
@@ -3375,8 +3560,8 @@ class k extends u {
|
|
|
3375
3560
|
return e;
|
|
3376
3561
|
}
|
|
3377
3562
|
// ── Drag and Drop ──────────────────────────────────────────
|
|
3378
|
-
#
|
|
3379
|
-
this.on(this, "pointerdown", this.#b), this.on(document, "pointermove", this.#
|
|
3563
|
+
#m() {
|
|
3564
|
+
this.on(this, "pointerdown", this.#b), this.on(document, "pointermove", this.#k), this.on(document, "pointerup", this.#g);
|
|
3380
3565
|
}
|
|
3381
3566
|
#b = (t) => {
|
|
3382
3567
|
const s = t.target.closest(".ry-tree__label, .ry-tree__file");
|
|
@@ -3384,42 +3569,42 @@ class k extends u {
|
|
|
3384
3569
|
const i = s.closest(".ry-tree__item");
|
|
3385
3570
|
i && (this.#t = !0, this.#i = t.clientX, this.#s = t.clientY, this.#r = i);
|
|
3386
3571
|
};
|
|
3387
|
-
#
|
|
3572
|
+
#k = (t) => {
|
|
3388
3573
|
if (!this.#t && !this.#e) return;
|
|
3389
3574
|
if (this.#t && !this.#e) {
|
|
3390
3575
|
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.#
|
|
3576
|
+
if (Math.hypot(c, d) < kt) return;
|
|
3577
|
+
this.#t = !1, this.#e = !0, this.#l(t);
|
|
3393
3578
|
}
|
|
3394
3579
|
if (!this.#e || !this.#a) return;
|
|
3395
3580
|
this.#a.style.left = `${t.clientX + 12}px`, this.#a.style.top = `${t.clientY - 14}px`, this.#a.style.display = "none";
|
|
3396
3581
|
const e = document.elementFromPoint(t.clientX, t.clientY);
|
|
3397
3582
|
if (this.#a.style.display = "", !e) {
|
|
3398
|
-
this.#
|
|
3583
|
+
this.#y();
|
|
3399
3584
|
return;
|
|
3400
3585
|
}
|
|
3401
3586
|
const s = e.closest(".ry-tree__label, .ry-tree__file");
|
|
3402
3587
|
if (!s) {
|
|
3403
|
-
this.#
|
|
3588
|
+
this.#y();
|
|
3404
3589
|
return;
|
|
3405
3590
|
}
|
|
3406
3591
|
const i = s.closest(".ry-tree__item");
|
|
3407
3592
|
if (!i || i === this.#r) {
|
|
3408
|
-
this.#
|
|
3593
|
+
this.#y();
|
|
3409
3594
|
return;
|
|
3410
3595
|
}
|
|
3411
3596
|
if (this.#r?.contains(i)) {
|
|
3412
|
-
this.#
|
|
3597
|
+
this.#y();
|
|
3413
3598
|
return;
|
|
3414
3599
|
}
|
|
3415
3600
|
const r = s.getBoundingClientRect(), a = t.clientY - r.top, n = r.height, o = i.querySelector(":scope > .ry-tree__toggle") !== null;
|
|
3416
3601
|
let l;
|
|
3417
|
-
o && a > n * 0.25 && a < n * 0.75 ? l = "inside" : a < n * 0.5 ? l = "before" : l = "after", this.#
|
|
3602
|
+
o && a > n * 0.25 && a < n * 0.75 ? l = "inside" : a < n * 0.5 ? l = "before" : l = "after", this.#v(i, l);
|
|
3418
3603
|
};
|
|
3419
3604
|
#g = () => {
|
|
3420
|
-
this.#e && this.#
|
|
3605
|
+
this.#e && this.#f(), this.#t = !1, this.#e = !1, this.#r = null;
|
|
3421
3606
|
};
|
|
3422
|
-
#
|
|
3607
|
+
#l(t) {
|
|
3423
3608
|
if (!this.#r) return;
|
|
3424
3609
|
t.preventDefault(), this.#r.setAttribute("data-ry-dragging", ""), this.#r.classList.add("ry-tree__item--collapsed");
|
|
3425
3610
|
const e = this.#r.querySelector(".ry-tree__label, .ry-tree__file");
|
|
@@ -3427,16 +3612,16 @@ class k extends u {
|
|
|
3427
3612
|
const s = e.cloneNode(!0);
|
|
3428
3613
|
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
3614
|
}
|
|
3430
|
-
#
|
|
3615
|
+
#f() {
|
|
3431
3616
|
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.#
|
|
3617
|
+
const t = this.#o, e = this.#c;
|
|
3618
|
+
this.#y(), this.#r && t && e && this.#M(this.#r, t, e);
|
|
3434
3619
|
}
|
|
3435
|
-
#
|
|
3436
|
-
this.#o === t && this.#
|
|
3620
|
+
#v(t, e) {
|
|
3621
|
+
this.#o === t && this.#c === e || (this.#y(), t.setAttribute("data-ry-drop-target", e), this.#o = t, this.#c = e);
|
|
3437
3622
|
}
|
|
3438
|
-
#
|
|
3439
|
-
this.#o?.removeAttribute("data-ry-drop-target"), this.#o = null, this.#
|
|
3623
|
+
#y() {
|
|
3624
|
+
this.#o?.removeAttribute("data-ry-drop-target"), this.#o = null, this.#c = null;
|
|
3440
3625
|
}
|
|
3441
3626
|
#M(t, e, s) {
|
|
3442
3627
|
if (s === "inside" && e.contains(t)) return;
|
|
@@ -3464,12 +3649,12 @@ class k extends u {
|
|
|
3464
3649
|
return e?.dataset.ryLabel ?? s?.dataset.ryLabel ?? "";
|
|
3465
3650
|
}
|
|
3466
3651
|
}
|
|
3467
|
-
class
|
|
3652
|
+
class wt extends u {
|
|
3468
3653
|
// Declarative container consumed by RyTree#build
|
|
3469
3654
|
}
|
|
3470
3655
|
customElements.define("ry-tree", k);
|
|
3471
|
-
customElements.define("ry-tree-item",
|
|
3472
|
-
class
|
|
3656
|
+
customElements.define("ry-tree-item", wt);
|
|
3657
|
+
class $t extends u {
|
|
3473
3658
|
setup() {
|
|
3474
3659
|
this.#t();
|
|
3475
3660
|
}
|
|
@@ -3490,8 +3675,8 @@ class At extends u {
|
|
|
3490
3675
|
return this.$('[data-ry-target="label"]')?.textContent?.trim() ?? "";
|
|
3491
3676
|
}
|
|
3492
3677
|
}
|
|
3493
|
-
customElements.define("ry-tag",
|
|
3494
|
-
class
|
|
3678
|
+
customElements.define("ry-tag", $t);
|
|
3679
|
+
class xt extends u {
|
|
3495
3680
|
#t = [];
|
|
3496
3681
|
setup() {
|
|
3497
3682
|
this.#e(), this.#i();
|
|
@@ -3526,7 +3711,7 @@ class kt extends u {
|
|
|
3526
3711
|
else if (t.key === "Tab")
|
|
3527
3712
|
return;
|
|
3528
3713
|
}
|
|
3529
|
-
t.key === "Backspace" && !e.value && this.#t.length > 0 && this.#
|
|
3714
|
+
t.key === "Backspace" && !e.value && this.#t.length > 0 && this.#c();
|
|
3530
3715
|
};
|
|
3531
3716
|
#r = (t) => {
|
|
3532
3717
|
t.preventDefault();
|
|
@@ -3538,7 +3723,7 @@ class kt extends u {
|
|
|
3538
3723
|
};
|
|
3539
3724
|
#a = (t) => {
|
|
3540
3725
|
const e = t.detail.value, s = this.#t.indexOf(e);
|
|
3541
|
-
s >= 0 && (this.#t.splice(s, 1), this.#
|
|
3726
|
+
s >= 0 && (this.#t.splice(s, 1), this.#h(), this.emit("change", { values: [...this.#t] }));
|
|
3542
3727
|
};
|
|
3543
3728
|
#o(t) {
|
|
3544
3729
|
const e = this.getAttribute("max-tags");
|
|
@@ -3549,16 +3734,16 @@ class kt extends u {
|
|
|
3549
3734
|
const i = document.createElement("ry-tag");
|
|
3550
3735
|
i.setAttribute("removable", ""), i.setAttribute("size", "sm"), i.setAttribute("data-value", t), i.textContent = t, s.appendChild(i);
|
|
3551
3736
|
}
|
|
3552
|
-
this.#
|
|
3737
|
+
this.#h(), this.emit("add", { value: t }), this.emit("change", { values: [...this.#t] });
|
|
3553
3738
|
}
|
|
3554
|
-
#
|
|
3739
|
+
#c() {
|
|
3555
3740
|
const e = this.$('[data-ry-target="tags"]')?.lastElementChild;
|
|
3556
3741
|
if (e) {
|
|
3557
3742
|
const s = e.dataset.value ?? "";
|
|
3558
|
-
e.remove(), this.#t.pop(), this.#
|
|
3743
|
+
e.remove(), this.#t.pop(), this.#h(), this.emit("remove", { value: s, label: s }), this.emit("change", { values: [...this.#t] });
|
|
3559
3744
|
}
|
|
3560
3745
|
}
|
|
3561
|
-
#
|
|
3746
|
+
#h() {
|
|
3562
3747
|
const t = this.$('[data-ry-target="hidden"]'), e = this.getAttribute("delimiter") ?? ",";
|
|
3563
3748
|
t && (t.value = this.#t.join(e));
|
|
3564
3749
|
}
|
|
@@ -3570,11 +3755,11 @@ class kt extends u {
|
|
|
3570
3755
|
return [...this.#t];
|
|
3571
3756
|
}
|
|
3572
3757
|
}
|
|
3573
|
-
customElements.define("ry-tag-input",
|
|
3574
|
-
class
|
|
3758
|
+
customElements.define("ry-tag-input", xt);
|
|
3759
|
+
class _t extends u {
|
|
3575
3760
|
}
|
|
3576
|
-
customElements.define("ry-hero",
|
|
3577
|
-
class
|
|
3761
|
+
customElements.define("ry-hero", _t);
|
|
3762
|
+
class Mt extends u {
|
|
3578
3763
|
setup() {
|
|
3579
3764
|
this.#t();
|
|
3580
3765
|
}
|
|
@@ -3587,8 +3772,8 @@ class $t extends u {
|
|
|
3587
3772
|
`;
|
|
3588
3773
|
}
|
|
3589
3774
|
}
|
|
3590
|
-
customElements.define("ry-stat",
|
|
3591
|
-
class
|
|
3775
|
+
customElements.define("ry-stat", Mt);
|
|
3776
|
+
class Et extends u {
|
|
3592
3777
|
setup() {
|
|
3593
3778
|
this.#t();
|
|
3594
3779
|
}
|
|
@@ -3602,17 +3787,17 @@ class xt extends u {
|
|
|
3602
3787
|
s.setAttribute("data-ry-target", "icon"), s.className = "ry-feature__icon", s.innerHTML = e, this.insertBefore(s, this.firstChild);
|
|
3603
3788
|
}
|
|
3604
3789
|
}
|
|
3605
|
-
class
|
|
3790
|
+
class Ct extends u {
|
|
3606
3791
|
}
|
|
3607
|
-
customElements.define("ry-feature",
|
|
3608
|
-
customElements.define("ry-feature-grid",
|
|
3609
|
-
class
|
|
3792
|
+
customElements.define("ry-feature", Et);
|
|
3793
|
+
customElements.define("ry-feature-grid", Ct);
|
|
3794
|
+
class St extends u {
|
|
3610
3795
|
}
|
|
3611
|
-
class
|
|
3796
|
+
class Tt extends u {
|
|
3612
3797
|
}
|
|
3613
|
-
customElements.define("ry-pricing",
|
|
3614
|
-
customElements.define("ry-pricing-card",
|
|
3615
|
-
class
|
|
3798
|
+
customElements.define("ry-pricing", St);
|
|
3799
|
+
customElements.define("ry-pricing-card", Tt);
|
|
3800
|
+
class Lt extends u {
|
|
3616
3801
|
#t = 0;
|
|
3617
3802
|
#e = 0;
|
|
3618
3803
|
#i = null;
|
|
@@ -3647,18 +3832,18 @@ class Et extends u {
|
|
|
3647
3832
|
}
|
|
3648
3833
|
this.appendChild(a);
|
|
3649
3834
|
}
|
|
3650
|
-
this.on(r, "pointerdown", this.#
|
|
3835
|
+
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
3836
|
}
|
|
3652
3837
|
#o = (t) => {
|
|
3653
3838
|
t.key === "ArrowLeft" ? (t.preventDefault(), this.prev()) : t.key === "ArrowRight" && (t.preventDefault(), this.next());
|
|
3654
3839
|
};
|
|
3655
|
-
#
|
|
3840
|
+
#c = (t) => {
|
|
3656
3841
|
this.#s = t.clientX, this.#r = !0, t.currentTarget.setPointerCapture(t.pointerId);
|
|
3657
3842
|
};
|
|
3658
|
-
#
|
|
3843
|
+
#h = (t) => {
|
|
3659
3844
|
this.#r && t.preventDefault();
|
|
3660
3845
|
};
|
|
3661
|
-
#
|
|
3846
|
+
#d = (t) => {
|
|
3662
3847
|
if (!this.#r) return;
|
|
3663
3848
|
this.#r = !1;
|
|
3664
3849
|
const e = t.clientX - this.#s, s = 50;
|
|
@@ -3692,50 +3877,53 @@ class Et extends u {
|
|
|
3692
3877
|
this.#p();
|
|
3693
3878
|
}
|
|
3694
3879
|
}
|
|
3695
|
-
customElements.define("ry-carousel",
|
|
3880
|
+
customElements.define("ry-carousel", Lt);
|
|
3696
3881
|
window.RyToast = f;
|
|
3697
3882
|
console.log("ry-ui loaded");
|
|
3698
3883
|
export {
|
|
3699
3884
|
R as RyAccordion,
|
|
3700
|
-
|
|
3885
|
+
U as RyAlert,
|
|
3701
3886
|
N as RyButton,
|
|
3702
|
-
|
|
3703
|
-
|
|
3704
|
-
|
|
3705
|
-
|
|
3706
|
-
|
|
3887
|
+
O as RyButtonGroup,
|
|
3888
|
+
z as RyCard,
|
|
3889
|
+
Lt as RyCarousel,
|
|
3890
|
+
st as RyCode,
|
|
3891
|
+
ft as RyColorInput,
|
|
3892
|
+
gt as RyColorPicker,
|
|
3893
|
+
J as RyDrawer,
|
|
3707
3894
|
j as RyDropdown,
|
|
3708
3895
|
u as RyElement,
|
|
3709
|
-
|
|
3710
|
-
|
|
3711
|
-
|
|
3712
|
-
|
|
3713
|
-
|
|
3714
|
-
|
|
3715
|
-
|
|
3716
|
-
|
|
3896
|
+
it as RyExample,
|
|
3897
|
+
Et as RyFeature,
|
|
3898
|
+
Ct as RyFeatureGrid,
|
|
3899
|
+
V as RyField,
|
|
3900
|
+
vt as RyGradientPicker,
|
|
3901
|
+
_t as RyHero,
|
|
3902
|
+
rt as RyIcon,
|
|
3903
|
+
ct as RyKnob,
|
|
3717
3904
|
P as RyModal,
|
|
3718
|
-
|
|
3719
|
-
|
|
3720
|
-
|
|
3721
|
-
|
|
3722
|
-
|
|
3723
|
-
|
|
3724
|
-
|
|
3905
|
+
dt as RyNumberSelect,
|
|
3906
|
+
St as RyPricing,
|
|
3907
|
+
Tt as RyPricingCard,
|
|
3908
|
+
tt as RySelect,
|
|
3909
|
+
lt as RySlider,
|
|
3910
|
+
K as RySplit,
|
|
3911
|
+
Mt as RyStat,
|
|
3912
|
+
Y as RySwitch,
|
|
3725
3913
|
F as RyTabs,
|
|
3726
|
-
|
|
3727
|
-
|
|
3728
|
-
|
|
3914
|
+
$t as RyTag,
|
|
3915
|
+
xt as RyTagInput,
|
|
3916
|
+
q as RyThemeToggle,
|
|
3729
3917
|
f as RyToast,
|
|
3730
|
-
|
|
3731
|
-
|
|
3918
|
+
ht as RyToggleButton,
|
|
3919
|
+
G as RyTooltip,
|
|
3732
3920
|
k as RyTree,
|
|
3733
|
-
|
|
3921
|
+
wt as RyTreeItem,
|
|
3734
3922
|
p as getIcon,
|
|
3735
|
-
|
|
3736
|
-
|
|
3737
|
-
|
|
3738
|
-
|
|
3923
|
+
Bt as getIconNames,
|
|
3924
|
+
C as processTransforms,
|
|
3925
|
+
It as registerIcon,
|
|
3926
|
+
Ht as registerIcons,
|
|
3739
3927
|
M as transform
|
|
3740
3928
|
};
|
|
3741
3929
|
//# sourceMappingURL=ry-ui.js.map
|