@ryanhelsing/ry-ui 1.0.1 → 1.0.3
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/AGENTS.md +56 -0
- package/README.md +28 -1
- package/dist/components/ry-carousel.d.ts +21 -0
- package/dist/components/ry-carousel.d.ts.map +1 -0
- package/dist/components/ry-dropdown.d.ts.map +1 -1
- package/dist/components/ry-example.d.ts +1 -1
- package/dist/components/ry-feature.d.ts +21 -0
- package/dist/components/ry-feature.d.ts.map +1 -0
- package/dist/components/ry-gradient-picker.d.ts +39 -0
- package/dist/components/ry-gradient-picker.d.ts.map +1 -0
- package/dist/components/ry-hero.d.ts +16 -0
- package/dist/components/ry-hero.d.ts.map +1 -0
- package/dist/components/ry-number-select.d.ts +30 -0
- package/dist/components/ry-number-select.d.ts.map +1 -0
- package/dist/components/ry-pricing.d.ts +21 -0
- package/dist/components/ry-pricing.d.ts.map +1 -0
- package/dist/components/ry-select.d.ts +8 -1
- package/dist/components/ry-select.d.ts.map +1 -1
- package/dist/components/ry-stat.d.ts +17 -0
- package/dist/components/ry-stat.d.ts.map +1 -0
- package/dist/components/ry-tag-input.d.ts +18 -0
- package/dist/components/ry-tag-input.d.ts.map +1 -0
- package/dist/components/ry-tag.d.ts +19 -0
- package/dist/components/ry-tag.d.ts.map +1 -0
- package/dist/components/ry-tree.d.ts +41 -0
- package/dist/components/ry-tree.d.ts.map +1 -0
- package/dist/core/ry-icons.d.ts.map +1 -1
- package/dist/core/ry-transform.d.ts.map +1 -1
- package/dist/css/ry-structure.css +1020 -95
- package/dist/css/ry-theme.css +772 -145
- package/dist/css/ry-tokens.css +112 -24
- package/dist/css/ry-ui.css +4713 -927
- package/dist/ry-ui.d.ts +12 -0
- package/dist/ry-ui.d.ts.map +1 -1
- package/dist/ry-ui.js +1838 -544
- package/dist/ry-ui.js.map +1 -1
- package/dist/themes/dark.css +7 -90
- package/dist/themes/light.css +6 -35
- package/dist/themes/ocean.css +22 -26
- package/docs/components/accordion.md +31 -0
- package/docs/components/button.md +65 -0
- package/docs/components/color.md +84 -0
- package/docs/components/display.md +69 -0
- package/docs/components/drawer.md +36 -0
- package/docs/components/dropdown.md +33 -0
- package/docs/components/forms.md +86 -0
- package/docs/components/knob.md +42 -0
- package/docs/components/layout.md +189 -0
- package/docs/components/modal.md +38 -0
- package/docs/components/number-select.md +42 -0
- package/docs/components/slider.md +48 -0
- package/docs/components/tabs.md +30 -0
- package/docs/components/theme-toggle.md +36 -0
- package/docs/components/toast.md +27 -0
- package/docs/components/tooltip.md +14 -0
- package/docs/components/tree.md +46 -0
- package/docs/theming.md +182 -0
- package/package.json +5 -3
- package/USING_CDN.md +0 -390
package/dist/ry-ui.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
class
|
|
1
|
+
class u 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
|
|
92
|
+
const D = [
|
|
93
93
|
// Layout
|
|
94
94
|
"page",
|
|
95
95
|
"header",
|
|
@@ -132,26 +132,39 @@ const E = [
|
|
|
132
132
|
"toggle-button",
|
|
133
133
|
"slider",
|
|
134
134
|
"knob",
|
|
135
|
+
"number-select",
|
|
135
136
|
"color-picker",
|
|
136
|
-
"color-input"
|
|
137
|
-
|
|
138
|
-
|
|
137
|
+
"color-input",
|
|
138
|
+
"gradient-picker",
|
|
139
|
+
"tree",
|
|
140
|
+
"tree-item",
|
|
141
|
+
"tag",
|
|
142
|
+
"tag-input",
|
|
143
|
+
"hero",
|
|
144
|
+
"stat",
|
|
145
|
+
"feature",
|
|
146
|
+
"feature-grid",
|
|
147
|
+
"pricing",
|
|
148
|
+
"pricing-card",
|
|
149
|
+
"carousel"
|
|
150
|
+
], B = new RegExp(
|
|
151
|
+
`<(/?)(${D.join("|")})(\\s|>|/)`,
|
|
139
152
|
"g"
|
|
140
153
|
);
|
|
141
|
-
function
|
|
142
|
-
return
|
|
154
|
+
function M(h) {
|
|
155
|
+
return h.replace(B, "<$1ry-$2$3");
|
|
143
156
|
}
|
|
144
|
-
function
|
|
145
|
-
document.querySelectorAll("ry").forEach((
|
|
146
|
-
const t =
|
|
147
|
-
e.innerHTML = t,
|
|
148
|
-
}), document.querySelectorAll("template[ry]").forEach((
|
|
149
|
-
const t =
|
|
150
|
-
e.innerHTML = t,
|
|
157
|
+
function E() {
|
|
158
|
+
document.querySelectorAll("ry").forEach((h) => {
|
|
159
|
+
const t = M(h.innerHTML), e = document.createElement("template");
|
|
160
|
+
e.innerHTML = t, h.replaceWith(e.content);
|
|
161
|
+
}), document.querySelectorAll("template[ry]").forEach((h) => {
|
|
162
|
+
const t = M(h.innerHTML), e = document.createElement("template");
|
|
163
|
+
e.innerHTML = t, h.replaceWith(e.content);
|
|
151
164
|
});
|
|
152
165
|
}
|
|
153
|
-
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded",
|
|
154
|
-
class
|
|
166
|
+
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", E) : E();
|
|
167
|
+
class R extends u {
|
|
155
168
|
setup() {
|
|
156
169
|
this.#t(), this.$$('[data-ry-target="trigger"]').forEach((t) => {
|
|
157
170
|
this.on(t, "click", this.#i);
|
|
@@ -227,10 +240,10 @@ class T extends d {
|
|
|
227
240
|
this.$$('[data-ry-target="item"]').forEach((t) => this.close(t));
|
|
228
241
|
}
|
|
229
242
|
}
|
|
230
|
-
customElements.define("ry-accordion",
|
|
243
|
+
customElements.define("ry-accordion", R);
|
|
231
244
|
customElements.get("ry-accordion-item") || customElements.define("ry-accordion-item", class extends HTMLElement {
|
|
232
245
|
});
|
|
233
|
-
class
|
|
246
|
+
class P extends u {
|
|
234
247
|
#t = null;
|
|
235
248
|
#e = 0;
|
|
236
249
|
setup() {
|
|
@@ -279,8 +292,8 @@ class H extends d {
|
|
|
279
292
|
this.state === "open" ? this.close() : this.open();
|
|
280
293
|
}
|
|
281
294
|
}
|
|
282
|
-
customElements.define("ry-modal",
|
|
283
|
-
class
|
|
295
|
+
customElements.define("ry-modal", P);
|
|
296
|
+
class F extends u {
|
|
284
297
|
setup() {
|
|
285
298
|
this.#t(), this.$$('[data-ry-target="trigger"]').forEach((t) => {
|
|
286
299
|
this.on(t, "click", this.#i);
|
|
@@ -291,8 +304,8 @@ class L extends d {
|
|
|
291
304
|
if (t.length === 0) return;
|
|
292
305
|
const e = t.findIndex((r) => r.hasAttribute("active")), s = e === -1 ? 0 : e, i = document.createElement("div");
|
|
293
306
|
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}`,
|
|
295
|
-
|
|
307
|
+
const n = r.getAttribute("title") ?? `Tab ${a + 1}`, o = a === s, l = document.createElement("button");
|
|
308
|
+
l.setAttribute("data-ry-target", "trigger"), l.className = "ry-tabs__trigger", l.setAttribute("role", "tab"), l.setAttribute("aria-selected", String(o)), l.textContent = n, i.appendChild(l), r.setAttribute("data-ry-target", "panel"), r.className = "ry-tabs__panel", r.setAttribute("role", "tabpanel"), r.dataset.ryState = o ? "active" : "", r.removeAttribute("title"), r.removeAttribute("active");
|
|
296
309
|
}), this.insertBefore(i, this.firstChild);
|
|
297
310
|
}
|
|
298
311
|
#e() {
|
|
@@ -300,8 +313,8 @@ class L extends d {
|
|
|
300
313
|
t.forEach((i, r) => {
|
|
301
314
|
const a = e[r];
|
|
302
315
|
if (!a) return;
|
|
303
|
-
const n = i.id || `ry-tab-${this.id || ""}-${r}`,
|
|
304
|
-
i.id = n, a.id =
|
|
316
|
+
const n = i.id || `ry-tab-${this.id || ""}-${r}`, o = a.id || `ry-tabpanel-${this.id || ""}-${r}`;
|
|
317
|
+
i.id = n, a.id = o, i.setAttribute("aria-controls", o), a.setAttribute("aria-labelledby", n), i.setAttribute("tabindex", i.getAttribute("aria-selected") === "true" ? "0" : "-1");
|
|
305
318
|
}), t.findIndex((i) => i.getAttribute("aria-selected") === "true") === -1 && t.length > 0 && this.select(0);
|
|
306
319
|
}
|
|
307
320
|
#i = (t) => {
|
|
@@ -342,10 +355,10 @@ class L extends d {
|
|
|
342
355
|
return this.$$('[data-ry-target="trigger"]').findIndex((e) => e.getAttribute("aria-selected") === "true");
|
|
343
356
|
}
|
|
344
357
|
}
|
|
345
|
-
customElements.define("ry-tabs",
|
|
358
|
+
customElements.define("ry-tabs", F);
|
|
346
359
|
customElements.get("ry-tab") || customElements.define("ry-tab", class extends HTMLElement {
|
|
347
360
|
});
|
|
348
|
-
class
|
|
361
|
+
class j extends u {
|
|
349
362
|
setup() {
|
|
350
363
|
this.#t();
|
|
351
364
|
const t = this.$('[data-ry-target="trigger"]');
|
|
@@ -375,24 +388,30 @@ class I extends d {
|
|
|
375
388
|
};
|
|
376
389
|
open() {
|
|
377
390
|
if (this.state === "open") return;
|
|
378
|
-
this.$('[data-ry-target="trigger"]')?.setAttribute("aria-expanded", "true"), this.state = "open", this.nextFrame().then(() => {
|
|
391
|
+
this.#s(), this.$('[data-ry-target="trigger"]')?.setAttribute("aria-expanded", "true"), this.state = "open", this.nextFrame().then(() => {
|
|
379
392
|
this.$('[data-ry-target="item"], ry-menu-item')?.focus();
|
|
380
393
|
}), this.emit("open");
|
|
381
394
|
}
|
|
382
395
|
close() {
|
|
383
396
|
if (this.state === "closed") return;
|
|
384
|
-
this.$('[data-ry-target="trigger"]')?.setAttribute("aria-expanded", "false"), this.state = "closed", this.emit("close");
|
|
397
|
+
this.$('[data-ry-target="trigger"]')?.setAttribute("aria-expanded", "false"), this.state = "closed", this.removeAttribute("data-ry-position"), this.emit("close");
|
|
398
|
+
}
|
|
399
|
+
#s() {
|
|
400
|
+
const t = this.$('[data-ry-target="menu"], ry-menu');
|
|
401
|
+
if (!t) return;
|
|
402
|
+
const e = this.getBoundingClientRect(), s = t.scrollHeight || 240, i = window.innerHeight - e.bottom, r = e.top;
|
|
403
|
+
i < s && r > i ? this.setAttribute("data-ry-position", "top") : this.setAttribute("data-ry-position", "bottom");
|
|
385
404
|
}
|
|
386
405
|
toggle() {
|
|
387
406
|
this.state === "open" ? this.close() : this.open();
|
|
388
407
|
}
|
|
389
408
|
}
|
|
390
|
-
customElements.define("ry-dropdown",
|
|
409
|
+
customElements.define("ry-dropdown", j);
|
|
391
410
|
customElements.get("ry-menu") || customElements.define("ry-menu", class extends HTMLElement {
|
|
392
411
|
});
|
|
393
412
|
customElements.get("ry-menu-item") || customElements.define("ry-menu-item", class extends HTMLElement {
|
|
394
413
|
});
|
|
395
|
-
class
|
|
414
|
+
class N extends u {
|
|
396
415
|
setup() {
|
|
397
416
|
this.hasAttribute("tabindex") || this.setAttribute("tabindex", "0"), this.setAttribute("role", "button"), this.on(this, "click", this.#t), this.on(this, "keydown", this.#e);
|
|
398
417
|
}
|
|
@@ -407,8 +426,8 @@ class D extends d {
|
|
|
407
426
|
(t.key === "Enter" || t.key === " ") && (t.preventDefault(), this.click());
|
|
408
427
|
};
|
|
409
428
|
}
|
|
410
|
-
customElements.define("ry-button",
|
|
411
|
-
class
|
|
429
|
+
customElements.define("ry-button", N);
|
|
430
|
+
class O extends u {
|
|
412
431
|
#t = ["light", "dark"];
|
|
413
432
|
#e = 0;
|
|
414
433
|
setup() {
|
|
@@ -448,8 +467,8 @@ class F extends d {
|
|
|
448
467
|
}
|
|
449
468
|
}
|
|
450
469
|
}
|
|
451
|
-
customElements.define("ry-theme-toggle",
|
|
452
|
-
class
|
|
470
|
+
customElements.define("ry-theme-toggle", O);
|
|
471
|
+
class K extends u {
|
|
453
472
|
setup() {
|
|
454
473
|
this.#t();
|
|
455
474
|
const t = this.$("[close]");
|
|
@@ -469,8 +488,8 @@ class j extends d {
|
|
|
469
488
|
}, 200), this.emit("close");
|
|
470
489
|
}
|
|
471
490
|
}
|
|
472
|
-
customElements.define("ry-alert",
|
|
473
|
-
class
|
|
491
|
+
customElements.define("ry-alert", K);
|
|
492
|
+
class q extends u {
|
|
474
493
|
setup() {
|
|
475
494
|
this.#t();
|
|
476
495
|
}
|
|
@@ -486,9 +505,9 @@ class B extends d {
|
|
|
486
505
|
i.setAttribute("data-ry-target", "label"), i.className = "ry-label", i.setAttribute("for", s), i.textContent = t, this.insertBefore(i, e);
|
|
487
506
|
}
|
|
488
507
|
}
|
|
489
|
-
customElements.define("ry-field",
|
|
490
|
-
let
|
|
491
|
-
class
|
|
508
|
+
customElements.define("ry-field", q);
|
|
509
|
+
let V = 0;
|
|
510
|
+
class z extends u {
|
|
492
511
|
#t = null;
|
|
493
512
|
static observedAttributes = ["checked", "disabled"];
|
|
494
513
|
setup() {
|
|
@@ -496,7 +515,7 @@ class P extends d {
|
|
|
496
515
|
}
|
|
497
516
|
#e() {
|
|
498
517
|
if (this.$('[data-ry-target="track"]')) return;
|
|
499
|
-
const t = `ry-switch-${++
|
|
518
|
+
const t = `ry-switch-${++V}`, e = this.getAttribute("name") ?? "", s = this.hasAttribute("checked"), i = this.hasAttribute("disabled"), r = this.textContent?.trim() ?? "";
|
|
500
519
|
this.innerHTML = `
|
|
501
520
|
<label data-ry-target="wrapper" class="ry-switch__wrapper" for="${t}">
|
|
502
521
|
<input
|
|
@@ -541,41 +560,41 @@ class P extends d {
|
|
|
541
560
|
this.#t && (this.#t.value = t);
|
|
542
561
|
}
|
|
543
562
|
}
|
|
544
|
-
customElements.define("ry-switch",
|
|
545
|
-
let
|
|
546
|
-
class
|
|
563
|
+
customElements.define("ry-switch", z);
|
|
564
|
+
let U = 0;
|
|
565
|
+
class Y extends u {
|
|
547
566
|
#t = null;
|
|
548
567
|
#e = null;
|
|
549
568
|
#i = null;
|
|
550
569
|
setup() {
|
|
551
|
-
this.#i = `ry-tooltip-${++
|
|
570
|
+
this.#i = `ry-tooltip-${++U}`, this.#s();
|
|
552
571
|
const t = this.firstElementChild;
|
|
553
|
-
t && (t.setAttribute("aria-describedby", this.#i), this.on(t, "mouseenter", this.#r), this.on(t, "mouseleave", this.#
|
|
572
|
+
t && (t.setAttribute("aria-describedby", this.#i), this.on(t, "mouseenter", this.#r), this.on(t, "mouseleave", this.#o), this.on(t, "focusin", this.#r), this.on(t, "focusout", this.#o)), this.on(document, "keydown", this.#l);
|
|
554
573
|
}
|
|
555
574
|
#s() {
|
|
556
575
|
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);
|
|
557
576
|
}
|
|
558
577
|
#r = () => {
|
|
559
578
|
this.#t && clearTimeout(this.#t), this.#t = setTimeout(() => {
|
|
560
|
-
this.#
|
|
579
|
+
this.#a();
|
|
561
580
|
}, 200);
|
|
562
581
|
};
|
|
563
|
-
#
|
|
582
|
+
#a = () => {
|
|
564
583
|
const t = this.getAttribute("position") ?? "top";
|
|
565
584
|
this.setAttribute("data-ry-position", t), this.state = "open";
|
|
566
585
|
};
|
|
567
|
-
#
|
|
586
|
+
#o = () => {
|
|
568
587
|
this.#t && (clearTimeout(this.#t), this.#t = null), this.state = "closed";
|
|
569
588
|
};
|
|
570
|
-
#
|
|
571
|
-
t.key === "Escape" && this.state === "open" && this.#
|
|
589
|
+
#l = (t) => {
|
|
590
|
+
t.key === "Escape" && this.state === "open" && this.#o();
|
|
572
591
|
};
|
|
573
592
|
teardown() {
|
|
574
593
|
this.#t && clearTimeout(this.#t);
|
|
575
594
|
}
|
|
576
595
|
}
|
|
577
|
-
customElements.define("ry-tooltip",
|
|
578
|
-
class
|
|
596
|
+
customElements.define("ry-tooltip", Y);
|
|
597
|
+
class W extends u {
|
|
579
598
|
#t = null;
|
|
580
599
|
#e = 0;
|
|
581
600
|
setup() {
|
|
@@ -620,38 +639,38 @@ class N extends d {
|
|
|
620
639
|
this.state === "open" ? this.close() : this.open();
|
|
621
640
|
}
|
|
622
641
|
}
|
|
623
|
-
customElements.define("ry-drawer",
|
|
624
|
-
const
|
|
625
|
-
class
|
|
642
|
+
customElements.define("ry-drawer", W);
|
|
643
|
+
const X = 4e3;
|
|
644
|
+
class f extends u {
|
|
626
645
|
#t = null;
|
|
627
646
|
static observedAttributes = ["variant", "duration"];
|
|
628
647
|
// Static container for programmatic toasts
|
|
629
648
|
static #e = null;
|
|
630
649
|
static #i() {
|
|
631
|
-
return
|
|
650
|
+
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
651
|
}
|
|
633
652
|
// Static API
|
|
634
653
|
static show(t) {
|
|
635
654
|
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)),
|
|
655
|
+
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
656
|
}
|
|
638
657
|
static success(t, e) {
|
|
639
|
-
return
|
|
658
|
+
return f.show({ message: t, variant: "success", duration: e });
|
|
640
659
|
}
|
|
641
660
|
static error(t, e) {
|
|
642
|
-
return
|
|
661
|
+
return f.show({ message: t, variant: "error", duration: e });
|
|
643
662
|
}
|
|
644
663
|
static info(t, e) {
|
|
645
|
-
return
|
|
664
|
+
return f.show({ message: t, variant: "info", duration: e });
|
|
646
665
|
}
|
|
647
666
|
static warning(t, e) {
|
|
648
|
-
return
|
|
667
|
+
return f.show({ message: t, variant: "warning", duration: e });
|
|
649
668
|
}
|
|
650
669
|
setup() {
|
|
651
670
|
this.#s();
|
|
652
671
|
const t = this.$("[close]");
|
|
653
672
|
t && this.on(t, "click", () => this.dismiss());
|
|
654
|
-
const e = parseInt(this.getAttribute("duration") ?? String(
|
|
673
|
+
const e = parseInt(this.getAttribute("duration") ?? String(X), 10);
|
|
655
674
|
e > 0 && (this.#t = setTimeout(() => this.dismiss(), e)), requestAnimationFrame(() => {
|
|
656
675
|
this.state = "visible";
|
|
657
676
|
});
|
|
@@ -683,62 +702,180 @@ class p extends d {
|
|
|
683
702
|
this.#t && clearTimeout(this.#t);
|
|
684
703
|
}
|
|
685
704
|
}
|
|
686
|
-
customElements.define("ry-toast",
|
|
687
|
-
|
|
688
|
-
|
|
705
|
+
customElements.define("ry-toast", f);
|
|
706
|
+
const w = {
|
|
707
|
+
// Close / X
|
|
708
|
+
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>',
|
|
709
|
+
// Chevron down
|
|
710
|
+
"chevron-down": '<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="M6 9l6 6 6-6"/></svg>',
|
|
711
|
+
// Chevron up
|
|
712
|
+
"chevron-up": '<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 15l-6-6-6 6"/></svg>',
|
|
713
|
+
// Chevron right
|
|
714
|
+
"chevron-right": '<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="M9 18l6-6-6-6"/></svg>',
|
|
715
|
+
// Chevron left
|
|
716
|
+
"chevron-left": '<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="M15 18l-6-6 6-6"/></svg>',
|
|
717
|
+
// Check / Checkmark
|
|
718
|
+
check: '<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="M20 6L9 17l-5-5"/></svg>',
|
|
719
|
+
// Copy
|
|
720
|
+
copy: '<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="9" y="9" width="13" height="13" rx="2"/><path d="M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"/></svg>',
|
|
721
|
+
// Sun (light mode)
|
|
722
|
+
sun: '<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="4"/><path d="M12 2v2"/><path d="M12 20v2"/><path d="M4.93 4.93l1.41 1.41"/><path d="M17.66 17.66l1.41 1.41"/><path d="M2 12h2"/><path d="M20 12h2"/><path d="M6.34 17.66l-1.41 1.41"/><path d="M19.07 4.93l-1.41 1.41"/></svg>',
|
|
723
|
+
// Moon (dark mode)
|
|
724
|
+
moon: '<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 12.79A9 9 0 1111.21 3 7 7 0 0021 12.79z"/></svg>',
|
|
725
|
+
// Info
|
|
726
|
+
info: '<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="10"/><path d="M12 16v-4"/><path d="M12 8h.01"/></svg>',
|
|
727
|
+
// Warning / Alert triangle
|
|
728
|
+
warning: '<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="M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z"/><path d="M12 9v4"/><path d="M12 17h.01"/></svg>',
|
|
729
|
+
// Error / X circle
|
|
730
|
+
error: '<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="10"/><path d="M15 9l-6 6"/><path d="M9 9l6 6"/></svg>',
|
|
731
|
+
// Success / Check circle
|
|
732
|
+
success: '<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="10"/><path d="M9 12l2 2 4-4"/></svg>',
|
|
733
|
+
// Search
|
|
734
|
+
search: '<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="11" cy="11" r="8"/><path d="M21 21l-4.35-4.35"/></svg>',
|
|
735
|
+
// Menu / Hamburger
|
|
736
|
+
menu: '<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="M3 12h18"/><path d="M3 6h18"/><path d="M3 18h18"/></svg>',
|
|
737
|
+
// Plus
|
|
738
|
+
plus: '<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="M12 5v14"/><path d="M5 12h14"/></svg>',
|
|
739
|
+
// Minus
|
|
740
|
+
minus: '<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="M5 12h14"/></svg>',
|
|
741
|
+
// Settings / Gear
|
|
742
|
+
settings: '<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="3"/><path d="M19.4 15a1.65 1.65 0 00.33 1.82l.06.06a2 2 0 010 2.83 2 2 0 01-2.83 0l-.06-.06a1.65 1.65 0 00-1.82-.33 1.65 1.65 0 00-1 1.51V21a2 2 0 01-2 2 2 2 0 01-2-2v-.09A1.65 1.65 0 009 19.4a1.65 1.65 0 00-1.82.33l-.06.06a2 2 0 01-2.83 0 2 2 0 010-2.83l.06-.06a1.65 1.65 0 00.33-1.82 1.65 1.65 0 00-1.51-1H3a2 2 0 01-2-2 2 2 0 012-2h.09A1.65 1.65 0 004.6 9a1.65 1.65 0 00-.33-1.82l-.06-.06a2 2 0 010-2.83 2 2 0 012.83 0l.06.06a1.65 1.65 0 001.82.33H9a1.65 1.65 0 001-1.51V3a2 2 0 012-2 2 2 0 012 2v.09a1.65 1.65 0 001 1.51 1.65 1.65 0 001.82-.33l.06-.06a2 2 0 012.83 0 2 2 0 010 2.83l-.06.06a1.65 1.65 0 00-.33 1.82V9a1.65 1.65 0 001.51 1H21a2 2 0 012 2 2 2 0 01-2 2h-.09a1.65 1.65 0 00-1.51 1z"/></svg>',
|
|
743
|
+
// User
|
|
744
|
+
user: '<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="M20 21v-2a4 4 0 00-4-4H8a4 4 0 00-4 4v2"/><circle cx="12" cy="7" r="4"/></svg>',
|
|
745
|
+
// Heart
|
|
746
|
+
heart: '<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="M20.84 4.61a5.5 5.5 0 00-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 00-7.78 7.78l1.06 1.06L12 21.23l7.78-7.78 1.06-1.06a5.5 5.5 0 000-7.78z"/></svg>',
|
|
747
|
+
// Star
|
|
748
|
+
star: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polygon points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"/></svg>',
|
|
749
|
+
// Trash
|
|
750
|
+
trash: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 01-2 2H7a2 2 0 01-2-2V6m3 0V4a2 2 0 012-2h4a2 2 0 012 2v2"/></svg>',
|
|
751
|
+
// Edit / Pencil
|
|
752
|
+
edit: '<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="M11 4H4a2 2 0 00-2 2v14a2 2 0 002 2h14a2 2 0 002-2v-7"/><path d="M18.5 2.5a2.121 2.121 0 013 3L12 15l-4 1 1-4 9.5-9.5z"/></svg>',
|
|
753
|
+
// External link
|
|
754
|
+
"external-link": '<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 13v6a2 2 0 01-2 2H5a2 2 0 01-2-2V8a2 2 0 012-2h6"/><polyline points="15 3 21 3 21 9"/><line x1="10" y1="14" x2="21" y2="3"/></svg>',
|
|
755
|
+
// Download
|
|
756
|
+
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>',
|
|
757
|
+
// Upload
|
|
758
|
+
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>',
|
|
759
|
+
// Folder (closed)
|
|
760
|
+
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>',
|
|
761
|
+
// Folder open
|
|
762
|
+
"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>',
|
|
763
|
+
// File
|
|
764
|
+
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>',
|
|
765
|
+
// Gradient: solid color
|
|
766
|
+
"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>',
|
|
767
|
+
// Gradient: linear
|
|
768
|
+
"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>',
|
|
769
|
+
// Gradient: radial
|
|
770
|
+
"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>',
|
|
771
|
+
// Shape: circle
|
|
772
|
+
"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>',
|
|
773
|
+
// Shape: ellipse
|
|
774
|
+
"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>'
|
|
775
|
+
};
|
|
776
|
+
function p(h) {
|
|
777
|
+
return w[h] ?? "";
|
|
778
|
+
}
|
|
779
|
+
function Tt(h, t) {
|
|
780
|
+
w[h] = t;
|
|
781
|
+
}
|
|
782
|
+
function Lt(h) {
|
|
783
|
+
Object.assign(w, h);
|
|
784
|
+
}
|
|
785
|
+
function It() {
|
|
786
|
+
return Object.keys(w);
|
|
787
|
+
}
|
|
788
|
+
let G = 0;
|
|
789
|
+
class J extends u {
|
|
689
790
|
#t = null;
|
|
690
791
|
#e = -1;
|
|
691
792
|
#i = "";
|
|
692
793
|
#s = null;
|
|
794
|
+
#r = /* @__PURE__ */ new Set();
|
|
693
795
|
// Store options reference
|
|
694
796
|
_options = [];
|
|
797
|
+
get #a() {
|
|
798
|
+
return this.hasAttribute("multiple");
|
|
799
|
+
}
|
|
695
800
|
static observedAttributes = ["value", "disabled"];
|
|
696
801
|
setup() {
|
|
697
|
-
this.#t = `ry-select-${++
|
|
802
|
+
this.#t = `ry-select-${++G}`, this.#o(), this.hasAttribute("tabindex") || this.setAttribute("tabindex", "0"), this.on(this, "click", this.#l), this.on(this, "keydown", this.#c), this.on(document, "click", this.#h), this.#a && this.on(this, "ry:remove", this.#n), this.hasAttribute("data-ry-state") || (this.state = "closed");
|
|
698
803
|
const t = this.getAttribute("value");
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
804
|
+
if (t)
|
|
805
|
+
if (this.#a)
|
|
806
|
+
for (const e of t.split(",").map((s) => s.trim()).filter(Boolean))
|
|
807
|
+
this.#d(e);
|
|
808
|
+
else
|
|
809
|
+
this.value = t;
|
|
810
|
+
}
|
|
811
|
+
#o() {
|
|
812
|
+
const t = [...this.querySelectorAll("ry-option")].map((o) => ({
|
|
813
|
+
value: o.getAttribute("value") ?? o.textContent?.trim() ?? "",
|
|
814
|
+
label: o.textContent?.trim() ?? "",
|
|
815
|
+
disabled: o.hasAttribute("disabled")
|
|
816
|
+
})), e = this.getAttribute("placeholder") ?? "Select...", s = this.getAttribute("name") ?? "", i = this.hasAttribute("disabled"), r = this.#a, a = t.map(
|
|
817
|
+
(o) => `<option value="${o.value}"${o.disabled ? " disabled" : ""}>${o.label}</option>`
|
|
818
|
+
).join(""), n = t.map((o, l) => `
|
|
709
819
|
<div data-ry-target="option" class="ry-select__option"
|
|
710
820
|
role="option"
|
|
711
821
|
id="${this.#t}-option-${l}"
|
|
712
|
-
data-value="${
|
|
713
|
-
${
|
|
714
|
-
aria-disabled="${
|
|
715
|
-
${
|
|
822
|
+
data-value="${o.value}"
|
|
823
|
+
${o.disabled ? "data-disabled" : ""}
|
|
824
|
+
aria-disabled="${o.disabled}">
|
|
825
|
+
${r ? `<span data-ry-target="check" class="ry-select__check">${p("check")}</span>` : ""}
|
|
826
|
+
<span class="ry-select__option-label">${o.label}</span>
|
|
716
827
|
</div>
|
|
717
828
|
`).join("");
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
<
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
<
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
829
|
+
if (r) {
|
|
830
|
+
const o = this.hasAttribute("clearable");
|
|
831
|
+
this.innerHTML = `
|
|
832
|
+
<div data-ry-target="trigger" class="ry-select__trigger ry-select__trigger--multi" aria-haspopup="listbox" aria-expanded="false">
|
|
833
|
+
<div data-ry-target="tags" class="ry-select__tags"></div>
|
|
834
|
+
<span data-ry-target="value" class="ry-select__value">${e}</span>
|
|
835
|
+
${o ? `<button data-ry-target="clear" class="ry-select__clear" aria-label="Clear all" type="button">${p("close")}</button>` : ""}
|
|
836
|
+
<span data-ry-target="arrow" class="ry-select__arrow">▾</span>
|
|
837
|
+
</div>
|
|
838
|
+
<div data-ry-target="dropdown" class="ry-select__dropdown" role="listbox" id="${this.#t}-listbox" tabindex="-1" aria-multiselectable="true">
|
|
839
|
+
${n}
|
|
840
|
+
</div>
|
|
841
|
+
<select data-ry-target="native" class="ry-select__native" ${s ? `name="${s}"` : ""} multiple tabindex="-1" aria-hidden="true" ${i ? "disabled" : ""}>
|
|
842
|
+
${a}
|
|
843
|
+
</select>
|
|
844
|
+
`;
|
|
845
|
+
const l = this.$('[data-ry-target="clear"]');
|
|
846
|
+
l && this.on(l, "click", (c) => {
|
|
847
|
+
c.stopPropagation(), this.#M();
|
|
848
|
+
});
|
|
849
|
+
} else
|
|
850
|
+
this.innerHTML = `
|
|
851
|
+
<div data-ry-target="trigger" class="ry-select__trigger" aria-haspopup="listbox" aria-expanded="false">
|
|
852
|
+
<span data-ry-target="value" class="ry-select__value">${e}</span>
|
|
853
|
+
<span data-ry-target="arrow" class="ry-select__arrow">▾</span>
|
|
854
|
+
</div>
|
|
855
|
+
<div data-ry-target="dropdown" class="ry-select__dropdown" role="listbox" id="${this.#t}-listbox" tabindex="-1">
|
|
856
|
+
${n}
|
|
857
|
+
</div>
|
|
858
|
+
<select data-ry-target="native" class="ry-select__native" ${s ? `name="${s}"` : ""} tabindex="-1" aria-hidden="true" ${i ? "disabled" : ""}>
|
|
859
|
+
<option value="">${e}</option>
|
|
860
|
+
${a}
|
|
861
|
+
</select>
|
|
862
|
+
`;
|
|
863
|
+
this._options = t;
|
|
731
864
|
}
|
|
732
|
-
#
|
|
865
|
+
#l = (t) => {
|
|
733
866
|
if (this.hasAttribute("disabled")) return;
|
|
734
867
|
const e = t.target, s = e.closest('[data-ry-target="option"]');
|
|
735
868
|
if (s instanceof HTMLElement && !s.hasAttribute("data-disabled")) {
|
|
736
|
-
this.#
|
|
869
|
+
if (this.#a) {
|
|
870
|
+
const r = s.dataset.value ?? "";
|
|
871
|
+
this.#d(r);
|
|
872
|
+
} else
|
|
873
|
+
this.#$(s), this.close();
|
|
737
874
|
return;
|
|
738
875
|
}
|
|
739
876
|
e.closest('[data-ry-target="trigger"]') && this.toggle();
|
|
740
877
|
};
|
|
741
|
-
#
|
|
878
|
+
#c = (t) => {
|
|
742
879
|
if (this.hasAttribute("disabled")) return;
|
|
743
880
|
const e = this.state === "open";
|
|
744
881
|
switch (t.key) {
|
|
@@ -746,7 +883,12 @@ class V extends d {
|
|
|
746
883
|
case " ":
|
|
747
884
|
if (t.preventDefault(), e && this.#e >= 0) {
|
|
748
885
|
const i = this.$$('[data-ry-target="option"]:not([data-disabled])')[this.#e];
|
|
749
|
-
|
|
886
|
+
if (i)
|
|
887
|
+
if (this.#a) {
|
|
888
|
+
const r = i.dataset.value ?? "";
|
|
889
|
+
this.#d(r);
|
|
890
|
+
} else
|
|
891
|
+
this.#$(i), this.close();
|
|
750
892
|
} else
|
|
751
893
|
this.toggle();
|
|
752
894
|
break;
|
|
@@ -754,43 +896,54 @@ class V extends d {
|
|
|
754
896
|
e && (t.preventDefault(), this.close());
|
|
755
897
|
break;
|
|
756
898
|
case "ArrowDown":
|
|
757
|
-
t.preventDefault(), e ? this.#
|
|
899
|
+
t.preventDefault(), e ? this.#v() : this.open();
|
|
758
900
|
break;
|
|
759
901
|
case "ArrowUp":
|
|
760
|
-
t.preventDefault(), e && this.#
|
|
902
|
+
t.preventDefault(), e && this.#b();
|
|
761
903
|
break;
|
|
762
904
|
case "Home":
|
|
763
|
-
e && (t.preventDefault(), this.#
|
|
905
|
+
e && (t.preventDefault(), this.#w());
|
|
764
906
|
break;
|
|
765
907
|
case "End":
|
|
766
908
|
e && (t.preventDefault(), this.#g());
|
|
767
909
|
break;
|
|
910
|
+
case "Backspace":
|
|
911
|
+
if (this.#a && this.#r.size > 0) {
|
|
912
|
+
const s = [...this.#r], i = s[s.length - 1];
|
|
913
|
+
i && this.#d(i);
|
|
914
|
+
}
|
|
915
|
+
break;
|
|
768
916
|
default:
|
|
769
917
|
t.key.length === 1 && !t.ctrlKey && !t.metaKey && this.#p(t.key);
|
|
770
918
|
break;
|
|
771
919
|
}
|
|
772
920
|
};
|
|
773
|
-
#
|
|
921
|
+
#h = (t) => {
|
|
774
922
|
const e = t.target;
|
|
775
923
|
!this.contains(e) && this.state === "open" && this.close();
|
|
776
924
|
};
|
|
925
|
+
#n = (t) => {
|
|
926
|
+
const e = t.detail.value;
|
|
927
|
+
this.#r.has(e) && this.#d(e);
|
|
928
|
+
};
|
|
777
929
|
#p(t) {
|
|
778
930
|
this.#s && clearTimeout(this.#s), this.#i += t.toLowerCase();
|
|
779
931
|
const e = this.$$('[data-ry-target="option"]:not([data-disabled])'), s = e.findIndex(
|
|
780
932
|
(i) => i.textContent?.trim().toLowerCase().startsWith(this.#i)
|
|
781
933
|
);
|
|
782
|
-
if (s >= 0)
|
|
934
|
+
if (s >= 0) {
|
|
783
935
|
if (this.state === "open")
|
|
784
|
-
this.#
|
|
785
|
-
else {
|
|
936
|
+
this.#u(s);
|
|
937
|
+
else if (!this.#a) {
|
|
786
938
|
const i = e[s];
|
|
787
|
-
i && this
|
|
939
|
+
i && this.#$(i);
|
|
788
940
|
}
|
|
941
|
+
}
|
|
789
942
|
this.#s = setTimeout(() => {
|
|
790
943
|
this.#i = "";
|
|
791
944
|
}, 500);
|
|
792
945
|
}
|
|
793
|
-
#
|
|
946
|
+
#u(t) {
|
|
794
947
|
const e = this.$$('[data-ry-target="option"]:not([data-disabled])');
|
|
795
948
|
if (t < 0 || t >= e.length) return;
|
|
796
949
|
this.$$('[data-ry-target="option"][data-highlighted]').forEach((r) => {
|
|
@@ -802,22 +955,62 @@ class V extends d {
|
|
|
802
955
|
const i = this.$('[data-ry-target="trigger"]');
|
|
803
956
|
i && i.setAttribute("aria-activedescendant", s.id);
|
|
804
957
|
}
|
|
805
|
-
#
|
|
958
|
+
#v() {
|
|
806
959
|
const t = this.$$('[data-ry-target="option"]:not([data-disabled])'), e = Math.min(this.#e + 1, t.length - 1);
|
|
807
|
-
this.#
|
|
960
|
+
this.#u(e);
|
|
808
961
|
}
|
|
809
|
-
#
|
|
962
|
+
#b() {
|
|
810
963
|
const t = Math.max(this.#e - 1, 0);
|
|
811
|
-
this.#
|
|
964
|
+
this.#u(t);
|
|
812
965
|
}
|
|
813
|
-
#
|
|
814
|
-
this.#
|
|
966
|
+
#w() {
|
|
967
|
+
this.#u(0);
|
|
815
968
|
}
|
|
816
969
|
#g() {
|
|
817
970
|
const t = this.$$('[data-ry-target="option"]:not([data-disabled])');
|
|
818
|
-
this.#
|
|
971
|
+
this.#u(t.length - 1);
|
|
819
972
|
}
|
|
820
|
-
|
|
973
|
+
// --- Multi-select methods ---
|
|
974
|
+
#d(t) {
|
|
975
|
+
const e = this.getAttribute("max-selections");
|
|
976
|
+
if (this.#r.has(t))
|
|
977
|
+
this.#r.delete(t);
|
|
978
|
+
else {
|
|
979
|
+
if (e && this.#r.size >= parseInt(e, 10)) return;
|
|
980
|
+
this.#r.add(t);
|
|
981
|
+
}
|
|
982
|
+
this.#y(), this.#m(), this.#f(), this.setAttribute("value", [...this.#r].join(",")), this.emit("change", { value: this.value, label: "" });
|
|
983
|
+
}
|
|
984
|
+
#y() {
|
|
985
|
+
const t = this.$('[data-ry-target="tags"]'), e = this.$('[data-ry-target="value"]');
|
|
986
|
+
if (t) {
|
|
987
|
+
t.innerHTML = "";
|
|
988
|
+
for (const s of this.#r) {
|
|
989
|
+
const i = this._options.find((a) => a.value === s);
|
|
990
|
+
if (!i) continue;
|
|
991
|
+
const r = document.createElement("ry-tag");
|
|
992
|
+
r.setAttribute("removable", ""), r.setAttribute("size", "sm"), r.setAttribute("data-value", s), r.textContent = i.label, t.appendChild(r);
|
|
993
|
+
}
|
|
994
|
+
e && (this.#r.size > 0 ? e.style.display = "none" : e.style.display = "");
|
|
995
|
+
}
|
|
996
|
+
}
|
|
997
|
+
#m() {
|
|
998
|
+
const t = this.$('[data-ry-target="native"]');
|
|
999
|
+
if (t)
|
|
1000
|
+
for (const e of t.options)
|
|
1001
|
+
e.selected = this.#r.has(e.value);
|
|
1002
|
+
}
|
|
1003
|
+
#f() {
|
|
1004
|
+
this.$$('[data-ry-target="option"]').forEach((t) => {
|
|
1005
|
+
const e = t.dataset.value ?? "";
|
|
1006
|
+
this.#r.has(e) ? t.setAttribute("aria-selected", "true") : t.removeAttribute("aria-selected");
|
|
1007
|
+
});
|
|
1008
|
+
}
|
|
1009
|
+
#M() {
|
|
1010
|
+
this.#r.clear(), this.#y(), this.#m(), this.#f(), this.setAttribute("value", ""), this.emit("change", { value: "", label: "" });
|
|
1011
|
+
}
|
|
1012
|
+
// --- Single-select method ---
|
|
1013
|
+
#$(t) {
|
|
821
1014
|
const e = t.dataset.value ?? "", s = t.textContent?.trim() ?? "", i = this.$('[data-ry-target="value"]');
|
|
822
1015
|
i && (i.textContent = s, i.setAttribute("data-selected", ""));
|
|
823
1016
|
const r = this.$('[data-ry-target="native"]');
|
|
@@ -829,16 +1022,19 @@ class V extends d {
|
|
|
829
1022
|
if (this.state === "open") return;
|
|
830
1023
|
this.state = "open";
|
|
831
1024
|
const t = this.$('[data-ry-target="trigger"]');
|
|
832
|
-
t && t.setAttribute("aria-expanded", "true"), this.#
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
const
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
1025
|
+
if (t && t.setAttribute("aria-expanded", "true"), this.#H(), this.#a)
|
|
1026
|
+
this.#u(0);
|
|
1027
|
+
else {
|
|
1028
|
+
const e = this.getAttribute("value");
|
|
1029
|
+
if (e) {
|
|
1030
|
+
const i = this.$$('[data-ry-target="option"]:not([data-disabled])').findIndex((r) => r.dataset.value === e);
|
|
1031
|
+
i >= 0 && this.#u(i);
|
|
1032
|
+
} else
|
|
1033
|
+
this.#u(0);
|
|
1034
|
+
}
|
|
839
1035
|
this.emit("open");
|
|
840
1036
|
}
|
|
841
|
-
#
|
|
1037
|
+
#H() {
|
|
842
1038
|
const t = this.$('[data-ry-target="dropdown"]');
|
|
843
1039
|
if (!t) return;
|
|
844
1040
|
this.removeAttribute("data-ry-position");
|
|
@@ -857,94 +1053,38 @@ class V extends d {
|
|
|
857
1053
|
this.state === "open" ? this.close() : this.open();
|
|
858
1054
|
}
|
|
859
1055
|
get value() {
|
|
860
|
-
return this.getAttribute("value") ?? "";
|
|
1056
|
+
return this.#a ? [...this.#r].join(",") : this.getAttribute("value") ?? "";
|
|
861
1057
|
}
|
|
862
1058
|
set value(t) {
|
|
863
|
-
|
|
864
|
-
|
|
1059
|
+
if (this.#a) {
|
|
1060
|
+
this.#r.clear();
|
|
1061
|
+
for (const e of t.split(",").map((s) => s.trim()).filter(Boolean))
|
|
1062
|
+
this.#r.add(e);
|
|
1063
|
+
this.#y(), this.#m(), this.#f(), this.setAttribute("value", t);
|
|
1064
|
+
} else {
|
|
1065
|
+
const e = this.$(`[data-ry-target="option"][data-value="${t}"]`);
|
|
1066
|
+
e && this.#$(e);
|
|
1067
|
+
}
|
|
1068
|
+
}
|
|
1069
|
+
get values() {
|
|
1070
|
+
return [...this.#r];
|
|
865
1071
|
}
|
|
866
1072
|
teardown() {
|
|
867
1073
|
this.#s && clearTimeout(this.#s);
|
|
868
1074
|
}
|
|
869
1075
|
}
|
|
870
|
-
class
|
|
871
|
-
}
|
|
872
|
-
customElements.define("ry-option", q);
|
|
873
|
-
customElements.define("ry-select", V);
|
|
874
|
-
const v = {
|
|
875
|
-
// Close / X
|
|
876
|
-
close: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M18 6L6 18"/><path d="M6 6l12 12"/></svg>',
|
|
877
|
-
// Chevron down
|
|
878
|
-
"chevron-down": '<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="M6 9l6 6 6-6"/></svg>',
|
|
879
|
-
// Chevron up
|
|
880
|
-
"chevron-up": '<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 15l-6-6-6 6"/></svg>',
|
|
881
|
-
// Chevron right
|
|
882
|
-
"chevron-right": '<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="M9 18l6-6-6-6"/></svg>',
|
|
883
|
-
// Chevron left
|
|
884
|
-
"chevron-left": '<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="M15 18l-6-6 6-6"/></svg>',
|
|
885
|
-
// Check / Checkmark
|
|
886
|
-
check: '<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="M20 6L9 17l-5-5"/></svg>',
|
|
887
|
-
// Copy
|
|
888
|
-
copy: '<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="9" y="9" width="13" height="13" rx="2"/><path d="M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"/></svg>',
|
|
889
|
-
// Sun (light mode)
|
|
890
|
-
sun: '<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="4"/><path d="M12 2v2"/><path d="M12 20v2"/><path d="M4.93 4.93l1.41 1.41"/><path d="M17.66 17.66l1.41 1.41"/><path d="M2 12h2"/><path d="M20 12h2"/><path d="M6.34 17.66l-1.41 1.41"/><path d="M19.07 4.93l-1.41 1.41"/></svg>',
|
|
891
|
-
// Moon (dark mode)
|
|
892
|
-
moon: '<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 12.79A9 9 0 1111.21 3 7 7 0 0021 12.79z"/></svg>',
|
|
893
|
-
// Info
|
|
894
|
-
info: '<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="10"/><path d="M12 16v-4"/><path d="M12 8h.01"/></svg>',
|
|
895
|
-
// Warning / Alert triangle
|
|
896
|
-
warning: '<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="M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z"/><path d="M12 9v4"/><path d="M12 17h.01"/></svg>',
|
|
897
|
-
// Error / X circle
|
|
898
|
-
error: '<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="10"/><path d="M15 9l-6 6"/><path d="M9 9l6 6"/></svg>',
|
|
899
|
-
// Success / Check circle
|
|
900
|
-
success: '<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="10"/><path d="M9 12l2 2 4-4"/></svg>',
|
|
901
|
-
// Search
|
|
902
|
-
search: '<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="11" cy="11" r="8"/><path d="M21 21l-4.35-4.35"/></svg>',
|
|
903
|
-
// Menu / Hamburger
|
|
904
|
-
menu: '<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="M3 12h18"/><path d="M3 6h18"/><path d="M3 18h18"/></svg>',
|
|
905
|
-
// Plus
|
|
906
|
-
plus: '<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="M12 5v14"/><path d="M5 12h14"/></svg>',
|
|
907
|
-
// Minus
|
|
908
|
-
minus: '<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="M5 12h14"/></svg>',
|
|
909
|
-
// Settings / Gear
|
|
910
|
-
settings: '<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="3"/><path d="M19.4 15a1.65 1.65 0 00.33 1.82l.06.06a2 2 0 010 2.83 2 2 0 01-2.83 0l-.06-.06a1.65 1.65 0 00-1.82-.33 1.65 1.65 0 00-1 1.51V21a2 2 0 01-2 2 2 2 0 01-2-2v-.09A1.65 1.65 0 009 19.4a1.65 1.65 0 00-1.82.33l-.06.06a2 2 0 01-2.83 0 2 2 0 010-2.83l.06-.06a1.65 1.65 0 00.33-1.82 1.65 1.65 0 00-1.51-1H3a2 2 0 01-2-2 2 2 0 012-2h.09A1.65 1.65 0 004.6 9a1.65 1.65 0 00-.33-1.82l-.06-.06a2 2 0 010-2.83 2 2 0 012.83 0l.06.06a1.65 1.65 0 001.82.33H9a1.65 1.65 0 001-1.51V3a2 2 0 012-2 2 2 0 012 2v.09a1.65 1.65 0 001 1.51 1.65 1.65 0 001.82-.33l.06-.06a2 2 0 012.83 0 2 2 0 010 2.83l-.06.06a1.65 1.65 0 00-.33 1.82V9a1.65 1.65 0 001.51 1H21a2 2 0 012 2 2 2 0 01-2 2h-.09a1.65 1.65 0 00-1.51 1z"/></svg>',
|
|
911
|
-
// User
|
|
912
|
-
user: '<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="M20 21v-2a4 4 0 00-4-4H8a4 4 0 00-4 4v2"/><circle cx="12" cy="7" r="4"/></svg>',
|
|
913
|
-
// Heart
|
|
914
|
-
heart: '<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="M20.84 4.61a5.5 5.5 0 00-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 00-7.78 7.78l1.06 1.06L12 21.23l7.78-7.78 1.06-1.06a5.5 5.5 0 000-7.78z"/></svg>',
|
|
915
|
-
// Star
|
|
916
|
-
star: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polygon points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"/></svg>',
|
|
917
|
-
// Trash
|
|
918
|
-
trash: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 01-2 2H7a2 2 0 01-2-2V6m3 0V4a2 2 0 012-2h4a2 2 0 012 2v2"/></svg>',
|
|
919
|
-
// Edit / Pencil
|
|
920
|
-
edit: '<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="M11 4H4a2 2 0 00-2 2v14a2 2 0 002 2h14a2 2 0 002-2v-7"/><path d="M18.5 2.5a2.121 2.121 0 013 3L12 15l-4 1 1-4 9.5-9.5z"/></svg>',
|
|
921
|
-
// External link
|
|
922
|
-
"external-link": '<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 13v6a2 2 0 01-2 2H5a2 2 0 01-2-2V8a2 2 0 012-2h6"/><polyline points="15 3 21 3 21 9"/><line x1="10" y1="14" x2="21" y2="3"/></svg>',
|
|
923
|
-
// Download
|
|
924
|
-
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
|
-
// 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>'
|
|
927
|
-
};
|
|
928
|
-
function y(o) {
|
|
929
|
-
return v[o] ?? "";
|
|
930
|
-
}
|
|
931
|
-
function ot(o, t) {
|
|
932
|
-
v[o] = t;
|
|
1076
|
+
class Z extends HTMLElement {
|
|
933
1077
|
}
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
function lt() {
|
|
938
|
-
return Object.keys(v);
|
|
939
|
-
}
|
|
940
|
-
class z extends d {
|
|
1078
|
+
customElements.define("ry-option", Z);
|
|
1079
|
+
customElements.define("ry-select", J);
|
|
1080
|
+
class Q extends u {
|
|
941
1081
|
#t = "";
|
|
942
1082
|
static get observedAttributes() {
|
|
943
1083
|
return ["language", "title", "line-numbers"];
|
|
944
1084
|
}
|
|
945
1085
|
setup() {
|
|
946
1086
|
const t = this.querySelector("template");
|
|
947
|
-
t ? this.#t = this.#
|
|
1087
|
+
t ? this.#t = this.#n(t.innerHTML) : this.#t = this.textContent?.trim() ?? "", this.#e();
|
|
948
1088
|
const e = this.$('[data-ry-target="copy"]');
|
|
949
1089
|
e && this.on(e, "click", this.#i);
|
|
950
1090
|
}
|
|
@@ -955,7 +1095,7 @@ class z extends d {
|
|
|
955
1095
|
<div data-ry-target="header" class="ry-code__header">
|
|
956
1096
|
<span data-ry-target="title" class="ry-code__title">${e}</span>
|
|
957
1097
|
<button data-ry-target="copy" class="ry-code__copy" type="button" aria-label="Copy code">
|
|
958
|
-
${
|
|
1098
|
+
${p("copy")}
|
|
959
1099
|
</button>
|
|
960
1100
|
</div>
|
|
961
1101
|
<div data-ry-target="content" class="ry-code__content">
|
|
@@ -967,8 +1107,8 @@ class z extends d {
|
|
|
967
1107
|
const t = this.$('[data-ry-target="copy"]');
|
|
968
1108
|
if (t)
|
|
969
1109
|
try {
|
|
970
|
-
await navigator.clipboard.writeText(this.#t), t.innerHTML =
|
|
971
|
-
t.innerHTML =
|
|
1110
|
+
await navigator.clipboard.writeText(this.#t), t.innerHTML = p("check"), t.classList.add("ry-code__copy--success"), this.emit("copy", { code: this.#t }), setTimeout(() => {
|
|
1111
|
+
t.innerHTML = p("copy"), t.classList.remove("ry-code__copy--success");
|
|
972
1112
|
}, 2e3);
|
|
973
1113
|
} catch {
|
|
974
1114
|
this.emit("copy-error");
|
|
@@ -980,13 +1120,13 @@ class z extends d {
|
|
|
980
1120
|
return this.#r(t);
|
|
981
1121
|
case "js":
|
|
982
1122
|
case "javascript":
|
|
983
|
-
return this.#
|
|
1123
|
+
return this.#a(t);
|
|
984
1124
|
case "html":
|
|
985
|
-
return this.#
|
|
1125
|
+
return this.#o(t);
|
|
986
1126
|
case "json":
|
|
987
|
-
return this.#
|
|
1127
|
+
return this.#l(t);
|
|
988
1128
|
default:
|
|
989
|
-
return this.#
|
|
1129
|
+
return this.#h(t);
|
|
990
1130
|
}
|
|
991
1131
|
}
|
|
992
1132
|
#r(t) {
|
|
@@ -994,9 +1134,9 @@ class z extends d {
|
|
|
994
1134
|
let s = t;
|
|
995
1135
|
for (; s.length > 0; ) {
|
|
996
1136
|
if (s.startsWith("/*")) {
|
|
997
|
-
const
|
|
998
|
-
if (
|
|
999
|
-
e.push({ type: "comment", value: s.slice(0,
|
|
1137
|
+
const y = s.indexOf("*/");
|
|
1138
|
+
if (y !== -1) {
|
|
1139
|
+
e.push({ type: "comment", value: s.slice(0, y + 2) }), s = s.slice(y + 2);
|
|
1000
1140
|
continue;
|
|
1001
1141
|
}
|
|
1002
1142
|
}
|
|
@@ -1020,14 +1160,14 @@ class z extends d {
|
|
|
1020
1160
|
e.push({ type: "color", value: n[1], color: n[1] }), s = s.slice(n[1].length);
|
|
1021
1161
|
continue;
|
|
1022
1162
|
}
|
|
1023
|
-
const
|
|
1024
|
-
if (
|
|
1025
|
-
e.push({ type: "number", value:
|
|
1163
|
+
const o = s.match(/^(-?[\d.]+(?:px|em|rem|%|vh|vw|deg|s|ms)?)/);
|
|
1164
|
+
if (o?.[1]) {
|
|
1165
|
+
e.push({ type: "number", value: o[1] }), s = s.slice(o[1].length);
|
|
1026
1166
|
continue;
|
|
1027
1167
|
}
|
|
1028
|
-
const
|
|
1029
|
-
if (
|
|
1030
|
-
e.push({ type: "string", value:
|
|
1168
|
+
const l = s.match(/^(['"])((?:[^\\]|\\.)*?)\1/);
|
|
1169
|
+
if (l) {
|
|
1170
|
+
e.push({ type: "string", value: l[0] }), s = s.slice(l[0].length);
|
|
1031
1171
|
continue;
|
|
1032
1172
|
}
|
|
1033
1173
|
const c = s[0];
|
|
@@ -1035,32 +1175,32 @@ class z extends d {
|
|
|
1035
1175
|
e.push({ type: "punctuation", value: c }), s = s.slice(1);
|
|
1036
1176
|
continue;
|
|
1037
1177
|
}
|
|
1038
|
-
const
|
|
1039
|
-
if (
|
|
1040
|
-
e.push({ type: "text", value:
|
|
1178
|
+
const d = s.match(/^(\s+)/);
|
|
1179
|
+
if (d?.[1]) {
|
|
1180
|
+
e.push({ type: "text", value: d[1] }), s = s.slice(d[1].length);
|
|
1041
1181
|
continue;
|
|
1042
1182
|
}
|
|
1043
|
-
const
|
|
1044
|
-
if (
|
|
1045
|
-
const
|
|
1046
|
-
["inherit", "initial", "unset", "none", "auto", "transparent", "solid", "dashed", "dotted", "flex", "grid", "block", "inline", "inline-block", "absolute", "relative", "fixed", "sticky"].includes(
|
|
1183
|
+
const g = s.match(/^([\w-]+)/);
|
|
1184
|
+
if (g?.[1]) {
|
|
1185
|
+
const y = g[1];
|
|
1186
|
+
["inherit", "initial", "unset", "none", "auto", "transparent", "solid", "dashed", "dotted", "flex", "grid", "block", "inline", "inline-block", "absolute", "relative", "fixed", "sticky"].includes(y) ? e.push({ type: "keyword", value: y }) : e.push({ type: "value", value: y }), s = s.slice(y.length);
|
|
1047
1187
|
continue;
|
|
1048
1188
|
}
|
|
1049
|
-
const
|
|
1050
|
-
|
|
1189
|
+
const b = s[0];
|
|
1190
|
+
b && e.push({ type: "text", value: b }), s = s.slice(1);
|
|
1051
1191
|
}
|
|
1052
|
-
return e.map((i) => this.#
|
|
1192
|
+
return e.map((i) => this.#c(i)).join("");
|
|
1053
1193
|
}
|
|
1054
|
-
#
|
|
1194
|
+
#a(t) {
|
|
1055
1195
|
const e = [];
|
|
1056
1196
|
let s = t;
|
|
1057
1197
|
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
1198
|
for (; s.length > 0; ) {
|
|
1059
1199
|
if (s.startsWith("//")) {
|
|
1060
|
-
const
|
|
1200
|
+
const d = s.indexOf(`
|
|
1061
1201
|
`);
|
|
1062
|
-
if (
|
|
1063
|
-
e.push({ type: "comment", value: s.slice(0,
|
|
1202
|
+
if (d !== -1) {
|
|
1203
|
+
e.push({ type: "comment", value: s.slice(0, d) }), s = s.slice(d);
|
|
1064
1204
|
continue;
|
|
1065
1205
|
} else {
|
|
1066
1206
|
e.push({ type: "comment", value: s });
|
|
@@ -1068,9 +1208,9 @@ class z extends d {
|
|
|
1068
1208
|
}
|
|
1069
1209
|
}
|
|
1070
1210
|
if (s.startsWith("/*")) {
|
|
1071
|
-
const
|
|
1072
|
-
if (
|
|
1073
|
-
e.push({ type: "comment", value: s.slice(0,
|
|
1211
|
+
const d = s.indexOf("*/");
|
|
1212
|
+
if (d !== -1) {
|
|
1213
|
+
e.push({ type: "comment", value: s.slice(0, d + 2) }), s = s.slice(d + 2);
|
|
1074
1214
|
continue;
|
|
1075
1215
|
}
|
|
1076
1216
|
}
|
|
@@ -1086,26 +1226,26 @@ class z extends d {
|
|
|
1086
1226
|
}
|
|
1087
1227
|
const n = s.match(/^([a-zA-Z_$][\w$]*)/);
|
|
1088
1228
|
if (n?.[1]) {
|
|
1089
|
-
const
|
|
1090
|
-
i.includes(
|
|
1229
|
+
const d = n[1];
|
|
1230
|
+
i.includes(d) ? e.push({ type: "keyword", value: d }) : e.push({ type: "text", value: d }), s = s.slice(d.length);
|
|
1091
1231
|
continue;
|
|
1092
1232
|
}
|
|
1093
|
-
const
|
|
1094
|
-
if (
|
|
1095
|
-
e.push({ type: "punctuation", value:
|
|
1233
|
+
const o = s[0];
|
|
1234
|
+
if (o && /^[{}[\]();,.:?!<>=+\-*/&|^%~@#]/.test(o)) {
|
|
1235
|
+
e.push({ type: "punctuation", value: o }), s = s.slice(1);
|
|
1096
1236
|
continue;
|
|
1097
1237
|
}
|
|
1098
|
-
const
|
|
1099
|
-
if (
|
|
1100
|
-
e.push({ type: "text", value:
|
|
1238
|
+
const l = s.match(/^(\s+)/);
|
|
1239
|
+
if (l?.[1]) {
|
|
1240
|
+
e.push({ type: "text", value: l[1] }), s = s.slice(l[1].length);
|
|
1101
1241
|
continue;
|
|
1102
1242
|
}
|
|
1103
1243
|
const c = s[0];
|
|
1104
1244
|
c && e.push({ type: "text", value: c }), s = s.slice(1);
|
|
1105
1245
|
}
|
|
1106
|
-
return e.map((r) => this.#
|
|
1246
|
+
return e.map((r) => this.#c(r)).join("");
|
|
1107
1247
|
}
|
|
1108
|
-
#
|
|
1248
|
+
#o(t) {
|
|
1109
1249
|
const e = [];
|
|
1110
1250
|
let s = t;
|
|
1111
1251
|
for (; s.length > 0; ) {
|
|
@@ -1141,17 +1281,17 @@ class z extends d {
|
|
|
1141
1281
|
e.push({ type: "text", value: n[1] }), s = s.slice(n[1].length);
|
|
1142
1282
|
continue;
|
|
1143
1283
|
}
|
|
1144
|
-
const
|
|
1145
|
-
if (
|
|
1146
|
-
e.push({ type: "text", value:
|
|
1284
|
+
const o = s.match(/^([^<]+)/);
|
|
1285
|
+
if (o?.[1]) {
|
|
1286
|
+
e.push({ type: "text", value: o[1] }), s = s.slice(o[1].length);
|
|
1147
1287
|
continue;
|
|
1148
1288
|
}
|
|
1149
|
-
const
|
|
1150
|
-
|
|
1289
|
+
const l = s[0];
|
|
1290
|
+
l && e.push({ type: "text", value: l }), s = s.slice(1);
|
|
1151
1291
|
}
|
|
1152
|
-
return e.map((i) => this.#
|
|
1292
|
+
return e.map((i) => this.#c(i)).join("");
|
|
1153
1293
|
}
|
|
1154
|
-
#
|
|
1294
|
+
#l(t) {
|
|
1155
1295
|
const e = [];
|
|
1156
1296
|
let s = t;
|
|
1157
1297
|
for (; s.length > 0; ) {
|
|
@@ -1175,18 +1315,18 @@ class z extends d {
|
|
|
1175
1315
|
e.push({ type: "punctuation", value: n }), s = s.slice(1);
|
|
1176
1316
|
continue;
|
|
1177
1317
|
}
|
|
1178
|
-
const
|
|
1179
|
-
if (
|
|
1180
|
-
e.push({ type: "text", value:
|
|
1318
|
+
const o = s.match(/^(\s+)/);
|
|
1319
|
+
if (o?.[1]) {
|
|
1320
|
+
e.push({ type: "text", value: o[1] }), s = s.slice(o[1].length);
|
|
1181
1321
|
continue;
|
|
1182
1322
|
}
|
|
1183
|
-
const
|
|
1184
|
-
|
|
1323
|
+
const l = s[0];
|
|
1324
|
+
l && e.push({ type: "text", value: l }), s = s.slice(1);
|
|
1185
1325
|
}
|
|
1186
|
-
return e.map((i) => this.#
|
|
1326
|
+
return e.map((i) => this.#c(i)).join("");
|
|
1187
1327
|
}
|
|
1188
|
-
#
|
|
1189
|
-
const e = this.#
|
|
1328
|
+
#c(t) {
|
|
1329
|
+
const e = this.#h(t.value);
|
|
1190
1330
|
switch (t.type) {
|
|
1191
1331
|
case "keyword":
|
|
1192
1332
|
return `<span class="ry-code__keyword">${e}</span>`;
|
|
@@ -1214,10 +1354,10 @@ class z extends d {
|
|
|
1214
1354
|
return e;
|
|
1215
1355
|
}
|
|
1216
1356
|
}
|
|
1217
|
-
#
|
|
1357
|
+
#h(t) {
|
|
1218
1358
|
return t.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
1219
1359
|
}
|
|
1220
|
-
#
|
|
1360
|
+
#n(t) {
|
|
1221
1361
|
const e = t.split(`
|
|
1222
1362
|
`);
|
|
1223
1363
|
for (; e.length && !e[0]?.trim(); ) e.shift();
|
|
@@ -1236,12 +1376,12 @@ class z extends d {
|
|
|
1236
1376
|
this.#t = t, this.#e();
|
|
1237
1377
|
}
|
|
1238
1378
|
}
|
|
1239
|
-
customElements.define("ry-code",
|
|
1240
|
-
class
|
|
1379
|
+
customElements.define("ry-code", Q);
|
|
1380
|
+
class tt extends u {
|
|
1241
1381
|
setup() {
|
|
1242
1382
|
const t = this.$("template");
|
|
1243
1383
|
if (!t) return;
|
|
1244
|
-
const e = this.$('script[slot="js"]'), s = e ? this.#e(e.textContent ?? "") : null, i = this.#e(t.innerHTML), r =
|
|
1384
|
+
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
1385
|
this.innerHTML = `
|
|
1246
1386
|
<div data-ry-target="preview" class="ry-example__preview"></div>
|
|
1247
1387
|
<div data-ry-target="code" class="ry-example__code"></div>
|
|
@@ -1249,8 +1389,8 @@ class Y extends d {
|
|
|
1249
1389
|
`, a && this.setAttribute("data-stacked", "");
|
|
1250
1390
|
const n = document.createElement("ry-code");
|
|
1251
1391
|
n.setAttribute("language", "html"), n.setAttribute("title", this.getAttribute("title") ?? "Example"), n.textContent = i, this.$('[data-ry-target="code"]').appendChild(n);
|
|
1252
|
-
const
|
|
1253
|
-
|
|
1392
|
+
const o = document.createElement("template");
|
|
1393
|
+
o.innerHTML = r, this.$('[data-ry-target="preview"]').appendChild(o.content), s && this.#t(s);
|
|
1254
1394
|
}
|
|
1255
1395
|
#t(t) {
|
|
1256
1396
|
const e = this.$('[data-ry-target="usage"]');
|
|
@@ -1281,8 +1421,8 @@ class Y extends d {
|
|
|
1281
1421
|
`).trim();
|
|
1282
1422
|
}
|
|
1283
1423
|
}
|
|
1284
|
-
customElements.define("ry-example",
|
|
1285
|
-
class
|
|
1424
|
+
customElements.define("ry-example", tt);
|
|
1425
|
+
class et extends u {
|
|
1286
1426
|
static get observedAttributes() {
|
|
1287
1427
|
return ["name", "size", "label"];
|
|
1288
1428
|
}
|
|
@@ -1293,7 +1433,7 @@ class G extends d {
|
|
|
1293
1433
|
e !== s && this.hasAttribute("data-ry-initialized") && this.#t();
|
|
1294
1434
|
}
|
|
1295
1435
|
#t() {
|
|
1296
|
-
const t = this.getAttribute("name") ?? "", e = this.getAttribute("size") ?? "24", s = this.getAttribute("label"), i =
|
|
1436
|
+
const t = this.getAttribute("name") ?? "", e = this.getAttribute("size") ?? "24", s = this.getAttribute("label"), i = p(t);
|
|
1297
1437
|
if (!i) {
|
|
1298
1438
|
this.innerHTML = "";
|
|
1299
1439
|
return;
|
|
@@ -1315,24 +1455,24 @@ class G extends d {
|
|
|
1315
1455
|
this.setAttribute("size", String(t));
|
|
1316
1456
|
}
|
|
1317
1457
|
}
|
|
1318
|
-
customElements.define("ry-icon",
|
|
1319
|
-
const
|
|
1320
|
-
function
|
|
1321
|
-
let t =
|
|
1458
|
+
customElements.define("ry-icon", et);
|
|
1459
|
+
const st = ["form", "section", "fieldset", "ry-section"], m = /* @__PURE__ */ new Map(), C = /* @__PURE__ */ new Set();
|
|
1460
|
+
function it(h) {
|
|
1461
|
+
let t = h.parentElement;
|
|
1322
1462
|
for (; t; ) {
|
|
1323
|
-
if (
|
|
1463
|
+
if (st.some((e) => t.matches(e)))
|
|
1324
1464
|
return t;
|
|
1325
1465
|
t = t.parentElement;
|
|
1326
1466
|
}
|
|
1327
1467
|
return null;
|
|
1328
1468
|
}
|
|
1329
|
-
function
|
|
1330
|
-
if (
|
|
1331
|
-
const t =
|
|
1469
|
+
function rt(h) {
|
|
1470
|
+
if (C.has(h)) return;
|
|
1471
|
+
const t = m.get(h);
|
|
1332
1472
|
if (!t || t.size < 2) return;
|
|
1333
1473
|
const e = /* @__PURE__ */ new Map();
|
|
1334
1474
|
for (const s of t) {
|
|
1335
|
-
const i =
|
|
1475
|
+
const i = it(s), r = e.get(i) ?? [];
|
|
1336
1476
|
r.push(s), e.set(i, r);
|
|
1337
1477
|
}
|
|
1338
1478
|
if (e.size > 1) {
|
|
@@ -1344,11 +1484,11 @@ function Z(o) {
|
|
|
1344
1484
|
} else
|
|
1345
1485
|
s.push("(no container)");
|
|
1346
1486
|
console.warn(
|
|
1347
|
-
`ry-toggle-button: Buttons with name="${
|
|
1348
|
-
),
|
|
1487
|
+
`ry-toggle-button: Buttons with name="${h}" span multiple containers (${s.join(", ")}). Intentional?`
|
|
1488
|
+
), C.add(h);
|
|
1349
1489
|
}
|
|
1350
1490
|
}
|
|
1351
|
-
class
|
|
1491
|
+
class at extends u {
|
|
1352
1492
|
static observedAttributes = ["pressed", "disabled", "name", "value"];
|
|
1353
1493
|
#t = !1;
|
|
1354
1494
|
setup() {
|
|
@@ -1359,12 +1499,12 @@ class Q extends d {
|
|
|
1359
1499
|
}
|
|
1360
1500
|
#e() {
|
|
1361
1501
|
const t = this.name;
|
|
1362
|
-
t && (
|
|
1502
|
+
t && (m.has(t) || m.set(t, /* @__PURE__ */ new Set()), m.get(t).add(this), this.#t = !0, queueMicrotask(() => rt(t)));
|
|
1363
1503
|
}
|
|
1364
1504
|
#i() {
|
|
1365
1505
|
if (!this.#t) return;
|
|
1366
1506
|
const t = this.name;
|
|
1367
|
-
t &&
|
|
1507
|
+
t && m.has(t) && (m.get(t).delete(this), m.get(t).size === 0 && (m.delete(t), C.delete(t))), this.#t = !1;
|
|
1368
1508
|
}
|
|
1369
1509
|
#s = (t) => {
|
|
1370
1510
|
if (this.disabled) {
|
|
@@ -1376,10 +1516,10 @@ class Q extends d {
|
|
|
1376
1516
|
#r = (t) => {
|
|
1377
1517
|
(t.key === "Enter" || t.key === " ") && (t.preventDefault(), this.click());
|
|
1378
1518
|
};
|
|
1379
|
-
#
|
|
1519
|
+
#a() {
|
|
1380
1520
|
const t = this.name;
|
|
1381
1521
|
if (!t) return;
|
|
1382
|
-
const e =
|
|
1522
|
+
const e = m.get(t);
|
|
1383
1523
|
if (e)
|
|
1384
1524
|
for (const s of e)
|
|
1385
1525
|
s !== this && s.pressed && (s.pressed = !1);
|
|
@@ -1390,7 +1530,7 @@ class Q extends d {
|
|
|
1390
1530
|
}
|
|
1391
1531
|
set pressed(t) {
|
|
1392
1532
|
const e = this.pressed;
|
|
1393
|
-
t ? (this.setAttribute("pressed", ""), this.setAttribute("aria-pressed", "true"), this.#
|
|
1533
|
+
t ? (this.setAttribute("pressed", ""), this.setAttribute("aria-pressed", "true"), this.#a()) : (this.removeAttribute("pressed"), this.setAttribute("aria-pressed", "false")), e !== t && this.emit("change", {
|
|
1394
1534
|
value: this.value,
|
|
1395
1535
|
label: t ? "pressed" : "unpressed"
|
|
1396
1536
|
});
|
|
@@ -1420,19 +1560,19 @@ class Q extends d {
|
|
|
1420
1560
|
this.setAttribute("icon", t);
|
|
1421
1561
|
}
|
|
1422
1562
|
}
|
|
1423
|
-
customElements.define("ry-toggle-button",
|
|
1424
|
-
class
|
|
1563
|
+
customElements.define("ry-toggle-button", at);
|
|
1564
|
+
class nt extends u {
|
|
1425
1565
|
#t = !1;
|
|
1426
1566
|
#e = null;
|
|
1427
1567
|
#i = null;
|
|
1428
1568
|
#s = null;
|
|
1429
1569
|
#r = /* @__PURE__ */ new Map();
|
|
1430
|
-
#
|
|
1570
|
+
#a = /* @__PURE__ */ new Map();
|
|
1431
1571
|
static observedAttributes = ["min", "max", "step", "value", "start", "end", "disabled"];
|
|
1432
1572
|
setup() {
|
|
1433
|
-
this.#
|
|
1573
|
+
this.#o(), this.#c(), this.#y();
|
|
1434
1574
|
}
|
|
1435
|
-
#
|
|
1575
|
+
#o() {
|
|
1436
1576
|
const t = this.hasAttribute("range"), e = this.hasAttribute("labeled"), s = this.hasAttribute("tooltip");
|
|
1437
1577
|
this.hasAttribute("vertical");
|
|
1438
1578
|
let i = `
|
|
@@ -1450,20 +1590,20 @@ class tt extends d {
|
|
|
1450
1590
|
<div data-ry-target="thumb-value" class="ry-slider__thumb" tabindex="0" role="slider" aria-label="Value">
|
|
1451
1591
|
${s ? '<span data-ry-target="tooltip-value" class="ry-slider__tooltip"></span>' : ""}
|
|
1452
1592
|
</div>
|
|
1453
|
-
`, i += "</div>", e && (i += this.#
|
|
1593
|
+
`, 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.#a.set("start", this.$('[data-ry-target="tooltip-start"]')), this.#a.set("end", this.$('[data-ry-target="tooltip-end"]')))) : (this.#r.set("value", this.$('[data-ry-target="thumb-value"]')), s && this.#a.set("value", this.$('[data-ry-target="tooltip-value"]')));
|
|
1454
1594
|
}
|
|
1455
|
-
#
|
|
1595
|
+
#l() {
|
|
1456
1596
|
const t = this.min, e = this.max, s = this.getAttribute("labels")?.split(","), i = this.getAttribute("label-type") || "number";
|
|
1457
1597
|
let r = [];
|
|
1458
1598
|
if (s)
|
|
1459
1599
|
r = s;
|
|
1460
1600
|
else
|
|
1461
1601
|
for (let n = 0; n < 5; n++) {
|
|
1462
|
-
const
|
|
1602
|
+
const o = n / 4, l = t + o * (e - t);
|
|
1463
1603
|
if (i === "letter")
|
|
1464
1604
|
r.push(String.fromCharCode(65 + n));
|
|
1465
1605
|
else {
|
|
1466
|
-
const c = Math.round(
|
|
1606
|
+
const c = Math.round(l * 100) / 100;
|
|
1467
1607
|
r.push(String(Number.isInteger(c) ? c : c.toFixed(1)));
|
|
1468
1608
|
}
|
|
1469
1609
|
}
|
|
@@ -1473,13 +1613,13 @@ class tt extends d {
|
|
|
1473
1613
|
</div>
|
|
1474
1614
|
`;
|
|
1475
1615
|
}
|
|
1476
|
-
#
|
|
1477
|
-
this.#i && this.on(this.#i, "pointerdown", this.#
|
|
1616
|
+
#c() {
|
|
1617
|
+
this.#i && this.on(this.#i, "pointerdown", this.#h);
|
|
1478
1618
|
for (const [t, e] of this.#r)
|
|
1479
|
-
this.on(e, "pointerdown", (s) => this.#
|
|
1480
|
-
this.on(document, "pointermove", this.#
|
|
1619
|
+
this.on(e, "pointerdown", (s) => this.#n(s, t)), this.on(e, "keydown", (s) => this.#v(s, t));
|
|
1620
|
+
this.on(document, "pointermove", this.#p), this.on(document, "pointerup", this.#u);
|
|
1481
1621
|
}
|
|
1482
|
-
#
|
|
1622
|
+
#h = (t) => {
|
|
1483
1623
|
if (this.disabled) return;
|
|
1484
1624
|
const e = this.#w(t);
|
|
1485
1625
|
if (this.hasAttribute("range")) {
|
|
@@ -1487,20 +1627,20 @@ class tt extends d {
|
|
|
1487
1627
|
i < r ? (this.start = e, this.#e = "start") : (this.end = e, this.#e = "end");
|
|
1488
1628
|
} else
|
|
1489
1629
|
this.value = e, this.#e = "value";
|
|
1490
|
-
this.#t = !0, this.#
|
|
1630
|
+
this.#t = !0, this.#y(), this.#f();
|
|
1491
1631
|
};
|
|
1492
|
-
#
|
|
1632
|
+
#n = (t, e) => {
|
|
1493
1633
|
this.disabled || (t.stopPropagation(), this.#t = !0, this.#e = e, t.target.setPointerCapture(t.pointerId));
|
|
1494
1634
|
};
|
|
1495
|
-
#
|
|
1635
|
+
#p = (t) => {
|
|
1496
1636
|
if (!this.#t || !this.#e) return;
|
|
1497
1637
|
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.#
|
|
1638
|
+
this.hasAttribute("range") ? this.#e === "start" ? this.start = Math.min(e, this.end) : this.#e === "end" && (this.end = Math.max(e, this.start)) : this.value = e, this.#y(), this.#f();
|
|
1499
1639
|
};
|
|
1500
|
-
#
|
|
1501
|
-
this.#t && (this.#t = !1, this.#e = null, this.#
|
|
1640
|
+
#u = () => {
|
|
1641
|
+
this.#t && (this.#t = !1, this.#e = null, this.#M());
|
|
1502
1642
|
};
|
|
1503
|
-
#
|
|
1643
|
+
#v = (t, e) => {
|
|
1504
1644
|
if (this.disabled) return;
|
|
1505
1645
|
const s = this.step || 1, i = (this.max - this.min) / 10;
|
|
1506
1646
|
let r = 0;
|
|
@@ -1520,19 +1660,19 @@ class tt extends d {
|
|
|
1520
1660
|
r = -i;
|
|
1521
1661
|
break;
|
|
1522
1662
|
case "Home":
|
|
1523
|
-
r = this.min - this.#
|
|
1663
|
+
r = this.min - this.#b(e);
|
|
1524
1664
|
break;
|
|
1525
1665
|
case "End":
|
|
1526
|
-
r = this.max - this.#
|
|
1666
|
+
r = this.max - this.#b(e);
|
|
1527
1667
|
break;
|
|
1528
1668
|
default:
|
|
1529
1669
|
return;
|
|
1530
1670
|
}
|
|
1531
1671
|
t.preventDefault();
|
|
1532
|
-
const a = this.#d(this.#
|
|
1533
|
-
e === "start" ? this.start = Math.min(a, this.end) : e === "end" ? this.end = Math.max(a, this.start) : this.value = a, this.#
|
|
1672
|
+
const a = this.#d(this.#b(e) + r);
|
|
1673
|
+
e === "start" ? this.start = Math.min(a, this.end) : e === "end" ? this.end = Math.max(a, this.start) : this.value = a, this.#y(), this.#f(), this.#M();
|
|
1534
1674
|
};
|
|
1535
|
-
#
|
|
1675
|
+
#b(t) {
|
|
1536
1676
|
return t === "start" ? this.start : t === "end" ? this.end : this.value;
|
|
1537
1677
|
}
|
|
1538
1678
|
#w(t) {
|
|
@@ -1541,9 +1681,9 @@ class tt extends d {
|
|
|
1541
1681
|
let r;
|
|
1542
1682
|
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
1683
|
const a = this.min + r * (this.max - this.min);
|
|
1544
|
-
return this.#
|
|
1684
|
+
return this.#g(a);
|
|
1545
1685
|
}
|
|
1546
|
-
#
|
|
1686
|
+
#g(t) {
|
|
1547
1687
|
const e = this.step;
|
|
1548
1688
|
if (e === 0) return this.#d(t);
|
|
1549
1689
|
const s = Math.round((t - this.min) / e) * e + this.min;
|
|
@@ -1552,34 +1692,34 @@ class tt extends d {
|
|
|
1552
1692
|
#d(t) {
|
|
1553
1693
|
return Math.max(this.min, Math.min(this.max, t));
|
|
1554
1694
|
}
|
|
1555
|
-
#
|
|
1695
|
+
#y() {
|
|
1556
1696
|
const t = this.hasAttribute("range"), e = this.hasAttribute("vertical"), s = this.hasAttribute("reversed"), i = (r) => {
|
|
1557
1697
|
let a = (r - this.min) / (this.max - this.min) * 100;
|
|
1558
1698
|
return s && (a = 100 - a), a;
|
|
1559
1699
|
};
|
|
1560
1700
|
if (t) {
|
|
1561
|
-
const r = i(this.start), a = i(this.end), n = Math.min(r, a),
|
|
1562
|
-
this.#s && (e ? (this.#s.style.bottom = `${n}%`, this.#s.style.height = `${
|
|
1563
|
-
const
|
|
1564
|
-
|
|
1701
|
+
const r = i(this.start), a = i(this.end), n = Math.min(r, a), o = Math.max(r, a);
|
|
1702
|
+
this.#s && (e ? (this.#s.style.bottom = `${n}%`, this.#s.style.height = `${o - n}%`, this.#s.style.left = "", this.#s.style.width = "") : (this.#s.style.left = `${n}%`, this.#s.style.width = `${o - n}%`, this.#s.style.bottom = "", this.#s.style.height = ""));
|
|
1703
|
+
const l = this.#r.get("start"), c = this.#r.get("end");
|
|
1704
|
+
l && (e ? (l.style.bottom = `${r}%`, l.style.left = "") : (l.style.left = `${r}%`, l.style.bottom = "")), c && (e ? (c.style.bottom = `${a}%`, c.style.left = "") : (c.style.left = `${a}%`, c.style.bottom = "")), this.#m("start", this.start), this.#m("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
1705
|
} else {
|
|
1566
1706
|
const r = i(this.value);
|
|
1567
1707
|
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
1708
|
const a = this.#r.get("value");
|
|
1569
|
-
a && (e ? (a.style.bottom = `${r}%`, a.style.left = "") : (a.style.left = `${r}%`, a.style.bottom = "")), this.#
|
|
1709
|
+
a && (e ? (a.style.bottom = `${r}%`, a.style.left = "") : (a.style.left = `${r}%`, a.style.bottom = "")), this.#m("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
1710
|
}
|
|
1571
1711
|
}
|
|
1572
|
-
#
|
|
1573
|
-
const s = this.#
|
|
1712
|
+
#m(t, e) {
|
|
1713
|
+
const s = this.#a.get(t);
|
|
1574
1714
|
if (s) {
|
|
1575
1715
|
const i = this.step === 0 ? 2 : String(this.step).split(".")[1]?.length || 0;
|
|
1576
1716
|
s.textContent = e.toFixed(i);
|
|
1577
1717
|
}
|
|
1578
1718
|
}
|
|
1579
|
-
#
|
|
1719
|
+
#f() {
|
|
1580
1720
|
this.hasAttribute("range") ? this.emit("input", { start: this.start, end: this.end }) : this.emit("input", { value: this.value });
|
|
1581
1721
|
}
|
|
1582
|
-
#
|
|
1722
|
+
#M() {
|
|
1583
1723
|
this.hasAttribute("range") ? this.emit("change", { start: this.start, end: this.end }) : this.emit("change", { value: this.value });
|
|
1584
1724
|
}
|
|
1585
1725
|
// --- Public API ---
|
|
@@ -1626,19 +1766,19 @@ class tt extends d {
|
|
|
1626
1766
|
t ? this.setAttribute("disabled", "") : this.removeAttribute("disabled");
|
|
1627
1767
|
}
|
|
1628
1768
|
}
|
|
1629
|
-
customElements.define("ry-slider",
|
|
1630
|
-
class
|
|
1769
|
+
customElements.define("ry-slider", nt);
|
|
1770
|
+
class ot extends u {
|
|
1631
1771
|
#t = !1;
|
|
1632
1772
|
#e = 0;
|
|
1633
1773
|
#i = 0;
|
|
1634
1774
|
#s = null;
|
|
1635
1775
|
#r = null;
|
|
1636
|
-
#
|
|
1776
|
+
#a = null;
|
|
1637
1777
|
static observedAttributes = ["min", "max", "step", "value", "disabled", "label", "labels", "description"];
|
|
1638
1778
|
setup() {
|
|
1639
|
-
this.#
|
|
1779
|
+
this.#o(), this.#l(), this.#d();
|
|
1640
1780
|
}
|
|
1641
|
-
#
|
|
1781
|
+
#o() {
|
|
1642
1782
|
const t = this.getAttribute("label"), e = this.getAttribute("description"), s = e ? ` title="${e}"` : "";
|
|
1643
1783
|
this.innerHTML = `
|
|
1644
1784
|
<div data-ry-target="ring" class="ry-knob__ring"${s}>
|
|
@@ -1648,41 +1788,41 @@ class et extends d {
|
|
|
1648
1788
|
</div>
|
|
1649
1789
|
<span data-ry-target="display" class="ry-knob__value"></span>
|
|
1650
1790
|
${t ? `<span data-ry-target="label" class="ry-knob__label"${s}>${t}</span>` : ""}
|
|
1651
|
-
`, this.#s = this.$('[data-ry-target="ring"]'), this.#r = this.$('[data-ry-target="indicator"]'), this.#
|
|
1791
|
+
`, this.#s = this.$('[data-ry-target="ring"]'), this.#r = this.$('[data-ry-target="indicator"]'), this.#a = this.$('[data-ry-target="display"]');
|
|
1652
1792
|
}
|
|
1653
|
-
#
|
|
1654
|
-
this.#s && (this.on(this.#s, "mousedown", this.#
|
|
1793
|
+
#l() {
|
|
1794
|
+
this.#s && (this.on(this.#s, "mousedown", this.#c), this.on(document, "mousemove", this.#h), this.on(document, "mouseup", this.#n), this.on(this.#s, "touchstart", this.#p), this.on(document, "touchmove", this.#u), this.on(document, "touchend", this.#v), this.on(this.#s, "wheel", this.#b), this.on(this, "keydown", this.#w));
|
|
1655
1795
|
}
|
|
1656
|
-
#
|
|
1796
|
+
#c = (t) => {
|
|
1657
1797
|
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
1798
|
};
|
|
1659
|
-
#
|
|
1799
|
+
#h = (t) => {
|
|
1660
1800
|
if (!this.#t) return;
|
|
1661
1801
|
const e = this.#e - t.clientY, s = (this.max - this.min) / 100;
|
|
1662
|
-
this.#
|
|
1802
|
+
this.#g(this.#i + e * s);
|
|
1663
1803
|
};
|
|
1664
|
-
#
|
|
1665
|
-
this.#t && (this.#t = !1, this.#s?.classList.remove("ry-knob__ring--dragging"), this.removeAttribute("data-dragging"), this.#
|
|
1804
|
+
#n = () => {
|
|
1805
|
+
this.#t && (this.#t = !1, this.#s?.classList.remove("ry-knob__ring--dragging"), this.removeAttribute("data-dragging"), this.#f());
|
|
1666
1806
|
};
|
|
1667
|
-
#
|
|
1807
|
+
#p = (t) => {
|
|
1668
1808
|
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
1809
|
};
|
|
1670
|
-
#
|
|
1810
|
+
#u = (t) => {
|
|
1671
1811
|
if (!this.#t) return;
|
|
1672
1812
|
t.preventDefault();
|
|
1673
1813
|
const e = t.touches[0];
|
|
1674
1814
|
if (!e) return;
|
|
1675
1815
|
const s = this.#e - e.clientY, i = (this.max - this.min) / 100;
|
|
1676
|
-
this.#
|
|
1816
|
+
this.#g(this.#i + s * i);
|
|
1677
1817
|
};
|
|
1678
|
-
#
|
|
1679
|
-
this.#t && (this.#t = !1, this.#s?.classList.remove("ry-knob__ring--dragging"), this.removeAttribute("data-dragging"), this.#
|
|
1818
|
+
#v = () => {
|
|
1819
|
+
this.#t && (this.#t = !1, this.#s?.classList.remove("ry-knob__ring--dragging"), this.removeAttribute("data-dragging"), this.#f());
|
|
1680
1820
|
};
|
|
1681
|
-
#
|
|
1821
|
+
#b = (t) => {
|
|
1682
1822
|
if (this.disabled) return;
|
|
1683
1823
|
t.preventDefault();
|
|
1684
1824
|
const e = this.step || (this.max - this.min) / 50, s = t.deltaY < 0 ? e : -e;
|
|
1685
|
-
this.#
|
|
1825
|
+
this.#g(this.value + s), this.#f();
|
|
1686
1826
|
};
|
|
1687
1827
|
#w = (t) => {
|
|
1688
1828
|
if (this.disabled) return;
|
|
@@ -1704,26 +1844,26 @@ class et extends d {
|
|
|
1704
1844
|
i = -s;
|
|
1705
1845
|
break;
|
|
1706
1846
|
case "Home":
|
|
1707
|
-
this.#
|
|
1847
|
+
this.#g(this.min), this.#f();
|
|
1708
1848
|
return;
|
|
1709
1849
|
case "End":
|
|
1710
|
-
this.#
|
|
1850
|
+
this.#g(this.max), this.#f();
|
|
1711
1851
|
return;
|
|
1712
1852
|
default:
|
|
1713
1853
|
return;
|
|
1714
1854
|
}
|
|
1715
|
-
t.preventDefault(), this.#
|
|
1855
|
+
t.preventDefault(), this.#g(this.value + i), this.#f();
|
|
1716
1856
|
};
|
|
1717
|
-
#
|
|
1857
|
+
#g(t) {
|
|
1718
1858
|
let e = Math.max(this.min, Math.min(this.max, t));
|
|
1719
1859
|
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.#
|
|
1860
|
+
s > 0 && (e = Math.round((e - this.min) / s) * s + this.min, e = Math.max(this.min, Math.min(this.max, e))), this.value = e, this.#d(), this.#m();
|
|
1721
1861
|
}
|
|
1722
1862
|
#d() {
|
|
1723
1863
|
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.#
|
|
1864
|
+
this.#s && (this.#s.style.setProperty("--knob-rotation", `${e}deg`), this.#s.style.setProperty("--knob-percent", String(t))), this.#a && (this.#a.textContent = this.#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
1865
|
}
|
|
1726
|
-
#
|
|
1866
|
+
#y(t) {
|
|
1727
1867
|
const e = this.getAttribute("labels");
|
|
1728
1868
|
if (e) {
|
|
1729
1869
|
const i = e.split(","), r = Math.round(t);
|
|
@@ -1731,11 +1871,11 @@ class et extends d {
|
|
|
1731
1871
|
}
|
|
1732
1872
|
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
1873
|
}
|
|
1734
|
-
#
|
|
1874
|
+
#m() {
|
|
1735
1875
|
const t = (this.value - this.min) / (this.max - this.min);
|
|
1736
1876
|
this.emit("input", { value: this.value, percent: t });
|
|
1737
1877
|
}
|
|
1738
|
-
#
|
|
1878
|
+
#f() {
|
|
1739
1879
|
const t = (this.value - this.min) / (this.max - this.min);
|
|
1740
1880
|
this.emit("change", { value: this.value, percent: t });
|
|
1741
1881
|
}
|
|
@@ -1774,29 +1914,291 @@ class et extends d {
|
|
|
1774
1914
|
t ? this.setAttribute("disabled", "") : this.removeAttribute("disabled");
|
|
1775
1915
|
}
|
|
1776
1916
|
}
|
|
1777
|
-
customElements.define("ry-knob",
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1917
|
+
customElements.define("ry-knob", ot);
|
|
1918
|
+
const S = 15, T = 3;
|
|
1919
|
+
class ht extends u {
|
|
1920
|
+
#t = null;
|
|
1921
|
+
#e = null;
|
|
1922
|
+
#i = null;
|
|
1923
|
+
#s = null;
|
|
1924
|
+
#r = null;
|
|
1925
|
+
#a = !1;
|
|
1926
|
+
#o = 0;
|
|
1927
|
+
#l = 0;
|
|
1928
|
+
#c = 0;
|
|
1929
|
+
#h = !1;
|
|
1930
|
+
#n = null;
|
|
1931
|
+
#p = null;
|
|
1932
|
+
static observedAttributes = ["min", "max", "step", "value", "disabled", "arrows", "icons", "drag", "editable", "wrap", "label", "prefix", "suffix"];
|
|
1933
|
+
setup() {
|
|
1934
|
+
this.#u(), this.#b(), this.#w(), this.#A();
|
|
1935
|
+
}
|
|
1936
|
+
#u() {
|
|
1937
|
+
const t = this.getAttribute("arrows") ?? "both", e = this.getAttribute("label"), s = t === "stacked" || t === "stacked-end" || t === "stacked-start", [i, r] = this.#v(s), a = t !== "end" && t !== "none", n = t !== "start" && t !== "none", o = this.getAttribute("prefix"), l = this.getAttribute("suffix"), c = a ? `<button data-ry-target="decrement" class="ry-number-select__btn ry-number-select__decrement" aria-label="Decrease" tabindex="-1" type="button">${i}</button>` : "", d = n ? `<button data-ry-target="increment" class="ry-number-select__btn ry-number-select__increment" aria-label="Increase" tabindex="-1" type="button">${r}</button>` : "", g = `
|
|
1938
|
+
<div data-ry-target="display" class="ry-number-select__display" tabindex="0" role="spinbutton"
|
|
1939
|
+
aria-valuenow="${this.value}" aria-valuemin="${this.min}" aria-valuemax="${this.max}"
|
|
1940
|
+
${e ? `aria-label="${e}"` : ""}>
|
|
1941
|
+
${o ? `<span data-ry-target="prefix" class="ry-number-select__affix">${o}</span>` : ""}
|
|
1942
|
+
<span data-ry-target="value" class="ry-number-select__value">${this.#j(this.value)}</span>
|
|
1943
|
+
${l ? `<span data-ry-target="suffix" class="ry-number-select__affix">${l}</span>` : ""}
|
|
1944
|
+
<input data-ry-target="input" class="ry-number-select__input" type="text" inputmode="decimal" tabindex="-1">
|
|
1945
|
+
</div>`, b = e ? `<span data-ry-target="label" class="ry-number-select__label">${e}</span>` : "";
|
|
1946
|
+
if (t === "stacked")
|
|
1947
|
+
this.innerHTML = `${d}${g}${c}${b}`;
|
|
1948
|
+
else if (t === "stacked-end") {
|
|
1949
|
+
const y = `<div data-ry-target="btn-group" class="ry-number-select__btn-group">${d}${c}</div>`;
|
|
1950
|
+
this.innerHTML = `${g}${y}${b}`;
|
|
1951
|
+
} else if (t === "stacked-start") {
|
|
1952
|
+
const y = `<div data-ry-target="btn-group" class="ry-number-select__btn-group">${d}${c}</div>`;
|
|
1953
|
+
this.innerHTML = `${y}${g}${b}`;
|
|
1954
|
+
} else
|
|
1955
|
+
this.innerHTML = `${c}${g}${d}${b}`;
|
|
1956
|
+
}
|
|
1957
|
+
#v(t) {
|
|
1958
|
+
const e = this.getAttribute("icons") ?? "plus-minus";
|
|
1959
|
+
return e === "chevron" ? t ? [p("chevron-down") ?? "▾", p("chevron-up") ?? "▴"] : [p("chevron-left") ?? "‹", p("chevron-right") ?? "›"] : e === "arrow" ? t ? [p("chevron-down") ?? "▼", p("chevron-up") ?? "▲"] : [p("chevron-left") ?? "◀", p("chevron-right") ?? "▶"] : [p("minus") ?? "−", p("plus") ?? "+"];
|
|
1960
|
+
}
|
|
1961
|
+
#b() {
|
|
1962
|
+
this.#t = this.$('[data-ry-target="display"]'), this.#e = this.$('[data-ry-target="value"]'), this.#i = this.$('[data-ry-target="input"]'), this.#s = this.$('[data-ry-target="decrement"]'), this.#r = this.$('[data-ry-target="increment"]');
|
|
1963
|
+
}
|
|
1964
|
+
#w() {
|
|
1965
|
+
this.#s && (this.on(this.#s, "mousedown", (t) => {
|
|
1966
|
+
t.preventDefault(), this.#g(-1);
|
|
1967
|
+
}), this.on(this.#s, "mouseup", () => this.#d()), this.on(this.#s, "mouseleave", () => this.#d())), this.#r && (this.on(this.#r, "mousedown", (t) => {
|
|
1968
|
+
t.preventDefault(), this.#g(1);
|
|
1969
|
+
}), this.on(this.#r, "mouseup", () => this.#d()), this.on(this.#r, "mouseleave", () => this.#d())), this.#t && this.on(this.#t, "mousedown", this.#H), 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.#C()), this.#i && (this.on(this.#i, "blur", () => this.#V()), this.on(this.#i, "keydown", (t) => {
|
|
1970
|
+
t.key === "Enter" && (t.preventDefault(), this.#V()), t.key === "Escape" && (t.preventDefault(), this.#P()), t.stopPropagation();
|
|
1971
|
+
}));
|
|
1972
|
+
}
|
|
1973
|
+
// --- Button hold-to-repeat ---
|
|
1974
|
+
#g(t) {
|
|
1975
|
+
if (this.disabled) return;
|
|
1976
|
+
const e = this.step || 1;
|
|
1977
|
+
this.#R(t * e), this.#_(), this.#n = setTimeout(() => {
|
|
1978
|
+
let s = 150;
|
|
1979
|
+
const i = () => {
|
|
1980
|
+
this.#R(t * e), this.#x(), s = Math.max(40, s * 0.85), this.#p = setTimeout(i, s);
|
|
1981
|
+
};
|
|
1982
|
+
i();
|
|
1983
|
+
}, 400);
|
|
1984
|
+
}
|
|
1985
|
+
#d() {
|
|
1986
|
+
this.#n && (clearTimeout(this.#n), this.#n = null), this.#p && (clearTimeout(this.#p), this.#p = null);
|
|
1987
|
+
}
|
|
1988
|
+
// --- Drag helpers ---
|
|
1989
|
+
get #y() {
|
|
1990
|
+
const t = this.getAttribute("drag");
|
|
1991
|
+
if (t === "x" || t === "y" || t === "none") return t;
|
|
1992
|
+
const e = this.getAttribute("arrows");
|
|
1993
|
+
return e === "stacked" || e === "stacked-end" || e === "stacked-start" ? "y" : "x";
|
|
1994
|
+
}
|
|
1995
|
+
#m(t, e) {
|
|
1996
|
+
return this.#y === "y" ? this.#l - e : t - this.#o;
|
|
1997
|
+
}
|
|
1998
|
+
#f(t, e) {
|
|
1999
|
+
return this.#y === "y" ? Math.abs(e - this.#l) : Math.abs(t - this.#o);
|
|
2000
|
+
}
|
|
2001
|
+
#M(t, e) {
|
|
2002
|
+
if (!this.#e) return;
|
|
2003
|
+
const s = t / e * 4, i = this.#y;
|
|
2004
|
+
this.#e.style.transform = i === "y" ? `translateY(${-s}px)` : `translateX(${s}px)`;
|
|
2005
|
+
}
|
|
2006
|
+
#$(t, e, s) {
|
|
2007
|
+
const i = this.#m(t, e), r = this.step || 1, a = s ? r * 10 : r, n = s ? S * 2 : S, o = Math.round(i / n), l = this.#c + o * a, c = i - o * n;
|
|
2008
|
+
this.#M(c, n);
|
|
2009
|
+
const d = this.hasAttribute("wrap") ? this.#z(l) : this.#T(l), g = this.#F(d);
|
|
2010
|
+
g !== this.value && (this.value = g, this.#A(), this.#x());
|
|
2011
|
+
}
|
|
2012
|
+
// --- Mouse drag ---
|
|
2013
|
+
#H = (t) => {
|
|
2014
|
+
this.disabled || this.#h || this.#y === "none" || (t.preventDefault(), this.#a = !0, this.#o = t.clientX, this.#l = t.clientY, this.#c = this.value, this.setAttribute("data-dragging", ""));
|
|
2015
|
+
};
|
|
2016
|
+
#W = (t) => {
|
|
2017
|
+
this.#a && this.#$(t.clientX, t.clientY, t.shiftKey);
|
|
2018
|
+
};
|
|
2019
|
+
#E = (t) => {
|
|
2020
|
+
if (!this.#a) return;
|
|
2021
|
+
const e = this.#f(t.clientX, t.clientY);
|
|
2022
|
+
this.#a = !1, this.removeAttribute("data-dragging"), this.#e && (this.#e.style.transform = ""), e < T && this.hasAttribute("editable") ? this.#C() : e >= T && this.#_();
|
|
2023
|
+
};
|
|
2024
|
+
// --- Touch drag ---
|
|
2025
|
+
#X = (t) => {
|
|
2026
|
+
this.disabled || this.#h || this.#y === "none" || (t.preventDefault(), this.#a = !0, this.#o = t.touches[0]?.clientX ?? 0, this.#l = t.touches[0]?.clientY ?? 0, this.#c = this.value, this.setAttribute("data-dragging", ""));
|
|
2027
|
+
};
|
|
2028
|
+
#G = (t) => {
|
|
2029
|
+
if (!this.#a) return;
|
|
2030
|
+
t.preventDefault();
|
|
2031
|
+
const e = t.touches[0];
|
|
2032
|
+
e && this.#$(e.clientX, e.clientY, !1);
|
|
2033
|
+
};
|
|
2034
|
+
#K = () => {
|
|
2035
|
+
this.#a && (this.#a = !1, this.removeAttribute("data-dragging"), this.#e && (this.#e.style.transform = ""), this.#_());
|
|
2036
|
+
};
|
|
2037
|
+
// --- Keyboard ---
|
|
2038
|
+
#q = (t) => {
|
|
2039
|
+
if (this.disabled || this.#h) return;
|
|
2040
|
+
const e = this.step || 1, s = e * 10;
|
|
2041
|
+
let i = 0;
|
|
2042
|
+
switch (t.key) {
|
|
2043
|
+
case "ArrowUp":
|
|
2044
|
+
case "ArrowRight":
|
|
2045
|
+
i = t.shiftKey ? s : e;
|
|
2046
|
+
break;
|
|
2047
|
+
case "ArrowDown":
|
|
2048
|
+
case "ArrowLeft":
|
|
2049
|
+
i = -(t.shiftKey ? s : e);
|
|
2050
|
+
break;
|
|
2051
|
+
case "PageUp":
|
|
2052
|
+
i = s;
|
|
2053
|
+
break;
|
|
2054
|
+
case "PageDown":
|
|
2055
|
+
i = -s;
|
|
2056
|
+
break;
|
|
2057
|
+
case "Home":
|
|
2058
|
+
i = this.min - this.value;
|
|
2059
|
+
break;
|
|
2060
|
+
case "End":
|
|
2061
|
+
i = this.max - this.value;
|
|
2062
|
+
break;
|
|
2063
|
+
case "Enter":
|
|
2064
|
+
this.hasAttribute("editable") && this.#C();
|
|
2065
|
+
return;
|
|
2066
|
+
default:
|
|
2067
|
+
this.hasAttribute("editable") && /^[0-9.\-]$/.test(t.key) && (this.#C(t.key), t.preventDefault());
|
|
2068
|
+
return;
|
|
2069
|
+
}
|
|
2070
|
+
t.preventDefault(), this.#R(i), this.#x(), this.#_();
|
|
2071
|
+
};
|
|
2072
|
+
// --- Wheel ---
|
|
2073
|
+
#J = (t) => {
|
|
2074
|
+
if (this.disabled || this.#h || !this.matches(":hover") && !this.contains(document.activeElement)) return;
|
|
2075
|
+
t.preventDefault();
|
|
2076
|
+
const e = this.step || 1, s = t.shiftKey ? e * 10 : e, i = t.deltaY < 0 ? s : -s;
|
|
2077
|
+
this.#R(i), this.#x(), this.#_();
|
|
2078
|
+
};
|
|
2079
|
+
// --- Edit mode ---
|
|
2080
|
+
#C(t) {
|
|
2081
|
+
this.disabled || this.#h || (this.#h = !0, this.state = "editing", this.#e && (this.#e.style.display = "none"), this.#i && (this.#i.style.display = "block", this.#i.value = t ?? this.#j(this.value), this.#i.focus(), t ? this.#i.setSelectionRange(1, 1) : this.#i.select()));
|
|
2082
|
+
}
|
|
2083
|
+
#V() {
|
|
2084
|
+
if (!this.#h) return;
|
|
2085
|
+
this.#h = !1, this.state = "";
|
|
2086
|
+
const t = parseFloat(this.#i?.value ?? "");
|
|
2087
|
+
if (!isNaN(t)) {
|
|
2088
|
+
const e = this.#T(t), s = this.#F(e);
|
|
2089
|
+
this.value = s, this.#_();
|
|
2090
|
+
}
|
|
2091
|
+
this.#e && (this.#e.style.display = ""), this.#i && (this.#i.style.display = "none"), this.#A(), this.#t?.focus();
|
|
2092
|
+
}
|
|
2093
|
+
#P() {
|
|
2094
|
+
this.#h && (this.#h = !1, this.state = "", this.#e && (this.#e.style.display = ""), this.#i && (this.#i.style.display = "none"), this.#t?.focus());
|
|
2095
|
+
}
|
|
2096
|
+
// --- Value management ---
|
|
2097
|
+
#R(t) {
|
|
2098
|
+
let e = this.value + t;
|
|
2099
|
+
this.hasAttribute("wrap") ? e = this.#z(e) : e = this.#T(e), e = this.#F(e), this.value = e, this.#A();
|
|
2100
|
+
}
|
|
2101
|
+
#T(t) {
|
|
2102
|
+
return Math.max(this.min, Math.min(this.max, t));
|
|
2103
|
+
}
|
|
2104
|
+
#z(t) {
|
|
2105
|
+
const e = this.step || 1, s = this.max - this.min + e;
|
|
2106
|
+
let i = t;
|
|
2107
|
+
for (; i > this.max; ) i -= s;
|
|
2108
|
+
for (; i < this.min; ) i += s;
|
|
2109
|
+
return i;
|
|
2110
|
+
}
|
|
2111
|
+
#F(t) {
|
|
2112
|
+
const e = this.step;
|
|
2113
|
+
if (e <= 0) return this.#T(t);
|
|
2114
|
+
const s = Math.round((t - this.min) / e) * e + this.min;
|
|
2115
|
+
return this.#T(s);
|
|
2116
|
+
}
|
|
2117
|
+
#j(t) {
|
|
2118
|
+
const e = this.step;
|
|
2119
|
+
if (e >= 1) return Math.round(t).toString();
|
|
2120
|
+
const s = Math.max(0, -Math.floor(Math.log10(e)));
|
|
2121
|
+
return t.toFixed(s);
|
|
2122
|
+
}
|
|
2123
|
+
#A() {
|
|
2124
|
+
this.#e && (this.#e.textContent = this.#j(this.value)), this.#U();
|
|
2125
|
+
}
|
|
2126
|
+
#U() {
|
|
2127
|
+
this.#t && (this.#t.setAttribute("aria-valuenow", String(this.value)), this.#t.setAttribute("aria-valuemin", String(this.min)), this.#t.setAttribute("aria-valuemax", String(this.max)));
|
|
2128
|
+
}
|
|
2129
|
+
#x() {
|
|
2130
|
+
this.emit("input", { value: this.value });
|
|
2131
|
+
}
|
|
2132
|
+
#_() {
|
|
2133
|
+
this.emit("change", { value: this.value });
|
|
2134
|
+
}
|
|
2135
|
+
// --- Public API ---
|
|
2136
|
+
get value() {
|
|
2137
|
+
return parseFloat(this.getAttribute("value") ?? "0");
|
|
2138
|
+
}
|
|
2139
|
+
set value(t) {
|
|
2140
|
+
this.setAttribute("value", String(t));
|
|
2141
|
+
}
|
|
2142
|
+
get min() {
|
|
2143
|
+
return parseFloat(this.getAttribute("min") ?? "0");
|
|
2144
|
+
}
|
|
2145
|
+
set min(t) {
|
|
2146
|
+
this.setAttribute("min", String(t));
|
|
2147
|
+
}
|
|
2148
|
+
get max() {
|
|
2149
|
+
return parseFloat(this.getAttribute("max") ?? "100");
|
|
2150
|
+
}
|
|
2151
|
+
set max(t) {
|
|
2152
|
+
this.setAttribute("max", String(t));
|
|
2153
|
+
}
|
|
2154
|
+
get step() {
|
|
2155
|
+
return parseFloat(this.getAttribute("step") ?? "1");
|
|
2156
|
+
}
|
|
2157
|
+
set step(t) {
|
|
2158
|
+
this.setAttribute("step", String(t));
|
|
2159
|
+
}
|
|
2160
|
+
get drag() {
|
|
2161
|
+
return this.#y;
|
|
2162
|
+
}
|
|
2163
|
+
set drag(t) {
|
|
2164
|
+
this.setAttribute("drag", t);
|
|
2165
|
+
}
|
|
2166
|
+
get disabled() {
|
|
2167
|
+
return this.hasAttribute("disabled");
|
|
2168
|
+
}
|
|
2169
|
+
set disabled(t) {
|
|
2170
|
+
t ? this.setAttribute("disabled", "") : this.removeAttribute("disabled");
|
|
2171
|
+
}
|
|
2172
|
+
attributeChangedCallback(t, e, s) {
|
|
2173
|
+
e !== s && t === "value" && this.#t && this.#A();
|
|
2174
|
+
}
|
|
2175
|
+
teardown() {
|
|
2176
|
+
this.#d();
|
|
2177
|
+
}
|
|
2178
|
+
}
|
|
2179
|
+
customElements.define("ry-number-select", ht);
|
|
2180
|
+
function v(h) {
|
|
2181
|
+
const t = h.h / 360, e = h.s / 100, s = h.v / 100;
|
|
2182
|
+
let i = 0, r = 0, a = 0;
|
|
2183
|
+
const n = Math.floor(t * 6), o = t * 6 - n, l = s * (1 - e), c = s * (1 - o * e), d = s * (1 - (1 - o) * e);
|
|
2184
|
+
switch (n % 6) {
|
|
2185
|
+
case 0:
|
|
2186
|
+
i = s, r = d, a = l;
|
|
2187
|
+
break;
|
|
2188
|
+
case 1:
|
|
2189
|
+
i = c, r = s, a = l;
|
|
2190
|
+
break;
|
|
2191
|
+
case 2:
|
|
2192
|
+
i = l, r = s, a = d;
|
|
2193
|
+
break;
|
|
2194
|
+
case 3:
|
|
2195
|
+
i = l, r = c, a = s;
|
|
1794
2196
|
break;
|
|
1795
2197
|
case 4:
|
|
1796
|
-
i =
|
|
2198
|
+
i = d, r = l, a = s;
|
|
1797
2199
|
break;
|
|
1798
2200
|
case 5:
|
|
1799
|
-
i = s, r =
|
|
2201
|
+
i = s, r = l, a = c;
|
|
1800
2202
|
break;
|
|
1801
2203
|
}
|
|
1802
2204
|
return {
|
|
@@ -1805,10 +2207,10 @@ function f(o) {
|
|
|
1805
2207
|
b: Math.round(a * 255)
|
|
1806
2208
|
};
|
|
1807
2209
|
}
|
|
1808
|
-
function
|
|
1809
|
-
const t =
|
|
2210
|
+
function $(h) {
|
|
2211
|
+
const t = h.r / 255, e = h.g / 255, s = h.b / 255, i = Math.max(t, e, s), r = Math.min(t, e, s), a = i - r;
|
|
1810
2212
|
let n = 0;
|
|
1811
|
-
const
|
|
2213
|
+
const o = i === 0 ? 0 : a / i, l = i;
|
|
1812
2214
|
if (i !== r)
|
|
1813
2215
|
switch (i) {
|
|
1814
2216
|
case t:
|
|
@@ -1823,34 +2225,34 @@ function w(o) {
|
|
|
1823
2225
|
}
|
|
1824
2226
|
return {
|
|
1825
2227
|
h: Math.round(n * 360),
|
|
1826
|
-
s: Math.round(
|
|
1827
|
-
v: Math.round(
|
|
2228
|
+
s: Math.round(o * 100),
|
|
2229
|
+
v: Math.round(l * 100)
|
|
1828
2230
|
};
|
|
1829
2231
|
}
|
|
1830
|
-
function
|
|
1831
|
-
const t =
|
|
2232
|
+
function L(h) {
|
|
2233
|
+
const t = h.s / 100, e = h.v / 100, s = e * (1 - t / 2), i = s === 0 || s === 1 ? 0 : (e - s) / Math.min(s, 1 - s);
|
|
1832
2234
|
return {
|
|
1833
|
-
h:
|
|
2235
|
+
h: h.h,
|
|
1834
2236
|
s: Math.round(i * 100),
|
|
1835
2237
|
l: Math.round(s * 100)
|
|
1836
2238
|
};
|
|
1837
2239
|
}
|
|
1838
|
-
function
|
|
1839
|
-
const t =
|
|
2240
|
+
function lt(h) {
|
|
2241
|
+
const t = h.s / 100, e = h.l / 100, s = e + t * Math.min(e, 1 - e), i = s === 0 ? 0 : 2 * (1 - e / s);
|
|
1840
2242
|
return {
|
|
1841
|
-
h:
|
|
2243
|
+
h: h.h,
|
|
1842
2244
|
s: Math.round(i * 100),
|
|
1843
2245
|
v: Math.round(s * 100)
|
|
1844
2246
|
};
|
|
1845
2247
|
}
|
|
1846
|
-
function
|
|
2248
|
+
function I(h) {
|
|
1847
2249
|
const t = (e) => e.toString(16).padStart(2, "0");
|
|
1848
|
-
return `#${t(
|
|
2250
|
+
return `#${t(h.r)}${t(h.g)}${t(h.b)}`;
|
|
1849
2251
|
}
|
|
1850
|
-
function
|
|
1851
|
-
const t = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(
|
|
2252
|
+
function ct(h) {
|
|
2253
|
+
const t = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(h);
|
|
1852
2254
|
if (!t) {
|
|
1853
|
-
const e = /^#?([a-f\d])([a-f\d])([a-f\d])$/i.exec(
|
|
2255
|
+
const e = /^#?([a-f\d])([a-f\d])([a-f\d])$/i.exec(h);
|
|
1854
2256
|
return e ? {
|
|
1855
2257
|
r: parseInt(e[1] + e[1], 16),
|
|
1856
2258
|
g: parseInt(e[2] + e[2], 16),
|
|
@@ -1863,8 +2265,8 @@ function it(o) {
|
|
|
1863
2265
|
b: parseInt(t[3], 16)
|
|
1864
2266
|
};
|
|
1865
2267
|
}
|
|
1866
|
-
function
|
|
1867
|
-
const t =
|
|
2268
|
+
function A(h) {
|
|
2269
|
+
const t = h.trim().toLowerCase();
|
|
1868
2270
|
if (t.startsWith("#")) {
|
|
1869
2271
|
const i = /^#([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);
|
|
1870
2272
|
if (i) {
|
|
@@ -1873,10 +2275,10 @@ function m(o) {
|
|
|
1873
2275
|
g: parseInt(i[2], 16),
|
|
1874
2276
|
b: parseInt(i[3], 16)
|
|
1875
2277
|
}, n = parseInt(i[4], 16) / 255;
|
|
1876
|
-
return { hsv:
|
|
2278
|
+
return { hsv: $(a), alpha: Math.round(n * 100) };
|
|
1877
2279
|
}
|
|
1878
|
-
const r =
|
|
1879
|
-
return r ? { hsv:
|
|
2280
|
+
const r = ct(t);
|
|
2281
|
+
return r ? { hsv: $(r), alpha: 100 } : null;
|
|
1880
2282
|
}
|
|
1881
2283
|
const e = /^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d.]+))?\s*\)$/.exec(t);
|
|
1882
2284
|
if (e) {
|
|
@@ -1885,7 +2287,7 @@ function m(o) {
|
|
|
1885
2287
|
g: parseInt(e[2], 10),
|
|
1886
2288
|
b: parseInt(e[3], 10)
|
|
1887
2289
|
}, r = e[4] ? parseFloat(e[4]) * 100 : 100;
|
|
1888
|
-
return { hsv:
|
|
2290
|
+
return { hsv: $(i), alpha: r };
|
|
1889
2291
|
}
|
|
1890
2292
|
const s = /^hsla?\(\s*([\d.]+)\s*,\s*([\d.]+)%\s*,\s*([\d.]+)%\s*(?:,\s*([\d.]+))?\s*\)$/.exec(t);
|
|
1891
2293
|
if (s) {
|
|
@@ -1894,31 +2296,31 @@ function m(o) {
|
|
|
1894
2296
|
s: parseFloat(s[2]),
|
|
1895
2297
|
l: parseFloat(s[3])
|
|
1896
2298
|
}, r = s[4] ? parseFloat(s[4]) * 100 : 100;
|
|
1897
|
-
return { hsv:
|
|
2299
|
+
return { hsv: lt(i), alpha: r };
|
|
1898
2300
|
}
|
|
1899
2301
|
return null;
|
|
1900
2302
|
}
|
|
1901
|
-
class
|
|
2303
|
+
class dt extends u {
|
|
1902
2304
|
#t = 0;
|
|
1903
2305
|
#e = 100;
|
|
1904
2306
|
#i = 100;
|
|
1905
2307
|
#s = 100;
|
|
1906
2308
|
#r = !1;
|
|
1907
|
-
#
|
|
1908
|
-
#
|
|
2309
|
+
#a = !1;
|
|
2310
|
+
#o = !1;
|
|
2311
|
+
#l = null;
|
|
1909
2312
|
#c = null;
|
|
2313
|
+
#h = null;
|
|
2314
|
+
#n = null;
|
|
1910
2315
|
#p = null;
|
|
1911
|
-
#a = null;
|
|
1912
2316
|
#u = null;
|
|
1913
|
-
#
|
|
2317
|
+
#v = null;
|
|
1914
2318
|
#b = null;
|
|
1915
|
-
#g = null;
|
|
1916
|
-
#o = null;
|
|
1917
2319
|
#w = null;
|
|
1918
|
-
#
|
|
2320
|
+
#g = null;
|
|
1919
2321
|
static observedAttributes = ["value", "format", "opacity", "disabled", "swatches", "inline"];
|
|
1920
2322
|
setup() {
|
|
1921
|
-
this.#d(), this.#
|
|
2323
|
+
this.#d(), this.#y(), this.#m(), this.#A();
|
|
1922
2324
|
}
|
|
1923
2325
|
#d() {
|
|
1924
2326
|
const t = this.hasAttribute("inline"), e = this.hasAttribute("opacity"), s = this.getAttribute("swatches");
|
|
@@ -1960,57 +2362,57 @@ class rt extends d {
|
|
|
1960
2362
|
<span data-ry-target="trigger-color" class="ry-color-picker__trigger-color"></span>
|
|
1961
2363
|
</button>
|
|
1962
2364
|
<div data-ry-target="panel" class="ry-color-picker__panel">${i}</div>
|
|
1963
|
-
`, this.#
|
|
2365
|
+
`, this.#l = this.$('[data-ry-target="trigger"]'), this.#c = this.$('[data-ry-target="panel"]'), this.#h = this.$('[data-ry-target="grid"]'), this.#n = this.$('[data-ry-target="grid-handle"]'), this.#p = this.$('[data-ry-target="hue-slider"]'), this.#u = this.$('[data-ry-target="hue-handle"]'), this.#v = this.$('[data-ry-target="alpha-slider"]'), this.#b = this.$('[data-ry-target="alpha-handle"]'), this.#w = this.$('[data-ry-target="preview"]'), this.#g = this.$('[data-ry-target="input"]');
|
|
1964
2366
|
}
|
|
1965
|
-
#
|
|
1966
|
-
this.#
|
|
2367
|
+
#y() {
|
|
2368
|
+
this.#l && this.on(this.#l, "click", this.#f), this.on(document, "click", this.#M), this.on(document, "keydown", this.#$), this.#h && this.on(this.#h, "pointerdown", this.#W), this.#n && this.on(this.#n, "keydown", this.#X), this.#p && this.on(this.#p, "pointerdown", this.#G), this.#u && this.on(this.#u, "keydown", this.#q), this.#v && this.on(this.#v, "pointerdown", this.#J), this.#b && this.on(this.#b, "keydown", this.#V), this.on(document, "pointermove", this.#P), this.on(document, "pointerup", this.#R), this.#g && (this.on(this.#g, "change", this.#T), this.on(this.#g, "keydown", this.#z));
|
|
1967
2369
|
const t = this.$('[data-ry-target="format-toggle"]');
|
|
1968
|
-
t && this.on(t, "click", this.#
|
|
2370
|
+
t && this.on(t, "click", this.#F);
|
|
1969
2371
|
const e = this.$('[data-ry-target="swatches"]');
|
|
1970
|
-
e && this.on(e, "click", this.#
|
|
2372
|
+
e && this.on(e, "click", this.#j);
|
|
1971
2373
|
}
|
|
1972
|
-
#
|
|
2374
|
+
#m() {
|
|
1973
2375
|
const t = this.getAttribute("value");
|
|
1974
2376
|
if (t) {
|
|
1975
|
-
const e =
|
|
2377
|
+
const e = A(t);
|
|
1976
2378
|
e && (this.#t = e.hsv.h, this.#e = e.hsv.s, this.#i = e.hsv.v, this.#s = e.alpha);
|
|
1977
2379
|
}
|
|
1978
2380
|
}
|
|
1979
2381
|
// ───────────────────────────────────────────────────────────────────────────
|
|
1980
2382
|
// Dropdown handlers
|
|
1981
2383
|
// ───────────────────────────────────────────────────────────────────────────
|
|
1982
|
-
#
|
|
2384
|
+
#f = () => {
|
|
1983
2385
|
this.disabled || (this.state === "open" ? this.close() : this.open());
|
|
1984
2386
|
};
|
|
1985
|
-
#
|
|
2387
|
+
#M = (t) => {
|
|
1986
2388
|
this.state === "open" && (this.contains(t.target) || this.close());
|
|
1987
2389
|
};
|
|
1988
|
-
|
|
1989
|
-
t.key === "Escape" && this.state === "open" && (this.close(), this.#
|
|
2390
|
+
#$ = (t) => {
|
|
2391
|
+
t.key === "Escape" && this.state === "open" && (this.close(), this.#l?.focus());
|
|
1990
2392
|
};
|
|
1991
2393
|
open() {
|
|
1992
|
-
this.hasAttribute("inline") || (this.#
|
|
2394
|
+
this.hasAttribute("inline") || (this.#H(), this.state = "open");
|
|
1993
2395
|
}
|
|
1994
2396
|
close() {
|
|
1995
2397
|
this.hasAttribute("inline") || (this.state = "closed", this.removeAttribute("data-ry-position"));
|
|
1996
2398
|
}
|
|
1997
|
-
#
|
|
1998
|
-
if (!this.#
|
|
1999
|
-
const t = this.#
|
|
2399
|
+
#H() {
|
|
2400
|
+
if (!this.#c || !this.#l) return;
|
|
2401
|
+
const t = this.#l.getBoundingClientRect(), e = 320, i = window.innerHeight - t.bottom, r = t.top;
|
|
2000
2402
|
i < e && r > i ? this.setAttribute("data-ry-position", "top") : this.setAttribute("data-ry-position", "bottom");
|
|
2001
2403
|
}
|
|
2002
2404
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2003
2405
|
// Grid handlers
|
|
2004
2406
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2005
|
-
#
|
|
2006
|
-
this.disabled || (t.preventDefault(), this.#r = !0, this.#
|
|
2407
|
+
#W = (t) => {
|
|
2408
|
+
this.disabled || (t.preventDefault(), this.#r = !0, this.#n?.focus(), this.#E(t));
|
|
2007
2409
|
};
|
|
2008
|
-
#
|
|
2009
|
-
if (!this.#
|
|
2010
|
-
const e = this.#
|
|
2011
|
-
this.#e = Math.round(s * 100), this.#i = Math.round((1 - i) * 100), this.#
|
|
2410
|
+
#E(t) {
|
|
2411
|
+
if (!this.#h) return;
|
|
2412
|
+
const e = this.#h.getBoundingClientRect(), s = Math.max(0, Math.min(1, (t.clientX - e.left) / e.width)), i = Math.max(0, Math.min(1, (t.clientY - e.top) / e.height));
|
|
2413
|
+
this.#e = Math.round(s * 100), this.#i = Math.round((1 - i) * 100), this.#A(), this.#L();
|
|
2012
2414
|
}
|
|
2013
|
-
#
|
|
2415
|
+
#X = (t) => {
|
|
2014
2416
|
if (this.disabled) return;
|
|
2015
2417
|
const e = t.shiftKey ? 10 : 1;
|
|
2016
2418
|
let s = !1;
|
|
@@ -2028,20 +2430,20 @@ class rt extends d {
|
|
|
2028
2430
|
this.#i = Math.max(0, this.#i - e), s = !0;
|
|
2029
2431
|
break;
|
|
2030
2432
|
}
|
|
2031
|
-
s && (t.preventDefault(), this.#
|
|
2433
|
+
s && (t.preventDefault(), this.#A(), this.#L(), this.#k());
|
|
2032
2434
|
};
|
|
2033
2435
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2034
2436
|
// Hue handlers
|
|
2035
2437
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2036
|
-
#
|
|
2037
|
-
this.disabled || (t.preventDefault(), this.#
|
|
2438
|
+
#G = (t) => {
|
|
2439
|
+
this.disabled || (t.preventDefault(), this.#a = !0, this.#u?.focus(), this.#K(t));
|
|
2038
2440
|
};
|
|
2039
|
-
#
|
|
2040
|
-
if (!this.#
|
|
2041
|
-
const e = this.#
|
|
2042
|
-
this.#t = Math.round(s * 360), this.#
|
|
2441
|
+
#K(t) {
|
|
2442
|
+
if (!this.#p) return;
|
|
2443
|
+
const e = this.#p.getBoundingClientRect(), s = Math.max(0, Math.min(1, (t.clientX - e.left) / e.width));
|
|
2444
|
+
this.#t = Math.round(s * 360), this.#A(), this.#L();
|
|
2043
2445
|
}
|
|
2044
|
-
#
|
|
2446
|
+
#q = (t) => {
|
|
2045
2447
|
if (this.disabled) return;
|
|
2046
2448
|
const e = t.shiftKey ? 10 : 1;
|
|
2047
2449
|
let s = !1;
|
|
@@ -2055,20 +2457,20 @@ class rt extends d {
|
|
|
2055
2457
|
this.#t = (this.#t - e + 360) % 360, s = !0;
|
|
2056
2458
|
break;
|
|
2057
2459
|
}
|
|
2058
|
-
s && (t.preventDefault(), this.#
|
|
2460
|
+
s && (t.preventDefault(), this.#A(), this.#L(), this.#k());
|
|
2059
2461
|
};
|
|
2060
2462
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2061
2463
|
// Alpha handlers
|
|
2062
2464
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2063
|
-
#
|
|
2064
|
-
this.disabled || (t.preventDefault(), this.#
|
|
2465
|
+
#J = (t) => {
|
|
2466
|
+
this.disabled || (t.preventDefault(), this.#o = !0, this.#b?.focus(), this.#C(t));
|
|
2065
2467
|
};
|
|
2066
|
-
#
|
|
2067
|
-
if (!this.#
|
|
2068
|
-
const e = this.#
|
|
2069
|
-
this.#s = Math.round(s * 100), this.#
|
|
2468
|
+
#C(t) {
|
|
2469
|
+
if (!this.#v) return;
|
|
2470
|
+
const e = this.#v.getBoundingClientRect(), s = Math.max(0, Math.min(1, (t.clientX - e.left) / e.width));
|
|
2471
|
+
this.#s = Math.round(s * 100), this.#A(), this.#L();
|
|
2070
2472
|
}
|
|
2071
|
-
#
|
|
2473
|
+
#V = (t) => {
|
|
2072
2474
|
if (this.disabled) return;
|
|
2073
2475
|
const e = t.shiftKey ? 10 : 1;
|
|
2074
2476
|
let s = !1;
|
|
@@ -2082,99 +2484,99 @@ class rt extends d {
|
|
|
2082
2484
|
this.#s = Math.max(0, this.#s - e), s = !0;
|
|
2083
2485
|
break;
|
|
2084
2486
|
}
|
|
2085
|
-
s && (t.preventDefault(), this.#
|
|
2487
|
+
s && (t.preventDefault(), this.#A(), this.#L(), this.#k());
|
|
2086
2488
|
};
|
|
2087
2489
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2088
2490
|
// Pointer move/up
|
|
2089
2491
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2090
|
-
#
|
|
2091
|
-
this.#r ? this.#
|
|
2492
|
+
#P = (t) => {
|
|
2493
|
+
this.#r ? this.#E(t) : this.#a ? this.#K(t) : this.#o && this.#C(t);
|
|
2092
2494
|
};
|
|
2093
|
-
#
|
|
2094
|
-
(this.#r || this.#
|
|
2495
|
+
#R = () => {
|
|
2496
|
+
(this.#r || this.#a || this.#o) && (this.#r = !1, this.#a = !1, this.#o = !1, this.#k());
|
|
2095
2497
|
};
|
|
2096
2498
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2097
2499
|
// Input handlers
|
|
2098
2500
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2099
2501
|
#T = () => {
|
|
2100
|
-
if (!this.#
|
|
2101
|
-
const t =
|
|
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.#
|
|
2502
|
+
if (!this.#g) return;
|
|
2503
|
+
const t = A(this.#g.value);
|
|
2504
|
+
t ? (this.#t = t.hsv.h, this.#e = t.hsv.s, this.#i = t.hsv.v, this.hasAttribute("opacity") && (this.#s = t.alpha), this.#A(), this.#k()) : this.#Y();
|
|
2103
2505
|
};
|
|
2104
|
-
#
|
|
2506
|
+
#z = (t) => {
|
|
2105
2507
|
t.key === "Enter" && (t.preventDefault(), this.#T());
|
|
2106
2508
|
};
|
|
2107
2509
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2108
2510
|
// Format toggle
|
|
2109
2511
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2110
|
-
#
|
|
2512
|
+
#F = () => {
|
|
2111
2513
|
const t = ["hex", "rgb", "hsl"], e = this.format, s = t.indexOf(e), i = t[(s + 1) % t.length];
|
|
2112
2514
|
this.format = i;
|
|
2113
2515
|
const r = this.$('[data-ry-target="format-toggle"]');
|
|
2114
|
-
r && (r.textContent = i.toUpperCase()), this.#
|
|
2516
|
+
r && (r.textContent = i.toUpperCase()), this.#Y();
|
|
2115
2517
|
};
|
|
2116
2518
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2117
2519
|
// Swatches
|
|
2118
2520
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2119
|
-
#
|
|
2521
|
+
#j = (t) => {
|
|
2120
2522
|
const e = t.target;
|
|
2121
2523
|
if (e.classList.contains("ry-color-picker__swatch")) {
|
|
2122
2524
|
const s = e.dataset.color;
|
|
2123
2525
|
if (s) {
|
|
2124
|
-
const i =
|
|
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.#
|
|
2526
|
+
const i = A(s);
|
|
2527
|
+
i && (this.#t = i.hsv.h, this.#e = i.hsv.s, this.#i = i.hsv.v, this.hasAttribute("opacity") && (this.#s = i.alpha), this.#A(), this.#L(), this.#k());
|
|
2126
2528
|
}
|
|
2127
2529
|
}
|
|
2128
2530
|
};
|
|
2129
2531
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2130
2532
|
// Update methods
|
|
2131
2533
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2132
|
-
#
|
|
2133
|
-
this.#
|
|
2534
|
+
#A() {
|
|
2535
|
+
this.#U(), this.#x(), this.#_(), this.#D(), this.#N(), this.#Y(), this.#Z();
|
|
2134
2536
|
}
|
|
2135
|
-
#
|
|
2537
|
+
#U() {
|
|
2136
2538
|
const t = this.$('[data-ry-target="trigger-color"]');
|
|
2137
2539
|
if (t) {
|
|
2138
|
-
const e =
|
|
2540
|
+
const e = v({ h: this.#t, s: this.#e, v: this.#i }), s = this.hasAttribute("opacity") ? this.#s / 100 : 1;
|
|
2139
2541
|
t.style.backgroundColor = `rgba(${e.r}, ${e.g}, ${e.b}, ${s})`;
|
|
2140
2542
|
}
|
|
2141
2543
|
}
|
|
2142
|
-
#
|
|
2143
|
-
if (this.#
|
|
2144
|
-
const t =
|
|
2145
|
-
this.#
|
|
2544
|
+
#x() {
|
|
2545
|
+
if (this.#h) {
|
|
2546
|
+
const t = v({ h: this.#t, s: 100, v: 100 });
|
|
2547
|
+
this.#h.style.setProperty("--grid-hue-color", `rgb(${t.r}, ${t.g}, ${t.b})`);
|
|
2146
2548
|
}
|
|
2147
|
-
this.#
|
|
2549
|
+
this.#n && (this.#n.style.left = `${this.#e}%`, this.#n.style.top = `${100 - this.#i}%`);
|
|
2148
2550
|
}
|
|
2149
|
-
#
|
|
2150
|
-
this.#
|
|
2551
|
+
#_() {
|
|
2552
|
+
this.#u && (this.#u.style.left = `${this.#t / 360 * 100}%`);
|
|
2151
2553
|
}
|
|
2152
2554
|
#D() {
|
|
2153
|
-
if (this.#
|
|
2154
|
-
const t =
|
|
2155
|
-
this.#
|
|
2555
|
+
if (this.#v) {
|
|
2556
|
+
const t = v({ h: this.#t, s: this.#e, v: this.#i });
|
|
2557
|
+
this.#v.style.setProperty("--alpha-color", `rgb(${t.r}, ${t.g}, ${t.b})`);
|
|
2156
2558
|
}
|
|
2157
|
-
this.#
|
|
2559
|
+
this.#b && (this.#b.style.left = `${this.#s}%`);
|
|
2158
2560
|
}
|
|
2159
|
-
#
|
|
2561
|
+
#N() {
|
|
2160
2562
|
const t = this.$('[data-ry-target="preview-color"]');
|
|
2161
2563
|
if (t) {
|
|
2162
|
-
const e =
|
|
2564
|
+
const e = v({ h: this.#t, s: this.#e, v: this.#i }), s = this.hasAttribute("opacity") ? this.#s / 100 : 1;
|
|
2163
2565
|
t.style.backgroundColor = `rgba(${e.r}, ${e.g}, ${e.b}, ${s})`;
|
|
2164
2566
|
}
|
|
2165
2567
|
}
|
|
2166
|
-
#
|
|
2167
|
-
this.#
|
|
2568
|
+
#Y() {
|
|
2569
|
+
this.#g && (this.#g.value = this.#O());
|
|
2168
2570
|
}
|
|
2169
|
-
#
|
|
2170
|
-
const t = this.#
|
|
2571
|
+
#Z() {
|
|
2572
|
+
const t = this.#O();
|
|
2171
2573
|
this.getAttribute("value") !== t && this.setAttribute("value", t);
|
|
2172
2574
|
}
|
|
2173
|
-
#
|
|
2174
|
-
const t = this.format, e =
|
|
2575
|
+
#O() {
|
|
2576
|
+
const t = this.format, e = v({ h: this.#t, s: this.#e, v: this.#i }), s = this.hasAttribute("opacity");
|
|
2175
2577
|
switch (t) {
|
|
2176
2578
|
case "hex": {
|
|
2177
|
-
const i =
|
|
2579
|
+
const i = I(e);
|
|
2178
2580
|
if (s && this.#s < 100) {
|
|
2179
2581
|
const r = Math.round(this.#s / 100 * 255).toString(16).padStart(2, "0");
|
|
2180
2582
|
return i + r;
|
|
@@ -2184,40 +2586,40 @@ class rt extends d {
|
|
|
2184
2586
|
case "rgb":
|
|
2185
2587
|
return s ? `rgba(${e.r}, ${e.g}, ${e.b}, ${(this.#s / 100).toFixed(2)})` : `rgb(${e.r}, ${e.g}, ${e.b})`;
|
|
2186
2588
|
case "hsl": {
|
|
2187
|
-
const i =
|
|
2589
|
+
const i = L({ h: this.#t, s: this.#e, v: this.#i });
|
|
2188
2590
|
return s ? `hsla(${i.h}, ${i.s}%, ${i.l}%, ${(this.#s / 100).toFixed(2)})` : `hsl(${i.h}, ${i.s}%, ${i.l}%)`;
|
|
2189
2591
|
}
|
|
2190
2592
|
default:
|
|
2191
|
-
return
|
|
2593
|
+
return I(e);
|
|
2192
2594
|
}
|
|
2193
2595
|
}
|
|
2194
2596
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2195
2597
|
// Events
|
|
2196
2598
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2197
|
-
#
|
|
2599
|
+
#L() {
|
|
2198
2600
|
this.emit("input", { value: this.value, hsv: this.hsv, rgb: this.rgb });
|
|
2199
2601
|
}
|
|
2200
|
-
|
|
2602
|
+
#k() {
|
|
2201
2603
|
this.emit("change", { value: this.value, hsv: this.hsv, rgb: this.rgb });
|
|
2202
2604
|
}
|
|
2203
2605
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2204
2606
|
// Attribute changed
|
|
2205
2607
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2206
2608
|
attributeChangedCallback(t, e, s) {
|
|
2207
|
-
if (e !== s && t === "value" && this.#
|
|
2208
|
-
const i =
|
|
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.#
|
|
2609
|
+
if (e !== s && t === "value" && this.#h && s) {
|
|
2610
|
+
const i = A(s);
|
|
2611
|
+
i && (this.#t = i.hsv.h, this.#e = i.hsv.s, this.#i = i.hsv.v, this.hasAttribute("opacity") && (this.#s = i.alpha), this.#U(), this.#x(), this.#_(), this.#D(), this.#N());
|
|
2210
2612
|
}
|
|
2211
2613
|
}
|
|
2212
2614
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2213
2615
|
// Public API
|
|
2214
2616
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2215
2617
|
get value() {
|
|
2216
|
-
return this.#
|
|
2618
|
+
return this.#O();
|
|
2217
2619
|
}
|
|
2218
2620
|
set value(t) {
|
|
2219
|
-
const e =
|
|
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.#
|
|
2621
|
+
const e = A(t);
|
|
2622
|
+
e && (this.#t = e.hsv.h, this.#e = e.hsv.s, this.#i = e.hsv.v, this.hasAttribute("opacity") && (this.#s = e.alpha), this.#A());
|
|
2221
2623
|
}
|
|
2222
2624
|
get format() {
|
|
2223
2625
|
return this.getAttribute("format") || "hex";
|
|
@@ -2235,39 +2637,39 @@ class rt extends d {
|
|
|
2235
2637
|
return { h: this.#t, s: this.#e, v: this.#i };
|
|
2236
2638
|
}
|
|
2237
2639
|
get rgb() {
|
|
2238
|
-
return
|
|
2640
|
+
return v(this.hsv);
|
|
2239
2641
|
}
|
|
2240
2642
|
get hsl() {
|
|
2241
|
-
return
|
|
2643
|
+
return L(this.hsv);
|
|
2242
2644
|
}
|
|
2243
2645
|
get alpha() {
|
|
2244
2646
|
return this.#s;
|
|
2245
2647
|
}
|
|
2246
2648
|
set alpha(t) {
|
|
2247
|
-
this.#s = Math.max(0, Math.min(100, t)), this.#
|
|
2649
|
+
this.#s = Math.max(0, Math.min(100, t)), this.#A();
|
|
2248
2650
|
}
|
|
2249
2651
|
/** Set color from any valid color string */
|
|
2250
2652
|
setColor(t) {
|
|
2251
|
-
const e =
|
|
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.#
|
|
2653
|
+
const e = A(t);
|
|
2654
|
+
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.#A(), !0) : !1;
|
|
2253
2655
|
}
|
|
2254
2656
|
/** Get color in specific format */
|
|
2255
2657
|
getFormattedValue(t) {
|
|
2256
2658
|
const e = this.format;
|
|
2257
2659
|
this.format = t;
|
|
2258
|
-
const s = this.#
|
|
2660
|
+
const s = this.#O();
|
|
2259
2661
|
return this.format = e, s;
|
|
2260
2662
|
}
|
|
2261
2663
|
}
|
|
2262
|
-
customElements.define("ry-color-picker",
|
|
2263
|
-
class
|
|
2664
|
+
customElements.define("ry-color-picker", dt);
|
|
2665
|
+
class ut extends u {
|
|
2264
2666
|
#t = null;
|
|
2265
2667
|
#e = null;
|
|
2266
2668
|
#i = null;
|
|
2267
2669
|
#s = null;
|
|
2268
2670
|
static observedAttributes = ["value", "format", "opacity", "disabled", "placeholder"];
|
|
2269
2671
|
setup() {
|
|
2270
|
-
this.#r(), this.#
|
|
2672
|
+
this.#r(), this.#a(), this.#y(), this.state = "closed";
|
|
2271
2673
|
}
|
|
2272
2674
|
#r() {
|
|
2273
2675
|
const t = this.hasAttribute("opacity"), e = this.getAttribute("format") || "hex", s = this.getAttribute("value") || "#000000", i = this.getAttribute("placeholder") || "#000000";
|
|
@@ -2298,16 +2700,16 @@ class at extends d {
|
|
|
2298
2700
|
</div>
|
|
2299
2701
|
`, 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
2702
|
}
|
|
2301
|
-
#
|
|
2302
|
-
this.#t && this.on(this.#t, "click", this.#
|
|
2703
|
+
#a() {
|
|
2704
|
+
this.#t && this.on(this.#t, "click", this.#o), this.#e && (this.on(this.#e, "input", this.#c), this.on(this.#e, "keydown", this.#p), this.on(this.#e, "focus", this.#l)), this.#s && (this.on(this.#s, "ry:input", this.#u), this.on(this.#s, "ry:change", this.#v)), this.on(document, "click", this.#b), this.on(document, "keydown", this.#w);
|
|
2303
2705
|
}
|
|
2304
|
-
#
|
|
2706
|
+
#o = () => {
|
|
2305
2707
|
this.disabled || (this.state === "open" ? this.close() : this.open());
|
|
2306
2708
|
};
|
|
2307
|
-
#
|
|
2709
|
+
#l = () => {
|
|
2308
2710
|
this.disabled || this.open();
|
|
2309
2711
|
};
|
|
2310
|
-
#
|
|
2712
|
+
#c = () => {
|
|
2311
2713
|
if (!this.#e || !this.#s) return;
|
|
2312
2714
|
let t = this.#e.value;
|
|
2313
2715
|
const e = this.#e.selectionStart ?? t.length, r = "#" + t.replace(/[^#a-fA-F0-9]/g, "").replace(/#/g, "").slice(0, 6);
|
|
@@ -2316,10 +2718,10 @@ class at extends d {
|
|
|
2316
2718
|
const n = Math.min(e, r.length);
|
|
2317
2719
|
this.#e.setSelectionRange(n, n);
|
|
2318
2720
|
}
|
|
2319
|
-
const a = this.#
|
|
2320
|
-
a && (this.#s.setColor(a), this.#d(), this.#
|
|
2721
|
+
const a = this.#h(r);
|
|
2722
|
+
a && (this.#s.setColor(a), this.#d(), this.#n(r) && this.#m(), this.emit("input", { value: this.value }));
|
|
2321
2723
|
};
|
|
2322
|
-
#
|
|
2724
|
+
#h(t) {
|
|
2323
2725
|
let e = t;
|
|
2324
2726
|
e.startsWith("#") || (e = "#" + e);
|
|
2325
2727
|
const s = e.slice(1);
|
|
@@ -2333,31 +2735,31 @@ class at extends d {
|
|
|
2333
2735
|
}
|
|
2334
2736
|
return "#" + s.padEnd(6, "0");
|
|
2335
2737
|
}
|
|
2336
|
-
#
|
|
2738
|
+
#n(t) {
|
|
2337
2739
|
return !!(/^#[a-fA-F0-9]{6}$/.test(t) || /^#[a-fA-F0-9]{3}$/.test(t));
|
|
2338
2740
|
}
|
|
2339
|
-
#
|
|
2340
|
-
t.key === "Enter" && (t.preventDefault(), this.#
|
|
2741
|
+
#p = (t) => {
|
|
2742
|
+
t.key === "Enter" && (t.preventDefault(), this.#c(), this.emit("change", { value: this.value }));
|
|
2341
2743
|
};
|
|
2342
|
-
#
|
|
2343
|
-
!this.#s || !this.#e || (document.activeElement !== this.#e && (this.#e.value = this.#s.value), this.#d(), this.#
|
|
2744
|
+
#u = () => {
|
|
2745
|
+
!this.#s || !this.#e || (document.activeElement !== this.#e && (this.#e.value = this.#s.value), this.#d(), this.#m(), this.emit("input", { value: this.value }));
|
|
2344
2746
|
};
|
|
2345
|
-
#
|
|
2747
|
+
#v = () => {
|
|
2346
2748
|
this.emit("change", { value: this.value });
|
|
2347
2749
|
};
|
|
2348
|
-
#
|
|
2750
|
+
#b = (t) => {
|
|
2349
2751
|
this.state === "open" && (this.contains(t.target) || this.close());
|
|
2350
2752
|
};
|
|
2351
2753
|
#w = (t) => {
|
|
2352
2754
|
t.key === "Escape" && this.state === "open" && (this.close(), this.#t?.focus());
|
|
2353
2755
|
};
|
|
2354
2756
|
open() {
|
|
2355
|
-
this.#
|
|
2757
|
+
this.#g(), this.state = "open";
|
|
2356
2758
|
}
|
|
2357
2759
|
close() {
|
|
2358
2760
|
this.state = "closed", this.removeAttribute("data-ry-position");
|
|
2359
2761
|
}
|
|
2360
|
-
#
|
|
2762
|
+
#g() {
|
|
2361
2763
|
if (!this.#i) return;
|
|
2362
2764
|
const t = this.getBoundingClientRect(), e = 280, i = window.innerHeight - t.bottom, r = t.top;
|
|
2363
2765
|
i < e && r > i ? this.setAttribute("data-ry-position", "top") : this.setAttribute("data-ry-position", "bottom");
|
|
@@ -2369,7 +2771,7 @@ class at extends d {
|
|
|
2369
2771
|
t.style.backgroundColor = `rgba(${e.r}, ${e.g}, ${e.b}, ${s})`;
|
|
2370
2772
|
}
|
|
2371
2773
|
}
|
|
2372
|
-
#
|
|
2774
|
+
#y() {
|
|
2373
2775
|
const t = this.getAttribute("value") || "#000000";
|
|
2374
2776
|
if (this.#s) {
|
|
2375
2777
|
if (this.#s.setColor(t), this.#e) {
|
|
@@ -2379,7 +2781,7 @@ class at extends d {
|
|
|
2379
2781
|
this.#d();
|
|
2380
2782
|
}
|
|
2381
2783
|
}
|
|
2382
|
-
#
|
|
2784
|
+
#m() {
|
|
2383
2785
|
if (this.#s) {
|
|
2384
2786
|
const t = this.#s.value;
|
|
2385
2787
|
this.getAttribute("value") !== t && this.setAttribute("value", t);
|
|
@@ -2393,7 +2795,7 @@ class at extends d {
|
|
|
2393
2795
|
return this.#s?.value ?? this.getAttribute("value") ?? "#000000";
|
|
2394
2796
|
}
|
|
2395
2797
|
set value(t) {
|
|
2396
|
-
this.#s?.setColor(t) && (this.#e && (this.#e.value = this.#s.value), this.#d(), this.#
|
|
2798
|
+
this.#s?.setColor(t) && (this.#e && (this.#e.value = this.#s.value), this.#d(), this.#m());
|
|
2397
2799
|
}
|
|
2398
2800
|
get disabled() {
|
|
2399
2801
|
return this.hasAttribute("disabled");
|
|
@@ -2411,37 +2813,929 @@ class at extends d {
|
|
|
2411
2813
|
return this.#s?.hsv ?? { h: 0, s: 0, v: 0 };
|
|
2412
2814
|
}
|
|
2413
2815
|
}
|
|
2414
|
-
customElements.define("ry-color-input",
|
|
2415
|
-
|
|
2816
|
+
customElements.define("ry-color-input", ut);
|
|
2817
|
+
function x(h) {
|
|
2818
|
+
const t = h.trim().toLowerCase();
|
|
2819
|
+
if (t.startsWith("#")) {
|
|
2820
|
+
const i = t.slice(1);
|
|
2821
|
+
return i.length === 3 ? {
|
|
2822
|
+
r: parseInt(i[0] + i[0], 16),
|
|
2823
|
+
g: parseInt(i[1] + i[1], 16),
|
|
2824
|
+
b: parseInt(i[2] + i[2], 16)
|
|
2825
|
+
} : i.length >= 6 ? {
|
|
2826
|
+
r: parseInt(i.slice(0, 2), 16),
|
|
2827
|
+
g: parseInt(i.slice(2, 4), 16),
|
|
2828
|
+
b: parseInt(i.slice(4, 6), 16)
|
|
2829
|
+
} : null;
|
|
2830
|
+
}
|
|
2831
|
+
const e = /^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/.exec(t);
|
|
2832
|
+
if (e)
|
|
2833
|
+
return {
|
|
2834
|
+
r: parseInt(e[1], 10),
|
|
2835
|
+
g: parseInt(e[2], 10),
|
|
2836
|
+
b: parseInt(e[3], 10)
|
|
2837
|
+
};
|
|
2838
|
+
const s = /^hsla?\(\s*([\d.]+)\s*,\s*([\d.]+)%\s*,\s*([\d.]+)%/.exec(t);
|
|
2839
|
+
if (s) {
|
|
2840
|
+
const i = parseFloat(s[1]) / 360, r = parseFloat(s[2]) / 100, a = parseFloat(s[3]) / 100, n = (c, d, g) => (g < 0 && (g += 1), g > 1 && (g -= 1), g < 1 / 6 ? c + (d - c) * 6 * g : g < 1 / 2 ? d : g < 2 / 3 ? c + (d - c) * (2 / 3 - g) * 6 : c), o = a < 0.5 ? a * (1 + r) : a + r - a * r, l = 2 * a - o;
|
|
2841
|
+
return {
|
|
2842
|
+
r: Math.round(n(l, o, i + 1 / 3) * 255),
|
|
2843
|
+
g: Math.round(n(l, o, i) * 255),
|
|
2844
|
+
b: Math.round(n(l, o, i - 1 / 3) * 255)
|
|
2845
|
+
};
|
|
2846
|
+
}
|
|
2847
|
+
return null;
|
|
2848
|
+
}
|
|
2849
|
+
function pt(h) {
|
|
2850
|
+
const t = (e) => Math.max(0, Math.min(255, e)).toString(16).padStart(2, "0");
|
|
2851
|
+
return `#${t(h.r)}${t(h.g)}${t(h.b)}`;
|
|
2852
|
+
}
|
|
2853
|
+
function gt(h, t, e) {
|
|
2854
|
+
return {
|
|
2855
|
+
r: Math.round(h.r + (t.r - h.r) * e),
|
|
2856
|
+
g: Math.round(h.g + (t.g - h.g) * e),
|
|
2857
|
+
b: Math.round(h.b + (t.b - h.b) * e)
|
|
2858
|
+
};
|
|
2859
|
+
}
|
|
2860
|
+
const H = "linear-gradient(90deg, #000000 0%, #ffffff 100%)", ft = 50;
|
|
2861
|
+
class yt extends u {
|
|
2862
|
+
#t = "linear";
|
|
2863
|
+
#e = 90;
|
|
2864
|
+
#i = "circle";
|
|
2865
|
+
#s = [];
|
|
2866
|
+
#r = null;
|
|
2867
|
+
#a = 0;
|
|
2868
|
+
#o = null;
|
|
2869
|
+
#l = !1;
|
|
2870
|
+
#c = null;
|
|
2871
|
+
#h = !1;
|
|
2872
|
+
// Cached DOM refs
|
|
2873
|
+
#n = null;
|
|
2874
|
+
#p = null;
|
|
2875
|
+
#u = null;
|
|
2876
|
+
static observedAttributes = ["value", "disabled", "output"];
|
|
2877
|
+
setup() {
|
|
2878
|
+
this.#v(), this.#W(), this.#X(), this.#x();
|
|
2879
|
+
}
|
|
2880
|
+
// ───────────────────────────────────────────────────────────────────────────
|
|
2881
|
+
// Parsing / Serialization
|
|
2882
|
+
// ───────────────────────────────────────────────────────────────────────────
|
|
2883
|
+
#v() {
|
|
2884
|
+
const t = this.getAttribute("value") || H;
|
|
2885
|
+
this.#b(t) || this.#b(H);
|
|
2886
|
+
}
|
|
2887
|
+
#b(t) {
|
|
2888
|
+
const e = t.trim();
|
|
2889
|
+
if (!e.startsWith("linear-gradient(") && !e.startsWith("radial-gradient("))
|
|
2890
|
+
return x(e) ? (this.#t = "solid", this.#s = [this.#d(e, 0), this.#d(e, 100)], this.#r = this.#s[0].id, !0) : !1;
|
|
2891
|
+
let s, i;
|
|
2892
|
+
e.startsWith("linear-gradient(") ? (s = "linear", i = e.slice(16, -1)) : (s = "radial", i = e.slice(16, -1));
|
|
2893
|
+
let r = 90, a = "circle", n = i;
|
|
2894
|
+
if (s === "linear") {
|
|
2895
|
+
const d = /^([\d.]+)deg\s*,\s*/.exec(i);
|
|
2896
|
+
if (d)
|
|
2897
|
+
r = parseFloat(d[1]), n = i.slice(d[0].length);
|
|
2898
|
+
else {
|
|
2899
|
+
const g = /^to\s+\w+(?:\s+\w+)?\s*,\s*/.exec(i);
|
|
2900
|
+
if (g) {
|
|
2901
|
+
const b = g[0].trim().replace(/,\s*$/, "");
|
|
2902
|
+
r = this.#w(b), n = i.slice(g[0].length);
|
|
2903
|
+
}
|
|
2904
|
+
}
|
|
2905
|
+
} else {
|
|
2906
|
+
const d = /^(circle|ellipse)(?:\s+at\s+[^,]+)?\s*,\s*/.exec(i);
|
|
2907
|
+
d && (a = d[1], n = i.slice(d[0].length));
|
|
2908
|
+
}
|
|
2909
|
+
const o = [], l = /(#[a-fA-F0-9]{3,8}|rgba?\([^)]+\)|hsla?\([^)]+\)|[a-z]+)\s+([\d.]+)%/g;
|
|
2910
|
+
let c;
|
|
2911
|
+
for (; (c = l.exec(n)) !== null; )
|
|
2912
|
+
o.push(this.#d(c[1], parseFloat(c[2])));
|
|
2913
|
+
return o.length < 2 ? !1 : (this.#t = s, this.#e = r, this.#i = a, this.#s = o, this.#r = o[0].id, !0);
|
|
2914
|
+
}
|
|
2915
|
+
#w(t) {
|
|
2916
|
+
return {
|
|
2917
|
+
"to top": 0,
|
|
2918
|
+
"to top right": 45,
|
|
2919
|
+
"to right": 90,
|
|
2920
|
+
"to bottom right": 135,
|
|
2921
|
+
"to bottom": 180,
|
|
2922
|
+
"to bottom left": 225,
|
|
2923
|
+
"to left": 270,
|
|
2924
|
+
"to top left": 315
|
|
2925
|
+
}[t] ?? 90;
|
|
2926
|
+
}
|
|
2927
|
+
#g() {
|
|
2928
|
+
if (this.#t === "solid")
|
|
2929
|
+
return this.#s[0]?.color ?? "#000000";
|
|
2930
|
+
const t = this.#s.map((e) => `${e.color} ${Math.round(e.position)}%`).join(", ");
|
|
2931
|
+
return this.#t === "linear" ? `linear-gradient(${Math.round(this.#e)}deg, ${t})` : `radial-gradient(${this.#i}, ${t})`;
|
|
2932
|
+
}
|
|
2933
|
+
// ───────────────────────────────────────────────────────────────────────────
|
|
2934
|
+
// Stop management
|
|
2935
|
+
// ───────────────────────────────────────────────────────────────────────────
|
|
2936
|
+
#d(t, e) {
|
|
2937
|
+
return { id: `stop-${this.#a++}`, color: t, position: e };
|
|
2938
|
+
}
|
|
2939
|
+
/** CSS left value clamped so the stop handle stays within the bar */
|
|
2940
|
+
#y(t) {
|
|
2941
|
+
const e = "calc(var(--ry-gradient-picker-stop-size, 16px) / 2)";
|
|
2942
|
+
return `clamp(${e}, ${t}%, calc(100% - ${e}))`;
|
|
2943
|
+
}
|
|
2944
|
+
#m(t, e) {
|
|
2945
|
+
const s = this.#d(t, e);
|
|
2946
|
+
this.#s.push(s), this.#$(), this.#r = s.id, this.#E(), this.#x();
|
|
2947
|
+
}
|
|
2948
|
+
#f(t) {
|
|
2949
|
+
if (this.#s.length <= 2) return !1;
|
|
2950
|
+
const e = this.#s.findIndex((s) => s.id === t);
|
|
2951
|
+
return e === -1 ? !1 : (this.#s.splice(e, 1), this.#r === t && (this.#r = this.#s[Math.min(e, this.#s.length - 1)]?.id ?? null), this.#E(), this.#x(), !0);
|
|
2952
|
+
}
|
|
2953
|
+
#M(t) {
|
|
2954
|
+
this.#r !== t && (this.#r = t, this.#O(), this.#L());
|
|
2955
|
+
}
|
|
2956
|
+
#$() {
|
|
2957
|
+
this.#s.sort((t, e) => t.position - e.position);
|
|
2958
|
+
}
|
|
2959
|
+
#H() {
|
|
2960
|
+
return this.#s.find((t) => t.id === this.#r) ?? null;
|
|
2961
|
+
}
|
|
2962
|
+
// ───────────────────────────────────────────────────────────────────────────
|
|
2963
|
+
// Markup
|
|
2964
|
+
// ───────────────────────────────────────────────────────────────────────────
|
|
2965
|
+
#W() {
|
|
2966
|
+
const t = this.hasAttribute("output"), e = p("copy"), s = p("gradient-solid"), i = p("gradient-linear"), r = p("gradient-radial"), a = p("shape-circle"), n = p("shape-ellipse");
|
|
2967
|
+
let o = "";
|
|
2968
|
+
t && (o = `
|
|
2969
|
+
<div data-ry-target="output-row" class="ry-gradient-picker__output-row">
|
|
2970
|
+
<input data-ry-target="output" type="text" class="ry-gradient-picker__output" spellcheck="false" />
|
|
2971
|
+
<button data-ry-target="copy-btn" type="button" class="ry-gradient-picker__copy-btn">${e}</button>
|
|
2972
|
+
</div>`), this.innerHTML = `
|
|
2973
|
+
<div data-ry-target="controls" class="ry-gradient-picker__controls">
|
|
2974
|
+
<div data-ry-target="type-toggle" class="ry-gradient-picker__type-toggle">
|
|
2975
|
+
<button data-ry-target="type-solid" type="button" class="ry-gradient-picker__type-btn">${s}</button>
|
|
2976
|
+
<button data-ry-target="type-linear" type="button" class="ry-gradient-picker__type-btn">${i}</button>
|
|
2977
|
+
<button data-ry-target="type-radial" type="button" class="ry-gradient-picker__type-btn">${r}</button>
|
|
2978
|
+
</div>
|
|
2979
|
+
<div data-ry-target="angle-control" class="ry-gradient-picker__angle-control">
|
|
2980
|
+
<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>
|
|
2981
|
+
</div>
|
|
2982
|
+
<div data-ry-target="shape-control" class="ry-gradient-picker__shape-control">
|
|
2983
|
+
<button data-ry-target="shape-circle" type="button" class="ry-gradient-picker__shape-btn">${a}</button>
|
|
2984
|
+
<button data-ry-target="shape-ellipse" type="button" class="ry-gradient-picker__shape-btn">${n}</button>
|
|
2985
|
+
</div>
|
|
2986
|
+
</div>
|
|
2987
|
+
<div data-ry-target="bar-container" class="ry-gradient-picker__bar-container">
|
|
2988
|
+
<div data-ry-target="bar" class="ry-gradient-picker__bar"></div>
|
|
2989
|
+
</div>
|
|
2990
|
+
<ry-color-picker data-ry-target="picker" inline opacity></ry-color-picker>
|
|
2991
|
+
${o}
|
|
2992
|
+
`, this.#n = this.$('[data-ry-target="bar"]'), this.#p = this.$('[data-ry-target="picker"]'), this.#u = this.$('[data-ry-target="output"]'), this.#E();
|
|
2993
|
+
}
|
|
2994
|
+
#E() {
|
|
2995
|
+
if (this.#n) {
|
|
2996
|
+
this.#n.querySelectorAll('[data-ry-target="stop"]').forEach((t) => t.remove());
|
|
2997
|
+
for (const t of this.#s) {
|
|
2998
|
+
const e = document.createElement("div");
|
|
2999
|
+
e.setAttribute("data-ry-target", "stop"), e.setAttribute("data-stop-id", t.id), e.classList.add("ry-gradient-picker__stop"), e.tabIndex = 0, e.style.left = this.#y(t.position), e.style.setProperty("--stop-color", t.color), t.id === this.#r && e.setAttribute("data-selected", ""), this.#n.appendChild(e);
|
|
3000
|
+
}
|
|
3001
|
+
}
|
|
3002
|
+
}
|
|
3003
|
+
// ───────────────────────────────────────────────────────────────────────────
|
|
3004
|
+
// Event binding
|
|
3005
|
+
// ───────────────────────────────────────────────────────────────────────────
|
|
3006
|
+
#X() {
|
|
3007
|
+
this.#n && (this.on(this.#n, "pointerdown", this.#G), this.on(this.#n, "pointermove", this.#K), this.on(this.#n, "pointerup", this.#q), this.on(this.#n, "lostpointercapture", this.#q));
|
|
3008
|
+
const t = this.$('[data-ry-target="type-solid"]'), e = this.$('[data-ry-target="type-linear"]'), s = this.$('[data-ry-target="type-radial"]');
|
|
3009
|
+
t && this.on(t, "click", () => this.#C("solid")), e && this.on(e, "click", () => this.#C("linear")), s && this.on(s, "click", () => this.#C("radial"));
|
|
3010
|
+
const i = this.$('[data-ry-target="angle-select"]');
|
|
3011
|
+
i && this.on(i, "ry:input", this.#V);
|
|
3012
|
+
const r = this.$('[data-ry-target="shape-circle"]'), a = this.$('[data-ry-target="shape-ellipse"]');
|
|
3013
|
+
r && this.on(r, "click", () => this.#P("circle")), a && this.on(a, "click", () => this.#P("ellipse")), this.#p && (this.on(this.#p, "ry:input", this.#R), this.on(this.#p, "ry:change", this.#T)), this.#u && (this.on(this.#u, "keydown", this.#F), this.on(this.#u, "blur", this.#j));
|
|
3014
|
+
const n = this.$('[data-ry-target="copy-btn"]');
|
|
3015
|
+
n && this.on(n, "click", this.#z), this.#n && this.on(this.#n, "keydown", this.#J);
|
|
3016
|
+
}
|
|
3017
|
+
// ───────────────────────────────────────────────────────────────────────────
|
|
3018
|
+
// Bar / Stop interaction handlers
|
|
3019
|
+
// ───────────────────────────────────────────────────────────────────────────
|
|
3020
|
+
#G = (t) => {
|
|
3021
|
+
if (this.disabled) return;
|
|
3022
|
+
const s = t.target.closest('[data-ry-target="stop"]');
|
|
3023
|
+
if (s) {
|
|
3024
|
+
const i = s.getAttribute("data-stop-id");
|
|
3025
|
+
if (!i) return;
|
|
3026
|
+
t.preventDefault(), this.#o = i, this.#l = !1, this.#c = this.#n.getBoundingClientRect(), this.#M(i), this.#n.setPointerCapture(t.pointerId), s.focus();
|
|
3027
|
+
} else {
|
|
3028
|
+
if (t.preventDefault(), !this.#n) return;
|
|
3029
|
+
const i = this.#n.getBoundingClientRect(), r = Math.round(Math.max(0, Math.min(100, (t.clientX - i.left) / i.width * 100))), a = this.#U(r);
|
|
3030
|
+
this.#m(a, r), this.#n.querySelector(`[data-stop-id="${this.#r}"]`)?.focus(), this.#o = this.#r, this.#l = !1, this.#c = i, this.#n.setPointerCapture(t.pointerId), this.#I();
|
|
3031
|
+
}
|
|
3032
|
+
};
|
|
3033
|
+
#K = (t) => {
|
|
3034
|
+
if (!this.#o || !this.#c) return;
|
|
3035
|
+
const e = this.#s.find((n) => n.id === this.#o);
|
|
3036
|
+
if (!e) return;
|
|
3037
|
+
const s = Math.max(0, Math.min(1, (t.clientX - this.#c.left) / this.#c.width));
|
|
3038
|
+
e.position = Math.round(s * 100);
|
|
3039
|
+
const i = this.#c.top + this.#c.height / 2, r = Math.abs(t.clientY - i);
|
|
3040
|
+
this.#l = r > ft && this.#s.length > 2;
|
|
3041
|
+
const a = this.#n?.querySelector(`[data-stop-id="${e.id}"]`);
|
|
3042
|
+
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.#$(), this.#N(), this.#D(), this.#k(), this.#I();
|
|
3043
|
+
};
|
|
3044
|
+
#q = () => {
|
|
3045
|
+
this.#o && (this.#l && this.#f(this.#o), this.#o = null, this.#l = !1, this.#c = null, this.#S(), this.#B());
|
|
3046
|
+
};
|
|
3047
|
+
#J = (t) => {
|
|
3048
|
+
if (this.disabled) return;
|
|
3049
|
+
const s = t.target.closest('[data-ry-target="stop"]');
|
|
3050
|
+
if (!s) return;
|
|
3051
|
+
const i = s.getAttribute("data-stop-id");
|
|
3052
|
+
if (!i) return;
|
|
3053
|
+
const r = this.#s.find((o) => o.id === i);
|
|
3054
|
+
if (!r) return;
|
|
3055
|
+
const a = t.shiftKey ? 10 : 1;
|
|
3056
|
+
let n = !1;
|
|
3057
|
+
switch (t.key) {
|
|
3058
|
+
case "ArrowRight":
|
|
3059
|
+
r.position = Math.min(100, r.position + a), n = !0;
|
|
3060
|
+
break;
|
|
3061
|
+
case "ArrowLeft":
|
|
3062
|
+
r.position = Math.max(0, r.position - a), n = !0;
|
|
3063
|
+
break;
|
|
3064
|
+
case "Delete":
|
|
3065
|
+
case "Backspace":
|
|
3066
|
+
this.#f(i) && (this.#I(), this.#B()), t.preventDefault();
|
|
3067
|
+
return;
|
|
3068
|
+
}
|
|
3069
|
+
n && (t.preventDefault(), this.#$(), this.#Y(), this.#N(), this.#D(), this.#k(), this.#S(), this.#I(), this.#B());
|
|
3070
|
+
};
|
|
3071
|
+
// ───────────────────────────────────────────────────────────────────────────
|
|
3072
|
+
// Type / Angle / Shape handlers
|
|
3073
|
+
// ───────────────────────────────────────────────────────────────────────────
|
|
3074
|
+
#C(t) {
|
|
3075
|
+
this.#t !== t && (this.#t = t, this.setAttribute("data-ry-type", t), this.#_(), this.#D(), this.#k(), this.#S(), this.#I(), this.#B());
|
|
3076
|
+
}
|
|
3077
|
+
#V = (t) => {
|
|
3078
|
+
const e = t.detail;
|
|
3079
|
+
this.#e = e.value, this.#D(), this.#k(), this.#S(), this.#I();
|
|
3080
|
+
};
|
|
3081
|
+
#P(t) {
|
|
3082
|
+
this.#i !== t && (this.#i = t, this.#_(), this.#k(), this.#S(), this.#I(), this.#B());
|
|
3083
|
+
}
|
|
3084
|
+
// ───────────────────────────────────────────────────────────────────────────
|
|
3085
|
+
// Color picker handlers
|
|
3086
|
+
// ───────────────────────────────────────────────────────────────────────────
|
|
3087
|
+
#R = () => {
|
|
3088
|
+
const t = this.#H();
|
|
3089
|
+
!t || !this.#p || (t.color = this.#p.value, this.#Z(t), this.#N(), this.#D(), this.#k(), this.#I());
|
|
3090
|
+
};
|
|
3091
|
+
#T = () => {
|
|
3092
|
+
this.#S(), this.#B();
|
|
3093
|
+
};
|
|
3094
|
+
// ───────────────────────────────────────────────────────────────────────────
|
|
3095
|
+
// Copy handler
|
|
3096
|
+
// ───────────────────────────────────────────────────────────────────────────
|
|
3097
|
+
#z = () => {
|
|
3098
|
+
const t = this.#g();
|
|
3099
|
+
navigator.clipboard.writeText(t).then(() => {
|
|
3100
|
+
const e = this.$('[data-ry-target="copy-btn"]');
|
|
3101
|
+
e && (e.setAttribute("data-copied", ""), setTimeout(() => e.removeAttribute("data-copied"), 1500));
|
|
3102
|
+
});
|
|
3103
|
+
};
|
|
3104
|
+
// ───────────────────────────────────────────────────────────────────────────
|
|
3105
|
+
// Output (editable CSS) handlers
|
|
3106
|
+
// ───────────────────────────────────────────────────────────────────────────
|
|
3107
|
+
#F = (t) => {
|
|
3108
|
+
t.key === "Enter" && (t.preventDefault(), this.#A());
|
|
3109
|
+
};
|
|
3110
|
+
#j = () => {
|
|
3111
|
+
this.#A();
|
|
3112
|
+
};
|
|
3113
|
+
#A() {
|
|
3114
|
+
if (!this.#u) return;
|
|
3115
|
+
const t = this.#u.value.trim();
|
|
3116
|
+
t && this.#b(t) ? (this.#E(), this.#x(), this.#S(), this.#I(), this.#B()) : this.#k();
|
|
3117
|
+
}
|
|
3118
|
+
// ───────────────────────────────────────────────────────────────────────────
|
|
3119
|
+
// Color interpolation
|
|
3120
|
+
// ───────────────────────────────────────────────────────────────────────────
|
|
3121
|
+
#U(t) {
|
|
3122
|
+
if (this.#s.length === 0) return "#808080";
|
|
3123
|
+
if (this.#s.length === 1) return this.#s[0].color;
|
|
3124
|
+
const e = [...this.#s].sort((l, c) => l.position - c.position);
|
|
3125
|
+
if (t <= e[0].position) return e[0].color;
|
|
3126
|
+
if (t >= e[e.length - 1].position) return e[e.length - 1].color;
|
|
3127
|
+
let s = e[0], i = e[1];
|
|
3128
|
+
for (let l = 0; l < e.length - 1; l++)
|
|
3129
|
+
if (e[l].position <= t && e[l + 1].position >= t) {
|
|
3130
|
+
s = e[l], i = e[l + 1];
|
|
3131
|
+
break;
|
|
3132
|
+
}
|
|
3133
|
+
const r = i.position - s.position;
|
|
3134
|
+
if (r === 0) return s.color;
|
|
3135
|
+
const a = (t - s.position) / r, n = x(s.color), o = x(i.color);
|
|
3136
|
+
return !n || !o ? s.color : pt(gt(n, o, a));
|
|
3137
|
+
}
|
|
3138
|
+
// ───────────────────────────────────────────────────────────────────────────
|
|
3139
|
+
// Update methods
|
|
3140
|
+
// ───────────────────────────────────────────────────────────────────────────
|
|
3141
|
+
#x() {
|
|
3142
|
+
this.setAttribute("data-ry-type", this.#t), this.#_(), this.#N(), this.#D(), this.#Y(), this.#O(), this.#L(), this.#k();
|
|
3143
|
+
}
|
|
3144
|
+
#_() {
|
|
3145
|
+
const t = this.$('[data-ry-target="type-solid"]'), e = this.$('[data-ry-target="type-linear"]'), s = this.$('[data-ry-target="type-radial"]');
|
|
3146
|
+
t && t.toggleAttribute("data-active", this.#t === "solid"), e && e.toggleAttribute("data-active", this.#t === "linear"), s && s.toggleAttribute("data-active", this.#t === "radial");
|
|
3147
|
+
const i = this.$('[data-ry-target="shape-circle"]'), r = this.$('[data-ry-target="shape-ellipse"]');
|
|
3148
|
+
i && i.toggleAttribute("data-active", this.#i === "circle"), r && r.toggleAttribute("data-active", this.#i === "ellipse");
|
|
3149
|
+
const a = this.$('[data-ry-target="angle-select"]');
|
|
3150
|
+
a && a.setAttribute("value", String(this.#e));
|
|
3151
|
+
}
|
|
3152
|
+
#D() {
|
|
3153
|
+
if (!this.#p) return;
|
|
3154
|
+
const t = this.#p.querySelector('[data-ry-target="preview-color"]');
|
|
3155
|
+
t && (t.style.backgroundImage = this.#t === "solid" ? "" : this.#g());
|
|
3156
|
+
}
|
|
3157
|
+
#N() {
|
|
3158
|
+
if (!this.#n) return;
|
|
3159
|
+
const t = this.#s.map((e) => `${e.color} ${e.position}%`).join(", ");
|
|
3160
|
+
this.#n.style.backgroundImage = `linear-gradient(to right, ${t})`;
|
|
3161
|
+
}
|
|
3162
|
+
#Y() {
|
|
3163
|
+
if (this.#n)
|
|
3164
|
+
for (const t of this.#s) {
|
|
3165
|
+
const e = this.#n.querySelector(`[data-stop-id="${t.id}"]`);
|
|
3166
|
+
e && (e.style.left = this.#y(t.position));
|
|
3167
|
+
}
|
|
3168
|
+
}
|
|
3169
|
+
#Z(t) {
|
|
3170
|
+
if (!this.#n) return;
|
|
3171
|
+
const e = this.#n.querySelector(`[data-stop-id="${t.id}"]`);
|
|
3172
|
+
e && e.style.setProperty("--stop-color", t.color);
|
|
3173
|
+
}
|
|
3174
|
+
#O() {
|
|
3175
|
+
if (!this.#n) return;
|
|
3176
|
+
const t = this.#n.querySelectorAll('[data-ry-target="stop"]');
|
|
3177
|
+
for (const e of t)
|
|
3178
|
+
e.getAttribute("data-stop-id") === this.#r ? e.setAttribute("data-selected", "") : e.removeAttribute("data-selected");
|
|
3179
|
+
}
|
|
3180
|
+
#L() {
|
|
3181
|
+
const t = this.#H();
|
|
3182
|
+
!t || !this.#p || this.#p.setColor(t.color);
|
|
3183
|
+
}
|
|
3184
|
+
#k() {
|
|
3185
|
+
this.#u && document.activeElement !== this.#u && (this.#u.value = this.#g());
|
|
3186
|
+
}
|
|
3187
|
+
#S() {
|
|
3188
|
+
const t = this.#g();
|
|
3189
|
+
this.getAttribute("value") !== t && (this.#h = !0, this.setAttribute("value", t), this.#h = !1);
|
|
3190
|
+
}
|
|
3191
|
+
// ───────────────────────────────────────────────────────────────────────────
|
|
3192
|
+
// Events
|
|
3193
|
+
// ───────────────────────────────────────────────────────────────────────────
|
|
3194
|
+
#I() {
|
|
3195
|
+
this.emit("input", {
|
|
3196
|
+
value: this.#g(),
|
|
3197
|
+
type: this.#t,
|
|
3198
|
+
angle: this.#e,
|
|
3199
|
+
shape: this.#i,
|
|
3200
|
+
stops: this.stops
|
|
3201
|
+
});
|
|
3202
|
+
}
|
|
3203
|
+
#B() {
|
|
3204
|
+
this.emit("change", {
|
|
3205
|
+
value: this.#g(),
|
|
3206
|
+
type: this.#t,
|
|
3207
|
+
angle: this.#e,
|
|
3208
|
+
shape: this.#i,
|
|
3209
|
+
stops: this.stops
|
|
3210
|
+
});
|
|
3211
|
+
}
|
|
3212
|
+
// ───────────────────────────────────────────────────────────────────────────
|
|
3213
|
+
// Attribute changed
|
|
3214
|
+
// ───────────────────────────────────────────────────────────────────────────
|
|
3215
|
+
attributeChangedCallback(t, e, s) {
|
|
3216
|
+
e === s || this.#h || t === "value" && this.#n && s && this.#b(s) && (this.#E(), this.#x());
|
|
3217
|
+
}
|
|
3218
|
+
// ───────────────────────────────────────────────────────────────────────────
|
|
3219
|
+
// Public API
|
|
3220
|
+
// ───────────────────────────────────────────────────────────────────────────
|
|
3221
|
+
get value() {
|
|
3222
|
+
return this.#g();
|
|
3223
|
+
}
|
|
3224
|
+
set value(t) {
|
|
3225
|
+
this.#b(t) && (this.#E(), this.#x(), this.#S());
|
|
3226
|
+
}
|
|
3227
|
+
get type() {
|
|
3228
|
+
return this.#t;
|
|
3229
|
+
}
|
|
3230
|
+
set type(t) {
|
|
3231
|
+
this.#C(t);
|
|
3232
|
+
}
|
|
3233
|
+
get angle() {
|
|
3234
|
+
return this.#e;
|
|
3235
|
+
}
|
|
3236
|
+
set angle(t) {
|
|
3237
|
+
this.#e = (t % 360 + 360) % 360, this.#_(), this.#k(), this.#S();
|
|
3238
|
+
}
|
|
3239
|
+
get shape() {
|
|
3240
|
+
return this.#i;
|
|
3241
|
+
}
|
|
3242
|
+
set shape(t) {
|
|
3243
|
+
this.#P(t);
|
|
3244
|
+
}
|
|
3245
|
+
get stops() {
|
|
3246
|
+
return this.#s.map((t) => ({ ...t }));
|
|
3247
|
+
}
|
|
3248
|
+
get selectedStop() {
|
|
3249
|
+
const t = this.#H();
|
|
3250
|
+
return t ? { ...t } : null;
|
|
3251
|
+
}
|
|
3252
|
+
get disabled() {
|
|
3253
|
+
return this.hasAttribute("disabled");
|
|
3254
|
+
}
|
|
3255
|
+
set disabled(t) {
|
|
3256
|
+
t ? this.setAttribute("disabled", "") : this.removeAttribute("disabled");
|
|
3257
|
+
}
|
|
3258
|
+
addStop(t, e) {
|
|
3259
|
+
this.#m(t, e), this.#S(), this.#I(), this.#B();
|
|
3260
|
+
}
|
|
3261
|
+
removeStop(t) {
|
|
3262
|
+
const e = this.#f(t);
|
|
3263
|
+
return e && (this.#k(), this.#S(), this.#B()), e;
|
|
3264
|
+
}
|
|
3265
|
+
}
|
|
3266
|
+
customElements.define("ry-gradient-picker", yt);
|
|
3267
|
+
let bt = 0;
|
|
3268
|
+
const mt = 5;
|
|
3269
|
+
function _(h) {
|
|
3270
|
+
return p(h).replace(/width="24"/g, 'width="16"').replace(/height="24"/g, 'height="16"').replace(/viewBox/, 'class="ry-tree__icon" viewBox');
|
|
3271
|
+
}
|
|
3272
|
+
class k extends u {
|
|
3273
|
+
// Drag state
|
|
3274
|
+
#t = !1;
|
|
3275
|
+
#e = !1;
|
|
3276
|
+
#i = 0;
|
|
3277
|
+
#s = 0;
|
|
3278
|
+
#r = null;
|
|
3279
|
+
#a = null;
|
|
3280
|
+
#o = null;
|
|
3281
|
+
#l = null;
|
|
3282
|
+
setup() {
|
|
3283
|
+
this.#c(), this.on(this, "click", (t) => {
|
|
3284
|
+
const s = t.target.closest('[data-ry-target="file"]');
|
|
3285
|
+
s && (this.$$("[data-ry-selected]").forEach((i) => i.removeAttribute("data-ry-selected")), s.setAttribute("data-ry-selected", ""), this.emit("select", {
|
|
3286
|
+
label: s.dataset.ryLabel ?? ""
|
|
3287
|
+
}));
|
|
3288
|
+
}), this.on(this, "change", (t) => {
|
|
3289
|
+
const e = t.target;
|
|
3290
|
+
if (!e.classList.contains("ry-tree__toggle")) return;
|
|
3291
|
+
const i = e.closest(".ry-tree__item")?.querySelector('[data-ry-target="folder"]')?.dataset.ryLabel ?? "";
|
|
3292
|
+
this.emit("toggle", {
|
|
3293
|
+
label: i,
|
|
3294
|
+
open: e.checked
|
|
3295
|
+
});
|
|
3296
|
+
}), this.hasAttribute("sortable") && this.#v();
|
|
3297
|
+
}
|
|
3298
|
+
// ── Build ──────────────────────────────────────────────────
|
|
3299
|
+
#c() {
|
|
3300
|
+
if (this.$(".ry-tree__root")) return;
|
|
3301
|
+
const t = Array.from(this.children), e = document.createElement("ul");
|
|
3302
|
+
e.className = "ry-tree__root";
|
|
3303
|
+
for (const s of t)
|
|
3304
|
+
e.appendChild(this.#h(s));
|
|
3305
|
+
this.innerHTML = "", this.appendChild(e);
|
|
3306
|
+
}
|
|
3307
|
+
#h(t) {
|
|
3308
|
+
const e = document.createElement("li");
|
|
3309
|
+
e.className = "ry-tree__item";
|
|
3310
|
+
const s = t.getAttribute("label") ?? "", i = t.hasAttribute("open"), r = t.hasAttribute("selected"), a = Array.from(t.children).filter(
|
|
3311
|
+
(o) => o.tagName === "RY-TREE-ITEM"
|
|
3312
|
+
);
|
|
3313
|
+
if (a.length > 0) {
|
|
3314
|
+
const o = `ry-tree-${++bt}`, l = document.createElement("input");
|
|
3315
|
+
l.type = "checkbox", l.id = o, l.className = "ry-tree__toggle", i && (l.checked = !0);
|
|
3316
|
+
const c = document.createElement("label");
|
|
3317
|
+
c.htmlFor = o, c.className = "ry-tree__label", c.setAttribute("data-ry-target", "folder"), c.dataset.ryLabel = s, c.innerHTML = `
|
|
3318
|
+
<span class="ry-tree__icon-closed">${_("folder")}</span>
|
|
3319
|
+
<span class="ry-tree__icon-open">${_("folder-open")}</span>
|
|
3320
|
+
${s}
|
|
3321
|
+
`;
|
|
3322
|
+
const d = document.createElement("div");
|
|
3323
|
+
d.className = "ry-tree__children-wrapper";
|
|
3324
|
+
const g = document.createElement("ul");
|
|
3325
|
+
g.className = "ry-tree__children";
|
|
3326
|
+
for (const b of a)
|
|
3327
|
+
g.appendChild(this.#h(b));
|
|
3328
|
+
d.appendChild(g), e.appendChild(l), e.appendChild(c), e.appendChild(d);
|
|
3329
|
+
} else {
|
|
3330
|
+
const o = document.createElement("div");
|
|
3331
|
+
o.className = "ry-tree__file", o.setAttribute("data-ry-target", "file"), o.dataset.ryLabel = s, r && o.setAttribute("data-ry-selected", ""), o.innerHTML = `${_("file")} ${s}`, e.appendChild(o);
|
|
3332
|
+
}
|
|
3333
|
+
return e;
|
|
3334
|
+
}
|
|
3335
|
+
// ── Serialization ──────────────────────────────────────────
|
|
3336
|
+
/** Serialize the current tree state to JSON. */
|
|
3337
|
+
toJSON() {
|
|
3338
|
+
const t = this.$(".ry-tree__root");
|
|
3339
|
+
return t ? this.#n(t) : [];
|
|
3340
|
+
}
|
|
3341
|
+
/** Alias for toJSON(). */
|
|
3342
|
+
get value() {
|
|
3343
|
+
return this.toJSON();
|
|
3344
|
+
}
|
|
3345
|
+
#n(t) {
|
|
3346
|
+
return Array.from(t.children).filter(
|
|
3347
|
+
(s) => s instanceof HTMLElement && s.classList.contains("ry-tree__item")
|
|
3348
|
+
).map((s) => this.#p(s));
|
|
3349
|
+
}
|
|
3350
|
+
#p(t) {
|
|
3351
|
+
const e = t.querySelector(':scope > [data-ry-target="folder"]'), s = t.querySelector(':scope > [data-ry-target="file"]');
|
|
3352
|
+
if (e) {
|
|
3353
|
+
const r = t.querySelector(":scope > .ry-tree__toggle"), a = t.querySelector(".ry-tree__children"), n = { label: e.dataset.ryLabel ?? "" };
|
|
3354
|
+
if (r?.checked && (n.open = !0), a) {
|
|
3355
|
+
const o = this.#n(a);
|
|
3356
|
+
o.length > 0 && (n.children = o);
|
|
3357
|
+
}
|
|
3358
|
+
return n;
|
|
3359
|
+
}
|
|
3360
|
+
const i = { label: s?.dataset.ryLabel ?? "" };
|
|
3361
|
+
return s?.hasAttribute("data-ry-selected") && (i.selected = !0), i;
|
|
3362
|
+
}
|
|
3363
|
+
/** Create a tree element from JSON data. */
|
|
3364
|
+
static from(t) {
|
|
3365
|
+
const e = document.createElement("ry-tree");
|
|
3366
|
+
for (const s of t)
|
|
3367
|
+
e.appendChild(k.#u(s));
|
|
3368
|
+
return e;
|
|
3369
|
+
}
|
|
3370
|
+
static #u(t) {
|
|
3371
|
+
const e = document.createElement("ry-tree-item");
|
|
3372
|
+
if (e.setAttribute("label", t.label), t.open && e.setAttribute("open", ""), t.selected && e.setAttribute("selected", ""), t.children)
|
|
3373
|
+
for (const s of t.children)
|
|
3374
|
+
e.appendChild(k.#u(s));
|
|
3375
|
+
return e;
|
|
3376
|
+
}
|
|
3377
|
+
// ── Drag and Drop ──────────────────────────────────────────
|
|
3378
|
+
#v() {
|
|
3379
|
+
this.on(this, "pointerdown", this.#b), this.on(document, "pointermove", this.#w), this.on(document, "pointerup", this.#g);
|
|
3380
|
+
}
|
|
3381
|
+
#b = (t) => {
|
|
3382
|
+
const s = t.target.closest(".ry-tree__label, .ry-tree__file");
|
|
3383
|
+
if (!s) return;
|
|
3384
|
+
const i = s.closest(".ry-tree__item");
|
|
3385
|
+
i && (this.#t = !0, this.#i = t.clientX, this.#s = t.clientY, this.#r = i);
|
|
3386
|
+
};
|
|
3387
|
+
#w = (t) => {
|
|
3388
|
+
if (!this.#t && !this.#e) return;
|
|
3389
|
+
if (this.#t && !this.#e) {
|
|
3390
|
+
const c = t.clientX - this.#i, d = t.clientY - this.#s;
|
|
3391
|
+
if (Math.hypot(c, d) < mt) return;
|
|
3392
|
+
this.#t = !1, this.#e = !0, this.#d(t);
|
|
3393
|
+
}
|
|
3394
|
+
if (!this.#e || !this.#a) return;
|
|
3395
|
+
this.#a.style.left = `${t.clientX + 12}px`, this.#a.style.top = `${t.clientY - 14}px`, this.#a.style.display = "none";
|
|
3396
|
+
const e = document.elementFromPoint(t.clientX, t.clientY);
|
|
3397
|
+
if (this.#a.style.display = "", !e) {
|
|
3398
|
+
this.#f();
|
|
3399
|
+
return;
|
|
3400
|
+
}
|
|
3401
|
+
const s = e.closest(".ry-tree__label, .ry-tree__file");
|
|
3402
|
+
if (!s) {
|
|
3403
|
+
this.#f();
|
|
3404
|
+
return;
|
|
3405
|
+
}
|
|
3406
|
+
const i = s.closest(".ry-tree__item");
|
|
3407
|
+
if (!i || i === this.#r) {
|
|
3408
|
+
this.#f();
|
|
3409
|
+
return;
|
|
3410
|
+
}
|
|
3411
|
+
if (this.#r?.contains(i)) {
|
|
3412
|
+
this.#f();
|
|
3413
|
+
return;
|
|
3414
|
+
}
|
|
3415
|
+
const r = s.getBoundingClientRect(), a = t.clientY - r.top, n = r.height, o = i.querySelector(":scope > .ry-tree__toggle") !== null;
|
|
3416
|
+
let l;
|
|
3417
|
+
o && a > n * 0.25 && a < n * 0.75 ? l = "inside" : a < n * 0.5 ? l = "before" : l = "after", this.#m(i, l);
|
|
3418
|
+
};
|
|
3419
|
+
#g = () => {
|
|
3420
|
+
this.#e && this.#y(), this.#t = !1, this.#e = !1, this.#r = null;
|
|
3421
|
+
};
|
|
3422
|
+
#d(t) {
|
|
3423
|
+
if (!this.#r) return;
|
|
3424
|
+
t.preventDefault(), this.#r.setAttribute("data-ry-dragging", ""), this.#r.classList.add("ry-tree__item--collapsed");
|
|
3425
|
+
const e = this.#r.querySelector(".ry-tree__label, .ry-tree__file");
|
|
3426
|
+
if (!e) return;
|
|
3427
|
+
const s = e.cloneNode(!0);
|
|
3428
|
+
s.className = "ry-tree__ghost", s.style.display = "flex", s.style.alignItems = "center", s.style.gap = "var(--ry-space-2, 0.5rem)", s.style.padding = "var(--ry-space-1, 0.25rem) var(--ry-space-2, 0.5rem)", s.style.height = "28px", s.style.fontSize = "var(--ry-text-sm, 0.875rem)", s.style.whiteSpace = "nowrap", s.style.left = `${t.clientX + 12}px`, s.style.top = `${t.clientY - 14}px`, document.body.appendChild(s), this.#a = s;
|
|
3429
|
+
}
|
|
3430
|
+
#y() {
|
|
3431
|
+
this.#a?.parentNode && this.#a.parentNode.removeChild(this.#a), this.#a = null, this.#r?.classList.remove("ry-tree__item--collapsed"), this.#r?.removeAttribute("data-ry-dragging");
|
|
3432
|
+
const t = this.#o, e = this.#l;
|
|
3433
|
+
this.#f(), this.#r && t && e && this.#M(this.#r, t, e);
|
|
3434
|
+
}
|
|
3435
|
+
#m(t, e) {
|
|
3436
|
+
this.#o === t && this.#l === e || (this.#f(), t.setAttribute("data-ry-drop-target", e), this.#o = t, this.#l = e);
|
|
3437
|
+
}
|
|
3438
|
+
#f() {
|
|
3439
|
+
this.#o?.removeAttribute("data-ry-drop-target"), this.#o = null, this.#l = null;
|
|
3440
|
+
}
|
|
3441
|
+
#M(t, e, s) {
|
|
3442
|
+
if (s === "inside" && e.contains(t)) return;
|
|
3443
|
+
const i = this.#$(t), r = this.#$(e);
|
|
3444
|
+
if (s === "before")
|
|
3445
|
+
e.parentNode?.insertBefore(t, e);
|
|
3446
|
+
else if (s === "after")
|
|
3447
|
+
e.parentNode?.insertBefore(t, e.nextSibling);
|
|
3448
|
+
else {
|
|
3449
|
+
const a = e.querySelector(".ry-tree__children");
|
|
3450
|
+
if (a) {
|
|
3451
|
+
a.appendChild(t);
|
|
3452
|
+
const n = e.querySelector(":scope > .ry-tree__toggle");
|
|
3453
|
+
n && !n.checked && (n.checked = !0);
|
|
3454
|
+
}
|
|
3455
|
+
}
|
|
3456
|
+
this.emit("move", {
|
|
3457
|
+
item: i,
|
|
3458
|
+
target: r,
|
|
3459
|
+
position: s
|
|
3460
|
+
});
|
|
3461
|
+
}
|
|
3462
|
+
#$(t) {
|
|
3463
|
+
const e = t.querySelector(':scope > [data-ry-target="folder"]'), s = t.querySelector(':scope > [data-ry-target="file"]');
|
|
3464
|
+
return e?.dataset.ryLabel ?? s?.dataset.ryLabel ?? "";
|
|
3465
|
+
}
|
|
3466
|
+
}
|
|
3467
|
+
class vt extends u {
|
|
3468
|
+
// Declarative container consumed by RyTree#build
|
|
3469
|
+
}
|
|
3470
|
+
customElements.define("ry-tree", k);
|
|
3471
|
+
customElements.define("ry-tree-item", vt);
|
|
3472
|
+
class At extends u {
|
|
3473
|
+
setup() {
|
|
3474
|
+
this.#t();
|
|
3475
|
+
}
|
|
3476
|
+
#t() {
|
|
3477
|
+
if (this.$('[data-ry-target="label"]')) return;
|
|
3478
|
+
const t = this.textContent?.trim() ?? "", e = this.hasAttribute("removable");
|
|
3479
|
+
if (this.innerHTML = `<span data-ry-target="label" class="ry-tag__label">${t}</span>${e ? `<button data-ry-target="remove" class="ry-tag__remove" aria-label="Remove" type="button">${p("close")}</button>` : ""}`, e) {
|
|
3480
|
+
const s = this.$('[data-ry-target="remove"]');
|
|
3481
|
+
s && this.on(s, "click", (i) => {
|
|
3482
|
+
i.stopPropagation(), this.emit("remove", {
|
|
3483
|
+
value: this.dataset.value ?? "",
|
|
3484
|
+
label: t
|
|
3485
|
+
}), this.remove();
|
|
3486
|
+
});
|
|
3487
|
+
}
|
|
3488
|
+
}
|
|
3489
|
+
get label() {
|
|
3490
|
+
return this.$('[data-ry-target="label"]')?.textContent?.trim() ?? "";
|
|
3491
|
+
}
|
|
3492
|
+
}
|
|
3493
|
+
customElements.define("ry-tag", At);
|
|
3494
|
+
class kt extends u {
|
|
3495
|
+
#t = [];
|
|
3496
|
+
setup() {
|
|
3497
|
+
this.#e(), this.#i();
|
|
3498
|
+
}
|
|
3499
|
+
#e() {
|
|
3500
|
+
if (this.$('[data-ry-target="container"]')) return;
|
|
3501
|
+
const t = this.getAttribute("placeholder") ?? "Add tag...", e = this.getAttribute("name") ?? "", s = this.hasAttribute("disabled");
|
|
3502
|
+
this.innerHTML = `
|
|
3503
|
+
<div data-ry-target="container" class="ry-tag-input__container">
|
|
3504
|
+
<div data-ry-target="tags" class="ry-tag-input__tags"></div>
|
|
3505
|
+
<input data-ry-target="input" class="ry-tag-input__input" type="text" placeholder="${t}" ${s ? "disabled" : ""}>
|
|
3506
|
+
</div>
|
|
3507
|
+
<input data-ry-target="hidden" type="hidden" ${e ? `name="${e}"` : ""}>
|
|
3508
|
+
`;
|
|
3509
|
+
const i = this.$('[data-ry-target="input"]');
|
|
3510
|
+
i && (this.on(i, "keydown", this.#s), this.on(i, "paste", this.#r));
|
|
3511
|
+
const r = this.$('[data-ry-target="container"]');
|
|
3512
|
+
r && this.on(r, "click", () => i?.focus()), this.on(this, "ry:remove", this.#a);
|
|
3513
|
+
}
|
|
3514
|
+
#i() {
|
|
3515
|
+
const t = this.getAttribute("value");
|
|
3516
|
+
if (!t) return;
|
|
3517
|
+
const e = this.getAttribute("delimiter") ?? ",", s = t.split(e).map((i) => i.trim()).filter(Boolean);
|
|
3518
|
+
for (const i of s)
|
|
3519
|
+
this.#o(i);
|
|
3520
|
+
}
|
|
3521
|
+
#s = (t) => {
|
|
3522
|
+
const e = t.target, s = this.getAttribute("delimiter") ?? ",", i = e.value.trim();
|
|
3523
|
+
if (t.key === "Enter" || t.key === s || t.key === "Tab") {
|
|
3524
|
+
if (i)
|
|
3525
|
+
t.preventDefault(), this.#o(i), e.value = "";
|
|
3526
|
+
else if (t.key === "Tab")
|
|
3527
|
+
return;
|
|
3528
|
+
}
|
|
3529
|
+
t.key === "Backspace" && !e.value && this.#t.length > 0 && this.#l();
|
|
3530
|
+
};
|
|
3531
|
+
#r = (t) => {
|
|
3532
|
+
t.preventDefault();
|
|
3533
|
+
const e = t.clipboardData?.getData("text") ?? "", s = this.getAttribute("delimiter") ?? ",", i = e.split(new RegExp(`[${s}\\t\\n]+`)).map((a) => a.trim()).filter(Boolean);
|
|
3534
|
+
for (const a of i)
|
|
3535
|
+
this.#o(a);
|
|
3536
|
+
const r = this.$('[data-ry-target="input"]');
|
|
3537
|
+
r && (r.value = "");
|
|
3538
|
+
};
|
|
3539
|
+
#a = (t) => {
|
|
3540
|
+
const e = t.detail.value, s = this.#t.indexOf(e);
|
|
3541
|
+
s >= 0 && (this.#t.splice(s, 1), this.#c(), this.emit("change", { values: [...this.#t] }));
|
|
3542
|
+
};
|
|
3543
|
+
#o(t) {
|
|
3544
|
+
const e = this.getAttribute("max-tags");
|
|
3545
|
+
if (e && this.#t.length >= parseInt(e, 10) || !this.hasAttribute("allow-duplicates") && this.#t.includes(t)) return;
|
|
3546
|
+
this.#t.push(t);
|
|
3547
|
+
const s = this.$('[data-ry-target="tags"]');
|
|
3548
|
+
if (s) {
|
|
3549
|
+
const i = document.createElement("ry-tag");
|
|
3550
|
+
i.setAttribute("removable", ""), i.setAttribute("size", "sm"), i.setAttribute("data-value", t), i.textContent = t, s.appendChild(i);
|
|
3551
|
+
}
|
|
3552
|
+
this.#c(), this.emit("add", { value: t }), this.emit("change", { values: [...this.#t] });
|
|
3553
|
+
}
|
|
3554
|
+
#l() {
|
|
3555
|
+
const e = this.$('[data-ry-target="tags"]')?.lastElementChild;
|
|
3556
|
+
if (e) {
|
|
3557
|
+
const s = e.dataset.value ?? "";
|
|
3558
|
+
e.remove(), this.#t.pop(), this.#c(), this.emit("remove", { value: s, label: s }), this.emit("change", { values: [...this.#t] });
|
|
3559
|
+
}
|
|
3560
|
+
}
|
|
3561
|
+
#c() {
|
|
3562
|
+
const t = this.$('[data-ry-target="hidden"]'), e = this.getAttribute("delimiter") ?? ",";
|
|
3563
|
+
t && (t.value = this.#t.join(e));
|
|
3564
|
+
}
|
|
3565
|
+
get value() {
|
|
3566
|
+
const t = this.getAttribute("delimiter") ?? ",";
|
|
3567
|
+
return this.#t.join(t);
|
|
3568
|
+
}
|
|
3569
|
+
get values() {
|
|
3570
|
+
return [...this.#t];
|
|
3571
|
+
}
|
|
3572
|
+
}
|
|
3573
|
+
customElements.define("ry-tag-input", kt);
|
|
3574
|
+
class wt extends u {
|
|
3575
|
+
}
|
|
3576
|
+
customElements.define("ry-hero", wt);
|
|
3577
|
+
class $t extends u {
|
|
3578
|
+
setup() {
|
|
3579
|
+
this.#t();
|
|
3580
|
+
}
|
|
3581
|
+
#t() {
|
|
3582
|
+
if (this.$('[data-ry-target="value"]')) return;
|
|
3583
|
+
const t = this.querySelector('[slot="value"]'), e = this.querySelector('[slot="label"]'), s = this.getAttribute("trend"), i = t?.textContent?.trim() ?? "", r = e?.textContent?.trim() ?? "", a = s === "up" ? `<span data-ry-target="trend" class="ry-stat__trend ry-stat__trend--up">${p("chevron-up")}</span>` : s === "down" ? `<span data-ry-target="trend" class="ry-stat__trend ry-stat__trend--down">${p("chevron-down")}</span>` : "";
|
|
3584
|
+
this.innerHTML = `
|
|
3585
|
+
<div data-ry-target="value" class="ry-stat__value">${i}${a}</div>
|
|
3586
|
+
<div data-ry-target="label" class="ry-stat__label">${r}</div>
|
|
3587
|
+
`;
|
|
3588
|
+
}
|
|
3589
|
+
}
|
|
3590
|
+
customElements.define("ry-stat", $t);
|
|
3591
|
+
class xt extends u {
|
|
3592
|
+
setup() {
|
|
3593
|
+
this.#t();
|
|
3594
|
+
}
|
|
3595
|
+
#t() {
|
|
3596
|
+
if (this.$('[data-ry-target="icon"]')) return;
|
|
3597
|
+
const t = this.getAttribute("icon");
|
|
3598
|
+
if (!t) return;
|
|
3599
|
+
const e = p(t);
|
|
3600
|
+
if (!e) return;
|
|
3601
|
+
const s = document.createElement("div");
|
|
3602
|
+
s.setAttribute("data-ry-target", "icon"), s.className = "ry-feature__icon", s.innerHTML = e, this.insertBefore(s, this.firstChild);
|
|
3603
|
+
}
|
|
3604
|
+
}
|
|
3605
|
+
class _t extends u {
|
|
3606
|
+
}
|
|
3607
|
+
customElements.define("ry-feature", xt);
|
|
3608
|
+
customElements.define("ry-feature-grid", _t);
|
|
3609
|
+
class Mt extends u {
|
|
3610
|
+
}
|
|
3611
|
+
class Ct extends u {
|
|
3612
|
+
}
|
|
3613
|
+
customElements.define("ry-pricing", Mt);
|
|
3614
|
+
customElements.define("ry-pricing-card", Ct);
|
|
3615
|
+
class Et extends u {
|
|
3616
|
+
#t = 0;
|
|
3617
|
+
#e = 0;
|
|
3618
|
+
#i = null;
|
|
3619
|
+
#s = 0;
|
|
3620
|
+
#r = !1;
|
|
3621
|
+
setup() {
|
|
3622
|
+
this.#a(), this.#n(), this.hasAttribute("tabindex") || this.setAttribute("tabindex", "0"), this.on(this, "keydown", this.#o);
|
|
3623
|
+
}
|
|
3624
|
+
#a() {
|
|
3625
|
+
if (this.$('[data-ry-target="viewport"]')) return;
|
|
3626
|
+
const t = [...this.children];
|
|
3627
|
+
if (this.#e = t.length, this.#e === 0) return;
|
|
3628
|
+
const e = this.hasAttribute("arrows"), s = this.hasAttribute("dots"), i = document.createElement("div");
|
|
3629
|
+
i.setAttribute("data-ry-target", "track"), i.className = "ry-carousel__track";
|
|
3630
|
+
for (const a of t) {
|
|
3631
|
+
const n = document.createElement("div");
|
|
3632
|
+
n.setAttribute("data-ry-target", "slide"), n.className = "ry-carousel__slide", n.appendChild(a), i.appendChild(n);
|
|
3633
|
+
}
|
|
3634
|
+
const r = document.createElement("div");
|
|
3635
|
+
if (r.setAttribute("data-ry-target", "viewport"), r.className = "ry-carousel__viewport", r.appendChild(i), this.innerHTML = "", this.appendChild(r), e) {
|
|
3636
|
+
const a = document.createElement("button");
|
|
3637
|
+
a.setAttribute("data-ry-target", "prev"), a.className = "ry-carousel__arrow ry-carousel__arrow--prev", a.setAttribute("aria-label", "Previous slide"), a.setAttribute("type", "button"), a.innerHTML = p("chevron-left"), this.appendChild(a), this.on(a, "click", () => this.prev());
|
|
3638
|
+
const n = document.createElement("button");
|
|
3639
|
+
n.setAttribute("data-ry-target", "next"), n.className = "ry-carousel__arrow ry-carousel__arrow--next", n.setAttribute("aria-label", "Next slide"), n.setAttribute("type", "button"), n.innerHTML = p("chevron-right"), this.appendChild(n), this.on(n, "click", () => this.next());
|
|
3640
|
+
}
|
|
3641
|
+
if (s) {
|
|
3642
|
+
const a = document.createElement("div");
|
|
3643
|
+
a.setAttribute("data-ry-target", "dots"), a.className = "ry-carousel__dots";
|
|
3644
|
+
for (let n = 0; n < this.#e; n++) {
|
|
3645
|
+
const o = document.createElement("button");
|
|
3646
|
+
o.setAttribute("data-ry-target", "dot"), o.className = "ry-carousel__dot", o.setAttribute("aria-label", `Go to slide ${n + 1}`), o.setAttribute("type", "button"), n === 0 && o.setAttribute("data-active", ""), this.on(o, "click", () => this.goTo(n)), a.appendChild(o);
|
|
3647
|
+
}
|
|
3648
|
+
this.appendChild(a);
|
|
3649
|
+
}
|
|
3650
|
+
this.on(r, "pointerdown", this.#l), this.on(r, "pointermove", this.#c), this.on(r, "pointerup", this.#h), this.on(r, "pointercancel", this.#h), this.hasAttribute("pause-on-hover") && (this.on(this, "mouseenter", () => this.#p()), this.on(this, "mouseleave", () => this.#n())), this.goTo(0);
|
|
3651
|
+
}
|
|
3652
|
+
#o = (t) => {
|
|
3653
|
+
t.key === "ArrowLeft" ? (t.preventDefault(), this.prev()) : t.key === "ArrowRight" && (t.preventDefault(), this.next());
|
|
3654
|
+
};
|
|
3655
|
+
#l = (t) => {
|
|
3656
|
+
this.#s = t.clientX, this.#r = !0, t.currentTarget.setPointerCapture(t.pointerId);
|
|
3657
|
+
};
|
|
3658
|
+
#c = (t) => {
|
|
3659
|
+
this.#r && t.preventDefault();
|
|
3660
|
+
};
|
|
3661
|
+
#h = (t) => {
|
|
3662
|
+
if (!this.#r) return;
|
|
3663
|
+
this.#r = !1;
|
|
3664
|
+
const e = t.clientX - this.#s, s = 50;
|
|
3665
|
+
e > s ? this.prev() : e < -s && this.next();
|
|
3666
|
+
};
|
|
3667
|
+
#n() {
|
|
3668
|
+
if (this.#p(), !this.hasAttribute("autoplay")) return;
|
|
3669
|
+
const t = parseInt(this.getAttribute("interval") ?? "5000", 10);
|
|
3670
|
+
this.#i = setInterval(() => this.next(), t);
|
|
3671
|
+
}
|
|
3672
|
+
#p() {
|
|
3673
|
+
this.#i && (clearInterval(this.#i), this.#i = null);
|
|
3674
|
+
}
|
|
3675
|
+
goTo(t) {
|
|
3676
|
+
if (this.hasAttribute("loop"))
|
|
3677
|
+
t < 0 && (t = this.#e - 1), t >= this.#e && (t = 0);
|
|
3678
|
+
else if (t < 0 || t >= this.#e) return;
|
|
3679
|
+
this.#t = t;
|
|
3680
|
+
const s = this.$('[data-ry-target="track"]');
|
|
3681
|
+
s && (s.style.transform = `translateX(-${t * 100}%)`), this.$$('[data-ry-target="dot"]').forEach((r, a) => {
|
|
3682
|
+
a === t ? r.setAttribute("data-active", "") : r.removeAttribute("data-active");
|
|
3683
|
+
}), this.emit("change", { index: t, slide: this.#t });
|
|
3684
|
+
}
|
|
3685
|
+
next() {
|
|
3686
|
+
this.goTo(this.#t + 1);
|
|
3687
|
+
}
|
|
3688
|
+
prev() {
|
|
3689
|
+
this.goTo(this.#t - 1);
|
|
3690
|
+
}
|
|
3691
|
+
teardown() {
|
|
3692
|
+
this.#p();
|
|
3693
|
+
}
|
|
3694
|
+
}
|
|
3695
|
+
customElements.define("ry-carousel", Et);
|
|
3696
|
+
window.RyToast = f;
|
|
2416
3697
|
console.log("ry-ui loaded");
|
|
2417
3698
|
export {
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
3699
|
+
R as RyAccordion,
|
|
3700
|
+
K as RyAlert,
|
|
3701
|
+
N as RyButton,
|
|
3702
|
+
Et as RyCarousel,
|
|
3703
|
+
Q as RyCode,
|
|
3704
|
+
ut as RyColorInput,
|
|
3705
|
+
dt as RyColorPicker,
|
|
3706
|
+
W as RyDrawer,
|
|
3707
|
+
j as RyDropdown,
|
|
3708
|
+
u as RyElement,
|
|
3709
|
+
tt as RyExample,
|
|
3710
|
+
xt as RyFeature,
|
|
3711
|
+
_t as RyFeatureGrid,
|
|
3712
|
+
q as RyField,
|
|
3713
|
+
yt as RyGradientPicker,
|
|
3714
|
+
wt as RyHero,
|
|
3715
|
+
et as RyIcon,
|
|
3716
|
+
ot as RyKnob,
|
|
3717
|
+
P as RyModal,
|
|
3718
|
+
ht as RyNumberSelect,
|
|
3719
|
+
Mt as RyPricing,
|
|
3720
|
+
Ct as RyPricingCard,
|
|
3721
|
+
J as RySelect,
|
|
3722
|
+
nt as RySlider,
|
|
3723
|
+
$t as RyStat,
|
|
3724
|
+
z as RySwitch,
|
|
3725
|
+
F as RyTabs,
|
|
3726
|
+
At as RyTag,
|
|
3727
|
+
kt as RyTagInput,
|
|
3728
|
+
O as RyThemeToggle,
|
|
3729
|
+
f as RyToast,
|
|
3730
|
+
at as RyToggleButton,
|
|
3731
|
+
Y as RyTooltip,
|
|
3732
|
+
k as RyTree,
|
|
3733
|
+
vt as RyTreeItem,
|
|
3734
|
+
p as getIcon,
|
|
3735
|
+
It as getIconNames,
|
|
3736
|
+
E as processTransforms,
|
|
3737
|
+
Tt as registerIcon,
|
|
3738
|
+
Lt as registerIcons,
|
|
3739
|
+
M as transform
|
|
2446
3740
|
};
|
|
2447
3741
|
//# sourceMappingURL=ry-ui.js.map
|