@ryanhelsing/ry-ui 1.0.2 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENT.md +460 -0
- package/AGENTS.md +57 -0
- package/README.md +45 -1
- package/dist/components/ry-button-group.d.ts +32 -0
- package/dist/components/ry-button-group.d.ts.map +1 -0
- package/dist/components/ry-carousel.d.ts +21 -0
- package/dist/components/ry-carousel.d.ts.map +1 -0
- package/dist/components/ry-feature.d.ts +21 -0
- package/dist/components/ry-feature.d.ts.map +1 -0
- package/dist/components/ry-field.d.ts +7 -1
- package/dist/components/ry-field.d.ts.map +1 -1
- package/dist/components/ry-hero.d.ts +16 -0
- package/dist/components/ry-hero.d.ts.map +1 -0
- package/dist/components/ry-number-select.d.ts.map +1 -1
- 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-split.d.ts +28 -0
- package/dist/components/ry-split.d.ts.map +1 -0
- 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/core/ry-transform.d.ts.map +1 -1
- package/dist/css/ry-structure.css +739 -149
- package/dist/css/ry-theme.css +581 -180
- package/dist/css/ry-tokens.css +120 -24
- package/dist/css/ry-ui.css +4965 -1065
- package/dist/ry-ui.d.ts +9 -0
- package/dist/ry-ui.d.ts.map +1 -1
- package/dist/ry-ui.js +1309 -778
- 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-group.md +36 -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 +90 -0
- package/docs/components/knob.md +42 -0
- package/docs/components/layout.md +217 -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 +8 -4
- package/USING_CDN.md +0 -591
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 p extends HTMLElement {
|
|
|
89
89
|
this.on(t, "keydown", a), i?.focus();
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
|
-
const
|
|
92
|
+
const H = [
|
|
93
93
|
// Layout
|
|
94
94
|
"page",
|
|
95
95
|
"header",
|
|
@@ -119,6 +119,7 @@ const D = [
|
|
|
119
119
|
"alert",
|
|
120
120
|
"card",
|
|
121
121
|
"button",
|
|
122
|
+
"button-group",
|
|
122
123
|
"badge",
|
|
123
124
|
"field",
|
|
124
125
|
"switch",
|
|
@@ -137,25 +138,34 @@ const D = [
|
|
|
137
138
|
"color-input",
|
|
138
139
|
"gradient-picker",
|
|
139
140
|
"tree",
|
|
140
|
-
"tree-item"
|
|
141
|
+
"tree-item",
|
|
142
|
+
"tag",
|
|
143
|
+
"tag-input",
|
|
144
|
+
"hero",
|
|
145
|
+
"stat",
|
|
146
|
+
"feature",
|
|
147
|
+
"feature-grid",
|
|
148
|
+
"pricing",
|
|
149
|
+
"pricing-card",
|
|
150
|
+
"carousel"
|
|
141
151
|
], B = new RegExp(
|
|
142
|
-
`<(/?)(${
|
|
152
|
+
`<(/?)(${H.join("|")})(\\s|>|/)`,
|
|
143
153
|
"g"
|
|
144
154
|
);
|
|
145
|
-
function M(
|
|
146
|
-
return
|
|
155
|
+
function M(h) {
|
|
156
|
+
return h.replace(B, "<$1ry-$2$3");
|
|
147
157
|
}
|
|
148
158
|
function C() {
|
|
149
|
-
document.querySelectorAll("ry").forEach((
|
|
150
|
-
const t = M(
|
|
151
|
-
e.innerHTML = t,
|
|
152
|
-
}), document.querySelectorAll("template[ry]").forEach((
|
|
153
|
-
const t = M(
|
|
154
|
-
e.innerHTML = t,
|
|
159
|
+
document.querySelectorAll("ry").forEach((h) => {
|
|
160
|
+
const t = M(h.innerHTML), e = document.createElement("template");
|
|
161
|
+
e.innerHTML = t, h.replaceWith(e.content);
|
|
162
|
+
}), document.querySelectorAll("template[ry]").forEach((h) => {
|
|
163
|
+
const t = M(h.innerHTML), e = document.createElement("template");
|
|
164
|
+
e.innerHTML = t, h.replaceWith(e.content);
|
|
155
165
|
});
|
|
156
166
|
}
|
|
157
167
|
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", C) : C();
|
|
158
|
-
class
|
|
168
|
+
class R extends u {
|
|
159
169
|
setup() {
|
|
160
170
|
this.#t(), this.$$('[data-ry-target="trigger"]').forEach((t) => {
|
|
161
171
|
this.on(t, "click", this.#i);
|
|
@@ -231,10 +241,10 @@ class F extends p {
|
|
|
231
241
|
this.$$('[data-ry-target="item"]').forEach((t) => this.close(t));
|
|
232
242
|
}
|
|
233
243
|
}
|
|
234
|
-
customElements.define("ry-accordion",
|
|
244
|
+
customElements.define("ry-accordion", R);
|
|
235
245
|
customElements.get("ry-accordion-item") || customElements.define("ry-accordion-item", class extends HTMLElement {
|
|
236
246
|
});
|
|
237
|
-
class P extends
|
|
247
|
+
class P extends u {
|
|
238
248
|
#t = null;
|
|
239
249
|
#e = 0;
|
|
240
250
|
setup() {
|
|
@@ -284,7 +294,7 @@ class P extends p {
|
|
|
284
294
|
}
|
|
285
295
|
}
|
|
286
296
|
customElements.define("ry-modal", P);
|
|
287
|
-
class
|
|
297
|
+
class F extends u {
|
|
288
298
|
setup() {
|
|
289
299
|
this.#t(), this.$$('[data-ry-target="trigger"]').forEach((t) => {
|
|
290
300
|
this.on(t, "click", this.#i);
|
|
@@ -295,8 +305,8 @@ class R extends p {
|
|
|
295
305
|
if (t.length === 0) return;
|
|
296
306
|
const e = t.findIndex((r) => r.hasAttribute("active")), s = e === -1 ? 0 : e, i = document.createElement("div");
|
|
297
307
|
i.setAttribute("data-ry-target", "list"), i.className = "ry-tabs__list", i.setAttribute("role", "tablist"), t.forEach((r, a) => {
|
|
298
|
-
const n = r.getAttribute("title") ?? `Tab ${a + 1}`,
|
|
299
|
-
l.setAttribute("data-ry-target", "trigger"), l.className = "ry-tabs__trigger", l.setAttribute("role", "tab"), l.setAttribute("aria-selected", String(
|
|
308
|
+
const n = r.getAttribute("title") ?? `Tab ${a + 1}`, o = a === s, l = document.createElement("button");
|
|
309
|
+
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");
|
|
300
310
|
}), this.insertBefore(i, this.firstChild);
|
|
301
311
|
}
|
|
302
312
|
#e() {
|
|
@@ -304,8 +314,8 @@ class R extends p {
|
|
|
304
314
|
t.forEach((i, r) => {
|
|
305
315
|
const a = e[r];
|
|
306
316
|
if (!a) return;
|
|
307
|
-
const n = i.id || `ry-tab-${this.id || ""}-${r}`,
|
|
308
|
-
i.id = n, a.id =
|
|
317
|
+
const n = i.id || `ry-tab-${this.id || ""}-${r}`, o = a.id || `ry-tabpanel-${this.id || ""}-${r}`;
|
|
318
|
+
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");
|
|
309
319
|
}), t.findIndex((i) => i.getAttribute("aria-selected") === "true") === -1 && t.length > 0 && this.select(0);
|
|
310
320
|
}
|
|
311
321
|
#i = (t) => {
|
|
@@ -346,10 +356,10 @@ class R extends p {
|
|
|
346
356
|
return this.$$('[data-ry-target="trigger"]').findIndex((e) => e.getAttribute("aria-selected") === "true");
|
|
347
357
|
}
|
|
348
358
|
}
|
|
349
|
-
customElements.define("ry-tabs",
|
|
359
|
+
customElements.define("ry-tabs", F);
|
|
350
360
|
customElements.get("ry-tab") || customElements.define("ry-tab", class extends HTMLElement {
|
|
351
361
|
});
|
|
352
|
-
class j extends
|
|
362
|
+
class j extends u {
|
|
353
363
|
setup() {
|
|
354
364
|
this.#t();
|
|
355
365
|
const t = this.$('[data-ry-target="trigger"]');
|
|
@@ -402,7 +412,7 @@ customElements.get("ry-menu") || customElements.define("ry-menu", class extends
|
|
|
402
412
|
});
|
|
403
413
|
customElements.get("ry-menu-item") || customElements.define("ry-menu-item", class extends HTMLElement {
|
|
404
414
|
});
|
|
405
|
-
class
|
|
415
|
+
class N extends u {
|
|
406
416
|
setup() {
|
|
407
417
|
this.hasAttribute("tabindex") || this.setAttribute("tabindex", "0"), this.setAttribute("role", "button"), this.on(this, "click", this.#t), this.on(this, "keydown", this.#e);
|
|
408
418
|
}
|
|
@@ -417,8 +427,141 @@ class O extends p {
|
|
|
417
427
|
(t.key === "Enter" || t.key === " ") && (t.preventDefault(), this.click());
|
|
418
428
|
};
|
|
419
429
|
}
|
|
420
|
-
customElements.define("ry-button",
|
|
421
|
-
class
|
|
430
|
+
customElements.define("ry-button", N);
|
|
431
|
+
class O extends u {
|
|
432
|
+
static get observedAttributes() {
|
|
433
|
+
return ["value"];
|
|
434
|
+
}
|
|
435
|
+
get value() {
|
|
436
|
+
return this.getAttribute("value") ?? "";
|
|
437
|
+
}
|
|
438
|
+
set value(t) {
|
|
439
|
+
this.setAttribute("value", t);
|
|
440
|
+
}
|
|
441
|
+
setup() {
|
|
442
|
+
this.setAttribute("role", "group"), this.#e(), this.on(this, "click", this.#t);
|
|
443
|
+
}
|
|
444
|
+
attributeChangedCallback(t, e, s) {
|
|
445
|
+
t === "value" && e !== s && this.#e();
|
|
446
|
+
}
|
|
447
|
+
#t = (t) => {
|
|
448
|
+
const e = t.target.closest("ry-button, ry-toggle-button");
|
|
449
|
+
if (!e || !this.contains(e)) return;
|
|
450
|
+
const s = e.getAttribute("value");
|
|
451
|
+
s != null && this.value !== s && (this.value = s, this.emit("change", { value: s }));
|
|
452
|
+
};
|
|
453
|
+
#e() {
|
|
454
|
+
const t = this.value;
|
|
455
|
+
if (t)
|
|
456
|
+
for (const e of this.querySelectorAll("ry-button, ry-toggle-button"))
|
|
457
|
+
e.getAttribute("value") === t ? (e.setAttribute("pressed", ""), e.setAttribute("aria-pressed", "true")) : (e.removeAttribute("pressed"), e.removeAttribute("aria-pressed"));
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
customElements.define("ry-button-group", O);
|
|
461
|
+
class K extends u {
|
|
462
|
+
#t = null;
|
|
463
|
+
#e = !1;
|
|
464
|
+
#i = 0;
|
|
465
|
+
#s = 0;
|
|
466
|
+
setup() {
|
|
467
|
+
if (!this.hasAttribute("resizable")) return;
|
|
468
|
+
this.#f(), this.#t = document.createElement("div"), this.#t.setAttribute("data-ry-target", "handle"), this.#t.className = "ry-split__handle", this.#t.setAttribute("role", "separator"), this.#t.setAttribute("aria-orientation", "vertical"), this.#t.setAttribute("tabindex", "0");
|
|
469
|
+
const t = this.lastElementChild;
|
|
470
|
+
t && this.insertBefore(this.#t, t), this.on(this.#t, "mousedown", this.#d), this.on(this.#t, "touchstart", this.#n), this.on(this.#t, "keydown", this.#b), this.on(this.#t, "dblclick", this.#k);
|
|
471
|
+
}
|
|
472
|
+
#r() {
|
|
473
|
+
return this.lastElementChild;
|
|
474
|
+
}
|
|
475
|
+
#a() {
|
|
476
|
+
const t = this.#r();
|
|
477
|
+
return t ? t.getBoundingClientRect().width : 300;
|
|
478
|
+
}
|
|
479
|
+
#o() {
|
|
480
|
+
const t = getComputedStyle(this).getPropertyValue("--ry-split-min-width").trim();
|
|
481
|
+
return t ? parseFloat(t) : 100;
|
|
482
|
+
}
|
|
483
|
+
#c() {
|
|
484
|
+
const t = getComputedStyle(this).getPropertyValue("--ry-split-max-width").trim();
|
|
485
|
+
return t ? parseFloat(t) : this.getBoundingClientRect().width * 0.8;
|
|
486
|
+
}
|
|
487
|
+
#h(t) {
|
|
488
|
+
const e = this.#o(), s = this.#c(), i = Math.round(Math.max(e, Math.min(s, t)));
|
|
489
|
+
this.style.setProperty("--ry-split-width", `${i}px`);
|
|
490
|
+
}
|
|
491
|
+
#d = (t) => {
|
|
492
|
+
t.preventDefault(), this.#p(t.clientX);
|
|
493
|
+
const e = (i) => this.#u(i.clientX), s = () => {
|
|
494
|
+
document.removeEventListener("mousemove", e), document.removeEventListener("mouseup", s), this.#m();
|
|
495
|
+
};
|
|
496
|
+
document.addEventListener("mousemove", e), document.addEventListener("mouseup", s);
|
|
497
|
+
};
|
|
498
|
+
#n = (t) => {
|
|
499
|
+
const e = t.touches[0];
|
|
500
|
+
if (!e) return;
|
|
501
|
+
t.preventDefault(), this.#p(e.clientX);
|
|
502
|
+
const s = (r) => {
|
|
503
|
+
const a = r.touches[0];
|
|
504
|
+
a && this.#u(a.clientX);
|
|
505
|
+
}, i = () => {
|
|
506
|
+
document.removeEventListener("touchmove", s), document.removeEventListener("touchend", i), this.#m();
|
|
507
|
+
};
|
|
508
|
+
document.addEventListener("touchmove", s, { passive: !1 }), document.addEventListener("touchend", i);
|
|
509
|
+
};
|
|
510
|
+
#p(t) {
|
|
511
|
+
this.#e = !0, this.#i = t, this.#s = this.#a(), this.setAttribute("data-ry-resizing", ""), document.body.style.cursor = "col-resize", document.body.style.userSelect = "none";
|
|
512
|
+
}
|
|
513
|
+
#u(t) {
|
|
514
|
+
if (!this.#e) return;
|
|
515
|
+
const e = this.#i - t;
|
|
516
|
+
this.#h(this.#s + e);
|
|
517
|
+
}
|
|
518
|
+
#m() {
|
|
519
|
+
this.#e = !1, this.removeAttribute("data-ry-resizing"), document.body.style.cursor = "", document.body.style.userSelect = "", this.#l(), this.emit("resize", { width: this.#a() });
|
|
520
|
+
}
|
|
521
|
+
#b = (t) => {
|
|
522
|
+
const e = t.shiftKey ? 50 : 10;
|
|
523
|
+
let s = this.#a();
|
|
524
|
+
t.key === "ArrowLeft" ? (t.preventDefault(), this.#h(s + e), this.#l()) : t.key === "ArrowRight" ? (t.preventDefault(), this.#h(s - e), this.#l()) : t.key === "Home" ? (t.preventDefault(), this.#h(this.#o()), this.#l()) : t.key === "End" && (t.preventDefault(), this.#h(this.#c()), this.#l());
|
|
525
|
+
};
|
|
526
|
+
#k = () => {
|
|
527
|
+
this.style.removeProperty("--ry-split-width"), this.#v(), this.emit("resize", { width: this.#a() });
|
|
528
|
+
};
|
|
529
|
+
// Persistence
|
|
530
|
+
#g() {
|
|
531
|
+
const t = this.getAttribute("persist");
|
|
532
|
+
return t ? `ry-split:${t}` : null;
|
|
533
|
+
}
|
|
534
|
+
#l() {
|
|
535
|
+
const t = this.#g();
|
|
536
|
+
if (t)
|
|
537
|
+
try {
|
|
538
|
+
localStorage.setItem(t, String(this.#a()));
|
|
539
|
+
} catch {
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
#f() {
|
|
543
|
+
const t = this.#g();
|
|
544
|
+
if (t)
|
|
545
|
+
try {
|
|
546
|
+
const e = localStorage.getItem(t);
|
|
547
|
+
if (e) {
|
|
548
|
+
const s = parseFloat(e);
|
|
549
|
+
isNaN(s) || this.style.setProperty("--ry-split-width", `${s}px`);
|
|
550
|
+
}
|
|
551
|
+
} catch {
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
#v() {
|
|
555
|
+
const t = this.#g();
|
|
556
|
+
if (t)
|
|
557
|
+
try {
|
|
558
|
+
localStorage.removeItem(t);
|
|
559
|
+
} catch {
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
customElements.define("ry-split", K);
|
|
564
|
+
class q extends u {
|
|
422
565
|
#t = ["light", "dark"];
|
|
423
566
|
#e = 0;
|
|
424
567
|
setup() {
|
|
@@ -458,8 +601,8 @@ class N extends p {
|
|
|
458
601
|
}
|
|
459
602
|
}
|
|
460
603
|
}
|
|
461
|
-
customElements.define("ry-theme-toggle",
|
|
462
|
-
class
|
|
604
|
+
customElements.define("ry-theme-toggle", q);
|
|
605
|
+
class z extends u {
|
|
463
606
|
setup() {
|
|
464
607
|
this.#t();
|
|
465
608
|
const t = this.$("[close]");
|
|
@@ -479,26 +622,63 @@ class K extends p {
|
|
|
479
622
|
}, 200), this.emit("close");
|
|
480
623
|
}
|
|
481
624
|
}
|
|
482
|
-
customElements.define("ry-alert",
|
|
483
|
-
class
|
|
625
|
+
customElements.define("ry-alert", z);
|
|
626
|
+
class U extends u {
|
|
627
|
+
static get observedAttributes() {
|
|
628
|
+
return ["label", "error", "hint"];
|
|
629
|
+
}
|
|
484
630
|
setup() {
|
|
485
631
|
this.#t();
|
|
486
632
|
}
|
|
633
|
+
attributeChangedCallback(t, e, s) {
|
|
634
|
+
e !== s && (t === "error" ? this.#e(s) : t === "hint" ? this.#i(s) : t === "label" && this.#s(s));
|
|
635
|
+
}
|
|
487
636
|
#t() {
|
|
488
|
-
|
|
489
|
-
const t = this.getAttribute("label");
|
|
637
|
+
const t = this.$("input, textarea, select");
|
|
490
638
|
if (!t) return;
|
|
491
|
-
const e =
|
|
492
|
-
if (!
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
639
|
+
const e = t.id || `ry-field-${Math.random().toString(36).slice(2, 9)}`;
|
|
640
|
+
if (t.id = e, !this.$('[data-ry-target="label"]')) {
|
|
641
|
+
const a = this.getAttribute("label");
|
|
642
|
+
if (a) {
|
|
643
|
+
const n = document.createElement("label");
|
|
644
|
+
n.setAttribute("data-ry-target", "label"), n.className = "ry-label", n.setAttribute("for", e), n.textContent = a, this.insertBefore(n, t);
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
if (!this.$('[data-ry-target="error"]')) {
|
|
648
|
+
const a = document.createElement("div");
|
|
649
|
+
a.setAttribute("data-ry-target", "error"), a.className = "ry-field__error", a.setAttribute("role", "alert");
|
|
650
|
+
const n = this.getAttribute("error");
|
|
651
|
+
n && (a.textContent = n), t.insertAdjacentElement("afterend", a);
|
|
652
|
+
}
|
|
653
|
+
if (!this.$('[data-ry-target="hint"]')) {
|
|
654
|
+
const a = document.createElement("div");
|
|
655
|
+
a.setAttribute("data-ry-target", "hint"), a.className = "ry-field__hint";
|
|
656
|
+
const n = this.getAttribute("hint");
|
|
657
|
+
n && (a.textContent = n);
|
|
658
|
+
const o = this.$('[data-ry-target="error"]');
|
|
659
|
+
o ? o.insertAdjacentElement("afterend", a) : t.insertAdjacentElement("afterend", a);
|
|
660
|
+
}
|
|
661
|
+
const s = this.$('[data-ry-target="error"]'), i = this.$('[data-ry-target="hint"]'), r = [];
|
|
662
|
+
s && (s.id = `${e}-error`, r.push(s.id)), i && (i.id = `${e}-hint`, r.push(i.id)), r.length && t.setAttribute("aria-describedby", r.join(" "));
|
|
663
|
+
}
|
|
664
|
+
#e(t) {
|
|
665
|
+
const e = this.$('[data-ry-target="error"]');
|
|
666
|
+
e && (e.textContent = t ?? "");
|
|
667
|
+
const s = this.$("input, textarea, select");
|
|
668
|
+
s && (t ? s.setAttribute("aria-invalid", "true") : s.removeAttribute("aria-invalid"));
|
|
669
|
+
}
|
|
670
|
+
#i(t) {
|
|
671
|
+
const e = this.$('[data-ry-target="hint"]');
|
|
672
|
+
e && (e.textContent = t ?? "");
|
|
673
|
+
}
|
|
674
|
+
#s(t) {
|
|
675
|
+
const e = this.$('[data-ry-target="label"]');
|
|
676
|
+
e && (e.textContent = t ?? "");
|
|
497
677
|
}
|
|
498
678
|
}
|
|
499
|
-
customElements.define("ry-field",
|
|
500
|
-
let
|
|
501
|
-
class
|
|
679
|
+
customElements.define("ry-field", U);
|
|
680
|
+
let V = 0;
|
|
681
|
+
class W extends u {
|
|
502
682
|
#t = null;
|
|
503
683
|
static observedAttributes = ["checked", "disabled"];
|
|
504
684
|
setup() {
|
|
@@ -506,7 +686,7 @@ class V extends p {
|
|
|
506
686
|
}
|
|
507
687
|
#e() {
|
|
508
688
|
if (this.$('[data-ry-target="track"]')) return;
|
|
509
|
-
const t = `ry-switch-${++
|
|
689
|
+
const t = `ry-switch-${++V}`, e = this.getAttribute("name") ?? "", s = this.hasAttribute("checked"), i = this.hasAttribute("disabled"), r = this.textContent?.trim() ?? "";
|
|
510
690
|
this.innerHTML = `
|
|
511
691
|
<label data-ry-target="wrapper" class="ry-switch__wrapper" for="${t}">
|
|
512
692
|
<input
|
|
@@ -551,41 +731,41 @@ class V extends p {
|
|
|
551
731
|
this.#t && (this.#t.value = t);
|
|
552
732
|
}
|
|
553
733
|
}
|
|
554
|
-
customElements.define("ry-switch",
|
|
734
|
+
customElements.define("ry-switch", W);
|
|
555
735
|
let Y = 0;
|
|
556
|
-
class
|
|
736
|
+
class X extends u {
|
|
557
737
|
#t = null;
|
|
558
738
|
#e = null;
|
|
559
739
|
#i = null;
|
|
560
740
|
setup() {
|
|
561
741
|
this.#i = `ry-tooltip-${++Y}`, this.#s();
|
|
562
742
|
const t = this.firstElementChild;
|
|
563
|
-
t && (t.setAttribute("aria-describedby", this.#i), this.on(t, "mouseenter", this.#r), this.on(t, "mouseleave", this.#
|
|
743
|
+
t && (t.setAttribute("aria-describedby", this.#i), this.on(t, "mouseenter", this.#r), this.on(t, "mouseleave", this.#o), this.on(t, "focusin", this.#r), this.on(t, "focusout", this.#o)), this.on(document, "keydown", this.#c);
|
|
564
744
|
}
|
|
565
745
|
#s() {
|
|
566
746
|
this.#e = document.createElement("div"), this.#e.id = this.#i, this.#e.setAttribute("data-ry-target", "content"), this.#e.className = "ry-tooltip__content", this.#e.setAttribute("role", "tooltip"), this.#e.textContent = this.getAttribute("content") ?? "", this.appendChild(this.#e);
|
|
567
747
|
}
|
|
568
748
|
#r = () => {
|
|
569
749
|
this.#t && clearTimeout(this.#t), this.#t = setTimeout(() => {
|
|
570
|
-
this.#
|
|
750
|
+
this.#a();
|
|
571
751
|
}, 200);
|
|
572
752
|
};
|
|
573
|
-
#
|
|
753
|
+
#a = () => {
|
|
574
754
|
const t = this.getAttribute("position") ?? "top";
|
|
575
755
|
this.setAttribute("data-ry-position", t), this.state = "open";
|
|
576
756
|
};
|
|
577
|
-
#
|
|
757
|
+
#o = () => {
|
|
578
758
|
this.#t && (clearTimeout(this.#t), this.#t = null), this.state = "closed";
|
|
579
759
|
};
|
|
580
|
-
#
|
|
581
|
-
t.key === "Escape" && this.state === "open" && this.#
|
|
760
|
+
#c = (t) => {
|
|
761
|
+
t.key === "Escape" && this.state === "open" && this.#o();
|
|
582
762
|
};
|
|
583
763
|
teardown() {
|
|
584
764
|
this.#t && clearTimeout(this.#t);
|
|
585
765
|
}
|
|
586
766
|
}
|
|
587
|
-
customElements.define("ry-tooltip",
|
|
588
|
-
class
|
|
767
|
+
customElements.define("ry-tooltip", X);
|
|
768
|
+
class G extends u {
|
|
589
769
|
#t = null;
|
|
590
770
|
#e = 0;
|
|
591
771
|
setup() {
|
|
@@ -630,9 +810,9 @@ class W extends p {
|
|
|
630
810
|
this.state === "open" ? this.close() : this.open();
|
|
631
811
|
}
|
|
632
812
|
}
|
|
633
|
-
customElements.define("ry-drawer",
|
|
634
|
-
const
|
|
635
|
-
class f extends
|
|
813
|
+
customElements.define("ry-drawer", G);
|
|
814
|
+
const J = 4e3;
|
|
815
|
+
class f extends u {
|
|
636
816
|
#t = null;
|
|
637
817
|
static observedAttributes = ["variant", "duration"];
|
|
638
818
|
// Static container for programmatic toasts
|
|
@@ -661,7 +841,7 @@ class f extends p {
|
|
|
661
841
|
this.#s();
|
|
662
842
|
const t = this.$("[close]");
|
|
663
843
|
t && this.on(t, "click", () => this.dismiss());
|
|
664
|
-
const e = parseInt(this.getAttribute("duration") ?? String(
|
|
844
|
+
const e = parseInt(this.getAttribute("duration") ?? String(J), 10);
|
|
665
845
|
e > 0 && (this.#t = setTimeout(() => this.dismiss(), e)), requestAnimationFrame(() => {
|
|
666
846
|
this.state = "visible";
|
|
667
847
|
});
|
|
@@ -694,56 +874,174 @@ class f extends p {
|
|
|
694
874
|
}
|
|
695
875
|
}
|
|
696
876
|
customElements.define("ry-toast", f);
|
|
697
|
-
|
|
698
|
-
|
|
877
|
+
const w = {
|
|
878
|
+
// Close / X
|
|
879
|
+
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>',
|
|
880
|
+
// Chevron down
|
|
881
|
+
"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>',
|
|
882
|
+
// Chevron up
|
|
883
|
+
"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>',
|
|
884
|
+
// Chevron right
|
|
885
|
+
"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>',
|
|
886
|
+
// Chevron left
|
|
887
|
+
"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>',
|
|
888
|
+
// Check / Checkmark
|
|
889
|
+
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>',
|
|
890
|
+
// Copy
|
|
891
|
+
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>',
|
|
892
|
+
// Sun (light mode)
|
|
893
|
+
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>',
|
|
894
|
+
// Moon (dark mode)
|
|
895
|
+
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>',
|
|
896
|
+
// Info
|
|
897
|
+
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>',
|
|
898
|
+
// Warning / Alert triangle
|
|
899
|
+
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>',
|
|
900
|
+
// Error / X circle
|
|
901
|
+
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>',
|
|
902
|
+
// Success / Check circle
|
|
903
|
+
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>',
|
|
904
|
+
// Search
|
|
905
|
+
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>',
|
|
906
|
+
// Menu / Hamburger
|
|
907
|
+
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>',
|
|
908
|
+
// Plus
|
|
909
|
+
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>',
|
|
910
|
+
// Minus
|
|
911
|
+
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>',
|
|
912
|
+
// Settings / Gear
|
|
913
|
+
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>',
|
|
914
|
+
// User
|
|
915
|
+
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>',
|
|
916
|
+
// Heart
|
|
917
|
+
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>',
|
|
918
|
+
// Star
|
|
919
|
+
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>',
|
|
920
|
+
// Trash
|
|
921
|
+
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>',
|
|
922
|
+
// Edit / Pencil
|
|
923
|
+
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>',
|
|
924
|
+
// External link
|
|
925
|
+
"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>',
|
|
926
|
+
// Download
|
|
927
|
+
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>',
|
|
928
|
+
// Upload
|
|
929
|
+
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>',
|
|
930
|
+
// Folder (closed)
|
|
931
|
+
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>',
|
|
932
|
+
// Folder open
|
|
933
|
+
"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>',
|
|
934
|
+
// File
|
|
935
|
+
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>',
|
|
936
|
+
// Gradient: solid color
|
|
937
|
+
"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>',
|
|
938
|
+
// Gradient: linear
|
|
939
|
+
"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>',
|
|
940
|
+
// Gradient: radial
|
|
941
|
+
"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>',
|
|
942
|
+
// Shape: circle
|
|
943
|
+
"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>',
|
|
944
|
+
// Shape: ellipse
|
|
945
|
+
"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>'
|
|
946
|
+
};
|
|
947
|
+
function p(h) {
|
|
948
|
+
return w[h] ?? "";
|
|
949
|
+
}
|
|
950
|
+
function Dt(h, t) {
|
|
951
|
+
w[h] = t;
|
|
952
|
+
}
|
|
953
|
+
function It(h) {
|
|
954
|
+
Object.assign(w, h);
|
|
955
|
+
}
|
|
956
|
+
function Ht() {
|
|
957
|
+
return Object.keys(w);
|
|
958
|
+
}
|
|
959
|
+
let Z = 0;
|
|
960
|
+
class Q extends u {
|
|
699
961
|
#t = null;
|
|
700
962
|
#e = -1;
|
|
701
963
|
#i = "";
|
|
702
964
|
#s = null;
|
|
965
|
+
#r = /* @__PURE__ */ new Set();
|
|
703
966
|
// Store options reference
|
|
704
967
|
_options = [];
|
|
968
|
+
get #a() {
|
|
969
|
+
return this.hasAttribute("multiple");
|
|
970
|
+
}
|
|
705
971
|
static observedAttributes = ["value", "disabled"];
|
|
706
972
|
setup() {
|
|
707
|
-
this.#t = `ry-select-${++
|
|
973
|
+
this.#t = `ry-select-${++Z}`, this.#o(), this.hasAttribute("tabindex") || this.setAttribute("tabindex", "0"), this.on(this, "click", this.#c), this.on(this, "keydown", this.#h), this.on(document, "click", this.#d), this.#a && this.on(this, "ry:remove", this.#n), this.hasAttribute("data-ry-state") || (this.state = "closed");
|
|
708
974
|
const t = this.getAttribute("value");
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
975
|
+
if (t)
|
|
976
|
+
if (this.#a)
|
|
977
|
+
for (const e of t.split(",").map((s) => s.trim()).filter(Boolean))
|
|
978
|
+
this.#l(e);
|
|
979
|
+
else
|
|
980
|
+
this.value = t;
|
|
981
|
+
}
|
|
982
|
+
#o() {
|
|
983
|
+
const t = [...this.querySelectorAll("ry-option")].map((o) => ({
|
|
984
|
+
value: o.getAttribute("value") ?? o.textContent?.trim() ?? "",
|
|
985
|
+
label: o.textContent?.trim() ?? "",
|
|
986
|
+
disabled: o.hasAttribute("disabled")
|
|
987
|
+
})), e = this.getAttribute("placeholder") ?? "Select...", s = this.getAttribute("name") ?? "", i = this.hasAttribute("disabled"), r = this.#a, a = t.map(
|
|
988
|
+
(o) => `<option value="${o.value}"${o.disabled ? " disabled" : ""}>${o.label}</option>`
|
|
989
|
+
).join(""), n = t.map((o, l) => `
|
|
719
990
|
<div data-ry-target="option" class="ry-select__option"
|
|
720
991
|
role="option"
|
|
721
|
-
id="${this.#t}-option-${
|
|
722
|
-
data-value="${
|
|
723
|
-
${
|
|
724
|
-
aria-disabled="${
|
|
725
|
-
${
|
|
992
|
+
id="${this.#t}-option-${l}"
|
|
993
|
+
data-value="${o.value}"
|
|
994
|
+
${o.disabled ? "data-disabled" : ""}
|
|
995
|
+
aria-disabled="${o.disabled}">
|
|
996
|
+
${r ? `<span data-ry-target="check" class="ry-select__check">${p("check")}</span>` : ""}
|
|
997
|
+
<span class="ry-select__option-label">${o.label}</span>
|
|
726
998
|
</div>
|
|
727
999
|
`).join("");
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
<
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
<
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
1000
|
+
if (r) {
|
|
1001
|
+
const o = this.hasAttribute("clearable");
|
|
1002
|
+
this.innerHTML = `
|
|
1003
|
+
<div data-ry-target="trigger" class="ry-select__trigger ry-select__trigger--multi" aria-haspopup="listbox" aria-expanded="false">
|
|
1004
|
+
<div data-ry-target="tags" class="ry-select__tags"></div>
|
|
1005
|
+
<span data-ry-target="value" class="ry-select__value">${e}</span>
|
|
1006
|
+
${o ? `<button data-ry-target="clear" class="ry-select__clear" aria-label="Clear all" type="button">${p("close")}</button>` : ""}
|
|
1007
|
+
<span data-ry-target="arrow" class="ry-select__arrow">▾</span>
|
|
1008
|
+
</div>
|
|
1009
|
+
<div data-ry-target="dropdown" class="ry-select__dropdown" role="listbox" id="${this.#t}-listbox" tabindex="-1" aria-multiselectable="true">
|
|
1010
|
+
${n}
|
|
1011
|
+
</div>
|
|
1012
|
+
<select data-ry-target="native" class="ry-select__native" ${s ? `name="${s}"` : ""} multiple tabindex="-1" aria-hidden="true" ${i ? "disabled" : ""}>
|
|
1013
|
+
${a}
|
|
1014
|
+
</select>
|
|
1015
|
+
`;
|
|
1016
|
+
const l = this.$('[data-ry-target="clear"]');
|
|
1017
|
+
l && this.on(l, "click", (c) => {
|
|
1018
|
+
c.stopPropagation(), this.#M();
|
|
1019
|
+
});
|
|
1020
|
+
} else
|
|
1021
|
+
this.innerHTML = `
|
|
1022
|
+
<div data-ry-target="trigger" class="ry-select__trigger" aria-haspopup="listbox" aria-expanded="false">
|
|
1023
|
+
<span data-ry-target="value" class="ry-select__value">${e}</span>
|
|
1024
|
+
<span data-ry-target="arrow" class="ry-select__arrow">▾</span>
|
|
1025
|
+
</div>
|
|
1026
|
+
<div data-ry-target="dropdown" class="ry-select__dropdown" role="listbox" id="${this.#t}-listbox" tabindex="-1">
|
|
1027
|
+
${n}
|
|
1028
|
+
</div>
|
|
1029
|
+
<select data-ry-target="native" class="ry-select__native" ${s ? `name="${s}"` : ""} tabindex="-1" aria-hidden="true" ${i ? "disabled" : ""}>
|
|
1030
|
+
<option value="">${e}</option>
|
|
1031
|
+
${a}
|
|
1032
|
+
</select>
|
|
1033
|
+
`;
|
|
1034
|
+
this._options = t;
|
|
741
1035
|
}
|
|
742
|
-
#
|
|
1036
|
+
#c = (t) => {
|
|
743
1037
|
if (this.hasAttribute("disabled")) return;
|
|
744
1038
|
const e = t.target, s = e.closest('[data-ry-target="option"]');
|
|
745
1039
|
if (s instanceof HTMLElement && !s.hasAttribute("data-disabled")) {
|
|
746
|
-
this.#
|
|
1040
|
+
if (this.#a) {
|
|
1041
|
+
const r = s.dataset.value ?? "";
|
|
1042
|
+
this.#l(r);
|
|
1043
|
+
} else
|
|
1044
|
+
this.#$(s), this.close();
|
|
747
1045
|
return;
|
|
748
1046
|
}
|
|
749
1047
|
e.closest('[data-ry-target="trigger"]') && this.toggle();
|
|
@@ -756,7 +1054,12 @@ class J extends p {
|
|
|
756
1054
|
case " ":
|
|
757
1055
|
if (t.preventDefault(), e && this.#e >= 0) {
|
|
758
1056
|
const i = this.$$('[data-ry-target="option"]:not([data-disabled])')[this.#e];
|
|
759
|
-
|
|
1057
|
+
if (i)
|
|
1058
|
+
if (this.#a) {
|
|
1059
|
+
const r = i.dataset.value ?? "";
|
|
1060
|
+
this.#l(r);
|
|
1061
|
+
} else
|
|
1062
|
+
this.#$(i), this.close();
|
|
760
1063
|
} else
|
|
761
1064
|
this.toggle();
|
|
762
1065
|
break;
|
|
@@ -764,43 +1067,54 @@ class J extends p {
|
|
|
764
1067
|
e && (t.preventDefault(), this.close());
|
|
765
1068
|
break;
|
|
766
1069
|
case "ArrowDown":
|
|
767
|
-
t.preventDefault(), e ? this.#
|
|
1070
|
+
t.preventDefault(), e ? this.#m() : this.open();
|
|
768
1071
|
break;
|
|
769
1072
|
case "ArrowUp":
|
|
770
|
-
t.preventDefault(), e && this.#
|
|
1073
|
+
t.preventDefault(), e && this.#b();
|
|
771
1074
|
break;
|
|
772
1075
|
case "Home":
|
|
773
|
-
e && (t.preventDefault(), this.#
|
|
1076
|
+
e && (t.preventDefault(), this.#k());
|
|
774
1077
|
break;
|
|
775
1078
|
case "End":
|
|
776
|
-
e && (t.preventDefault(), this.#
|
|
1079
|
+
e && (t.preventDefault(), this.#g());
|
|
1080
|
+
break;
|
|
1081
|
+
case "Backspace":
|
|
1082
|
+
if (this.#a && this.#r.size > 0) {
|
|
1083
|
+
const s = [...this.#r], i = s[s.length - 1];
|
|
1084
|
+
i && this.#l(i);
|
|
1085
|
+
}
|
|
777
1086
|
break;
|
|
778
1087
|
default:
|
|
779
|
-
t.key.length === 1 && !t.ctrlKey && !t.metaKey && this.#
|
|
1088
|
+
t.key.length === 1 && !t.ctrlKey && !t.metaKey && this.#p(t.key);
|
|
780
1089
|
break;
|
|
781
1090
|
}
|
|
782
1091
|
};
|
|
783
|
-
#
|
|
1092
|
+
#d = (t) => {
|
|
784
1093
|
const e = t.target;
|
|
785
1094
|
!this.contains(e) && this.state === "open" && this.close();
|
|
786
1095
|
};
|
|
787
|
-
#
|
|
1096
|
+
#n = (t) => {
|
|
1097
|
+
const e = t.detail.value;
|
|
1098
|
+
this.#r.has(e) && this.#l(e);
|
|
1099
|
+
};
|
|
1100
|
+
#p(t) {
|
|
788
1101
|
this.#s && clearTimeout(this.#s), this.#i += t.toLowerCase();
|
|
789
1102
|
const e = this.$$('[data-ry-target="option"]:not([data-disabled])'), s = e.findIndex(
|
|
790
1103
|
(i) => i.textContent?.trim().toLowerCase().startsWith(this.#i)
|
|
791
1104
|
);
|
|
792
|
-
if (s >= 0)
|
|
1105
|
+
if (s >= 0) {
|
|
793
1106
|
if (this.state === "open")
|
|
794
|
-
this.#
|
|
795
|
-
else {
|
|
1107
|
+
this.#u(s);
|
|
1108
|
+
else if (!this.#a) {
|
|
796
1109
|
const i = e[s];
|
|
797
|
-
i && this
|
|
1110
|
+
i && this.#$(i);
|
|
798
1111
|
}
|
|
1112
|
+
}
|
|
799
1113
|
this.#s = setTimeout(() => {
|
|
800
1114
|
this.#i = "";
|
|
801
1115
|
}, 500);
|
|
802
1116
|
}
|
|
803
|
-
#
|
|
1117
|
+
#u(t) {
|
|
804
1118
|
const e = this.$$('[data-ry-target="option"]:not([data-disabled])');
|
|
805
1119
|
if (t < 0 || t >= e.length) return;
|
|
806
1120
|
this.$$('[data-ry-target="option"][data-highlighted]').forEach((r) => {
|
|
@@ -812,22 +1126,62 @@ class J extends p {
|
|
|
812
1126
|
const i = this.$('[data-ry-target="trigger"]');
|
|
813
1127
|
i && i.setAttribute("aria-activedescendant", s.id);
|
|
814
1128
|
}
|
|
815
|
-
#
|
|
1129
|
+
#m() {
|
|
816
1130
|
const t = this.$$('[data-ry-target="option"]:not([data-disabled])'), e = Math.min(this.#e + 1, t.length - 1);
|
|
817
|
-
this.#
|
|
1131
|
+
this.#u(e);
|
|
818
1132
|
}
|
|
819
|
-
#
|
|
1133
|
+
#b() {
|
|
820
1134
|
const t = Math.max(this.#e - 1, 0);
|
|
821
|
-
this.#
|
|
1135
|
+
this.#u(t);
|
|
822
1136
|
}
|
|
823
|
-
#
|
|
824
|
-
this.#
|
|
1137
|
+
#k() {
|
|
1138
|
+
this.#u(0);
|
|
825
1139
|
}
|
|
826
|
-
#
|
|
1140
|
+
#g() {
|
|
827
1141
|
const t = this.$$('[data-ry-target="option"]:not([data-disabled])');
|
|
828
|
-
this.#
|
|
1142
|
+
this.#u(t.length - 1);
|
|
829
1143
|
}
|
|
830
|
-
|
|
1144
|
+
// --- Multi-select methods ---
|
|
1145
|
+
#l(t) {
|
|
1146
|
+
const e = this.getAttribute("max-selections");
|
|
1147
|
+
if (this.#r.has(t))
|
|
1148
|
+
this.#r.delete(t);
|
|
1149
|
+
else {
|
|
1150
|
+
if (e && this.#r.size >= parseInt(e, 10)) return;
|
|
1151
|
+
this.#r.add(t);
|
|
1152
|
+
}
|
|
1153
|
+
this.#f(), this.#v(), this.#y(), this.setAttribute("value", [...this.#r].join(",")), this.emit("change", { value: this.value, label: "" });
|
|
1154
|
+
}
|
|
1155
|
+
#f() {
|
|
1156
|
+
const t = this.$('[data-ry-target="tags"]'), e = this.$('[data-ry-target="value"]');
|
|
1157
|
+
if (t) {
|
|
1158
|
+
t.innerHTML = "";
|
|
1159
|
+
for (const s of this.#r) {
|
|
1160
|
+
const i = this._options.find((a) => a.value === s);
|
|
1161
|
+
if (!i) continue;
|
|
1162
|
+
const r = document.createElement("ry-tag");
|
|
1163
|
+
r.setAttribute("removable", ""), r.setAttribute("size", "sm"), r.setAttribute("data-value", s), r.textContent = i.label, t.appendChild(r);
|
|
1164
|
+
}
|
|
1165
|
+
e && (this.#r.size > 0 ? e.style.display = "none" : e.style.display = "");
|
|
1166
|
+
}
|
|
1167
|
+
}
|
|
1168
|
+
#v() {
|
|
1169
|
+
const t = this.$('[data-ry-target="native"]');
|
|
1170
|
+
if (t)
|
|
1171
|
+
for (const e of t.options)
|
|
1172
|
+
e.selected = this.#r.has(e.value);
|
|
1173
|
+
}
|
|
1174
|
+
#y() {
|
|
1175
|
+
this.$$('[data-ry-target="option"]').forEach((t) => {
|
|
1176
|
+
const e = t.dataset.value ?? "";
|
|
1177
|
+
this.#r.has(e) ? t.setAttribute("aria-selected", "true") : t.removeAttribute("aria-selected");
|
|
1178
|
+
});
|
|
1179
|
+
}
|
|
1180
|
+
#M() {
|
|
1181
|
+
this.#r.clear(), this.#f(), this.#v(), this.#y(), this.setAttribute("value", ""), this.emit("change", { value: "", label: "" });
|
|
1182
|
+
}
|
|
1183
|
+
// --- Single-select method ---
|
|
1184
|
+
#$(t) {
|
|
831
1185
|
const e = t.dataset.value ?? "", s = t.textContent?.trim() ?? "", i = this.$('[data-ry-target="value"]');
|
|
832
1186
|
i && (i.textContent = s, i.setAttribute("data-selected", ""));
|
|
833
1187
|
const r = this.$('[data-ry-target="native"]');
|
|
@@ -839,16 +1193,19 @@ class J extends p {
|
|
|
839
1193
|
if (this.state === "open") return;
|
|
840
1194
|
this.state = "open";
|
|
841
1195
|
const t = this.$('[data-ry-target="trigger"]');
|
|
842
|
-
t && t.setAttribute("aria-expanded", "true"), this.#
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
const
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
1196
|
+
if (t && t.setAttribute("aria-expanded", "true"), this.#I(), this.#a)
|
|
1197
|
+
this.#u(0);
|
|
1198
|
+
else {
|
|
1199
|
+
const e = this.getAttribute("value");
|
|
1200
|
+
if (e) {
|
|
1201
|
+
const i = this.$$('[data-ry-target="option"]:not([data-disabled])').findIndex((r) => r.dataset.value === e);
|
|
1202
|
+
i >= 0 && this.#u(i);
|
|
1203
|
+
} else
|
|
1204
|
+
this.#u(0);
|
|
1205
|
+
}
|
|
849
1206
|
this.emit("open");
|
|
850
1207
|
}
|
|
851
|
-
#
|
|
1208
|
+
#I() {
|
|
852
1209
|
const t = this.$('[data-ry-target="dropdown"]');
|
|
853
1210
|
if (!t) return;
|
|
854
1211
|
this.removeAttribute("data-ry-position");
|
|
@@ -867,110 +1224,38 @@ class J extends p {
|
|
|
867
1224
|
this.state === "open" ? this.close() : this.open();
|
|
868
1225
|
}
|
|
869
1226
|
get value() {
|
|
870
|
-
return this.getAttribute("value") ?? "";
|
|
1227
|
+
return this.#a ? [...this.#r].join(",") : this.getAttribute("value") ?? "";
|
|
871
1228
|
}
|
|
872
1229
|
set value(t) {
|
|
873
|
-
|
|
874
|
-
|
|
1230
|
+
if (this.#a) {
|
|
1231
|
+
this.#r.clear();
|
|
1232
|
+
for (const e of t.split(",").map((s) => s.trim()).filter(Boolean))
|
|
1233
|
+
this.#r.add(e);
|
|
1234
|
+
this.#f(), this.#v(), this.#y(), this.setAttribute("value", t);
|
|
1235
|
+
} else {
|
|
1236
|
+
const e = this.$(`[data-ry-target="option"][data-value="${t}"]`);
|
|
1237
|
+
e && this.#$(e);
|
|
1238
|
+
}
|
|
1239
|
+
}
|
|
1240
|
+
get values() {
|
|
1241
|
+
return [...this.#r];
|
|
875
1242
|
}
|
|
876
1243
|
teardown() {
|
|
877
1244
|
this.#s && clearTimeout(this.#s);
|
|
878
1245
|
}
|
|
879
1246
|
}
|
|
880
|
-
class
|
|
1247
|
+
class tt extends HTMLElement {
|
|
881
1248
|
}
|
|
882
|
-
customElements.define("ry-option",
|
|
883
|
-
customElements.define("ry-select",
|
|
884
|
-
|
|
885
|
-
// Close / X
|
|
886
|
-
close: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M18 6L6 18"/><path d="M6 6l12 12"/></svg>',
|
|
887
|
-
// Chevron down
|
|
888
|
-
"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>',
|
|
889
|
-
// Chevron up
|
|
890
|
-
"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>',
|
|
891
|
-
// Chevron right
|
|
892
|
-
"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>',
|
|
893
|
-
// Chevron left
|
|
894
|
-
"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>',
|
|
895
|
-
// Check / Checkmark
|
|
896
|
-
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>',
|
|
897
|
-
// Copy
|
|
898
|
-
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>',
|
|
899
|
-
// Sun (light mode)
|
|
900
|
-
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>',
|
|
901
|
-
// Moon (dark mode)
|
|
902
|
-
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>',
|
|
903
|
-
// Info
|
|
904
|
-
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>',
|
|
905
|
-
// Warning / Alert triangle
|
|
906
|
-
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>',
|
|
907
|
-
// Error / X circle
|
|
908
|
-
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>',
|
|
909
|
-
// Success / Check circle
|
|
910
|
-
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>',
|
|
911
|
-
// Search
|
|
912
|
-
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>',
|
|
913
|
-
// Menu / Hamburger
|
|
914
|
-
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>',
|
|
915
|
-
// Plus
|
|
916
|
-
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>',
|
|
917
|
-
// Minus
|
|
918
|
-
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>',
|
|
919
|
-
// Settings / Gear
|
|
920
|
-
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>',
|
|
921
|
-
// User
|
|
922
|
-
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>',
|
|
923
|
-
// Heart
|
|
924
|
-
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>',
|
|
925
|
-
// Star
|
|
926
|
-
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>',
|
|
927
|
-
// Trash
|
|
928
|
-
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>',
|
|
929
|
-
// Edit / Pencil
|
|
930
|
-
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>',
|
|
931
|
-
// External link
|
|
932
|
-
"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>',
|
|
933
|
-
// Download
|
|
934
|
-
download: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/></svg>',
|
|
935
|
-
// Upload
|
|
936
|
-
upload: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4"/><polyline points="17 8 12 3 7 8"/><line x1="12" y1="3" x2="12" y2="15"/></svg>',
|
|
937
|
-
// Folder (closed)
|
|
938
|
-
folder: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.93a2 2 0 0 1-1.66-.9l-.82-1.2A2 2 0 0 0 7.93 2H4a2 2 0 0 0-2 2v13c0 1.1.9 2 2 2Z"/></svg>',
|
|
939
|
-
// Folder open
|
|
940
|
-
"folder-open": '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.93a2 2 0 0 1-1.66-.9l-.82-1.2A2 2 0 0 0 7.93 2H4a2 2 0 0 0-2 2v13c0 1.1.9 2 2 2Z"/><path d="M2 10h20"/></svg>',
|
|
941
|
-
// File
|
|
942
|
-
file: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z"/><polyline points="14 2 14 8 20 8"/></svg>',
|
|
943
|
-
// Gradient: solid color
|
|
944
|
-
"gradient-solid": '<svg width="24" height="24" viewBox="0 0 24 24" fill="currentColor" stroke="none"><rect x="4" y="4" width="16" height="16" rx="2"/></svg>',
|
|
945
|
-
// Gradient: linear
|
|
946
|
-
"gradient-linear": '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="2"/><line x1="3" y1="21" x2="21" y2="3"/><line x1="3" y1="15" x2="15" y2="3"/><line x1="9" y1="21" x2="21" y2="9"/></svg>',
|
|
947
|
-
// Gradient: radial
|
|
948
|
-
"gradient-radial": '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="2"/><circle cx="12" cy="12" r="3"/><circle cx="12" cy="12" r="6.5"/></svg>',
|
|
949
|
-
// Shape: circle
|
|
950
|
-
"shape-circle": '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="9"/></svg>',
|
|
951
|
-
// Shape: ellipse
|
|
952
|
-
"shape-ellipse": '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><ellipse cx="12" cy="12" rx="10" ry="6"/></svg>'
|
|
953
|
-
};
|
|
954
|
-
function g(o) {
|
|
955
|
-
return A[o] ?? "";
|
|
956
|
-
}
|
|
957
|
-
function kt(o, t) {
|
|
958
|
-
A[o] = t;
|
|
959
|
-
}
|
|
960
|
-
function At(o) {
|
|
961
|
-
Object.assign(A, o);
|
|
962
|
-
}
|
|
963
|
-
function $t() {
|
|
964
|
-
return Object.keys(A);
|
|
965
|
-
}
|
|
966
|
-
class Q extends p {
|
|
1249
|
+
customElements.define("ry-option", tt);
|
|
1250
|
+
customElements.define("ry-select", Q);
|
|
1251
|
+
class et extends u {
|
|
967
1252
|
#t = "";
|
|
968
1253
|
static get observedAttributes() {
|
|
969
1254
|
return ["language", "title", "line-numbers"];
|
|
970
1255
|
}
|
|
971
1256
|
setup() {
|
|
972
1257
|
const t = this.querySelector("template");
|
|
973
|
-
t ? this.#t = this.#
|
|
1258
|
+
t ? this.#t = this.#n(t.innerHTML) : this.#t = this.textContent?.trim() ?? "", this.#e();
|
|
974
1259
|
const e = this.$('[data-ry-target="copy"]');
|
|
975
1260
|
e && this.on(e, "click", this.#i);
|
|
976
1261
|
}
|
|
@@ -981,7 +1266,7 @@ class Q extends p {
|
|
|
981
1266
|
<div data-ry-target="header" class="ry-code__header">
|
|
982
1267
|
<span data-ry-target="title" class="ry-code__title">${e}</span>
|
|
983
1268
|
<button data-ry-target="copy" class="ry-code__copy" type="button" aria-label="Copy code">
|
|
984
|
-
${
|
|
1269
|
+
${p("copy")}
|
|
985
1270
|
</button>
|
|
986
1271
|
</div>
|
|
987
1272
|
<div data-ry-target="content" class="ry-code__content">
|
|
@@ -993,8 +1278,8 @@ class Q extends p {
|
|
|
993
1278
|
const t = this.$('[data-ry-target="copy"]');
|
|
994
1279
|
if (t)
|
|
995
1280
|
try {
|
|
996
|
-
await navigator.clipboard.writeText(this.#t), t.innerHTML =
|
|
997
|
-
t.innerHTML =
|
|
1281
|
+
await navigator.clipboard.writeText(this.#t), t.innerHTML = p("check"), t.classList.add("ry-code__copy--success"), this.emit("copy", { code: this.#t }), setTimeout(() => {
|
|
1282
|
+
t.innerHTML = p("copy"), t.classList.remove("ry-code__copy--success");
|
|
998
1283
|
}, 2e3);
|
|
999
1284
|
} catch {
|
|
1000
1285
|
this.emit("copy-error");
|
|
@@ -1006,13 +1291,13 @@ class Q extends p {
|
|
|
1006
1291
|
return this.#r(t);
|
|
1007
1292
|
case "js":
|
|
1008
1293
|
case "javascript":
|
|
1009
|
-
return this.#
|
|
1294
|
+
return this.#a(t);
|
|
1010
1295
|
case "html":
|
|
1011
|
-
return this.#
|
|
1296
|
+
return this.#o(t);
|
|
1012
1297
|
case "json":
|
|
1013
|
-
return this.#
|
|
1298
|
+
return this.#c(t);
|
|
1014
1299
|
default:
|
|
1015
|
-
return this.#
|
|
1300
|
+
return this.#d(t);
|
|
1016
1301
|
}
|
|
1017
1302
|
}
|
|
1018
1303
|
#r(t) {
|
|
@@ -1020,9 +1305,9 @@ class Q extends p {
|
|
|
1020
1305
|
let s = t;
|
|
1021
1306
|
for (; s.length > 0; ) {
|
|
1022
1307
|
if (s.startsWith("/*")) {
|
|
1023
|
-
const
|
|
1024
|
-
if (
|
|
1025
|
-
e.push({ type: "comment", value: s.slice(0,
|
|
1308
|
+
const y = s.indexOf("*/");
|
|
1309
|
+
if (y !== -1) {
|
|
1310
|
+
e.push({ type: "comment", value: s.slice(0, y + 2) }), s = s.slice(y + 2);
|
|
1026
1311
|
continue;
|
|
1027
1312
|
}
|
|
1028
1313
|
}
|
|
@@ -1046,9 +1331,9 @@ class Q extends p {
|
|
|
1046
1331
|
e.push({ type: "color", value: n[1], color: n[1] }), s = s.slice(n[1].length);
|
|
1047
1332
|
continue;
|
|
1048
1333
|
}
|
|
1049
|
-
const
|
|
1050
|
-
if (
|
|
1051
|
-
e.push({ type: "number", value:
|
|
1334
|
+
const o = s.match(/^(-?[\d.]+(?:px|em|rem|%|vh|vw|deg|s|ms)?)/);
|
|
1335
|
+
if (o?.[1]) {
|
|
1336
|
+
e.push({ type: "number", value: o[1] }), s = s.slice(o[1].length);
|
|
1052
1337
|
continue;
|
|
1053
1338
|
}
|
|
1054
1339
|
const l = s.match(/^(['"])((?:[^\\]|\\.)*?)\1/);
|
|
@@ -1066,18 +1351,18 @@ class Q extends p {
|
|
|
1066
1351
|
e.push({ type: "text", value: d[1] }), s = s.slice(d[1].length);
|
|
1067
1352
|
continue;
|
|
1068
1353
|
}
|
|
1069
|
-
const
|
|
1070
|
-
if (
|
|
1071
|
-
const
|
|
1072
|
-
["inherit", "initial", "unset", "none", "auto", "transparent", "solid", "dashed", "dotted", "flex", "grid", "block", "inline", "inline-block", "absolute", "relative", "fixed", "sticky"].includes(
|
|
1354
|
+
const g = s.match(/^([\w-]+)/);
|
|
1355
|
+
if (g?.[1]) {
|
|
1356
|
+
const y = g[1];
|
|
1357
|
+
["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);
|
|
1073
1358
|
continue;
|
|
1074
1359
|
}
|
|
1075
1360
|
const b = s[0];
|
|
1076
1361
|
b && e.push({ type: "text", value: b }), s = s.slice(1);
|
|
1077
1362
|
}
|
|
1078
|
-
return e.map((i) => this.#
|
|
1363
|
+
return e.map((i) => this.#h(i)).join("");
|
|
1079
1364
|
}
|
|
1080
|
-
#
|
|
1365
|
+
#a(t) {
|
|
1081
1366
|
const e = [];
|
|
1082
1367
|
let s = t;
|
|
1083
1368
|
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"];
|
|
@@ -1116,9 +1401,9 @@ class Q extends p {
|
|
|
1116
1401
|
i.includes(d) ? e.push({ type: "keyword", value: d }) : e.push({ type: "text", value: d }), s = s.slice(d.length);
|
|
1117
1402
|
continue;
|
|
1118
1403
|
}
|
|
1119
|
-
const
|
|
1120
|
-
if (
|
|
1121
|
-
e.push({ type: "punctuation", value:
|
|
1404
|
+
const o = s[0];
|
|
1405
|
+
if (o && /^[{}[\]();,.:?!<>=+\-*/&|^%~@#]/.test(o)) {
|
|
1406
|
+
e.push({ type: "punctuation", value: o }), s = s.slice(1);
|
|
1122
1407
|
continue;
|
|
1123
1408
|
}
|
|
1124
1409
|
const l = s.match(/^(\s+)/);
|
|
@@ -1129,9 +1414,9 @@ class Q extends p {
|
|
|
1129
1414
|
const c = s[0];
|
|
1130
1415
|
c && e.push({ type: "text", value: c }), s = s.slice(1);
|
|
1131
1416
|
}
|
|
1132
|
-
return e.map((r) => this.#
|
|
1417
|
+
return e.map((r) => this.#h(r)).join("");
|
|
1133
1418
|
}
|
|
1134
|
-
#
|
|
1419
|
+
#o(t) {
|
|
1135
1420
|
const e = [];
|
|
1136
1421
|
let s = t;
|
|
1137
1422
|
for (; s.length > 0; ) {
|
|
@@ -1167,17 +1452,17 @@ class Q extends p {
|
|
|
1167
1452
|
e.push({ type: "text", value: n[1] }), s = s.slice(n[1].length);
|
|
1168
1453
|
continue;
|
|
1169
1454
|
}
|
|
1170
|
-
const
|
|
1171
|
-
if (
|
|
1172
|
-
e.push({ type: "text", value:
|
|
1455
|
+
const o = s.match(/^([^<]+)/);
|
|
1456
|
+
if (o?.[1]) {
|
|
1457
|
+
e.push({ type: "text", value: o[1] }), s = s.slice(o[1].length);
|
|
1173
1458
|
continue;
|
|
1174
1459
|
}
|
|
1175
1460
|
const l = s[0];
|
|
1176
1461
|
l && e.push({ type: "text", value: l }), s = s.slice(1);
|
|
1177
1462
|
}
|
|
1178
|
-
return e.map((i) => this.#
|
|
1463
|
+
return e.map((i) => this.#h(i)).join("");
|
|
1179
1464
|
}
|
|
1180
|
-
#
|
|
1465
|
+
#c(t) {
|
|
1181
1466
|
const e = [];
|
|
1182
1467
|
let s = t;
|
|
1183
1468
|
for (; s.length > 0; ) {
|
|
@@ -1201,18 +1486,18 @@ class Q extends p {
|
|
|
1201
1486
|
e.push({ type: "punctuation", value: n }), s = s.slice(1);
|
|
1202
1487
|
continue;
|
|
1203
1488
|
}
|
|
1204
|
-
const
|
|
1205
|
-
if (
|
|
1206
|
-
e.push({ type: "text", value:
|
|
1489
|
+
const o = s.match(/^(\s+)/);
|
|
1490
|
+
if (o?.[1]) {
|
|
1491
|
+
e.push({ type: "text", value: o[1] }), s = s.slice(o[1].length);
|
|
1207
1492
|
continue;
|
|
1208
1493
|
}
|
|
1209
1494
|
const l = s[0];
|
|
1210
1495
|
l && e.push({ type: "text", value: l }), s = s.slice(1);
|
|
1211
1496
|
}
|
|
1212
|
-
return e.map((i) => this.#
|
|
1497
|
+
return e.map((i) => this.#h(i)).join("");
|
|
1213
1498
|
}
|
|
1214
|
-
#
|
|
1215
|
-
const e = this.#
|
|
1499
|
+
#h(t) {
|
|
1500
|
+
const e = this.#d(t.value);
|
|
1216
1501
|
switch (t.type) {
|
|
1217
1502
|
case "keyword":
|
|
1218
1503
|
return `<span class="ry-code__keyword">${e}</span>`;
|
|
@@ -1240,10 +1525,10 @@ class Q extends p {
|
|
|
1240
1525
|
return e;
|
|
1241
1526
|
}
|
|
1242
1527
|
}
|
|
1243
|
-
#
|
|
1528
|
+
#d(t) {
|
|
1244
1529
|
return t.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
1245
1530
|
}
|
|
1246
|
-
#
|
|
1531
|
+
#n(t) {
|
|
1247
1532
|
const e = t.split(`
|
|
1248
1533
|
`);
|
|
1249
1534
|
for (; e.length && !e[0]?.trim(); ) e.shift();
|
|
@@ -1262,8 +1547,8 @@ class Q extends p {
|
|
|
1262
1547
|
this.#t = t, this.#e();
|
|
1263
1548
|
}
|
|
1264
1549
|
}
|
|
1265
|
-
customElements.define("ry-code",
|
|
1266
|
-
class
|
|
1550
|
+
customElements.define("ry-code", et);
|
|
1551
|
+
class st extends u {
|
|
1267
1552
|
setup() {
|
|
1268
1553
|
const t = this.$("template");
|
|
1269
1554
|
if (!t) return;
|
|
@@ -1275,8 +1560,8 @@ class tt extends p {
|
|
|
1275
1560
|
`, a && this.setAttribute("data-stacked", "");
|
|
1276
1561
|
const n = document.createElement("ry-code");
|
|
1277
1562
|
n.setAttribute("language", "html"), n.setAttribute("title", this.getAttribute("title") ?? "Example"), n.textContent = i, this.$('[data-ry-target="code"]').appendChild(n);
|
|
1278
|
-
const
|
|
1279
|
-
|
|
1563
|
+
const o = document.createElement("template");
|
|
1564
|
+
o.innerHTML = r, this.$('[data-ry-target="preview"]').appendChild(o.content), s && this.#t(s);
|
|
1280
1565
|
}
|
|
1281
1566
|
#t(t) {
|
|
1282
1567
|
const e = this.$('[data-ry-target="usage"]');
|
|
@@ -1307,8 +1592,8 @@ class tt extends p {
|
|
|
1307
1592
|
`).trim();
|
|
1308
1593
|
}
|
|
1309
1594
|
}
|
|
1310
|
-
customElements.define("ry-example",
|
|
1311
|
-
class
|
|
1595
|
+
customElements.define("ry-example", st);
|
|
1596
|
+
class it extends u {
|
|
1312
1597
|
static get observedAttributes() {
|
|
1313
1598
|
return ["name", "size", "label"];
|
|
1314
1599
|
}
|
|
@@ -1319,7 +1604,7 @@ class et extends p {
|
|
|
1319
1604
|
e !== s && this.hasAttribute("data-ry-initialized") && this.#t();
|
|
1320
1605
|
}
|
|
1321
1606
|
#t() {
|
|
1322
|
-
const t = this.getAttribute("name") ?? "", e = this.getAttribute("size") ?? "24", s = this.getAttribute("label"), i =
|
|
1607
|
+
const t = this.getAttribute("name") ?? "", e = this.getAttribute("size") ?? "24", s = this.getAttribute("label"), i = p(t);
|
|
1323
1608
|
if (!i) {
|
|
1324
1609
|
this.innerHTML = "";
|
|
1325
1610
|
return;
|
|
@@ -1341,24 +1626,24 @@ class et extends p {
|
|
|
1341
1626
|
this.setAttribute("size", String(t));
|
|
1342
1627
|
}
|
|
1343
1628
|
}
|
|
1344
|
-
customElements.define("ry-icon",
|
|
1345
|
-
const
|
|
1346
|
-
function
|
|
1347
|
-
let t =
|
|
1629
|
+
customElements.define("ry-icon", it);
|
|
1630
|
+
const rt = ["form", "section", "fieldset", "ry-section"], m = /* @__PURE__ */ new Map(), E = /* @__PURE__ */ new Set();
|
|
1631
|
+
function at(h) {
|
|
1632
|
+
let t = h.parentElement;
|
|
1348
1633
|
for (; t; ) {
|
|
1349
|
-
if (
|
|
1634
|
+
if (rt.some((e) => t.matches(e)))
|
|
1350
1635
|
return t;
|
|
1351
1636
|
t = t.parentElement;
|
|
1352
1637
|
}
|
|
1353
1638
|
return null;
|
|
1354
1639
|
}
|
|
1355
|
-
function
|
|
1356
|
-
if (E.has(
|
|
1357
|
-
const t =
|
|
1640
|
+
function nt(h) {
|
|
1641
|
+
if (E.has(h)) return;
|
|
1642
|
+
const t = m.get(h);
|
|
1358
1643
|
if (!t || t.size < 2) return;
|
|
1359
1644
|
const e = /* @__PURE__ */ new Map();
|
|
1360
1645
|
for (const s of t) {
|
|
1361
|
-
const i =
|
|
1646
|
+
const i = at(s), r = e.get(i) ?? [];
|
|
1362
1647
|
r.push(s), e.set(i, r);
|
|
1363
1648
|
}
|
|
1364
1649
|
if (e.size > 1) {
|
|
@@ -1370,11 +1655,11 @@ function rt(o) {
|
|
|
1370
1655
|
} else
|
|
1371
1656
|
s.push("(no container)");
|
|
1372
1657
|
console.warn(
|
|
1373
|
-
`ry-toggle-button: Buttons with name="${
|
|
1374
|
-
), E.add(
|
|
1658
|
+
`ry-toggle-button: Buttons with name="${h}" span multiple containers (${s.join(", ")}). Intentional?`
|
|
1659
|
+
), E.add(h);
|
|
1375
1660
|
}
|
|
1376
1661
|
}
|
|
1377
|
-
class
|
|
1662
|
+
class ot extends u {
|
|
1378
1663
|
static observedAttributes = ["pressed", "disabled", "name", "value"];
|
|
1379
1664
|
#t = !1;
|
|
1380
1665
|
setup() {
|
|
@@ -1385,12 +1670,12 @@ class at extends p {
|
|
|
1385
1670
|
}
|
|
1386
1671
|
#e() {
|
|
1387
1672
|
const t = this.name;
|
|
1388
|
-
t && (
|
|
1673
|
+
t && (m.has(t) || m.set(t, /* @__PURE__ */ new Set()), m.get(t).add(this), this.#t = !0, queueMicrotask(() => nt(t)));
|
|
1389
1674
|
}
|
|
1390
1675
|
#i() {
|
|
1391
1676
|
if (!this.#t) return;
|
|
1392
1677
|
const t = this.name;
|
|
1393
|
-
t &&
|
|
1678
|
+
t && m.has(t) && (m.get(t).delete(this), m.get(t).size === 0 && (m.delete(t), E.delete(t))), this.#t = !1;
|
|
1394
1679
|
}
|
|
1395
1680
|
#s = (t) => {
|
|
1396
1681
|
if (this.disabled) {
|
|
@@ -1402,10 +1687,10 @@ class at extends p {
|
|
|
1402
1687
|
#r = (t) => {
|
|
1403
1688
|
(t.key === "Enter" || t.key === " ") && (t.preventDefault(), this.click());
|
|
1404
1689
|
};
|
|
1405
|
-
#
|
|
1690
|
+
#a() {
|
|
1406
1691
|
const t = this.name;
|
|
1407
1692
|
if (!t) return;
|
|
1408
|
-
const e =
|
|
1693
|
+
const e = m.get(t);
|
|
1409
1694
|
if (e)
|
|
1410
1695
|
for (const s of e)
|
|
1411
1696
|
s !== this && s.pressed && (s.pressed = !1);
|
|
@@ -1416,7 +1701,7 @@ class at extends p {
|
|
|
1416
1701
|
}
|
|
1417
1702
|
set pressed(t) {
|
|
1418
1703
|
const e = this.pressed;
|
|
1419
|
-
t ? (this.setAttribute("pressed", ""), this.setAttribute("aria-pressed", "true"), this.#
|
|
1704
|
+
t ? (this.setAttribute("pressed", ""), this.setAttribute("aria-pressed", "true"), this.#a()) : (this.removeAttribute("pressed"), this.setAttribute("aria-pressed", "false")), e !== t && this.emit("change", {
|
|
1420
1705
|
value: this.value,
|
|
1421
1706
|
label: t ? "pressed" : "unpressed"
|
|
1422
1707
|
});
|
|
@@ -1446,19 +1731,19 @@ class at extends p {
|
|
|
1446
1731
|
this.setAttribute("icon", t);
|
|
1447
1732
|
}
|
|
1448
1733
|
}
|
|
1449
|
-
customElements.define("ry-toggle-button",
|
|
1450
|
-
class
|
|
1734
|
+
customElements.define("ry-toggle-button", ot);
|
|
1735
|
+
class ht extends u {
|
|
1451
1736
|
#t = !1;
|
|
1452
1737
|
#e = null;
|
|
1453
1738
|
#i = null;
|
|
1454
1739
|
#s = null;
|
|
1455
1740
|
#r = /* @__PURE__ */ new Map();
|
|
1456
|
-
#
|
|
1741
|
+
#a = /* @__PURE__ */ new Map();
|
|
1457
1742
|
static observedAttributes = ["min", "max", "step", "value", "start", "end", "disabled"];
|
|
1458
1743
|
setup() {
|
|
1459
|
-
this.#
|
|
1744
|
+
this.#o(), this.#h(), this.#f();
|
|
1460
1745
|
}
|
|
1461
|
-
#
|
|
1746
|
+
#o() {
|
|
1462
1747
|
const t = this.hasAttribute("range"), e = this.hasAttribute("labeled"), s = this.hasAttribute("tooltip");
|
|
1463
1748
|
this.hasAttribute("vertical");
|
|
1464
1749
|
let i = `
|
|
@@ -1476,16 +1761,16 @@ class nt extends p {
|
|
|
1476
1761
|
<div data-ry-target="thumb-value" class="ry-slider__thumb" tabindex="0" role="slider" aria-label="Value">
|
|
1477
1762
|
${s ? '<span data-ry-target="tooltip-value" class="ry-slider__tooltip"></span>' : ""}
|
|
1478
1763
|
</div>
|
|
1479
|
-
`, i += "</div>", e && (i += this.#
|
|
1764
|
+
`, i += "</div>", e && (i += this.#c()), this.innerHTML = i, this.#i = this.$('[data-ry-target="track"]'), this.#s = this.$('[data-ry-target="fill"]'), t ? (this.#r.set("start", this.$('[data-ry-target="thumb-start"]')), this.#r.set("end", this.$('[data-ry-target="thumb-end"]')), s && (this.#a.set("start", this.$('[data-ry-target="tooltip-start"]')), this.#a.set("end", this.$('[data-ry-target="tooltip-end"]')))) : (this.#r.set("value", this.$('[data-ry-target="thumb-value"]')), s && this.#a.set("value", this.$('[data-ry-target="tooltip-value"]')));
|
|
1480
1765
|
}
|
|
1481
|
-
#
|
|
1766
|
+
#c() {
|
|
1482
1767
|
const t = this.min, e = this.max, s = this.getAttribute("labels")?.split(","), i = this.getAttribute("label-type") || "number";
|
|
1483
1768
|
let r = [];
|
|
1484
1769
|
if (s)
|
|
1485
1770
|
r = s;
|
|
1486
1771
|
else
|
|
1487
1772
|
for (let n = 0; n < 5; n++) {
|
|
1488
|
-
const
|
|
1773
|
+
const o = n / 4, l = t + o * (e - t);
|
|
1489
1774
|
if (i === "letter")
|
|
1490
1775
|
r.push(String.fromCharCode(65 + n));
|
|
1491
1776
|
else {
|
|
@@ -1499,32 +1784,32 @@ class nt extends p {
|
|
|
1499
1784
|
</div>
|
|
1500
1785
|
`;
|
|
1501
1786
|
}
|
|
1502
|
-
#
|
|
1503
|
-
this.#i && this.on(this.#i, "pointerdown", this.#
|
|
1787
|
+
#h() {
|
|
1788
|
+
this.#i && this.on(this.#i, "pointerdown", this.#d);
|
|
1504
1789
|
for (const [t, e] of this.#r)
|
|
1505
|
-
this.on(e, "pointerdown", (s) => this.#
|
|
1506
|
-
this.on(document, "pointermove", this.#
|
|
1790
|
+
this.on(e, "pointerdown", (s) => this.#n(s, t)), this.on(e, "keydown", (s) => this.#m(s, t));
|
|
1791
|
+
this.on(document, "pointermove", this.#p), this.on(document, "pointerup", this.#u);
|
|
1507
1792
|
}
|
|
1508
|
-
#
|
|
1793
|
+
#d = (t) => {
|
|
1509
1794
|
if (this.disabled) return;
|
|
1510
|
-
const e = this.#
|
|
1795
|
+
const e = this.#k(t);
|
|
1511
1796
|
if (this.hasAttribute("range")) {
|
|
1512
1797
|
const i = Math.abs(e - this.start), r = Math.abs(e - this.end);
|
|
1513
1798
|
i < r ? (this.start = e, this.#e = "start") : (this.end = e, this.#e = "end");
|
|
1514
1799
|
} else
|
|
1515
1800
|
this.value = e, this.#e = "value";
|
|
1516
|
-
this.#t = !0, this.#
|
|
1801
|
+
this.#t = !0, this.#f(), this.#y();
|
|
1517
1802
|
};
|
|
1518
|
-
#
|
|
1803
|
+
#n = (t, e) => {
|
|
1519
1804
|
this.disabled || (t.stopPropagation(), this.#t = !0, this.#e = e, t.target.setPointerCapture(t.pointerId));
|
|
1520
1805
|
};
|
|
1521
|
-
#
|
|
1806
|
+
#p = (t) => {
|
|
1522
1807
|
if (!this.#t || !this.#e) return;
|
|
1523
|
-
const e = this.#
|
|
1524
|
-
this.hasAttribute("range") ? this.#e === "start" ? this.start = Math.min(e, this.end) : this.#e === "end" && (this.end = Math.max(e, this.start)) : this.value = e, this.#
|
|
1808
|
+
const e = this.#k(t);
|
|
1809
|
+
this.hasAttribute("range") ? this.#e === "start" ? this.start = Math.min(e, this.end) : this.#e === "end" && (this.end = Math.max(e, this.start)) : this.value = e, this.#f(), this.#y();
|
|
1525
1810
|
};
|
|
1526
|
-
#
|
|
1527
|
-
this.#t && (this.#t = !1, this.#e = null, this.#
|
|
1811
|
+
#u = () => {
|
|
1812
|
+
this.#t && (this.#t = !1, this.#e = null, this.#M());
|
|
1528
1813
|
};
|
|
1529
1814
|
#m = (t, e) => {
|
|
1530
1815
|
if (this.disabled) return;
|
|
@@ -1546,66 +1831,66 @@ class nt extends p {
|
|
|
1546
1831
|
r = -i;
|
|
1547
1832
|
break;
|
|
1548
1833
|
case "Home":
|
|
1549
|
-
r = this.min - this.#
|
|
1834
|
+
r = this.min - this.#b(e);
|
|
1550
1835
|
break;
|
|
1551
1836
|
case "End":
|
|
1552
|
-
r = this.max - this.#
|
|
1837
|
+
r = this.max - this.#b(e);
|
|
1553
1838
|
break;
|
|
1554
1839
|
default:
|
|
1555
1840
|
return;
|
|
1556
1841
|
}
|
|
1557
1842
|
t.preventDefault();
|
|
1558
|
-
const a = this.#
|
|
1559
|
-
e === "start" ? this.start = Math.min(a, this.end) : e === "end" ? this.end = Math.max(a, this.start) : this.value = a, this.#
|
|
1843
|
+
const a = this.#l(this.#b(e) + r);
|
|
1844
|
+
e === "start" ? this.start = Math.min(a, this.end) : e === "end" ? this.end = Math.max(a, this.start) : this.value = a, this.#f(), this.#y(), this.#M();
|
|
1560
1845
|
};
|
|
1561
|
-
#
|
|
1846
|
+
#b(t) {
|
|
1562
1847
|
return t === "start" ? this.start : t === "end" ? this.end : this.value;
|
|
1563
1848
|
}
|
|
1564
|
-
#
|
|
1849
|
+
#k(t) {
|
|
1565
1850
|
if (!this.#i) return this.min;
|
|
1566
1851
|
const e = this.#i.getBoundingClientRect(), s = this.hasAttribute("vertical"), i = this.hasAttribute("reversed");
|
|
1567
1852
|
let r;
|
|
1568
1853
|
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));
|
|
1569
1854
|
const a = this.min + r * (this.max - this.min);
|
|
1570
|
-
return this.#
|
|
1855
|
+
return this.#g(a);
|
|
1571
1856
|
}
|
|
1572
|
-
#
|
|
1857
|
+
#g(t) {
|
|
1573
1858
|
const e = this.step;
|
|
1574
|
-
if (e === 0) return this.#
|
|
1859
|
+
if (e === 0) return this.#l(t);
|
|
1575
1860
|
const s = Math.round((t - this.min) / e) * e + this.min;
|
|
1576
|
-
return this.#
|
|
1861
|
+
return this.#l(s);
|
|
1577
1862
|
}
|
|
1578
|
-
#
|
|
1863
|
+
#l(t) {
|
|
1579
1864
|
return Math.max(this.min, Math.min(this.max, t));
|
|
1580
1865
|
}
|
|
1581
|
-
#
|
|
1866
|
+
#f() {
|
|
1582
1867
|
const t = this.hasAttribute("range"), e = this.hasAttribute("vertical"), s = this.hasAttribute("reversed"), i = (r) => {
|
|
1583
1868
|
let a = (r - this.min) / (this.max - this.min) * 100;
|
|
1584
1869
|
return s && (a = 100 - a), a;
|
|
1585
1870
|
};
|
|
1586
1871
|
if (t) {
|
|
1587
|
-
const r = i(this.start), a = i(this.end), n = Math.min(r, a),
|
|
1588
|
-
this.#s && (e ? (this.#s.style.bottom = `${n}%`, this.#s.style.height = `${
|
|
1872
|
+
const r = i(this.start), a = i(this.end), n = Math.min(r, a), o = Math.max(r, a);
|
|
1873
|
+
this.#s && (e ? (this.#s.style.bottom = `${n}%`, this.#s.style.height = `${o - n}%`, this.#s.style.left = "", this.#s.style.width = "") : (this.#s.style.left = `${n}%`, this.#s.style.width = `${o - n}%`, this.#s.style.bottom = "", this.#s.style.height = ""));
|
|
1589
1874
|
const l = this.#r.get("start"), c = this.#r.get("end");
|
|
1590
|
-
l && (e ? (l.style.bottom = `${r}%`, l.style.left = "") : (l.style.left = `${r}%`, l.style.bottom = "")), c && (e ? (c.style.bottom = `${a}%`, c.style.left = "") : (c.style.left = `${a}%`, c.style.bottom = "")), this.#
|
|
1875
|
+
l && (e ? (l.style.bottom = `${r}%`, l.style.left = "") : (l.style.left = `${r}%`, l.style.bottom = "")), c && (e ? (c.style.bottom = `${a}%`, c.style.left = "") : (c.style.left = `${a}%`, c.style.bottom = "")), this.#v("start", this.start), this.#v("end", this.end), l?.setAttribute("aria-valuenow", String(this.start)), l?.setAttribute("aria-valuemin", String(this.min)), l?.setAttribute("aria-valuemax", String(this.end)), c?.setAttribute("aria-valuenow", String(this.end)), c?.setAttribute("aria-valuemin", String(this.start)), c?.setAttribute("aria-valuemax", String(this.max));
|
|
1591
1876
|
} else {
|
|
1592
1877
|
const r = i(this.value);
|
|
1593
1878
|
this.#s && (e ? (this.#s.style.bottom = "0", this.#s.style.height = `${r}%`, this.#s.style.left = "", this.#s.style.width = "") : (this.#s.style.left = "0", this.#s.style.width = `${r}%`, this.#s.style.bottom = "", this.#s.style.height = ""));
|
|
1594
1879
|
const a = this.#r.get("value");
|
|
1595
|
-
a && (e ? (a.style.bottom = `${r}%`, a.style.left = "") : (a.style.left = `${r}%`, a.style.bottom = "")), this.#
|
|
1880
|
+
a && (e ? (a.style.bottom = `${r}%`, a.style.left = "") : (a.style.left = `${r}%`, a.style.bottom = "")), this.#v("value", this.value), a?.setAttribute("aria-valuenow", String(this.value)), a?.setAttribute("aria-valuemin", String(this.min)), a?.setAttribute("aria-valuemax", String(this.max));
|
|
1596
1881
|
}
|
|
1597
1882
|
}
|
|
1598
|
-
#
|
|
1599
|
-
const s = this.#
|
|
1883
|
+
#v(t, e) {
|
|
1884
|
+
const s = this.#a.get(t);
|
|
1600
1885
|
if (s) {
|
|
1601
1886
|
const i = this.step === 0 ? 2 : String(this.step).split(".")[1]?.length || 0;
|
|
1602
1887
|
s.textContent = e.toFixed(i);
|
|
1603
1888
|
}
|
|
1604
1889
|
}
|
|
1605
|
-
#
|
|
1890
|
+
#y() {
|
|
1606
1891
|
this.hasAttribute("range") ? this.emit("input", { start: this.start, end: this.end }) : this.emit("input", { value: this.value });
|
|
1607
1892
|
}
|
|
1608
|
-
#
|
|
1893
|
+
#M() {
|
|
1609
1894
|
this.hasAttribute("range") ? this.emit("change", { start: this.start, end: this.end }) : this.emit("change", { value: this.value });
|
|
1610
1895
|
}
|
|
1611
1896
|
// --- Public API ---
|
|
@@ -1631,19 +1916,19 @@ class nt extends p {
|
|
|
1631
1916
|
return parseFloat(this.getAttribute("value") ?? String(this.min));
|
|
1632
1917
|
}
|
|
1633
1918
|
set value(t) {
|
|
1634
|
-
this.setAttribute("value", String(this.#
|
|
1919
|
+
this.setAttribute("value", String(this.#l(t)));
|
|
1635
1920
|
}
|
|
1636
1921
|
get start() {
|
|
1637
1922
|
return parseFloat(this.getAttribute("start") ?? String(this.min));
|
|
1638
1923
|
}
|
|
1639
1924
|
set start(t) {
|
|
1640
|
-
this.setAttribute("start", String(this.#
|
|
1925
|
+
this.setAttribute("start", String(this.#l(t)));
|
|
1641
1926
|
}
|
|
1642
1927
|
get end() {
|
|
1643
1928
|
return parseFloat(this.getAttribute("end") ?? String(this.max));
|
|
1644
1929
|
}
|
|
1645
1930
|
set end(t) {
|
|
1646
|
-
this.setAttribute("end", String(this.#
|
|
1931
|
+
this.setAttribute("end", String(this.#l(t)));
|
|
1647
1932
|
}
|
|
1648
1933
|
get disabled() {
|
|
1649
1934
|
return this.hasAttribute("disabled");
|
|
@@ -1652,19 +1937,19 @@ class nt extends p {
|
|
|
1652
1937
|
t ? this.setAttribute("disabled", "") : this.removeAttribute("disabled");
|
|
1653
1938
|
}
|
|
1654
1939
|
}
|
|
1655
|
-
customElements.define("ry-slider",
|
|
1656
|
-
class
|
|
1940
|
+
customElements.define("ry-slider", ht);
|
|
1941
|
+
class lt extends u {
|
|
1657
1942
|
#t = !1;
|
|
1658
1943
|
#e = 0;
|
|
1659
1944
|
#i = 0;
|
|
1660
1945
|
#s = null;
|
|
1661
1946
|
#r = null;
|
|
1662
|
-
#
|
|
1947
|
+
#a = null;
|
|
1663
1948
|
static observedAttributes = ["min", "max", "step", "value", "disabled", "label", "labels", "description"];
|
|
1664
1949
|
setup() {
|
|
1665
|
-
this.#
|
|
1950
|
+
this.#o(), this.#c(), this.#l();
|
|
1666
1951
|
}
|
|
1667
|
-
#
|
|
1952
|
+
#o() {
|
|
1668
1953
|
const t = this.getAttribute("label"), e = this.getAttribute("description"), s = e ? ` title="${e}"` : "";
|
|
1669
1954
|
this.innerHTML = `
|
|
1670
1955
|
<div data-ry-target="ring" class="ry-knob__ring"${s}>
|
|
@@ -1674,43 +1959,43 @@ class ot extends p {
|
|
|
1674
1959
|
</div>
|
|
1675
1960
|
<span data-ry-target="display" class="ry-knob__value"></span>
|
|
1676
1961
|
${t ? `<span data-ry-target="label" class="ry-knob__label"${s}>${t}</span>` : ""}
|
|
1677
|
-
`, this.#s = this.$('[data-ry-target="ring"]'), this.#r = this.$('[data-ry-target="indicator"]'), this.#
|
|
1962
|
+
`, this.#s = this.$('[data-ry-target="ring"]'), this.#r = this.$('[data-ry-target="indicator"]'), this.#a = this.$('[data-ry-target="display"]');
|
|
1678
1963
|
}
|
|
1679
|
-
#
|
|
1680
|
-
this.#s && (this.on(this.#s, "mousedown", this.#
|
|
1964
|
+
#c() {
|
|
1965
|
+
this.#s && (this.on(this.#s, "mousedown", this.#h), this.on(document, "mousemove", this.#d), this.on(document, "mouseup", this.#n), this.on(this.#s, "touchstart", this.#p), this.on(document, "touchmove", this.#u), this.on(document, "touchend", this.#m), this.on(this.#s, "wheel", this.#b), this.on(this, "keydown", this.#k));
|
|
1681
1966
|
}
|
|
1682
|
-
#
|
|
1967
|
+
#h = (t) => {
|
|
1683
1968
|
this.disabled || (t.preventDefault(), this.#t = !0, this.#e = t.clientY, this.#i = this.value, this.#s?.classList.add("ry-knob__ring--dragging"), this.setAttribute("data-dragging", ""));
|
|
1684
1969
|
};
|
|
1685
|
-
#
|
|
1970
|
+
#d = (t) => {
|
|
1686
1971
|
if (!this.#t) return;
|
|
1687
1972
|
const e = this.#e - t.clientY, s = (this.max - this.min) / 100;
|
|
1688
|
-
this.#
|
|
1973
|
+
this.#g(this.#i + e * s);
|
|
1689
1974
|
};
|
|
1690
|
-
#
|
|
1691
|
-
this.#t && (this.#t = !1, this.#s?.classList.remove("ry-knob__ring--dragging"), this.removeAttribute("data-dragging"), this.#
|
|
1975
|
+
#n = () => {
|
|
1976
|
+
this.#t && (this.#t = !1, this.#s?.classList.remove("ry-knob__ring--dragging"), this.removeAttribute("data-dragging"), this.#y());
|
|
1692
1977
|
};
|
|
1693
|
-
#
|
|
1978
|
+
#p = (t) => {
|
|
1694
1979
|
this.disabled || (t.preventDefault(), this.#t = !0, this.#e = t.touches[0]?.clientY ?? 0, this.#i = this.value, this.#s?.classList.add("ry-knob__ring--dragging"), this.setAttribute("data-dragging", ""));
|
|
1695
1980
|
};
|
|
1696
|
-
#
|
|
1981
|
+
#u = (t) => {
|
|
1697
1982
|
if (!this.#t) return;
|
|
1698
1983
|
t.preventDefault();
|
|
1699
1984
|
const e = t.touches[0];
|
|
1700
1985
|
if (!e) return;
|
|
1701
1986
|
const s = this.#e - e.clientY, i = (this.max - this.min) / 100;
|
|
1702
|
-
this.#
|
|
1987
|
+
this.#g(this.#i + s * i);
|
|
1703
1988
|
};
|
|
1704
1989
|
#m = () => {
|
|
1705
|
-
this.#t && (this.#t = !1, this.#s?.classList.remove("ry-knob__ring--dragging"), this.removeAttribute("data-dragging"), this.#
|
|
1990
|
+
this.#t && (this.#t = !1, this.#s?.classList.remove("ry-knob__ring--dragging"), this.removeAttribute("data-dragging"), this.#y());
|
|
1706
1991
|
};
|
|
1707
|
-
#
|
|
1992
|
+
#b = (t) => {
|
|
1708
1993
|
if (this.disabled) return;
|
|
1709
1994
|
t.preventDefault();
|
|
1710
1995
|
const e = this.step || (this.max - this.min) / 50, s = t.deltaY < 0 ? e : -e;
|
|
1711
|
-
this.#
|
|
1996
|
+
this.#g(this.value + s), this.#y();
|
|
1712
1997
|
};
|
|
1713
|
-
#
|
|
1998
|
+
#k = (t) => {
|
|
1714
1999
|
if (this.disabled) return;
|
|
1715
2000
|
const e = this.step || 1, s = (this.max - this.min) / 10;
|
|
1716
2001
|
let i = 0;
|
|
@@ -1730,26 +2015,26 @@ class ot extends p {
|
|
|
1730
2015
|
i = -s;
|
|
1731
2016
|
break;
|
|
1732
2017
|
case "Home":
|
|
1733
|
-
this.#
|
|
2018
|
+
this.#g(this.min), this.#y();
|
|
1734
2019
|
return;
|
|
1735
2020
|
case "End":
|
|
1736
|
-
this.#
|
|
2021
|
+
this.#g(this.max), this.#y();
|
|
1737
2022
|
return;
|
|
1738
2023
|
default:
|
|
1739
2024
|
return;
|
|
1740
2025
|
}
|
|
1741
|
-
t.preventDefault(), this.#
|
|
2026
|
+
t.preventDefault(), this.#g(this.value + i), this.#y();
|
|
1742
2027
|
};
|
|
1743
|
-
#
|
|
2028
|
+
#g(t) {
|
|
1744
2029
|
let e = Math.max(this.min, Math.min(this.max, t));
|
|
1745
2030
|
const s = this.step;
|
|
1746
|
-
s > 0 && (e = Math.round((e - this.min) / s) * s + this.min, e = Math.max(this.min, Math.min(this.max, e))), this.value = e, this.#
|
|
2031
|
+
s > 0 && (e = Math.round((e - this.min) / s) * s + this.min, e = Math.max(this.min, Math.min(this.max, e))), this.value = e, this.#l(), this.#v();
|
|
1747
2032
|
}
|
|
1748
|
-
#
|
|
2033
|
+
#l() {
|
|
1749
2034
|
const t = (this.value - this.min) / (this.max - this.min), e = -135 + t * 270;
|
|
1750
|
-
this.#s && (this.#s.style.setProperty("--knob-rotation", `${e}deg`), this.#s.style.setProperty("--knob-percent", String(t))), this.#
|
|
2035
|
+
this.#s && (this.#s.style.setProperty("--knob-rotation", `${e}deg`), this.#s.style.setProperty("--knob-percent", String(t))), this.#a && (this.#a.textContent = this.#f(this.value)), this.setAttribute("aria-valuenow", String(this.value)), this.setAttribute("aria-valuemin", String(this.min)), this.setAttribute("aria-valuemax", String(this.max));
|
|
1751
2036
|
}
|
|
1752
|
-
#
|
|
2037
|
+
#f(t) {
|
|
1753
2038
|
const e = this.getAttribute("labels");
|
|
1754
2039
|
if (e) {
|
|
1755
2040
|
const i = e.split(","), r = Math.round(t);
|
|
@@ -1757,16 +2042,16 @@ class ot extends p {
|
|
|
1757
2042
|
}
|
|
1758
2043
|
return this.step >= 1 ? Math.round(t).toString() : Math.abs(t) >= 1e3 ? (t / 1e3).toFixed(1) + "k" : Math.abs(t) >= 100 ? Math.round(t).toString() : Math.abs(t) >= 10 ? t.toFixed(1) : t.toFixed(2);
|
|
1759
2044
|
}
|
|
1760
|
-
#
|
|
2045
|
+
#v() {
|
|
1761
2046
|
const t = (this.value - this.min) / (this.max - this.min);
|
|
1762
2047
|
this.emit("input", { value: this.value, percent: t });
|
|
1763
2048
|
}
|
|
1764
|
-
#
|
|
2049
|
+
#y() {
|
|
1765
2050
|
const t = (this.value - this.min) / (this.max - this.min);
|
|
1766
2051
|
this.emit("change", { value: this.value, percent: t });
|
|
1767
2052
|
}
|
|
1768
2053
|
attributeChangedCallback(t, e, s) {
|
|
1769
|
-
e !== s && t === "value" && this.#s && this.#
|
|
2054
|
+
e !== s && t === "value" && this.#s && this.#l();
|
|
1770
2055
|
}
|
|
1771
2056
|
// --- Public API ---
|
|
1772
2057
|
get min() {
|
|
@@ -1800,118 +2085,129 @@ class ot extends p {
|
|
|
1800
2085
|
t ? this.setAttribute("disabled", "") : this.removeAttribute("disabled");
|
|
1801
2086
|
}
|
|
1802
2087
|
}
|
|
1803
|
-
customElements.define("ry-knob",
|
|
2088
|
+
customElements.define("ry-knob", lt);
|
|
1804
2089
|
const S = 15, T = 3;
|
|
1805
|
-
class
|
|
2090
|
+
class ct extends u {
|
|
1806
2091
|
#t = null;
|
|
1807
2092
|
#e = null;
|
|
1808
2093
|
#i = null;
|
|
1809
2094
|
#s = null;
|
|
1810
2095
|
#r = null;
|
|
1811
|
-
#
|
|
2096
|
+
#a = !1;
|
|
2097
|
+
#o = 0;
|
|
2098
|
+
#c = 0;
|
|
1812
2099
|
#h = 0;
|
|
1813
|
-
#
|
|
1814
|
-
#
|
|
1815
|
-
#
|
|
1816
|
-
#a = null;
|
|
1817
|
-
#u = null;
|
|
2100
|
+
#d = !1;
|
|
2101
|
+
#n = null;
|
|
2102
|
+
#p = null;
|
|
1818
2103
|
static observedAttributes = ["min", "max", "step", "value", "disabled", "arrows", "icons", "drag", "editable", "wrap", "label", "prefix", "suffix"];
|
|
1819
2104
|
setup() {
|
|
1820
|
-
this.#
|
|
2105
|
+
this.#u(), this.#b(), this.#k(), this.#A();
|
|
1821
2106
|
}
|
|
1822
|
-
#
|
|
1823
|
-
const t = this.getAttribute("arrows") ?? "both", e = this.getAttribute("label"), s = t === "stacked", [i, r] = this.#m(s), a = t
|
|
2107
|
+
#u() {
|
|
2108
|
+
const t = this.getAttribute("arrows") ?? "both", e = this.getAttribute("label"), s = t === "stacked" || t === "stacked-end" || t === "stacked-start", [i, r] = this.#m(s), a = t !== "end" && t !== "none", n = t !== "start" && t !== "none", o = this.getAttribute("prefix"), l = this.getAttribute("suffix"), c = a ? `<button data-ry-target="decrement" class="ry-number-select__btn ry-number-select__decrement" aria-label="Decrease" tabindex="-1" type="button">${i}</button>` : "", d = n ? `<button data-ry-target="increment" class="ry-number-select__btn ry-number-select__increment" aria-label="Increase" tabindex="-1" type="button">${r}</button>` : "", g = `
|
|
1824
2109
|
<div data-ry-target="display" class="ry-number-select__display" tabindex="0" role="spinbutton"
|
|
1825
2110
|
aria-valuenow="${this.value}" aria-valuemin="${this.min}" aria-valuemax="${this.max}"
|
|
1826
2111
|
${e ? `aria-label="${e}"` : ""}>
|
|
1827
|
-
${
|
|
2112
|
+
${o ? `<span data-ry-target="prefix" class="ry-number-select__affix">${o}</span>` : ""}
|
|
1828
2113
|
<span data-ry-target="value" class="ry-number-select__value">${this.#j(this.value)}</span>
|
|
1829
2114
|
${l ? `<span data-ry-target="suffix" class="ry-number-select__affix">${l}</span>` : ""}
|
|
1830
2115
|
<input data-ry-target="input" class="ry-number-select__input" type="text" inputmode="decimal" tabindex="-1">
|
|
1831
2116
|
</div>`, b = e ? `<span data-ry-target="label" class="ry-number-select__label">${e}</span>` : "";
|
|
1832
|
-
|
|
2117
|
+
if (t === "stacked")
|
|
2118
|
+
this.innerHTML = `${d}${g}${c}${b}`;
|
|
2119
|
+
else if (t === "stacked-end") {
|
|
2120
|
+
const y = `<div data-ry-target="btn-group" class="ry-number-select__btn-group">${d}${c}</div>`;
|
|
2121
|
+
this.innerHTML = `${g}${y}${b}`;
|
|
2122
|
+
} else if (t === "stacked-start") {
|
|
2123
|
+
const y = `<div data-ry-target="btn-group" class="ry-number-select__btn-group">${d}${c}</div>`;
|
|
2124
|
+
this.innerHTML = `${y}${g}${b}`;
|
|
2125
|
+
} else
|
|
2126
|
+
this.innerHTML = `${c}${g}${d}${b}`;
|
|
1833
2127
|
}
|
|
1834
2128
|
#m(t) {
|
|
1835
2129
|
const e = this.getAttribute("icons") ?? "plus-minus";
|
|
1836
|
-
return e === "chevron" ? t ? [
|
|
2130
|
+
return e === "chevron" ? t ? [p("chevron-down") ?? "▾", p("chevron-up") ?? "▴"] : [p("chevron-left") ?? "‹", p("chevron-right") ?? "›"] : e === "arrow" ? t ? [p("chevron-down") ?? "▼", p("chevron-up") ?? "▲"] : [p("chevron-left") ?? "◀", p("chevron-right") ?? "▶"] : [p("minus") ?? "−", p("plus") ?? "+"];
|
|
1837
2131
|
}
|
|
1838
|
-
#
|
|
2132
|
+
#b() {
|
|
1839
2133
|
this.#t = this.$('[data-ry-target="display"]'), this.#e = this.$('[data-ry-target="value"]'), this.#i = this.$('[data-ry-target="input"]'), this.#s = this.$('[data-ry-target="decrement"]'), this.#r = this.$('[data-ry-target="increment"]');
|
|
1840
2134
|
}
|
|
1841
|
-
#
|
|
2135
|
+
#k() {
|
|
1842
2136
|
this.#s && (this.on(this.#s, "mousedown", (t) => {
|
|
1843
|
-
t.preventDefault(), this.#
|
|
1844
|
-
}), this.on(this.#s, "mouseup", () => this.#
|
|
1845
|
-
t.preventDefault(), this.#
|
|
1846
|
-
}), this.on(this.#r, "mouseup", () => this.#
|
|
1847
|
-
t.key === "Enter" && (t.preventDefault(), this.#
|
|
2137
|
+
t.preventDefault(), this.#g(-1);
|
|
2138
|
+
}), this.on(this.#s, "mouseup", () => this.#l()), this.on(this.#s, "mouseleave", () => this.#l())), this.#r && (this.on(this.#r, "mousedown", (t) => {
|
|
2139
|
+
t.preventDefault(), this.#g(1);
|
|
2140
|
+
}), this.on(this.#r, "mouseup", () => this.#l()), this.on(this.#r, "mouseleave", () => this.#l())), this.#t && this.on(this.#t, "mousedown", this.#I), this.on(document, "mousemove", this.#Y), this.on(document, "mouseup", this.#C), this.#t && this.on(this.#t, "touchstart", this.#X), this.on(document, "touchmove", this.#G), this.on(document, "touchend", this.#K), this.#t && this.on(this.#t, "keydown", this.#q), this.on(this, "wheel", this.#J), this.#t && this.on(this.#t, "dblclick", () => this.#E()), this.#i && (this.on(this.#i, "blur", () => this.#z()), this.on(this.#i, "keydown", (t) => {
|
|
2141
|
+
t.key === "Enter" && (t.preventDefault(), this.#z()), t.key === "Escape" && (t.preventDefault(), this.#P()), t.stopPropagation();
|
|
1848
2142
|
}));
|
|
1849
2143
|
}
|
|
1850
2144
|
// --- Button hold-to-repeat ---
|
|
1851
|
-
#
|
|
2145
|
+
#g(t) {
|
|
1852
2146
|
if (this.disabled) return;
|
|
1853
2147
|
const e = this.step || 1;
|
|
1854
|
-
this.#
|
|
2148
|
+
this.#R(t * e), this.#_(), this.#n = setTimeout(() => {
|
|
1855
2149
|
let s = 150;
|
|
1856
2150
|
const i = () => {
|
|
1857
|
-
this.#
|
|
2151
|
+
this.#R(t * e), this.#x(), s = Math.max(40, s * 0.85), this.#p = setTimeout(i, s);
|
|
1858
2152
|
};
|
|
1859
2153
|
i();
|
|
1860
2154
|
}, 400);
|
|
1861
2155
|
}
|
|
1862
|
-
#
|
|
1863
|
-
this.#
|
|
2156
|
+
#l() {
|
|
2157
|
+
this.#n && (clearTimeout(this.#n), this.#n = null), this.#p && (clearTimeout(this.#p), this.#p = null);
|
|
1864
2158
|
}
|
|
1865
2159
|
// --- Drag helpers ---
|
|
1866
|
-
get #
|
|
2160
|
+
get #f() {
|
|
1867
2161
|
const t = this.getAttribute("drag");
|
|
1868
|
-
|
|
2162
|
+
if (t === "x" || t === "y" || t === "none") return t;
|
|
2163
|
+
const e = this.getAttribute("arrows");
|
|
2164
|
+
return e === "stacked" || e === "stacked-end" || e === "stacked-start" ? "y" : "x";
|
|
1869
2165
|
}
|
|
1870
|
-
#
|
|
1871
|
-
return this.#
|
|
2166
|
+
#v(t, e) {
|
|
2167
|
+
return this.#f === "y" ? this.#c - e : t - this.#o;
|
|
1872
2168
|
}
|
|
1873
|
-
#
|
|
1874
|
-
return this.#
|
|
2169
|
+
#y(t, e) {
|
|
2170
|
+
return this.#f === "y" ? Math.abs(e - this.#c) : Math.abs(t - this.#o);
|
|
1875
2171
|
}
|
|
1876
|
-
#
|
|
2172
|
+
#M(t, e) {
|
|
1877
2173
|
if (!this.#e) return;
|
|
1878
|
-
const s = t / e * 4, i = this.#
|
|
2174
|
+
const s = t / e * 4, i = this.#f;
|
|
1879
2175
|
this.#e.style.transform = i === "y" ? `translateY(${-s}px)` : `translateX(${s}px)`;
|
|
1880
2176
|
}
|
|
1881
|
-
|
|
1882
|
-
const i = this.#
|
|
1883
|
-
this.#
|
|
1884
|
-
const d = this.hasAttribute("wrap") ? this.#
|
|
1885
|
-
|
|
2177
|
+
#$(t, e, s) {
|
|
2178
|
+
const i = this.#v(t, e), r = this.step || 1, a = s ? r * 10 : r, n = s ? S * 2 : S, o = Math.round(i / n), l = this.#h + o * a, c = i - o * n;
|
|
2179
|
+
this.#M(c, n);
|
|
2180
|
+
const d = this.hasAttribute("wrap") ? this.#U(l) : this.#T(l), g = this.#F(d);
|
|
2181
|
+
g !== this.value && (this.value = g, this.#A(), this.#x());
|
|
1886
2182
|
}
|
|
1887
2183
|
// --- Mouse drag ---
|
|
1888
|
-
#
|
|
1889
|
-
this.disabled || this.#
|
|
2184
|
+
#I = (t) => {
|
|
2185
|
+
this.disabled || this.#d || this.#f === "none" || (t.preventDefault(), this.#a = !0, this.#o = t.clientX, this.#c = t.clientY, this.#h = this.value, this.setAttribute("data-dragging", ""));
|
|
1890
2186
|
};
|
|
1891
|
-
#
|
|
1892
|
-
this.#
|
|
2187
|
+
#Y = (t) => {
|
|
2188
|
+
this.#a && this.#$(t.clientX, t.clientY, t.shiftKey);
|
|
1893
2189
|
};
|
|
1894
|
-
#
|
|
1895
|
-
if (!this.#
|
|
1896
|
-
const e = this.#
|
|
1897
|
-
this.#
|
|
2190
|
+
#C = (t) => {
|
|
2191
|
+
if (!this.#a) return;
|
|
2192
|
+
const e = this.#y(t.clientX, t.clientY);
|
|
2193
|
+
this.#a = !1, this.removeAttribute("data-dragging"), this.#e && (this.#e.style.transform = ""), e < T && this.hasAttribute("editable") ? this.#E() : e >= T && this.#_();
|
|
1898
2194
|
};
|
|
1899
2195
|
// --- Touch drag ---
|
|
1900
2196
|
#X = (t) => {
|
|
1901
|
-
this.disabled || this.#
|
|
2197
|
+
this.disabled || this.#d || this.#f === "none" || (t.preventDefault(), this.#a = !0, this.#o = t.touches[0]?.clientX ?? 0, this.#c = t.touches[0]?.clientY ?? 0, this.#h = this.value, this.setAttribute("data-dragging", ""));
|
|
1902
2198
|
};
|
|
1903
2199
|
#G = (t) => {
|
|
1904
|
-
if (!this.#
|
|
2200
|
+
if (!this.#a) return;
|
|
1905
2201
|
t.preventDefault();
|
|
1906
2202
|
const e = t.touches[0];
|
|
1907
|
-
e && this
|
|
2203
|
+
e && this.#$(e.clientX, e.clientY, !1);
|
|
1908
2204
|
};
|
|
1909
2205
|
#K = () => {
|
|
1910
|
-
this.#
|
|
2206
|
+
this.#a && (this.#a = !1, this.removeAttribute("data-dragging"), this.#e && (this.#e.style.transform = ""), this.#_());
|
|
1911
2207
|
};
|
|
1912
2208
|
// --- Keyboard ---
|
|
1913
2209
|
#q = (t) => {
|
|
1914
|
-
if (this.disabled || this.#
|
|
2210
|
+
if (this.disabled || this.#d) return;
|
|
1915
2211
|
const e = this.step || 1, s = e * 10;
|
|
1916
2212
|
let i = 0;
|
|
1917
2213
|
switch (t.key) {
|
|
@@ -1936,54 +2232,54 @@ class ht extends p {
|
|
|
1936
2232
|
i = this.max - this.value;
|
|
1937
2233
|
break;
|
|
1938
2234
|
case "Enter":
|
|
1939
|
-
this.hasAttribute("editable") && this.#
|
|
2235
|
+
this.hasAttribute("editable") && this.#E();
|
|
1940
2236
|
return;
|
|
1941
2237
|
default:
|
|
1942
|
-
this.hasAttribute("editable") && /^[0-9.\-]$/.test(t.key) && (this.#
|
|
2238
|
+
this.hasAttribute("editable") && /^[0-9.\-]$/.test(t.key) && (this.#E(t.key), t.preventDefault());
|
|
1943
2239
|
return;
|
|
1944
2240
|
}
|
|
1945
|
-
t.preventDefault(), this.#
|
|
2241
|
+
t.preventDefault(), this.#R(i), this.#x(), this.#_();
|
|
1946
2242
|
};
|
|
1947
2243
|
// --- Wheel ---
|
|
1948
2244
|
#J = (t) => {
|
|
1949
|
-
if (this.disabled || this.#
|
|
2245
|
+
if (this.disabled || this.#d || !this.matches(":hover") && !this.contains(document.activeElement)) return;
|
|
1950
2246
|
t.preventDefault();
|
|
1951
2247
|
const e = this.step || 1, s = t.shiftKey ? e * 10 : e, i = t.deltaY < 0 ? s : -s;
|
|
1952
|
-
this.#
|
|
2248
|
+
this.#R(i), this.#x(), this.#_();
|
|
1953
2249
|
};
|
|
1954
2250
|
// --- Edit mode ---
|
|
1955
|
-
#
|
|
1956
|
-
this.disabled || this.#
|
|
2251
|
+
#E(t) {
|
|
2252
|
+
this.disabled || this.#d || (this.#d = !0, this.state = "editing", this.#e && (this.#e.style.display = "none"), this.#i && (this.#i.style.display = "block", this.#i.value = t ?? this.#j(this.value), this.#i.focus(), t ? this.#i.setSelectionRange(1, 1) : this.#i.select()));
|
|
1957
2253
|
}
|
|
1958
|
-
#
|
|
1959
|
-
if (!this.#
|
|
1960
|
-
this.#
|
|
2254
|
+
#z() {
|
|
2255
|
+
if (!this.#d) return;
|
|
2256
|
+
this.#d = !1, this.state = "";
|
|
1961
2257
|
const t = parseFloat(this.#i?.value ?? "");
|
|
1962
2258
|
if (!isNaN(t)) {
|
|
1963
|
-
const e = this.#T(t), s = this.#
|
|
1964
|
-
this.value = s, this.#
|
|
2259
|
+
const e = this.#T(t), s = this.#F(e);
|
|
2260
|
+
this.value = s, this.#_();
|
|
1965
2261
|
}
|
|
1966
|
-
this.#e && (this.#e.style.display = ""), this.#i && (this.#i.style.display = "none"), this.#
|
|
2262
|
+
this.#e && (this.#e.style.display = ""), this.#i && (this.#i.style.display = "none"), this.#A(), this.#t?.focus();
|
|
1967
2263
|
}
|
|
1968
2264
|
#P() {
|
|
1969
|
-
this.#
|
|
2265
|
+
this.#d && (this.#d = !1, this.state = "", this.#e && (this.#e.style.display = ""), this.#i && (this.#i.style.display = "none"), this.#t?.focus());
|
|
1970
2266
|
}
|
|
1971
2267
|
// --- Value management ---
|
|
1972
|
-
#
|
|
2268
|
+
#R(t) {
|
|
1973
2269
|
let e = this.value + t;
|
|
1974
|
-
this.hasAttribute("wrap") ? e = this.#
|
|
2270
|
+
this.hasAttribute("wrap") ? e = this.#U(e) : e = this.#T(e), e = this.#F(e), this.value = e, this.#A();
|
|
1975
2271
|
}
|
|
1976
2272
|
#T(t) {
|
|
1977
2273
|
return Math.max(this.min, Math.min(this.max, t));
|
|
1978
2274
|
}
|
|
1979
|
-
#
|
|
2275
|
+
#U(t) {
|
|
1980
2276
|
const e = this.step || 1, s = this.max - this.min + e;
|
|
1981
2277
|
let i = t;
|
|
1982
2278
|
for (; i > this.max; ) i -= s;
|
|
1983
2279
|
for (; i < this.min; ) i += s;
|
|
1984
2280
|
return i;
|
|
1985
2281
|
}
|
|
1986
|
-
#
|
|
2282
|
+
#F(t) {
|
|
1987
2283
|
const e = this.step;
|
|
1988
2284
|
if (e <= 0) return this.#T(t);
|
|
1989
2285
|
const s = Math.round((t - this.min) / e) * e + this.min;
|
|
@@ -1995,16 +2291,16 @@ class ht extends p {
|
|
|
1995
2291
|
const s = Math.max(0, -Math.floor(Math.log10(e)));
|
|
1996
2292
|
return t.toFixed(s);
|
|
1997
2293
|
}
|
|
1998
|
-
#
|
|
1999
|
-
this.#e && (this.#e.textContent = this.#j(this.value)), this.#
|
|
2294
|
+
#A() {
|
|
2295
|
+
this.#e && (this.#e.textContent = this.#j(this.value)), this.#V();
|
|
2000
2296
|
}
|
|
2001
|
-
#
|
|
2297
|
+
#V() {
|
|
2002
2298
|
this.#t && (this.#t.setAttribute("aria-valuenow", String(this.value)), this.#t.setAttribute("aria-valuemin", String(this.min)), this.#t.setAttribute("aria-valuemax", String(this.max)));
|
|
2003
2299
|
}
|
|
2004
|
-
|
|
2300
|
+
#x() {
|
|
2005
2301
|
this.emit("input", { value: this.value });
|
|
2006
2302
|
}
|
|
2007
|
-
#
|
|
2303
|
+
#_() {
|
|
2008
2304
|
this.emit("change", { value: this.value });
|
|
2009
2305
|
}
|
|
2010
2306
|
// --- Public API ---
|
|
@@ -2033,7 +2329,7 @@ class ht extends p {
|
|
|
2033
2329
|
this.setAttribute("step", String(t));
|
|
2034
2330
|
}
|
|
2035
2331
|
get drag() {
|
|
2036
|
-
return this.#
|
|
2332
|
+
return this.#f;
|
|
2037
2333
|
}
|
|
2038
2334
|
set drag(t) {
|
|
2039
2335
|
this.setAttribute("drag", t);
|
|
@@ -2045,17 +2341,17 @@ class ht extends p {
|
|
|
2045
2341
|
t ? this.setAttribute("disabled", "") : this.removeAttribute("disabled");
|
|
2046
2342
|
}
|
|
2047
2343
|
attributeChangedCallback(t, e, s) {
|
|
2048
|
-
e !== s && t === "value" && this.#t && this.#
|
|
2344
|
+
e !== s && t === "value" && this.#t && this.#A();
|
|
2049
2345
|
}
|
|
2050
2346
|
teardown() {
|
|
2051
|
-
this.#
|
|
2347
|
+
this.#l();
|
|
2052
2348
|
}
|
|
2053
2349
|
}
|
|
2054
|
-
customElements.define("ry-number-select",
|
|
2055
|
-
function v(
|
|
2056
|
-
const t =
|
|
2350
|
+
customElements.define("ry-number-select", ct);
|
|
2351
|
+
function v(h) {
|
|
2352
|
+
const t = h.h / 360, e = h.s / 100, s = h.v / 100;
|
|
2057
2353
|
let i = 0, r = 0, a = 0;
|
|
2058
|
-
const n = Math.floor(t * 6),
|
|
2354
|
+
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);
|
|
2059
2355
|
switch (n % 6) {
|
|
2060
2356
|
case 0:
|
|
2061
2357
|
i = s, r = d, a = l;
|
|
@@ -2082,10 +2378,10 @@ function v(o) {
|
|
|
2082
2378
|
b: Math.round(a * 255)
|
|
2083
2379
|
};
|
|
2084
2380
|
}
|
|
2085
|
-
function $(
|
|
2086
|
-
const t =
|
|
2381
|
+
function $(h) {
|
|
2382
|
+
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;
|
|
2087
2383
|
let n = 0;
|
|
2088
|
-
const
|
|
2384
|
+
const o = i === 0 ? 0 : a / i, l = i;
|
|
2089
2385
|
if (i !== r)
|
|
2090
2386
|
switch (i) {
|
|
2091
2387
|
case t:
|
|
@@ -2100,34 +2396,34 @@ function $(o) {
|
|
|
2100
2396
|
}
|
|
2101
2397
|
return {
|
|
2102
2398
|
h: Math.round(n * 360),
|
|
2103
|
-
s: Math.round(
|
|
2399
|
+
s: Math.round(o * 100),
|
|
2104
2400
|
v: Math.round(l * 100)
|
|
2105
2401
|
};
|
|
2106
2402
|
}
|
|
2107
|
-
function L(
|
|
2108
|
-
const t =
|
|
2403
|
+
function L(h) {
|
|
2404
|
+
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);
|
|
2109
2405
|
return {
|
|
2110
|
-
h:
|
|
2406
|
+
h: h.h,
|
|
2111
2407
|
s: Math.round(i * 100),
|
|
2112
2408
|
l: Math.round(s * 100)
|
|
2113
2409
|
};
|
|
2114
2410
|
}
|
|
2115
|
-
function
|
|
2116
|
-
const t =
|
|
2411
|
+
function dt(h) {
|
|
2412
|
+
const t = h.s / 100, e = h.l / 100, s = e + t * Math.min(e, 1 - e), i = s === 0 ? 0 : 2 * (1 - e / s);
|
|
2117
2413
|
return {
|
|
2118
|
-
h:
|
|
2414
|
+
h: h.h,
|
|
2119
2415
|
s: Math.round(i * 100),
|
|
2120
2416
|
v: Math.round(s * 100)
|
|
2121
2417
|
};
|
|
2122
2418
|
}
|
|
2123
|
-
function
|
|
2419
|
+
function D(h) {
|
|
2124
2420
|
const t = (e) => e.toString(16).padStart(2, "0");
|
|
2125
|
-
return `#${t(
|
|
2421
|
+
return `#${t(h.r)}${t(h.g)}${t(h.b)}`;
|
|
2126
2422
|
}
|
|
2127
|
-
function
|
|
2128
|
-
const t = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(
|
|
2423
|
+
function ut(h) {
|
|
2424
|
+
const t = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(h);
|
|
2129
2425
|
if (!t) {
|
|
2130
|
-
const e = /^#?([a-f\d])([a-f\d])([a-f\d])$/i.exec(
|
|
2426
|
+
const e = /^#?([a-f\d])([a-f\d])([a-f\d])$/i.exec(h);
|
|
2131
2427
|
return e ? {
|
|
2132
2428
|
r: parseInt(e[1] + e[1], 16),
|
|
2133
2429
|
g: parseInt(e[2] + e[2], 16),
|
|
@@ -2140,8 +2436,8 @@ function ct(o) {
|
|
|
2140
2436
|
b: parseInt(t[3], 16)
|
|
2141
2437
|
};
|
|
2142
2438
|
}
|
|
2143
|
-
function
|
|
2144
|
-
const t =
|
|
2439
|
+
function A(h) {
|
|
2440
|
+
const t = h.trim().toLowerCase();
|
|
2145
2441
|
if (t.startsWith("#")) {
|
|
2146
2442
|
const i = /^#([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);
|
|
2147
2443
|
if (i) {
|
|
@@ -2152,7 +2448,7 @@ function w(o) {
|
|
|
2152
2448
|
}, n = parseInt(i[4], 16) / 255;
|
|
2153
2449
|
return { hsv: $(a), alpha: Math.round(n * 100) };
|
|
2154
2450
|
}
|
|
2155
|
-
const r =
|
|
2451
|
+
const r = ut(t);
|
|
2156
2452
|
return r ? { hsv: $(r), alpha: 100 } : null;
|
|
2157
2453
|
}
|
|
2158
2454
|
const e = /^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d.]+))?\s*\)$/.exec(t);
|
|
@@ -2171,33 +2467,33 @@ function w(o) {
|
|
|
2171
2467
|
s: parseFloat(s[2]),
|
|
2172
2468
|
l: parseFloat(s[3])
|
|
2173
2469
|
}, r = s[4] ? parseFloat(s[4]) * 100 : 100;
|
|
2174
|
-
return { hsv:
|
|
2470
|
+
return { hsv: dt(i), alpha: r };
|
|
2175
2471
|
}
|
|
2176
2472
|
return null;
|
|
2177
2473
|
}
|
|
2178
|
-
class
|
|
2474
|
+
class pt extends u {
|
|
2179
2475
|
#t = 0;
|
|
2180
2476
|
#e = 100;
|
|
2181
2477
|
#i = 100;
|
|
2182
2478
|
#s = 100;
|
|
2183
2479
|
#r = !1;
|
|
2184
|
-
#
|
|
2185
|
-
#
|
|
2186
|
-
#
|
|
2480
|
+
#a = !1;
|
|
2481
|
+
#o = !1;
|
|
2482
|
+
#c = null;
|
|
2483
|
+
#h = null;
|
|
2187
2484
|
#d = null;
|
|
2188
|
-
#
|
|
2189
|
-
#
|
|
2485
|
+
#n = null;
|
|
2486
|
+
#p = null;
|
|
2190
2487
|
#u = null;
|
|
2191
|
-
#g = null;
|
|
2192
2488
|
#m = null;
|
|
2193
|
-
#
|
|
2194
|
-
#
|
|
2195
|
-
#
|
|
2489
|
+
#b = null;
|
|
2490
|
+
#k = null;
|
|
2491
|
+
#g = null;
|
|
2196
2492
|
static observedAttributes = ["value", "format", "opacity", "disabled", "swatches", "inline"];
|
|
2197
2493
|
setup() {
|
|
2198
|
-
this.#
|
|
2494
|
+
this.#l(), this.#f(), this.#v(), this.#A();
|
|
2199
2495
|
}
|
|
2200
|
-
#
|
|
2496
|
+
#l() {
|
|
2201
2497
|
const t = this.hasAttribute("inline"), e = this.hasAttribute("opacity"), s = this.getAttribute("swatches");
|
|
2202
2498
|
let i = `
|
|
2203
2499
|
<div data-ry-target="grid" class="ry-color-picker__grid">
|
|
@@ -2237,55 +2533,55 @@ class dt extends p {
|
|
|
2237
2533
|
<span data-ry-target="trigger-color" class="ry-color-picker__trigger-color"></span>
|
|
2238
2534
|
</button>
|
|
2239
2535
|
<div data-ry-target="panel" class="ry-color-picker__panel">${i}</div>
|
|
2240
|
-
`, this.#
|
|
2536
|
+
`, this.#c = this.$('[data-ry-target="trigger"]'), this.#h = this.$('[data-ry-target="panel"]'), this.#d = this.$('[data-ry-target="grid"]'), this.#n = this.$('[data-ry-target="grid-handle"]'), this.#p = this.$('[data-ry-target="hue-slider"]'), this.#u = this.$('[data-ry-target="hue-handle"]'), this.#m = this.$('[data-ry-target="alpha-slider"]'), this.#b = this.$('[data-ry-target="alpha-handle"]'), this.#k = this.$('[data-ry-target="preview"]'), this.#g = this.$('[data-ry-target="input"]');
|
|
2241
2537
|
}
|
|
2242
|
-
#
|
|
2243
|
-
this.#
|
|
2538
|
+
#f() {
|
|
2539
|
+
this.#c && this.on(this.#c, "click", this.#y), this.on(document, "click", this.#M), this.on(document, "keydown", this.#$), this.#d && this.on(this.#d, "pointerdown", this.#Y), this.#n && this.on(this.#n, "keydown", this.#X), this.#p && this.on(this.#p, "pointerdown", this.#G), this.#u && this.on(this.#u, "keydown", this.#q), this.#m && this.on(this.#m, "pointerdown", this.#J), this.#b && this.on(this.#b, "keydown", this.#z), this.on(document, "pointermove", this.#P), this.on(document, "pointerup", this.#R), this.#g && (this.on(this.#g, "change", this.#T), this.on(this.#g, "keydown", this.#U));
|
|
2244
2540
|
const t = this.$('[data-ry-target="format-toggle"]');
|
|
2245
|
-
t && this.on(t, "click", this.#
|
|
2541
|
+
t && this.on(t, "click", this.#F);
|
|
2246
2542
|
const e = this.$('[data-ry-target="swatches"]');
|
|
2247
2543
|
e && this.on(e, "click", this.#j);
|
|
2248
2544
|
}
|
|
2249
|
-
#
|
|
2545
|
+
#v() {
|
|
2250
2546
|
const t = this.getAttribute("value");
|
|
2251
2547
|
if (t) {
|
|
2252
|
-
const e =
|
|
2548
|
+
const e = A(t);
|
|
2253
2549
|
e && (this.#t = e.hsv.h, this.#e = e.hsv.s, this.#i = e.hsv.v, this.#s = e.alpha);
|
|
2254
2550
|
}
|
|
2255
2551
|
}
|
|
2256
2552
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2257
2553
|
// Dropdown handlers
|
|
2258
2554
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2259
|
-
#
|
|
2555
|
+
#y = () => {
|
|
2260
2556
|
this.disabled || (this.state === "open" ? this.close() : this.open());
|
|
2261
2557
|
};
|
|
2262
|
-
#
|
|
2558
|
+
#M = (t) => {
|
|
2263
2559
|
this.state === "open" && (this.contains(t.target) || this.close());
|
|
2264
2560
|
};
|
|
2265
|
-
|
|
2266
|
-
t.key === "Escape" && this.state === "open" && (this.close(), this.#
|
|
2561
|
+
#$ = (t) => {
|
|
2562
|
+
t.key === "Escape" && this.state === "open" && (this.close(), this.#c?.focus());
|
|
2267
2563
|
};
|
|
2268
2564
|
open() {
|
|
2269
|
-
this.hasAttribute("inline") || (this.#
|
|
2565
|
+
this.hasAttribute("inline") || (this.#I(), this.state = "open");
|
|
2270
2566
|
}
|
|
2271
2567
|
close() {
|
|
2272
2568
|
this.hasAttribute("inline") || (this.state = "closed", this.removeAttribute("data-ry-position"));
|
|
2273
2569
|
}
|
|
2274
|
-
#
|
|
2275
|
-
if (!this.#
|
|
2276
|
-
const t = this.#
|
|
2570
|
+
#I() {
|
|
2571
|
+
if (!this.#h || !this.#c) return;
|
|
2572
|
+
const t = this.#c.getBoundingClientRect(), e = 320, i = window.innerHeight - t.bottom, r = t.top;
|
|
2277
2573
|
i < e && r > i ? this.setAttribute("data-ry-position", "top") : this.setAttribute("data-ry-position", "bottom");
|
|
2278
2574
|
}
|
|
2279
2575
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2280
2576
|
// Grid handlers
|
|
2281
2577
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2282
|
-
#
|
|
2283
|
-
this.disabled || (t.preventDefault(), this.#r = !0, this.#
|
|
2578
|
+
#Y = (t) => {
|
|
2579
|
+
this.disabled || (t.preventDefault(), this.#r = !0, this.#n?.focus(), this.#C(t));
|
|
2284
2580
|
};
|
|
2285
|
-
#
|
|
2286
|
-
if (!this.#
|
|
2287
|
-
const e = this.#
|
|
2288
|
-
this.#e = Math.round(s * 100), this.#i = Math.round((1 - i) * 100), this.#
|
|
2581
|
+
#C(t) {
|
|
2582
|
+
if (!this.#d) return;
|
|
2583
|
+
const e = this.#d.getBoundingClientRect(), s = Math.max(0, Math.min(1, (t.clientX - e.left) / e.width)), i = Math.max(0, Math.min(1, (t.clientY - e.top) / e.height));
|
|
2584
|
+
this.#e = Math.round(s * 100), this.#i = Math.round((1 - i) * 100), this.#A(), this.#L();
|
|
2289
2585
|
}
|
|
2290
2586
|
#X = (t) => {
|
|
2291
2587
|
if (this.disabled) return;
|
|
@@ -2305,18 +2601,18 @@ class dt extends p {
|
|
|
2305
2601
|
this.#i = Math.max(0, this.#i - e), s = !0;
|
|
2306
2602
|
break;
|
|
2307
2603
|
}
|
|
2308
|
-
s && (t.preventDefault(), this.#
|
|
2604
|
+
s && (t.preventDefault(), this.#A(), this.#L(), this.#w());
|
|
2309
2605
|
};
|
|
2310
2606
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2311
2607
|
// Hue handlers
|
|
2312
2608
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2313
2609
|
#G = (t) => {
|
|
2314
|
-
this.disabled || (t.preventDefault(), this.#
|
|
2610
|
+
this.disabled || (t.preventDefault(), this.#a = !0, this.#u?.focus(), this.#K(t));
|
|
2315
2611
|
};
|
|
2316
2612
|
#K(t) {
|
|
2317
|
-
if (!this.#
|
|
2318
|
-
const e = this.#
|
|
2319
|
-
this.#t = Math.round(s * 360), this.#
|
|
2613
|
+
if (!this.#p) return;
|
|
2614
|
+
const e = this.#p.getBoundingClientRect(), s = Math.max(0, Math.min(1, (t.clientX - e.left) / e.width));
|
|
2615
|
+
this.#t = Math.round(s * 360), this.#A(), this.#L();
|
|
2320
2616
|
}
|
|
2321
2617
|
#q = (t) => {
|
|
2322
2618
|
if (this.disabled) return;
|
|
@@ -2332,20 +2628,20 @@ class dt extends p {
|
|
|
2332
2628
|
this.#t = (this.#t - e + 360) % 360, s = !0;
|
|
2333
2629
|
break;
|
|
2334
2630
|
}
|
|
2335
|
-
s && (t.preventDefault(), this.#
|
|
2631
|
+
s && (t.preventDefault(), this.#A(), this.#L(), this.#w());
|
|
2336
2632
|
};
|
|
2337
2633
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2338
2634
|
// Alpha handlers
|
|
2339
2635
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2340
2636
|
#J = (t) => {
|
|
2341
|
-
this.disabled || (t.preventDefault(), this.#
|
|
2637
|
+
this.disabled || (t.preventDefault(), this.#o = !0, this.#b?.focus(), this.#E(t));
|
|
2342
2638
|
};
|
|
2343
|
-
#
|
|
2639
|
+
#E(t) {
|
|
2344
2640
|
if (!this.#m) return;
|
|
2345
2641
|
const e = this.#m.getBoundingClientRect(), s = Math.max(0, Math.min(1, (t.clientX - e.left) / e.width));
|
|
2346
|
-
this.#s = Math.round(s * 100), this.#
|
|
2642
|
+
this.#s = Math.round(s * 100), this.#A(), this.#L();
|
|
2347
2643
|
}
|
|
2348
|
-
#
|
|
2644
|
+
#z = (t) => {
|
|
2349
2645
|
if (this.disabled) return;
|
|
2350
2646
|
const e = t.shiftKey ? 10 : 1;
|
|
2351
2647
|
let s = !1;
|
|
@@ -2359,36 +2655,36 @@ class dt extends p {
|
|
|
2359
2655
|
this.#s = Math.max(0, this.#s - e), s = !0;
|
|
2360
2656
|
break;
|
|
2361
2657
|
}
|
|
2362
|
-
s && (t.preventDefault(), this.#
|
|
2658
|
+
s && (t.preventDefault(), this.#A(), this.#L(), this.#w());
|
|
2363
2659
|
};
|
|
2364
2660
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2365
2661
|
// Pointer move/up
|
|
2366
2662
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2367
2663
|
#P = (t) => {
|
|
2368
|
-
this.#r ? this.#
|
|
2664
|
+
this.#r ? this.#C(t) : this.#a ? this.#K(t) : this.#o && this.#E(t);
|
|
2369
2665
|
};
|
|
2370
|
-
#
|
|
2371
|
-
(this.#r || this.#
|
|
2666
|
+
#R = () => {
|
|
2667
|
+
(this.#r || this.#a || this.#o) && (this.#r = !1, this.#a = !1, this.#o = !1, this.#w());
|
|
2372
2668
|
};
|
|
2373
2669
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2374
2670
|
// Input handlers
|
|
2375
2671
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2376
2672
|
#T = () => {
|
|
2377
|
-
if (!this.#
|
|
2378
|
-
const t =
|
|
2379
|
-
t ? (this.#t = t.hsv.h, this.#e = t.hsv.s, this.#i = t.hsv.v, this.hasAttribute("opacity") && (this.#s = t.alpha), this.#
|
|
2673
|
+
if (!this.#g) return;
|
|
2674
|
+
const t = A(this.#g.value);
|
|
2675
|
+
t ? (this.#t = t.hsv.h, this.#e = t.hsv.s, this.#i = t.hsv.v, this.hasAttribute("opacity") && (this.#s = t.alpha), this.#A(), this.#w()) : this.#W();
|
|
2380
2676
|
};
|
|
2381
|
-
#
|
|
2677
|
+
#U = (t) => {
|
|
2382
2678
|
t.key === "Enter" && (t.preventDefault(), this.#T());
|
|
2383
2679
|
};
|
|
2384
2680
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2385
2681
|
// Format toggle
|
|
2386
2682
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2387
|
-
#
|
|
2683
|
+
#F = () => {
|
|
2388
2684
|
const t = ["hex", "rgb", "hsl"], e = this.format, s = t.indexOf(e), i = t[(s + 1) % t.length];
|
|
2389
2685
|
this.format = i;
|
|
2390
2686
|
const r = this.$('[data-ry-target="format-toggle"]');
|
|
2391
|
-
r && (r.textContent = i.toUpperCase()), this.#
|
|
2687
|
+
r && (r.textContent = i.toUpperCase()), this.#W();
|
|
2392
2688
|
};
|
|
2393
2689
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2394
2690
|
// Swatches
|
|
@@ -2398,60 +2694,60 @@ class dt extends p {
|
|
|
2398
2694
|
if (e.classList.contains("ry-color-picker__swatch")) {
|
|
2399
2695
|
const s = e.dataset.color;
|
|
2400
2696
|
if (s) {
|
|
2401
|
-
const i =
|
|
2402
|
-
i && (this.#t = i.hsv.h, this.#e = i.hsv.s, this.#i = i.hsv.v, this.hasAttribute("opacity") && (this.#s = i.alpha), this.#
|
|
2697
|
+
const i = A(s);
|
|
2698
|
+
i && (this.#t = i.hsv.h, this.#e = i.hsv.s, this.#i = i.hsv.v, this.hasAttribute("opacity") && (this.#s = i.alpha), this.#A(), this.#L(), this.#w());
|
|
2403
2699
|
}
|
|
2404
2700
|
}
|
|
2405
2701
|
};
|
|
2406
2702
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2407
2703
|
// Update methods
|
|
2408
2704
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2409
|
-
#
|
|
2410
|
-
this.#
|
|
2705
|
+
#A() {
|
|
2706
|
+
this.#V(), this.#x(), this.#_(), this.#H(), this.#N(), this.#W(), this.#Z();
|
|
2411
2707
|
}
|
|
2412
|
-
#
|
|
2708
|
+
#V() {
|
|
2413
2709
|
const t = this.$('[data-ry-target="trigger-color"]');
|
|
2414
2710
|
if (t) {
|
|
2415
2711
|
const e = v({ h: this.#t, s: this.#e, v: this.#i }), s = this.hasAttribute("opacity") ? this.#s / 100 : 1;
|
|
2416
2712
|
t.style.backgroundColor = `rgba(${e.r}, ${e.g}, ${e.b}, ${s})`;
|
|
2417
2713
|
}
|
|
2418
2714
|
}
|
|
2419
|
-
|
|
2420
|
-
if (this.#
|
|
2715
|
+
#x() {
|
|
2716
|
+
if (this.#d) {
|
|
2421
2717
|
const t = v({ h: this.#t, s: 100, v: 100 });
|
|
2422
|
-
this.#
|
|
2718
|
+
this.#d.style.setProperty("--grid-hue-color", `rgb(${t.r}, ${t.g}, ${t.b})`);
|
|
2423
2719
|
}
|
|
2424
|
-
this.#
|
|
2720
|
+
this.#n && (this.#n.style.left = `${this.#e}%`, this.#n.style.top = `${100 - this.#i}%`);
|
|
2425
2721
|
}
|
|
2426
|
-
#
|
|
2427
|
-
this.#
|
|
2722
|
+
#_() {
|
|
2723
|
+
this.#u && (this.#u.style.left = `${this.#t / 360 * 100}%`);
|
|
2428
2724
|
}
|
|
2429
2725
|
#H() {
|
|
2430
2726
|
if (this.#m) {
|
|
2431
2727
|
const t = v({ h: this.#t, s: this.#e, v: this.#i });
|
|
2432
2728
|
this.#m.style.setProperty("--alpha-color", `rgb(${t.r}, ${t.g}, ${t.b})`);
|
|
2433
2729
|
}
|
|
2434
|
-
this.#
|
|
2730
|
+
this.#b && (this.#b.style.left = `${this.#s}%`);
|
|
2435
2731
|
}
|
|
2436
|
-
#
|
|
2732
|
+
#N() {
|
|
2437
2733
|
const t = this.$('[data-ry-target="preview-color"]');
|
|
2438
2734
|
if (t) {
|
|
2439
2735
|
const e = v({ h: this.#t, s: this.#e, v: this.#i }), s = this.hasAttribute("opacity") ? this.#s / 100 : 1;
|
|
2440
2736
|
t.style.backgroundColor = `rgba(${e.r}, ${e.g}, ${e.b}, ${s})`;
|
|
2441
2737
|
}
|
|
2442
2738
|
}
|
|
2443
|
-
#
|
|
2444
|
-
this.#
|
|
2739
|
+
#W() {
|
|
2740
|
+
this.#g && (this.#g.value = this.#O());
|
|
2445
2741
|
}
|
|
2446
2742
|
#Z() {
|
|
2447
|
-
const t = this.#
|
|
2743
|
+
const t = this.#O();
|
|
2448
2744
|
this.getAttribute("value") !== t && this.setAttribute("value", t);
|
|
2449
2745
|
}
|
|
2450
|
-
#
|
|
2746
|
+
#O() {
|
|
2451
2747
|
const t = this.format, e = v({ h: this.#t, s: this.#e, v: this.#i }), s = this.hasAttribute("opacity");
|
|
2452
2748
|
switch (t) {
|
|
2453
2749
|
case "hex": {
|
|
2454
|
-
const i =
|
|
2750
|
+
const i = D(e);
|
|
2455
2751
|
if (s && this.#s < 100) {
|
|
2456
2752
|
const r = Math.round(this.#s / 100 * 255).toString(16).padStart(2, "0");
|
|
2457
2753
|
return i + r;
|
|
@@ -2465,7 +2761,7 @@ class dt extends p {
|
|
|
2465
2761
|
return s ? `hsla(${i.h}, ${i.s}%, ${i.l}%, ${(this.#s / 100).toFixed(2)})` : `hsl(${i.h}, ${i.s}%, ${i.l}%)`;
|
|
2466
2762
|
}
|
|
2467
2763
|
default:
|
|
2468
|
-
return
|
|
2764
|
+
return D(e);
|
|
2469
2765
|
}
|
|
2470
2766
|
}
|
|
2471
2767
|
// ───────────────────────────────────────────────────────────────────────────
|
|
@@ -2474,27 +2770,27 @@ class dt extends p {
|
|
|
2474
2770
|
#L() {
|
|
2475
2771
|
this.emit("input", { value: this.value, hsv: this.hsv, rgb: this.rgb });
|
|
2476
2772
|
}
|
|
2477
|
-
#
|
|
2773
|
+
#w() {
|
|
2478
2774
|
this.emit("change", { value: this.value, hsv: this.hsv, rgb: this.rgb });
|
|
2479
2775
|
}
|
|
2480
2776
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2481
2777
|
// Attribute changed
|
|
2482
2778
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2483
2779
|
attributeChangedCallback(t, e, s) {
|
|
2484
|
-
if (e !== s && t === "value" && this.#
|
|
2485
|
-
const i =
|
|
2486
|
-
i && (this.#t = i.hsv.h, this.#e = i.hsv.s, this.#i = i.hsv.v, this.hasAttribute("opacity") && (this.#s = i.alpha), this.#
|
|
2780
|
+
if (e !== s && t === "value" && this.#d && s) {
|
|
2781
|
+
const i = A(s);
|
|
2782
|
+
i && (this.#t = i.hsv.h, this.#e = i.hsv.s, this.#i = i.hsv.v, this.hasAttribute("opacity") && (this.#s = i.alpha), this.#V(), this.#x(), this.#_(), this.#H(), this.#N());
|
|
2487
2783
|
}
|
|
2488
2784
|
}
|
|
2489
2785
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2490
2786
|
// Public API
|
|
2491
2787
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2492
2788
|
get value() {
|
|
2493
|
-
return this.#
|
|
2789
|
+
return this.#O();
|
|
2494
2790
|
}
|
|
2495
2791
|
set value(t) {
|
|
2496
|
-
const e =
|
|
2497
|
-
e && (this.#t = e.hsv.h, this.#e = e.hsv.s, this.#i = e.hsv.v, this.hasAttribute("opacity") && (this.#s = e.alpha), this.#
|
|
2792
|
+
const e = A(t);
|
|
2793
|
+
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());
|
|
2498
2794
|
}
|
|
2499
2795
|
get format() {
|
|
2500
2796
|
return this.getAttribute("format") || "hex";
|
|
@@ -2521,30 +2817,30 @@ class dt extends p {
|
|
|
2521
2817
|
return this.#s;
|
|
2522
2818
|
}
|
|
2523
2819
|
set alpha(t) {
|
|
2524
|
-
this.#s = Math.max(0, Math.min(100, t)), this.#
|
|
2820
|
+
this.#s = Math.max(0, Math.min(100, t)), this.#A();
|
|
2525
2821
|
}
|
|
2526
2822
|
/** Set color from any valid color string */
|
|
2527
2823
|
setColor(t) {
|
|
2528
|
-
const e =
|
|
2529
|
-
return e ? (this.#t = e.hsv.h, this.#e = e.hsv.s, this.#i = e.hsv.v, this.hasAttribute("opacity") && (this.#s = e.alpha), this.#
|
|
2824
|
+
const e = A(t);
|
|
2825
|
+
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;
|
|
2530
2826
|
}
|
|
2531
2827
|
/** Get color in specific format */
|
|
2532
2828
|
getFormattedValue(t) {
|
|
2533
2829
|
const e = this.format;
|
|
2534
2830
|
this.format = t;
|
|
2535
|
-
const s = this.#
|
|
2831
|
+
const s = this.#O();
|
|
2536
2832
|
return this.format = e, s;
|
|
2537
2833
|
}
|
|
2538
2834
|
}
|
|
2539
|
-
customElements.define("ry-color-picker",
|
|
2540
|
-
class
|
|
2835
|
+
customElements.define("ry-color-picker", pt);
|
|
2836
|
+
class gt extends u {
|
|
2541
2837
|
#t = null;
|
|
2542
2838
|
#e = null;
|
|
2543
2839
|
#i = null;
|
|
2544
2840
|
#s = null;
|
|
2545
2841
|
static observedAttributes = ["value", "format", "opacity", "disabled", "placeholder"];
|
|
2546
2842
|
setup() {
|
|
2547
|
-
this.#r(), this.#
|
|
2843
|
+
this.#r(), this.#a(), this.#f(), this.state = "closed";
|
|
2548
2844
|
}
|
|
2549
2845
|
#r() {
|
|
2550
2846
|
const t = this.hasAttribute("opacity"), e = this.getAttribute("format") || "hex", s = this.getAttribute("value") || "#000000", i = this.getAttribute("placeholder") || "#000000";
|
|
@@ -2575,16 +2871,16 @@ class ut extends p {
|
|
|
2575
2871
|
</div>
|
|
2576
2872
|
`, this.#t = this.$('[data-ry-target="swatch"]'), this.#e = this.$('[data-ry-target="input"]'), this.#i = this.$('[data-ry-target="panel"]'), this.#s = this.$('[data-ry-target="picker"]');
|
|
2577
2873
|
}
|
|
2578
|
-
#
|
|
2579
|
-
this.#t && this.on(this.#t, "click", this.#
|
|
2874
|
+
#a() {
|
|
2875
|
+
this.#t && this.on(this.#t, "click", this.#o), this.#e && (this.on(this.#e, "input", this.#h), this.on(this.#e, "keydown", this.#p), this.on(this.#e, "focus", this.#c)), this.#s && (this.on(this.#s, "ry:input", this.#u), this.on(this.#s, "ry:change", this.#m)), this.on(document, "click", this.#b), this.on(document, "keydown", this.#k);
|
|
2580
2876
|
}
|
|
2581
|
-
#
|
|
2877
|
+
#o = () => {
|
|
2582
2878
|
this.disabled || (this.state === "open" ? this.close() : this.open());
|
|
2583
2879
|
};
|
|
2584
|
-
#
|
|
2880
|
+
#c = () => {
|
|
2585
2881
|
this.disabled || this.open();
|
|
2586
2882
|
};
|
|
2587
|
-
#
|
|
2883
|
+
#h = () => {
|
|
2588
2884
|
if (!this.#e || !this.#s) return;
|
|
2589
2885
|
let t = this.#e.value;
|
|
2590
2886
|
const e = this.#e.selectionStart ?? t.length, r = "#" + t.replace(/[^#a-fA-F0-9]/g, "").replace(/#/g, "").slice(0, 6);
|
|
@@ -2593,10 +2889,10 @@ class ut extends p {
|
|
|
2593
2889
|
const n = Math.min(e, r.length);
|
|
2594
2890
|
this.#e.setSelectionRange(n, n);
|
|
2595
2891
|
}
|
|
2596
|
-
const a = this.#
|
|
2597
|
-
a && (this.#s.setColor(a), this.#
|
|
2892
|
+
const a = this.#d(r);
|
|
2893
|
+
a && (this.#s.setColor(a), this.#l(), this.#n(r) && this.#v(), this.emit("input", { value: this.value }));
|
|
2598
2894
|
};
|
|
2599
|
-
#
|
|
2895
|
+
#d(t) {
|
|
2600
2896
|
let e = t;
|
|
2601
2897
|
e.startsWith("#") || (e = "#" + e);
|
|
2602
2898
|
const s = e.slice(1);
|
|
@@ -2610,67 +2906,67 @@ class ut extends p {
|
|
|
2610
2906
|
}
|
|
2611
2907
|
return "#" + s.padEnd(6, "0");
|
|
2612
2908
|
}
|
|
2613
|
-
#
|
|
2909
|
+
#n(t) {
|
|
2614
2910
|
return !!(/^#[a-fA-F0-9]{6}$/.test(t) || /^#[a-fA-F0-9]{3}$/.test(t));
|
|
2615
2911
|
}
|
|
2616
|
-
#
|
|
2617
|
-
t.key === "Enter" && (t.preventDefault(), this.#
|
|
2912
|
+
#p = (t) => {
|
|
2913
|
+
t.key === "Enter" && (t.preventDefault(), this.#h(), this.emit("change", { value: this.value }));
|
|
2618
2914
|
};
|
|
2619
|
-
#
|
|
2620
|
-
!this.#s || !this.#e || (document.activeElement !== this.#e && (this.#e.value = this.#s.value), this.#
|
|
2915
|
+
#u = () => {
|
|
2916
|
+
!this.#s || !this.#e || (document.activeElement !== this.#e && (this.#e.value = this.#s.value), this.#l(), this.#v(), this.emit("input", { value: this.value }));
|
|
2621
2917
|
};
|
|
2622
2918
|
#m = () => {
|
|
2623
2919
|
this.emit("change", { value: this.value });
|
|
2624
2920
|
};
|
|
2625
|
-
#
|
|
2921
|
+
#b = (t) => {
|
|
2626
2922
|
this.state === "open" && (this.contains(t.target) || this.close());
|
|
2627
2923
|
};
|
|
2628
|
-
#
|
|
2924
|
+
#k = (t) => {
|
|
2629
2925
|
t.key === "Escape" && this.state === "open" && (this.close(), this.#t?.focus());
|
|
2630
2926
|
};
|
|
2631
2927
|
open() {
|
|
2632
|
-
this.#
|
|
2928
|
+
this.#g(), this.state = "open";
|
|
2633
2929
|
}
|
|
2634
2930
|
close() {
|
|
2635
2931
|
this.state = "closed", this.removeAttribute("data-ry-position");
|
|
2636
2932
|
}
|
|
2637
|
-
#
|
|
2933
|
+
#g() {
|
|
2638
2934
|
if (!this.#i) return;
|
|
2639
2935
|
const t = this.getBoundingClientRect(), e = 280, i = window.innerHeight - t.bottom, r = t.top;
|
|
2640
2936
|
i < e && r > i ? this.setAttribute("data-ry-position", "top") : this.setAttribute("data-ry-position", "bottom");
|
|
2641
2937
|
}
|
|
2642
|
-
#
|
|
2938
|
+
#l() {
|
|
2643
2939
|
const t = this.$('[data-ry-target="swatch-color"]');
|
|
2644
2940
|
if (t && this.#s) {
|
|
2645
2941
|
const e = this.#s.rgb, s = this.hasAttribute("opacity") ? this.#s.alpha / 100 : 1;
|
|
2646
2942
|
t.style.backgroundColor = `rgba(${e.r}, ${e.g}, ${e.b}, ${s})`;
|
|
2647
2943
|
}
|
|
2648
2944
|
}
|
|
2649
|
-
#
|
|
2945
|
+
#f() {
|
|
2650
2946
|
const t = this.getAttribute("value") || "#000000";
|
|
2651
2947
|
if (this.#s) {
|
|
2652
2948
|
if (this.#s.setColor(t), this.#e) {
|
|
2653
2949
|
const e = this.#s.value;
|
|
2654
2950
|
this.#e.value = e.startsWith("#") ? e : "#" + e;
|
|
2655
2951
|
}
|
|
2656
|
-
this.#
|
|
2952
|
+
this.#l();
|
|
2657
2953
|
}
|
|
2658
2954
|
}
|
|
2659
|
-
#
|
|
2955
|
+
#v() {
|
|
2660
2956
|
if (this.#s) {
|
|
2661
2957
|
const t = this.#s.value;
|
|
2662
2958
|
this.getAttribute("value") !== t && this.setAttribute("value", t);
|
|
2663
2959
|
}
|
|
2664
2960
|
}
|
|
2665
2961
|
attributeChangedCallback(t, e, s) {
|
|
2666
|
-
e !== s && (t === "value" && this.#s && this.#e && s && (this.#s.setColor(s), document.activeElement !== this.#e && (this.#e.value = this.#s.value), this.#
|
|
2962
|
+
e !== s && (t === "value" && this.#s && this.#e && s && (this.#s.setColor(s), document.activeElement !== this.#e && (this.#e.value = this.#s.value), this.#l()), t === "disabled" && this.#e && (s !== null ? this.#e.setAttribute("disabled", "") : this.#e.removeAttribute("disabled")));
|
|
2667
2963
|
}
|
|
2668
2964
|
// Public API
|
|
2669
2965
|
get value() {
|
|
2670
2966
|
return this.#s?.value ?? this.getAttribute("value") ?? "#000000";
|
|
2671
2967
|
}
|
|
2672
2968
|
set value(t) {
|
|
2673
|
-
this.#s?.setColor(t) && (this.#e && (this.#e.value = this.#s.value), this.#
|
|
2969
|
+
this.#s?.setColor(t) && (this.#e && (this.#e.value = this.#s.value), this.#l(), this.#v());
|
|
2674
2970
|
}
|
|
2675
2971
|
get disabled() {
|
|
2676
2972
|
return this.hasAttribute("disabled");
|
|
@@ -2688,9 +2984,9 @@ class ut extends p {
|
|
|
2688
2984
|
return this.#s?.hsv ?? { h: 0, s: 0, v: 0 };
|
|
2689
2985
|
}
|
|
2690
2986
|
}
|
|
2691
|
-
customElements.define("ry-color-input",
|
|
2692
|
-
function x(
|
|
2693
|
-
const t =
|
|
2987
|
+
customElements.define("ry-color-input", gt);
|
|
2988
|
+
function x(h) {
|
|
2989
|
+
const t = h.trim().toLowerCase();
|
|
2694
2990
|
if (t.startsWith("#")) {
|
|
2695
2991
|
const i = t.slice(1);
|
|
2696
2992
|
return i.length === 3 ? {
|
|
@@ -2712,57 +3008,57 @@ function x(o) {
|
|
|
2712
3008
|
};
|
|
2713
3009
|
const s = /^hsla?\(\s*([\d.]+)\s*,\s*([\d.]+)%\s*,\s*([\d.]+)%/.exec(t);
|
|
2714
3010
|
if (s) {
|
|
2715
|
-
const i = parseFloat(s[1]) / 360, r = parseFloat(s[2]) / 100, a = parseFloat(s[3]) / 100, n = (c, d,
|
|
3011
|
+
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;
|
|
2716
3012
|
return {
|
|
2717
|
-
r: Math.round(n(l,
|
|
2718
|
-
g: Math.round(n(l,
|
|
2719
|
-
b: Math.round(n(l,
|
|
3013
|
+
r: Math.round(n(l, o, i + 1 / 3) * 255),
|
|
3014
|
+
g: Math.round(n(l, o, i) * 255),
|
|
3015
|
+
b: Math.round(n(l, o, i - 1 / 3) * 255)
|
|
2720
3016
|
};
|
|
2721
3017
|
}
|
|
2722
3018
|
return null;
|
|
2723
3019
|
}
|
|
2724
|
-
function
|
|
3020
|
+
function ft(h) {
|
|
2725
3021
|
const t = (e) => Math.max(0, Math.min(255, e)).toString(16).padStart(2, "0");
|
|
2726
|
-
return `#${t(
|
|
3022
|
+
return `#${t(h.r)}${t(h.g)}${t(h.b)}`;
|
|
2727
3023
|
}
|
|
2728
|
-
function
|
|
3024
|
+
function yt(h, t, e) {
|
|
2729
3025
|
return {
|
|
2730
|
-
r: Math.round(
|
|
2731
|
-
g: Math.round(
|
|
2732
|
-
b: Math.round(
|
|
3026
|
+
r: Math.round(h.r + (t.r - h.r) * e),
|
|
3027
|
+
g: Math.round(h.g + (t.g - h.g) * e),
|
|
3028
|
+
b: Math.round(h.b + (t.b - h.b) * e)
|
|
2733
3029
|
};
|
|
2734
3030
|
}
|
|
2735
|
-
const
|
|
2736
|
-
class
|
|
3031
|
+
const I = "linear-gradient(90deg, #000000 0%, #ffffff 100%)", bt = 50;
|
|
3032
|
+
class mt extends u {
|
|
2737
3033
|
#t = "linear";
|
|
2738
3034
|
#e = 90;
|
|
2739
3035
|
#i = "circle";
|
|
2740
3036
|
#s = [];
|
|
2741
3037
|
#r = null;
|
|
2742
|
-
#
|
|
3038
|
+
#a = 0;
|
|
3039
|
+
#o = null;
|
|
3040
|
+
#c = !1;
|
|
2743
3041
|
#h = null;
|
|
2744
|
-
#
|
|
2745
|
-
#d = null;
|
|
2746
|
-
#o = !1;
|
|
3042
|
+
#d = !1;
|
|
2747
3043
|
// Cached DOM refs
|
|
2748
|
-
#
|
|
3044
|
+
#n = null;
|
|
3045
|
+
#p = null;
|
|
2749
3046
|
#u = null;
|
|
2750
|
-
#g = null;
|
|
2751
3047
|
static observedAttributes = ["value", "disabled", "output"];
|
|
2752
3048
|
setup() {
|
|
2753
|
-
this.#m(), this.#
|
|
3049
|
+
this.#m(), this.#Y(), this.#X(), this.#x();
|
|
2754
3050
|
}
|
|
2755
3051
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2756
3052
|
// Parsing / Serialization
|
|
2757
3053
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2758
3054
|
#m() {
|
|
2759
|
-
const t = this.getAttribute("value") ||
|
|
2760
|
-
this.#
|
|
3055
|
+
const t = this.getAttribute("value") || I;
|
|
3056
|
+
this.#b(t) || this.#b(I);
|
|
2761
3057
|
}
|
|
2762
|
-
#
|
|
3058
|
+
#b(t) {
|
|
2763
3059
|
const e = t.trim();
|
|
2764
3060
|
if (!e.startsWith("linear-gradient(") && !e.startsWith("radial-gradient("))
|
|
2765
|
-
return x(e) ? (this.#t = "solid", this.#s = [this.#
|
|
3061
|
+
return x(e) ? (this.#t = "solid", this.#s = [this.#l(e, 0), this.#l(e, 100)], this.#r = this.#s[0].id, !0) : !1;
|
|
2766
3062
|
let s, i;
|
|
2767
3063
|
e.startsWith("linear-gradient(") ? (s = "linear", i = e.slice(16, -1)) : (s = "radial", i = e.slice(16, -1));
|
|
2768
3064
|
let r = 90, a = "circle", n = i;
|
|
@@ -2771,23 +3067,23 @@ class bt extends p {
|
|
|
2771
3067
|
if (d)
|
|
2772
3068
|
r = parseFloat(d[1]), n = i.slice(d[0].length);
|
|
2773
3069
|
else {
|
|
2774
|
-
const
|
|
2775
|
-
if (
|
|
2776
|
-
const b =
|
|
2777
|
-
r = this.#
|
|
3070
|
+
const g = /^to\s+\w+(?:\s+\w+)?\s*,\s*/.exec(i);
|
|
3071
|
+
if (g) {
|
|
3072
|
+
const b = g[0].trim().replace(/,\s*$/, "");
|
|
3073
|
+
r = this.#k(b), n = i.slice(g[0].length);
|
|
2778
3074
|
}
|
|
2779
3075
|
}
|
|
2780
3076
|
} else {
|
|
2781
3077
|
const d = /^(circle|ellipse)(?:\s+at\s+[^,]+)?\s*,\s*/.exec(i);
|
|
2782
3078
|
d && (a = d[1], n = i.slice(d[0].length));
|
|
2783
3079
|
}
|
|
2784
|
-
const
|
|
3080
|
+
const o = [], l = /(#[a-fA-F0-9]{3,8}|rgba?\([^)]+\)|hsla?\([^)]+\)|[a-z]+)\s+([\d.]+)%/g;
|
|
2785
3081
|
let c;
|
|
2786
3082
|
for (; (c = l.exec(n)) !== null; )
|
|
2787
|
-
|
|
2788
|
-
return
|
|
3083
|
+
o.push(this.#l(c[1], parseFloat(c[2])));
|
|
3084
|
+
return o.length < 2 ? !1 : (this.#t = s, this.#e = r, this.#i = a, this.#s = o, this.#r = o[0].id, !0);
|
|
2789
3085
|
}
|
|
2790
|
-
#
|
|
3086
|
+
#k(t) {
|
|
2791
3087
|
return {
|
|
2792
3088
|
"to top": 0,
|
|
2793
3089
|
"to top right": 45,
|
|
@@ -2799,7 +3095,7 @@ class bt extends p {
|
|
|
2799
3095
|
"to top left": 315
|
|
2800
3096
|
}[t] ?? 90;
|
|
2801
3097
|
}
|
|
2802
|
-
#
|
|
3098
|
+
#g() {
|
|
2803
3099
|
if (this.#t === "solid")
|
|
2804
3100
|
return this.#s[0]?.color ?? "#000000";
|
|
2805
3101
|
const t = this.#s.map((e) => `${e.color} ${Math.round(e.position)}%`).join(", ");
|
|
@@ -2808,39 +3104,39 @@ class bt extends p {
|
|
|
2808
3104
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2809
3105
|
// Stop management
|
|
2810
3106
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2811
|
-
#
|
|
2812
|
-
return { id: `stop-${this.#
|
|
3107
|
+
#l(t, e) {
|
|
3108
|
+
return { id: `stop-${this.#a++}`, color: t, position: e };
|
|
2813
3109
|
}
|
|
2814
3110
|
/** CSS left value clamped so the stop handle stays within the bar */
|
|
2815
|
-
#
|
|
3111
|
+
#f(t) {
|
|
2816
3112
|
const e = "calc(var(--ry-gradient-picker-stop-size, 16px) / 2)";
|
|
2817
3113
|
return `clamp(${e}, ${t}%, calc(100% - ${e}))`;
|
|
2818
3114
|
}
|
|
2819
|
-
#
|
|
2820
|
-
const s = this.#
|
|
2821
|
-
this.#s.push(s), this
|
|
3115
|
+
#v(t, e) {
|
|
3116
|
+
const s = this.#l(t, e);
|
|
3117
|
+
this.#s.push(s), this.#$(), this.#r = s.id, this.#C(), this.#x();
|
|
2822
3118
|
}
|
|
2823
|
-
#
|
|
3119
|
+
#y(t) {
|
|
2824
3120
|
if (this.#s.length <= 2) return !1;
|
|
2825
3121
|
const e = this.#s.findIndex((s) => s.id === t);
|
|
2826
|
-
return e === -1 ? !1 : (this.#s.splice(e, 1), this.#r === t && (this.#r = this.#s[Math.min(e, this.#s.length - 1)]?.id ?? null), this.#
|
|
3122
|
+
return e === -1 ? !1 : (this.#s.splice(e, 1), this.#r === t && (this.#r = this.#s[Math.min(e, this.#s.length - 1)]?.id ?? null), this.#C(), this.#x(), !0);
|
|
2827
3123
|
}
|
|
2828
|
-
#
|
|
2829
|
-
this.#r !== t && (this.#r = t, this.#
|
|
3124
|
+
#M(t) {
|
|
3125
|
+
this.#r !== t && (this.#r = t, this.#O(), this.#L());
|
|
2830
3126
|
}
|
|
2831
|
-
|
|
3127
|
+
#$() {
|
|
2832
3128
|
this.#s.sort((t, e) => t.position - e.position);
|
|
2833
3129
|
}
|
|
2834
|
-
#
|
|
3130
|
+
#I() {
|
|
2835
3131
|
return this.#s.find((t) => t.id === this.#r) ?? null;
|
|
2836
3132
|
}
|
|
2837
3133
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2838
3134
|
// Markup
|
|
2839
3135
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2840
|
-
#
|
|
2841
|
-
const t = this.hasAttribute("output"), e =
|
|
2842
|
-
let
|
|
2843
|
-
t && (
|
|
3136
|
+
#Y() {
|
|
3137
|
+
const t = this.hasAttribute("output"), e = p("copy"), s = p("gradient-solid"), i = p("gradient-linear"), r = p("gradient-radial"), a = p("shape-circle"), n = p("shape-ellipse");
|
|
3138
|
+
let o = "";
|
|
3139
|
+
t && (o = `
|
|
2844
3140
|
<div data-ry-target="output-row" class="ry-gradient-picker__output-row">
|
|
2845
3141
|
<input data-ry-target="output" type="text" class="ry-gradient-picker__output" spellcheck="false" />
|
|
2846
3142
|
<button data-ry-target="copy-btn" type="button" class="ry-gradient-picker__copy-btn">${e}</button>
|
|
@@ -2863,15 +3159,15 @@ class bt extends p {
|
|
|
2863
3159
|
<div data-ry-target="bar" class="ry-gradient-picker__bar"></div>
|
|
2864
3160
|
</div>
|
|
2865
3161
|
<ry-color-picker data-ry-target="picker" inline opacity></ry-color-picker>
|
|
2866
|
-
${
|
|
2867
|
-
`, this.#
|
|
3162
|
+
${o}
|
|
3163
|
+
`, this.#n = this.$('[data-ry-target="bar"]'), this.#p = this.$('[data-ry-target="picker"]'), this.#u = this.$('[data-ry-target="output"]'), this.#C();
|
|
2868
3164
|
}
|
|
2869
|
-
#
|
|
2870
|
-
if (this.#
|
|
2871
|
-
this.#
|
|
3165
|
+
#C() {
|
|
3166
|
+
if (this.#n) {
|
|
3167
|
+
this.#n.querySelectorAll('[data-ry-target="stop"]').forEach((t) => t.remove());
|
|
2872
3168
|
for (const t of this.#s) {
|
|
2873
3169
|
const e = document.createElement("div");
|
|
2874
|
-
e.setAttribute("data-ry-target", "stop"), e.setAttribute("data-stop-id", t.id), e.classList.add("ry-gradient-picker__stop"), e.tabIndex = 0, e.style.left = this.#
|
|
3170
|
+
e.setAttribute("data-ry-target", "stop"), e.setAttribute("data-stop-id", t.id), e.classList.add("ry-gradient-picker__stop"), e.tabIndex = 0, e.style.left = this.#f(t.position), e.style.setProperty("--stop-color", t.color), t.id === this.#r && e.setAttribute("data-selected", ""), this.#n.appendChild(e);
|
|
2875
3171
|
}
|
|
2876
3172
|
}
|
|
2877
3173
|
}
|
|
@@ -2879,15 +3175,15 @@ class bt extends p {
|
|
|
2879
3175
|
// Event binding
|
|
2880
3176
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2881
3177
|
#X() {
|
|
2882
|
-
this.#
|
|
3178
|
+
this.#n && (this.on(this.#n, "pointerdown", this.#G), this.on(this.#n, "pointermove", this.#K), this.on(this.#n, "pointerup", this.#q), this.on(this.#n, "lostpointercapture", this.#q));
|
|
2883
3179
|
const t = this.$('[data-ry-target="type-solid"]'), e = this.$('[data-ry-target="type-linear"]'), s = this.$('[data-ry-target="type-radial"]');
|
|
2884
|
-
t && this.on(t, "click", () => this.#
|
|
3180
|
+
t && this.on(t, "click", () => this.#E("solid")), e && this.on(e, "click", () => this.#E("linear")), s && this.on(s, "click", () => this.#E("radial"));
|
|
2885
3181
|
const i = this.$('[data-ry-target="angle-select"]');
|
|
2886
|
-
i && this.on(i, "ry:input", this.#
|
|
3182
|
+
i && this.on(i, "ry:input", this.#z);
|
|
2887
3183
|
const r = this.$('[data-ry-target="shape-circle"]'), a = this.$('[data-ry-target="shape-ellipse"]');
|
|
2888
|
-
r && this.on(r, "click", () => this.#P("circle")), a && this.on(a, "click", () => this.#P("ellipse")), this.#
|
|
3184
|
+
r && this.on(r, "click", () => this.#P("circle")), a && this.on(a, "click", () => this.#P("ellipse")), this.#p && (this.on(this.#p, "ry:input", this.#R), this.on(this.#p, "ry:change", this.#T)), this.#u && (this.on(this.#u, "keydown", this.#F), this.on(this.#u, "blur", this.#j));
|
|
2889
3185
|
const n = this.$('[data-ry-target="copy-btn"]');
|
|
2890
|
-
n && this.on(n, "click", this.#
|
|
3186
|
+
n && this.on(n, "click", this.#U), this.#n && this.on(this.#n, "keydown", this.#J);
|
|
2891
3187
|
}
|
|
2892
3188
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2893
3189
|
// Bar / Stop interaction handlers
|
|
@@ -2898,26 +3194,26 @@ class bt extends p {
|
|
|
2898
3194
|
if (s) {
|
|
2899
3195
|
const i = s.getAttribute("data-stop-id");
|
|
2900
3196
|
if (!i) return;
|
|
2901
|
-
t.preventDefault(), this.#
|
|
3197
|
+
t.preventDefault(), this.#o = i, this.#c = !1, this.#h = this.#n.getBoundingClientRect(), this.#M(i), this.#n.setPointerCapture(t.pointerId), s.focus();
|
|
2902
3198
|
} else {
|
|
2903
|
-
if (t.preventDefault(), !this.#
|
|
2904
|
-
const i = this.#
|
|
2905
|
-
this.#
|
|
3199
|
+
if (t.preventDefault(), !this.#n) return;
|
|
3200
|
+
const i = this.#n.getBoundingClientRect(), r = Math.round(Math.max(0, Math.min(100, (t.clientX - i.left) / i.width * 100))), a = this.#V(r);
|
|
3201
|
+
this.#v(a, r), this.#n.querySelector(`[data-stop-id="${this.#r}"]`)?.focus(), this.#o = this.#r, this.#c = !1, this.#h = i, this.#n.setPointerCapture(t.pointerId), this.#D();
|
|
2906
3202
|
}
|
|
2907
3203
|
};
|
|
2908
3204
|
#K = (t) => {
|
|
2909
|
-
if (!this.#
|
|
2910
|
-
const e = this.#s.find((n) => n.id === this.#
|
|
3205
|
+
if (!this.#o || !this.#h) return;
|
|
3206
|
+
const e = this.#s.find((n) => n.id === this.#o);
|
|
2911
3207
|
if (!e) return;
|
|
2912
|
-
const s = Math.max(0, Math.min(1, (t.clientX - this.#
|
|
3208
|
+
const s = Math.max(0, Math.min(1, (t.clientX - this.#h.left) / this.#h.width));
|
|
2913
3209
|
e.position = Math.round(s * 100);
|
|
2914
|
-
const i = this.#
|
|
2915
|
-
this.#
|
|
2916
|
-
const a = this.#
|
|
2917
|
-
a && (a.style.left = this.#
|
|
3210
|
+
const i = this.#h.top + this.#h.height / 2, r = Math.abs(t.clientY - i);
|
|
3211
|
+
this.#c = r > bt && this.#s.length > 2;
|
|
3212
|
+
const a = this.#n?.querySelector(`[data-stop-id="${e.id}"]`);
|
|
3213
|
+
a && (a.style.left = this.#f(e.position), this.#c ? (a.style.opacity = "0.3", a.style.transform = "translate(-50%, -50%) scale(0.7)") : (a.style.opacity = "", a.style.transform = "")), this.#$(), this.#N(), this.#H(), this.#w(), this.#D();
|
|
2918
3214
|
};
|
|
2919
3215
|
#q = () => {
|
|
2920
|
-
this.#
|
|
3216
|
+
this.#o && (this.#c && this.#y(this.#o), this.#o = null, this.#c = !1, this.#h = null, this.#S(), this.#B());
|
|
2921
3217
|
};
|
|
2922
3218
|
#J = (t) => {
|
|
2923
3219
|
if (this.disabled) return;
|
|
@@ -2925,7 +3221,7 @@ class bt extends p {
|
|
|
2925
3221
|
if (!s) return;
|
|
2926
3222
|
const i = s.getAttribute("data-stop-id");
|
|
2927
3223
|
if (!i) return;
|
|
2928
|
-
const r = this.#s.find((
|
|
3224
|
+
const r = this.#s.find((o) => o.id === i);
|
|
2929
3225
|
if (!r) return;
|
|
2930
3226
|
const a = t.shiftKey ? 10 : 1;
|
|
2931
3227
|
let n = !1;
|
|
@@ -2938,39 +3234,39 @@ class bt extends p {
|
|
|
2938
3234
|
break;
|
|
2939
3235
|
case "Delete":
|
|
2940
3236
|
case "Backspace":
|
|
2941
|
-
this.#
|
|
3237
|
+
this.#y(i) && (this.#D(), this.#B()), t.preventDefault();
|
|
2942
3238
|
return;
|
|
2943
3239
|
}
|
|
2944
|
-
n && (t.preventDefault(), this
|
|
3240
|
+
n && (t.preventDefault(), this.#$(), this.#W(), this.#N(), this.#H(), this.#w(), this.#S(), this.#D(), this.#B());
|
|
2945
3241
|
};
|
|
2946
3242
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2947
3243
|
// Type / Angle / Shape handlers
|
|
2948
3244
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2949
|
-
#
|
|
2950
|
-
this.#t !== t && (this.#t = t, this.setAttribute("data-ry-type", t), this.#
|
|
3245
|
+
#E(t) {
|
|
3246
|
+
this.#t !== t && (this.#t = t, this.setAttribute("data-ry-type", t), this.#_(), this.#H(), this.#w(), this.#S(), this.#D(), this.#B());
|
|
2951
3247
|
}
|
|
2952
|
-
#
|
|
3248
|
+
#z = (t) => {
|
|
2953
3249
|
const e = t.detail;
|
|
2954
|
-
this.#e = e.value, this.#H(), this.#
|
|
3250
|
+
this.#e = e.value, this.#H(), this.#w(), this.#S(), this.#D();
|
|
2955
3251
|
};
|
|
2956
3252
|
#P(t) {
|
|
2957
|
-
this.#i !== t && (this.#i = t, this.#
|
|
3253
|
+
this.#i !== t && (this.#i = t, this.#_(), this.#w(), this.#S(), this.#D(), this.#B());
|
|
2958
3254
|
}
|
|
2959
3255
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2960
3256
|
// Color picker handlers
|
|
2961
3257
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2962
|
-
#
|
|
2963
|
-
const t = this.#
|
|
2964
|
-
!t || !this.#
|
|
3258
|
+
#R = () => {
|
|
3259
|
+
const t = this.#I();
|
|
3260
|
+
!t || !this.#p || (t.color = this.#p.value, this.#Z(t), this.#N(), this.#H(), this.#w(), this.#D());
|
|
2965
3261
|
};
|
|
2966
3262
|
#T = () => {
|
|
2967
|
-
this.#
|
|
3263
|
+
this.#S(), this.#B();
|
|
2968
3264
|
};
|
|
2969
3265
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2970
3266
|
// Copy handler
|
|
2971
3267
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2972
|
-
#
|
|
2973
|
-
const t = this.#
|
|
3268
|
+
#U = () => {
|
|
3269
|
+
const t = this.#g();
|
|
2974
3270
|
navigator.clipboard.writeText(t).then(() => {
|
|
2975
3271
|
const e = this.$('[data-ry-target="copy-btn"]');
|
|
2976
3272
|
e && (e.setAttribute("data-copied", ""), setTimeout(() => e.removeAttribute("data-copied"), 1500));
|
|
@@ -2979,21 +3275,21 @@ class bt extends p {
|
|
|
2979
3275
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2980
3276
|
// Output (editable CSS) handlers
|
|
2981
3277
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2982
|
-
#
|
|
2983
|
-
t.key === "Enter" && (t.preventDefault(), this.#
|
|
3278
|
+
#F = (t) => {
|
|
3279
|
+
t.key === "Enter" && (t.preventDefault(), this.#A());
|
|
2984
3280
|
};
|
|
2985
3281
|
#j = () => {
|
|
2986
|
-
this.#
|
|
3282
|
+
this.#A();
|
|
2987
3283
|
};
|
|
2988
|
-
#
|
|
2989
|
-
if (!this.#
|
|
2990
|
-
const t = this.#
|
|
2991
|
-
t && this.#
|
|
3284
|
+
#A() {
|
|
3285
|
+
if (!this.#u) return;
|
|
3286
|
+
const t = this.#u.value.trim();
|
|
3287
|
+
t && this.#b(t) ? (this.#C(), this.#x(), this.#S(), this.#D(), this.#B()) : this.#w();
|
|
2992
3288
|
}
|
|
2993
3289
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2994
3290
|
// Color interpolation
|
|
2995
3291
|
// ───────────────────────────────────────────────────────────────────────────
|
|
2996
|
-
#
|
|
3292
|
+
#V(t) {
|
|
2997
3293
|
if (this.#s.length === 0) return "#808080";
|
|
2998
3294
|
if (this.#s.length === 1) return this.#s[0].color;
|
|
2999
3295
|
const e = [...this.#s].sort((l, c) => l.position - c.position);
|
|
@@ -3007,16 +3303,16 @@ class bt extends p {
|
|
|
3007
3303
|
}
|
|
3008
3304
|
const r = i.position - s.position;
|
|
3009
3305
|
if (r === 0) return s.color;
|
|
3010
|
-
const a = (t - s.position) / r, n = x(s.color),
|
|
3011
|
-
return !n || !
|
|
3306
|
+
const a = (t - s.position) / r, n = x(s.color), o = x(i.color);
|
|
3307
|
+
return !n || !o ? s.color : ft(yt(n, o, a));
|
|
3012
3308
|
}
|
|
3013
3309
|
// ───────────────────────────────────────────────────────────────────────────
|
|
3014
3310
|
// Update methods
|
|
3015
3311
|
// ───────────────────────────────────────────────────────────────────────────
|
|
3016
|
-
#$() {
|
|
3017
|
-
this.setAttribute("data-ry-type", this.#t), this.#x(), this.#O(), this.#H(), this.#z(), this.#N(), this.#L(), this.#k();
|
|
3018
|
-
}
|
|
3019
3312
|
#x() {
|
|
3313
|
+
this.setAttribute("data-ry-type", this.#t), this.#_(), this.#N(), this.#H(), this.#W(), this.#O(), this.#L(), this.#w();
|
|
3314
|
+
}
|
|
3315
|
+
#_() {
|
|
3020
3316
|
const t = this.$('[data-ry-target="type-solid"]'), e = this.$('[data-ry-target="type-linear"]'), s = this.$('[data-ry-target="type-radial"]');
|
|
3021
3317
|
t && t.toggleAttribute("data-active", this.#t === "solid"), e && e.toggleAttribute("data-active", this.#t === "linear"), s && s.toggleAttribute("data-active", this.#t === "radial");
|
|
3022
3318
|
const i = this.$('[data-ry-target="shape-circle"]'), r = this.$('[data-ry-target="shape-ellipse"]');
|
|
@@ -3025,59 +3321,59 @@ class bt extends p {
|
|
|
3025
3321
|
a && a.setAttribute("value", String(this.#e));
|
|
3026
3322
|
}
|
|
3027
3323
|
#H() {
|
|
3028
|
-
if (!this.#
|
|
3029
|
-
const t = this.#
|
|
3030
|
-
t && (t.style.backgroundImage = this.#t === "solid" ? "" : this.#
|
|
3324
|
+
if (!this.#p) return;
|
|
3325
|
+
const t = this.#p.querySelector('[data-ry-target="preview-color"]');
|
|
3326
|
+
t && (t.style.backgroundImage = this.#t === "solid" ? "" : this.#g());
|
|
3031
3327
|
}
|
|
3032
|
-
#
|
|
3033
|
-
if (!this.#
|
|
3328
|
+
#N() {
|
|
3329
|
+
if (!this.#n) return;
|
|
3034
3330
|
const t = this.#s.map((e) => `${e.color} ${e.position}%`).join(", ");
|
|
3035
|
-
this.#
|
|
3331
|
+
this.#n.style.backgroundImage = `linear-gradient(to right, ${t})`;
|
|
3036
3332
|
}
|
|
3037
|
-
#
|
|
3038
|
-
if (this.#
|
|
3333
|
+
#W() {
|
|
3334
|
+
if (this.#n)
|
|
3039
3335
|
for (const t of this.#s) {
|
|
3040
|
-
const e = this.#
|
|
3041
|
-
e && (e.style.left = this.#
|
|
3336
|
+
const e = this.#n.querySelector(`[data-stop-id="${t.id}"]`);
|
|
3337
|
+
e && (e.style.left = this.#f(t.position));
|
|
3042
3338
|
}
|
|
3043
3339
|
}
|
|
3044
3340
|
#Z(t) {
|
|
3045
|
-
if (!this.#
|
|
3046
|
-
const e = this.#
|
|
3341
|
+
if (!this.#n) return;
|
|
3342
|
+
const e = this.#n.querySelector(`[data-stop-id="${t.id}"]`);
|
|
3047
3343
|
e && e.style.setProperty("--stop-color", t.color);
|
|
3048
3344
|
}
|
|
3049
|
-
#
|
|
3050
|
-
if (!this.#
|
|
3051
|
-
const t = this.#
|
|
3345
|
+
#O() {
|
|
3346
|
+
if (!this.#n) return;
|
|
3347
|
+
const t = this.#n.querySelectorAll('[data-ry-target="stop"]');
|
|
3052
3348
|
for (const e of t)
|
|
3053
3349
|
e.getAttribute("data-stop-id") === this.#r ? e.setAttribute("data-selected", "") : e.removeAttribute("data-selected");
|
|
3054
3350
|
}
|
|
3055
3351
|
#L() {
|
|
3056
|
-
const t = this.#
|
|
3057
|
-
!t || !this.#
|
|
3352
|
+
const t = this.#I();
|
|
3353
|
+
!t || !this.#p || this.#p.setColor(t.color);
|
|
3058
3354
|
}
|
|
3059
|
-
#
|
|
3060
|
-
this.#
|
|
3355
|
+
#w() {
|
|
3356
|
+
this.#u && document.activeElement !== this.#u && (this.#u.value = this.#g());
|
|
3061
3357
|
}
|
|
3062
|
-
#
|
|
3063
|
-
const t = this.#
|
|
3064
|
-
this.getAttribute("value") !== t && (this.#
|
|
3358
|
+
#S() {
|
|
3359
|
+
const t = this.#g();
|
|
3360
|
+
this.getAttribute("value") !== t && (this.#d = !0, this.setAttribute("value", t), this.#d = !1);
|
|
3065
3361
|
}
|
|
3066
3362
|
// ───────────────────────────────────────────────────────────────────────────
|
|
3067
3363
|
// Events
|
|
3068
3364
|
// ───────────────────────────────────────────────────────────────────────────
|
|
3069
|
-
#
|
|
3365
|
+
#D() {
|
|
3070
3366
|
this.emit("input", {
|
|
3071
|
-
value: this.#
|
|
3367
|
+
value: this.#g(),
|
|
3072
3368
|
type: this.#t,
|
|
3073
3369
|
angle: this.#e,
|
|
3074
3370
|
shape: this.#i,
|
|
3075
3371
|
stops: this.stops
|
|
3076
3372
|
});
|
|
3077
3373
|
}
|
|
3078
|
-
#
|
|
3374
|
+
#B() {
|
|
3079
3375
|
this.emit("change", {
|
|
3080
|
-
value: this.#
|
|
3376
|
+
value: this.#g(),
|
|
3081
3377
|
type: this.#t,
|
|
3082
3378
|
angle: this.#e,
|
|
3083
3379
|
shape: this.#i,
|
|
@@ -3088,28 +3384,28 @@ class bt extends p {
|
|
|
3088
3384
|
// Attribute changed
|
|
3089
3385
|
// ───────────────────────────────────────────────────────────────────────────
|
|
3090
3386
|
attributeChangedCallback(t, e, s) {
|
|
3091
|
-
e === s || this.#
|
|
3387
|
+
e === s || this.#d || t === "value" && this.#n && s && this.#b(s) && (this.#C(), this.#x());
|
|
3092
3388
|
}
|
|
3093
3389
|
// ───────────────────────────────────────────────────────────────────────────
|
|
3094
3390
|
// Public API
|
|
3095
3391
|
// ───────────────────────────────────────────────────────────────────────────
|
|
3096
3392
|
get value() {
|
|
3097
|
-
return this.#
|
|
3393
|
+
return this.#g();
|
|
3098
3394
|
}
|
|
3099
3395
|
set value(t) {
|
|
3100
|
-
this.#
|
|
3396
|
+
this.#b(t) && (this.#C(), this.#x(), this.#S());
|
|
3101
3397
|
}
|
|
3102
3398
|
get type() {
|
|
3103
3399
|
return this.#t;
|
|
3104
3400
|
}
|
|
3105
3401
|
set type(t) {
|
|
3106
|
-
this.#
|
|
3402
|
+
this.#E(t);
|
|
3107
3403
|
}
|
|
3108
3404
|
get angle() {
|
|
3109
3405
|
return this.#e;
|
|
3110
3406
|
}
|
|
3111
3407
|
set angle(t) {
|
|
3112
|
-
this.#e = (t % 360 + 360) % 360, this.#
|
|
3408
|
+
this.#e = (t % 360 + 360) % 360, this.#_(), this.#w(), this.#S();
|
|
3113
3409
|
}
|
|
3114
3410
|
get shape() {
|
|
3115
3411
|
return this.#i;
|
|
@@ -3121,7 +3417,7 @@ class bt extends p {
|
|
|
3121
3417
|
return this.#s.map((t) => ({ ...t }));
|
|
3122
3418
|
}
|
|
3123
3419
|
get selectedStop() {
|
|
3124
|
-
const t = this.#
|
|
3420
|
+
const t = this.#I();
|
|
3125
3421
|
return t ? { ...t } : null;
|
|
3126
3422
|
}
|
|
3127
3423
|
get disabled() {
|
|
@@ -3131,31 +3427,31 @@ class bt extends p {
|
|
|
3131
3427
|
t ? this.setAttribute("disabled", "") : this.removeAttribute("disabled");
|
|
3132
3428
|
}
|
|
3133
3429
|
addStop(t, e) {
|
|
3134
|
-
this.#
|
|
3430
|
+
this.#v(t, e), this.#S(), this.#D(), this.#B();
|
|
3135
3431
|
}
|
|
3136
3432
|
removeStop(t) {
|
|
3137
|
-
const e = this.#
|
|
3138
|
-
return e && (this.#
|
|
3433
|
+
const e = this.#y(t);
|
|
3434
|
+
return e && (this.#w(), this.#S(), this.#B()), e;
|
|
3139
3435
|
}
|
|
3140
3436
|
}
|
|
3141
|
-
customElements.define("ry-gradient-picker",
|
|
3142
|
-
let
|
|
3143
|
-
const
|
|
3144
|
-
function _(
|
|
3145
|
-
return
|
|
3437
|
+
customElements.define("ry-gradient-picker", mt);
|
|
3438
|
+
let vt = 0;
|
|
3439
|
+
const At = 5;
|
|
3440
|
+
function _(h) {
|
|
3441
|
+
return p(h).replace(/width="24"/g, 'width="16"').replace(/height="24"/g, 'height="16"').replace(/viewBox/, 'class="ry-tree__icon" viewBox');
|
|
3146
3442
|
}
|
|
3147
|
-
class k extends
|
|
3443
|
+
class k extends u {
|
|
3148
3444
|
// Drag state
|
|
3149
3445
|
#t = !1;
|
|
3150
3446
|
#e = !1;
|
|
3151
3447
|
#i = 0;
|
|
3152
3448
|
#s = 0;
|
|
3153
3449
|
#r = null;
|
|
3154
|
-
#
|
|
3155
|
-
#
|
|
3156
|
-
#
|
|
3450
|
+
#a = null;
|
|
3451
|
+
#o = null;
|
|
3452
|
+
#c = null;
|
|
3157
3453
|
setup() {
|
|
3158
|
-
this.#
|
|
3454
|
+
this.#h(), this.on(this, "click", (t) => {
|
|
3159
3455
|
const s = t.target.closest('[data-ry-target="file"]');
|
|
3160
3456
|
s && (this.$$("[data-ry-selected]").forEach((i) => i.removeAttribute("data-ry-selected")), s.setAttribute("data-ry-selected", ""), this.emit("select", {
|
|
3161
3457
|
label: s.dataset.ryLabel ?? ""
|
|
@@ -3171,39 +3467,39 @@ class k extends p {
|
|
|
3171
3467
|
}), this.hasAttribute("sortable") && this.#m();
|
|
3172
3468
|
}
|
|
3173
3469
|
// ── Build ──────────────────────────────────────────────────
|
|
3174
|
-
#
|
|
3470
|
+
#h() {
|
|
3175
3471
|
if (this.$(".ry-tree__root")) return;
|
|
3176
3472
|
const t = Array.from(this.children), e = document.createElement("ul");
|
|
3177
3473
|
e.className = "ry-tree__root";
|
|
3178
3474
|
for (const s of t)
|
|
3179
|
-
e.appendChild(this.#
|
|
3475
|
+
e.appendChild(this.#d(s));
|
|
3180
3476
|
this.innerHTML = "", this.appendChild(e);
|
|
3181
3477
|
}
|
|
3182
|
-
#
|
|
3478
|
+
#d(t) {
|
|
3183
3479
|
const e = document.createElement("li");
|
|
3184
3480
|
e.className = "ry-tree__item";
|
|
3185
3481
|
const s = t.getAttribute("label") ?? "", i = t.hasAttribute("open"), r = t.hasAttribute("selected"), a = Array.from(t.children).filter(
|
|
3186
|
-
(
|
|
3482
|
+
(o) => o.tagName === "RY-TREE-ITEM"
|
|
3187
3483
|
);
|
|
3188
3484
|
if (a.length > 0) {
|
|
3189
|
-
const
|
|
3190
|
-
l.type = "checkbox", l.id =
|
|
3485
|
+
const o = `ry-tree-${++vt}`, l = document.createElement("input");
|
|
3486
|
+
l.type = "checkbox", l.id = o, l.className = "ry-tree__toggle", i && (l.checked = !0);
|
|
3191
3487
|
const c = document.createElement("label");
|
|
3192
|
-
c.htmlFor =
|
|
3488
|
+
c.htmlFor = o, c.className = "ry-tree__label", c.setAttribute("data-ry-target", "folder"), c.dataset.ryLabel = s, c.innerHTML = `
|
|
3193
3489
|
<span class="ry-tree__icon-closed">${_("folder")}</span>
|
|
3194
3490
|
<span class="ry-tree__icon-open">${_("folder-open")}</span>
|
|
3195
3491
|
${s}
|
|
3196
3492
|
`;
|
|
3197
3493
|
const d = document.createElement("div");
|
|
3198
3494
|
d.className = "ry-tree__children-wrapper";
|
|
3199
|
-
const
|
|
3200
|
-
|
|
3495
|
+
const g = document.createElement("ul");
|
|
3496
|
+
g.className = "ry-tree__children";
|
|
3201
3497
|
for (const b of a)
|
|
3202
|
-
|
|
3203
|
-
d.appendChild(
|
|
3498
|
+
g.appendChild(this.#d(b));
|
|
3499
|
+
d.appendChild(g), e.appendChild(l), e.appendChild(c), e.appendChild(d);
|
|
3204
3500
|
} else {
|
|
3205
|
-
const
|
|
3206
|
-
|
|
3501
|
+
const o = document.createElement("div");
|
|
3502
|
+
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);
|
|
3207
3503
|
}
|
|
3208
3504
|
return e;
|
|
3209
3505
|
}
|
|
@@ -3211,24 +3507,24 @@ class k extends p {
|
|
|
3211
3507
|
/** Serialize the current tree state to JSON. */
|
|
3212
3508
|
toJSON() {
|
|
3213
3509
|
const t = this.$(".ry-tree__root");
|
|
3214
|
-
return t ? this.#
|
|
3510
|
+
return t ? this.#n(t) : [];
|
|
3215
3511
|
}
|
|
3216
3512
|
/** Alias for toJSON(). */
|
|
3217
3513
|
get value() {
|
|
3218
3514
|
return this.toJSON();
|
|
3219
3515
|
}
|
|
3220
|
-
#
|
|
3516
|
+
#n(t) {
|
|
3221
3517
|
return Array.from(t.children).filter(
|
|
3222
3518
|
(s) => s instanceof HTMLElement && s.classList.contains("ry-tree__item")
|
|
3223
|
-
).map((s) => this.#
|
|
3519
|
+
).map((s) => this.#p(s));
|
|
3224
3520
|
}
|
|
3225
|
-
#
|
|
3521
|
+
#p(t) {
|
|
3226
3522
|
const e = t.querySelector(':scope > [data-ry-target="folder"]'), s = t.querySelector(':scope > [data-ry-target="file"]');
|
|
3227
3523
|
if (e) {
|
|
3228
3524
|
const r = t.querySelector(":scope > .ry-tree__toggle"), a = t.querySelector(".ry-tree__children"), n = { label: e.dataset.ryLabel ?? "" };
|
|
3229
3525
|
if (r?.checked && (n.open = !0), a) {
|
|
3230
|
-
const
|
|
3231
|
-
|
|
3526
|
+
const o = this.#n(a);
|
|
3527
|
+
o.length > 0 && (n.children = o);
|
|
3232
3528
|
}
|
|
3233
3529
|
return n;
|
|
3234
3530
|
}
|
|
@@ -3239,83 +3535,83 @@ class k extends p {
|
|
|
3239
3535
|
static from(t) {
|
|
3240
3536
|
const e = document.createElement("ry-tree");
|
|
3241
3537
|
for (const s of t)
|
|
3242
|
-
e.appendChild(k.#
|
|
3538
|
+
e.appendChild(k.#u(s));
|
|
3243
3539
|
return e;
|
|
3244
3540
|
}
|
|
3245
|
-
static #
|
|
3541
|
+
static #u(t) {
|
|
3246
3542
|
const e = document.createElement("ry-tree-item");
|
|
3247
3543
|
if (e.setAttribute("label", t.label), t.open && e.setAttribute("open", ""), t.selected && e.setAttribute("selected", ""), t.children)
|
|
3248
3544
|
for (const s of t.children)
|
|
3249
|
-
e.appendChild(k.#
|
|
3545
|
+
e.appendChild(k.#u(s));
|
|
3250
3546
|
return e;
|
|
3251
3547
|
}
|
|
3252
3548
|
// ── Drag and Drop ──────────────────────────────────────────
|
|
3253
3549
|
#m() {
|
|
3254
|
-
this.on(this, "pointerdown", this.#
|
|
3550
|
+
this.on(this, "pointerdown", this.#b), this.on(document, "pointermove", this.#k), this.on(document, "pointerup", this.#g);
|
|
3255
3551
|
}
|
|
3256
|
-
#
|
|
3552
|
+
#b = (t) => {
|
|
3257
3553
|
const s = t.target.closest(".ry-tree__label, .ry-tree__file");
|
|
3258
3554
|
if (!s) return;
|
|
3259
3555
|
const i = s.closest(".ry-tree__item");
|
|
3260
3556
|
i && (this.#t = !0, this.#i = t.clientX, this.#s = t.clientY, this.#r = i);
|
|
3261
3557
|
};
|
|
3262
|
-
#
|
|
3558
|
+
#k = (t) => {
|
|
3263
3559
|
if (!this.#t && !this.#e) return;
|
|
3264
3560
|
if (this.#t && !this.#e) {
|
|
3265
3561
|
const c = t.clientX - this.#i, d = t.clientY - this.#s;
|
|
3266
|
-
if (Math.hypot(c, d) <
|
|
3267
|
-
this.#t = !1, this.#e = !0, this.#
|
|
3562
|
+
if (Math.hypot(c, d) < At) return;
|
|
3563
|
+
this.#t = !1, this.#e = !0, this.#l(t);
|
|
3268
3564
|
}
|
|
3269
|
-
if (!this.#e || !this.#
|
|
3270
|
-
this.#
|
|
3565
|
+
if (!this.#e || !this.#a) return;
|
|
3566
|
+
this.#a.style.left = `${t.clientX + 12}px`, this.#a.style.top = `${t.clientY - 14}px`, this.#a.style.display = "none";
|
|
3271
3567
|
const e = document.elementFromPoint(t.clientX, t.clientY);
|
|
3272
|
-
if (this.#
|
|
3273
|
-
this.#
|
|
3568
|
+
if (this.#a.style.display = "", !e) {
|
|
3569
|
+
this.#y();
|
|
3274
3570
|
return;
|
|
3275
3571
|
}
|
|
3276
3572
|
const s = e.closest(".ry-tree__label, .ry-tree__file");
|
|
3277
3573
|
if (!s) {
|
|
3278
|
-
this.#
|
|
3574
|
+
this.#y();
|
|
3279
3575
|
return;
|
|
3280
3576
|
}
|
|
3281
3577
|
const i = s.closest(".ry-tree__item");
|
|
3282
3578
|
if (!i || i === this.#r) {
|
|
3283
|
-
this.#
|
|
3579
|
+
this.#y();
|
|
3284
3580
|
return;
|
|
3285
3581
|
}
|
|
3286
3582
|
if (this.#r?.contains(i)) {
|
|
3287
|
-
this.#
|
|
3583
|
+
this.#y();
|
|
3288
3584
|
return;
|
|
3289
3585
|
}
|
|
3290
|
-
const r = s.getBoundingClientRect(), a = t.clientY - r.top, n = r.height,
|
|
3586
|
+
const r = s.getBoundingClientRect(), a = t.clientY - r.top, n = r.height, o = i.querySelector(":scope > .ry-tree__toggle") !== null;
|
|
3291
3587
|
let l;
|
|
3292
|
-
|
|
3588
|
+
o && a > n * 0.25 && a < n * 0.75 ? l = "inside" : a < n * 0.5 ? l = "before" : l = "after", this.#v(i, l);
|
|
3293
3589
|
};
|
|
3294
|
-
#
|
|
3295
|
-
this.#e && this.#
|
|
3590
|
+
#g = () => {
|
|
3591
|
+
this.#e && this.#f(), this.#t = !1, this.#e = !1, this.#r = null;
|
|
3296
3592
|
};
|
|
3297
|
-
#
|
|
3593
|
+
#l(t) {
|
|
3298
3594
|
if (!this.#r) return;
|
|
3299
3595
|
t.preventDefault(), this.#r.setAttribute("data-ry-dragging", ""), this.#r.classList.add("ry-tree__item--collapsed");
|
|
3300
3596
|
const e = this.#r.querySelector(".ry-tree__label, .ry-tree__file");
|
|
3301
3597
|
if (!e) return;
|
|
3302
3598
|
const s = e.cloneNode(!0);
|
|
3303
|
-
s.className = "ry-tree__ghost", s.style.display = "flex", s.style.alignItems = "center", s.style.gap = "var(--ry-space-2, 0.5rem)", s.style.padding = "var(--ry-space-1, 0.25rem) var(--ry-space-2, 0.5rem)", s.style.height = "28px", s.style.fontSize = "var(--ry-text-sm, 0.875rem)", s.style.whiteSpace = "nowrap", s.style.left = `${t.clientX + 12}px`, s.style.top = `${t.clientY - 14}px`, document.body.appendChild(s), this.#
|
|
3599
|
+
s.className = "ry-tree__ghost", s.style.display = "flex", s.style.alignItems = "center", s.style.gap = "var(--ry-space-2, 0.5rem)", s.style.padding = "var(--ry-space-1, 0.25rem) var(--ry-space-2, 0.5rem)", s.style.height = "28px", s.style.fontSize = "var(--ry-text-sm, 0.875rem)", s.style.whiteSpace = "nowrap", s.style.left = `${t.clientX + 12}px`, s.style.top = `${t.clientY - 14}px`, document.body.appendChild(s), this.#a = s;
|
|
3304
3600
|
}
|
|
3305
|
-
#
|
|
3306
|
-
this.#
|
|
3307
|
-
const t = this.#
|
|
3308
|
-
this.#
|
|
3601
|
+
#f() {
|
|
3602
|
+
this.#a?.parentNode && this.#a.parentNode.removeChild(this.#a), this.#a = null, this.#r?.classList.remove("ry-tree__item--collapsed"), this.#r?.removeAttribute("data-ry-dragging");
|
|
3603
|
+
const t = this.#o, e = this.#c;
|
|
3604
|
+
this.#y(), this.#r && t && e && this.#M(this.#r, t, e);
|
|
3309
3605
|
}
|
|
3310
|
-
#
|
|
3311
|
-
this.#
|
|
3606
|
+
#v(t, e) {
|
|
3607
|
+
this.#o === t && this.#c === e || (this.#y(), t.setAttribute("data-ry-drop-target", e), this.#o = t, this.#c = e);
|
|
3312
3608
|
}
|
|
3313
|
-
#
|
|
3314
|
-
this.#
|
|
3609
|
+
#y() {
|
|
3610
|
+
this.#o?.removeAttribute("data-ry-drop-target"), this.#o = null, this.#c = null;
|
|
3315
3611
|
}
|
|
3316
|
-
#
|
|
3612
|
+
#M(t, e, s) {
|
|
3317
3613
|
if (s === "inside" && e.contains(t)) return;
|
|
3318
|
-
const i = this
|
|
3614
|
+
const i = this.#$(t), r = this.#$(e);
|
|
3319
3615
|
if (s === "before")
|
|
3320
3616
|
e.parentNode?.insertBefore(t, e);
|
|
3321
3617
|
else if (s === "after")
|
|
@@ -3334,50 +3630,285 @@ class k extends p {
|
|
|
3334
3630
|
position: s
|
|
3335
3631
|
});
|
|
3336
3632
|
}
|
|
3337
|
-
|
|
3633
|
+
#$(t) {
|
|
3338
3634
|
const e = t.querySelector(':scope > [data-ry-target="folder"]'), s = t.querySelector(':scope > [data-ry-target="file"]');
|
|
3339
3635
|
return e?.dataset.ryLabel ?? s?.dataset.ryLabel ?? "";
|
|
3340
3636
|
}
|
|
3341
3637
|
}
|
|
3342
|
-
class
|
|
3638
|
+
class kt extends u {
|
|
3343
3639
|
// Declarative container consumed by RyTree#build
|
|
3344
3640
|
}
|
|
3345
3641
|
customElements.define("ry-tree", k);
|
|
3346
|
-
customElements.define("ry-tree-item",
|
|
3642
|
+
customElements.define("ry-tree-item", kt);
|
|
3643
|
+
class wt extends u {
|
|
3644
|
+
setup() {
|
|
3645
|
+
this.#t();
|
|
3646
|
+
}
|
|
3647
|
+
#t() {
|
|
3648
|
+
if (this.$('[data-ry-target="label"]')) return;
|
|
3649
|
+
const t = this.textContent?.trim() ?? "", e = this.hasAttribute("removable");
|
|
3650
|
+
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) {
|
|
3651
|
+
const s = this.$('[data-ry-target="remove"]');
|
|
3652
|
+
s && this.on(s, "click", (i) => {
|
|
3653
|
+
i.stopPropagation(), this.emit("remove", {
|
|
3654
|
+
value: this.dataset.value ?? "",
|
|
3655
|
+
label: t
|
|
3656
|
+
}), this.remove();
|
|
3657
|
+
});
|
|
3658
|
+
}
|
|
3659
|
+
}
|
|
3660
|
+
get label() {
|
|
3661
|
+
return this.$('[data-ry-target="label"]')?.textContent?.trim() ?? "";
|
|
3662
|
+
}
|
|
3663
|
+
}
|
|
3664
|
+
customElements.define("ry-tag", wt);
|
|
3665
|
+
class $t extends u {
|
|
3666
|
+
#t = [];
|
|
3667
|
+
setup() {
|
|
3668
|
+
this.#e(), this.#i();
|
|
3669
|
+
}
|
|
3670
|
+
#e() {
|
|
3671
|
+
if (this.$('[data-ry-target="container"]')) return;
|
|
3672
|
+
const t = this.getAttribute("placeholder") ?? "Add tag...", e = this.getAttribute("name") ?? "", s = this.hasAttribute("disabled");
|
|
3673
|
+
this.innerHTML = `
|
|
3674
|
+
<div data-ry-target="container" class="ry-tag-input__container">
|
|
3675
|
+
<div data-ry-target="tags" class="ry-tag-input__tags"></div>
|
|
3676
|
+
<input data-ry-target="input" class="ry-tag-input__input" type="text" placeholder="${t}" ${s ? "disabled" : ""}>
|
|
3677
|
+
</div>
|
|
3678
|
+
<input data-ry-target="hidden" type="hidden" ${e ? `name="${e}"` : ""}>
|
|
3679
|
+
`;
|
|
3680
|
+
const i = this.$('[data-ry-target="input"]');
|
|
3681
|
+
i && (this.on(i, "keydown", this.#s), this.on(i, "paste", this.#r));
|
|
3682
|
+
const r = this.$('[data-ry-target="container"]');
|
|
3683
|
+
r && this.on(r, "click", () => i?.focus()), this.on(this, "ry:remove", this.#a);
|
|
3684
|
+
}
|
|
3685
|
+
#i() {
|
|
3686
|
+
const t = this.getAttribute("value");
|
|
3687
|
+
if (!t) return;
|
|
3688
|
+
const e = this.getAttribute("delimiter") ?? ",", s = t.split(e).map((i) => i.trim()).filter(Boolean);
|
|
3689
|
+
for (const i of s)
|
|
3690
|
+
this.#o(i);
|
|
3691
|
+
}
|
|
3692
|
+
#s = (t) => {
|
|
3693
|
+
const e = t.target, s = this.getAttribute("delimiter") ?? ",", i = e.value.trim();
|
|
3694
|
+
if (t.key === "Enter" || t.key === s || t.key === "Tab") {
|
|
3695
|
+
if (i)
|
|
3696
|
+
t.preventDefault(), this.#o(i), e.value = "";
|
|
3697
|
+
else if (t.key === "Tab")
|
|
3698
|
+
return;
|
|
3699
|
+
}
|
|
3700
|
+
t.key === "Backspace" && !e.value && this.#t.length > 0 && this.#c();
|
|
3701
|
+
};
|
|
3702
|
+
#r = (t) => {
|
|
3703
|
+
t.preventDefault();
|
|
3704
|
+
const e = t.clipboardData?.getData("text") ?? "", s = this.getAttribute("delimiter") ?? ",", i = e.split(new RegExp(`[${s}\\t\\n]+`)).map((a) => a.trim()).filter(Boolean);
|
|
3705
|
+
for (const a of i)
|
|
3706
|
+
this.#o(a);
|
|
3707
|
+
const r = this.$('[data-ry-target="input"]');
|
|
3708
|
+
r && (r.value = "");
|
|
3709
|
+
};
|
|
3710
|
+
#a = (t) => {
|
|
3711
|
+
const e = t.detail.value, s = this.#t.indexOf(e);
|
|
3712
|
+
s >= 0 && (this.#t.splice(s, 1), this.#h(), this.emit("change", { values: [...this.#t] }));
|
|
3713
|
+
};
|
|
3714
|
+
#o(t) {
|
|
3715
|
+
const e = this.getAttribute("max-tags");
|
|
3716
|
+
if (e && this.#t.length >= parseInt(e, 10) || !this.hasAttribute("allow-duplicates") && this.#t.includes(t)) return;
|
|
3717
|
+
this.#t.push(t);
|
|
3718
|
+
const s = this.$('[data-ry-target="tags"]');
|
|
3719
|
+
if (s) {
|
|
3720
|
+
const i = document.createElement("ry-tag");
|
|
3721
|
+
i.setAttribute("removable", ""), i.setAttribute("size", "sm"), i.setAttribute("data-value", t), i.textContent = t, s.appendChild(i);
|
|
3722
|
+
}
|
|
3723
|
+
this.#h(), this.emit("add", { value: t }), this.emit("change", { values: [...this.#t] });
|
|
3724
|
+
}
|
|
3725
|
+
#c() {
|
|
3726
|
+
const e = this.$('[data-ry-target="tags"]')?.lastElementChild;
|
|
3727
|
+
if (e) {
|
|
3728
|
+
const s = e.dataset.value ?? "";
|
|
3729
|
+
e.remove(), this.#t.pop(), this.#h(), this.emit("remove", { value: s, label: s }), this.emit("change", { values: [...this.#t] });
|
|
3730
|
+
}
|
|
3731
|
+
}
|
|
3732
|
+
#h() {
|
|
3733
|
+
const t = this.$('[data-ry-target="hidden"]'), e = this.getAttribute("delimiter") ?? ",";
|
|
3734
|
+
t && (t.value = this.#t.join(e));
|
|
3735
|
+
}
|
|
3736
|
+
get value() {
|
|
3737
|
+
const t = this.getAttribute("delimiter") ?? ",";
|
|
3738
|
+
return this.#t.join(t);
|
|
3739
|
+
}
|
|
3740
|
+
get values() {
|
|
3741
|
+
return [...this.#t];
|
|
3742
|
+
}
|
|
3743
|
+
}
|
|
3744
|
+
customElements.define("ry-tag-input", $t);
|
|
3745
|
+
class xt extends u {
|
|
3746
|
+
}
|
|
3747
|
+
customElements.define("ry-hero", xt);
|
|
3748
|
+
class _t extends u {
|
|
3749
|
+
setup() {
|
|
3750
|
+
this.#t();
|
|
3751
|
+
}
|
|
3752
|
+
#t() {
|
|
3753
|
+
if (this.$('[data-ry-target="value"]')) return;
|
|
3754
|
+
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>` : "";
|
|
3755
|
+
this.innerHTML = `
|
|
3756
|
+
<div data-ry-target="value" class="ry-stat__value">${i}${a}</div>
|
|
3757
|
+
<div data-ry-target="label" class="ry-stat__label">${r}</div>
|
|
3758
|
+
`;
|
|
3759
|
+
}
|
|
3760
|
+
}
|
|
3761
|
+
customElements.define("ry-stat", _t);
|
|
3762
|
+
class Mt extends u {
|
|
3763
|
+
setup() {
|
|
3764
|
+
this.#t();
|
|
3765
|
+
}
|
|
3766
|
+
#t() {
|
|
3767
|
+
if (this.$('[data-ry-target="icon"]')) return;
|
|
3768
|
+
const t = this.getAttribute("icon");
|
|
3769
|
+
if (!t) return;
|
|
3770
|
+
const e = p(t);
|
|
3771
|
+
if (!e) return;
|
|
3772
|
+
const s = document.createElement("div");
|
|
3773
|
+
s.setAttribute("data-ry-target", "icon"), s.className = "ry-feature__icon", s.innerHTML = e, this.insertBefore(s, this.firstChild);
|
|
3774
|
+
}
|
|
3775
|
+
}
|
|
3776
|
+
class Et extends u {
|
|
3777
|
+
}
|
|
3778
|
+
customElements.define("ry-feature", Mt);
|
|
3779
|
+
customElements.define("ry-feature-grid", Et);
|
|
3780
|
+
class Ct extends u {
|
|
3781
|
+
}
|
|
3782
|
+
class St extends u {
|
|
3783
|
+
}
|
|
3784
|
+
customElements.define("ry-pricing", Ct);
|
|
3785
|
+
customElements.define("ry-pricing-card", St);
|
|
3786
|
+
class Tt extends u {
|
|
3787
|
+
#t = 0;
|
|
3788
|
+
#e = 0;
|
|
3789
|
+
#i = null;
|
|
3790
|
+
#s = 0;
|
|
3791
|
+
#r = !1;
|
|
3792
|
+
setup() {
|
|
3793
|
+
this.#a(), this.#n(), this.hasAttribute("tabindex") || this.setAttribute("tabindex", "0"), this.on(this, "keydown", this.#o);
|
|
3794
|
+
}
|
|
3795
|
+
#a() {
|
|
3796
|
+
if (this.$('[data-ry-target="viewport"]')) return;
|
|
3797
|
+
const t = [...this.children];
|
|
3798
|
+
if (this.#e = t.length, this.#e === 0) return;
|
|
3799
|
+
const e = this.hasAttribute("arrows"), s = this.hasAttribute("dots"), i = document.createElement("div");
|
|
3800
|
+
i.setAttribute("data-ry-target", "track"), i.className = "ry-carousel__track";
|
|
3801
|
+
for (const a of t) {
|
|
3802
|
+
const n = document.createElement("div");
|
|
3803
|
+
n.setAttribute("data-ry-target", "slide"), n.className = "ry-carousel__slide", n.appendChild(a), i.appendChild(n);
|
|
3804
|
+
}
|
|
3805
|
+
const r = document.createElement("div");
|
|
3806
|
+
if (r.setAttribute("data-ry-target", "viewport"), r.className = "ry-carousel__viewport", r.appendChild(i), this.innerHTML = "", this.appendChild(r), e) {
|
|
3807
|
+
const a = document.createElement("button");
|
|
3808
|
+
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());
|
|
3809
|
+
const n = document.createElement("button");
|
|
3810
|
+
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());
|
|
3811
|
+
}
|
|
3812
|
+
if (s) {
|
|
3813
|
+
const a = document.createElement("div");
|
|
3814
|
+
a.setAttribute("data-ry-target", "dots"), a.className = "ry-carousel__dots";
|
|
3815
|
+
for (let n = 0; n < this.#e; n++) {
|
|
3816
|
+
const o = document.createElement("button");
|
|
3817
|
+
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);
|
|
3818
|
+
}
|
|
3819
|
+
this.appendChild(a);
|
|
3820
|
+
}
|
|
3821
|
+
this.on(r, "pointerdown", this.#c), this.on(r, "pointermove", this.#h), this.on(r, "pointerup", this.#d), this.on(r, "pointercancel", this.#d), this.hasAttribute("pause-on-hover") && (this.on(this, "mouseenter", () => this.#p()), this.on(this, "mouseleave", () => this.#n())), this.goTo(0);
|
|
3822
|
+
}
|
|
3823
|
+
#o = (t) => {
|
|
3824
|
+
t.key === "ArrowLeft" ? (t.preventDefault(), this.prev()) : t.key === "ArrowRight" && (t.preventDefault(), this.next());
|
|
3825
|
+
};
|
|
3826
|
+
#c = (t) => {
|
|
3827
|
+
this.#s = t.clientX, this.#r = !0, t.currentTarget.setPointerCapture(t.pointerId);
|
|
3828
|
+
};
|
|
3829
|
+
#h = (t) => {
|
|
3830
|
+
this.#r && t.preventDefault();
|
|
3831
|
+
};
|
|
3832
|
+
#d = (t) => {
|
|
3833
|
+
if (!this.#r) return;
|
|
3834
|
+
this.#r = !1;
|
|
3835
|
+
const e = t.clientX - this.#s, s = 50;
|
|
3836
|
+
e > s ? this.prev() : e < -s && this.next();
|
|
3837
|
+
};
|
|
3838
|
+
#n() {
|
|
3839
|
+
if (this.#p(), !this.hasAttribute("autoplay")) return;
|
|
3840
|
+
const t = parseInt(this.getAttribute("interval") ?? "5000", 10);
|
|
3841
|
+
this.#i = setInterval(() => this.next(), t);
|
|
3842
|
+
}
|
|
3843
|
+
#p() {
|
|
3844
|
+
this.#i && (clearInterval(this.#i), this.#i = null);
|
|
3845
|
+
}
|
|
3846
|
+
goTo(t) {
|
|
3847
|
+
if (this.hasAttribute("loop"))
|
|
3848
|
+
t < 0 && (t = this.#e - 1), t >= this.#e && (t = 0);
|
|
3849
|
+
else if (t < 0 || t >= this.#e) return;
|
|
3850
|
+
this.#t = t;
|
|
3851
|
+
const s = this.$('[data-ry-target="track"]');
|
|
3852
|
+
s && (s.style.transform = `translateX(-${t * 100}%)`), this.$$('[data-ry-target="dot"]').forEach((r, a) => {
|
|
3853
|
+
a === t ? r.setAttribute("data-active", "") : r.removeAttribute("data-active");
|
|
3854
|
+
}), this.emit("change", { index: t, slide: this.#t });
|
|
3855
|
+
}
|
|
3856
|
+
next() {
|
|
3857
|
+
this.goTo(this.#t + 1);
|
|
3858
|
+
}
|
|
3859
|
+
prev() {
|
|
3860
|
+
this.goTo(this.#t - 1);
|
|
3861
|
+
}
|
|
3862
|
+
teardown() {
|
|
3863
|
+
this.#p();
|
|
3864
|
+
}
|
|
3865
|
+
}
|
|
3866
|
+
customElements.define("ry-carousel", Tt);
|
|
3347
3867
|
window.RyToast = f;
|
|
3348
3868
|
console.log("ry-ui loaded");
|
|
3349
3869
|
export {
|
|
3350
|
-
|
|
3351
|
-
|
|
3352
|
-
|
|
3353
|
-
|
|
3354
|
-
|
|
3355
|
-
|
|
3356
|
-
|
|
3870
|
+
R as RyAccordion,
|
|
3871
|
+
z as RyAlert,
|
|
3872
|
+
N as RyButton,
|
|
3873
|
+
O as RyButtonGroup,
|
|
3874
|
+
Tt as RyCarousel,
|
|
3875
|
+
et as RyCode,
|
|
3876
|
+
gt as RyColorInput,
|
|
3877
|
+
pt as RyColorPicker,
|
|
3878
|
+
G as RyDrawer,
|
|
3357
3879
|
j as RyDropdown,
|
|
3358
|
-
|
|
3359
|
-
|
|
3360
|
-
|
|
3361
|
-
|
|
3362
|
-
|
|
3363
|
-
|
|
3880
|
+
u as RyElement,
|
|
3881
|
+
st as RyExample,
|
|
3882
|
+
Mt as RyFeature,
|
|
3883
|
+
Et as RyFeatureGrid,
|
|
3884
|
+
U as RyField,
|
|
3885
|
+
mt as RyGradientPicker,
|
|
3886
|
+
xt as RyHero,
|
|
3887
|
+
it as RyIcon,
|
|
3888
|
+
lt as RyKnob,
|
|
3364
3889
|
P as RyModal,
|
|
3365
|
-
|
|
3366
|
-
|
|
3367
|
-
|
|
3368
|
-
|
|
3369
|
-
|
|
3370
|
-
|
|
3890
|
+
ct as RyNumberSelect,
|
|
3891
|
+
Ct as RyPricing,
|
|
3892
|
+
St as RyPricingCard,
|
|
3893
|
+
Q as RySelect,
|
|
3894
|
+
ht as RySlider,
|
|
3895
|
+
K as RySplit,
|
|
3896
|
+
_t as RyStat,
|
|
3897
|
+
W as RySwitch,
|
|
3898
|
+
F as RyTabs,
|
|
3899
|
+
wt as RyTag,
|
|
3900
|
+
$t as RyTagInput,
|
|
3901
|
+
q as RyThemeToggle,
|
|
3371
3902
|
f as RyToast,
|
|
3372
|
-
|
|
3373
|
-
|
|
3903
|
+
ot as RyToggleButton,
|
|
3904
|
+
X as RyTooltip,
|
|
3374
3905
|
k as RyTree,
|
|
3375
|
-
|
|
3376
|
-
|
|
3377
|
-
|
|
3906
|
+
kt as RyTreeItem,
|
|
3907
|
+
p as getIcon,
|
|
3908
|
+
Ht as getIconNames,
|
|
3378
3909
|
C as processTransforms,
|
|
3379
|
-
|
|
3380
|
-
|
|
3910
|
+
Dt as registerIcon,
|
|
3911
|
+
It as registerIcons,
|
|
3381
3912
|
M as transform
|
|
3382
3913
|
};
|
|
3383
3914
|
//# sourceMappingURL=ry-ui.js.map
|