@citrusworx/juiceui 0.4.0 → 0.6.0
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/README.md +21 -8
- package/dist/index.css +24118 -23563
- package/dist/index.d.ts +2 -0
- package/dist/index.js +264 -44
- package/dist/js/juice.d.ts +2 -0
- package/dist/js/src/modal/modal-runtime.d.ts +30 -0
- package/dist/themes/aquaflux.css +81 -0
- package/dist/themes/citrusmint.css +79 -0
- package/dist/themes/index.d.ts +1 -1
- package/dist/themes/kiwipress.css +67 -6
- package/dist/themes/tide.css +482 -0
- package/package.json +12 -3
package/dist/index.d.ts
CHANGED
|
@@ -5,4 +5,6 @@ export { createAccordion, initAccordion, startAccordionRuntime, stopAccordionRun
|
|
|
5
5
|
export type { AccordionController, AccordionOptions } from "./js/src/accordion/accordion-runtime.js";
|
|
6
6
|
export { createTabs, initTabs, startTabsRuntime, stopTabsRuntime } from "./js/src/tabs/tabs-runtime.js";
|
|
7
7
|
export type { TabsController, TabsOptions } from "./js/src/tabs/tabs-runtime.js";
|
|
8
|
+
export { createModal, initModal, startModalRuntime, stopModalRuntime } from "./js/src/modal/modal-runtime.js";
|
|
9
|
+
export type { ModalController, ModalOptions } from "./js/src/modal/modal-runtime.js";
|
|
8
10
|
export { tokens } from "./tokens/index.js";
|
package/dist/index.js
CHANGED
|
@@ -346,13 +346,13 @@ var A = {
|
|
|
346
346
|
root: typeof document < "u" ? document : {},
|
|
347
347
|
accordionSelector: "[accordion]",
|
|
348
348
|
triggerSelector: "[accordion-item]"
|
|
349
|
-
}, j = (e) => Array.from(e),
|
|
349
|
+
}, j = (e) => Array.from(e), ee = "juice-accordion-trigger", M = "juice-accordion-panel", N = (e) => e instanceof HTMLButtonElement ? !0 : e instanceof HTMLAnchorElement ? e.hasAttribute("href") : !1, te = /* @__PURE__ */ new WeakSet(), P = (e) => te.has(e) ? !1 : (te.add(e), !0), ne = (e) => e.trim().toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "") || "accordion", F = (e, t, n) => {
|
|
350
350
|
let r = String(n);
|
|
351
351
|
if (e.getAttribute("aria-expanded") !== r && e.setAttribute("aria-expanded", r), !t) return;
|
|
352
352
|
t.hidden !== !n && (t.hidden = !n);
|
|
353
353
|
let i = String(!n);
|
|
354
354
|
t.getAttribute("aria-hidden") !== i && t.setAttribute("aria-hidden", i);
|
|
355
|
-
},
|
|
355
|
+
}, I = (e, t) => t ? !t.hasAttribute("hidden") : e.getAttribute("aria-expanded") === "true", re = (e = {}) => {
|
|
356
356
|
if (typeof window > "u" || typeof document > "u") return {
|
|
357
357
|
destroy: () => {},
|
|
358
358
|
sync: () => {},
|
|
@@ -390,26 +390,26 @@ var A = {
|
|
|
390
390
|
return o()[0] ?? null;
|
|
391
391
|
}, p = (e) => {
|
|
392
392
|
let t = e.getAttribute("name");
|
|
393
|
-
return t ?
|
|
393
|
+
return t ? ne(t) : null;
|
|
394
394
|
}, m = (e, t) => {
|
|
395
395
|
let n = u(e);
|
|
396
396
|
if (!n) return;
|
|
397
397
|
let r = a(n), i = Math.max(0, r.indexOf(e)), o = p(n), s = r.length > 1 ? `-${i + 1}` : "";
|
|
398
|
-
e.id ||= o ? `${o}-trigger${s}` : l(
|
|
398
|
+
e.id ||= o ? `${o}-trigger${s}` : l(ee), N(e) || (e.setAttribute("role", "button"), e.hasAttribute("tabindex") || e.setAttribute("tabindex", "0")), t && (t.id ||= o ? `${o}-panel${s}` : l(M), e.getAttribute("aria-controls") !== t.id && e.setAttribute("aria-controls", t.id), t.getAttribute("role") !== "region" && t.setAttribute("role", "region"), t.getAttribute("aria-labelledby") !== e.id && t.setAttribute("aria-labelledby", e.id));
|
|
399
399
|
}, h = (e) => {
|
|
400
400
|
let t = f(e);
|
|
401
401
|
if (!t) return;
|
|
402
402
|
let n = d(t);
|
|
403
|
-
m(t, n),
|
|
403
|
+
m(t, n), F(t, n, !0), c = t;
|
|
404
404
|
}, g = (e) => {
|
|
405
405
|
let t = f(e);
|
|
406
406
|
if (!t) return;
|
|
407
407
|
let n = d(t);
|
|
408
|
-
m(t, n),
|
|
408
|
+
m(t, n), F(t, n, !1), t === c && (c = o().find((e) => e !== t && I(e, d(e))) ?? null);
|
|
409
409
|
}, _ = (e) => {
|
|
410
410
|
let t = f(e);
|
|
411
411
|
if (t) {
|
|
412
|
-
if (
|
|
412
|
+
if (I(t, d(t))) {
|
|
413
413
|
g(t);
|
|
414
414
|
return;
|
|
415
415
|
}
|
|
@@ -420,7 +420,7 @@ var A = {
|
|
|
420
420
|
a(e).forEach((e) => {
|
|
421
421
|
let t = d(e);
|
|
422
422
|
if (m(e, t), t) {
|
|
423
|
-
|
|
423
|
+
F(e, t, I(e, t));
|
|
424
424
|
return;
|
|
425
425
|
}
|
|
426
426
|
e.hasAttribute("aria-expanded") || e.setAttribute("aria-expanded", "false");
|
|
@@ -430,23 +430,23 @@ var A = {
|
|
|
430
430
|
let n = e.target;
|
|
431
431
|
if (!(n instanceof Element)) return;
|
|
432
432
|
let r = n.closest(t.triggerSelector);
|
|
433
|
-
!(r instanceof HTMLElement) || !u(r) ||
|
|
433
|
+
!(r instanceof HTMLElement) || !u(r) || P(e) && _(r);
|
|
434
434
|
}, b = (e) => {
|
|
435
435
|
let n = e.closest(t.triggerSelector);
|
|
436
|
-
return n instanceof HTMLElement && u(n) &&
|
|
436
|
+
return n instanceof HTMLElement && u(n) && I(n, d(n)) ? n : o().filter((e) => I(e, d(e))).find((t) => d(t)?.contains(e)) || (c && u(c) && I(c, d(c)) ? c : null);
|
|
437
437
|
}, x = (e) => {
|
|
438
438
|
if (!(e instanceof KeyboardEvent)) return;
|
|
439
439
|
let n = e.target;
|
|
440
440
|
if (!(n instanceof Element)) return;
|
|
441
441
|
if (e.key === "Escape") {
|
|
442
442
|
let t = b(n);
|
|
443
|
-
if (!t || !
|
|
443
|
+
if (!t || !P(e)) return;
|
|
444
444
|
e.preventDefault(), g(t), t.focus();
|
|
445
445
|
return;
|
|
446
446
|
}
|
|
447
447
|
if (e.key !== "Enter" && e.key !== " ") return;
|
|
448
448
|
let r = n.closest(t.triggerSelector);
|
|
449
|
-
!(r instanceof HTMLElement) || !u(r) || N(r) ||
|
|
449
|
+
!(r instanceof HTMLElement) || !u(r) || N(r) || P(e) && (e.preventDefault(), _(r));
|
|
450
450
|
}, S = !1, C = () => {
|
|
451
451
|
S || (S = !0, requestAnimationFrame(() => {
|
|
452
452
|
S = !1, v();
|
|
@@ -472,32 +472,32 @@ var A = {
|
|
|
472
472
|
collapse: g,
|
|
473
473
|
toggle: _
|
|
474
474
|
};
|
|
475
|
-
},
|
|
476
|
-
|
|
477
|
-
},
|
|
478
|
-
|
|
475
|
+
}, ie = (e = {}) => re(e), L = null, ae = !1, R = null, oe = () => {
|
|
476
|
+
R &&= (document.removeEventListener("DOMContentLoaded", R), null);
|
|
477
|
+
}, z = () => typeof window > "u" || typeof document > "u" ? null : (ae = !1, oe(), L ? (L.sync(), L) : (L = re(), L)), se = () => {
|
|
478
|
+
ae = !0, oe(), L?.destroy(), L = null;
|
|
479
479
|
};
|
|
480
|
-
typeof window < "u" && typeof document < "u" && (document.readyState === "loading" ? (
|
|
481
|
-
|
|
482
|
-
}, document.addEventListener("DOMContentLoaded",
|
|
480
|
+
typeof window < "u" && typeof document < "u" && (document.readyState === "loading" ? (R = () => {
|
|
481
|
+
R = null, ae || z();
|
|
482
|
+
}, document.addEventListener("DOMContentLoaded", R)) : z());
|
|
483
483
|
//#endregion
|
|
484
484
|
//#region src/js/src/tabs/tabs-runtime.ts
|
|
485
|
-
var
|
|
485
|
+
var ce = {
|
|
486
486
|
root: typeof document < "u" ? document : {},
|
|
487
487
|
tabsSelector: "[tabs]",
|
|
488
488
|
listSelector: "[tabs-list]",
|
|
489
489
|
triggerSelector: "[tab]",
|
|
490
490
|
panelSelector: "[tab-panel]"
|
|
491
|
-
},
|
|
491
|
+
}, B = (e) => Array.from(e), le = "juice-tabs-trigger", ue = "juice-tabs-panel", de = /* @__PURE__ */ new WeakSet(), V = (e) => de.has(e) ? !1 : (de.add(e), !0), fe = (e) => e instanceof HTMLButtonElement ? !0 : e instanceof HTMLAnchorElement ? e.hasAttribute("href") : !1, pe = (e) => e.trim().toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "") || "tabs", me = (e) => e instanceof HTMLElement ? e instanceof HTMLInputElement || e instanceof HTMLTextAreaElement || e instanceof HTMLSelectElement ? !0 : e.isContentEditable : !1, he = (e) => typeof CSS < "u" && typeof CSS.escape == "function" ? CSS.escape(e) : e, H = (e = {}) => {
|
|
492
492
|
if (typeof window > "u" || typeof document > "u") return {
|
|
493
493
|
destroy: () => {},
|
|
494
494
|
sync: () => {},
|
|
495
495
|
select: () => {}
|
|
496
496
|
};
|
|
497
497
|
let t = {
|
|
498
|
-
...
|
|
498
|
+
...ce,
|
|
499
499
|
...e
|
|
500
|
-
}, n = t.root ?? document, r = n, i = () =>
|
|
500
|
+
}, n = t.root ?? document, r = n, i = () => B(n.querySelectorAll(t.tabsSelector)), a = (e) => {
|
|
501
501
|
let n = e.querySelector(`:scope > ${t.listSelector}`);
|
|
502
502
|
return n instanceof HTMLElement ? n : null;
|
|
503
503
|
}, o = (e) => {
|
|
@@ -517,16 +517,16 @@ var ie = {
|
|
|
517
517
|
let n = a(e) ?? e, r = /* @__PURE__ */ new Set(), i = [], o = (t) => {
|
|
518
518
|
t instanceof HTMLElement && (!c(t, e) || r.has(t) || (r.add(t), i.push(t)));
|
|
519
519
|
};
|
|
520
|
-
return
|
|
520
|
+
return B(n.children).forEach(o), B(n.querySelectorAll(t.triggerSelector)).forEach(o), B(n.querySelectorAll("[role=\"tab\"]")).forEach(o), i.sort((e, t) => {
|
|
521
521
|
let n = e.compareDocumentPosition(t);
|
|
522
522
|
return n & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : n & Node.DOCUMENT_POSITION_PRECEDING ? 1 : 0;
|
|
523
523
|
});
|
|
524
|
-
}, u = (e) =>
|
|
524
|
+
}, u = (e) => B(e.querySelectorAll(t.panelSelector)).filter((t) => o(t) === e), d = () => i().flatMap((e) => l(e)), f = 0, p = (e) => (f += 1, `${e}-${f}`), m = (e) => {
|
|
525
525
|
let n = o(e);
|
|
526
526
|
if (!n) return null;
|
|
527
527
|
let r = e.getAttribute("aria-controls");
|
|
528
528
|
if (r) {
|
|
529
|
-
let e = n.querySelector(`#${
|
|
529
|
+
let e = n.querySelector(`#${he(r)}`);
|
|
530
530
|
if (e && e.matches(t.panelSelector) && o(e) === n) return e;
|
|
531
531
|
}
|
|
532
532
|
let i = l(n), a = u(n), s = i.indexOf(e);
|
|
@@ -551,7 +551,7 @@ var ie = {
|
|
|
551
551
|
return d()[0] ?? null;
|
|
552
552
|
}, g = (e) => {
|
|
553
553
|
let t = e.getAttribute("name");
|
|
554
|
-
return t ?
|
|
554
|
+
return t ? pe(t) : null;
|
|
555
555
|
}, _ = (e) => {
|
|
556
556
|
let t = a(e), n = u(e), r = t ?? (n.length === 0 ? e : null);
|
|
557
557
|
if (!r) return;
|
|
@@ -563,7 +563,7 @@ var ie = {
|
|
|
563
563
|
if (!n) return;
|
|
564
564
|
_(n);
|
|
565
565
|
let r = l(n), i = Math.max(0, r.indexOf(e)), a = g(n), s = r.length > 1 ? `-${i + 1}` : "";
|
|
566
|
-
e.id ||= a ? `${a}-tab${s}` : p(
|
|
566
|
+
e.id ||= a ? `${a}-tab${s}` : p(le), e.getAttribute("role") !== "tab" && e.setAttribute("role", "tab"), !fe(e) && !e.hasAttribute("tabindex") && e.setAttribute("tabindex", "-1"), t && (t.id ||= a ? `${a}-panel${s}` : p(ue), e.getAttribute("aria-controls") !== t.id && e.setAttribute("aria-controls", t.id), t.getAttribute("role") !== "tabpanel" && t.setAttribute("role", "tabpanel"), t.getAttribute("aria-labelledby") !== e.id && t.setAttribute("aria-labelledby", e.id));
|
|
567
567
|
}, y = (e) => e.hasAttribute("active") || e.getAttribute("aria-selected") === "true", b = (e, t, n) => {
|
|
568
568
|
n ? e.hasAttribute("active") || e.setAttribute("active", "") : e.hasAttribute("active") && e.removeAttribute("active");
|
|
569
569
|
let r = String(n);
|
|
@@ -609,7 +609,7 @@ var ie = {
|
|
|
609
609
|
let t = e.target;
|
|
610
610
|
if (!(t instanceof Element)) return;
|
|
611
611
|
let n = T(t);
|
|
612
|
-
n &&
|
|
612
|
+
n && V(e) && S(n);
|
|
613
613
|
}, D = (e, t) => {
|
|
614
614
|
let n = o(e);
|
|
615
615
|
if (!n) return;
|
|
@@ -620,30 +620,30 @@ var ie = {
|
|
|
620
620
|
}, O = (e) => {
|
|
621
621
|
if (!(e instanceof KeyboardEvent)) return;
|
|
622
622
|
let t = e.target;
|
|
623
|
-
if (!(t instanceof Element) ||
|
|
623
|
+
if (!(t instanceof Element) || me(t)) return;
|
|
624
624
|
let n = T(t);
|
|
625
625
|
if (n && !(e.key === "Escape" || e.key === "ArrowUp" || e.key === "ArrowDown")) {
|
|
626
626
|
if (e.key === "ArrowRight") {
|
|
627
|
-
if (!
|
|
627
|
+
if (!V(e)) return;
|
|
628
628
|
e.preventDefault(), D(n, (e, t) => (e + 1) % t);
|
|
629
629
|
return;
|
|
630
630
|
}
|
|
631
631
|
if (e.key === "ArrowLeft") {
|
|
632
|
-
if (!
|
|
632
|
+
if (!V(e)) return;
|
|
633
633
|
e.preventDefault(), D(n, (e, t) => (e - 1 + t) % t);
|
|
634
634
|
return;
|
|
635
635
|
}
|
|
636
636
|
if (e.key === "Home") {
|
|
637
|
-
if (!
|
|
637
|
+
if (!V(e)) return;
|
|
638
638
|
e.preventDefault(), D(n, () => 0);
|
|
639
639
|
return;
|
|
640
640
|
}
|
|
641
641
|
if (e.key === "End") {
|
|
642
|
-
if (!
|
|
642
|
+
if (!V(e)) return;
|
|
643
643
|
e.preventDefault(), D(n, (e, t) => t - 1);
|
|
644
644
|
return;
|
|
645
645
|
}
|
|
646
|
-
e.key !== "Enter" && e.key !== " " ||
|
|
646
|
+
e.key !== "Enter" && e.key !== " " || fe(n) || V(e) && (e.preventDefault(), S(n));
|
|
647
647
|
}
|
|
648
648
|
}, k = !1, A = () => {
|
|
649
649
|
k || (k = !0, requestAnimationFrame(() => {
|
|
@@ -671,17 +671,237 @@ var ie = {
|
|
|
671
671
|
sync: w,
|
|
672
672
|
select: S
|
|
673
673
|
};
|
|
674
|
-
},
|
|
675
|
-
|
|
676
|
-
},
|
|
677
|
-
|
|
674
|
+
}, ge = (e = {}) => H(e), U = null, W = !1, G = null, _e = () => {
|
|
675
|
+
G &&= (document.removeEventListener("DOMContentLoaded", G), null);
|
|
676
|
+
}, ve = () => typeof window > "u" || typeof document > "u" ? null : (W = !1, _e(), U ? (U.sync(), U) : (U = H(), U)), ye = () => {
|
|
677
|
+
W = !0, _e(), U?.destroy(), U = null;
|
|
678
678
|
};
|
|
679
|
-
typeof window < "u" && typeof document < "u" && (document.readyState === "loading" ? (
|
|
680
|
-
|
|
681
|
-
}, document.addEventListener("DOMContentLoaded",
|
|
679
|
+
typeof window < "u" && typeof document < "u" && (document.readyState === "loading" ? (G = () => {
|
|
680
|
+
G = null, W || ve();
|
|
681
|
+
}, document.addEventListener("DOMContentLoaded", G)) : ve());
|
|
682
|
+
//#endregion
|
|
683
|
+
//#region src/js/src/modal/modal-runtime.ts
|
|
684
|
+
var be = {
|
|
685
|
+
root: typeof document < "u" ? document : {},
|
|
686
|
+
overlaySelector: "[modal-overlay]",
|
|
687
|
+
dialogSelector: "[modal]",
|
|
688
|
+
closeSelector: "[modal-close]",
|
|
689
|
+
closeOnBackdrop: !0
|
|
690
|
+
}, K = (e) => Array.from(e), xe = "juice-modal-overlay", Se = "juice-modal-dialog", Ce = "juice-modal-title", we = [
|
|
691
|
+
"a[href]",
|
|
692
|
+
"button:not([disabled])",
|
|
693
|
+
"textarea:not([disabled])",
|
|
694
|
+
"input:not([disabled]):not([type=\"hidden\"])",
|
|
695
|
+
"select:not([disabled])",
|
|
696
|
+
"[tabindex]:not([tabindex=\"-1\"])"
|
|
697
|
+
].join(","), Te = /* @__PURE__ */ new WeakSet(), q = /* @__PURE__ */ new WeakMap(), J = (e) => Te.has(e) ? !1 : (Te.add(e), !0), Ee = (e) => typeof CSS < "u" && typeof CSS.escape == "function" ? CSS.escape(e) : e, De = (e) => e.trim().toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "") || "modal", Y = (e) => e instanceof HTMLButtonElement ? !0 : e instanceof HTMLAnchorElement ? e.hasAttribute("href") : !1, Oe = (e) => (e.getAttribute("aria-controls") ?? "").trim().split(/\s+/).filter(Boolean), X = (e) => !e.hasAttribute("hidden"), ke = (e) => !(e.closest("[hidden]") || e.getAttribute("aria-hidden") === "true" || e instanceof HTMLButtonElement && e.disabled || e instanceof HTMLInputElement && e.disabled), Ae = (e) => K(e.querySelectorAll(we)).filter(ke), je = (e = {}) => {
|
|
698
|
+
if (typeof window > "u" || typeof document > "u") return {
|
|
699
|
+
destroy: () => {},
|
|
700
|
+
sync: () => {},
|
|
701
|
+
open: () => {},
|
|
702
|
+
close: () => {},
|
|
703
|
+
toggle: () => {}
|
|
704
|
+
};
|
|
705
|
+
let t = {
|
|
706
|
+
...be,
|
|
707
|
+
...e
|
|
708
|
+
}, n = t.root ?? document, r = n, i = 0, a = (e) => (i += 1, `${e}-${i}`), o = () => K(n.querySelectorAll(t.overlaySelector)), s = (e) => {
|
|
709
|
+
if (!e) return null;
|
|
710
|
+
let n = e.closest(t.overlaySelector);
|
|
711
|
+
return n instanceof HTMLElement ? n : null;
|
|
712
|
+
}, c = (e) => {
|
|
713
|
+
let t = Ee(e);
|
|
714
|
+
if (n instanceof Document || n instanceof Element) {
|
|
715
|
+
let e = n.querySelector(`#${t}`);
|
|
716
|
+
if (e) return e;
|
|
717
|
+
}
|
|
718
|
+
let r = document.getElementById(e);
|
|
719
|
+
return r instanceof HTMLElement ? r : null;
|
|
720
|
+
}, l = (e) => e?.matches(t.overlaySelector) ? n instanceof Document ? !0 : n instanceof Node ? n.contains(e) : o().includes(e) : !1, u = (e) => K(e.querySelectorAll(t.dialogSelector)).find((t) => s(t) === e) || K(e.querySelectorAll("[role=\"dialog\"]")).find((t) => s(t) === e) || (K(e.children).find((e) => e instanceof HTMLElement) ?? e), d = (e) => {
|
|
721
|
+
if (s(e)) return null;
|
|
722
|
+
for (let t of Oe(e)) {
|
|
723
|
+
let e = c(t);
|
|
724
|
+
if (e && l(e)) return e;
|
|
725
|
+
}
|
|
726
|
+
return null;
|
|
727
|
+
}, f = (e) => {
|
|
728
|
+
if (e) {
|
|
729
|
+
if (l(e)) return e;
|
|
730
|
+
let n = s(e);
|
|
731
|
+
if (n && l(n)) return n;
|
|
732
|
+
if (e.matches(t.closeSelector)) {
|
|
733
|
+
let t = s(e);
|
|
734
|
+
if (t && l(t)) return t;
|
|
735
|
+
}
|
|
736
|
+
let r = d(e);
|
|
737
|
+
if (r) return r;
|
|
738
|
+
let i = e.closest("[aria-controls]");
|
|
739
|
+
if (i instanceof HTMLElement) {
|
|
740
|
+
let e = d(i);
|
|
741
|
+
if (e) return e;
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
return o().find(X) ?? o()[0] ?? null;
|
|
745
|
+
}, p = (e) => {
|
|
746
|
+
let t = e.getAttribute("name");
|
|
747
|
+
return t ? De(t) : e.id ? De(e.id) : null;
|
|
748
|
+
}, m = (e) => e.id ? K(document.querySelectorAll("[aria-controls]")).filter((t) => s(t) ? !1 : Oe(t).includes(e.id)) : [], h = (e, t) => {
|
|
749
|
+
let n = String(t);
|
|
750
|
+
m(e).forEach((e) => {
|
|
751
|
+
e.getAttribute("aria-expanded") !== n && e.setAttribute("aria-expanded", n), e.hasAttribute("aria-haspopup") || e.setAttribute("aria-haspopup", "dialog");
|
|
752
|
+
});
|
|
753
|
+
}, g = (e) => {
|
|
754
|
+
let n = u(e), r = p(e);
|
|
755
|
+
if (e.id ||= r ? `${r}-overlay` : a(xe), n.id ||= r ? `${r}-dialog` : a(Se), n.getAttribute("role") !== "dialog" && n.setAttribute("role", "dialog"), n.getAttribute("aria-modal") !== "true" && n.setAttribute("aria-modal", "true"), !n.hasAttribute("aria-labelledby") && !n.hasAttribute("aria-label")) {
|
|
756
|
+
let e = n.querySelector("[modal-header] :is(h1,h2,h3,h4,h5,h6), :is(h1,h2,h3,h4,h5,h6)");
|
|
757
|
+
e && (e.id ||= r ? `${r}-title` : a(Ce), n.setAttribute("aria-labelledby", e.id));
|
|
758
|
+
}
|
|
759
|
+
K(e.querySelectorAll(t.closeSelector)).filter((t) => s(t) === e).forEach((e) => {
|
|
760
|
+
Y(e) || (e.setAttribute("role", "button"), e.hasAttribute("tabindex") || e.setAttribute("tabindex", "0")), !e.hasAttribute("aria-label") && !e.hasAttribute("aria-labelledby") && !e.textContent?.trim() && e.setAttribute("aria-label", "Close");
|
|
761
|
+
}), m(e).forEach((t) => {
|
|
762
|
+
Y(t) || (t.setAttribute("role", "button"), t.hasAttribute("tabindex") || t.setAttribute("tabindex", "0")), t.hasAttribute("aria-haspopup") || t.setAttribute("aria-haspopup", "dialog"), t.hasAttribute("aria-expanded") || t.setAttribute("aria-expanded", String(X(e)));
|
|
763
|
+
});
|
|
764
|
+
}, _ = (e, t) => {
|
|
765
|
+
let n = document.activeElement instanceof HTMLElement ? document.activeElement : null, r = t && !e.contains(t) ? t : n && !e.contains(n) ? n : null;
|
|
766
|
+
r && q.set(e, r);
|
|
767
|
+
}, v = (e) => {
|
|
768
|
+
let t = q.get(e);
|
|
769
|
+
q.delete(e), t?.isConnected && t.focus();
|
|
770
|
+
}, y = (e) => {
|
|
771
|
+
let t = u(e), n = t.querySelector("[autofocus]"), r = Ae(t), i = (n && ke(n) ? n : null) ?? r[0] ?? t;
|
|
772
|
+
i === t && !t.hasAttribute("tabindex") && t.setAttribute("tabindex", "-1"), i.focus();
|
|
773
|
+
}, b = (e, t) => {
|
|
774
|
+
e.hidden !== !t && (e.hidden = !t);
|
|
775
|
+
}, x = (e, t) => {
|
|
776
|
+
g(e), b(e, !1), h(e, !1), t ? v(e) : q.delete(e);
|
|
777
|
+
}, S = (e, n) => {
|
|
778
|
+
o().concat(K(document.querySelectorAll(t.overlaySelector))).forEach((t) => {
|
|
779
|
+
t === e || !X(t) || x(t, !1);
|
|
780
|
+
}), _(e, n), g(e), b(e, !0), h(e, !0), y(e);
|
|
781
|
+
}, C = (e) => {
|
|
782
|
+
let t = f(e);
|
|
783
|
+
if (t) {
|
|
784
|
+
if (X(t)) {
|
|
785
|
+
g(t), h(t, !0);
|
|
786
|
+
return;
|
|
787
|
+
}
|
|
788
|
+
S(t, e && d(e) === t ? e : e?.closest("[aria-controls]") instanceof HTMLElement && d(e.closest("[aria-controls]")) === t ? e.closest("[aria-controls]") : null);
|
|
789
|
+
}
|
|
790
|
+
}, w = (e) => {
|
|
791
|
+
let t = f(e);
|
|
792
|
+
!t || !X(t) || x(t, !0);
|
|
793
|
+
}, T = (e) => {
|
|
794
|
+
let t = f(e);
|
|
795
|
+
if (t) {
|
|
796
|
+
if (X(t)) {
|
|
797
|
+
w(t);
|
|
798
|
+
return;
|
|
799
|
+
}
|
|
800
|
+
C(e ?? t);
|
|
801
|
+
}
|
|
802
|
+
}, E = () => {
|
|
803
|
+
o().forEach((e) => {
|
|
804
|
+
g(e), h(e, X(e));
|
|
805
|
+
});
|
|
806
|
+
}, D = (e) => t.closeOnBackdrop ? e.getAttribute("modal-overlay") !== "static" : !1, O = (e) => {
|
|
807
|
+
if (!(e instanceof HTMLElement) || s(e)) return null;
|
|
808
|
+
if (d(e)) return e;
|
|
809
|
+
let t = e.closest("[aria-controls]");
|
|
810
|
+
return t instanceof HTMLElement && d(t) ? t : null;
|
|
811
|
+
}, k = (e) => {
|
|
812
|
+
let n = e.target;
|
|
813
|
+
if (!(n instanceof Element)) return;
|
|
814
|
+
let r = s(n instanceof HTMLElement ? n : n.parentElement);
|
|
815
|
+
if (r && l(r)) {
|
|
816
|
+
let i = n.closest(t.closeSelector) instanceof HTMLElement ? n.closest(t.closeSelector) : null;
|
|
817
|
+
if (i && s(i) === r) {
|
|
818
|
+
if (!J(e)) return;
|
|
819
|
+
w(r);
|
|
820
|
+
return;
|
|
821
|
+
}
|
|
822
|
+
if (n === r && D(r)) {
|
|
823
|
+
if (!J(e)) return;
|
|
824
|
+
w(r);
|
|
825
|
+
}
|
|
826
|
+
return;
|
|
827
|
+
}
|
|
828
|
+
let i = O(n);
|
|
829
|
+
i && J(e) && T(i);
|
|
830
|
+
}, A = () => o().find(X) ?? null, j = (e, t) => {
|
|
831
|
+
if (e.key !== "Tab") return !1;
|
|
832
|
+
let n = u(t), r = Ae(n), i = document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
|
833
|
+
if (r.length === 0) return e.preventDefault(), n.hasAttribute("tabindex") || n.setAttribute("tabindex", "-1"), n.focus(), !0;
|
|
834
|
+
let a = r[0], o = r[r.length - 1];
|
|
835
|
+
return e.shiftKey ? !i || i === a || !n.contains(i) ? (e.preventDefault(), o.focus(), !0) : !0 : !i || i === o || !n.contains(i) ? (e.preventDefault(), a.focus(), !0) : !0;
|
|
836
|
+
}, ee = (e) => {
|
|
837
|
+
if (!(e instanceof KeyboardEvent)) return;
|
|
838
|
+
let n = e.target;
|
|
839
|
+
if (!(n instanceof Element)) return;
|
|
840
|
+
let r = A();
|
|
841
|
+
if (r && e.key === "Escape") {
|
|
842
|
+
if (!J(e)) return;
|
|
843
|
+
e.preventDefault(), e.stopPropagation(), w(r);
|
|
844
|
+
return;
|
|
845
|
+
}
|
|
846
|
+
if (r && e.key === "Tab") {
|
|
847
|
+
if (!J(e)) return;
|
|
848
|
+
j(e, r);
|
|
849
|
+
return;
|
|
850
|
+
}
|
|
851
|
+
if (e.key !== "Enter" && e.key !== " ") return;
|
|
852
|
+
let i = n.closest(t.closeSelector);
|
|
853
|
+
if (i instanceof HTMLElement && s(i) && !Y(i)) {
|
|
854
|
+
if (!J(e)) return;
|
|
855
|
+
e.preventDefault(), w(i);
|
|
856
|
+
return;
|
|
857
|
+
}
|
|
858
|
+
let a = O(n);
|
|
859
|
+
!a || Y(a) || J(e) && (e.preventDefault(), T(a));
|
|
860
|
+
}, M = (e) => {
|
|
861
|
+
let t = A();
|
|
862
|
+
if (!t) return;
|
|
863
|
+
let n = e.target;
|
|
864
|
+
if (!(n instanceof Node) || t.contains(n) || !J(e)) return;
|
|
865
|
+
let r = u(t);
|
|
866
|
+
(Ae(r)[0] ?? r).focus();
|
|
867
|
+
}, N = !1, te = () => {
|
|
868
|
+
N || (N = !0, requestAnimationFrame(() => {
|
|
869
|
+
N = !1, E();
|
|
870
|
+
}));
|
|
871
|
+
}, P = typeof MutationObserver < "u" ? new MutationObserver(() => te()) : null;
|
|
872
|
+
return r.addEventListener("click", k), r.addEventListener("keydown", ee, !0), r.addEventListener("focusin", M, !0), P && n instanceof Node && P.observe(n, {
|
|
873
|
+
childList: !0,
|
|
874
|
+
subtree: !0,
|
|
875
|
+
attributes: !0,
|
|
876
|
+
attributeFilter: [
|
|
877
|
+
"hidden",
|
|
878
|
+
"aria-controls",
|
|
879
|
+
"aria-labelledby",
|
|
880
|
+
"aria-modal",
|
|
881
|
+
"modal-overlay",
|
|
882
|
+
"modal",
|
|
883
|
+
"modal-close"
|
|
884
|
+
]
|
|
885
|
+
}), E(), {
|
|
886
|
+
destroy: () => {
|
|
887
|
+
r.removeEventListener("click", k), r.removeEventListener("keydown", ee, !0), r.removeEventListener("focusin", M, !0), P?.disconnect();
|
|
888
|
+
},
|
|
889
|
+
sync: E,
|
|
890
|
+
open: C,
|
|
891
|
+
close: w,
|
|
892
|
+
toggle: T
|
|
893
|
+
};
|
|
894
|
+
}, Me = (e = {}) => je(e), Z = null, Ne = !1, Q = null, Pe = () => {
|
|
895
|
+
Q &&= (document.removeEventListener("DOMContentLoaded", Q), null);
|
|
896
|
+
}, $ = () => typeof window > "u" || typeof document > "u" ? null : (Ne = !1, Pe(), Z ? (Z.sync(), Z) : (Z = je(), Z)), Fe = () => {
|
|
897
|
+
Ne = !0, Pe(), Z?.destroy(), Z = null;
|
|
898
|
+
};
|
|
899
|
+
typeof window < "u" && typeof document < "u" && (document.readyState === "loading" ? (Q = () => {
|
|
900
|
+
Q = null, Ne || $();
|
|
901
|
+
}, document.addEventListener("DOMContentLoaded", Q)) : $());
|
|
682
902
|
//#endregion
|
|
683
903
|
//#region src/tokens/index.ts
|
|
684
|
-
var
|
|
904
|
+
var Ie = {
|
|
685
905
|
colors: {
|
|
686
906
|
families: [
|
|
687
907
|
"black",
|
|
@@ -849,4 +1069,4 @@ var fe = {
|
|
|
849
1069
|
themes: {}
|
|
850
1070
|
};
|
|
851
1071
|
//#endregion
|
|
852
|
-
export { v as Accordion,
|
|
1072
|
+
export { v as Accordion, re as createAccordion, je as createModal, T as createNavigation, H as createTabs, ie as initAccordion, Me as initModal, E as initNavigation, ge as initTabs, z as startAccordionRuntime, $ as startModalRuntime, O as startNavigationRuntime, ve as startTabsRuntime, se as stopAccordionRuntime, Fe as stopModalRuntime, k as stopNavigationRuntime, ye as stopTabsRuntime, Ie as tokens };
|
package/dist/js/juice.d.ts
CHANGED
|
@@ -4,3 +4,5 @@ export { createAccordion, initAccordion, startAccordionRuntime, stopAccordionRun
|
|
|
4
4
|
export type { AccordionController, AccordionOptions } from "./src/accordion/accordion-runtime.js";
|
|
5
5
|
export { createTabs, initTabs, startTabsRuntime, stopTabsRuntime } from "./src/tabs/tabs-runtime.js";
|
|
6
6
|
export type { TabsController, TabsOptions } from "./src/tabs/tabs-runtime.js";
|
|
7
|
+
export { createModal, initModal, startModalRuntime, stopModalRuntime } from "./src/modal/modal-runtime.js";
|
|
8
|
+
export type { ModalController, ModalOptions } from "./src/modal/modal-runtime.js";
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DOM-first dialog runtime for Juice modal chrome.
|
|
3
|
+
*
|
|
4
|
+
* Markup contract:
|
|
5
|
+
* [modal-overlay][hidden] > [modal role="dialog"] + [modal-close]
|
|
6
|
+
* Closed vs open is the native `hidden` attribute on the overlay.
|
|
7
|
+
*
|
|
8
|
+
* Openers: any element whose `aria-controls` token list includes a
|
|
9
|
+
* `[modal-overlay]` id. `[modal-close]` closes the containing overlay.
|
|
10
|
+
* Backdrop click closes unless `modal-overlay="static"` or
|
|
11
|
+
* `closeOnBackdrop` is false.
|
|
12
|
+
*/
|
|
13
|
+
export type ModalOptions = {
|
|
14
|
+
root?: ParentNode;
|
|
15
|
+
overlaySelector?: string;
|
|
16
|
+
dialogSelector?: string;
|
|
17
|
+
closeSelector?: string;
|
|
18
|
+
closeOnBackdrop?: boolean;
|
|
19
|
+
};
|
|
20
|
+
export type ModalController = {
|
|
21
|
+
destroy: () => void;
|
|
22
|
+
sync: () => void;
|
|
23
|
+
open: (target?: HTMLElement | null) => void;
|
|
24
|
+
close: (target?: HTMLElement | null) => void;
|
|
25
|
+
toggle: (target?: HTMLElement | null) => void;
|
|
26
|
+
};
|
|
27
|
+
export declare const createModal: (options?: ModalOptions) => ModalController;
|
|
28
|
+
export declare const initModal: (options?: ModalOptions) => ModalController;
|
|
29
|
+
export declare const startModalRuntime: () => ModalController | null;
|
|
30
|
+
export declare const stopModalRuntime: () => void;
|
package/dist/themes/aquaflux.css
CHANGED
|
@@ -94,6 +94,52 @@
|
|
|
94
94
|
--juice-tabs-indicator: var(--aqua-tabs-indicator);
|
|
95
95
|
--juice-tabs-list-rule: var(--aqua-tabs-list-rule);
|
|
96
96
|
--juice-tabs-focus-ring: var(--aqua-tabs-focus-ring);
|
|
97
|
+
/* Surface tone roles — frosted / elevated / recessed from existing tokens. */
|
|
98
|
+
--juice-surface-soft-bg: var(--aqua-surface);
|
|
99
|
+
--juice-surface-soft-border: var(--aqua-border);
|
|
100
|
+
--juice-surface-soft-shadow: 0 18px 40px -28px var(--aqua-shadow);
|
|
101
|
+
--juice-surface-soft-blur: 14px;
|
|
102
|
+
--juice-surface-strong-bg: var(--aqua-surface-strong);
|
|
103
|
+
--juice-surface-strong-border: var(--aqua-border-strong);
|
|
104
|
+
--juice-surface-strong-shadow: 0 24px 56px -24px var(--aqua-shadow);
|
|
105
|
+
--juice-surface-strong-blur: 0px;
|
|
106
|
+
--juice-surface-muted-bg: var(--aqua-surface-muted);
|
|
107
|
+
--juice-surface-muted-border: var(--aqua-border);
|
|
108
|
+
--juice-surface-muted-shadow: none;
|
|
109
|
+
--juice-surface-muted-blur: 0px;
|
|
110
|
+
/* Border strength — existing --aqua-border tokens; 1px hairline vs 2px rule. */
|
|
111
|
+
--juice-border-strength-soft-width: 1px;
|
|
112
|
+
--juice-border-strength-soft-color: var(--aqua-border);
|
|
113
|
+
--juice-border-strength-bold-width: 2px;
|
|
114
|
+
--juice-border-strength-bold-color: var(--aqua-border-strong);
|
|
115
|
+
/* Shadow tone — existing blue / purple identity; no new hue family. */
|
|
116
|
+
--juice-shadow-tone-cool-color: var(--aqua-shadow);
|
|
117
|
+
--juice-shadow-tone-cool-shadow: 0 18px 40px -28px var(--aqua-shadow);
|
|
118
|
+
--juice-shadow-tone-warm-color: color-mix(in srgb, var(--aqua-accent-strong) 16%, transparent);
|
|
119
|
+
--juice-shadow-tone-warm-shadow: 0 18px 40px -28px color-mix(in srgb, var(--aqua-accent-strong) 16%, transparent);
|
|
120
|
+
/* Overlay — frost veil / page-tint wash; existing tokens only. */
|
|
121
|
+
--juice-overlay-frost-wash: color-mix(in srgb, var(--aqua-page) 42%, transparent);
|
|
122
|
+
--juice-overlay-frost-layer: linear-gradient(var(--juice-overlay-frost-wash), var(--juice-overlay-frost-wash));
|
|
123
|
+
--juice-overlay-tint-wash: color-mix(in srgb, var(--aqua-page-tint) 38%, transparent);
|
|
124
|
+
--juice-overlay-tint-layer: linear-gradient(var(--juice-overlay-tint-wash), var(--juice-overlay-tint-wash));
|
|
125
|
+
/* Modal chrome — dimming scrim + elevated panel. Close is a surface
|
|
126
|
+
control, not the CTA gradient. Distinct from overlay="frost|tint". */
|
|
127
|
+
--aqua-modal-overlay: color-mix(in srgb, var(--aqua-page-deep) 62%, transparent);
|
|
128
|
+
--aqua-modal-panel: var(--aqua-surface-strong);
|
|
129
|
+
--aqua-modal-panel-border: var(--aqua-border);
|
|
130
|
+
--aqua-modal-panel-shadow: 0 24px 56px -24px var(--aqua-shadow);
|
|
131
|
+
--aqua-modal-close: var(--aqua-surface-strong);
|
|
132
|
+
--aqua-modal-close-color: var(--aqua-heading);
|
|
133
|
+
--aqua-modal-close-hover: var(--aqua-surface-muted);
|
|
134
|
+
--aqua-modal-focus-ring: var(--aqua-accent);
|
|
135
|
+
--juice-modal-overlay: var(--aqua-modal-overlay);
|
|
136
|
+
--juice-modal-panel: var(--aqua-modal-panel);
|
|
137
|
+
--juice-modal-panel-border: var(--aqua-modal-panel-border);
|
|
138
|
+
--juice-modal-panel-shadow: var(--aqua-modal-panel-shadow);
|
|
139
|
+
--juice-modal-close: var(--aqua-modal-close);
|
|
140
|
+
--juice-modal-close-color: var(--aqua-modal-close-color);
|
|
141
|
+
--juice-modal-close-hover: var(--aqua-modal-close-hover);
|
|
142
|
+
--juice-modal-focus-ring: var(--aqua-modal-focus-ring);
|
|
97
143
|
background-color: var(--aqua-page);
|
|
98
144
|
background-image: var(--aqua-page-background);
|
|
99
145
|
color: var(--aqua-text);
|
|
@@ -464,4 +510,39 @@
|
|
|
464
510
|
|
|
465
511
|
[theme=aquaflux] [tab-panel] {
|
|
466
512
|
color: var(--aqua-text);
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
/* Modal chrome. Generic Aquaflux buttons use the CTA gradient;
|
|
516
|
+
[modal-close] stays a surface control. Runtime is slice B. */
|
|
517
|
+
[theme=aquaflux] [modal-overlay] {
|
|
518
|
+
background-color: var(--juice-modal-overlay);
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
[theme=aquaflux] [modal]:not([surfaceTone]) {
|
|
522
|
+
background-color: var(--juice-modal-panel);
|
|
523
|
+
border: 1px solid var(--juice-modal-panel-border);
|
|
524
|
+
box-shadow: var(--juice-modal-panel-shadow);
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
[theme=aquaflux] button[modal-close],
|
|
528
|
+
[theme=aquaflux] [modal-close] {
|
|
529
|
+
background-image: none;
|
|
530
|
+
background-color: var(--juice-modal-close);
|
|
531
|
+
color: var(--juice-modal-close-color);
|
|
532
|
+
box-shadow: none;
|
|
533
|
+
transform: none;
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
[theme=aquaflux] button[modal-close]:hover,
|
|
537
|
+
[theme=aquaflux] [modal-close]:hover {
|
|
538
|
+
background-image: none;
|
|
539
|
+
background-color: var(--juice-modal-close-hover);
|
|
540
|
+
color: var(--juice-modal-close-color);
|
|
541
|
+
transform: none;
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
[theme=aquaflux] button[modal-close]:focus-visible,
|
|
545
|
+
[theme=aquaflux] [modal-close]:focus-visible {
|
|
546
|
+
outline: 2px solid var(--juice-modal-focus-ring);
|
|
547
|
+
outline-offset: 2px;
|
|
467
548
|
}
|