@editora/ui-core 0.1.12 → 0.1.14
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 +95 -5
- package/dist/alert-dialog.cjs.js +18 -18
- package/dist/alert-dialog.esm.js +130 -117
- package/dist/app-header.cjs.js +22 -2
- package/dist/app-header.esm.js +22 -2
- package/dist/badge.cjs.js +5 -5
- package/dist/badge.esm.js +9 -8
- package/dist/color-picker.cjs.js +4 -4
- package/dist/color-picker.esm.js +40 -31
- package/dist/combobox.cjs.js +21 -21
- package/dist/combobox.esm.js +79 -40
- package/dist/command-palette.cjs.js +1 -1
- package/dist/command-palette.esm.js +2 -2
- package/dist/components/date-time-utils.d.ts +2 -1
- package/dist/components/date-time-utils.d.ts.map +1 -1
- package/dist/components/ui-alert-dialog.d.ts +2 -0
- package/dist/components/ui-alert-dialog.d.ts.map +1 -1
- package/dist/components/ui-app-header.d.ts.map +1 -1
- package/dist/components/ui-badge.d.ts.map +1 -1
- package/dist/components/ui-color-picker.d.ts.map +1 -1
- package/dist/components/ui-combobox.d.ts +4 -1
- package/dist/components/ui-combobox.d.ts.map +1 -1
- package/dist/components/ui-context-menu.d.ts +6 -0
- package/dist/components/ui-context-menu.d.ts.map +1 -1
- package/dist/components/ui-date-picker.d.ts +3 -0
- package/dist/components/ui-date-picker.d.ts.map +1 -1
- package/dist/components/ui-date-range-picker.d.ts +3 -0
- package/dist/components/ui-date-range-picker.d.ts.map +1 -1
- package/dist/components/ui-date-range-time-picker.d.ts +3 -0
- package/dist/components/ui-date-range-time-picker.d.ts.map +1 -1
- package/dist/components/ui-date-time-picker.d.ts +3 -0
- package/dist/components/ui-date-time-picker.d.ts.map +1 -1
- package/dist/components/ui-dialog.d.ts +3 -0
- package/dist/components/ui-dialog.d.ts.map +1 -1
- package/dist/components/ui-drawer.d.ts +14 -0
- package/dist/components/ui-drawer.d.ts.map +1 -1
- package/dist/components/ui-floating-toolbar.d.ts +3 -0
- package/dist/components/ui-floating-toolbar.d.ts.map +1 -1
- package/dist/components/ui-gantt.d.ts +30 -1
- package/dist/components/ui-gantt.d.ts.map +1 -1
- package/dist/components/ui-hover-card.d.ts +3 -0
- package/dist/components/ui-hover-card.d.ts.map +1 -1
- package/dist/components/ui-menu.d.ts +1 -0
- package/dist/components/ui-menu.d.ts.map +1 -1
- package/dist/components/ui-menubar.d.ts +1 -0
- package/dist/components/ui-menubar.d.ts.map +1 -1
- package/dist/components/ui-positioner.d.ts.map +1 -1
- package/dist/components/ui-quick-actions.d.ts.map +1 -1
- package/dist/components/ui-radio.d.ts +47 -0
- package/dist/components/ui-radio.d.ts.map +1 -0
- package/dist/components/ui-select.d.ts +8 -0
- package/dist/components/ui-select.d.ts.map +1 -1
- package/dist/components/ui-selection-popup.d.ts.map +1 -1
- package/dist/components/ui-stepper.d.ts.map +1 -1
- package/dist/components/ui-time-picker.d.ts +3 -0
- package/dist/components/ui-time-picker.d.ts.map +1 -1
- package/dist/context-menu.cjs.js +12 -12
- package/dist/context-menu.esm.js +160 -133
- package/dist/date-field.cjs.js +1 -1
- package/dist/date-field.esm.js +3 -2
- package/dist/date-picker.cjs.js +13 -13
- package/dist/date-picker.esm.js +101 -67
- package/dist/date-range-picker.cjs.js +14 -14
- package/dist/date-range-picker.esm.js +99 -65
- package/dist/date-range-time-picker.cjs.js +13 -13
- package/dist/date-range-time-picker.esm.js +77 -45
- package/dist/date-time-picker.cjs.js +13 -13
- package/dist/date-time-picker.esm.js +133 -101
- package/dist/date-time-utils-66480de4.js +1 -0
- package/dist/date-time-utils-a2c7af25.mjs +307 -0
- package/dist/dialog.cjs.js +29 -20
- package/dist/dialog.esm.js +90 -70
- package/dist/drawer.cjs.js +16 -16
- package/dist/drawer.esm.js +216 -98
- package/dist/floating-toolbar.cjs.js +6 -16
- package/dist/floating-toolbar.esm.js +57 -40
- package/dist/gantt.cjs.js +656 -74
- package/dist/gantt.esm.js +1050 -100
- package/dist/hover-card.cjs.js +4 -4
- package/dist/hover-card.esm.js +62 -39
- package/dist/index.cjs.js +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +300 -286
- package/dist/menu.cjs.js +2 -2
- package/dist/menu.esm.js +118 -110
- package/dist/menubar.cjs.js +5 -5
- package/dist/menubar.esm.js +83 -78
- package/dist/{overlayManager-ece06517.js → overlayManager-0eda4e08.js} +1 -1
- package/dist/{overlayManager-86454af7.mjs → overlayManager-5bbd4dc3.mjs} +1 -1
- package/dist/popover.cjs.js +1 -1
- package/dist/popover.esm.js +2 -2
- package/dist/portal-c69756c0.js +1 -0
- package/dist/portal-fe73e5cc.mjs +123 -0
- package/dist/portal.d.ts +29 -3
- package/dist/portal.d.ts.map +1 -1
- package/dist/positioner-33529bb8.js +1 -0
- package/dist/positioner-e9770c66.mjs +582 -0
- package/dist/positioner.cjs.js +2 -2
- package/dist/positioner.esm.js +36 -26
- package/dist/primitives/positioner.d.ts +199 -1
- package/dist/primitives/positioner.d.ts.map +1 -1
- package/dist/quick-actions.cjs.js +10 -4
- package/dist/quick-actions.esm.js +27 -21
- package/dist/radio.cjs.js +259 -0
- package/dist/radio.esm.js +455 -0
- package/dist/{runtime-4ac0107b.mjs → runtime-161f68a2.mjs} +24 -23
- package/dist/runtime-3f13807b.js +1 -0
- package/dist/runtime.cjs.js +1 -1
- package/dist/runtime.d.ts +2 -0
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.esm.js +39 -24
- package/dist/scroll-lock-31da444f.mjs +56 -0
- package/dist/scroll-lock-d7b0df21.js +1 -0
- package/dist/scroll-lock.d.ts.map +1 -1
- package/dist/select.cjs.js +14 -15
- package/dist/select.esm.js +117 -97
- package/dist/selection-popup.cjs.js +4 -7
- package/dist/selection-popup.esm.js +8 -11
- package/dist/split-button.cjs.js +1 -1
- package/dist/split-button.esm.js +2 -2
- package/dist/standalone/radio.d.ts +2 -0
- package/dist/standalone/radio.d.ts.map +1 -0
- package/dist/stepper.cjs.js +19 -50
- package/dist/stepper.esm.js +17 -48
- package/dist/time-field.cjs.js +1 -1
- package/dist/time-field.esm.js +3 -2
- package/dist/time-picker.cjs.js +15 -15
- package/dist/time-picker.esm.js +100 -68
- package/dist/tooltip.cjs.js +1 -1
- package/dist/tooltip.esm.js +2 -1
- package/package.json +1 -1
- package/dist/date-time-utils-5cf58cd0.js +0 -1
- package/dist/date-time-utils-bdceb7af.mjs +0 -273
- package/dist/portal-1cf392ca.mjs +0 -114
- package/dist/portal-d8d7fbca.js +0 -1
- package/dist/positioner-accc6e5f.js +0 -1
- package/dist/positioner-fbd61bf1.mjs +0 -132
- package/dist/runtime-5f282bc8.js +0 -1
- package/dist/scroll-lock-48793569.js +0 -1
- package/dist/scroll-lock-9de6d328.mjs +0 -53
package/dist/drawer.esm.js
CHANGED
|
@@ -1,7 +1,40 @@
|
|
|
1
|
-
import { E } from "./ElementBase-909688f3.mjs";
|
|
2
|
-
import { O as
|
|
3
|
-
import "./scroll-lock-
|
|
4
|
-
|
|
1
|
+
import { E as I } from "./ElementBase-909688f3.mjs";
|
|
2
|
+
import { O as m } from "./overlayManager-5bbd4dc3.mjs";
|
|
3
|
+
import "./scroll-lock-31da444f.mjs";
|
|
4
|
+
function F(i) {
|
|
5
|
+
return typeof requestAnimationFrame == "function" ? requestAnimationFrame(() => i()) : window.setTimeout(i, 16);
|
|
6
|
+
}
|
|
7
|
+
function _(i) {
|
|
8
|
+
if (i) {
|
|
9
|
+
if (typeof cancelAnimationFrame == "function") {
|
|
10
|
+
cancelAnimationFrame(i);
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
window.clearTimeout(i);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
const E = 'button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])', S = /* @__PURE__ */ new Set([
|
|
17
|
+
"side",
|
|
18
|
+
"dismissible",
|
|
19
|
+
"headless",
|
|
20
|
+
"variant",
|
|
21
|
+
"density",
|
|
22
|
+
"shape",
|
|
23
|
+
"elevation",
|
|
24
|
+
"tone",
|
|
25
|
+
"size",
|
|
26
|
+
"inset",
|
|
27
|
+
"close-on-overlay",
|
|
28
|
+
"close-on-esc",
|
|
29
|
+
"lock-while-loading",
|
|
30
|
+
"show-close",
|
|
31
|
+
"state",
|
|
32
|
+
"role",
|
|
33
|
+
"aria-label",
|
|
34
|
+
"aria-labelledby",
|
|
35
|
+
"aria-describedby",
|
|
36
|
+
"initial-focus"
|
|
37
|
+
]), O = `
|
|
5
38
|
:host {
|
|
6
39
|
position: fixed;
|
|
7
40
|
inset: 0;
|
|
@@ -502,29 +535,29 @@ const x = 'button:not([disabled]), [href], input:not([disabled]), select:not([di
|
|
|
502
535
|
}
|
|
503
536
|
}
|
|
504
537
|
`;
|
|
505
|
-
function
|
|
538
|
+
function w(i, e) {
|
|
506
539
|
if (i == null)
|
|
507
540
|
return e;
|
|
508
|
-
const
|
|
509
|
-
return
|
|
541
|
+
const t = i.trim().toLowerCase();
|
|
542
|
+
return t !== "false" && t !== "0" && t !== "off";
|
|
510
543
|
}
|
|
511
|
-
function
|
|
544
|
+
function v(i) {
|
|
512
545
|
return i.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
513
546
|
}
|
|
514
|
-
function
|
|
547
|
+
function C(i, e) {
|
|
515
548
|
return i === "top" || i === "bottom" || i === "left" || i === "right" ? i : i === "start" ? e === "rtl" ? "right" : "left" : i === "end" ? e === "rtl" ? "left" : "right" : "left";
|
|
516
549
|
}
|
|
517
|
-
function
|
|
518
|
-
var
|
|
519
|
-
const
|
|
520
|
-
return
|
|
550
|
+
function A(i, e) {
|
|
551
|
+
var r;
|
|
552
|
+
const t = i.querySelector(`[slot="${e}"]`);
|
|
553
|
+
return t ? ((r = t.textContent) == null ? void 0 : r.trim().length) !== 0 || t.children.length > 0 : !1;
|
|
521
554
|
}
|
|
522
|
-
function
|
|
555
|
+
function L() {
|
|
523
556
|
return typeof window < "u" && typeof document < "u";
|
|
524
557
|
}
|
|
525
|
-
class
|
|
558
|
+
class T extends I {
|
|
526
559
|
constructor() {
|
|
527
|
-
super(), this._uid = Math.random().toString(36).slice(2, 10), this._isOpen = !1, this._restoreFocusEl = null, this._globalListenersBound = !1, this._closeReason = "programmatic", this._onRootClick = this._onRootClick.bind(this), this._onDocumentKeyDown = this._onDocumentKeyDown.bind(this), this._onDocumentFocusIn = this._onDocumentFocusIn.bind(this);
|
|
560
|
+
super(), this._uid = Math.random().toString(36).slice(2, 10), this._isOpen = !1, this._restoreFocusEl = null, this._globalListenersBound = !1, this._closeReason = "programmatic", this._focusInitialFrame = 0, this._focusTrapFrame = 0, this._restoreFocusFrame = 0, this._onRootClick = this._onRootClick.bind(this), this._onDocumentKeyDown = this._onDocumentKeyDown.bind(this), this._onDocumentFocusIn = this._onDocumentFocusIn.bind(this);
|
|
528
561
|
}
|
|
529
562
|
static get observedAttributes() {
|
|
530
563
|
return [
|
|
@@ -556,15 +589,19 @@ class O extends E {
|
|
|
556
589
|
super.connectedCallback(), this.root.addEventListener("click", this._onRootClick), this._syncOpenState();
|
|
557
590
|
}
|
|
558
591
|
disconnectedCallback() {
|
|
559
|
-
this.root.removeEventListener("click", this._onRootClick), this._unbindGlobalListeners(), this._releaseOpenResources(), this._restoreFocusEl = null, this._isOpen = !1, super.disconnectedCallback();
|
|
592
|
+
this.root.removeEventListener("click", this._onRootClick), this._unbindGlobalListeners(), this._cancelScheduledFocusWork(), this._releaseOpenResources(), this._restoreFocusEl = null, this._isOpen = !1, super.disconnectedCallback();
|
|
560
593
|
}
|
|
561
|
-
attributeChangedCallback(e,
|
|
562
|
-
if (
|
|
594
|
+
attributeChangedCallback(e, t, r) {
|
|
595
|
+
if (t !== r) {
|
|
563
596
|
if (e === "open") {
|
|
564
597
|
this._syncOpenState();
|
|
565
598
|
return;
|
|
566
599
|
}
|
|
567
|
-
|
|
600
|
+
if (S.has(e)) {
|
|
601
|
+
this._syncLiveUi(), this._isOpen && (e === "initial-focus" || e === "dismissible" || e === "show-close") && this._scheduleEnsureFocusTrap();
|
|
602
|
+
return;
|
|
603
|
+
}
|
|
604
|
+
this.isConnected && this.requestRender();
|
|
568
605
|
}
|
|
569
606
|
}
|
|
570
607
|
open() {
|
|
@@ -587,31 +624,31 @@ class O extends E {
|
|
|
587
624
|
}
|
|
588
625
|
get dismissible() {
|
|
589
626
|
const e = this.getAttribute("dismissible");
|
|
590
|
-
return e == null ? !1 :
|
|
627
|
+
return e == null ? !1 : w(e, !0);
|
|
591
628
|
}
|
|
592
629
|
set dismissible(e) {
|
|
593
630
|
e ? this.setAttribute("dismissible", "") : this.removeAttribute("dismissible");
|
|
594
631
|
}
|
|
595
632
|
get closeOnOverlay() {
|
|
596
|
-
return
|
|
633
|
+
return w(this.getAttribute("close-on-overlay"), !0);
|
|
597
634
|
}
|
|
598
635
|
set closeOnOverlay(e) {
|
|
599
636
|
this.setAttribute("close-on-overlay", String(e));
|
|
600
637
|
}
|
|
601
638
|
get closeOnEsc() {
|
|
602
|
-
return
|
|
639
|
+
return w(this.getAttribute("close-on-esc"), !0);
|
|
603
640
|
}
|
|
604
641
|
set closeOnEsc(e) {
|
|
605
642
|
this.setAttribute("close-on-esc", String(e));
|
|
606
643
|
}
|
|
607
644
|
get lockWhileLoading() {
|
|
608
|
-
return
|
|
645
|
+
return w(this.getAttribute("lock-while-loading"), !0);
|
|
609
646
|
}
|
|
610
647
|
set lockWhileLoading(e) {
|
|
611
648
|
this.setAttribute("lock-while-loading", String(e));
|
|
612
649
|
}
|
|
613
650
|
get showClose() {
|
|
614
|
-
return this.hasAttribute("show-close") ?
|
|
651
|
+
return this.hasAttribute("show-close") ? w(this.getAttribute("show-close"), !0) : this.dismissible;
|
|
615
652
|
}
|
|
616
653
|
set showClose(e) {
|
|
617
654
|
this.setAttribute("show-close", String(e));
|
|
@@ -636,8 +673,27 @@ class O extends E {
|
|
|
636
673
|
_getPanel() {
|
|
637
674
|
return this.root.querySelector(".panel");
|
|
638
675
|
}
|
|
676
|
+
_getOverlay() {
|
|
677
|
+
return this.root.querySelector(".overlay");
|
|
678
|
+
}
|
|
679
|
+
_getHeader() {
|
|
680
|
+
return this.root.querySelector(".header");
|
|
681
|
+
}
|
|
682
|
+
_titleId() {
|
|
683
|
+
return `ui-drawer-title-${this._uid}`;
|
|
684
|
+
}
|
|
685
|
+
_descriptionId() {
|
|
686
|
+
return `ui-drawer-description-${this._uid}`;
|
|
687
|
+
}
|
|
688
|
+
_bodyId() {
|
|
689
|
+
return `ui-drawer-body-${this._uid}`;
|
|
690
|
+
}
|
|
691
|
+
_resolvedSide() {
|
|
692
|
+
const e = this.getAttribute("dir") || document.documentElement.getAttribute("dir") || "ltr";
|
|
693
|
+
return C(this.getAttribute("side"), e === "rtl" ? "rtl" : "ltr");
|
|
694
|
+
}
|
|
639
695
|
_isTopMost() {
|
|
640
|
-
const e =
|
|
696
|
+
const e = m.top();
|
|
641
697
|
return e ? e === this : !0;
|
|
642
698
|
}
|
|
643
699
|
_isInteractionLocked() {
|
|
@@ -646,22 +702,65 @@ class O extends E {
|
|
|
646
702
|
_isNodeInsideDrawer(e) {
|
|
647
703
|
if (!e)
|
|
648
704
|
return !1;
|
|
649
|
-
const
|
|
650
|
-
return
|
|
705
|
+
const t = this._getPanel();
|
|
706
|
+
return t && t.contains(e) ? !0 : this.contains(e);
|
|
651
707
|
}
|
|
652
708
|
_isFocusable(e) {
|
|
653
709
|
if (!e || !e.isConnected || e.disabled || e.matches('[inert], [aria-hidden="true"]') || e.closest('[inert], [aria-hidden="true"]'))
|
|
654
710
|
return !1;
|
|
655
|
-
if (!
|
|
711
|
+
if (!L())
|
|
656
712
|
return !0;
|
|
657
|
-
const
|
|
658
|
-
return
|
|
713
|
+
const t = window.getComputedStyle(e);
|
|
714
|
+
return t.display !== "none" && t.visibility !== "hidden";
|
|
659
715
|
}
|
|
660
716
|
_collectFocusable() {
|
|
661
|
-
const e = this._getPanel(),
|
|
662
|
-
this._isFocusable(
|
|
717
|
+
const e = this._getPanel(), t = [], r = (s) => {
|
|
718
|
+
this._isFocusable(s) && (t.includes(s) || t.push(s));
|
|
663
719
|
};
|
|
664
|
-
return this.querySelectorAll(
|
|
720
|
+
return this.querySelectorAll(E).forEach(r), e && e.querySelectorAll(E).forEach(r), t;
|
|
721
|
+
}
|
|
722
|
+
_cancelScheduledFocusWork() {
|
|
723
|
+
this._focusInitialFrame && (_(this._focusInitialFrame), this._focusInitialFrame = 0), this._focusTrapFrame && (_(this._focusTrapFrame), this._focusTrapFrame = 0), this._restoreFocusFrame && (_(this._restoreFocusFrame), this._restoreFocusFrame = 0);
|
|
724
|
+
}
|
|
725
|
+
_scheduleFocusInitial() {
|
|
726
|
+
this._isOpen && (this._focusInitialFrame || (this._focusInitialFrame = F(() => {
|
|
727
|
+
this._focusInitialFrame = 0, this._focusInitial();
|
|
728
|
+
})));
|
|
729
|
+
}
|
|
730
|
+
_scheduleEnsureFocusTrap() {
|
|
731
|
+
this._isOpen && (this._focusTrapFrame || (this._focusTrapFrame = F(() => {
|
|
732
|
+
this._focusTrapFrame = 0, this._ensureFocusTrap();
|
|
733
|
+
})));
|
|
734
|
+
}
|
|
735
|
+
_scheduleRestoreFocus(e) {
|
|
736
|
+
!e || !this._canRestoreFocus(e) || (this._restoreFocusFrame && _(this._restoreFocusFrame), this._restoreFocusFrame = F(() => {
|
|
737
|
+
this._restoreFocusFrame = 0;
|
|
738
|
+
try {
|
|
739
|
+
this._canRestoreFocus(e) && e.focus({ preventScroll: !0 });
|
|
740
|
+
} catch {
|
|
741
|
+
try {
|
|
742
|
+
this._canRestoreFocus(e) && e.focus();
|
|
743
|
+
} catch {
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
}));
|
|
747
|
+
}
|
|
748
|
+
_syncLiveUi() {
|
|
749
|
+
const e = this.hasAttribute("open"), t = this._getOverlay(), r = this._getPanel(), s = this._getHeader(), a = this.root.querySelector(".close-btn");
|
|
750
|
+
if (t && t.setAttribute("aria-hidden", e ? "false" : "true"), !r)
|
|
751
|
+
return;
|
|
752
|
+
const o = this._resolvedSide();
|
|
753
|
+
r.classList.remove("side-left", "side-right", "side-top", "side-bottom"), r.classList.add(`side-${o}`);
|
|
754
|
+
const n = this.state === "loading";
|
|
755
|
+
n ? r.setAttribute("aria-busy", "true") : r.removeAttribute("aria-busy");
|
|
756
|
+
const y = this.getAttribute("role") || "dialog";
|
|
757
|
+
r.setAttribute("role", y);
|
|
758
|
+
const u = (this.getAttribute("title") || "").trim(), h = (this.getAttribute("description") || "").trim(), p = A(this, "header"), b = this.showClose, x = b || p || !!u || !!h;
|
|
759
|
+
s && s.classList.toggle("empty", !x), a && (a.hidden = !b, a.disabled = n && this.lockWhileLoading);
|
|
760
|
+
const f = this.getAttribute("aria-label") || "", g = this.getAttribute("aria-labelledby") || "", l = this.getAttribute("aria-describedby") || "", c = g || (!f && (p || u) ? this._titleId() : ""), d = [];
|
|
761
|
+
l ? d.push(l) : (h && d.push(this._descriptionId()), d.push(this._bodyId()));
|
|
762
|
+
const k = f || (c ? "" : "Drawer");
|
|
763
|
+
k ? r.setAttribute("aria-label", k) : r.removeAttribute("aria-label"), c ? r.setAttribute("aria-labelledby", c) : r.removeAttribute("aria-labelledby"), d.length ? r.setAttribute("aria-describedby", d.join(" ")) : r.removeAttribute("aria-describedby");
|
|
665
764
|
}
|
|
666
765
|
_focusInitial() {
|
|
667
766
|
if (!this._isOpen)
|
|
@@ -669,21 +768,30 @@ class O extends E {
|
|
|
669
768
|
const e = this._getPanel();
|
|
670
769
|
if (!e)
|
|
671
770
|
return;
|
|
672
|
-
const
|
|
673
|
-
if (
|
|
674
|
-
const
|
|
675
|
-
if (
|
|
771
|
+
const t = this.getAttribute("initial-focus") || "";
|
|
772
|
+
if (t) {
|
|
773
|
+
const o = this.querySelector(t) || e.querySelector(t);
|
|
774
|
+
if (o && this._isFocusable(o))
|
|
676
775
|
try {
|
|
677
|
-
|
|
776
|
+
o.focus({ preventScroll: !0 });
|
|
678
777
|
return;
|
|
679
778
|
} catch {
|
|
779
|
+
try {
|
|
780
|
+
o.focus();
|
|
781
|
+
return;
|
|
782
|
+
} catch {
|
|
783
|
+
}
|
|
680
784
|
}
|
|
681
785
|
}
|
|
682
|
-
const
|
|
786
|
+
const r = this._collectFocusable(), a = r.find((o) => o.hasAttribute("autofocus")) || r[0] || e;
|
|
683
787
|
a === e && !a.hasAttribute("tabindex") && a.setAttribute("tabindex", "-1");
|
|
684
788
|
try {
|
|
685
|
-
a.focus();
|
|
789
|
+
a.focus({ preventScroll: !0 });
|
|
686
790
|
} catch {
|
|
791
|
+
try {
|
|
792
|
+
a.focus();
|
|
793
|
+
} catch {
|
|
794
|
+
}
|
|
687
795
|
}
|
|
688
796
|
}
|
|
689
797
|
_ensureFocusTrap() {
|
|
@@ -694,31 +802,31 @@ class O extends E {
|
|
|
694
802
|
}
|
|
695
803
|
_releaseOpenResources() {
|
|
696
804
|
try {
|
|
697
|
-
|
|
805
|
+
m.unregister(this), m.releaseLock();
|
|
698
806
|
} catch {
|
|
699
807
|
}
|
|
700
808
|
}
|
|
701
809
|
_canRestoreFocus(e) {
|
|
702
810
|
if (!e || !e.isConnected || e.disabled)
|
|
703
811
|
return !1;
|
|
704
|
-
if (!
|
|
812
|
+
if (!L())
|
|
705
813
|
return !0;
|
|
706
|
-
const
|
|
707
|
-
return
|
|
814
|
+
const t = window.getComputedStyle(e);
|
|
815
|
+
return t.display !== "none" && t.visibility !== "hidden";
|
|
708
816
|
}
|
|
709
817
|
_syncOpenState() {
|
|
710
818
|
const e = this.hasAttribute("open");
|
|
711
|
-
if (e === this._isOpen) {
|
|
712
|
-
e ? (this._bindGlobalListeners(),
|
|
819
|
+
if (this._syncLiveUi(), e === this._isOpen) {
|
|
820
|
+
e ? (this._bindGlobalListeners(), this._scheduleEnsureFocusTrap()) : (this._unbindGlobalListeners(), this._cancelScheduledFocusWork());
|
|
713
821
|
return;
|
|
714
822
|
}
|
|
715
823
|
if (this._isOpen = e, e) {
|
|
716
|
-
this._bindGlobalListeners(), this._restoreFocusEl = document.activeElement || null, this._closeReason = "programmatic";
|
|
824
|
+
this._cancelScheduledFocusWork(), this._bindGlobalListeners(), this._restoreFocusEl = document.activeElement || null, this._closeReason = "programmatic";
|
|
717
825
|
try {
|
|
718
|
-
|
|
826
|
+
m.register(this), m.acquireLock();
|
|
719
827
|
} catch {
|
|
720
828
|
}
|
|
721
|
-
this.
|
|
829
|
+
this._scheduleFocusInitial(), this._scheduleEnsureFocusTrap(), this.dispatchEvent(new CustomEvent("open", { bubbles: !0, composed: !0 })), this.dispatchEvent(new CustomEvent("show", { bubbles: !0, composed: !0 })), this.dispatchEvent(
|
|
722
830
|
new CustomEvent("change", {
|
|
723
831
|
bubbles: !0,
|
|
724
832
|
composed: !0,
|
|
@@ -727,77 +835,87 @@ class O extends E {
|
|
|
727
835
|
);
|
|
728
836
|
return;
|
|
729
837
|
}
|
|
730
|
-
this._unbindGlobalListeners(), this._releaseOpenResources();
|
|
731
|
-
const
|
|
838
|
+
this._unbindGlobalListeners(), this._cancelScheduledFocusWork(), this._releaseOpenResources();
|
|
839
|
+
const t = this._closeReason;
|
|
732
840
|
this.dispatchEvent(
|
|
733
841
|
new CustomEvent("close", {
|
|
734
842
|
bubbles: !0,
|
|
735
843
|
composed: !0,
|
|
736
|
-
detail: { reason:
|
|
844
|
+
detail: { reason: t }
|
|
737
845
|
})
|
|
738
846
|
), this.dispatchEvent(
|
|
739
847
|
new CustomEvent("hide", {
|
|
740
848
|
bubbles: !0,
|
|
741
849
|
composed: !0,
|
|
742
|
-
detail: { reason:
|
|
850
|
+
detail: { reason: t }
|
|
743
851
|
})
|
|
744
852
|
), this.dispatchEvent(
|
|
745
853
|
new CustomEvent("change", {
|
|
746
854
|
bubbles: !0,
|
|
747
855
|
composed: !0,
|
|
748
|
-
detail: { open: !1, reason:
|
|
856
|
+
detail: { open: !1, reason: t }
|
|
749
857
|
})
|
|
750
858
|
);
|
|
751
|
-
const
|
|
752
|
-
|
|
753
|
-
try {
|
|
754
|
-
this._canRestoreFocus(t) && t.focus();
|
|
755
|
-
} catch {
|
|
756
|
-
}
|
|
859
|
+
const r = this._restoreFocusEl;
|
|
860
|
+
this._restoreFocusEl = null, this._closeReason = "programmatic", this._scheduleRestoreFocus(r);
|
|
757
861
|
}
|
|
758
862
|
_requestClose(e) {
|
|
759
863
|
if (!this._isOpen || this._isInteractionLocked())
|
|
760
864
|
return;
|
|
761
|
-
const
|
|
865
|
+
const t = new CustomEvent("request-close", {
|
|
762
866
|
detail: { reason: e },
|
|
763
867
|
bubbles: !0,
|
|
764
868
|
composed: !0,
|
|
765
869
|
cancelable: !0
|
|
766
870
|
});
|
|
767
|
-
this.dispatchEvent(
|
|
768
|
-
const
|
|
871
|
+
this.dispatchEvent(t);
|
|
872
|
+
const r = new CustomEvent("ui-request-close", {
|
|
769
873
|
detail: { reason: e },
|
|
770
874
|
bubbles: !0,
|
|
771
875
|
composed: !0,
|
|
772
876
|
cancelable: !0
|
|
773
877
|
});
|
|
774
|
-
this.dispatchEvent(
|
|
878
|
+
this.dispatchEvent(r), !(t.defaultPrevented || r.defaultPrevented) && this.close(e);
|
|
775
879
|
}
|
|
776
880
|
_onRootClick(e) {
|
|
777
|
-
const
|
|
778
|
-
if (!
|
|
881
|
+
const t = e.target;
|
|
882
|
+
if (!t || !this._isOpen)
|
|
779
883
|
return;
|
|
780
|
-
if (
|
|
884
|
+
if (t.closest(".close-btn")) {
|
|
781
885
|
this._requestClose("button");
|
|
782
886
|
return;
|
|
783
887
|
}
|
|
784
|
-
|
|
888
|
+
t.closest(".overlay") && (!this.dismissible || !this.closeOnOverlay || this._isTopMost() && this._requestClose("overlay"));
|
|
785
889
|
}
|
|
786
890
|
_handleTab(e) {
|
|
787
|
-
const
|
|
788
|
-
if (!
|
|
891
|
+
const t = this._getPanel();
|
|
892
|
+
if (!t)
|
|
789
893
|
return;
|
|
790
|
-
const
|
|
791
|
-
if (!
|
|
792
|
-
e.preventDefault(),
|
|
894
|
+
const r = this._collectFocusable();
|
|
895
|
+
if (!r.length) {
|
|
896
|
+
e.preventDefault(), t.focus();
|
|
793
897
|
return;
|
|
794
898
|
}
|
|
795
|
-
const
|
|
899
|
+
const s = r[0], a = r[r.length - 1], o = document.activeElement, n = !!o && this._isNodeInsideDrawer(o);
|
|
796
900
|
if (e.shiftKey) {
|
|
797
|
-
(!n ||
|
|
901
|
+
if (!n || o === s) {
|
|
902
|
+
e.preventDefault();
|
|
903
|
+
try {
|
|
904
|
+
a.focus({ preventScroll: !0 });
|
|
905
|
+
} catch {
|
|
906
|
+
a.focus();
|
|
907
|
+
}
|
|
908
|
+
}
|
|
798
909
|
return;
|
|
799
910
|
}
|
|
800
|
-
(!n ||
|
|
911
|
+
if (!n || o === a) {
|
|
912
|
+
e.preventDefault();
|
|
913
|
+
try {
|
|
914
|
+
s.focus({ preventScroll: !0 });
|
|
915
|
+
} catch {
|
|
916
|
+
s.focus();
|
|
917
|
+
}
|
|
918
|
+
}
|
|
801
919
|
}
|
|
802
920
|
_onDocumentKeyDown(e) {
|
|
803
921
|
if (!(!this._isOpen || !this._isTopMost())) {
|
|
@@ -813,40 +931,40 @@ class O extends E {
|
|
|
813
931
|
_onDocumentFocusIn(e) {
|
|
814
932
|
if (!this._isOpen || !this._isTopMost())
|
|
815
933
|
return;
|
|
816
|
-
const
|
|
817
|
-
|
|
934
|
+
const t = e.target, r = this._getPanel(), s = typeof e.composedPath == "function" ? e.composedPath() : [];
|
|
935
|
+
t && this._isNodeInsideDrawer(t) || s.includes(this) || r && s.includes(r) || this._scheduleFocusInitial();
|
|
818
936
|
}
|
|
819
937
|
render() {
|
|
820
|
-
const e = this.getAttribute("dir") || document.documentElement.getAttribute("dir") || "ltr",
|
|
821
|
-
|
|
822
|
-
const
|
|
938
|
+
const e = this.getAttribute("dir") || document.documentElement.getAttribute("dir") || "ltr", t = C(this.getAttribute("side"), e === "rtl" ? "rtl" : "ltr"), r = this.showClose, s = A(this, "header"), a = A(this, "footer"), o = (this.getAttribute("title") || "").trim(), n = (this.getAttribute("description") || "").trim(), y = r || s || !!o || !!n, u = `ui-drawer-title-${this._uid}`, h = `ui-drawer-description-${this._uid}`, p = `ui-drawer-body-${this._uid}`, b = this.getAttribute("aria-label") || "", x = this.getAttribute("aria-labelledby") || "", f = this.getAttribute("aria-describedby") || "", g = x || (!b && (s || o) ? u : ""), l = [];
|
|
939
|
+
f ? l.push(f) : (n && l.push(h), l.push(p));
|
|
940
|
+
const c = b || (g ? "" : "Drawer"), d = this.state === "loading";
|
|
823
941
|
this.setContent(`
|
|
824
|
-
<style>${
|
|
942
|
+
<style>${O}</style>
|
|
825
943
|
<div class="overlay" part="overlay" aria-hidden="true"></div>
|
|
826
944
|
<aside
|
|
827
|
-
class="panel side-${
|
|
945
|
+
class="panel side-${t}"
|
|
828
946
|
part="panel"
|
|
829
947
|
role="dialog"
|
|
830
948
|
aria-modal="true"
|
|
831
|
-
${
|
|
832
|
-
${
|
|
833
|
-
${l.length ? `aria-describedby="${
|
|
834
|
-
${
|
|
949
|
+
${c ? `aria-label="${v(c)}"` : ""}
|
|
950
|
+
${g ? `aria-labelledby="${v(g)}"` : ""}
|
|
951
|
+
${l.length ? `aria-describedby="${v(l.join(" "))}"` : ""}
|
|
952
|
+
${d ? 'aria-busy="true"' : ""}
|
|
835
953
|
tabindex="-1"
|
|
836
954
|
>
|
|
837
|
-
<header class="header ${
|
|
955
|
+
<header class="header ${y ? "" : "empty"}" part="header">
|
|
838
956
|
<div class="header-main">
|
|
839
|
-
${
|
|
840
|
-
${!
|
|
841
|
-
${n ? `<p class="subtitle" id="${
|
|
957
|
+
${s ? `<slot name="header" id="${u}"></slot>` : ""}
|
|
958
|
+
${!s && o ? `<h2 class="title" id="${u}">${v(o)}</h2>` : ""}
|
|
959
|
+
${n ? `<p class="subtitle" id="${h}">${v(n)}</p>` : ""}
|
|
842
960
|
</div>
|
|
843
961
|
<button
|
|
844
962
|
type="button"
|
|
845
963
|
class="close-btn"
|
|
846
964
|
part="close"
|
|
847
965
|
aria-label="Close drawer"
|
|
848
|
-
${
|
|
849
|
-
${
|
|
966
|
+
${r ? "" : "hidden"}
|
|
967
|
+
${d && this.lockWhileLoading ? "disabled" : ""}
|
|
850
968
|
>
|
|
851
969
|
<svg class="close-icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" aria-hidden="true">
|
|
852
970
|
<path d="M3.5 3.5L12.5 12.5"></path>
|
|
@@ -854,10 +972,10 @@ class O extends E {
|
|
|
854
972
|
</svg>
|
|
855
973
|
</button>
|
|
856
974
|
</header>
|
|
857
|
-
<div class="body" part="body" id="${
|
|
975
|
+
<div class="body" part="body" id="${p}"><slot></slot></div>
|
|
858
976
|
<footer class="footer ${a ? "" : "empty"}" part="footer"><slot name="footer"></slot></footer>
|
|
859
977
|
</aside>
|
|
860
|
-
`), this._isOpen &&
|
|
978
|
+
`), this._syncLiveUi(), this._isOpen && this._scheduleEnsureFocusTrap();
|
|
861
979
|
}
|
|
862
980
|
_bindGlobalListeners() {
|
|
863
981
|
this._globalListenersBound || (document.addEventListener("keydown", this._onDocumentKeyDown, !0), document.addEventListener("focusin", this._onDocumentFocusIn, !0), this._globalListenersBound = !0);
|
|
@@ -866,7 +984,7 @@ class O extends E {
|
|
|
866
984
|
this._globalListenersBound && (document.removeEventListener("keydown", this._onDocumentKeyDown, !0), document.removeEventListener("focusin", this._onDocumentFocusIn, !0), this._globalListenersBound = !1);
|
|
867
985
|
}
|
|
868
986
|
}
|
|
869
|
-
typeof customElements < "u" && !customElements.get("ui-drawer") && customElements.define("ui-drawer",
|
|
987
|
+
typeof customElements < "u" && !customElements.get("ui-drawer") && customElements.define("ui-drawer", T);
|
|
870
988
|
export {
|
|
871
|
-
|
|
989
|
+
T as UIDrawer
|
|
872
990
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const b=require("./ElementBase-1b301e7f.js"),f=require("./positioner-33529bb8.js"),p=`
|
|
2
2
|
:host {
|
|
3
3
|
position: fixed;
|
|
4
4
|
inset: 0;
|
|
@@ -20,8 +20,6 @@
|
|
|
20
20
|
--ui-floating-toolbar-focus-ring: var(--ui-color-focus-ring, #2563eb);
|
|
21
21
|
--ui-floating-toolbar-accent: var(--ui-color-primary, #2563eb);
|
|
22
22
|
--ui-floating-toolbar-backdrop: none;
|
|
23
|
-
--ui-floating-toolbar-x: 0px;
|
|
24
|
-
--ui-floating-toolbar-y: 0px;
|
|
25
23
|
--ui-floating-toolbar-enter-y: -4px;
|
|
26
24
|
--ui-floating-toolbar-duration: 170ms;
|
|
27
25
|
--ui-floating-toolbar-easing: cubic-bezier(0.2, 0.8, 0.2, 1);
|
|
@@ -49,13 +47,7 @@
|
|
|
49
47
|
display: grid;
|
|
50
48
|
gap: var(--ui-floating-toolbar-gap);
|
|
51
49
|
outline: none;
|
|
52
|
-
transform:
|
|
53
|
-
translate3d(
|
|
54
|
-
var(--ui-floating-toolbar-x, 0px),
|
|
55
|
-
calc(var(--ui-floating-toolbar-y, 0px) + var(--ui-floating-toolbar-enter-y, -4px)),
|
|
56
|
-
0
|
|
57
|
-
)
|
|
58
|
-
scale(0.985);
|
|
50
|
+
transform: translate3d(0, var(--ui-floating-toolbar-enter-y, -4px), 0) scale(0.985);
|
|
59
51
|
opacity: 0;
|
|
60
52
|
transition:
|
|
61
53
|
transform var(--ui-floating-toolbar-duration) var(--ui-floating-toolbar-easing),
|
|
@@ -68,9 +60,7 @@
|
|
|
68
60
|
|
|
69
61
|
:host([open]) .panel {
|
|
70
62
|
opacity: 1;
|
|
71
|
-
transform:
|
|
72
|
-
translate3d(var(--ui-floating-toolbar-x, 0px), var(--ui-floating-toolbar-y, 0px), 0)
|
|
73
|
-
scale(1);
|
|
63
|
+
transform: translate3d(0, 0, 0) scale(1);
|
|
74
64
|
}
|
|
75
65
|
|
|
76
66
|
.panel[data-side="bottom"] {
|
|
@@ -210,8 +200,8 @@
|
|
|
210
200
|
transition: none !important;
|
|
211
201
|
}
|
|
212
202
|
}
|
|
213
|
-
`;function
|
|
214
|
-
<style>${
|
|
203
|
+
`;function g(i,t){if(i==null||i==="")return t;const e=Number(i);return Number.isFinite(e)?e:t}function h(i,t){if(i==null)return t;const e=i.trim().toLowerCase();return e!=="false"&&e!=="0"&&e!=="off"}function _(i){if(!document.body.contains(i))return!1;const t=window.getComputedStyle(i);return!(t.display==="none"||t.visibility==="hidden"||Number.parseFloat(t.opacity||"1")<=0)}function m(i){return i==="top"||i==="bottom"?i:"auto"}function v(i){return i==="start"||i==="end"?i:"center"}function y(i,t){const e=i==="top"?"top":"bottom";return t==="start"?`${e}-start`:t==="end"?`${e}-end`:e}function w(i){const t='button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])',e=[];return i.forEach(o=>{o instanceof HTMLElement&&(o.matches(t)&&e.push(o),e.push(...Array.from(o.querySelectorAll(t))))}),Array.from(new Set(e))}class d extends b.ElementBase{constructor(){super(...arguments),this._anchor=null,this._panel=null,this._toolbarSlot=null,this._defaultSlot=null,this._raf=null,this._resizeObserver=null,this._mutationObserver=null,this._positioner=null,this._positionerPlacement=null,this._positionerOffset=0,this._globalListenersBound=!1,this._isOpen=!1,this._closeReason="programmatic",this._onWindowChangeBound=this._onWindowChange.bind(this),this._onDocumentPointerDownBound=this._onDocumentPointerDown.bind(this),this._onDocumentKeyDownBound=this._onDocumentKeyDown.bind(this),this._onPanelKeyDownBound=this._onPanelKeyDown.bind(this),this._onSlotChangeBound=this._onSlotChange.bind(this)}static get observedAttributes(){return["open","anchor-id","headless","disabled","placement","align","offset","close-on-outside","close-on-escape","aria-label","aria-labelledby","variant","density","shape","elevation","tone"]}connectedCallback(){super.connectedCallback(),this._syncAnchorFromAttribute(),this._syncOpenState(),this._schedulePosition()}disconnectedCallback(){var t;this._unbindGlobalListeners(),this._teardownObservers(),(t=this._positioner)==null||t.destroy(),this._positioner=null,this._raf!=null&&(cancelAnimationFrame(this._raf),this._raf=null),super.disconnectedCallback()}attributeChangedCallback(t,e,o){if(e!==o){if(t==="anchor-id"){this._syncAnchorFromAttribute(),this.hasAttribute("open")&&!this._anchor&&this._requestClose("anchor-missing"),this._schedulePosition();return}if(t==="open"){this._syncOpenState(),this._schedulePosition();return}if(t==="disabled"){this.hasAttribute("disabled")&&this.hasAttribute("open")&&this._requestClose("disabled");return}if(t==="headless"){this._syncOpenState(),this._schedulePosition();return}if(t==="aria-label"||t==="aria-labelledby"){this._syncPanelA11y();return}(t==="placement"||t==="align"||t==="offset")&&this._schedulePosition()}}showForAnchorId(t){if(this.hasAttribute("disabled")||!t)return;const e=document.getElementById(t);if(!e){this._requestClose("anchor-missing");return}this._anchor=e,this.setAttribute("anchor-id",t),this.openToolbar()}hide(){this.closeToolbar("programmatic")}openToolbar(){this.hasAttribute("disabled")||(this.hasAttribute("open")||this.setAttribute("open",""),this._schedulePosition())}closeToolbar(t="programmatic"){this.hasAttribute("open")&&(this._closeReason=t,this.removeAttribute("open"))}_syncOpenState(){var e;const t=this.hasAttribute("open")&&!this.hasAttribute("headless")&&!this.hasAttribute("disabled");if(t===this._isOpen){t&&this._schedulePosition();return}if(this._isOpen=t,t){this._bindGlobalListeners(),this._ensureObservers(),this._dispatchOpenEvents(),this._schedulePosition();return}this._unbindGlobalListeners(),this._teardownObservers(),(e=this._positioner)==null||e.destroy(),this._positioner=null,this._positionerPlacement=null,this._positionerOffset=0,this._raf!=null&&(cancelAnimationFrame(this._raf),this._raf=null),this._dispatchCloseEvents(this._closeReason),this._closeReason="programmatic"}_dispatchOpenEvents(){this.dispatchEvent(new CustomEvent("open",{bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,composed:!0,detail:{open:!0}}))}_dispatchCloseEvents(t){this.dispatchEvent(new CustomEvent("close",{bubbles:!0,composed:!0,detail:{reason:t}})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,composed:!0,detail:{open:!1,reason:t}}))}_requestClose(t){if(!this.hasAttribute("open"))return;const e=new CustomEvent("request-close",{detail:{reason:t},bubbles:!0,composed:!0,cancelable:!0});this.dispatchEvent(e);const o=new CustomEvent("ui-request-close",{detail:{reason:t},bubbles:!0,composed:!0,cancelable:!0});this.dispatchEvent(o),!(e.defaultPrevented||o.defaultPrevented)&&this.closeToolbar(t)}_syncAnchorFromAttribute(){const t=this.getAttribute("anchor-id");if(!t){this._anchor=null;return}this._anchor=document.getElementById(t)}_schedulePosition(){!this.hasAttribute("open")||this.hasAttribute("headless")||this.hasAttribute("disabled")||(this._raf!=null&&cancelAnimationFrame(this._raf),this._raf=requestAnimationFrame(()=>{this._raf=null,this._position()}))}_ensureObservers(){if(!(this._resizeObserver&&this._mutationObserver)){if(typeof ResizeObserver<"u"){if(this._resizeObserver=new ResizeObserver(()=>this._schedulePosition()),this._panel)try{this._resizeObserver.observe(this._panel)}catch{}if(this._anchor)try{this._resizeObserver.observe(this._anchor)}catch{}}if(typeof MutationObserver<"u"&&this._anchor){this._mutationObserver=new MutationObserver(()=>this._schedulePosition());try{this._mutationObserver.observe(this._anchor,{attributes:!0,childList:!1,subtree:!1})}catch{}}}}_teardownObservers(){this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=null),this._mutationObserver&&(this._mutationObserver.disconnect(),this._mutationObserver=null)}_refreshObservers(){this._isOpen&&(this._teardownObservers(),this._ensureObservers())}_bindGlobalListeners(){this._globalListenersBound||(window.addEventListener("scroll",this._onWindowChangeBound,{passive:!0,capture:!0}),window.addEventListener("resize",this._onWindowChangeBound),document.addEventListener("pointerdown",this._onDocumentPointerDownBound,!0),document.addEventListener("keydown",this._onDocumentKeyDownBound,!0),this._globalListenersBound=!0)}_unbindGlobalListeners(){this._globalListenersBound&&(window.removeEventListener("scroll",this._onWindowChangeBound,!0),window.removeEventListener("resize",this._onWindowChangeBound),document.removeEventListener("pointerdown",this._onDocumentPointerDownBound,!0),document.removeEventListener("keydown",this._onDocumentKeyDownBound,!0),this._globalListenersBound=!1)}_position(){var s,a;if(!this.hasAttribute("open")||this.hasAttribute("headless")||this.hasAttribute("disabled"))return;if(!this._anchor){this._requestClose("anchor-missing");return}if(!_(this._anchor)){this._requestClose("anchor-hidden");return}if(!this._panel)return;const t=Math.max(0,g(this.getAttribute("offset"),8)),e=m(this.getAttribute("placement")),o=v(this.getAttribute("align")),n=y(e,o);if(!this._positioner||this._positionerPlacement!==n||this._positionerOffset!==t){(s=this._positioner)==null||s.destroy(),this._positioner=f.createPositioner({anchor:this._anchor,floating:this._panel,placement:n,strategy:"fixed",offset:t,flip:!0,shift:!0,boundaryPadding:8,observeWindowResize:!1,observeScroll:!1,observeAncestorScroll:!1,observeAncestorResize:!1,observeLayoutShift:!1,observeAnchorResize:!1,observeFloatingResize:!1,onUpdate:l=>{var u;const c=l.placement.startsWith("top")?"top":"bottom";this.style.setProperty("--ui-floating-toolbar-origin-x",o==="start"?"0%":o==="end"?"100%":"50%"),(u=this._panel)==null||u.setAttribute("data-side",c)}}),this._positionerPlacement=n,this._positionerOffset=t;return}(a=this._positioner)==null||a.update()}_onWindowChange(){this.hasAttribute("open")&&this._schedulePosition()}_onDocumentPointerDown(t){if(!this.hasAttribute("open")||!h(this.getAttribute("close-on-outside"),!0))return;const e=t.composedPath();e.includes(this)||this._anchor&&e.includes(this._anchor)||this._requestClose("outside")}_onDocumentKeyDown(t){this.hasAttribute("open")&&t.key==="Escape"&&h(this.getAttribute("close-on-escape"),!0)&&(t.preventDefault(),this._requestClose("escape"))}_onPanelKeyDown(t){if(!this._panel||!["ArrowRight","ArrowLeft","Home","End"].includes(t.key))return;const e=this._getFocusableItems();if(e.length===0)return;const o=document.activeElement,n=o?e.indexOf(o):-1;let r=n;t.key==="Home"?r=0:t.key==="End"?r=e.length-1:t.key==="ArrowRight"?r=n<0?0:(n+1)%e.length:t.key==="ArrowLeft"&&(r=n<0?e.length-1:(n-1+e.length)%e.length);const s=e[r];s&&(t.preventDefault(),s.focus())}_getFocusableItems(){var o,n;const t=((o=this._toolbarSlot)==null?void 0:o.assignedElements({flatten:!0}))||[],e=((n=this._defaultSlot)==null?void 0:n.assignedElements({flatten:!0}))||[];return w([...t,...e])}_onSlotChange(){this._syncRowVisibility(),this._schedulePosition()}_syncRowVisibility(){var r,s;const t=this.root.querySelector(".row-toolbar"),e=this.root.querySelector(".row-default");if(!t||!e)return;const o=(((r=this._toolbarSlot)==null?void 0:r.assignedNodes({flatten:!0}))||[]).some(a=>{var l;return a.nodeType===Node.TEXT_NODE?!!((l=a.textContent)!=null&&l.trim()):a.nodeType===Node.ELEMENT_NODE}),n=(((s=this._defaultSlot)==null?void 0:s.assignedNodes({flatten:!0}))||[]).some(a=>{var l;return a.nodeType===Node.TEXT_NODE?!!((l=a.textContent)!=null&&l.trim()):a.nodeType===Node.ELEMENT_NODE});o?t.removeAttribute("hidden"):t.setAttribute("hidden",""),n?e.removeAttribute("hidden"):e.setAttribute("hidden","")}_syncPanelA11y(){if(!this._panel)return;const t=this.getAttribute("aria-labelledby"),e=this.getAttribute("aria-label")||(t?null:"Floating toolbar");t?this._panel.setAttribute("aria-labelledby",t):this._panel.removeAttribute("aria-labelledby"),e?this._panel.setAttribute("aria-label",e):this._panel.removeAttribute("aria-label")}render(){var t,e,o,n,r,s;this.setContent(`
|
|
204
|
+
<style>${p}</style>
|
|
215
205
|
<section class="panel" part="panel" role="toolbar" aria-orientation="horizontal" tabindex="-1">
|
|
216
206
|
<div class="row row-toolbar" part="row-toolbar">
|
|
217
207
|
<slot name="toolbar"></slot>
|
|
@@ -220,4 +210,4 @@
|
|
|
220
210
|
<slot></slot>
|
|
221
211
|
</div>
|
|
222
212
|
</section>
|
|
223
|
-
`),this._panel=this.root.querySelector(".panel"),this._toolbarSlot=this.root.querySelector('slot[name="toolbar"]'),this._defaultSlot=this.root.querySelector("slot:not([name])"),(t=this._panel)==null||t.removeEventListener("keydown",this._onPanelKeyDownBound),(e=this._panel)==null||e.addEventListener("keydown",this._onPanelKeyDownBound),(o=this._toolbarSlot)==null||o.removeEventListener("slotchange",this._onSlotChangeBound),(n=this._defaultSlot)==null||n.removeEventListener("slotchange",this._onSlotChangeBound),(r=this._toolbarSlot)==null||r.addEventListener("slotchange",this._onSlotChangeBound),(s=this._defaultSlot)==null||s.addEventListener("slotchange",this._onSlotChangeBound),this._syncPanelA11y(),this._syncRowVisibility(),this._refreshObservers(),this._schedulePosition()}}typeof customElements<"u"&&!customElements.get("ui-floating-toolbar")&&customElements.define("ui-floating-toolbar",
|
|
213
|
+
`),this._panel=this.root.querySelector(".panel"),this._toolbarSlot=this.root.querySelector('slot[name="toolbar"]'),this._defaultSlot=this.root.querySelector("slot:not([name])"),(t=this._panel)==null||t.removeEventListener("keydown",this._onPanelKeyDownBound),(e=this._panel)==null||e.addEventListener("keydown",this._onPanelKeyDownBound),(o=this._toolbarSlot)==null||o.removeEventListener("slotchange",this._onSlotChangeBound),(n=this._defaultSlot)==null||n.removeEventListener("slotchange",this._onSlotChangeBound),(r=this._toolbarSlot)==null||r.addEventListener("slotchange",this._onSlotChangeBound),(s=this._defaultSlot)==null||s.addEventListener("slotchange",this._onSlotChangeBound),this._syncPanelA11y(),this._syncRowVisibility(),this._refreshObservers(),this._schedulePosition()}}typeof customElements<"u"&&!customElements.get("ui-floating-toolbar")&&customElements.define("ui-floating-toolbar",d);exports.UIFloatingToolbar=d;
|