@ryanhelsing/ry-ui 1.0.1 → 1.0.2

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/dist/ry-ui.js CHANGED
@@ -1,4 +1,4 @@
1
- class d extends HTMLElement {
1
+ class p extends HTMLElement {
2
2
  // Store for cleanup functions
3
3
  #t = [];
4
4
  // Store for MutationObserver
@@ -89,7 +89,7 @@ class d extends HTMLElement {
89
89
  this.on(t, "keydown", a), i?.focus();
90
90
  }
91
91
  }
92
- const E = [
92
+ const D = [
93
93
  // Layout
94
94
  "page",
95
95
  "header",
@@ -132,26 +132,30 @@ const E = [
132
132
  "toggle-button",
133
133
  "slider",
134
134
  "knob",
135
+ "number-select",
135
136
  "color-picker",
136
- "color-input"
137
- ], S = new RegExp(
138
- `<(/?)(${E.join("|")})(\\s|>|/)`,
137
+ "color-input",
138
+ "gradient-picker",
139
+ "tree",
140
+ "tree-item"
141
+ ], B = new RegExp(
142
+ `<(/?)(${D.join("|")})(\\s|>|/)`,
139
143
  "g"
140
144
  );
141
- function k(o) {
142
- return o.replace(S, "<$1ry-$2$3");
145
+ function M(o) {
146
+ return o.replace(B, "<$1ry-$2$3");
143
147
  }
144
- function _() {
148
+ function C() {
145
149
  document.querySelectorAll("ry").forEach((o) => {
146
- const t = k(o.innerHTML), e = document.createElement("template");
150
+ const t = M(o.innerHTML), e = document.createElement("template");
147
151
  e.innerHTML = t, o.replaceWith(e.content);
148
152
  }), document.querySelectorAll("template[ry]").forEach((o) => {
149
- const t = k(o.innerHTML), e = document.createElement("template");
153
+ const t = M(o.innerHTML), e = document.createElement("template");
150
154
  e.innerHTML = t, o.replaceWith(e.content);
151
155
  });
152
156
  }
153
- document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", _) : _();
154
- class T extends d {
157
+ document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", C) : C();
158
+ class F extends p {
155
159
  setup() {
156
160
  this.#t(), this.$$('[data-ry-target="trigger"]').forEach((t) => {
157
161
  this.on(t, "click", this.#i);
@@ -227,10 +231,10 @@ class T extends d {
227
231
  this.$$('[data-ry-target="item"]').forEach((t) => this.close(t));
228
232
  }
229
233
  }
230
- customElements.define("ry-accordion", T);
234
+ customElements.define("ry-accordion", F);
231
235
  customElements.get("ry-accordion-item") || customElements.define("ry-accordion-item", class extends HTMLElement {
232
236
  });
233
- class H extends d {
237
+ class P extends p {
234
238
  #t = null;
235
239
  #e = 0;
236
240
  setup() {
@@ -279,8 +283,8 @@ class H extends d {
279
283
  this.state === "open" ? this.close() : this.open();
280
284
  }
281
285
  }
282
- customElements.define("ry-modal", H);
283
- class L extends d {
286
+ customElements.define("ry-modal", P);
287
+ class R extends p {
284
288
  setup() {
285
289
  this.#t(), this.$$('[data-ry-target="trigger"]').forEach((t) => {
286
290
  this.on(t, "click", this.#i);
@@ -291,8 +295,8 @@ class L extends d {
291
295
  if (t.length === 0) return;
292
296
  const e = t.findIndex((r) => r.hasAttribute("active")), s = e === -1 ? 0 : e, i = document.createElement("div");
293
297
  i.setAttribute("data-ry-target", "list"), i.className = "ry-tabs__list", i.setAttribute("role", "tablist"), t.forEach((r, a) => {
294
- const n = r.getAttribute("title") ?? `Tab ${a + 1}`, l = a === s, h = document.createElement("button");
295
- h.setAttribute("data-ry-target", "trigger"), h.className = "ry-tabs__trigger", h.setAttribute("role", "tab"), h.setAttribute("aria-selected", String(l)), h.textContent = n, i.appendChild(h), r.setAttribute("data-ry-target", "panel"), r.className = "ry-tabs__panel", r.setAttribute("role", "tabpanel"), r.dataset.ryState = l ? "active" : "", r.removeAttribute("title"), r.removeAttribute("active");
298
+ const n = r.getAttribute("title") ?? `Tab ${a + 1}`, h = a === s, l = document.createElement("button");
299
+ l.setAttribute("data-ry-target", "trigger"), l.className = "ry-tabs__trigger", l.setAttribute("role", "tab"), l.setAttribute("aria-selected", String(h)), l.textContent = n, i.appendChild(l), r.setAttribute("data-ry-target", "panel"), r.className = "ry-tabs__panel", r.setAttribute("role", "tabpanel"), r.dataset.ryState = h ? "active" : "", r.removeAttribute("title"), r.removeAttribute("active");
296
300
  }), this.insertBefore(i, this.firstChild);
297
301
  }
298
302
  #e() {
@@ -300,8 +304,8 @@ class L extends d {
300
304
  t.forEach((i, r) => {
301
305
  const a = e[r];
302
306
  if (!a) return;
303
- const n = i.id || `ry-tab-${this.id || ""}-${r}`, l = a.id || `ry-tabpanel-${this.id || ""}-${r}`;
304
- i.id = n, a.id = l, i.setAttribute("aria-controls", l), a.setAttribute("aria-labelledby", n), i.setAttribute("tabindex", i.getAttribute("aria-selected") === "true" ? "0" : "-1");
307
+ const n = i.id || `ry-tab-${this.id || ""}-${r}`, h = a.id || `ry-tabpanel-${this.id || ""}-${r}`;
308
+ i.id = n, a.id = h, i.setAttribute("aria-controls", h), a.setAttribute("aria-labelledby", n), i.setAttribute("tabindex", i.getAttribute("aria-selected") === "true" ? "0" : "-1");
305
309
  }), t.findIndex((i) => i.getAttribute("aria-selected") === "true") === -1 && t.length > 0 && this.select(0);
306
310
  }
307
311
  #i = (t) => {
@@ -342,10 +346,10 @@ class L extends d {
342
346
  return this.$$('[data-ry-target="trigger"]').findIndex((e) => e.getAttribute("aria-selected") === "true");
343
347
  }
344
348
  }
345
- customElements.define("ry-tabs", L);
349
+ customElements.define("ry-tabs", R);
346
350
  customElements.get("ry-tab") || customElements.define("ry-tab", class extends HTMLElement {
347
351
  });
348
- class I extends d {
352
+ class j extends p {
349
353
  setup() {
350
354
  this.#t();
351
355
  const t = this.$('[data-ry-target="trigger"]');
@@ -375,24 +379,30 @@ class I extends d {
375
379
  };
376
380
  open() {
377
381
  if (this.state === "open") return;
378
- this.$('[data-ry-target="trigger"]')?.setAttribute("aria-expanded", "true"), this.state = "open", this.nextFrame().then(() => {
382
+ this.#s(), this.$('[data-ry-target="trigger"]')?.setAttribute("aria-expanded", "true"), this.state = "open", this.nextFrame().then(() => {
379
383
  this.$('[data-ry-target="item"], ry-menu-item')?.focus();
380
384
  }), this.emit("open");
381
385
  }
382
386
  close() {
383
387
  if (this.state === "closed") return;
384
- this.$('[data-ry-target="trigger"]')?.setAttribute("aria-expanded", "false"), this.state = "closed", this.emit("close");
388
+ this.$('[data-ry-target="trigger"]')?.setAttribute("aria-expanded", "false"), this.state = "closed", this.removeAttribute("data-ry-position"), this.emit("close");
389
+ }
390
+ #s() {
391
+ const t = this.$('[data-ry-target="menu"], ry-menu');
392
+ if (!t) return;
393
+ const e = this.getBoundingClientRect(), s = t.scrollHeight || 240, i = window.innerHeight - e.bottom, r = e.top;
394
+ i < s && r > i ? this.setAttribute("data-ry-position", "top") : this.setAttribute("data-ry-position", "bottom");
385
395
  }
386
396
  toggle() {
387
397
  this.state === "open" ? this.close() : this.open();
388
398
  }
389
399
  }
390
- customElements.define("ry-dropdown", I);
400
+ customElements.define("ry-dropdown", j);
391
401
  customElements.get("ry-menu") || customElements.define("ry-menu", class extends HTMLElement {
392
402
  });
393
403
  customElements.get("ry-menu-item") || customElements.define("ry-menu-item", class extends HTMLElement {
394
404
  });
395
- class D extends d {
405
+ class O extends p {
396
406
  setup() {
397
407
  this.hasAttribute("tabindex") || this.setAttribute("tabindex", "0"), this.setAttribute("role", "button"), this.on(this, "click", this.#t), this.on(this, "keydown", this.#e);
398
408
  }
@@ -407,8 +417,8 @@ class D extends d {
407
417
  (t.key === "Enter" || t.key === " ") && (t.preventDefault(), this.click());
408
418
  };
409
419
  }
410
- customElements.define("ry-button", D);
411
- class F extends d {
420
+ customElements.define("ry-button", O);
421
+ class N extends p {
412
422
  #t = ["light", "dark"];
413
423
  #e = 0;
414
424
  setup() {
@@ -448,8 +458,8 @@ class F extends d {
448
458
  }
449
459
  }
450
460
  }
451
- customElements.define("ry-theme-toggle", F);
452
- class j extends d {
461
+ customElements.define("ry-theme-toggle", N);
462
+ class K extends p {
453
463
  setup() {
454
464
  this.#t();
455
465
  const t = this.$("[close]");
@@ -469,8 +479,8 @@ class j extends d {
469
479
  }, 200), this.emit("close");
470
480
  }
471
481
  }
472
- customElements.define("ry-alert", j);
473
- class B extends d {
482
+ customElements.define("ry-alert", K);
483
+ class q extends p {
474
484
  setup() {
475
485
  this.#t();
476
486
  }
@@ -486,9 +496,9 @@ class B extends d {
486
496
  i.setAttribute("data-ry-target", "label"), i.className = "ry-label", i.setAttribute("for", s), i.textContent = t, this.insertBefore(i, e);
487
497
  }
488
498
  }
489
- customElements.define("ry-field", B);
490
- let R = 0;
491
- class P extends d {
499
+ customElements.define("ry-field", q);
500
+ let U = 0;
501
+ class V extends p {
492
502
  #t = null;
493
503
  static observedAttributes = ["checked", "disabled"];
494
504
  setup() {
@@ -496,7 +506,7 @@ class P extends d {
496
506
  }
497
507
  #e() {
498
508
  if (this.$('[data-ry-target="track"]')) return;
499
- const t = `ry-switch-${++R}`, e = this.getAttribute("name") ?? "", s = this.hasAttribute("checked"), i = this.hasAttribute("disabled"), r = this.textContent?.trim() ?? "";
509
+ const t = `ry-switch-${++U}`, e = this.getAttribute("name") ?? "", s = this.hasAttribute("checked"), i = this.hasAttribute("disabled"), r = this.textContent?.trim() ?? "";
500
510
  this.innerHTML = `
501
511
  <label data-ry-target="wrapper" class="ry-switch__wrapper" for="${t}">
502
512
  <input
@@ -541,16 +551,16 @@ class P extends d {
541
551
  this.#t && (this.#t.value = t);
542
552
  }
543
553
  }
544
- customElements.define("ry-switch", P);
545
- let O = 0;
546
- class K extends d {
554
+ customElements.define("ry-switch", V);
555
+ let Y = 0;
556
+ class z extends p {
547
557
  #t = null;
548
558
  #e = null;
549
559
  #i = null;
550
560
  setup() {
551
- this.#i = `ry-tooltip-${++O}`, this.#s();
561
+ this.#i = `ry-tooltip-${++Y}`, this.#s();
552
562
  const t = this.firstElementChild;
553
- t && (t.setAttribute("aria-describedby", this.#i), this.on(t, "mouseenter", this.#r), this.on(t, "mouseleave", this.#l), this.on(t, "focusin", this.#r), this.on(t, "focusout", this.#l)), this.on(document, "keydown", this.#c);
563
+ t && (t.setAttribute("aria-describedby", this.#i), this.on(t, "mouseenter", this.#r), this.on(t, "mouseleave", this.#h), this.on(t, "focusin", this.#r), this.on(t, "focusout", this.#h)), this.on(document, "keydown", this.#l);
554
564
  }
555
565
  #s() {
556
566
  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);
@@ -564,18 +574,18 @@ class K extends d {
564
574
  const t = this.getAttribute("position") ?? "top";
565
575
  this.setAttribute("data-ry-position", t), this.state = "open";
566
576
  };
567
- #l = () => {
577
+ #h = () => {
568
578
  this.#t && (clearTimeout(this.#t), this.#t = null), this.state = "closed";
569
579
  };
570
- #c = (t) => {
571
- t.key === "Escape" && this.state === "open" && this.#l();
580
+ #l = (t) => {
581
+ t.key === "Escape" && this.state === "open" && this.#h();
572
582
  };
573
583
  teardown() {
574
584
  this.#t && clearTimeout(this.#t);
575
585
  }
576
586
  }
577
- customElements.define("ry-tooltip", K);
578
- class N extends d {
587
+ customElements.define("ry-tooltip", z);
588
+ class W extends p {
579
589
  #t = null;
580
590
  #e = 0;
581
591
  setup() {
@@ -620,38 +630,38 @@ class N extends d {
620
630
  this.state === "open" ? this.close() : this.open();
621
631
  }
622
632
  }
623
- customElements.define("ry-drawer", N);
624
- const U = 4e3;
625
- class p extends d {
633
+ customElements.define("ry-drawer", W);
634
+ const X = 4e3;
635
+ class f extends p {
626
636
  #t = null;
627
637
  static observedAttributes = ["variant", "duration"];
628
638
  // Static container for programmatic toasts
629
639
  static #e = null;
630
640
  static #i() {
631
- return p.#e || (p.#e = document.createElement("div"), p.#e.setAttribute("data-ry-target", "toast-container"), p.#e.className = "ry-toast-container", document.body.appendChild(p.#e)), p.#e;
641
+ return f.#e || (f.#e = document.createElement("div"), f.#e.setAttribute("data-ry-target", "toast-container"), f.#e.className = "ry-toast-container", document.body.appendChild(f.#e)), f.#e;
632
642
  }
633
643
  // Static API
634
644
  static show(t) {
635
645
  const e = document.createElement("ry-toast");
636
- return e.textContent = t.message, t.variant && e.setAttribute("variant", t.variant), t.duration !== void 0 && e.setAttribute("duration", String(t.duration)), p.#i().appendChild(e), e;
646
+ return e.textContent = t.message, t.variant && e.setAttribute("variant", t.variant), t.duration !== void 0 && e.setAttribute("duration", String(t.duration)), f.#i().appendChild(e), e;
637
647
  }
638
648
  static success(t, e) {
639
- return p.show({ message: t, variant: "success", duration: e });
649
+ return f.show({ message: t, variant: "success", duration: e });
640
650
  }
641
651
  static error(t, e) {
642
- return p.show({ message: t, variant: "error", duration: e });
652
+ return f.show({ message: t, variant: "error", duration: e });
643
653
  }
644
654
  static info(t, e) {
645
- return p.show({ message: t, variant: "info", duration: e });
655
+ return f.show({ message: t, variant: "info", duration: e });
646
656
  }
647
657
  static warning(t, e) {
648
- return p.show({ message: t, variant: "warning", duration: e });
658
+ return f.show({ message: t, variant: "warning", duration: e });
649
659
  }
650
660
  setup() {
651
661
  this.#s();
652
662
  const t = this.$("[close]");
653
663
  t && this.on(t, "click", () => this.dismiss());
654
- const e = parseInt(this.getAttribute("duration") ?? String(U), 10);
664
+ const e = parseInt(this.getAttribute("duration") ?? String(X), 10);
655
665
  e > 0 && (this.#t = setTimeout(() => this.dismiss(), e)), requestAnimationFrame(() => {
656
666
  this.state = "visible";
657
667
  });
@@ -683,9 +693,9 @@ class p extends d {
683
693
  this.#t && clearTimeout(this.#t);
684
694
  }
685
695
  }
686
- customElements.define("ry-toast", p);
687
- let W = 0;
688
- class V extends d {
696
+ customElements.define("ry-toast", f);
697
+ let G = 0;
698
+ class J extends p {
689
699
  #t = null;
690
700
  #e = -1;
691
701
  #i = "";
@@ -694,7 +704,7 @@ class V extends d {
694
704
  _options = [];
695
705
  static observedAttributes = ["value", "disabled"];
696
706
  setup() {
697
- this.#t = `ry-select-${++W}`, this.#r(), this.hasAttribute("tabindex") || this.setAttribute("tabindex", "0"), this.on(this, "click", this.#n), this.on(this, "keydown", this.#l), this.on(document, "click", this.#c), this.hasAttribute("data-ry-state") || (this.state = "closed");
707
+ this.#t = `ry-select-${++G}`, this.#r(), this.hasAttribute("tabindex") || this.setAttribute("tabindex", "0"), this.on(this, "click", this.#n), this.on(this, "keydown", this.#h), this.on(document, "click", this.#l), this.hasAttribute("data-ry-state") || (this.state = "closed");
698
708
  const t = this.getAttribute("value");
699
709
  t && (this.value = t);
700
710
  }
@@ -705,10 +715,10 @@ class V extends d {
705
715
  disabled: n.hasAttribute("disabled")
706
716
  })), e = this.getAttribute("placeholder") ?? "Select...", s = this.getAttribute("name") ?? "", i = this.hasAttribute("disabled"), r = t.map(
707
717
  (n) => `<option value="${n.value}"${n.disabled ? " disabled" : ""}>${n.label}</option>`
708
- ).join(""), a = t.map((n, l) => `
718
+ ).join(""), a = t.map((n, h) => `
709
719
  <div data-ry-target="option" class="ry-select__option"
710
720
  role="option"
711
- id="${this.#t}-option-${l}"
721
+ id="${this.#t}-option-${h}"
712
722
  data-value="${n.value}"
713
723
  ${n.disabled ? "data-disabled" : ""}
714
724
  aria-disabled="${n.disabled}">
@@ -733,12 +743,12 @@ class V extends d {
733
743
  if (this.hasAttribute("disabled")) return;
734
744
  const e = t.target, s = e.closest('[data-ry-target="option"]');
735
745
  if (s instanceof HTMLElement && !s.hasAttribute("data-disabled")) {
736
- this.#o(s), this.close();
746
+ this.#f(s), this.close();
737
747
  return;
738
748
  }
739
749
  e.closest('[data-ry-target="trigger"]') && this.toggle();
740
750
  };
741
- #l = (t) => {
751
+ #h = (t) => {
742
752
  if (this.hasAttribute("disabled")) return;
743
753
  const e = this.state === "open";
744
754
  switch (t.key) {
@@ -746,7 +756,7 @@ class V extends d {
746
756
  case " ":
747
757
  if (t.preventDefault(), e && this.#e >= 0) {
748
758
  const i = this.$$('[data-ry-target="option"]:not([data-disabled])')[this.#e];
749
- i && (this.#o(i), this.close());
759
+ i && (this.#f(i), this.close());
750
760
  } else
751
761
  this.toggle();
752
762
  break;
@@ -754,43 +764,43 @@ class V extends d {
754
764
  e && (t.preventDefault(), this.close());
755
765
  break;
756
766
  case "ArrowDown":
757
- t.preventDefault(), e ? this.#u() : this.open();
767
+ t.preventDefault(), e ? this.#a() : this.open();
758
768
  break;
759
769
  case "ArrowUp":
760
- t.preventDefault(), e && this.#f();
770
+ t.preventDefault(), e && this.#u();
761
771
  break;
762
772
  case "Home":
763
- e && (t.preventDefault(), this.#b());
773
+ e && (t.preventDefault(), this.#g());
764
774
  break;
765
775
  case "End":
766
- e && (t.preventDefault(), this.#g());
776
+ e && (t.preventDefault(), this.#m());
767
777
  break;
768
778
  default:
769
- t.key.length === 1 && !t.ctrlKey && !t.metaKey && this.#p(t.key);
779
+ t.key.length === 1 && !t.ctrlKey && !t.metaKey && this.#d(t.key);
770
780
  break;
771
781
  }
772
782
  };
773
- #c = (t) => {
783
+ #l = (t) => {
774
784
  const e = t.target;
775
785
  !this.contains(e) && this.state === "open" && this.close();
776
786
  };
777
- #p(t) {
787
+ #d(t) {
778
788
  this.#s && clearTimeout(this.#s), this.#i += t.toLowerCase();
779
789
  const e = this.$$('[data-ry-target="option"]:not([data-disabled])'), s = e.findIndex(
780
790
  (i) => i.textContent?.trim().toLowerCase().startsWith(this.#i)
781
791
  );
782
792
  if (s >= 0)
783
793
  if (this.state === "open")
784
- this.#a(s);
794
+ this.#o(s);
785
795
  else {
786
796
  const i = e[s];
787
- i && this.#o(i);
797
+ i && this.#f(i);
788
798
  }
789
799
  this.#s = setTimeout(() => {
790
800
  this.#i = "";
791
801
  }, 500);
792
802
  }
793
- #a(t) {
803
+ #o(t) {
794
804
  const e = this.$$('[data-ry-target="option"]:not([data-disabled])');
795
805
  if (t < 0 || t >= e.length) return;
796
806
  this.$$('[data-ry-target="option"][data-highlighted]').forEach((r) => {
@@ -802,22 +812,22 @@ class V extends d {
802
812
  const i = this.$('[data-ry-target="trigger"]');
803
813
  i && i.setAttribute("aria-activedescendant", s.id);
804
814
  }
805
- #u() {
815
+ #a() {
806
816
  const t = this.$$('[data-ry-target="option"]:not([data-disabled])'), e = Math.min(this.#e + 1, t.length - 1);
807
- this.#a(e);
817
+ this.#o(e);
808
818
  }
809
- #f() {
819
+ #u() {
810
820
  const t = Math.max(this.#e - 1, 0);
811
- this.#a(t);
812
- }
813
- #b() {
814
- this.#a(0);
821
+ this.#o(t);
815
822
  }
816
823
  #g() {
824
+ this.#o(0);
825
+ }
826
+ #m() {
817
827
  const t = this.$$('[data-ry-target="option"]:not([data-disabled])');
818
- this.#a(t.length - 1);
828
+ this.#o(t.length - 1);
819
829
  }
820
- #o(t) {
830
+ #f(t) {
821
831
  const e = t.dataset.value ?? "", s = t.textContent?.trim() ?? "", i = this.$('[data-ry-target="value"]');
822
832
  i && (i.textContent = s, i.setAttribute("data-selected", ""));
823
833
  const r = this.$('[data-ry-target="native"]');
@@ -829,16 +839,16 @@ class V extends d {
829
839
  if (this.state === "open") return;
830
840
  this.state = "open";
831
841
  const t = this.$('[data-ry-target="trigger"]');
832
- t && t.setAttribute("aria-expanded", "true"), this.#w();
842
+ t && t.setAttribute("aria-expanded", "true"), this.#A();
833
843
  const e = this.getAttribute("value");
834
844
  if (e) {
835
845
  const i = this.$$('[data-ry-target="option"]:not([data-disabled])').findIndex((r) => r.dataset.value === e);
836
- i >= 0 && this.#a(i);
846
+ i >= 0 && this.#o(i);
837
847
  } else
838
- this.#a(0);
848
+ this.#o(0);
839
849
  this.emit("open");
840
850
  }
841
- #w() {
851
+ #A() {
842
852
  const t = this.$('[data-ry-target="dropdown"]');
843
853
  if (!t) return;
844
854
  this.removeAttribute("data-ry-position");
@@ -861,17 +871,17 @@ class V extends d {
861
871
  }
862
872
  set value(t) {
863
873
  const e = this.$(`[data-ry-target="option"][data-value="${t}"]`);
864
- e && this.#o(e);
874
+ e && this.#f(e);
865
875
  }
866
876
  teardown() {
867
877
  this.#s && clearTimeout(this.#s);
868
878
  }
869
879
  }
870
- class q extends HTMLElement {
880
+ class Z extends HTMLElement {
871
881
  }
872
- customElements.define("ry-option", q);
873
- customElements.define("ry-select", V);
874
- const v = {
882
+ customElements.define("ry-option", Z);
883
+ customElements.define("ry-select", J);
884
+ const A = {
875
885
  // Close / X
876
886
  close: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M18 6L6 18"/><path d="M6 6l12 12"/></svg>',
877
887
  // Chevron down
@@ -923,28 +933,44 @@ const v = {
923
933
  // Download
924
934
  download: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/></svg>',
925
935
  // Upload
926
- upload: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4"/><polyline points="17 8 12 3 7 8"/><line x1="12" y1="3" x2="12" y2="15"/></svg>'
936
+ upload: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4"/><polyline points="17 8 12 3 7 8"/><line x1="12" y1="3" x2="12" y2="15"/></svg>',
937
+ // Folder (closed)
938
+ folder: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.93a2 2 0 0 1-1.66-.9l-.82-1.2A2 2 0 0 0 7.93 2H4a2 2 0 0 0-2 2v13c0 1.1.9 2 2 2Z"/></svg>',
939
+ // Folder open
940
+ "folder-open": '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.93a2 2 0 0 1-1.66-.9l-.82-1.2A2 2 0 0 0 7.93 2H4a2 2 0 0 0-2 2v13c0 1.1.9 2 2 2Z"/><path d="M2 10h20"/></svg>',
941
+ // File
942
+ file: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z"/><polyline points="14 2 14 8 20 8"/></svg>',
943
+ // Gradient: solid color
944
+ "gradient-solid": '<svg width="24" height="24" viewBox="0 0 24 24" fill="currentColor" stroke="none"><rect x="4" y="4" width="16" height="16" rx="2"/></svg>',
945
+ // Gradient: linear
946
+ "gradient-linear": '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="2"/><line x1="3" y1="21" x2="21" y2="3"/><line x1="3" y1="15" x2="15" y2="3"/><line x1="9" y1="21" x2="21" y2="9"/></svg>',
947
+ // Gradient: radial
948
+ "gradient-radial": '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="2"/><circle cx="12" cy="12" r="3"/><circle cx="12" cy="12" r="6.5"/></svg>',
949
+ // Shape: circle
950
+ "shape-circle": '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="9"/></svg>',
951
+ // Shape: ellipse
952
+ "shape-ellipse": '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><ellipse cx="12" cy="12" rx="10" ry="6"/></svg>'
927
953
  };
928
- function y(o) {
929
- return v[o] ?? "";
954
+ function g(o) {
955
+ return A[o] ?? "";
930
956
  }
931
- function ot(o, t) {
932
- v[o] = t;
957
+ function kt(o, t) {
958
+ A[o] = t;
933
959
  }
934
- function ht(o) {
935
- Object.assign(v, o);
960
+ function At(o) {
961
+ Object.assign(A, o);
936
962
  }
937
- function lt() {
938
- return Object.keys(v);
963
+ function $t() {
964
+ return Object.keys(A);
939
965
  }
940
- class z extends d {
966
+ class Q extends p {
941
967
  #t = "";
942
968
  static get observedAttributes() {
943
969
  return ["language", "title", "line-numbers"];
944
970
  }
945
971
  setup() {
946
972
  const t = this.querySelector("template");
947
- t ? this.#t = this.#u(t.innerHTML) : this.#t = this.textContent?.trim() ?? "", this.#e();
973
+ t ? this.#t = this.#a(t.innerHTML) : this.#t = this.textContent?.trim() ?? "", this.#e();
948
974
  const e = this.$('[data-ry-target="copy"]');
949
975
  e && this.on(e, "click", this.#i);
950
976
  }
@@ -955,7 +981,7 @@ class z extends d {
955
981
  <div data-ry-target="header" class="ry-code__header">
956
982
  <span data-ry-target="title" class="ry-code__title">${e}</span>
957
983
  <button data-ry-target="copy" class="ry-code__copy" type="button" aria-label="Copy code">
958
- ${y("copy")}
984
+ ${g("copy")}
959
985
  </button>
960
986
  </div>
961
987
  <div data-ry-target="content" class="ry-code__content">
@@ -967,8 +993,8 @@ class z extends d {
967
993
  const t = this.$('[data-ry-target="copy"]');
968
994
  if (t)
969
995
  try {
970
- await navigator.clipboard.writeText(this.#t), t.innerHTML = y("check"), t.classList.add("ry-code__copy--success"), this.emit("copy", { code: this.#t }), setTimeout(() => {
971
- t.innerHTML = y("copy"), t.classList.remove("ry-code__copy--success");
996
+ await navigator.clipboard.writeText(this.#t), t.innerHTML = g("check"), t.classList.add("ry-code__copy--success"), this.emit("copy", { code: this.#t }), setTimeout(() => {
997
+ t.innerHTML = g("copy"), t.classList.remove("ry-code__copy--success");
972
998
  }, 2e3);
973
999
  } catch {
974
1000
  this.emit("copy-error");
@@ -982,11 +1008,11 @@ class z extends d {
982
1008
  case "javascript":
983
1009
  return this.#n(t);
984
1010
  case "html":
985
- return this.#l(t);
1011
+ return this.#h(t);
986
1012
  case "json":
987
- return this.#c(t);
1013
+ return this.#l(t);
988
1014
  default:
989
- return this.#a(t);
1015
+ return this.#o(t);
990
1016
  }
991
1017
  }
992
1018
  #r(t) {
@@ -994,9 +1020,9 @@ class z extends d {
994
1020
  let s = t;
995
1021
  for (; s.length > 0; ) {
996
1022
  if (s.startsWith("/*")) {
997
- const b = s.indexOf("*/");
998
- if (b !== -1) {
999
- e.push({ type: "comment", value: s.slice(0, b + 2) }), s = s.slice(b + 2);
1023
+ const m = s.indexOf("*/");
1024
+ if (m !== -1) {
1025
+ e.push({ type: "comment", value: s.slice(0, m + 2) }), s = s.slice(m + 2);
1000
1026
  continue;
1001
1027
  }
1002
1028
  }
@@ -1020,14 +1046,14 @@ class z extends d {
1020
1046
  e.push({ type: "color", value: n[1], color: n[1] }), s = s.slice(n[1].length);
1021
1047
  continue;
1022
1048
  }
1023
- const l = s.match(/^(-?[\d.]+(?:px|em|rem|%|vh|vw|deg|s|ms)?)/);
1024
- if (l?.[1]) {
1025
- e.push({ type: "number", value: l[1] }), s = s.slice(l[1].length);
1049
+ const h = s.match(/^(-?[\d.]+(?:px|em|rem|%|vh|vw|deg|s|ms)?)/);
1050
+ if (h?.[1]) {
1051
+ e.push({ type: "number", value: h[1] }), s = s.slice(h[1].length);
1026
1052
  continue;
1027
1053
  }
1028
- const h = s.match(/^(['"])((?:[^\\]|\\.)*?)\1/);
1029
- if (h) {
1030
- e.push({ type: "string", value: h[0] }), s = s.slice(h[0].length);
1054
+ const l = s.match(/^(['"])((?:[^\\]|\\.)*?)\1/);
1055
+ if (l) {
1056
+ e.push({ type: "string", value: l[0] }), s = s.slice(l[0].length);
1031
1057
  continue;
1032
1058
  }
1033
1059
  const c = s[0];
@@ -1035,21 +1061,21 @@ class z extends d {
1035
1061
  e.push({ type: "punctuation", value: c }), s = s.slice(1);
1036
1062
  continue;
1037
1063
  }
1038
- const u = s.match(/^(\s+)/);
1039
- if (u?.[1]) {
1040
- e.push({ type: "text", value: u[1] }), s = s.slice(u[1].length);
1064
+ const d = s.match(/^(\s+)/);
1065
+ if (d?.[1]) {
1066
+ e.push({ type: "text", value: d[1] }), s = s.slice(d[1].length);
1041
1067
  continue;
1042
1068
  }
1043
- const $ = s.match(/^([\w-]+)/);
1044
- if ($?.[1]) {
1045
- const b = $[1];
1046
- ["inherit", "initial", "unset", "none", "auto", "transparent", "solid", "dashed", "dotted", "flex", "grid", "block", "inline", "inline-block", "absolute", "relative", "fixed", "sticky"].includes(b) ? e.push({ type: "keyword", value: b }) : e.push({ type: "value", value: b }), s = s.slice(b.length);
1069
+ const u = s.match(/^([\w-]+)/);
1070
+ if (u?.[1]) {
1071
+ const m = u[1];
1072
+ ["inherit", "initial", "unset", "none", "auto", "transparent", "solid", "dashed", "dotted", "flex", "grid", "block", "inline", "inline-block", "absolute", "relative", "fixed", "sticky"].includes(m) ? e.push({ type: "keyword", value: m }) : e.push({ type: "value", value: m }), s = s.slice(m.length);
1047
1073
  continue;
1048
1074
  }
1049
- const x = s[0];
1050
- x && e.push({ type: "text", value: x }), s = s.slice(1);
1075
+ const b = s[0];
1076
+ b && e.push({ type: "text", value: b }), s = s.slice(1);
1051
1077
  }
1052
- return e.map((i) => this.#p(i)).join("");
1078
+ return e.map((i) => this.#d(i)).join("");
1053
1079
  }
1054
1080
  #n(t) {
1055
1081
  const e = [];
@@ -1057,10 +1083,10 @@ class z extends d {
1057
1083
  const i = ["const", "let", "var", "function", "return", "if", "else", "for", "while", "do", "switch", "case", "break", "continue", "try", "catch", "finally", "throw", "new", "class", "extends", "import", "export", "default", "from", "async", "await", "typeof", "instanceof", "in", "of", "true", "false", "null", "undefined", "this", "super", "static", "get", "set"];
1058
1084
  for (; s.length > 0; ) {
1059
1085
  if (s.startsWith("//")) {
1060
- const u = s.indexOf(`
1086
+ const d = s.indexOf(`
1061
1087
  `);
1062
- if (u !== -1) {
1063
- e.push({ type: "comment", value: s.slice(0, u) }), s = s.slice(u);
1088
+ if (d !== -1) {
1089
+ e.push({ type: "comment", value: s.slice(0, d) }), s = s.slice(d);
1064
1090
  continue;
1065
1091
  } else {
1066
1092
  e.push({ type: "comment", value: s });
@@ -1068,9 +1094,9 @@ class z extends d {
1068
1094
  }
1069
1095
  }
1070
1096
  if (s.startsWith("/*")) {
1071
- const u = s.indexOf("*/");
1072
- if (u !== -1) {
1073
- e.push({ type: "comment", value: s.slice(0, u + 2) }), s = s.slice(u + 2);
1097
+ const d = s.indexOf("*/");
1098
+ if (d !== -1) {
1099
+ e.push({ type: "comment", value: s.slice(0, d + 2) }), s = s.slice(d + 2);
1074
1100
  continue;
1075
1101
  }
1076
1102
  }
@@ -1086,26 +1112,26 @@ class z extends d {
1086
1112
  }
1087
1113
  const n = s.match(/^([a-zA-Z_$][\w$]*)/);
1088
1114
  if (n?.[1]) {
1089
- const u = n[1];
1090
- i.includes(u) ? e.push({ type: "keyword", value: u }) : e.push({ type: "text", value: u }), s = s.slice(u.length);
1115
+ const d = n[1];
1116
+ i.includes(d) ? e.push({ type: "keyword", value: d }) : e.push({ type: "text", value: d }), s = s.slice(d.length);
1091
1117
  continue;
1092
1118
  }
1093
- const l = s[0];
1094
- if (l && /^[{}[\]();,.:?!<>=+\-*/&|^%~@#]/.test(l)) {
1095
- e.push({ type: "punctuation", value: l }), s = s.slice(1);
1119
+ const h = s[0];
1120
+ if (h && /^[{}[\]();,.:?!<>=+\-*/&|^%~@#]/.test(h)) {
1121
+ e.push({ type: "punctuation", value: h }), s = s.slice(1);
1096
1122
  continue;
1097
1123
  }
1098
- const h = s.match(/^(\s+)/);
1099
- if (h?.[1]) {
1100
- e.push({ type: "text", value: h[1] }), s = s.slice(h[1].length);
1124
+ const l = s.match(/^(\s+)/);
1125
+ if (l?.[1]) {
1126
+ e.push({ type: "text", value: l[1] }), s = s.slice(l[1].length);
1101
1127
  continue;
1102
1128
  }
1103
1129
  const c = s[0];
1104
1130
  c && e.push({ type: "text", value: c }), s = s.slice(1);
1105
1131
  }
1106
- return e.map((r) => this.#p(r)).join("");
1132
+ return e.map((r) => this.#d(r)).join("");
1107
1133
  }
1108
- #l(t) {
1134
+ #h(t) {
1109
1135
  const e = [];
1110
1136
  let s = t;
1111
1137
  for (; s.length > 0; ) {
@@ -1141,17 +1167,17 @@ class z extends d {
1141
1167
  e.push({ type: "text", value: n[1] }), s = s.slice(n[1].length);
1142
1168
  continue;
1143
1169
  }
1144
- const l = s.match(/^([^<]+)/);
1145
- if (l?.[1]) {
1146
- e.push({ type: "text", value: l[1] }), s = s.slice(l[1].length);
1170
+ const h = s.match(/^([^<]+)/);
1171
+ if (h?.[1]) {
1172
+ e.push({ type: "text", value: h[1] }), s = s.slice(h[1].length);
1147
1173
  continue;
1148
1174
  }
1149
- const h = s[0];
1150
- h && e.push({ type: "text", value: h }), s = s.slice(1);
1175
+ const l = s[0];
1176
+ l && e.push({ type: "text", value: l }), s = s.slice(1);
1151
1177
  }
1152
- return e.map((i) => this.#p(i)).join("");
1178
+ return e.map((i) => this.#d(i)).join("");
1153
1179
  }
1154
- #c(t) {
1180
+ #l(t) {
1155
1181
  const e = [];
1156
1182
  let s = t;
1157
1183
  for (; s.length > 0; ) {
@@ -1175,18 +1201,18 @@ class z extends d {
1175
1201
  e.push({ type: "punctuation", value: n }), s = s.slice(1);
1176
1202
  continue;
1177
1203
  }
1178
- const l = s.match(/^(\s+)/);
1179
- if (l?.[1]) {
1180
- e.push({ type: "text", value: l[1] }), s = s.slice(l[1].length);
1204
+ const h = s.match(/^(\s+)/);
1205
+ if (h?.[1]) {
1206
+ e.push({ type: "text", value: h[1] }), s = s.slice(h[1].length);
1181
1207
  continue;
1182
1208
  }
1183
- const h = s[0];
1184
- h && e.push({ type: "text", value: h }), s = s.slice(1);
1209
+ const l = s[0];
1210
+ l && e.push({ type: "text", value: l }), s = s.slice(1);
1185
1211
  }
1186
- return e.map((i) => this.#p(i)).join("");
1212
+ return e.map((i) => this.#d(i)).join("");
1187
1213
  }
1188
- #p(t) {
1189
- const e = this.#a(t.value);
1214
+ #d(t) {
1215
+ const e = this.#o(t.value);
1190
1216
  switch (t.type) {
1191
1217
  case "keyword":
1192
1218
  return `<span class="ry-code__keyword">${e}</span>`;
@@ -1214,10 +1240,10 @@ class z extends d {
1214
1240
  return e;
1215
1241
  }
1216
1242
  }
1217
- #a(t) {
1243
+ #o(t) {
1218
1244
  return t.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#039;");
1219
1245
  }
1220
- #u(t) {
1246
+ #a(t) {
1221
1247
  const e = t.split(`
1222
1248
  `);
1223
1249
  for (; e.length && !e[0]?.trim(); ) e.shift();
@@ -1236,12 +1262,12 @@ class z extends d {
1236
1262
  this.#t = t, this.#e();
1237
1263
  }
1238
1264
  }
1239
- customElements.define("ry-code", z);
1240
- class Y extends d {
1265
+ customElements.define("ry-code", Q);
1266
+ class tt extends p {
1241
1267
  setup() {
1242
1268
  const t = this.$("template");
1243
1269
  if (!t) return;
1244
- const e = this.$('script[slot="js"]'), s = e ? this.#e(e.textContent ?? "") : null, i = this.#e(t.innerHTML), r = k(i), a = this.hasAttribute("stacked");
1270
+ const e = this.$('script[slot="js"]'), s = e ? this.#e(e.textContent ?? "") : null, i = this.#e(t.innerHTML), r = M(i), a = this.hasAttribute("stacked");
1245
1271
  this.innerHTML = `
1246
1272
  <div data-ry-target="preview" class="ry-example__preview"></div>
1247
1273
  <div data-ry-target="code" class="ry-example__code"></div>
@@ -1249,8 +1275,8 @@ class Y extends d {
1249
1275
  `, a && this.setAttribute("data-stacked", "");
1250
1276
  const n = document.createElement("ry-code");
1251
1277
  n.setAttribute("language", "html"), n.setAttribute("title", this.getAttribute("title") ?? "Example"), n.textContent = i, this.$('[data-ry-target="code"]').appendChild(n);
1252
- const l = document.createElement("template");
1253
- l.innerHTML = r, this.$('[data-ry-target="preview"]').appendChild(l.content), s && this.#t(s);
1278
+ const h = document.createElement("template");
1279
+ h.innerHTML = r, this.$('[data-ry-target="preview"]').appendChild(h.content), s && this.#t(s);
1254
1280
  }
1255
1281
  #t(t) {
1256
1282
  const e = this.$('[data-ry-target="usage"]');
@@ -1281,8 +1307,8 @@ class Y extends d {
1281
1307
  `).trim();
1282
1308
  }
1283
1309
  }
1284
- customElements.define("ry-example", Y);
1285
- class G extends d {
1310
+ customElements.define("ry-example", tt);
1311
+ class et extends p {
1286
1312
  static get observedAttributes() {
1287
1313
  return ["name", "size", "label"];
1288
1314
  }
@@ -1293,7 +1319,7 @@ class G extends d {
1293
1319
  e !== s && this.hasAttribute("data-ry-initialized") && this.#t();
1294
1320
  }
1295
1321
  #t() {
1296
- const t = this.getAttribute("name") ?? "", e = this.getAttribute("size") ?? "24", s = this.getAttribute("label"), i = y(t);
1322
+ const t = this.getAttribute("name") ?? "", e = this.getAttribute("size") ?? "24", s = this.getAttribute("label"), i = g(t);
1297
1323
  if (!i) {
1298
1324
  this.innerHTML = "";
1299
1325
  return;
@@ -1315,24 +1341,24 @@ class G extends d {
1315
1341
  this.setAttribute("size", String(t));
1316
1342
  }
1317
1343
  }
1318
- customElements.define("ry-icon", G);
1319
- const X = ["form", "section", "fieldset", "ry-section"], g = /* @__PURE__ */ new Map(), A = /* @__PURE__ */ new Set();
1320
- function J(o) {
1344
+ customElements.define("ry-icon", et);
1345
+ const st = ["form", "section", "fieldset", "ry-section"], y = /* @__PURE__ */ new Map(), E = /* @__PURE__ */ new Set();
1346
+ function it(o) {
1321
1347
  let t = o.parentElement;
1322
1348
  for (; t; ) {
1323
- if (X.some((e) => t.matches(e)))
1349
+ if (st.some((e) => t.matches(e)))
1324
1350
  return t;
1325
1351
  t = t.parentElement;
1326
1352
  }
1327
1353
  return null;
1328
1354
  }
1329
- function Z(o) {
1330
- if (A.has(o)) return;
1331
- const t = g.get(o);
1355
+ function rt(o) {
1356
+ if (E.has(o)) return;
1357
+ const t = y.get(o);
1332
1358
  if (!t || t.size < 2) return;
1333
1359
  const e = /* @__PURE__ */ new Map();
1334
1360
  for (const s of t) {
1335
- const i = J(s), r = e.get(i) ?? [];
1361
+ const i = it(s), r = e.get(i) ?? [];
1336
1362
  r.push(s), e.set(i, r);
1337
1363
  }
1338
1364
  if (e.size > 1) {
@@ -1345,10 +1371,10 @@ function Z(o) {
1345
1371
  s.push("(no container)");
1346
1372
  console.warn(
1347
1373
  `ry-toggle-button: Buttons with name="${o}" span multiple containers (${s.join(", ")}). Intentional?`
1348
- ), A.add(o);
1374
+ ), E.add(o);
1349
1375
  }
1350
1376
  }
1351
- class Q extends d {
1377
+ class at extends p {
1352
1378
  static observedAttributes = ["pressed", "disabled", "name", "value"];
1353
1379
  #t = !1;
1354
1380
  setup() {
@@ -1359,12 +1385,12 @@ class Q extends d {
1359
1385
  }
1360
1386
  #e() {
1361
1387
  const t = this.name;
1362
- t && (g.has(t) || g.set(t, /* @__PURE__ */ new Set()), g.get(t).add(this), this.#t = !0, queueMicrotask(() => Z(t)));
1388
+ t && (y.has(t) || y.set(t, /* @__PURE__ */ new Set()), y.get(t).add(this), this.#t = !0, queueMicrotask(() => rt(t)));
1363
1389
  }
1364
1390
  #i() {
1365
1391
  if (!this.#t) return;
1366
1392
  const t = this.name;
1367
- t && g.has(t) && (g.get(t).delete(this), g.get(t).size === 0 && (g.delete(t), A.delete(t))), this.#t = !1;
1393
+ t && y.has(t) && (y.get(t).delete(this), y.get(t).size === 0 && (y.delete(t), E.delete(t))), this.#t = !1;
1368
1394
  }
1369
1395
  #s = (t) => {
1370
1396
  if (this.disabled) {
@@ -1379,7 +1405,7 @@ class Q extends d {
1379
1405
  #n() {
1380
1406
  const t = this.name;
1381
1407
  if (!t) return;
1382
- const e = g.get(t);
1408
+ const e = y.get(t);
1383
1409
  if (e)
1384
1410
  for (const s of e)
1385
1411
  s !== this && s.pressed && (s.pressed = !1);
@@ -1420,8 +1446,8 @@ class Q extends d {
1420
1446
  this.setAttribute("icon", t);
1421
1447
  }
1422
1448
  }
1423
- customElements.define("ry-toggle-button", Q);
1424
- class tt extends d {
1449
+ customElements.define("ry-toggle-button", at);
1450
+ class nt extends p {
1425
1451
  #t = !1;
1426
1452
  #e = null;
1427
1453
  #i = null;
@@ -1430,9 +1456,9 @@ class tt extends d {
1430
1456
  #n = /* @__PURE__ */ new Map();
1431
1457
  static observedAttributes = ["min", "max", "step", "value", "start", "end", "disabled"];
1432
1458
  setup() {
1433
- this.#l(), this.#p(), this.#k();
1459
+ this.#h(), this.#d(), this.#y();
1434
1460
  }
1435
- #l() {
1461
+ #h() {
1436
1462
  const t = this.hasAttribute("range"), e = this.hasAttribute("labeled"), s = this.hasAttribute("tooltip");
1437
1463
  this.hasAttribute("vertical");
1438
1464
  let i = `
@@ -1450,20 +1476,20 @@ class tt extends d {
1450
1476
  <div data-ry-target="thumb-value" class="ry-slider__thumb" tabindex="0" role="slider" aria-label="Value">
1451
1477
  ${s ? '<span data-ry-target="tooltip-value" class="ry-slider__tooltip"></span>' : ""}
1452
1478
  </div>
1453
- `, 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.#n.set("start", this.$('[data-ry-target="tooltip-start"]')), this.#n.set("end", this.$('[data-ry-target="tooltip-end"]')))) : (this.#r.set("value", this.$('[data-ry-target="thumb-value"]')), s && this.#n.set("value", this.$('[data-ry-target="tooltip-value"]')));
1479
+ `, i += "</div>", e && (i += this.#l()), 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.#n.set("start", this.$('[data-ry-target="tooltip-start"]')), this.#n.set("end", this.$('[data-ry-target="tooltip-end"]')))) : (this.#r.set("value", this.$('[data-ry-target="thumb-value"]')), s && this.#n.set("value", this.$('[data-ry-target="tooltip-value"]')));
1454
1480
  }
1455
- #c() {
1481
+ #l() {
1456
1482
  const t = this.min, e = this.max, s = this.getAttribute("labels")?.split(","), i = this.getAttribute("label-type") || "number";
1457
1483
  let r = [];
1458
1484
  if (s)
1459
1485
  r = s;
1460
1486
  else
1461
1487
  for (let n = 0; n < 5; n++) {
1462
- const l = n / 4, h = t + l * (e - t);
1488
+ const h = n / 4, l = t + h * (e - t);
1463
1489
  if (i === "letter")
1464
1490
  r.push(String.fromCharCode(65 + n));
1465
1491
  else {
1466
- const c = Math.round(h * 100) / 100;
1492
+ const c = Math.round(l * 100) / 100;
1467
1493
  r.push(String(Number.isInteger(c) ? c : c.toFixed(1)));
1468
1494
  }
1469
1495
  }
@@ -1473,34 +1499,34 @@ class tt extends d {
1473
1499
  </div>
1474
1500
  `;
1475
1501
  }
1476
- #p() {
1477
- this.#i && this.on(this.#i, "pointerdown", this.#a);
1502
+ #d() {
1503
+ this.#i && this.on(this.#i, "pointerdown", this.#o);
1478
1504
  for (const [t, e] of this.#r)
1479
- this.on(e, "pointerdown", (s) => this.#u(s, t)), this.on(e, "keydown", (s) => this.#g(s, t));
1480
- this.on(document, "pointermove", this.#f), this.on(document, "pointerup", this.#b);
1505
+ this.on(e, "pointerdown", (s) => this.#a(s, t)), this.on(e, "keydown", (s) => this.#m(s, t));
1506
+ this.on(document, "pointermove", this.#u), this.on(document, "pointerup", this.#g);
1481
1507
  }
1482
- #a = (t) => {
1508
+ #o = (t) => {
1483
1509
  if (this.disabled) return;
1484
- const e = this.#w(t);
1510
+ const e = this.#A(t);
1485
1511
  if (this.hasAttribute("range")) {
1486
1512
  const i = Math.abs(e - this.start), r = Math.abs(e - this.end);
1487
1513
  i < r ? (this.start = e, this.#e = "start") : (this.end = e, this.#e = "end");
1488
1514
  } else
1489
1515
  this.value = e, this.#e = "value";
1490
- this.#t = !0, this.#k(), this.#m();
1516
+ this.#t = !0, this.#y(), this.#b();
1491
1517
  };
1492
- #u = (t, e) => {
1518
+ #a = (t, e) => {
1493
1519
  this.disabled || (t.stopPropagation(), this.#t = !0, this.#e = e, t.target.setPointerCapture(t.pointerId));
1494
1520
  };
1495
- #f = (t) => {
1521
+ #u = (t) => {
1496
1522
  if (!this.#t || !this.#e) return;
1497
- const e = this.#w(t);
1498
- this.hasAttribute("range") ? this.#e === "start" ? this.start = Math.min(e, this.end) : this.#e === "end" && (this.end = Math.max(e, this.start)) : this.value = e, this.#k(), this.#m();
1523
+ const e = this.#A(t);
1524
+ 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.#y(), this.#b();
1499
1525
  };
1500
- #b = () => {
1501
- this.#t && (this.#t = !1, this.#e = null, this.#x());
1526
+ #g = () => {
1527
+ this.#t && (this.#t = !1, this.#e = null, this.#S());
1502
1528
  };
1503
- #g = (t, e) => {
1529
+ #m = (t, e) => {
1504
1530
  if (this.disabled) return;
1505
1531
  const s = this.step || 1, i = (this.max - this.min) / 10;
1506
1532
  let r = 0;
@@ -1520,66 +1546,66 @@ class tt extends d {
1520
1546
  r = -i;
1521
1547
  break;
1522
1548
  case "Home":
1523
- r = this.min - this.#o(e);
1549
+ r = this.min - this.#f(e);
1524
1550
  break;
1525
1551
  case "End":
1526
- r = this.max - this.#o(e);
1552
+ r = this.max - this.#f(e);
1527
1553
  break;
1528
1554
  default:
1529
1555
  return;
1530
1556
  }
1531
1557
  t.preventDefault();
1532
- const a = this.#d(this.#o(e) + r);
1533
- e === "start" ? this.start = Math.min(a, this.end) : e === "end" ? this.end = Math.max(a, this.start) : this.value = a, this.#k(), this.#m(), this.#x();
1558
+ const a = this.#p(this.#f(e) + r);
1559
+ e === "start" ? this.start = Math.min(a, this.end) : e === "end" ? this.end = Math.max(a, this.start) : this.value = a, this.#y(), this.#b(), this.#S();
1534
1560
  };
1535
- #o(t) {
1561
+ #f(t) {
1536
1562
  return t === "start" ? this.start : t === "end" ? this.end : this.value;
1537
1563
  }
1538
- #w(t) {
1564
+ #A(t) {
1539
1565
  if (!this.#i) return this.min;
1540
1566
  const e = this.#i.getBoundingClientRect(), s = this.hasAttribute("vertical"), i = this.hasAttribute("reversed");
1541
1567
  let r;
1542
1568
  s ? r = (e.bottom - t.clientY) / e.height : r = (t.clientX - e.left) / e.width, i && (r = 1 - r), r = Math.max(0, Math.min(1, r));
1543
1569
  const a = this.min + r * (this.max - this.min);
1544
- return this.#h(a);
1570
+ return this.#c(a);
1545
1571
  }
1546
- #h(t) {
1572
+ #c(t) {
1547
1573
  const e = this.step;
1548
- if (e === 0) return this.#d(t);
1574
+ if (e === 0) return this.#p(t);
1549
1575
  const s = Math.round((t - this.min) / e) * e + this.min;
1550
- return this.#d(s);
1576
+ return this.#p(s);
1551
1577
  }
1552
- #d(t) {
1578
+ #p(t) {
1553
1579
  return Math.max(this.min, Math.min(this.max, t));
1554
1580
  }
1555
- #k() {
1581
+ #y() {
1556
1582
  const t = this.hasAttribute("range"), e = this.hasAttribute("vertical"), s = this.hasAttribute("reversed"), i = (r) => {
1557
1583
  let a = (r - this.min) / (this.max - this.min) * 100;
1558
1584
  return s && (a = 100 - a), a;
1559
1585
  };
1560
1586
  if (t) {
1561
- const r = i(this.start), a = i(this.end), n = Math.min(r, a), l = Math.max(r, a);
1562
- this.#s && (e ? (this.#s.style.bottom = `${n}%`, this.#s.style.height = `${l - n}%`, this.#s.style.left = "", this.#s.style.width = "") : (this.#s.style.left = `${n}%`, this.#s.style.width = `${l - n}%`, this.#s.style.bottom = "", this.#s.style.height = ""));
1563
- const h = this.#r.get("start"), c = this.#r.get("end");
1564
- h && (e ? (h.style.bottom = `${r}%`, h.style.left = "") : (h.style.left = `${r}%`, h.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), h?.setAttribute("aria-valuenow", String(this.start)), h?.setAttribute("aria-valuemin", String(this.min)), h?.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));
1587
+ const r = i(this.start), a = i(this.end), n = Math.min(r, a), h = Math.max(r, a);
1588
+ this.#s && (e ? (this.#s.style.bottom = `${n}%`, this.#s.style.height = `${h - n}%`, this.#s.style.left = "", this.#s.style.width = "") : (this.#s.style.left = `${n}%`, this.#s.style.width = `${h - n}%`, this.#s.style.bottom = "", this.#s.style.height = ""));
1589
+ const l = this.#r.get("start"), c = this.#r.get("end");
1590
+ 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.#w("start", this.start), this.#w("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));
1565
1591
  } else {
1566
1592
  const r = i(this.value);
1567
1593
  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 = ""));
1568
1594
  const a = this.#r.get("value");
1569
- 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));
1595
+ a && (e ? (a.style.bottom = `${r}%`, a.style.left = "") : (a.style.left = `${r}%`, a.style.bottom = "")), this.#w("value", this.value), a?.setAttribute("aria-valuenow", String(this.value)), a?.setAttribute("aria-valuemin", String(this.min)), a?.setAttribute("aria-valuemax", String(this.max));
1570
1596
  }
1571
1597
  }
1572
- #v(t, e) {
1598
+ #w(t, e) {
1573
1599
  const s = this.#n.get(t);
1574
1600
  if (s) {
1575
1601
  const i = this.step === 0 ? 2 : String(this.step).split(".")[1]?.length || 0;
1576
1602
  s.textContent = e.toFixed(i);
1577
1603
  }
1578
1604
  }
1579
- #m() {
1605
+ #b() {
1580
1606
  this.hasAttribute("range") ? this.emit("input", { start: this.start, end: this.end }) : this.emit("input", { value: this.value });
1581
1607
  }
1582
- #x() {
1608
+ #S() {
1583
1609
  this.hasAttribute("range") ? this.emit("change", { start: this.start, end: this.end }) : this.emit("change", { value: this.value });
1584
1610
  }
1585
1611
  // --- Public API ---
@@ -1605,19 +1631,19 @@ class tt extends d {
1605
1631
  return parseFloat(this.getAttribute("value") ?? String(this.min));
1606
1632
  }
1607
1633
  set value(t) {
1608
- this.setAttribute("value", String(this.#d(t)));
1634
+ this.setAttribute("value", String(this.#p(t)));
1609
1635
  }
1610
1636
  get start() {
1611
1637
  return parseFloat(this.getAttribute("start") ?? String(this.min));
1612
1638
  }
1613
1639
  set start(t) {
1614
- this.setAttribute("start", String(this.#d(t)));
1640
+ this.setAttribute("start", String(this.#p(t)));
1615
1641
  }
1616
1642
  get end() {
1617
1643
  return parseFloat(this.getAttribute("end") ?? String(this.max));
1618
1644
  }
1619
1645
  set end(t) {
1620
- this.setAttribute("end", String(this.#d(t)));
1646
+ this.setAttribute("end", String(this.#p(t)));
1621
1647
  }
1622
1648
  get disabled() {
1623
1649
  return this.hasAttribute("disabled");
@@ -1626,8 +1652,8 @@ class tt extends d {
1626
1652
  t ? this.setAttribute("disabled", "") : this.removeAttribute("disabled");
1627
1653
  }
1628
1654
  }
1629
- customElements.define("ry-slider", tt);
1630
- class et extends d {
1655
+ customElements.define("ry-slider", nt);
1656
+ class ot extends p {
1631
1657
  #t = !1;
1632
1658
  #e = 0;
1633
1659
  #i = 0;
@@ -1636,9 +1662,9 @@ class et extends d {
1636
1662
  #n = null;
1637
1663
  static observedAttributes = ["min", "max", "step", "value", "disabled", "label", "labels", "description"];
1638
1664
  setup() {
1639
- this.#l(), this.#c(), this.#d();
1665
+ this.#h(), this.#l(), this.#p();
1640
1666
  }
1641
- #l() {
1667
+ #h() {
1642
1668
  const t = this.getAttribute("label"), e = this.getAttribute("description"), s = e ? ` title="${e}"` : "";
1643
1669
  this.innerHTML = `
1644
1670
  <div data-ry-target="ring" class="ry-knob__ring"${s}>
@@ -1650,41 +1676,41 @@ class et extends d {
1650
1676
  ${t ? `<span data-ry-target="label" class="ry-knob__label"${s}>${t}</span>` : ""}
1651
1677
  `, this.#s = this.$('[data-ry-target="ring"]'), this.#r = this.$('[data-ry-target="indicator"]'), this.#n = this.$('[data-ry-target="display"]');
1652
1678
  }
1653
- #c() {
1654
- this.#s && (this.on(this.#s, "mousedown", this.#p), this.on(document, "mousemove", this.#a), this.on(document, "mouseup", this.#u), this.on(this.#s, "touchstart", this.#f), this.on(document, "touchmove", this.#b), this.on(document, "touchend", this.#g), this.on(this.#s, "wheel", this.#o), this.on(this, "keydown", this.#w));
1679
+ #l() {
1680
+ this.#s && (this.on(this.#s, "mousedown", this.#d), this.on(document, "mousemove", this.#o), this.on(document, "mouseup", this.#a), this.on(this.#s, "touchstart", this.#u), this.on(document, "touchmove", this.#g), this.on(document, "touchend", this.#m), this.on(this.#s, "wheel", this.#f), this.on(this, "keydown", this.#A));
1655
1681
  }
1656
- #p = (t) => {
1682
+ #d = (t) => {
1657
1683
  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", ""));
1658
1684
  };
1659
- #a = (t) => {
1685
+ #o = (t) => {
1660
1686
  if (!this.#t) return;
1661
1687
  const e = this.#e - t.clientY, s = (this.max - this.min) / 100;
1662
- this.#h(this.#i + e * s);
1688
+ this.#c(this.#i + e * s);
1663
1689
  };
1664
- #u = () => {
1665
- this.#t && (this.#t = !1, this.#s?.classList.remove("ry-knob__ring--dragging"), this.removeAttribute("data-dragging"), this.#m());
1690
+ #a = () => {
1691
+ this.#t && (this.#t = !1, this.#s?.classList.remove("ry-knob__ring--dragging"), this.removeAttribute("data-dragging"), this.#b());
1666
1692
  };
1667
- #f = (t) => {
1693
+ #u = (t) => {
1668
1694
  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", ""));
1669
1695
  };
1670
- #b = (t) => {
1696
+ #g = (t) => {
1671
1697
  if (!this.#t) return;
1672
1698
  t.preventDefault();
1673
1699
  const e = t.touches[0];
1674
1700
  if (!e) return;
1675
1701
  const s = this.#e - e.clientY, i = (this.max - this.min) / 100;
1676
- this.#h(this.#i + s * i);
1702
+ this.#c(this.#i + s * i);
1677
1703
  };
1678
- #g = () => {
1679
- this.#t && (this.#t = !1, this.#s?.classList.remove("ry-knob__ring--dragging"), this.removeAttribute("data-dragging"), this.#m());
1704
+ #m = () => {
1705
+ this.#t && (this.#t = !1, this.#s?.classList.remove("ry-knob__ring--dragging"), this.removeAttribute("data-dragging"), this.#b());
1680
1706
  };
1681
- #o = (t) => {
1707
+ #f = (t) => {
1682
1708
  if (this.disabled) return;
1683
1709
  t.preventDefault();
1684
1710
  const e = this.step || (this.max - this.min) / 50, s = t.deltaY < 0 ? e : -e;
1685
- this.#h(this.value + s), this.#m();
1711
+ this.#c(this.value + s), this.#b();
1686
1712
  };
1687
- #w = (t) => {
1713
+ #A = (t) => {
1688
1714
  if (this.disabled) return;
1689
1715
  const e = this.step || 1, s = (this.max - this.min) / 10;
1690
1716
  let i = 0;
@@ -1704,26 +1730,26 @@ class et extends d {
1704
1730
  i = -s;
1705
1731
  break;
1706
1732
  case "Home":
1707
- this.#h(this.min), this.#m();
1733
+ this.#c(this.min), this.#b();
1708
1734
  return;
1709
1735
  case "End":
1710
- this.#h(this.max), this.#m();
1736
+ this.#c(this.max), this.#b();
1711
1737
  return;
1712
1738
  default:
1713
1739
  return;
1714
1740
  }
1715
- t.preventDefault(), this.#h(this.value + i), this.#m();
1741
+ t.preventDefault(), this.#c(this.value + i), this.#b();
1716
1742
  };
1717
- #h(t) {
1743
+ #c(t) {
1718
1744
  let e = Math.max(this.min, Math.min(this.max, t));
1719
1745
  const s = this.step;
1720
- 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.#d(), this.#v();
1746
+ 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.#p(), this.#w();
1721
1747
  }
1722
- #d() {
1748
+ #p() {
1723
1749
  const t = (this.value - this.min) / (this.max - this.min), e = -135 + t * 270;
1724
- this.#s && (this.#s.style.setProperty("--knob-rotation", `${e}deg`), this.#s.style.setProperty("--knob-percent", String(t))), this.#n && (this.#n.textContent = this.#k(this.value)), this.setAttribute("aria-valuenow", String(this.value)), this.setAttribute("aria-valuemin", String(this.min)), this.setAttribute("aria-valuemax", String(this.max));
1750
+ this.#s && (this.#s.style.setProperty("--knob-rotation", `${e}deg`), this.#s.style.setProperty("--knob-percent", String(t))), this.#n && (this.#n.textContent = this.#y(this.value)), this.setAttribute("aria-valuenow", String(this.value)), this.setAttribute("aria-valuemin", String(this.min)), this.setAttribute("aria-valuemax", String(this.max));
1725
1751
  }
1726
- #k(t) {
1752
+ #y(t) {
1727
1753
  const e = this.getAttribute("labels");
1728
1754
  if (e) {
1729
1755
  const i = e.split(","), r = Math.round(t);
@@ -1731,16 +1757,16 @@ class et extends d {
1731
1757
  }
1732
1758
  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);
1733
1759
  }
1734
- #v() {
1760
+ #w() {
1735
1761
  const t = (this.value - this.min) / (this.max - this.min);
1736
1762
  this.emit("input", { value: this.value, percent: t });
1737
1763
  }
1738
- #m() {
1764
+ #b() {
1739
1765
  const t = (this.value - this.min) / (this.max - this.min);
1740
1766
  this.emit("change", { value: this.value, percent: t });
1741
1767
  }
1742
1768
  attributeChangedCallback(t, e, s) {
1743
- e !== s && t === "value" && this.#s && this.#d();
1769
+ e !== s && t === "value" && this.#s && this.#p();
1744
1770
  }
1745
1771
  // --- Public API ---
1746
1772
  get min() {
@@ -1774,29 +1800,280 @@ class et extends d {
1774
1800
  t ? this.setAttribute("disabled", "") : this.removeAttribute("disabled");
1775
1801
  }
1776
1802
  }
1777
- customElements.define("ry-knob", et);
1778
- function f(o) {
1803
+ customElements.define("ry-knob", ot);
1804
+ const S = 15, T = 3;
1805
+ class ht extends p {
1806
+ #t = null;
1807
+ #e = null;
1808
+ #i = null;
1809
+ #s = null;
1810
+ #r = null;
1811
+ #n = !1;
1812
+ #h = 0;
1813
+ #l = 0;
1814
+ #d = 0;
1815
+ #o = !1;
1816
+ #a = null;
1817
+ #u = null;
1818
+ static observedAttributes = ["min", "max", "step", "value", "disabled", "arrows", "icons", "drag", "editable", "wrap", "label", "prefix", "suffix"];
1819
+ setup() {
1820
+ this.#g(), this.#f(), this.#A(), this.#v();
1821
+ }
1822
+ #g() {
1823
+ const t = this.getAttribute("arrows") ?? "both", e = this.getAttribute("label"), s = t === "stacked", [i, r] = this.#m(s), a = t === "both" || t === "start" || s, n = t === "both" || t === "end" || s, h = 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>` : "", u = `
1824
+ <div data-ry-target="display" class="ry-number-select__display" tabindex="0" role="spinbutton"
1825
+ aria-valuenow="${this.value}" aria-valuemin="${this.min}" aria-valuemax="${this.max}"
1826
+ ${e ? `aria-label="${e}"` : ""}>
1827
+ ${h ? `<span data-ry-target="prefix" class="ry-number-select__affix">${h}</span>` : ""}
1828
+ <span data-ry-target="value" class="ry-number-select__value">${this.#j(this.value)}</span>
1829
+ ${l ? `<span data-ry-target="suffix" class="ry-number-select__affix">${l}</span>` : ""}
1830
+ <input data-ry-target="input" class="ry-number-select__input" type="text" inputmode="decimal" tabindex="-1">
1831
+ </div>`, b = e ? `<span data-ry-target="label" class="ry-number-select__label">${e}</span>` : "";
1832
+ s ? this.innerHTML = `${d}${u}${c}${b}` : this.innerHTML = `${c}${u}${d}${b}`;
1833
+ }
1834
+ #m(t) {
1835
+ const e = this.getAttribute("icons") ?? "plus-minus";
1836
+ return e === "chevron" ? t ? [g("chevron-down") ?? "▾", g("chevron-up") ?? "▴"] : [g("chevron-left") ?? "‹", g("chevron-right") ?? "›"] : e === "arrow" ? t ? [g("chevron-down") ?? "▼", g("chevron-up") ?? "▲"] : [g("chevron-left") ?? "◀", g("chevron-right") ?? "▶"] : [g("minus") ?? "−", g("plus") ?? "+"];
1837
+ }
1838
+ #f() {
1839
+ 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"]');
1840
+ }
1841
+ #A() {
1842
+ this.#s && (this.on(this.#s, "mousedown", (t) => {
1843
+ t.preventDefault(), this.#c(-1);
1844
+ }), this.on(this.#s, "mouseup", () => this.#p()), this.on(this.#s, "mouseleave", () => this.#p())), this.#r && (this.on(this.#r, "mousedown", (t) => {
1845
+ t.preventDefault(), this.#c(1);
1846
+ }), this.on(this.#r, "mouseup", () => this.#p()), this.on(this.#r, "mouseleave", () => this.#p())), this.#t && this.on(this.#t, "mousedown", this.#F), this.on(document, "mousemove", this.#W), this.on(document, "mouseup", this.#E), 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.#_()), this.#i && (this.on(this.#i, "blur", () => this.#U()), this.on(this.#i, "keydown", (t) => {
1847
+ t.key === "Enter" && (t.preventDefault(), this.#U()), t.key === "Escape" && (t.preventDefault(), this.#P()), t.stopPropagation();
1848
+ }));
1849
+ }
1850
+ // --- Button hold-to-repeat ---
1851
+ #c(t) {
1852
+ if (this.disabled) return;
1853
+ const e = this.step || 1;
1854
+ this.#B(t * e), this.#x(), this.#a = setTimeout(() => {
1855
+ let s = 150;
1856
+ const i = () => {
1857
+ this.#B(t * e), this.#$(), s = Math.max(40, s * 0.85), this.#u = setTimeout(i, s);
1858
+ };
1859
+ i();
1860
+ }, 400);
1861
+ }
1862
+ #p() {
1863
+ this.#a && (clearTimeout(this.#a), this.#a = null), this.#u && (clearTimeout(this.#u), this.#u = null);
1864
+ }
1865
+ // --- Drag helpers ---
1866
+ get #y() {
1867
+ const t = this.getAttribute("drag");
1868
+ return t === "x" || t === "y" || t === "none" ? t : this.getAttribute("arrows") === "stacked" ? "y" : "x";
1869
+ }
1870
+ #w(t, e) {
1871
+ return this.#y === "y" ? this.#l - e : t - this.#h;
1872
+ }
1873
+ #b(t, e) {
1874
+ return this.#y === "y" ? Math.abs(e - this.#l) : Math.abs(t - this.#h);
1875
+ }
1876
+ #S(t, e) {
1877
+ if (!this.#e) return;
1878
+ const s = t / e * 4, i = this.#y;
1879
+ this.#e.style.transform = i === "y" ? `translateY(${-s}px)` : `translateX(${s}px)`;
1880
+ }
1881
+ #M(t, e, s) {
1882
+ const i = this.#w(t, e), r = this.step || 1, a = s ? r * 10 : r, n = s ? S * 2 : S, h = Math.round(i / n), l = this.#d + h * a, c = i - h * n;
1883
+ this.#S(c, n);
1884
+ const d = this.hasAttribute("wrap") ? this.#V(l) : this.#T(l), u = this.#R(d);
1885
+ u !== this.value && (this.value = u, this.#v(), this.#$());
1886
+ }
1887
+ // --- Mouse drag ---
1888
+ #F = (t) => {
1889
+ this.disabled || this.#o || this.#y === "none" || (t.preventDefault(), this.#n = !0, this.#h = t.clientX, this.#l = t.clientY, this.#d = this.value, this.setAttribute("data-dragging", ""));
1890
+ };
1891
+ #W = (t) => {
1892
+ this.#n && this.#M(t.clientX, t.clientY, t.shiftKey);
1893
+ };
1894
+ #E = (t) => {
1895
+ if (!this.#n) return;
1896
+ const e = this.#b(t.clientX, t.clientY);
1897
+ this.#n = !1, this.removeAttribute("data-dragging"), this.#e && (this.#e.style.transform = ""), e < T && this.hasAttribute("editable") ? this.#_() : e >= T && this.#x();
1898
+ };
1899
+ // --- Touch drag ---
1900
+ #X = (t) => {
1901
+ this.disabled || this.#o || this.#y === "none" || (t.preventDefault(), this.#n = !0, this.#h = t.touches[0]?.clientX ?? 0, this.#l = t.touches[0]?.clientY ?? 0, this.#d = this.value, this.setAttribute("data-dragging", ""));
1902
+ };
1903
+ #G = (t) => {
1904
+ if (!this.#n) return;
1905
+ t.preventDefault();
1906
+ const e = t.touches[0];
1907
+ e && this.#M(e.clientX, e.clientY, !1);
1908
+ };
1909
+ #K = () => {
1910
+ this.#n && (this.#n = !1, this.removeAttribute("data-dragging"), this.#e && (this.#e.style.transform = ""), this.#x());
1911
+ };
1912
+ // --- Keyboard ---
1913
+ #q = (t) => {
1914
+ if (this.disabled || this.#o) return;
1915
+ const e = this.step || 1, s = e * 10;
1916
+ let i = 0;
1917
+ switch (t.key) {
1918
+ case "ArrowUp":
1919
+ case "ArrowRight":
1920
+ i = t.shiftKey ? s : e;
1921
+ break;
1922
+ case "ArrowDown":
1923
+ case "ArrowLeft":
1924
+ i = -(t.shiftKey ? s : e);
1925
+ break;
1926
+ case "PageUp":
1927
+ i = s;
1928
+ break;
1929
+ case "PageDown":
1930
+ i = -s;
1931
+ break;
1932
+ case "Home":
1933
+ i = this.min - this.value;
1934
+ break;
1935
+ case "End":
1936
+ i = this.max - this.value;
1937
+ break;
1938
+ case "Enter":
1939
+ this.hasAttribute("editable") && this.#_();
1940
+ return;
1941
+ default:
1942
+ this.hasAttribute("editable") && /^[0-9.\-]$/.test(t.key) && (this.#_(t.key), t.preventDefault());
1943
+ return;
1944
+ }
1945
+ t.preventDefault(), this.#B(i), this.#$(), this.#x();
1946
+ };
1947
+ // --- Wheel ---
1948
+ #J = (t) => {
1949
+ if (this.disabled || this.#o || !this.matches(":hover") && !this.contains(document.activeElement)) return;
1950
+ t.preventDefault();
1951
+ const e = this.step || 1, s = t.shiftKey ? e * 10 : e, i = t.deltaY < 0 ? s : -s;
1952
+ this.#B(i), this.#$(), this.#x();
1953
+ };
1954
+ // --- Edit mode ---
1955
+ #_(t) {
1956
+ this.disabled || this.#o || (this.#o = !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()));
1957
+ }
1958
+ #U() {
1959
+ if (!this.#o) return;
1960
+ this.#o = !1, this.state = "";
1961
+ const t = parseFloat(this.#i?.value ?? "");
1962
+ if (!isNaN(t)) {
1963
+ const e = this.#T(t), s = this.#R(e);
1964
+ this.value = s, this.#x();
1965
+ }
1966
+ this.#e && (this.#e.style.display = ""), this.#i && (this.#i.style.display = "none"), this.#v(), this.#t?.focus();
1967
+ }
1968
+ #P() {
1969
+ this.#o && (this.#o = !1, this.state = "", this.#e && (this.#e.style.display = ""), this.#i && (this.#i.style.display = "none"), this.#t?.focus());
1970
+ }
1971
+ // --- Value management ---
1972
+ #B(t) {
1973
+ let e = this.value + t;
1974
+ this.hasAttribute("wrap") ? e = this.#V(e) : e = this.#T(e), e = this.#R(e), this.value = e, this.#v();
1975
+ }
1976
+ #T(t) {
1977
+ return Math.max(this.min, Math.min(this.max, t));
1978
+ }
1979
+ #V(t) {
1980
+ const e = this.step || 1, s = this.max - this.min + e;
1981
+ let i = t;
1982
+ for (; i > this.max; ) i -= s;
1983
+ for (; i < this.min; ) i += s;
1984
+ return i;
1985
+ }
1986
+ #R(t) {
1987
+ const e = this.step;
1988
+ if (e <= 0) return this.#T(t);
1989
+ const s = Math.round((t - this.min) / e) * e + this.min;
1990
+ return this.#T(s);
1991
+ }
1992
+ #j(t) {
1993
+ const e = this.step;
1994
+ if (e >= 1) return Math.round(t).toString();
1995
+ const s = Math.max(0, -Math.floor(Math.log10(e)));
1996
+ return t.toFixed(s);
1997
+ }
1998
+ #v() {
1999
+ this.#e && (this.#e.textContent = this.#j(this.value)), this.#Y();
2000
+ }
2001
+ #Y() {
2002
+ 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)));
2003
+ }
2004
+ #$() {
2005
+ this.emit("input", { value: this.value });
2006
+ }
2007
+ #x() {
2008
+ this.emit("change", { value: this.value });
2009
+ }
2010
+ // --- Public API ---
2011
+ get value() {
2012
+ return parseFloat(this.getAttribute("value") ?? "0");
2013
+ }
2014
+ set value(t) {
2015
+ this.setAttribute("value", String(t));
2016
+ }
2017
+ get min() {
2018
+ return parseFloat(this.getAttribute("min") ?? "0");
2019
+ }
2020
+ set min(t) {
2021
+ this.setAttribute("min", String(t));
2022
+ }
2023
+ get max() {
2024
+ return parseFloat(this.getAttribute("max") ?? "100");
2025
+ }
2026
+ set max(t) {
2027
+ this.setAttribute("max", String(t));
2028
+ }
2029
+ get step() {
2030
+ return parseFloat(this.getAttribute("step") ?? "1");
2031
+ }
2032
+ set step(t) {
2033
+ this.setAttribute("step", String(t));
2034
+ }
2035
+ get drag() {
2036
+ return this.#y;
2037
+ }
2038
+ set drag(t) {
2039
+ this.setAttribute("drag", t);
2040
+ }
2041
+ get disabled() {
2042
+ return this.hasAttribute("disabled");
2043
+ }
2044
+ set disabled(t) {
2045
+ t ? this.setAttribute("disabled", "") : this.removeAttribute("disabled");
2046
+ }
2047
+ attributeChangedCallback(t, e, s) {
2048
+ e !== s && t === "value" && this.#t && this.#v();
2049
+ }
2050
+ teardown() {
2051
+ this.#p();
2052
+ }
2053
+ }
2054
+ customElements.define("ry-number-select", ht);
2055
+ function v(o) {
1779
2056
  const t = o.h / 360, e = o.s / 100, s = o.v / 100;
1780
2057
  let i = 0, r = 0, a = 0;
1781
- const n = Math.floor(t * 6), l = t * 6 - n, h = s * (1 - e), c = s * (1 - l * e), u = s * (1 - (1 - l) * e);
2058
+ const n = Math.floor(t * 6), h = t * 6 - n, l = s * (1 - e), c = s * (1 - h * e), d = s * (1 - (1 - h) * e);
1782
2059
  switch (n % 6) {
1783
2060
  case 0:
1784
- i = s, r = u, a = h;
2061
+ i = s, r = d, a = l;
1785
2062
  break;
1786
2063
  case 1:
1787
- i = c, r = s, a = h;
2064
+ i = c, r = s, a = l;
1788
2065
  break;
1789
2066
  case 2:
1790
- i = h, r = s, a = u;
2067
+ i = l, r = s, a = d;
1791
2068
  break;
1792
2069
  case 3:
1793
- i = h, r = c, a = s;
2070
+ i = l, r = c, a = s;
1794
2071
  break;
1795
2072
  case 4:
1796
- i = u, r = h, a = s;
2073
+ i = d, r = l, a = s;
1797
2074
  break;
1798
2075
  case 5:
1799
- i = s, r = h, a = c;
2076
+ i = s, r = l, a = c;
1800
2077
  break;
1801
2078
  }
1802
2079
  return {
@@ -1805,10 +2082,10 @@ function f(o) {
1805
2082
  b: Math.round(a * 255)
1806
2083
  };
1807
2084
  }
1808
- function w(o) {
2085
+ function $(o) {
1809
2086
  const t = o.r / 255, e = o.g / 255, s = o.b / 255, i = Math.max(t, e, s), r = Math.min(t, e, s), a = i - r;
1810
2087
  let n = 0;
1811
- const l = i === 0 ? 0 : a / i, h = i;
2088
+ const h = i === 0 ? 0 : a / i, l = i;
1812
2089
  if (i !== r)
1813
2090
  switch (i) {
1814
2091
  case t:
@@ -1823,11 +2100,11 @@ function w(o) {
1823
2100
  }
1824
2101
  return {
1825
2102
  h: Math.round(n * 360),
1826
- s: Math.round(l * 100),
1827
- v: Math.round(h * 100)
2103
+ s: Math.round(h * 100),
2104
+ v: Math.round(l * 100)
1828
2105
  };
1829
2106
  }
1830
- function M(o) {
2107
+ function L(o) {
1831
2108
  const t = o.s / 100, e = o.v / 100, s = e * (1 - t / 2), i = s === 0 || s === 1 ? 0 : (e - s) / Math.min(s, 1 - s);
1832
2109
  return {
1833
2110
  h: o.h,
@@ -1835,7 +2112,7 @@ function M(o) {
1835
2112
  l: Math.round(s * 100)
1836
2113
  };
1837
2114
  }
1838
- function st(o) {
2115
+ function lt(o) {
1839
2116
  const t = o.s / 100, e = o.l / 100, s = e + t * Math.min(e, 1 - e), i = s === 0 ? 0 : 2 * (1 - e / s);
1840
2117
  return {
1841
2118
  h: o.h,
@@ -1843,11 +2120,11 @@ function st(o) {
1843
2120
  v: Math.round(s * 100)
1844
2121
  };
1845
2122
  }
1846
- function C(o) {
2123
+ function I(o) {
1847
2124
  const t = (e) => e.toString(16).padStart(2, "0");
1848
2125
  return `#${t(o.r)}${t(o.g)}${t(o.b)}`;
1849
2126
  }
1850
- function it(o) {
2127
+ function ct(o) {
1851
2128
  const t = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(o);
1852
2129
  if (!t) {
1853
2130
  const e = /^#?([a-f\d])([a-f\d])([a-f\d])$/i.exec(o);
@@ -1863,7 +2140,7 @@ function it(o) {
1863
2140
  b: parseInt(t[3], 16)
1864
2141
  };
1865
2142
  }
1866
- function m(o) {
2143
+ function w(o) {
1867
2144
  const t = o.trim().toLowerCase();
1868
2145
  if (t.startsWith("#")) {
1869
2146
  const i = /^#([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);
@@ -1873,10 +2150,10 @@ function m(o) {
1873
2150
  g: parseInt(i[2], 16),
1874
2151
  b: parseInt(i[3], 16)
1875
2152
  }, n = parseInt(i[4], 16) / 255;
1876
- return { hsv: w(a), alpha: Math.round(n * 100) };
2153
+ return { hsv: $(a), alpha: Math.round(n * 100) };
1877
2154
  }
1878
- const r = it(t);
1879
- return r ? { hsv: w(r), alpha: 100 } : null;
2155
+ const r = ct(t);
2156
+ return r ? { hsv: $(r), alpha: 100 } : null;
1880
2157
  }
1881
2158
  const e = /^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d.]+))?\s*\)$/.exec(t);
1882
2159
  if (e) {
@@ -1885,7 +2162,7 @@ function m(o) {
1885
2162
  g: parseInt(e[2], 10),
1886
2163
  b: parseInt(e[3], 10)
1887
2164
  }, r = e[4] ? parseFloat(e[4]) * 100 : 100;
1888
- return { hsv: w(i), alpha: r };
2165
+ return { hsv: $(i), alpha: r };
1889
2166
  }
1890
2167
  const s = /^hsla?\(\s*([\d.]+)\s*,\s*([\d.]+)%\s*,\s*([\d.]+)%\s*(?:,\s*([\d.]+))?\s*\)$/.exec(t);
1891
2168
  if (s) {
@@ -1894,33 +2171,33 @@ function m(o) {
1894
2171
  s: parseFloat(s[2]),
1895
2172
  l: parseFloat(s[3])
1896
2173
  }, r = s[4] ? parseFloat(s[4]) * 100 : 100;
1897
- return { hsv: st(i), alpha: r };
2174
+ return { hsv: lt(i), alpha: r };
1898
2175
  }
1899
2176
  return null;
1900
2177
  }
1901
- class rt extends d {
2178
+ class dt extends p {
1902
2179
  #t = 0;
1903
2180
  #e = 100;
1904
2181
  #i = 100;
1905
2182
  #s = 100;
1906
2183
  #r = !1;
1907
2184
  #n = !1;
1908
- #l = !1;
1909
- #c = null;
1910
- #p = null;
2185
+ #h = !1;
2186
+ #l = null;
2187
+ #d = null;
2188
+ #o = null;
1911
2189
  #a = null;
1912
2190
  #u = null;
1913
- #f = null;
1914
- #b = null;
1915
2191
  #g = null;
1916
- #o = null;
1917
- #w = null;
1918
- #h = null;
2192
+ #m = null;
2193
+ #f = null;
2194
+ #A = null;
2195
+ #c = null;
1919
2196
  static observedAttributes = ["value", "format", "opacity", "disabled", "swatches", "inline"];
1920
2197
  setup() {
1921
- this.#d(), this.#k(), this.#v(), this.#y();
2198
+ this.#p(), this.#y(), this.#w(), this.#v();
1922
2199
  }
1923
- #d() {
2200
+ #p() {
1924
2201
  const t = this.hasAttribute("inline"), e = this.hasAttribute("opacity"), s = this.getAttribute("swatches");
1925
2202
  let i = `
1926
2203
  <div data-ry-target="grid" class="ry-color-picker__grid">
@@ -1960,57 +2237,57 @@ class rt extends d {
1960
2237
  <span data-ry-target="trigger-color" class="ry-color-picker__trigger-color"></span>
1961
2238
  </button>
1962
2239
  <div data-ry-target="panel" class="ry-color-picker__panel">${i}</div>
1963
- `, this.#c = this.$('[data-ry-target="trigger"]'), this.#p = this.$('[data-ry-target="panel"]'), this.#a = this.$('[data-ry-target="grid"]'), this.#u = this.$('[data-ry-target="grid-handle"]'), this.#f = this.$('[data-ry-target="hue-slider"]'), this.#b = this.$('[data-ry-target="hue-handle"]'), this.#g = this.$('[data-ry-target="alpha-slider"]'), this.#o = this.$('[data-ry-target="alpha-handle"]'), this.#w = this.$('[data-ry-target="preview"]'), this.#h = this.$('[data-ry-target="input"]');
2240
+ `, this.#l = this.$('[data-ry-target="trigger"]'), this.#d = this.$('[data-ry-target="panel"]'), this.#o = this.$('[data-ry-target="grid"]'), this.#a = this.$('[data-ry-target="grid-handle"]'), this.#u = this.$('[data-ry-target="hue-slider"]'), this.#g = this.$('[data-ry-target="hue-handle"]'), this.#m = this.$('[data-ry-target="alpha-slider"]'), this.#f = this.$('[data-ry-target="alpha-handle"]'), this.#A = this.$('[data-ry-target="preview"]'), this.#c = this.$('[data-ry-target="input"]');
1964
2241
  }
1965
- #k() {
1966
- this.#c && this.on(this.#c, "click", this.#m), this.on(document, "click", this.#x), this.on(document, "keydown", this.#j), this.#a && this.on(this.#a, "pointerdown", this.#R), this.#u && this.on(this.#u, "keydown", this.#P), this.#f && this.on(this.#f, "pointerdown", this.#O), this.#b && this.on(this.#b, "keydown", this.#K), this.#g && this.on(this.#g, "pointerdown", this.#N), this.#o && this.on(this.#o, "keydown", this.#U), this.on(document, "pointermove", this.#W), this.on(document, "pointerup", this.#V), this.#h && (this.on(this.#h, "change", this.#T), this.on(this.#h, "keydown", this.#q));
2242
+ #y() {
2243
+ this.#l && this.on(this.#l, "click", this.#b), this.on(document, "click", this.#S), this.on(document, "keydown", this.#M), this.#o && this.on(this.#o, "pointerdown", this.#W), this.#a && this.on(this.#a, "keydown", this.#X), this.#u && this.on(this.#u, "pointerdown", this.#G), this.#g && this.on(this.#g, "keydown", this.#q), this.#m && this.on(this.#m, "pointerdown", this.#J), this.#f && this.on(this.#f, "keydown", this.#U), this.on(document, "pointermove", this.#P), this.on(document, "pointerup", this.#B), this.#c && (this.on(this.#c, "change", this.#T), this.on(this.#c, "keydown", this.#V));
1967
2244
  const t = this.$('[data-ry-target="format-toggle"]');
1968
- t && this.on(t, "click", this.#z);
2245
+ t && this.on(t, "click", this.#R);
1969
2246
  const e = this.$('[data-ry-target="swatches"]');
1970
- e && this.on(e, "click", this.#Y);
2247
+ e && this.on(e, "click", this.#j);
1971
2248
  }
1972
- #v() {
2249
+ #w() {
1973
2250
  const t = this.getAttribute("value");
1974
2251
  if (t) {
1975
- const e = m(t);
2252
+ const e = w(t);
1976
2253
  e && (this.#t = e.hsv.h, this.#e = e.hsv.s, this.#i = e.hsv.v, this.#s = e.alpha);
1977
2254
  }
1978
2255
  }
1979
2256
  // ───────────────────────────────────────────────────────────────────────────
1980
2257
  // Dropdown handlers
1981
2258
  // ───────────────────────────────────────────────────────────────────────────
1982
- #m = () => {
2259
+ #b = () => {
1983
2260
  this.disabled || (this.state === "open" ? this.close() : this.open());
1984
2261
  };
1985
- #x = (t) => {
2262
+ #S = (t) => {
1986
2263
  this.state === "open" && (this.contains(t.target) || this.close());
1987
2264
  };
1988
- #j = (t) => {
1989
- t.key === "Escape" && this.state === "open" && (this.close(), this.#c?.focus());
2265
+ #M = (t) => {
2266
+ t.key === "Escape" && this.state === "open" && (this.close(), this.#l?.focus());
1990
2267
  };
1991
2268
  open() {
1992
- this.hasAttribute("inline") || (this.#B(), this.state = "open");
2269
+ this.hasAttribute("inline") || (this.#F(), this.state = "open");
1993
2270
  }
1994
2271
  close() {
1995
2272
  this.hasAttribute("inline") || (this.state = "closed", this.removeAttribute("data-ry-position"));
1996
2273
  }
1997
- #B() {
1998
- if (!this.#p || !this.#c) return;
1999
- const t = this.#c.getBoundingClientRect(), e = 320, i = window.innerHeight - t.bottom, r = t.top;
2274
+ #F() {
2275
+ if (!this.#d || !this.#l) return;
2276
+ const t = this.#l.getBoundingClientRect(), e = 320, i = window.innerHeight - t.bottom, r = t.top;
2000
2277
  i < e && r > i ? this.setAttribute("data-ry-position", "top") : this.setAttribute("data-ry-position", "bottom");
2001
2278
  }
2002
2279
  // ───────────────────────────────────────────────────────────────────────────
2003
2280
  // Grid handlers
2004
2281
  // ───────────────────────────────────────────────────────────────────────────
2005
- #R = (t) => {
2006
- this.disabled || (t.preventDefault(), this.#r = !0, this.#u?.focus(), this.#C(t));
2282
+ #W = (t) => {
2283
+ this.disabled || (t.preventDefault(), this.#r = !0, this.#a?.focus(), this.#E(t));
2007
2284
  };
2008
- #C(t) {
2009
- if (!this.#a) return;
2010
- const e = this.#a.getBoundingClientRect(), s = Math.max(0, Math.min(1, (t.clientX - e.left) / e.width)), i = Math.max(0, Math.min(1, (t.clientY - e.top) / e.height));
2011
- this.#e = Math.round(s * 100), this.#i = Math.round((1 - i) * 100), this.#y(), this.#A();
2285
+ #E(t) {
2286
+ if (!this.#o) return;
2287
+ const e = this.#o.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));
2288
+ this.#e = Math.round(s * 100), this.#i = Math.round((1 - i) * 100), this.#v(), this.#L();
2012
2289
  }
2013
- #P = (t) => {
2290
+ #X = (t) => {
2014
2291
  if (this.disabled) return;
2015
2292
  const e = t.shiftKey ? 10 : 1;
2016
2293
  let s = !1;
@@ -2028,20 +2305,20 @@ class rt extends d {
2028
2305
  this.#i = Math.max(0, this.#i - e), s = !0;
2029
2306
  break;
2030
2307
  }
2031
- s && (t.preventDefault(), this.#y(), this.#A(), this.#$());
2308
+ s && (t.preventDefault(), this.#v(), this.#L(), this.#k());
2032
2309
  };
2033
2310
  // ───────────────────────────────────────────────────────────────────────────
2034
2311
  // Hue handlers
2035
2312
  // ───────────────────────────────────────────────────────────────────────────
2036
- #O = (t) => {
2037
- this.disabled || (t.preventDefault(), this.#n = !0, this.#b?.focus(), this.#E(t));
2313
+ #G = (t) => {
2314
+ this.disabled || (t.preventDefault(), this.#n = !0, this.#g?.focus(), this.#K(t));
2038
2315
  };
2039
- #E(t) {
2040
- if (!this.#f) return;
2041
- const e = this.#f.getBoundingClientRect(), s = Math.max(0, Math.min(1, (t.clientX - e.left) / e.width));
2042
- this.#t = Math.round(s * 360), this.#y(), this.#A();
2316
+ #K(t) {
2317
+ if (!this.#u) return;
2318
+ const e = this.#u.getBoundingClientRect(), s = Math.max(0, Math.min(1, (t.clientX - e.left) / e.width));
2319
+ this.#t = Math.round(s * 360), this.#v(), this.#L();
2043
2320
  }
2044
- #K = (t) => {
2321
+ #q = (t) => {
2045
2322
  if (this.disabled) return;
2046
2323
  const e = t.shiftKey ? 10 : 1;
2047
2324
  let s = !1;
@@ -2055,18 +2332,18 @@ class rt extends d {
2055
2332
  this.#t = (this.#t - e + 360) % 360, s = !0;
2056
2333
  break;
2057
2334
  }
2058
- s && (t.preventDefault(), this.#y(), this.#A(), this.#$());
2335
+ s && (t.preventDefault(), this.#v(), this.#L(), this.#k());
2059
2336
  };
2060
2337
  // ───────────────────────────────────────────────────────────────────────────
2061
2338
  // Alpha handlers
2062
2339
  // ───────────────────────────────────────────────────────────────────────────
2063
- #N = (t) => {
2064
- this.disabled || (t.preventDefault(), this.#l = !0, this.#o?.focus(), this.#S(t));
2340
+ #J = (t) => {
2341
+ this.disabled || (t.preventDefault(), this.#h = !0, this.#f?.focus(), this.#_(t));
2065
2342
  };
2066
- #S(t) {
2067
- if (!this.#g) return;
2068
- const e = this.#g.getBoundingClientRect(), s = Math.max(0, Math.min(1, (t.clientX - e.left) / e.width));
2069
- this.#s = Math.round(s * 100), this.#y(), this.#A();
2343
+ #_(t) {
2344
+ if (!this.#m) return;
2345
+ const e = this.#m.getBoundingClientRect(), s = Math.max(0, Math.min(1, (t.clientX - e.left) / e.width));
2346
+ this.#s = Math.round(s * 100), this.#v(), this.#L();
2070
2347
  }
2071
2348
  #U = (t) => {
2072
2349
  if (this.disabled) return;
@@ -2082,99 +2359,99 @@ class rt extends d {
2082
2359
  this.#s = Math.max(0, this.#s - e), s = !0;
2083
2360
  break;
2084
2361
  }
2085
- s && (t.preventDefault(), this.#y(), this.#A(), this.#$());
2362
+ s && (t.preventDefault(), this.#v(), this.#L(), this.#k());
2086
2363
  };
2087
2364
  // ───────────────────────────────────────────────────────────────────────────
2088
2365
  // Pointer move/up
2089
2366
  // ───────────────────────────────────────────────────────────────────────────
2090
- #W = (t) => {
2091
- this.#r ? this.#C(t) : this.#n ? this.#E(t) : this.#l && this.#S(t);
2367
+ #P = (t) => {
2368
+ this.#r ? this.#E(t) : this.#n ? this.#K(t) : this.#h && this.#_(t);
2092
2369
  };
2093
- #V = () => {
2094
- (this.#r || this.#n || this.#l) && (this.#r = !1, this.#n = !1, this.#l = !1, this.#$());
2370
+ #B = () => {
2371
+ (this.#r || this.#n || this.#h) && (this.#r = !1, this.#n = !1, this.#h = !1, this.#k());
2095
2372
  };
2096
2373
  // ───────────────────────────────────────────────────────────────────────────
2097
2374
  // Input handlers
2098
2375
  // ───────────────────────────────────────────────────────────────────────────
2099
2376
  #T = () => {
2100
- if (!this.#h) return;
2101
- const t = m(this.#h.value);
2102
- t ? (this.#t = t.hsv.h, this.#e = t.hsv.s, this.#i = t.hsv.v, this.hasAttribute("opacity") && (this.#s = t.alpha), this.#y(), this.#$()) : this.#M();
2377
+ if (!this.#c) return;
2378
+ const t = w(this.#c.value);
2379
+ t ? (this.#t = t.hsv.h, this.#e = t.hsv.s, this.#i = t.hsv.v, this.hasAttribute("opacity") && (this.#s = t.alpha), this.#v(), this.#k()) : this.#z();
2103
2380
  };
2104
- #q = (t) => {
2381
+ #V = (t) => {
2105
2382
  t.key === "Enter" && (t.preventDefault(), this.#T());
2106
2383
  };
2107
2384
  // ───────────────────────────────────────────────────────────────────────────
2108
2385
  // Format toggle
2109
2386
  // ───────────────────────────────────────────────────────────────────────────
2110
- #z = () => {
2387
+ #R = () => {
2111
2388
  const t = ["hex", "rgb", "hsl"], e = this.format, s = t.indexOf(e), i = t[(s + 1) % t.length];
2112
2389
  this.format = i;
2113
2390
  const r = this.$('[data-ry-target="format-toggle"]');
2114
- r && (r.textContent = i.toUpperCase()), this.#M();
2391
+ r && (r.textContent = i.toUpperCase()), this.#z();
2115
2392
  };
2116
2393
  // ───────────────────────────────────────────────────────────────────────────
2117
2394
  // Swatches
2118
2395
  // ───────────────────────────────────────────────────────────────────────────
2119
- #Y = (t) => {
2396
+ #j = (t) => {
2120
2397
  const e = t.target;
2121
2398
  if (e.classList.contains("ry-color-picker__swatch")) {
2122
2399
  const s = e.dataset.color;
2123
2400
  if (s) {
2124
- const i = m(s);
2125
- i && (this.#t = i.hsv.h, this.#e = i.hsv.s, this.#i = i.hsv.v, this.hasAttribute("opacity") && (this.#s = i.alpha), this.#y(), this.#A(), this.#$());
2401
+ const i = w(s);
2402
+ 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.#L(), this.#k());
2126
2403
  }
2127
2404
  }
2128
2405
  };
2129
2406
  // ───────────────────────────────────────────────────────────────────────────
2130
2407
  // Update methods
2131
2408
  // ───────────────────────────────────────────────────────────────────────────
2132
- #y() {
2133
- this.#H(), this.#L(), this.#I(), this.#D(), this.#F(), this.#M(), this.#G();
2409
+ #v() {
2410
+ this.#Y(), this.#$(), this.#x(), this.#H(), this.#O(), this.#z(), this.#Z();
2134
2411
  }
2135
- #H() {
2412
+ #Y() {
2136
2413
  const t = this.$('[data-ry-target="trigger-color"]');
2137
2414
  if (t) {
2138
- const e = f({ h: this.#t, s: this.#e, v: this.#i }), s = this.hasAttribute("opacity") ? this.#s / 100 : 1;
2415
+ const e = v({ h: this.#t, s: this.#e, v: this.#i }), s = this.hasAttribute("opacity") ? this.#s / 100 : 1;
2139
2416
  t.style.backgroundColor = `rgba(${e.r}, ${e.g}, ${e.b}, ${s})`;
2140
2417
  }
2141
2418
  }
2142
- #L() {
2143
- if (this.#a) {
2144
- const t = f({ h: this.#t, s: 100, v: 100 });
2145
- this.#a.style.setProperty("--grid-hue-color", `rgb(${t.r}, ${t.g}, ${t.b})`);
2419
+ #$() {
2420
+ if (this.#o) {
2421
+ const t = v({ h: this.#t, s: 100, v: 100 });
2422
+ this.#o.style.setProperty("--grid-hue-color", `rgb(${t.r}, ${t.g}, ${t.b})`);
2146
2423
  }
2147
- this.#u && (this.#u.style.left = `${this.#e}%`, this.#u.style.top = `${100 - this.#i}%`);
2424
+ this.#a && (this.#a.style.left = `${this.#e}%`, this.#a.style.top = `${100 - this.#i}%`);
2148
2425
  }
2149
- #I() {
2150
- this.#b && (this.#b.style.left = `${this.#t / 360 * 100}%`);
2426
+ #x() {
2427
+ this.#g && (this.#g.style.left = `${this.#t / 360 * 100}%`);
2151
2428
  }
2152
- #D() {
2153
- if (this.#g) {
2154
- const t = f({ h: this.#t, s: this.#e, v: this.#i });
2155
- this.#g.style.setProperty("--alpha-color", `rgb(${t.r}, ${t.g}, ${t.b})`);
2429
+ #H() {
2430
+ if (this.#m) {
2431
+ const t = v({ h: this.#t, s: this.#e, v: this.#i });
2432
+ this.#m.style.setProperty("--alpha-color", `rgb(${t.r}, ${t.g}, ${t.b})`);
2156
2433
  }
2157
- this.#o && (this.#o.style.left = `${this.#s}%`);
2434
+ this.#f && (this.#f.style.left = `${this.#s}%`);
2158
2435
  }
2159
- #F() {
2436
+ #O() {
2160
2437
  const t = this.$('[data-ry-target="preview-color"]');
2161
2438
  if (t) {
2162
- const e = f({ h: this.#t, s: this.#e, v: this.#i }), s = this.hasAttribute("opacity") ? this.#s / 100 : 1;
2439
+ const e = v({ h: this.#t, s: this.#e, v: this.#i }), s = this.hasAttribute("opacity") ? this.#s / 100 : 1;
2163
2440
  t.style.backgroundColor = `rgba(${e.r}, ${e.g}, ${e.b}, ${s})`;
2164
2441
  }
2165
2442
  }
2166
- #M() {
2167
- this.#h && (this.#h.value = this.#_());
2443
+ #z() {
2444
+ this.#c && (this.#c.value = this.#N());
2168
2445
  }
2169
- #G() {
2170
- const t = this.#_();
2446
+ #Z() {
2447
+ const t = this.#N();
2171
2448
  this.getAttribute("value") !== t && this.setAttribute("value", t);
2172
2449
  }
2173
- #_() {
2174
- const t = this.format, e = f({ h: this.#t, s: this.#e, v: this.#i }), s = this.hasAttribute("opacity");
2450
+ #N() {
2451
+ const t = this.format, e = v({ h: this.#t, s: this.#e, v: this.#i }), s = this.hasAttribute("opacity");
2175
2452
  switch (t) {
2176
2453
  case "hex": {
2177
- const i = C(e);
2454
+ const i = I(e);
2178
2455
  if (s && this.#s < 100) {
2179
2456
  const r = Math.round(this.#s / 100 * 255).toString(16).padStart(2, "0");
2180
2457
  return i + r;
@@ -2184,40 +2461,40 @@ class rt extends d {
2184
2461
  case "rgb":
2185
2462
  return s ? `rgba(${e.r}, ${e.g}, ${e.b}, ${(this.#s / 100).toFixed(2)})` : `rgb(${e.r}, ${e.g}, ${e.b})`;
2186
2463
  case "hsl": {
2187
- const i = M({ h: this.#t, s: this.#e, v: this.#i });
2464
+ const i = L({ h: this.#t, s: this.#e, v: this.#i });
2188
2465
  return s ? `hsla(${i.h}, ${i.s}%, ${i.l}%, ${(this.#s / 100).toFixed(2)})` : `hsl(${i.h}, ${i.s}%, ${i.l}%)`;
2189
2466
  }
2190
2467
  default:
2191
- return C(e);
2468
+ return I(e);
2192
2469
  }
2193
2470
  }
2194
2471
  // ───────────────────────────────────────────────────────────────────────────
2195
2472
  // Events
2196
2473
  // ───────────────────────────────────────────────────────────────────────────
2197
- #A() {
2474
+ #L() {
2198
2475
  this.emit("input", { value: this.value, hsv: this.hsv, rgb: this.rgb });
2199
2476
  }
2200
- #$() {
2477
+ #k() {
2201
2478
  this.emit("change", { value: this.value, hsv: this.hsv, rgb: this.rgb });
2202
2479
  }
2203
2480
  // ───────────────────────────────────────────────────────────────────────────
2204
2481
  // Attribute changed
2205
2482
  // ───────────────────────────────────────────────────────────────────────────
2206
2483
  attributeChangedCallback(t, e, s) {
2207
- if (e !== s && t === "value" && this.#a && s) {
2208
- const i = m(s);
2209
- i && (this.#t = i.hsv.h, this.#e = i.hsv.s, this.#i = i.hsv.v, this.hasAttribute("opacity") && (this.#s = i.alpha), this.#H(), this.#L(), this.#I(), this.#D(), this.#F());
2484
+ if (e !== s && t === "value" && this.#o && s) {
2485
+ const i = w(s);
2486
+ i && (this.#t = i.hsv.h, this.#e = i.hsv.s, this.#i = i.hsv.v, this.hasAttribute("opacity") && (this.#s = i.alpha), this.#Y(), this.#$(), this.#x(), this.#H(), this.#O());
2210
2487
  }
2211
2488
  }
2212
2489
  // ───────────────────────────────────────────────────────────────────────────
2213
2490
  // Public API
2214
2491
  // ───────────────────────────────────────────────────────────────────────────
2215
2492
  get value() {
2216
- return this.#_();
2493
+ return this.#N();
2217
2494
  }
2218
2495
  set value(t) {
2219
- const e = m(t);
2220
- e && (this.#t = e.hsv.h, this.#e = e.hsv.s, this.#i = e.hsv.v, this.hasAttribute("opacity") && (this.#s = e.alpha), this.#y());
2496
+ const e = w(t);
2497
+ e && (this.#t = e.hsv.h, this.#e = e.hsv.s, this.#i = e.hsv.v, this.hasAttribute("opacity") && (this.#s = e.alpha), this.#v());
2221
2498
  }
2222
2499
  get format() {
2223
2500
  return this.getAttribute("format") || "hex";
@@ -2235,39 +2512,39 @@ class rt extends d {
2235
2512
  return { h: this.#t, s: this.#e, v: this.#i };
2236
2513
  }
2237
2514
  get rgb() {
2238
- return f(this.hsv);
2515
+ return v(this.hsv);
2239
2516
  }
2240
2517
  get hsl() {
2241
- return M(this.hsv);
2518
+ return L(this.hsv);
2242
2519
  }
2243
2520
  get alpha() {
2244
2521
  return this.#s;
2245
2522
  }
2246
2523
  set alpha(t) {
2247
- this.#s = Math.max(0, Math.min(100, t)), this.#y();
2524
+ this.#s = Math.max(0, Math.min(100, t)), this.#v();
2248
2525
  }
2249
2526
  /** Set color from any valid color string */
2250
2527
  setColor(t) {
2251
- const e = m(t);
2252
- return e ? (this.#t = e.hsv.h, this.#e = e.hsv.s, this.#i = e.hsv.v, this.hasAttribute("opacity") && (this.#s = e.alpha), this.#y(), !0) : !1;
2528
+ const e = w(t);
2529
+ return e ? (this.#t = e.hsv.h, this.#e = e.hsv.s, this.#i = e.hsv.v, this.hasAttribute("opacity") && (this.#s = e.alpha), this.#v(), !0) : !1;
2253
2530
  }
2254
2531
  /** Get color in specific format */
2255
2532
  getFormattedValue(t) {
2256
2533
  const e = this.format;
2257
2534
  this.format = t;
2258
- const s = this.#_();
2535
+ const s = this.#N();
2259
2536
  return this.format = e, s;
2260
2537
  }
2261
2538
  }
2262
- customElements.define("ry-color-picker", rt);
2263
- class at extends d {
2539
+ customElements.define("ry-color-picker", dt);
2540
+ class ut extends p {
2264
2541
  #t = null;
2265
2542
  #e = null;
2266
2543
  #i = null;
2267
2544
  #s = null;
2268
2545
  static observedAttributes = ["value", "format", "opacity", "disabled", "placeholder"];
2269
2546
  setup() {
2270
- this.#r(), this.#n(), this.#k(), this.state = "closed";
2547
+ this.#r(), this.#n(), this.#y(), this.state = "closed";
2271
2548
  }
2272
2549
  #r() {
2273
2550
  const t = this.hasAttribute("opacity"), e = this.getAttribute("format") || "hex", s = this.getAttribute("value") || "#000000", i = this.getAttribute("placeholder") || "#000000";
@@ -2299,15 +2576,15 @@ class at extends d {
2299
2576
  `, 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"]');
2300
2577
  }
2301
2578
  #n() {
2302
- this.#t && this.on(this.#t, "click", this.#l), this.#e && (this.on(this.#e, "input", this.#p), this.on(this.#e, "keydown", this.#f), this.on(this.#e, "focus", this.#c)), this.#s && (this.on(this.#s, "ry:input", this.#b), this.on(this.#s, "ry:change", this.#g)), this.on(document, "click", this.#o), this.on(document, "keydown", this.#w);
2579
+ this.#t && this.on(this.#t, "click", this.#h), this.#e && (this.on(this.#e, "input", this.#d), this.on(this.#e, "keydown", this.#u), this.on(this.#e, "focus", this.#l)), this.#s && (this.on(this.#s, "ry:input", this.#g), this.on(this.#s, "ry:change", this.#m)), this.on(document, "click", this.#f), this.on(document, "keydown", this.#A);
2303
2580
  }
2304
- #l = () => {
2581
+ #h = () => {
2305
2582
  this.disabled || (this.state === "open" ? this.close() : this.open());
2306
2583
  };
2307
- #c = () => {
2584
+ #l = () => {
2308
2585
  this.disabled || this.open();
2309
2586
  };
2310
- #p = () => {
2587
+ #d = () => {
2311
2588
  if (!this.#e || !this.#s) return;
2312
2589
  let t = this.#e.value;
2313
2590
  const e = this.#e.selectionStart ?? t.length, r = "#" + t.replace(/[^#a-fA-F0-9]/g, "").replace(/#/g, "").slice(0, 6);
@@ -2316,10 +2593,10 @@ class at extends d {
2316
2593
  const n = Math.min(e, r.length);
2317
2594
  this.#e.setSelectionRange(n, n);
2318
2595
  }
2319
- const a = this.#a(r);
2320
- a && (this.#s.setColor(a), this.#d(), this.#u(r) && this.#v(), this.emit("input", { value: this.value }));
2596
+ const a = this.#o(r);
2597
+ a && (this.#s.setColor(a), this.#p(), this.#a(r) && this.#w(), this.emit("input", { value: this.value }));
2321
2598
  };
2322
- #a(t) {
2599
+ #o(t) {
2323
2600
  let e = t;
2324
2601
  e.startsWith("#") || (e = "#" + e);
2325
2602
  const s = e.slice(1);
@@ -2333,67 +2610,67 @@ class at extends d {
2333
2610
  }
2334
2611
  return "#" + s.padEnd(6, "0");
2335
2612
  }
2336
- #u(t) {
2613
+ #a(t) {
2337
2614
  return !!(/^#[a-fA-F0-9]{6}$/.test(t) || /^#[a-fA-F0-9]{3}$/.test(t));
2338
2615
  }
2339
- #f = (t) => {
2340
- t.key === "Enter" && (t.preventDefault(), this.#p(), this.emit("change", { value: this.value }));
2341
- };
2342
- #b = () => {
2343
- !this.#s || !this.#e || (document.activeElement !== this.#e && (this.#e.value = this.#s.value), this.#d(), this.#v(), this.emit("input", { value: this.value }));
2616
+ #u = (t) => {
2617
+ t.key === "Enter" && (t.preventDefault(), this.#d(), this.emit("change", { value: this.value }));
2344
2618
  };
2345
2619
  #g = () => {
2620
+ !this.#s || !this.#e || (document.activeElement !== this.#e && (this.#e.value = this.#s.value), this.#p(), this.#w(), this.emit("input", { value: this.value }));
2621
+ };
2622
+ #m = () => {
2346
2623
  this.emit("change", { value: this.value });
2347
2624
  };
2348
- #o = (t) => {
2625
+ #f = (t) => {
2349
2626
  this.state === "open" && (this.contains(t.target) || this.close());
2350
2627
  };
2351
- #w = (t) => {
2628
+ #A = (t) => {
2352
2629
  t.key === "Escape" && this.state === "open" && (this.close(), this.#t?.focus());
2353
2630
  };
2354
2631
  open() {
2355
- this.#h(), this.state = "open";
2632
+ this.#c(), this.state = "open";
2356
2633
  }
2357
2634
  close() {
2358
2635
  this.state = "closed", this.removeAttribute("data-ry-position");
2359
2636
  }
2360
- #h() {
2637
+ #c() {
2361
2638
  if (!this.#i) return;
2362
2639
  const t = this.getBoundingClientRect(), e = 280, i = window.innerHeight - t.bottom, r = t.top;
2363
2640
  i < e && r > i ? this.setAttribute("data-ry-position", "top") : this.setAttribute("data-ry-position", "bottom");
2364
2641
  }
2365
- #d() {
2642
+ #p() {
2366
2643
  const t = this.$('[data-ry-target="swatch-color"]');
2367
2644
  if (t && this.#s) {
2368
2645
  const e = this.#s.rgb, s = this.hasAttribute("opacity") ? this.#s.alpha / 100 : 1;
2369
2646
  t.style.backgroundColor = `rgba(${e.r}, ${e.g}, ${e.b}, ${s})`;
2370
2647
  }
2371
2648
  }
2372
- #k() {
2649
+ #y() {
2373
2650
  const t = this.getAttribute("value") || "#000000";
2374
2651
  if (this.#s) {
2375
2652
  if (this.#s.setColor(t), this.#e) {
2376
2653
  const e = this.#s.value;
2377
2654
  this.#e.value = e.startsWith("#") ? e : "#" + e;
2378
2655
  }
2379
- this.#d();
2656
+ this.#p();
2380
2657
  }
2381
2658
  }
2382
- #v() {
2659
+ #w() {
2383
2660
  if (this.#s) {
2384
2661
  const t = this.#s.value;
2385
2662
  this.getAttribute("value") !== t && this.setAttribute("value", t);
2386
2663
  }
2387
2664
  }
2388
2665
  attributeChangedCallback(t, e, s) {
2389
- e !== s && (t === "value" && this.#s && this.#e && s && (this.#s.setColor(s), document.activeElement !== this.#e && (this.#e.value = this.#s.value), this.#d()), t === "disabled" && this.#e && (s !== null ? this.#e.setAttribute("disabled", "") : this.#e.removeAttribute("disabled")));
2666
+ e !== s && (t === "value" && this.#s && this.#e && s && (this.#s.setColor(s), document.activeElement !== this.#e && (this.#e.value = this.#s.value), this.#p()), t === "disabled" && this.#e && (s !== null ? this.#e.setAttribute("disabled", "") : this.#e.removeAttribute("disabled")));
2390
2667
  }
2391
2668
  // Public API
2392
2669
  get value() {
2393
2670
  return this.#s?.value ?? this.getAttribute("value") ?? "#000000";
2394
2671
  }
2395
2672
  set value(t) {
2396
- this.#s?.setColor(t) && (this.#e && (this.#e.value = this.#s.value), this.#d(), this.#v());
2673
+ this.#s?.setColor(t) && (this.#e && (this.#e.value = this.#s.value), this.#p(), this.#w());
2397
2674
  }
2398
2675
  get disabled() {
2399
2676
  return this.hasAttribute("disabled");
@@ -2411,37 +2688,696 @@ class at extends d {
2411
2688
  return this.#s?.hsv ?? { h: 0, s: 0, v: 0 };
2412
2689
  }
2413
2690
  }
2414
- customElements.define("ry-color-input", at);
2415
- window.RyToast = p;
2691
+ customElements.define("ry-color-input", ut);
2692
+ function x(o) {
2693
+ const t = o.trim().toLowerCase();
2694
+ if (t.startsWith("#")) {
2695
+ const i = t.slice(1);
2696
+ return i.length === 3 ? {
2697
+ r: parseInt(i[0] + i[0], 16),
2698
+ g: parseInt(i[1] + i[1], 16),
2699
+ b: parseInt(i[2] + i[2], 16)
2700
+ } : i.length >= 6 ? {
2701
+ r: parseInt(i.slice(0, 2), 16),
2702
+ g: parseInt(i.slice(2, 4), 16),
2703
+ b: parseInt(i.slice(4, 6), 16)
2704
+ } : null;
2705
+ }
2706
+ const e = /^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/.exec(t);
2707
+ if (e)
2708
+ return {
2709
+ r: parseInt(e[1], 10),
2710
+ g: parseInt(e[2], 10),
2711
+ b: parseInt(e[3], 10)
2712
+ };
2713
+ const s = /^hsla?\(\s*([\d.]+)\s*,\s*([\d.]+)%\s*,\s*([\d.]+)%/.exec(t);
2714
+ if (s) {
2715
+ const i = parseFloat(s[1]) / 360, r = parseFloat(s[2]) / 100, a = parseFloat(s[3]) / 100, n = (c, d, u) => (u < 0 && (u += 1), u > 1 && (u -= 1), u < 1 / 6 ? c + (d - c) * 6 * u : u < 1 / 2 ? d : u < 2 / 3 ? c + (d - c) * (2 / 3 - u) * 6 : c), h = a < 0.5 ? a * (1 + r) : a + r - a * r, l = 2 * a - h;
2716
+ return {
2717
+ r: Math.round(n(l, h, i + 1 / 3) * 255),
2718
+ g: Math.round(n(l, h, i) * 255),
2719
+ b: Math.round(n(l, h, i - 1 / 3) * 255)
2720
+ };
2721
+ }
2722
+ return null;
2723
+ }
2724
+ function pt(o) {
2725
+ const t = (e) => Math.max(0, Math.min(255, e)).toString(16).padStart(2, "0");
2726
+ return `#${t(o.r)}${t(o.g)}${t(o.b)}`;
2727
+ }
2728
+ function gt(o, t, e) {
2729
+ return {
2730
+ r: Math.round(o.r + (t.r - o.r) * e),
2731
+ g: Math.round(o.g + (t.g - o.g) * e),
2732
+ b: Math.round(o.b + (t.b - o.b) * e)
2733
+ };
2734
+ }
2735
+ const H = "linear-gradient(90deg, #000000 0%, #ffffff 100%)", ft = 50;
2736
+ class bt extends p {
2737
+ #t = "linear";
2738
+ #e = 90;
2739
+ #i = "circle";
2740
+ #s = [];
2741
+ #r = null;
2742
+ #n = 0;
2743
+ #h = null;
2744
+ #l = !1;
2745
+ #d = null;
2746
+ #o = !1;
2747
+ // Cached DOM refs
2748
+ #a = null;
2749
+ #u = null;
2750
+ #g = null;
2751
+ static observedAttributes = ["value", "disabled", "output"];
2752
+ setup() {
2753
+ this.#m(), this.#W(), this.#X(), this.#$();
2754
+ }
2755
+ // ───────────────────────────────────────────────────────────────────────────
2756
+ // Parsing / Serialization
2757
+ // ───────────────────────────────────────────────────────────────────────────
2758
+ #m() {
2759
+ const t = this.getAttribute("value") || H;
2760
+ this.#f(t) || this.#f(H);
2761
+ }
2762
+ #f(t) {
2763
+ const e = t.trim();
2764
+ if (!e.startsWith("linear-gradient(") && !e.startsWith("radial-gradient("))
2765
+ return x(e) ? (this.#t = "solid", this.#s = [this.#p(e, 0), this.#p(e, 100)], this.#r = this.#s[0].id, !0) : !1;
2766
+ let s, i;
2767
+ e.startsWith("linear-gradient(") ? (s = "linear", i = e.slice(16, -1)) : (s = "radial", i = e.slice(16, -1));
2768
+ let r = 90, a = "circle", n = i;
2769
+ if (s === "linear") {
2770
+ const d = /^([\d.]+)deg\s*,\s*/.exec(i);
2771
+ if (d)
2772
+ r = parseFloat(d[1]), n = i.slice(d[0].length);
2773
+ else {
2774
+ const u = /^to\s+\w+(?:\s+\w+)?\s*,\s*/.exec(i);
2775
+ if (u) {
2776
+ const b = u[0].trim().replace(/,\s*$/, "");
2777
+ r = this.#A(b), n = i.slice(u[0].length);
2778
+ }
2779
+ }
2780
+ } else {
2781
+ const d = /^(circle|ellipse)(?:\s+at\s+[^,]+)?\s*,\s*/.exec(i);
2782
+ d && (a = d[1], n = i.slice(d[0].length));
2783
+ }
2784
+ const h = [], l = /(#[a-fA-F0-9]{3,8}|rgba?\([^)]+\)|hsla?\([^)]+\)|[a-z]+)\s+([\d.]+)%/g;
2785
+ let c;
2786
+ for (; (c = l.exec(n)) !== null; )
2787
+ h.push(this.#p(c[1], parseFloat(c[2])));
2788
+ return h.length < 2 ? !1 : (this.#t = s, this.#e = r, this.#i = a, this.#s = h, this.#r = h[0].id, !0);
2789
+ }
2790
+ #A(t) {
2791
+ return {
2792
+ "to top": 0,
2793
+ "to top right": 45,
2794
+ "to right": 90,
2795
+ "to bottom right": 135,
2796
+ "to bottom": 180,
2797
+ "to bottom left": 225,
2798
+ "to left": 270,
2799
+ "to top left": 315
2800
+ }[t] ?? 90;
2801
+ }
2802
+ #c() {
2803
+ if (this.#t === "solid")
2804
+ return this.#s[0]?.color ?? "#000000";
2805
+ const t = this.#s.map((e) => `${e.color} ${Math.round(e.position)}%`).join(", ");
2806
+ return this.#t === "linear" ? `linear-gradient(${Math.round(this.#e)}deg, ${t})` : `radial-gradient(${this.#i}, ${t})`;
2807
+ }
2808
+ // ───────────────────────────────────────────────────────────────────────────
2809
+ // Stop management
2810
+ // ───────────────────────────────────────────────────────────────────────────
2811
+ #p(t, e) {
2812
+ return { id: `stop-${this.#n++}`, color: t, position: e };
2813
+ }
2814
+ /** CSS left value clamped so the stop handle stays within the bar */
2815
+ #y(t) {
2816
+ const e = "calc(var(--ry-gradient-picker-stop-size, 16px) / 2)";
2817
+ return `clamp(${e}, ${t}%, calc(100% - ${e}))`;
2818
+ }
2819
+ #w(t, e) {
2820
+ const s = this.#p(t, e);
2821
+ this.#s.push(s), this.#M(), this.#r = s.id, this.#E(), this.#$();
2822
+ }
2823
+ #b(t) {
2824
+ if (this.#s.length <= 2) return !1;
2825
+ const e = this.#s.findIndex((s) => s.id === t);
2826
+ 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.#E(), this.#$(), !0);
2827
+ }
2828
+ #S(t) {
2829
+ this.#r !== t && (this.#r = t, this.#N(), this.#L());
2830
+ }
2831
+ #M() {
2832
+ this.#s.sort((t, e) => t.position - e.position);
2833
+ }
2834
+ #F() {
2835
+ return this.#s.find((t) => t.id === this.#r) ?? null;
2836
+ }
2837
+ // ───────────────────────────────────────────────────────────────────────────
2838
+ // Markup
2839
+ // ───────────────────────────────────────────────────────────────────────────
2840
+ #W() {
2841
+ const t = this.hasAttribute("output"), e = g("copy"), s = g("gradient-solid"), i = g("gradient-linear"), r = g("gradient-radial"), a = g("shape-circle"), n = g("shape-ellipse");
2842
+ let h = "";
2843
+ t && (h = `
2844
+ <div data-ry-target="output-row" class="ry-gradient-picker__output-row">
2845
+ <input data-ry-target="output" type="text" class="ry-gradient-picker__output" spellcheck="false" />
2846
+ <button data-ry-target="copy-btn" type="button" class="ry-gradient-picker__copy-btn">${e}</button>
2847
+ </div>`), this.innerHTML = `
2848
+ <div data-ry-target="controls" class="ry-gradient-picker__controls">
2849
+ <div data-ry-target="type-toggle" class="ry-gradient-picker__type-toggle">
2850
+ <button data-ry-target="type-solid" type="button" class="ry-gradient-picker__type-btn">${s}</button>
2851
+ <button data-ry-target="type-linear" type="button" class="ry-gradient-picker__type-btn">${i}</button>
2852
+ <button data-ry-target="type-radial" type="button" class="ry-gradient-picker__type-btn">${r}</button>
2853
+ </div>
2854
+ <div data-ry-target="angle-control" class="ry-gradient-picker__angle-control">
2855
+ <ry-number-select data-ry-target="angle-select" min="0" max="360" step="1" value="${this.#e}" wrap suffix="°" size="xs" arrows="none"></ry-number-select>
2856
+ </div>
2857
+ <div data-ry-target="shape-control" class="ry-gradient-picker__shape-control">
2858
+ <button data-ry-target="shape-circle" type="button" class="ry-gradient-picker__shape-btn">${a}</button>
2859
+ <button data-ry-target="shape-ellipse" type="button" class="ry-gradient-picker__shape-btn">${n}</button>
2860
+ </div>
2861
+ </div>
2862
+ <div data-ry-target="bar-container" class="ry-gradient-picker__bar-container">
2863
+ <div data-ry-target="bar" class="ry-gradient-picker__bar"></div>
2864
+ </div>
2865
+ <ry-color-picker data-ry-target="picker" inline opacity></ry-color-picker>
2866
+ ${h}
2867
+ `, this.#a = this.$('[data-ry-target="bar"]'), this.#u = this.$('[data-ry-target="picker"]'), this.#g = this.$('[data-ry-target="output"]'), this.#E();
2868
+ }
2869
+ #E() {
2870
+ if (this.#a) {
2871
+ this.#a.querySelectorAll('[data-ry-target="stop"]').forEach((t) => t.remove());
2872
+ for (const t of this.#s) {
2873
+ const e = document.createElement("div");
2874
+ 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.#y(t.position), e.style.setProperty("--stop-color", t.color), t.id === this.#r && e.setAttribute("data-selected", ""), this.#a.appendChild(e);
2875
+ }
2876
+ }
2877
+ }
2878
+ // ───────────────────────────────────────────────────────────────────────────
2879
+ // Event binding
2880
+ // ───────────────────────────────────────────────────────────────────────────
2881
+ #X() {
2882
+ this.#a && (this.on(this.#a, "pointerdown", this.#G), this.on(this.#a, "pointermove", this.#K), this.on(this.#a, "pointerup", this.#q), this.on(this.#a, "lostpointercapture", this.#q));
2883
+ const t = this.$('[data-ry-target="type-solid"]'), e = this.$('[data-ry-target="type-linear"]'), s = this.$('[data-ry-target="type-radial"]');
2884
+ t && this.on(t, "click", () => this.#_("solid")), e && this.on(e, "click", () => this.#_("linear")), s && this.on(s, "click", () => this.#_("radial"));
2885
+ const i = this.$('[data-ry-target="angle-select"]');
2886
+ i && this.on(i, "ry:input", this.#U);
2887
+ const r = this.$('[data-ry-target="shape-circle"]'), a = this.$('[data-ry-target="shape-ellipse"]');
2888
+ r && this.on(r, "click", () => this.#P("circle")), a && this.on(a, "click", () => this.#P("ellipse")), this.#u && (this.on(this.#u, "ry:input", this.#B), this.on(this.#u, "ry:change", this.#T)), this.#g && (this.on(this.#g, "keydown", this.#R), this.on(this.#g, "blur", this.#j));
2889
+ const n = this.$('[data-ry-target="copy-btn"]');
2890
+ n && this.on(n, "click", this.#V), this.#a && this.on(this.#a, "keydown", this.#J);
2891
+ }
2892
+ // ───────────────────────────────────────────────────────────────────────────
2893
+ // Bar / Stop interaction handlers
2894
+ // ───────────────────────────────────────────────────────────────────────────
2895
+ #G = (t) => {
2896
+ if (this.disabled) return;
2897
+ const s = t.target.closest('[data-ry-target="stop"]');
2898
+ if (s) {
2899
+ const i = s.getAttribute("data-stop-id");
2900
+ if (!i) return;
2901
+ t.preventDefault(), this.#h = i, this.#l = !1, this.#d = this.#a.getBoundingClientRect(), this.#S(i), this.#a.setPointerCapture(t.pointerId), s.focus();
2902
+ } else {
2903
+ if (t.preventDefault(), !this.#a) return;
2904
+ const i = this.#a.getBoundingClientRect(), r = Math.round(Math.max(0, Math.min(100, (t.clientX - i.left) / i.width * 100))), a = this.#Y(r);
2905
+ this.#w(a, r), this.#a.querySelector(`[data-stop-id="${this.#r}"]`)?.focus(), this.#h = this.#r, this.#l = !1, this.#d = i, this.#a.setPointerCapture(t.pointerId), this.#I();
2906
+ }
2907
+ };
2908
+ #K = (t) => {
2909
+ if (!this.#h || !this.#d) return;
2910
+ const e = this.#s.find((n) => n.id === this.#h);
2911
+ if (!e) return;
2912
+ const s = Math.max(0, Math.min(1, (t.clientX - this.#d.left) / this.#d.width));
2913
+ e.position = Math.round(s * 100);
2914
+ const i = this.#d.top + this.#d.height / 2, r = Math.abs(t.clientY - i);
2915
+ this.#l = r > ft && this.#s.length > 2;
2916
+ const a = this.#a?.querySelector(`[data-stop-id="${e.id}"]`);
2917
+ a && (a.style.left = this.#y(e.position), this.#l ? (a.style.opacity = "0.3", a.style.transform = "translate(-50%, -50%) scale(0.7)") : (a.style.opacity = "", a.style.transform = "")), this.#M(), this.#O(), this.#H(), this.#k(), this.#I();
2918
+ };
2919
+ #q = () => {
2920
+ this.#h && (this.#l && this.#b(this.#h), this.#h = null, this.#l = !1, this.#d = null, this.#C(), this.#D());
2921
+ };
2922
+ #J = (t) => {
2923
+ if (this.disabled) return;
2924
+ const s = t.target.closest('[data-ry-target="stop"]');
2925
+ if (!s) return;
2926
+ const i = s.getAttribute("data-stop-id");
2927
+ if (!i) return;
2928
+ const r = this.#s.find((h) => h.id === i);
2929
+ if (!r) return;
2930
+ const a = t.shiftKey ? 10 : 1;
2931
+ let n = !1;
2932
+ switch (t.key) {
2933
+ case "ArrowRight":
2934
+ r.position = Math.min(100, r.position + a), n = !0;
2935
+ break;
2936
+ case "ArrowLeft":
2937
+ r.position = Math.max(0, r.position - a), n = !0;
2938
+ break;
2939
+ case "Delete":
2940
+ case "Backspace":
2941
+ this.#b(i) && (this.#I(), this.#D()), t.preventDefault();
2942
+ return;
2943
+ }
2944
+ n && (t.preventDefault(), this.#M(), this.#z(), this.#O(), this.#H(), this.#k(), this.#C(), this.#I(), this.#D());
2945
+ };
2946
+ // ───────────────────────────────────────────────────────────────────────────
2947
+ // Type / Angle / Shape handlers
2948
+ // ───────────────────────────────────────────────────────────────────────────
2949
+ #_(t) {
2950
+ this.#t !== t && (this.#t = t, this.setAttribute("data-ry-type", t), this.#x(), this.#H(), this.#k(), this.#C(), this.#I(), this.#D());
2951
+ }
2952
+ #U = (t) => {
2953
+ const e = t.detail;
2954
+ this.#e = e.value, this.#H(), this.#k(), this.#C(), this.#I();
2955
+ };
2956
+ #P(t) {
2957
+ this.#i !== t && (this.#i = t, this.#x(), this.#k(), this.#C(), this.#I(), this.#D());
2958
+ }
2959
+ // ───────────────────────────────────────────────────────────────────────────
2960
+ // Color picker handlers
2961
+ // ───────────────────────────────────────────────────────────────────────────
2962
+ #B = () => {
2963
+ const t = this.#F();
2964
+ !t || !this.#u || (t.color = this.#u.value, this.#Z(t), this.#O(), this.#H(), this.#k(), this.#I());
2965
+ };
2966
+ #T = () => {
2967
+ this.#C(), this.#D();
2968
+ };
2969
+ // ───────────────────────────────────────────────────────────────────────────
2970
+ // Copy handler
2971
+ // ───────────────────────────────────────────────────────────────────────────
2972
+ #V = () => {
2973
+ const t = this.#c();
2974
+ navigator.clipboard.writeText(t).then(() => {
2975
+ const e = this.$('[data-ry-target="copy-btn"]');
2976
+ e && (e.setAttribute("data-copied", ""), setTimeout(() => e.removeAttribute("data-copied"), 1500));
2977
+ });
2978
+ };
2979
+ // ───────────────────────────────────────────────────────────────────────────
2980
+ // Output (editable CSS) handlers
2981
+ // ───────────────────────────────────────────────────────────────────────────
2982
+ #R = (t) => {
2983
+ t.key === "Enter" && (t.preventDefault(), this.#v());
2984
+ };
2985
+ #j = () => {
2986
+ this.#v();
2987
+ };
2988
+ #v() {
2989
+ if (!this.#g) return;
2990
+ const t = this.#g.value.trim();
2991
+ t && this.#f(t) ? (this.#E(), this.#$(), this.#C(), this.#I(), this.#D()) : this.#k();
2992
+ }
2993
+ // ───────────────────────────────────────────────────────────────────────────
2994
+ // Color interpolation
2995
+ // ───────────────────────────────────────────────────────────────────────────
2996
+ #Y(t) {
2997
+ if (this.#s.length === 0) return "#808080";
2998
+ if (this.#s.length === 1) return this.#s[0].color;
2999
+ const e = [...this.#s].sort((l, c) => l.position - c.position);
3000
+ if (t <= e[0].position) return e[0].color;
3001
+ if (t >= e[e.length - 1].position) return e[e.length - 1].color;
3002
+ let s = e[0], i = e[1];
3003
+ for (let l = 0; l < e.length - 1; l++)
3004
+ if (e[l].position <= t && e[l + 1].position >= t) {
3005
+ s = e[l], i = e[l + 1];
3006
+ break;
3007
+ }
3008
+ const r = i.position - s.position;
3009
+ if (r === 0) return s.color;
3010
+ const a = (t - s.position) / r, n = x(s.color), h = x(i.color);
3011
+ return !n || !h ? s.color : pt(gt(n, h, a));
3012
+ }
3013
+ // ───────────────────────────────────────────────────────────────────────────
3014
+ // Update methods
3015
+ // ───────────────────────────────────────────────────────────────────────────
3016
+ #$() {
3017
+ this.setAttribute("data-ry-type", this.#t), this.#x(), this.#O(), this.#H(), this.#z(), this.#N(), this.#L(), this.#k();
3018
+ }
3019
+ #x() {
3020
+ const t = this.$('[data-ry-target="type-solid"]'), e = this.$('[data-ry-target="type-linear"]'), s = this.$('[data-ry-target="type-radial"]');
3021
+ t && t.toggleAttribute("data-active", this.#t === "solid"), e && e.toggleAttribute("data-active", this.#t === "linear"), s && s.toggleAttribute("data-active", this.#t === "radial");
3022
+ const i = this.$('[data-ry-target="shape-circle"]'), r = this.$('[data-ry-target="shape-ellipse"]');
3023
+ i && i.toggleAttribute("data-active", this.#i === "circle"), r && r.toggleAttribute("data-active", this.#i === "ellipse");
3024
+ const a = this.$('[data-ry-target="angle-select"]');
3025
+ a && a.setAttribute("value", String(this.#e));
3026
+ }
3027
+ #H() {
3028
+ if (!this.#u) return;
3029
+ const t = this.#u.querySelector('[data-ry-target="preview-color"]');
3030
+ t && (t.style.backgroundImage = this.#t === "solid" ? "" : this.#c());
3031
+ }
3032
+ #O() {
3033
+ if (!this.#a) return;
3034
+ const t = this.#s.map((e) => `${e.color} ${e.position}%`).join(", ");
3035
+ this.#a.style.backgroundImage = `linear-gradient(to right, ${t})`;
3036
+ }
3037
+ #z() {
3038
+ if (this.#a)
3039
+ for (const t of this.#s) {
3040
+ const e = this.#a.querySelector(`[data-stop-id="${t.id}"]`);
3041
+ e && (e.style.left = this.#y(t.position));
3042
+ }
3043
+ }
3044
+ #Z(t) {
3045
+ if (!this.#a) return;
3046
+ const e = this.#a.querySelector(`[data-stop-id="${t.id}"]`);
3047
+ e && e.style.setProperty("--stop-color", t.color);
3048
+ }
3049
+ #N() {
3050
+ if (!this.#a) return;
3051
+ const t = this.#a.querySelectorAll('[data-ry-target="stop"]');
3052
+ for (const e of t)
3053
+ e.getAttribute("data-stop-id") === this.#r ? e.setAttribute("data-selected", "") : e.removeAttribute("data-selected");
3054
+ }
3055
+ #L() {
3056
+ const t = this.#F();
3057
+ !t || !this.#u || this.#u.setColor(t.color);
3058
+ }
3059
+ #k() {
3060
+ this.#g && document.activeElement !== this.#g && (this.#g.value = this.#c());
3061
+ }
3062
+ #C() {
3063
+ const t = this.#c();
3064
+ this.getAttribute("value") !== t && (this.#o = !0, this.setAttribute("value", t), this.#o = !1);
3065
+ }
3066
+ // ───────────────────────────────────────────────────────────────────────────
3067
+ // Events
3068
+ // ───────────────────────────────────────────────────────────────────────────
3069
+ #I() {
3070
+ this.emit("input", {
3071
+ value: this.#c(),
3072
+ type: this.#t,
3073
+ angle: this.#e,
3074
+ shape: this.#i,
3075
+ stops: this.stops
3076
+ });
3077
+ }
3078
+ #D() {
3079
+ this.emit("change", {
3080
+ value: this.#c(),
3081
+ type: this.#t,
3082
+ angle: this.#e,
3083
+ shape: this.#i,
3084
+ stops: this.stops
3085
+ });
3086
+ }
3087
+ // ───────────────────────────────────────────────────────────────────────────
3088
+ // Attribute changed
3089
+ // ───────────────────────────────────────────────────────────────────────────
3090
+ attributeChangedCallback(t, e, s) {
3091
+ e === s || this.#o || t === "value" && this.#a && s && this.#f(s) && (this.#E(), this.#$());
3092
+ }
3093
+ // ───────────────────────────────────────────────────────────────────────────
3094
+ // Public API
3095
+ // ───────────────────────────────────────────────────────────────────────────
3096
+ get value() {
3097
+ return this.#c();
3098
+ }
3099
+ set value(t) {
3100
+ this.#f(t) && (this.#E(), this.#$(), this.#C());
3101
+ }
3102
+ get type() {
3103
+ return this.#t;
3104
+ }
3105
+ set type(t) {
3106
+ this.#_(t);
3107
+ }
3108
+ get angle() {
3109
+ return this.#e;
3110
+ }
3111
+ set angle(t) {
3112
+ this.#e = (t % 360 + 360) % 360, this.#x(), this.#k(), this.#C();
3113
+ }
3114
+ get shape() {
3115
+ return this.#i;
3116
+ }
3117
+ set shape(t) {
3118
+ this.#P(t);
3119
+ }
3120
+ get stops() {
3121
+ return this.#s.map((t) => ({ ...t }));
3122
+ }
3123
+ get selectedStop() {
3124
+ const t = this.#F();
3125
+ return t ? { ...t } : null;
3126
+ }
3127
+ get disabled() {
3128
+ return this.hasAttribute("disabled");
3129
+ }
3130
+ set disabled(t) {
3131
+ t ? this.setAttribute("disabled", "") : this.removeAttribute("disabled");
3132
+ }
3133
+ addStop(t, e) {
3134
+ this.#w(t, e), this.#C(), this.#I(), this.#D();
3135
+ }
3136
+ removeStop(t) {
3137
+ const e = this.#b(t);
3138
+ return e && (this.#k(), this.#C(), this.#D()), e;
3139
+ }
3140
+ }
3141
+ customElements.define("ry-gradient-picker", bt);
3142
+ let yt = 0;
3143
+ const mt = 5;
3144
+ function _(o) {
3145
+ return g(o).replace(/width="24"/g, 'width="16"').replace(/height="24"/g, 'height="16"').replace(/viewBox/, 'class="ry-tree__icon" viewBox');
3146
+ }
3147
+ class k extends p {
3148
+ // Drag state
3149
+ #t = !1;
3150
+ #e = !1;
3151
+ #i = 0;
3152
+ #s = 0;
3153
+ #r = null;
3154
+ #n = null;
3155
+ #h = null;
3156
+ #l = null;
3157
+ setup() {
3158
+ this.#d(), this.on(this, "click", (t) => {
3159
+ const s = t.target.closest('[data-ry-target="file"]');
3160
+ s && (this.$$("[data-ry-selected]").forEach((i) => i.removeAttribute("data-ry-selected")), s.setAttribute("data-ry-selected", ""), this.emit("select", {
3161
+ label: s.dataset.ryLabel ?? ""
3162
+ }));
3163
+ }), this.on(this, "change", (t) => {
3164
+ const e = t.target;
3165
+ if (!e.classList.contains("ry-tree__toggle")) return;
3166
+ const i = e.closest(".ry-tree__item")?.querySelector('[data-ry-target="folder"]')?.dataset.ryLabel ?? "";
3167
+ this.emit("toggle", {
3168
+ label: i,
3169
+ open: e.checked
3170
+ });
3171
+ }), this.hasAttribute("sortable") && this.#m();
3172
+ }
3173
+ // ── Build ──────────────────────────────────────────────────
3174
+ #d() {
3175
+ if (this.$(".ry-tree__root")) return;
3176
+ const t = Array.from(this.children), e = document.createElement("ul");
3177
+ e.className = "ry-tree__root";
3178
+ for (const s of t)
3179
+ e.appendChild(this.#o(s));
3180
+ this.innerHTML = "", this.appendChild(e);
3181
+ }
3182
+ #o(t) {
3183
+ const e = document.createElement("li");
3184
+ e.className = "ry-tree__item";
3185
+ const s = t.getAttribute("label") ?? "", i = t.hasAttribute("open"), r = t.hasAttribute("selected"), a = Array.from(t.children).filter(
3186
+ (h) => h.tagName === "RY-TREE-ITEM"
3187
+ );
3188
+ if (a.length > 0) {
3189
+ const h = `ry-tree-${++yt}`, l = document.createElement("input");
3190
+ l.type = "checkbox", l.id = h, l.className = "ry-tree__toggle", i && (l.checked = !0);
3191
+ const c = document.createElement("label");
3192
+ c.htmlFor = h, c.className = "ry-tree__label", c.setAttribute("data-ry-target", "folder"), c.dataset.ryLabel = s, c.innerHTML = `
3193
+ <span class="ry-tree__icon-closed">${_("folder")}</span>
3194
+ <span class="ry-tree__icon-open">${_("folder-open")}</span>
3195
+ ${s}
3196
+ `;
3197
+ const d = document.createElement("div");
3198
+ d.className = "ry-tree__children-wrapper";
3199
+ const u = document.createElement("ul");
3200
+ u.className = "ry-tree__children";
3201
+ for (const b of a)
3202
+ u.appendChild(this.#o(b));
3203
+ d.appendChild(u), e.appendChild(l), e.appendChild(c), e.appendChild(d);
3204
+ } else {
3205
+ const h = document.createElement("div");
3206
+ h.className = "ry-tree__file", h.setAttribute("data-ry-target", "file"), h.dataset.ryLabel = s, r && h.setAttribute("data-ry-selected", ""), h.innerHTML = `${_("file")} ${s}`, e.appendChild(h);
3207
+ }
3208
+ return e;
3209
+ }
3210
+ // ── Serialization ──────────────────────────────────────────
3211
+ /** Serialize the current tree state to JSON. */
3212
+ toJSON() {
3213
+ const t = this.$(".ry-tree__root");
3214
+ return t ? this.#a(t) : [];
3215
+ }
3216
+ /** Alias for toJSON(). */
3217
+ get value() {
3218
+ return this.toJSON();
3219
+ }
3220
+ #a(t) {
3221
+ return Array.from(t.children).filter(
3222
+ (s) => s instanceof HTMLElement && s.classList.contains("ry-tree__item")
3223
+ ).map((s) => this.#u(s));
3224
+ }
3225
+ #u(t) {
3226
+ const e = t.querySelector(':scope > [data-ry-target="folder"]'), s = t.querySelector(':scope > [data-ry-target="file"]');
3227
+ if (e) {
3228
+ const r = t.querySelector(":scope > .ry-tree__toggle"), a = t.querySelector(".ry-tree__children"), n = { label: e.dataset.ryLabel ?? "" };
3229
+ if (r?.checked && (n.open = !0), a) {
3230
+ const h = this.#a(a);
3231
+ h.length > 0 && (n.children = h);
3232
+ }
3233
+ return n;
3234
+ }
3235
+ const i = { label: s?.dataset.ryLabel ?? "" };
3236
+ return s?.hasAttribute("data-ry-selected") && (i.selected = !0), i;
3237
+ }
3238
+ /** Create a tree element from JSON data. */
3239
+ static from(t) {
3240
+ const e = document.createElement("ry-tree");
3241
+ for (const s of t)
3242
+ e.appendChild(k.#g(s));
3243
+ return e;
3244
+ }
3245
+ static #g(t) {
3246
+ const e = document.createElement("ry-tree-item");
3247
+ if (e.setAttribute("label", t.label), t.open && e.setAttribute("open", ""), t.selected && e.setAttribute("selected", ""), t.children)
3248
+ for (const s of t.children)
3249
+ e.appendChild(k.#g(s));
3250
+ return e;
3251
+ }
3252
+ // ── Drag and Drop ──────────────────────────────────────────
3253
+ #m() {
3254
+ this.on(this, "pointerdown", this.#f), this.on(document, "pointermove", this.#A), this.on(document, "pointerup", this.#c);
3255
+ }
3256
+ #f = (t) => {
3257
+ const s = t.target.closest(".ry-tree__label, .ry-tree__file");
3258
+ if (!s) return;
3259
+ const i = s.closest(".ry-tree__item");
3260
+ i && (this.#t = !0, this.#i = t.clientX, this.#s = t.clientY, this.#r = i);
3261
+ };
3262
+ #A = (t) => {
3263
+ if (!this.#t && !this.#e) return;
3264
+ if (this.#t && !this.#e) {
3265
+ const c = t.clientX - this.#i, d = t.clientY - this.#s;
3266
+ if (Math.hypot(c, d) < mt) return;
3267
+ this.#t = !1, this.#e = !0, this.#p(t);
3268
+ }
3269
+ if (!this.#e || !this.#n) return;
3270
+ this.#n.style.left = `${t.clientX + 12}px`, this.#n.style.top = `${t.clientY - 14}px`, this.#n.style.display = "none";
3271
+ const e = document.elementFromPoint(t.clientX, t.clientY);
3272
+ if (this.#n.style.display = "", !e) {
3273
+ this.#b();
3274
+ return;
3275
+ }
3276
+ const s = e.closest(".ry-tree__label, .ry-tree__file");
3277
+ if (!s) {
3278
+ this.#b();
3279
+ return;
3280
+ }
3281
+ const i = s.closest(".ry-tree__item");
3282
+ if (!i || i === this.#r) {
3283
+ this.#b();
3284
+ return;
3285
+ }
3286
+ if (this.#r?.contains(i)) {
3287
+ this.#b();
3288
+ return;
3289
+ }
3290
+ const r = s.getBoundingClientRect(), a = t.clientY - r.top, n = r.height, h = i.querySelector(":scope > .ry-tree__toggle") !== null;
3291
+ let l;
3292
+ h && a > n * 0.25 && a < n * 0.75 ? l = "inside" : a < n * 0.5 ? l = "before" : l = "after", this.#w(i, l);
3293
+ };
3294
+ #c = () => {
3295
+ this.#e && this.#y(), this.#t = !1, this.#e = !1, this.#r = null;
3296
+ };
3297
+ #p(t) {
3298
+ if (!this.#r) return;
3299
+ t.preventDefault(), this.#r.setAttribute("data-ry-dragging", ""), this.#r.classList.add("ry-tree__item--collapsed");
3300
+ const e = this.#r.querySelector(".ry-tree__label, .ry-tree__file");
3301
+ if (!e) return;
3302
+ const s = e.cloneNode(!0);
3303
+ 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.#n = s;
3304
+ }
3305
+ #y() {
3306
+ this.#n?.parentNode && this.#n.parentNode.removeChild(this.#n), this.#n = null, this.#r?.classList.remove("ry-tree__item--collapsed"), this.#r?.removeAttribute("data-ry-dragging");
3307
+ const t = this.#h, e = this.#l;
3308
+ this.#b(), this.#r && t && e && this.#S(this.#r, t, e);
3309
+ }
3310
+ #w(t, e) {
3311
+ this.#h === t && this.#l === e || (this.#b(), t.setAttribute("data-ry-drop-target", e), this.#h = t, this.#l = e);
3312
+ }
3313
+ #b() {
3314
+ this.#h?.removeAttribute("data-ry-drop-target"), this.#h = null, this.#l = null;
3315
+ }
3316
+ #S(t, e, s) {
3317
+ if (s === "inside" && e.contains(t)) return;
3318
+ const i = this.#M(t), r = this.#M(e);
3319
+ if (s === "before")
3320
+ e.parentNode?.insertBefore(t, e);
3321
+ else if (s === "after")
3322
+ e.parentNode?.insertBefore(t, e.nextSibling);
3323
+ else {
3324
+ const a = e.querySelector(".ry-tree__children");
3325
+ if (a) {
3326
+ a.appendChild(t);
3327
+ const n = e.querySelector(":scope > .ry-tree__toggle");
3328
+ n && !n.checked && (n.checked = !0);
3329
+ }
3330
+ }
3331
+ this.emit("move", {
3332
+ item: i,
3333
+ target: r,
3334
+ position: s
3335
+ });
3336
+ }
3337
+ #M(t) {
3338
+ const e = t.querySelector(':scope > [data-ry-target="folder"]'), s = t.querySelector(':scope > [data-ry-target="file"]');
3339
+ return e?.dataset.ryLabel ?? s?.dataset.ryLabel ?? "";
3340
+ }
3341
+ }
3342
+ class vt extends p {
3343
+ // Declarative container consumed by RyTree#build
3344
+ }
3345
+ customElements.define("ry-tree", k);
3346
+ customElements.define("ry-tree-item", vt);
3347
+ window.RyToast = f;
2416
3348
  console.log("ry-ui loaded");
2417
3349
  export {
2418
- T as RyAccordion,
2419
- j as RyAlert,
2420
- D as RyButton,
2421
- z as RyCode,
2422
- at as RyColorInput,
2423
- rt as RyColorPicker,
2424
- N as RyDrawer,
2425
- I as RyDropdown,
2426
- d as RyElement,
2427
- Y as RyExample,
2428
- B as RyField,
2429
- G as RyIcon,
2430
- et as RyKnob,
2431
- H as RyModal,
2432
- V as RySelect,
2433
- tt as RySlider,
2434
- P as RySwitch,
2435
- L as RyTabs,
2436
- F as RyThemeToggle,
2437
- p as RyToast,
2438
- Q as RyToggleButton,
2439
- K as RyTooltip,
2440
- y as getIcon,
2441
- lt as getIconNames,
2442
- _ as processTransforms,
2443
- ot as registerIcon,
2444
- ht as registerIcons,
2445
- k as transform
3350
+ F as RyAccordion,
3351
+ K as RyAlert,
3352
+ O as RyButton,
3353
+ Q as RyCode,
3354
+ ut as RyColorInput,
3355
+ dt as RyColorPicker,
3356
+ W as RyDrawer,
3357
+ j as RyDropdown,
3358
+ p as RyElement,
3359
+ tt as RyExample,
3360
+ q as RyField,
3361
+ bt as RyGradientPicker,
3362
+ et as RyIcon,
3363
+ ot as RyKnob,
3364
+ P as RyModal,
3365
+ ht as RyNumberSelect,
3366
+ J as RySelect,
3367
+ nt as RySlider,
3368
+ V as RySwitch,
3369
+ R as RyTabs,
3370
+ N as RyThemeToggle,
3371
+ f as RyToast,
3372
+ at as RyToggleButton,
3373
+ z as RyTooltip,
3374
+ k as RyTree,
3375
+ vt as RyTreeItem,
3376
+ g as getIcon,
3377
+ $t as getIconNames,
3378
+ C as processTransforms,
3379
+ kt as registerIcon,
3380
+ At as registerIcons,
3381
+ M as transform
2446
3382
  };
2447
3383
  //# sourceMappingURL=ry-ui.js.map