@editora/ui-core 0.1.19 → 0.1.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{ElementBase-1b301e7f.js → ElementBase-EV6mVBUV.js} +1 -1
- package/dist/{ElementBase-909688f3.mjs → ElementBase-YlTLMsGk.mjs} +3 -3
- package/dist/accordion.cjs.js +3 -3
- package/dist/accordion.esm.js +39 -62
- package/dist/alert-dialog.cjs.js +19 -19
- package/dist/alert-dialog.esm.js +69 -87
- package/dist/alert.cjs.js +1 -1
- package/dist/alert.esm.js +4 -7
- package/dist/anchor.cjs.js +2 -2
- package/dist/anchor.esm.js +3 -3
- package/dist/animated-beam.cjs.js +83 -83
- package/dist/animated-beam.esm.js +250 -277
- package/dist/animated-list.cjs.js +4 -4
- package/dist/animated-list.esm.js +47 -61
- package/dist/animated-text.cjs.js +2 -2
- package/dist/animated-text.esm.js +13 -24
- package/dist/app-header.cjs.js +3 -3
- package/dist/app-header.esm.js +11 -13
- package/dist/aspect-ratio.cjs.js +1 -1
- package/dist/aspect-ratio.esm.js +4 -7
- package/dist/avatar.cjs.js +1 -1
- package/dist/avatar.esm.js +7 -13
- package/dist/badge.cjs.js +1 -1
- package/dist/badge.esm.js +4 -7
- package/dist/block-controls.cjs.js +2 -2
- package/dist/block-controls.esm.js +19 -35
- package/dist/box.cjs.js +1 -1
- package/dist/box.esm.js +8 -15
- package/dist/breadcrumb.cjs.js +2 -2
- package/dist/breadcrumb.esm.js +20 -37
- package/dist/button.cjs.js +1 -521
- package/dist/button.esm.js +2 -671
- package/dist/{calendar-2c11b824.mjs → calendar-DLY4acgn.mjs} +293 -342
- package/dist/{calendar-a8735e40.js → calendar-Dkof-FTK.js} +25 -25
- package/dist/calendar.cjs.js +1 -1
- package/dist/calendar.esm.js +8 -9
- package/dist/card.cjs.js +4 -4
- package/dist/card.esm.js +13 -19
- package/dist/chart.cjs.js +64 -64
- package/dist/chart.esm.js +223 -254
- package/dist/checkbox.cjs.js +1 -1
- package/dist/checkbox.esm.js +2 -3
- package/dist/collapsible.cjs.js +1 -1
- package/dist/collapsible.esm.js +5 -9
- package/dist/{collection-a1aac0c6.mjs → collection-C7URGjEI.mjs} +8 -14
- package/dist/collection.cjs.js +1 -1
- package/dist/collection.esm.js +4 -7
- package/dist/color-picker.cjs.js +9 -9
- package/dist/color-picker.esm.js +189 -252
- package/dist/combobox.cjs.js +13 -13
- package/dist/combobox.esm.js +93 -126
- package/dist/command-palette.cjs.js +3 -3
- package/dist/command-palette.esm.js +19 -30
- package/dist/command.cjs.js +4 -4
- package/dist/command.esm.js +41 -53
- package/dist/components/ui-orbiter.d.ts.map +1 -1
- package/dist/components/ui-skeleton.d.ts.map +1 -1
- package/dist/components/ui-split-button.d.ts +1 -0
- package/dist/components/ui-split-button.d.ts.map +1 -1
- package/dist/components/ui-time-picker.d.ts.map +1 -1
- package/dist/container.cjs.js +2 -2
- package/dist/container.esm.js +2 -3
- package/dist/context-menu.cjs.js +8 -8
- package/dist/context-menu.esm.js +157 -219
- package/dist/control-group.cjs.js +1 -1
- package/dist/control-group.esm.js +2 -3
- package/dist/data-table.cjs.js +4 -4
- package/dist/data-table.esm.js +299 -381
- package/dist/date-field.cjs.js +3 -3
- package/dist/date-field.esm.js +68 -80
- package/dist/date-picker.cjs.js +9 -9
- package/dist/date-picker.esm.js +69 -97
- package/dist/date-range-picker.cjs.js +3 -3
- package/dist/date-range-picker.esm.js +32 -56
- package/dist/date-range-time-picker.cjs.js +9 -9
- package/dist/date-range-time-picker.esm.js +111 -140
- package/dist/date-time-picker.cjs.js +4 -4
- package/dist/date-time-picker.esm.js +112 -144
- package/dist/date-time-utils-Dmost5Ee.js +1 -0
- package/dist/date-time-utils-y1N2gvG2.mjs +268 -0
- package/dist/description.cjs.js +1 -1
- package/dist/description.esm.js +3 -5
- package/dist/dialog.cjs.js +12 -12
- package/dist/dialog.esm.js +44 -63
- package/dist/direction-provider.cjs.js +1 -1
- package/dist/direction-provider.esm.js +2 -3
- package/dist/{dismissable-layer-9c7e6b58.mjs → dismissable-layer-BmPIoK80.mjs} +29 -33
- package/dist/dismissable-layer-DNfrKA20.js +1 -0
- package/dist/dismissable-layer.cjs.js +2 -2
- package/dist/dismissable-layer.esm.js +4 -6
- package/dist/dock.cjs.js +5 -5
- package/dist/dock.esm.js +134 -155
- package/dist/drawer.cjs.js +2 -2
- package/dist/drawer.esm.js +18 -35
- package/dist/dropdown.cjs.js +2 -2
- package/dist/dropdown.esm.js +119 -149
- package/dist/dropzone.cjs.js +1 -1
- package/dist/dropzone.esm.js +0 -1
- package/dist/empty-state.cjs.js +1 -1
- package/dist/empty-state.esm.js +1 -1
- package/dist/field-error.cjs.js +1 -1
- package/dist/field-error.esm.js +3 -5
- package/dist/field.cjs.js +5 -5
- package/dist/field.esm.js +27 -34
- package/dist/fieldset.cjs.js +4 -4
- package/dist/fieldset.esm.js +19 -24
- package/dist/file-upload.cjs.js +4 -4
- package/dist/file-upload.esm.js +69 -93
- package/dist/flex.cjs.js +1 -1
- package/dist/flex.esm.js +5 -9
- package/dist/floating-toolbar.cjs.js +4 -4
- package/dist/floating-toolbar.esm.js +60 -85
- package/dist/focus-scope-Bwug2gDv.js +1 -0
- package/dist/{focus-scope-103833ee.mjs → focus-scope-CmEsG5UZ.mjs} +39 -48
- package/dist/focus-scope.cjs.js +2 -2
- package/dist/focus-scope.esm.js +15 -20
- package/dist/form.cjs.js +2 -2
- package/dist/form.esm.js +26 -53
- package/dist/gantt.cjs.js +43 -43
- package/dist/gantt.esm.js +295 -322
- package/dist/grid.cjs.js +1 -1
- package/dist/grid.esm.js +5 -9
- package/dist/hover-card.cjs.js +4 -4
- package/dist/hover-card.esm.js +22 -28
- package/dist/icon-cloud.cjs.js +7 -7
- package/dist/icon-cloud.esm.js +48 -62
- package/dist/icon.cjs.js +1 -1
- package/dist/icon.esm.js +2 -4
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +378 -390
- package/dist/inline-edit.cjs.js +11 -11
- package/dist/inline-edit.esm.js +32 -36
- package/dist/input.cjs.js +17 -17
- package/dist/input.esm.js +50 -63
- package/dist/label.cjs.js +2 -2
- package/dist/label.esm.js +8 -17
- package/dist/layout.cjs.js +2 -2
- package/dist/layout.esm.js +20 -26
- package/dist/listbox-B6QgECax.js +46 -0
- package/dist/listbox-DJamVeFj.mjs +200 -0
- package/dist/listbox.cjs.js +1 -1
- package/dist/listbox.esm.js +2 -4
- package/dist/marquee.cjs.js +5 -5
- package/dist/marquee.esm.js +33 -50
- package/dist/masonry-grid.cjs.js +1 -1
- package/dist/masonry-grid.esm.js +5 -9
- package/dist/menu.cjs.js +3 -3
- package/dist/menu.esm.js +106 -126
- package/dist/menubar.cjs.js +5 -5
- package/dist/menubar.esm.js +118 -164
- package/dist/meter.cjs.js +2 -2
- package/dist/meter.esm.js +4 -4
- package/dist/multi-select.cjs.js +4 -4
- package/dist/multi-select.esm.js +120 -140
- package/dist/navigation-menu.cjs.js +4 -4
- package/dist/navigation-menu.esm.js +44 -55
- package/dist/number-field.cjs.js +2 -2
- package/dist/number-field.esm.js +73 -98
- package/dist/number-ticker.cjs.js +3 -3
- package/dist/number-ticker.esm.js +22 -43
- package/dist/odometer.cjs.js +1 -1
- package/dist/odometer.esm.js +5 -9
- package/dist/orbiter.cjs.js +13 -13
- package/dist/orbiter.esm.js +79 -90
- package/dist/{overlayManager-5bbd4dc3.mjs → overlayManager-BJjU1VA8.mjs} +4 -5
- package/dist/{overlayManager-0eda4e08.js → overlayManager-CSy3fJmJ.js} +1 -1
- package/dist/pagination.cjs.js +2 -2
- package/dist/pagination.esm.js +14 -18
- package/dist/{panel-group-a376cc5e.mjs → panel-group-8sVNnGxg.mjs} +24 -46
- package/dist/panel-group-CaD0_KQf.js +36 -0
- package/dist/panel-group.cjs.js +1 -1
- package/dist/panel-group.esm.js +2 -5
- package/dist/panel.cjs.js +4 -4
- package/dist/panel.esm.js +8 -10
- package/dist/password-field.cjs.js +9 -9
- package/dist/password-field.esm.js +62 -82
- package/dist/pin-input.cjs.js +3 -3
- package/dist/pin-input.esm.js +33 -39
- package/dist/placement-grid.cjs.js +4 -4
- package/dist/placement-grid.esm.js +108 -131
- package/dist/plugin-panel.cjs.js +7 -7
- package/dist/plugin-panel.esm.js +13 -15
- package/dist/popover.cjs.js +2 -2
- package/dist/popover.esm.js +21 -31
- package/dist/portal-DgpQ3Jo1.js +1 -0
- package/dist/{portal-fe73e5cc.mjs → portal-bR42gHvG.mjs} +43 -48
- package/dist/portal.cjs.js +2 -2
- package/dist/portal.esm.js +10 -19
- package/dist/{positioner-e9770c66.mjs → positioner-D0VGxtYU.mjs} +189 -209
- package/dist/positioner-D_fqyx_j.js +1 -0
- package/dist/positioner.cjs.js +2 -2
- package/dist/positioner.esm.js +11 -18
- package/dist/presence.cjs.js +1 -1
- package/dist/presence.esm.js +7 -13
- package/dist/progress.cjs.js +1 -1
- package/dist/progress.esm.js +5 -9
- package/dist/quick-actions.cjs.js +6 -6
- package/dist/quick-actions.esm.js +52 -62
- package/dist/radio-group.cjs.js +13 -13
- package/dist/radio-group.esm.js +39 -51
- package/dist/radio.cjs.js +1 -1
- package/dist/radio.esm.js +5 -9
- package/dist/rating.cjs.js +1 -1
- package/dist/rating.esm.js +12 -23
- package/dist/{roving-focus-group-4350c9a7.mjs → roving-focus-group-Dbm1Jko_.mjs} +3 -6
- package/dist/roving-focus-group.cjs.js +1 -1
- package/dist/roving-focus-group.esm.js +3 -5
- package/dist/runtime-CTaOSmBj.js +1 -0
- package/dist/{runtime-161f68a2.mjs → runtime-D1gFh1fS.mjs} +338 -366
- package/dist/runtime.cjs.js +1 -1
- package/dist/runtime.esm.js +6 -6
- package/dist/scroll-area.cjs.js +3 -3
- package/dist/scroll-area.esm.js +38 -46
- package/dist/{scroll-lock-31da444f.mjs → scroll-lock-LfqXXqsu.mjs} +5 -9
- package/dist/section.cjs.js +1 -1
- package/dist/section.esm.js +1 -1
- package/dist/select.cjs.js +7 -7
- package/dist/select.esm.js +67 -97
- package/dist/selection-popup.cjs.js +1 -1
- package/dist/selection-popup.esm.js +8 -15
- package/dist/separator.cjs.js +1 -1
- package/dist/separator.esm.js +1 -1
- package/dist/sidebar.cjs.js +18 -18
- package/dist/sidebar.esm.js +117 -139
- package/dist/skeleton.cjs.js +11 -11
- package/dist/skeleton.esm.js +27 -24
- package/dist/slider.cjs.js +1 -1
- package/dist/slider.esm.js +6 -11
- package/dist/slot.cjs.js +4 -4
- package/dist/slot.esm.js +16 -19
- package/dist/sortable.cjs.js +45 -45
- package/dist/sortable.esm.js +421 -524
- package/dist/spinning-text.cjs.js +12 -12
- package/dist/spinning-text.esm.js +80 -92
- package/dist/split-button.cjs.js +4 -4
- package/dist/split-button.esm.js +77 -62
- package/dist/splitter.cjs.js +1 -1
- package/dist/splitter.esm.js +1 -1
- package/dist/stepper.cjs.js +8 -8
- package/dist/stepper.esm.js +32 -52
- package/dist/switch.cjs.js +7 -7
- package/dist/switch.esm.js +23 -31
- package/dist/table.cjs.js +2 -2
- package/dist/table.esm.js +46 -56
- package/dist/tabs.cjs.js +3 -3
- package/dist/tabs.esm.js +35 -55
- package/dist/tags-input.cjs.js +4 -4
- package/dist/tags-input.esm.js +45 -62
- package/dist/textarea.cjs.js +6 -6
- package/dist/textarea.esm.js +32 -41
- package/dist/time-field.cjs.js +4 -4
- package/dist/time-field.esm.js +70 -84
- package/dist/time-picker.cjs.js +22 -22
- package/dist/time-picker.esm.js +88 -110
- package/dist/timeline.cjs.js +1 -1
- package/dist/timeline.esm.js +3 -5
- package/dist/toast.cjs.js +2 -2
- package/dist/toast.esm.js +33 -47
- package/dist/toggle-group.cjs.js +6 -6
- package/dist/toggle-group.esm.js +85 -105
- package/dist/toggle.cjs.js +1 -1
- package/dist/toggle.esm.js +3 -5
- package/dist/toolbar.cjs.js +1 -1
- package/dist/toolbar.esm.js +13 -24
- package/dist/tooltip.cjs.js +2 -2
- package/dist/tooltip.esm.js +31 -42
- package/dist/transfer-list.cjs.js +19 -19
- package/dist/transfer-list.esm.js +98 -111
- package/dist/{tree-dcd74a4a.mjs → tree-B3kE8ESs.mjs} +55 -62
- package/dist/tree-Dx_kv_ih.js +39 -0
- package/dist/tree-item.cjs.js +2 -2
- package/dist/tree-item.esm.js +2 -3
- package/dist/tree.cjs.js +1 -1
- package/dist/tree.esm.js +2 -5
- package/dist/ui-button-Q0GNNWKC.mjs +665 -0
- package/dist/ui-button-rXQOS9QJ.js +521 -0
- package/dist/{icon-9e9da03b.js → ui-icon-BzVNC_lr.js} +4 -4
- package/dist/{icon-e2a85cc1.mjs → ui-icon-YI6lyuqU.mjs} +58 -65
- package/dist/visually-hidden.cjs.js +1 -1
- package/dist/visually-hidden.esm.js +1 -1
- package/dist/wizard.cjs.js +14 -14
- package/dist/wizard.esm.js +85 -105
- package/package.json +2 -2
- package/dist/date-time-utils-66480de4.js +0 -1
- package/dist/date-time-utils-a2c7af25.mjs +0 -307
- package/dist/dismissable-layer-193e3bed.js +0 -1
- package/dist/focus-scope-2b12b4e7.js +0 -1
- package/dist/listbox-308789a0.mjs +0 -210
- package/dist/listbox-ef2f708e.js +0 -46
- package/dist/panel-group-40254cdd.js +0 -36
- package/dist/portal-c69756c0.js +0 -1
- package/dist/positioner-33529bb8.js +0 -1
- package/dist/runtime-3f13807b.js +0 -1
- package/dist/tree-0a7a8d05.js +0 -39
- /package/dist/{collection-a2969ad2.js → collection-qv8A8rq4.js} +0 -0
- /package/dist/{menu-item-styles-27fdbac4.mjs → menu-item-styles-CZiPwPwl.mjs} +0 -0
- /package/dist/{menu-item-styles-83ad1e22.js → menu-item-styles-CbNUEwP2.js} +0 -0
- /package/dist/{roving-focus-group-5c059bf9.js → roving-focus-group-BdJ_4Njm.js} +0 -0
- /package/dist/{scroll-lock-d7b0df21.js → scroll-lock-BX6e3Ced.js} +0 -0
package/dist/menu.esm.js
CHANGED
|
@@ -1,25 +1,24 @@
|
|
|
1
|
-
import { E as _ } from "./ElementBase-
|
|
2
|
-
import {
|
|
3
|
-
import { c as y } from "./dismissable-layer-
|
|
4
|
-
import {
|
|
5
|
-
import { c as A } from "./menu-item-styles-
|
|
6
|
-
function g(
|
|
7
|
-
return
|
|
1
|
+
import { E as _ } from "./ElementBase-YlTLMsGk.mjs";
|
|
2
|
+
import { b as v } from "./portal-bR42gHvG.mjs";
|
|
3
|
+
import { c as y } from "./dismissable-layer-BmPIoK80.mjs";
|
|
4
|
+
import { e as x } from "./positioner-D0VGxtYU.mjs";
|
|
5
|
+
import { c as A } from "./menu-item-styles-CZiPwPwl.mjs";
|
|
6
|
+
function g(r) {
|
|
7
|
+
return r === "top" || r === "left" || r === "right" ? r : "bottom";
|
|
8
8
|
}
|
|
9
|
-
function E(
|
|
10
|
-
return
|
|
9
|
+
function E(r) {
|
|
10
|
+
return r === "sm" || r === "1" || r === "compact" ? "sm" : r === "lg" || r === "3" || r === "comfortable" ? "lg" : "md";
|
|
11
11
|
}
|
|
12
|
-
function k(
|
|
13
|
-
return !
|
|
12
|
+
function k(r) {
|
|
13
|
+
return !r || r === "default" ? null : r === "none" ? "0px" : r === "sm" ? "8px" : r === "md" ? "12px" : r === "lg" ? "16px" : r === "full" ? "999px" : r === "square" ? "6px" : r === "soft" ? "14px" : /^\d+(\.\d+)?$/.test(r) ? `${r}px` : /^\d+(\.\d+)?(px|rem|em|%)$/.test(r) ? r : null;
|
|
14
14
|
}
|
|
15
|
-
function l(
|
|
16
|
-
return
|
|
15
|
+
function l(r, e) {
|
|
16
|
+
return r.getAttribute(e) || "";
|
|
17
17
|
}
|
|
18
|
-
function h(
|
|
19
|
-
if (
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
return i !== "false" && i !== "0";
|
|
18
|
+
function h(r, e) {
|
|
19
|
+
if (r == null) return e;
|
|
20
|
+
const t = String(r).toLowerCase();
|
|
21
|
+
return t !== "false" && t !== "0";
|
|
23
22
|
}
|
|
24
23
|
function u() {
|
|
25
24
|
return [
|
|
@@ -30,16 +29,16 @@ function u() {
|
|
|
30
29
|
"[data-menu-item]"
|
|
31
30
|
].join(", ");
|
|
32
31
|
}
|
|
33
|
-
function m(
|
|
34
|
-
return
|
|
32
|
+
function m(r) {
|
|
33
|
+
return r.hasAttribute("disabled") || r.getAttribute("aria-disabled") === "true" || !!r.disabled;
|
|
35
34
|
}
|
|
36
|
-
function p(
|
|
37
|
-
const e = typeof
|
|
38
|
-
for (const
|
|
39
|
-
if (
|
|
40
|
-
return
|
|
41
|
-
const
|
|
42
|
-
return
|
|
35
|
+
function p(r) {
|
|
36
|
+
const e = typeof r.composedPath == "function" ? r.composedPath() : [];
|
|
37
|
+
for (const i of e)
|
|
38
|
+
if (i instanceof HTMLElement && i.matches(u()))
|
|
39
|
+
return i;
|
|
40
|
+
const t = r.target;
|
|
41
|
+
return t instanceof HTMLElement ? t.closest(u()) : null;
|
|
43
42
|
}
|
|
44
43
|
const w = /* @__PURE__ */ new Set(["variant", "density", "shape", "elevation", "tone", "size", "radius"]), S = [
|
|
45
44
|
"--ui-menu-bg",
|
|
@@ -366,8 +365,8 @@ class T extends _ {
|
|
|
366
365
|
disconnectedCallback() {
|
|
367
366
|
this.removeEventListener("click", this._onHostClick), this.root.removeEventListener("slotchange", this._onSlotChange), this._unbindGlobalListeners(), this._teardownPortal(), super.disconnectedCallback();
|
|
368
367
|
}
|
|
369
|
-
attributeChangedCallback(e,
|
|
370
|
-
if (
|
|
368
|
+
attributeChangedCallback(e, t, i) {
|
|
369
|
+
if (t !== i) {
|
|
371
370
|
if (e === "open") {
|
|
372
371
|
this._syncOpenState();
|
|
373
372
|
return;
|
|
@@ -435,10 +434,9 @@ class T extends _ {
|
|
|
435
434
|
}
|
|
436
435
|
}
|
|
437
436
|
_syncOpenState() {
|
|
438
|
-
var t;
|
|
439
437
|
const e = this.hasAttribute("open") && !this.hasAttribute("disabled");
|
|
440
438
|
if (e === this._isOpen) {
|
|
441
|
-
this._syncTriggerA11y(), e && !this._portalEl ? this._mountPortal() : e &&
|
|
439
|
+
this._syncTriggerA11y(), e && !this._portalEl ? this._mountPortal() : e && this._positioner?.update();
|
|
442
440
|
return;
|
|
443
441
|
}
|
|
444
442
|
if (this._isOpen = e, this._syncTriggerA11y(), e) {
|
|
@@ -446,12 +444,12 @@ class T extends _ {
|
|
|
446
444
|
return;
|
|
447
445
|
}
|
|
448
446
|
this._unbindGlobalListeners(), this._teardownPortal(), this.dispatchEvent(new CustomEvent("close", { bubbles: !0 })), this.dispatchEvent(new CustomEvent("change", { bubbles: !0, detail: { open: !1 } }));
|
|
449
|
-
const
|
|
450
|
-
if (
|
|
447
|
+
const t = this._getTrigger();
|
|
448
|
+
if (t)
|
|
451
449
|
try {
|
|
452
|
-
|
|
450
|
+
t.focus({ preventScroll: !0 });
|
|
453
451
|
} catch {
|
|
454
|
-
|
|
452
|
+
t.focus();
|
|
455
453
|
}
|
|
456
454
|
this._restoreFocusEl = null;
|
|
457
455
|
}
|
|
@@ -486,11 +484,10 @@ class T extends _ {
|
|
|
486
484
|
this._focusItem(e[e.length - 1] || null);
|
|
487
485
|
}
|
|
488
486
|
_moveFocus(e) {
|
|
489
|
-
const
|
|
490
|
-
if (!
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
this._focusItem(i[a] || null);
|
|
487
|
+
const t = this._queryItems();
|
|
488
|
+
if (!t.length) return;
|
|
489
|
+
const i = document.activeElement, n = i ? t.findIndex((o) => o === i || o.contains(i)) : -1, a = n === -1 ? 0 : Math.max(0, Math.min(t.length - 1, n + e));
|
|
490
|
+
this._focusItem(t[a] || null);
|
|
494
491
|
}
|
|
495
492
|
_resetTypeahead() {
|
|
496
493
|
this._typeaheadBuffer = "", this._typeaheadTimer != null && (window.clearTimeout(this._typeaheadTimer), this._typeaheadTimer = null);
|
|
@@ -499,41 +496,37 @@ class T extends _ {
|
|
|
499
496
|
return e.ctrlKey || e.metaKey || e.altKey ? !1 : e.key.length === 1 && /\S/.test(e.key);
|
|
500
497
|
}
|
|
501
498
|
_handleTypeahead(e) {
|
|
502
|
-
if (!this.typeahead || !this._isTypeaheadKey(e))
|
|
503
|
-
return !1;
|
|
499
|
+
if (!this.typeahead || !this._isTypeaheadKey(e)) return !1;
|
|
504
500
|
this._typeaheadBuffer = `${this._typeaheadBuffer}${e.key.toLowerCase()}`.slice(0, 24), this._typeaheadTimer != null && window.clearTimeout(this._typeaheadTimer), this._typeaheadTimer = window.setTimeout(() => this._resetTypeahead(), 420);
|
|
505
|
-
const
|
|
506
|
-
if (!
|
|
507
|
-
|
|
508
|
-
const r = i ? t.findIndex((s) => s === i || s.contains(i)) : -1, o = (r >= 0 ? [...t.slice(r + 1), ...t.slice(0, r + 1)] : t).find((s) => (s.textContent || "").trim().toLowerCase().startsWith(this._typeaheadBuffer));
|
|
501
|
+
const t = document.activeElement, i = this._queryItems();
|
|
502
|
+
if (!i.length) return !1;
|
|
503
|
+
const n = t ? i.findIndex((s) => s === t || s.contains(t)) : -1, o = (n >= 0 ? [...i.slice(n + 1), ...i.slice(0, n + 1)] : i).find((s) => (s.textContent || "").trim().toLowerCase().startsWith(this._typeaheadBuffer));
|
|
509
504
|
return o ? (e.preventDefault(), this._focusItem(o), !0) : !1;
|
|
510
505
|
}
|
|
511
506
|
_applySelectionBehavior(e) {
|
|
512
|
-
const
|
|
513
|
-
if (
|
|
514
|
-
const
|
|
515
|
-
e.setAttribute("aria-checked",
|
|
507
|
+
const t = e.getAttribute("role");
|
|
508
|
+
if (t === "menuitemcheckbox") {
|
|
509
|
+
const n = e.getAttribute("aria-checked") === "true";
|
|
510
|
+
e.setAttribute("aria-checked", n ? "false" : "true"), e.setAttribute("data-state", n ? "unchecked" : "checked");
|
|
516
511
|
return;
|
|
517
512
|
}
|
|
518
|
-
if (
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
t && a !== t || (r.setAttribute("aria-checked", r === e ? "true" : "false"), r.setAttribute("data-state", r === e ? "checked" : "unchecked"));
|
|
513
|
+
if (t !== "menuitemradio" || !this._portalEl) return;
|
|
514
|
+
const i = e.getAttribute("data-group") || e.getAttribute("name") || "";
|
|
515
|
+
this._portalEl.querySelectorAll('[role="menuitemradio"]').forEach((n) => {
|
|
516
|
+
const a = n.getAttribute("data-group") || n.getAttribute("name") || "";
|
|
517
|
+
i && a !== i || (n.setAttribute("aria-checked", n === e ? "true" : "false"), n.setAttribute("data-state", n === e ? "checked" : "unchecked"));
|
|
524
518
|
});
|
|
525
519
|
}
|
|
526
520
|
_handleItemSelect(e) {
|
|
527
|
-
var r;
|
|
528
521
|
this._applySelectionBehavior(e);
|
|
529
|
-
const
|
|
522
|
+
const t = e.getAttribute("data-index"), i = t != null && !Number.isNaN(Number(t)) ? Number(t) : void 0;
|
|
530
523
|
this.dispatchEvent(
|
|
531
524
|
new CustomEvent("select", {
|
|
532
525
|
bubbles: !0,
|
|
533
526
|
detail: {
|
|
534
|
-
index:
|
|
527
|
+
index: i,
|
|
535
528
|
value: e.getAttribute("data-value") || e.getAttribute("value") || void 0,
|
|
536
|
-
label: e.getAttribute("aria-label") ||
|
|
529
|
+
label: e.getAttribute("aria-label") || e.textContent?.trim() || void 0,
|
|
537
530
|
checked: e.getAttribute("aria-checked") === "true",
|
|
538
531
|
item: e
|
|
539
532
|
}
|
|
@@ -541,28 +534,28 @@ class T extends _ {
|
|
|
541
534
|
), this.closeOnSelect ? this.close() : this._focusItem(e);
|
|
542
535
|
}
|
|
543
536
|
_buildLegacyItems(e) {
|
|
544
|
-
const
|
|
545
|
-
return
|
|
546
|
-
const a =
|
|
547
|
-
a.removeAttribute("slot"), a.getAttribute("role") || a.setAttribute("role", "menuitem"), a.classList.contains("item") || a.classList.add("item"), a.hasAttribute("tabindex") || a.setAttribute("tabindex", "-1"), a.hasAttribute("data-index") || a.setAttribute("data-index", String(
|
|
548
|
-
}),
|
|
537
|
+
const t = this._getItemSources();
|
|
538
|
+
return t.forEach((i, n) => {
|
|
539
|
+
const a = i.cloneNode(!0);
|
|
540
|
+
a.removeAttribute("slot"), a.getAttribute("role") || a.setAttribute("role", "menuitem"), a.classList.contains("item") || a.classList.add("item"), a.hasAttribute("tabindex") || a.setAttribute("tabindex", "-1"), a.hasAttribute("data-index") || a.setAttribute("data-index", String(n)), e.appendChild(a);
|
|
541
|
+
}), t.length;
|
|
549
542
|
}
|
|
550
543
|
_hydrateMenuItems(e) {
|
|
551
|
-
const
|
|
552
|
-
return
|
|
553
|
-
|
|
554
|
-
}),
|
|
544
|
+
const t = Array.from(e.querySelectorAll(u()));
|
|
545
|
+
return t.forEach((i, n) => {
|
|
546
|
+
i.getAttribute("role") || i.setAttribute("role", "menuitem"), i.hasAttribute("tabindex") || i.setAttribute("tabindex", "-1"), i.classList.contains("item") || i.classList.add("item"), i.hasAttribute("data-index") || i.setAttribute("data-index", String(n));
|
|
547
|
+
}), t.length;
|
|
555
548
|
}
|
|
556
549
|
_applyPortalTokens(e) {
|
|
557
|
-
const
|
|
558
|
-
S.forEach((
|
|
559
|
-
const
|
|
560
|
-
|
|
550
|
+
const t = window.getComputedStyle(this);
|
|
551
|
+
S.forEach((i) => {
|
|
552
|
+
const n = t.getPropertyValue(i).trim();
|
|
553
|
+
n ? e.style.setProperty(i, n) : e.style.removeProperty(i);
|
|
561
554
|
});
|
|
562
555
|
}
|
|
563
556
|
_applyPortalVariantData(e) {
|
|
564
|
-
const
|
|
565
|
-
f ? e.setAttribute("data-variant", f) : e.removeAttribute("data-variant"),
|
|
557
|
+
const t = l(this, "variant"), i = E(this.getAttribute("size") || this.getAttribute("density")), n = l(this, "density"), a = this.getAttribute("radius"), o = l(this, "shape"), s = l(this, "elevation"), c = l(this, "tone"), f = t === "default" || t === "" ? "" : t === "line" ? "outline" : t === "glass" ? "soft" : t;
|
|
558
|
+
f ? e.setAttribute("data-variant", f) : e.removeAttribute("data-variant"), i !== "md" ? e.setAttribute("data-size", i) : e.removeAttribute("data-size"), n && n !== "default" ? e.setAttribute("data-density", n) : e.removeAttribute("data-density"), s && s !== "default" ? e.setAttribute("data-elevation", s) : e.removeAttribute("data-elevation");
|
|
566
559
|
const b = c === "default" || c === "brand" || c === "" ? "" : c;
|
|
567
560
|
b ? e.setAttribute("data-tone", b) : e.removeAttribute("data-tone");
|
|
568
561
|
const d = k(a || o || null);
|
|
@@ -572,48 +565,45 @@ class T extends _ {
|
|
|
572
565
|
this._portalEl && (this._applyPortalTokens(this._portalEl), this._applyPortalVariantData(this._portalEl), this._portalEl.setAttribute("aria-hidden", "false"), this._portalEl.setAttribute("aria-busy", "false"), this._portalEl.style.display = "block", this._portalEl.style.visibility = "visible", this._portalEl.style.opacity = "1", this._portalEl.style.transform = "translateY(0px) scale(1)", this._portalEl.style.pointerEvents = "auto");
|
|
573
566
|
}
|
|
574
567
|
_attachMenuEvents(e) {
|
|
575
|
-
this._menuClickHandler = (
|
|
576
|
-
const
|
|
577
|
-
!
|
|
578
|
-
}, e.addEventListener("click", this._menuClickHandler), e.addEventListener("mouseover", (
|
|
579
|
-
const
|
|
580
|
-
!
|
|
581
|
-
}), e.addEventListener("focusin", (
|
|
582
|
-
const
|
|
583
|
-
!
|
|
568
|
+
this._menuClickHandler = (t) => {
|
|
569
|
+
const i = p(t);
|
|
570
|
+
!i || m(i) || this._handleItemSelect(i);
|
|
571
|
+
}, e.addEventListener("click", this._menuClickHandler), e.addEventListener("mouseover", (t) => {
|
|
572
|
+
const i = p(t);
|
|
573
|
+
!i || m(i) || this._focusItem(i);
|
|
574
|
+
}), e.addEventListener("focusin", (t) => {
|
|
575
|
+
const i = p(t);
|
|
576
|
+
!i || m(i) || this._focusItem(i);
|
|
584
577
|
}), e.addEventListener("mouseleave", () => this._clearActiveState());
|
|
585
578
|
}
|
|
586
579
|
_buildPortalElement() {
|
|
587
580
|
const e = document.createElement("div");
|
|
588
581
|
e.className = "surface menu", e.id = this._menuId, e.setAttribute("part", "menu"), e.setAttribute("role", "menu"), e.setAttribute("tabindex", "-1"), e.setAttribute("aria-hidden", "false"), e.setAttribute("aria-busy", "false"), e.setAttribute("data-placement", g(this.getAttribute("placement")));
|
|
589
|
-
const
|
|
590
|
-
|
|
591
|
-
const
|
|
592
|
-
let
|
|
593
|
-
if (
|
|
594
|
-
const a =
|
|
582
|
+
const t = document.createElement("style");
|
|
583
|
+
t.textContent = C, e.appendChild(t);
|
|
584
|
+
const i = this._getContentSource();
|
|
585
|
+
let n = 0;
|
|
586
|
+
if (i) {
|
|
587
|
+
const a = i.cloneNode(!0);
|
|
595
588
|
a.removeAttribute("slot"), e.appendChild(a);
|
|
596
589
|
} else
|
|
597
|
-
|
|
598
|
-
if (
|
|
590
|
+
n = this._buildLegacyItems(e);
|
|
591
|
+
if (n = this._hydrateMenuItems(e) || n, n === 0) {
|
|
599
592
|
const a = document.createElement("div");
|
|
600
593
|
a.className = "empty-state", a.textContent = "No items", e.appendChild(a);
|
|
601
594
|
}
|
|
602
595
|
return this._applyPortalTokens(e), this._applyPortalVariantData(e), e.style.display = "block", e.style.visibility = "visible", e.style.opacity = "1", e.style.transform = "translateY(0px) scale(1)", e.style.pointerEvents = "auto", this._attachMenuEvents(e), e;
|
|
603
596
|
}
|
|
604
597
|
_rebuildPortalContent() {
|
|
605
|
-
if (!this._portalEl)
|
|
606
|
-
return;
|
|
598
|
+
if (!this._portalEl) return;
|
|
607
599
|
const e = this._portalEl.parentElement;
|
|
608
|
-
if (!e)
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
e.replaceChild(t, i), this._portalEl = t, this._rebuildPositioner();
|
|
600
|
+
if (!e) return;
|
|
601
|
+
const t = this._portalEl, i = this._buildPortalElement();
|
|
602
|
+
e.replaceChild(i, t), this._portalEl = i, this._rebuildPositioner();
|
|
612
603
|
}
|
|
613
604
|
_rebuildPositioner() {
|
|
614
|
-
var i;
|
|
615
605
|
const e = this._getTrigger();
|
|
616
|
-
!this._portalEl || !e || (
|
|
606
|
+
!this._portalEl || !e || (this._positioner?.destroy(), this._positioner = x({
|
|
617
607
|
anchor: e,
|
|
618
608
|
floating: this._portalEl,
|
|
619
609
|
placement: g(this.getAttribute("placement")),
|
|
@@ -625,7 +615,6 @@ class T extends _ {
|
|
|
625
615
|
}));
|
|
626
616
|
}
|
|
627
617
|
_mountPortal() {
|
|
628
|
-
var i;
|
|
629
618
|
const e = this._getTrigger();
|
|
630
619
|
if (e) {
|
|
631
620
|
if (this._portalEl)
|
|
@@ -639,7 +628,7 @@ class T extends _ {
|
|
|
639
628
|
}
|
|
640
629
|
t.appendChild(this._portalEl);
|
|
641
630
|
}
|
|
642
|
-
this._rebuildPositioner(),
|
|
631
|
+
this._rebuildPositioner(), this._dismissableLayer?.destroy(), this._dismissableLayer = y({
|
|
643
632
|
node: this._portalEl,
|
|
644
633
|
trigger: e,
|
|
645
634
|
closeOnEscape: !0,
|
|
@@ -649,8 +638,7 @@ class T extends _ {
|
|
|
649
638
|
}
|
|
650
639
|
}
|
|
651
640
|
_teardownPortal() {
|
|
652
|
-
|
|
653
|
-
if ((e = this._dismissableLayer) == null || e.destroy(), this._dismissableLayer = null, (i = this._positioner) == null || i.destroy(), this._positioner = null, (t = this._portalEl) != null && t.parentElement)
|
|
641
|
+
if (this._dismissableLayer?.destroy(), this._dismissableLayer = null, this._positioner?.destroy(), this._positioner = null, this._portalEl?.parentElement)
|
|
654
642
|
try {
|
|
655
643
|
this._portalEl.parentElement.removeChild(this._portalEl);
|
|
656
644
|
} catch {
|
|
@@ -658,22 +646,19 @@ class T extends _ {
|
|
|
658
646
|
this._portalEl = null, this._menuClickHandler = null, this._resetTypeahead();
|
|
659
647
|
}
|
|
660
648
|
_isEventInsideTrigger(e) {
|
|
661
|
-
const
|
|
662
|
-
return !!
|
|
649
|
+
const t = this._getTrigger();
|
|
650
|
+
return !!t && e.composedPath().includes(t);
|
|
663
651
|
}
|
|
664
652
|
_isEventInsideMenu(e) {
|
|
665
653
|
return !!this._portalEl && e.composedPath().includes(this._portalEl);
|
|
666
654
|
}
|
|
667
655
|
_isInternalScrollEvent(e) {
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
const
|
|
673
|
-
|
|
674
|
-
return !0;
|
|
675
|
-
const r = e.target;
|
|
676
|
-
return !!(r instanceof Node && ((a = this._portalEl) != null && a.contains(r) || t != null && t.contains(r)));
|
|
656
|
+
const t = typeof e.composedPath == "function" ? e.composedPath() : [];
|
|
657
|
+
if (this._portalEl && t.includes(this._portalEl)) return !0;
|
|
658
|
+
const i = this._getTrigger();
|
|
659
|
+
if (i && t.includes(i)) return !0;
|
|
660
|
+
const n = e.target;
|
|
661
|
+
return !!(n instanceof Node && (this._portalEl?.contains(n) || i?.contains(n)));
|
|
677
662
|
}
|
|
678
663
|
_onHostClick(e) {
|
|
679
664
|
this.hasAttribute("disabled") || this._isEventInsideTrigger(e) && (e.preventDefault(), this.toggle());
|
|
@@ -682,10 +667,8 @@ class T extends _ {
|
|
|
682
667
|
!this._isOpen || !this.closeOnScroll || this._isInternalScrollEvent(e) || this.close();
|
|
683
668
|
}
|
|
684
669
|
_onDocumentKeyDown(e) {
|
|
685
|
-
var i;
|
|
686
670
|
if (!this._isOpen) {
|
|
687
|
-
if (e.key !== "ArrowDown" && e.key !== "ArrowUp" || !this._isEventInsideTrigger(e))
|
|
688
|
-
return;
|
|
671
|
+
if (e.key !== "ArrowDown" && e.key !== "ArrowUp" || !this._isEventInsideTrigger(e)) return;
|
|
689
672
|
e.preventDefault(), this.open(), requestAnimationFrame(() => {
|
|
690
673
|
e.key === "ArrowUp" ? this._focusLastItem() : this._focusFirstItem();
|
|
691
674
|
});
|
|
@@ -718,17 +701,14 @@ class T extends _ {
|
|
|
718
701
|
}
|
|
719
702
|
if (e.key === "Enter" || e.key === " ") {
|
|
720
703
|
const t = document.activeElement;
|
|
721
|
-
if (!t || !
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
return;
|
|
726
|
-
e.preventDefault(), this._handleItemSelect(r);
|
|
704
|
+
if (!t || !this._portalEl?.contains(t)) return;
|
|
705
|
+
const i = t.closest(u());
|
|
706
|
+
if (!i || m(i)) return;
|
|
707
|
+
e.preventDefault(), this._handleItemSelect(i);
|
|
727
708
|
}
|
|
728
709
|
}
|
|
729
710
|
}
|
|
730
711
|
render() {
|
|
731
|
-
var e;
|
|
732
712
|
this.setContent(`
|
|
733
713
|
<style>${I}</style>
|
|
734
714
|
<div class="trigger" part="trigger">
|
|
@@ -739,7 +719,7 @@ class T extends _ {
|
|
|
739
719
|
<slot name="content"></slot>
|
|
740
720
|
</div>
|
|
741
721
|
<slot></slot>
|
|
742
|
-
`), this._syncTriggerA11y(), this._isOpen && !this._portalEl ? this._mountPortal() : this._isOpen &&
|
|
722
|
+
`), this._syncTriggerA11y(), this._isOpen && !this._portalEl ? this._mountPortal() : this._isOpen && this._positioner?.update();
|
|
743
723
|
}
|
|
744
724
|
shouldRenderOnAttributeChange() {
|
|
745
725
|
return !1;
|
package/dist/menubar.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const w=require("./ElementBase-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const w=require("./ElementBase-EV6mVBUV.js"),P=require("./portal-DgpQ3Jo1.js"),E=require("./collection-qv8A8rq4.js"),k=require("./dismissable-layer-DNfrKA20.js"),m=require("./roving-focus-group-BdJ_4Njm.js"),I=require("./positioner-D_fqyx_j.js");require("./listbox-B6QgECax.js");const L=require("./menu-item-styles-CbNUEwP2.js"),C=":scope > .submenu",T=["--ui-color-primary","--ui-color-primary-hover","--ui-color-foreground-on-primary","--ui-color-background","--ui-color-surface","--ui-color-surface-alt","--ui-color-text","--ui-color-muted","--ui-color-border","--ui-color-focus-ring","--ui-color-success","--ui-color-danger","--ui-color-warning","--ui-primary","--ui-primary-hover","--ui-foreground","--ui-background","--ui-surface","--ui-surface-alt","--ui-text","--ui-muted","--ui-border","--ui-focus-ring","--ui-radius","--color-background","--color-surface","--color-panel","--color-panel-solid","--color-panel-translucent","--color-overlay","--accent-contrast","--accent-surface","--accent-indicator","--accent-track"],D=[{prefix:"--accent-",from:1,to:12},{prefix:"--accent-a",from:1,to:12},{prefix:"--gray-",from:1,to:12},{prefix:"--gray-a",from:1,to:12},{prefix:"--black-a",from:1,to:12},{prefix:"--white-a",from:1,to:12},{prefix:"--shadow-",from:1,to:6},{prefix:"--radius-",from:1,to:6}];function z(n){return n==="sm"||n==="1"||n==="compact"?"sm":n==="lg"||n==="3"||n==="comfortable"?"lg":"md"}function v(n){return!n||n==="default"?null:n==="none"||n==="square"?"0px":n==="sm"?"8px":n==="md"||n==="soft"?"12px":n==="lg"?"16px":n==="full"?"999px":/^\d+(\.\d+)?$/.test(n)?`${n}px`:/^\d+(\.\d+)?(px|rem|em|%)$/.test(n)?n:null}const B=`
|
|
2
2
|
:host {
|
|
3
3
|
--ui-menubar-gap: var(--base-menubar-gap, 6px);
|
|
4
4
|
--ui-menubar-padding: var(--base-menubar-padding, 6px);
|
|
@@ -437,7 +437,7 @@
|
|
|
437
437
|
box-shadow: none;
|
|
438
438
|
}
|
|
439
439
|
}
|
|
440
|
-
`;function R(n){return n==="top"||n==="left"||n==="right"?n:"bottom"}function O(n){const e=R(n);return e==="top"?"top":e==="left"?"left":e==="right"?"right":"bottom"}function
|
|
440
|
+
`;function R(n){return n==="top"||n==="left"||n==="right"?n:"bottom"}function O(n){const e=R(n);return e==="top"?"top":e==="left"?"left":e==="right"?"right":"bottom"}function _(n,e){if(n==null)return e;const t=String(n).toLowerCase();return t!=="false"&&t!=="0"}function y(n,e){return e<=0?-1:Number.isNaN(n)||n<0?0:n>=e?e-1:n}function l(){return['[role="menuitem"]','[role="menuitemcheckbox"]','[role="menuitemradio"]',".item","[data-menu-item]"].join(", ")}function g(n){return n.hasAttribute("disabled")||n.getAttribute("aria-disabled")==="true"||!!n.disabled}function x(n){const e=typeof n.composedPath=="function"?n.composedPath():[];for(const r of e)if(r instanceof HTMLElement&&r.matches(l()))return r;const t=n.target;return t instanceof HTMLElement?t.closest(l()):null}function d(n){return n.hasAttribute("disabled")||n.disabled}function p(n,e){return n.getAttribute(e)||""}class S extends w.ElementBase{constructor(){super(),this._items=[],this._contents=[],this._itemSlot=null,this._contentSlot=null,this._uid=Math.random().toString(36).slice(2,8),this._ignoreSelected=!1,this._open=!1,this._portalEl=null,this._portalSurfaceEl=null,this._portalContentHostEl=null,this._positioner=null,this._dismissableLayer=null,this._panelForIndex=-1,this._typeaheadBuffer="",this._typeaheadTimer=null,this._submenuRaf=null,this._globalListenersBound=!1,this._focusIndex=-1,this._onClick=this._onClick.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onDocKeyDown=this._onDocKeyDown.bind(this),this._onDocScroll=this._onDocScroll.bind(this),this._onSlotChange=this._onSlotChange.bind(this),this._onMouseMove=this._onMouseMove.bind(this),this._onPanelPointerOver=this._onPanelPointerOver.bind(this),this._onPanelPointerLeave=this._onPanelPointerLeave.bind(this),this._onPanelFocusIn=this._onPanelFocusIn.bind(this)}static get observedAttributes(){return["selected","open","headless","loop","orientation","variant","size","density","radius","shape","elevation","tone","placement","close-on-select","close-on-scroll","typeahead"]}_setPanelFlag(e,t){this._portalEl&&(t?this._portalEl.setAttribute(`data-${e}`,"true"):this._portalEl.removeAttribute(`data-${e}`))}connectedCallback(){super.connectedCallback(),this.root.addEventListener("click",this._onClick),this.root.addEventListener("keydown",this._onKeyDown),this.root.addEventListener("mousemove",this._onMouseMove),this._attachSlotListeners(),this._syncHostVisualState(),this._syncState()}disconnectedCallback(){this.root.removeEventListener("click",this._onClick),this.root.removeEventListener("keydown",this._onKeyDown),this.root.removeEventListener("mousemove",this._onMouseMove),this._unbindGlobalListeners(),this._detachSlotListeners(),this._teardownPanel(),super.disconnectedCallback()}attributeChangedCallback(e,t,r){if(t!==r&&!(e==="selected"&&this._ignoreSelected)){if((e==="radius"||e==="shape")&&this._syncHostVisualState(),this._syncBarA11y(),this._open&&e==="placement"){this._rebuildPanel();return}if(this._open&&(e==="variant"||e==="size"||e==="density"||e==="radius"||e==="shape"||e==="elevation"||e==="tone")){this._syncPanelVisualState();return}this._syncState()}}render(){const e=this.getAttribute("orientation")==="vertical"?"vertical":"horizontal";this.setContent(`
|
|
441
441
|
<style>${B}</style>
|
|
442
442
|
<div class="bar" part="bar" role="menubar" aria-orientation="${e}">
|
|
443
443
|
<slot name="item"></slot>
|
|
@@ -446,10 +446,10 @@
|
|
|
446
446
|
<slot name="content"></slot>
|
|
447
447
|
</div>
|
|
448
448
|
<slot></slot>
|
|
449
|
-
`),this._attachSlotListeners(),this._syncStructure(),this._syncHostVisualState(),this._syncBarA11y(),this._open&&!this._portalEl?this._rebuildPanel():this._open&&
|
|
449
|
+
`),this._attachSlotListeners(),this._syncStructure(),this._syncHostVisualState(),this._syncBarA11y(),this._open&&!this._portalEl?this._rebuildPanel():this._open&&this._positioner?.update()}open(){this.hasAttribute("headless")||this.setAttribute("open","")}close(){this.removeAttribute("open")}toggle(){this.hasAttribute("open")?this.close():this.open()}get closeOnSelect(){return _(this.getAttribute("close-on-select"),!0)}set closeOnSelect(e){this.setAttribute("close-on-select",e?"true":"false")}get closeOnScroll(){return _(this.getAttribute("close-on-scroll"),!0)}set closeOnScroll(e){this.setAttribute("close-on-scroll",e?"true":"false")}get typeahead(){return _(this.getAttribute("typeahead"),!0)}set typeahead(e){this.setAttribute("typeahead",e?"true":"false")}_attachSlotListeners(){const e=this.root.querySelector('slot[name="item"]'),t=this.root.querySelector('slot[name="content"]');this._itemSlot&&this._itemSlot!==e&&this._itemSlot.removeEventListener("slotchange",this._onSlotChange),this._contentSlot&&this._contentSlot!==t&&this._contentSlot.removeEventListener("slotchange",this._onSlotChange),e&&this._itemSlot!==e&&e.addEventListener("slotchange",this._onSlotChange),t&&this._contentSlot!==t&&t.addEventListener("slotchange",this._onSlotChange),this._itemSlot=e,this._contentSlot=t}_detachSlotListeners(){this._itemSlot&&this._itemSlot.removeEventListener("slotchange",this._onSlotChange),this._contentSlot&&this._contentSlot.removeEventListener("slotchange",this._onSlotChange),this._itemSlot=null,this._contentSlot=null}_syncBarA11y(){const e=this.root.querySelector(".bar");if(!e)return;const t=this.getAttribute("orientation")==="vertical"?"vertical":"horizontal";e.setAttribute("aria-orientation",t)}_syncHostVisualState(){const e=v(this.getAttribute("radius")||this.getAttribute("shape"));e?(this.style.setProperty("--ui-menubar-radius",e),this.style.setProperty("--ui-menubar-item-radius",e==="999px"?"999px":`calc(${e} - 2px)`),this.style.setProperty("--ui-menubar-panel-radius",e),this.style.setProperty("--ui-menubar-panel-item-radius",e==="999px"?"999px":`calc(${e} - 2px)`)):(this.style.removeProperty("--ui-menubar-radius"),this.style.removeProperty("--ui-menubar-item-radius"),this.style.removeProperty("--ui-menubar-panel-radius"),this.style.removeProperty("--ui-menubar-panel-item-radius"))}_onSlotChange(){this._syncState()}_loopEnabled(){return _(this.getAttribute("loop"),!0)}_isOpenAttribute(){return this.hasAttribute("open")&&!this.hasAttribute("headless")}_selectedIndex(){const e=this.getAttribute("selected");if(e==null||e==="")return this._items.length>0?0:-1;const t=Number(e);return Number.isNaN(t)?this._items.length>0?0:-1:t<0?-1:y(t,this._items.length)}_setSelectedAttribute(e){this._ignoreSelected=!0,this.setAttribute("selected",String(e)),this._ignoreSelected=!1}_moveIndex(e,t){if(this._items.length===0)return-1;const r=this._loopEnabled();let a=e+t;return a<0&&(a=r?this._items.length-1:0),a>=this._items.length&&(a=r?0:this._items.length-1),a}_syncState(){this._syncStructure();const e=this._isOpenAttribute()&&this._selectedIndex()>=0&&this._items.length>0;if(e!==this._open){if(this._open=e,e)this._bindGlobalListeners(),this._rebuildPanel(),this.dispatchEvent(new CustomEvent("open",{detail:{selected:this._selectedIndex()},bubbles:!0}));else{this._unbindGlobalListeners();const t=this._panelForIndex>=0?this._panelForIndex:this._selectedIndex();this._teardownPanel(),this.dispatchEvent(new CustomEvent("close",{detail:{previous:t},bubbles:!0}))}return}this._open?(this._bindGlobalListeners(),(this._selectedIndex()!==this._panelForIndex||!this._portalEl)&&this._rebuildPanel()):(this._unbindGlobalListeners(),this._teardownPanel())}_bindGlobalListeners(){this._globalListenersBound||(document.addEventListener("keydown",this._onDocKeyDown),document.addEventListener("scroll",this._onDocScroll,{passive:!0,capture:!0}),this._globalListenersBound=!0)}_unbindGlobalListeners(){this._globalListenersBound&&(document.removeEventListener("keydown",this._onDocKeyDown),document.removeEventListener("scroll",this._onDocScroll,!0),this._globalListenersBound=!1)}_syncStructure(){this._items=this._itemSlot?this._itemSlot.assignedElements({flatten:!0}):[],this._contents=this._contentSlot?this._contentSlot.assignedElements({flatten:!0}):[];const e=this._selectedIndex(),t=m.resolveRovingFocusIndex(this._items,{activeIndex:this._focusIndex,selectedIndex:e,getDisabled:d});this._focusIndex=t;const r=this._isOpenAttribute();this._items.forEach((a,i)=>{const s=e===i,o=a.id||`ui-menubar-item-${this._uid}-${i}`,u=this._contents[i]?.id||`ui-menubar-content-${this._uid}-${i}`;a.id=o,a.setAttribute("role","menuitem"),a.setAttribute("tabindex",i===t&&!d(a)?"0":"-1"),a.setAttribute("aria-haspopup","menu"),a.setAttribute("aria-expanded",s&&r?"true":"false"),a.setAttribute("aria-controls",u),a.setAttribute("data-active",s?"true":"false")}),m.syncRovingTabStops(this._items,this._items[t]||null,{activeAttribute:null}),this._contents.forEach((a,i)=>{const s=a.id||`ui-menubar-content-${this._uid}-${i}`;a.id=s,a.setAttribute("role","menu"),a.setAttribute("tabindex","-1"),a.setAttribute("aria-hidden",e===i&&r?"false":"true"),this._items[i]?a.setAttribute("aria-labelledby",this._items[i].id):a.removeAttribute("aria-labelledby")})}_hydratePanelItems(e){Array.from(e.querySelectorAll(l())).forEach((r,a)=>{r.getAttribute("role")||r.setAttribute("role","menuitem"),r.hasAttribute("tabindex")||r.setAttribute("tabindex","-1"),r.hasAttribute("data-index")||r.setAttribute("data-index",String(a)),r.classList.contains("item")||r.classList.add("item")})}_queryPanelItemsIn(e){return this._panelListbox()?.queryEnabledItems({container:e||this._panelListbox()})||[]}_submenuFor(e){return e.querySelector(C)}_setOpenPanelBranch(e,t){const r=this._panelListbox();if(!r||(r.querySelectorAll('[data-submenu-open="true"]').forEach(s=>s.removeAttribute("data-submenu-open")),!e))return;const a=[];let i=e;for(;i;){const s=i.closest(".submenu");if(!s)break;const o=s.parentElement;if(!(o instanceof HTMLElement)||!o.matches(l()))break;a.unshift(o),i=o}a.forEach(s=>s.setAttribute("data-submenu-open","true")),t&&this._submenuFor(e)&&e.setAttribute("data-submenu-open","true")}_openPanelSubmenu(e,t){const r=this._submenuFor(e);if(!r||g(e))return!1;if(this._setOpenPanelBranch(e,!0),this._schedulePanelSubmenuLayout(),!t)return!0;const a=this._panelListbox()?.focusBoundary("first",{container:r,focus:!0,owner:this._panelSurface(),scroll:!0});return a&&this._setOpenPanelBranch(a,!1),!0}_closeParentPanelSubmenu(e){const t=e.closest(".submenu");if(!t)return!1;const r=t.parentElement;return!(r instanceof HTMLElement)||!r.matches(l())?!1:(this._focusPanelItem(r),this._setOpenPanelBranch(r,!1),r.removeAttribute("data-submenu-open"),!0)}_clearPanelSubmenuState(){const e=this._panelListbox();e&&e.querySelectorAll('[data-submenu-open="true"]').forEach(t=>t.removeAttribute("data-submenu-open"))}_schedulePanelSubmenuLayout(){this._submenuRaf!=null&&cancelAnimationFrame(this._submenuRaf),this._submenuRaf=requestAnimationFrame(()=>{this._submenuRaf=null,this._layoutPanelSubmenus()})}_layoutPanelSubmenus(){const e=this._panelListbox();if(!e)return;const t=window.innerWidth,r=window.innerHeight;Array.from(e.querySelectorAll('.item > .submenu, [role="menuitem"] > .submenu, [role="menuitemcheckbox"] > .submenu, [role="menuitemradio"] > .submenu, [data-menu-item] > .submenu')).forEach(i=>{const s=i.parentElement;if(!(s instanceof HTMLElement))return;s.removeAttribute("data-submenu-side"),s.removeAttribute("data-submenu-align");const o=i.style.display,u=i.style.visibility,c=i.style.pointerEvents,b=i.style.opacity,A=i.style.transform;i.style.display="grid",i.style.visibility="hidden",i.style.pointerEvents="none",i.style.opacity="0",i.style.transform="none";const h=s.getBoundingClientRect(),f=i.getBoundingClientRect();h.right+4+f.width>t-8&&h.left-4-f.width>=8&&s.setAttribute("data-submenu-side","left"),h.top+f.height>r-8&&h.bottom-f.height>=8&&s.setAttribute("data-submenu-align","up"),i.style.display=o,i.style.visibility=u,i.style.pointerEvents=c,i.style.opacity=b,i.style.transform=A})}_panelListbox(){return this._portalContentHostEl}_panelSurface(){return this._portalSurfaceEl}_buildPanelContent(e){const t=this._contents[e],r=document.createElement("div");r.className="ui-menubar-portal",r.style.position="absolute",r.style.pointerEvents="auto",r.innerHTML=`
|
|
450
450
|
<style>${F}</style>
|
|
451
451
|
<div class="surface menu-panel" part="menu" role="menu" aria-hidden="false" aria-busy="false" tabindex="-1">
|
|
452
452
|
<div class="state-row" part="state"></div>
|
|
453
|
-
<ui-listbox class="content-host" slot="menu" role="menu" item-selector="${
|
|
453
|
+
<ui-listbox class="content-host" slot="menu" role="menu" item-selector="${l().replace(/"/g,""")}" direct-item-selector=":scope > [slot="menu"] > ${l().replace(/"/g,""")}" item-role="menuitem" active-attribute="data-active"></ui-listbox>
|
|
454
454
|
</div>
|
|
455
|
-
`;const a=r.querySelector("ui-listbox.content-host"),i=r.querySelector(".surface");if(!a||!i)return r;if(i.id=(t==null?void 0:t.id)||`ui-menubar-panel-${this._uid}-${e}`,i.setAttribute("aria-labelledby",((s=this._items[e])==null?void 0:s.id)||""),this._applyPanelVariantData(r),this._applyPanelTokens(r),t){const o=t.cloneNode(!0);o.setAttribute("slot","menu"),a.appendChild(o)}if(this._hydratePanelItems(a),a.refresh(),!a.querySelector(c())){const o=document.createElement("div");o.className="empty-state",o.textContent="No items",a.appendChild(o)}return r.addEventListener("click",o=>{var h;const u=S(o);if(!u||v(u))return;if(this._submenuFor(u)){o.preventDefault(),this._openPanelSubmenu(u,!0);return}this._applyPanelSelectionBehavior(u);const l=u.getAttribute("data-index"),d=l!=null&&!Number.isNaN(Number(l))?Number(l):void 0;this.dispatchEvent(new CustomEvent("select",{detail:{selected:e,index:d,value:u.getAttribute("data-value")||u.getAttribute("value")||void 0,label:u.getAttribute("aria-label")||((h=u.textContent)==null?void 0:h.trim())||void 0,checked:u.getAttribute("aria-checked")==="true",item:u},bubbles:!0})),this.closeOnSelect?this.close():this._focusPanelItem(u)}),r.addEventListener("pointerover",this._onPanelPointerOver),r.addEventListener("pointerleave",this._onPanelPointerLeave),r.addEventListener("focusin",this._onPanelFocusIn),r}_applyPanelVariantData(e){const t=p(this,"variant"),r=z(this.getAttribute("size")||this.getAttribute("density")),a=p(this,"density"),i=this.getAttribute("radius"),s=p(this,"shape"),o=p(this,"elevation"),u=p(this,"tone"),l=t==="default"||t===""?"":t==="glass"?"soft":t==="line"?"outline":t;l?e.setAttribute("data-variant",l):e.removeAttribute("data-variant"),r!=="md"?e.setAttribute("data-size",r):e.removeAttribute("data-size"),a&&a!=="default"?e.setAttribute("data-density",a):e.removeAttribute("data-density"),i?e.setAttribute("data-radius",i):e.removeAttribute("data-radius"),s&&s!=="default"?e.setAttribute("data-shape",s):e.removeAttribute("data-shape"),o&&o!=="default"?e.setAttribute("data-elevation",o):e.removeAttribute("data-elevation"),u&&u!=="default"&&u!=="brand"?e.setAttribute("data-tone",u):e.removeAttribute("data-tone"),this._open?e.setAttribute("data-open","true"):e.removeAttribute("data-open");const d=y(i||s||null);d?(e.style.setProperty("--ui-menubar-panel-radius",d),e.style.setProperty("--ui-menubar-panel-item-radius",d==="999px"?"999px":`calc(${d} - 2px)`)):(e.style.removeProperty("--ui-menubar-panel-radius"),e.style.removeProperty("--ui-menubar-panel-item-radius"))}_applyPanelTokens(e){const t=window.getComputedStyle(this);["--ui-color-primary","--ui-color-primary-hover","--ui-color-foreground-on-primary","--ui-color-background","--ui-color-surface","--ui-color-surface-alt","--ui-color-text","--ui-color-muted","--ui-color-border","--ui-color-focus-ring","--ui-color-success","--ui-color-danger","--ui-color-warning","--ui-primary","--ui-primary-hover","--ui-foreground","--ui-background","--ui-surface","--ui-surface-alt","--ui-text","--ui-muted","--ui-border","--ui-focus-ring","--ui-radius","--color-background","--color-surface","--color-panel","--color-panel-solid","--color-panel-translucent","--color-overlay","--accent-contrast","--accent-surface","--accent-indicator","--accent-track","--ui-menubar-ring","--ui-menubar-z","--ui-menubar-panel-bg","--ui-menubar-panel-color","--ui-menubar-panel-border","--ui-menubar-panel-shadow","--ui-menubar-panel-radius","--ui-menubar-panel-padding","--ui-menubar-panel-min-width","--ui-menubar-panel-item-radius","--ui-menubar-panel-item-gap","--ui-menubar-panel-item-min-height","--ui-menubar-panel-item-pad-y","--ui-menubar-panel-item-pad-x","--ui-menubar-panel-item-font-size","--ui-menubar-panel-item-font-weight","--ui-menubar-panel-item-line-height","--ui-menubar-panel-separator-margin","--ui-menubar-panel-item-hover-bg","--ui-menubar-panel-item-active-color"].forEach(a=>{const i=t.getPropertyValue(a).trim();i?e.style.setProperty(a,i):e.style.removeProperty(a)}),T.forEach(a=>{const i=t.getPropertyValue(a).trim();i?e.style.setProperty(a,i):e.style.removeProperty(a)}),D.forEach(({prefix:a,from:i,to:s})=>{for(let o=i;o<=s;o+=1){const u=`${a}${o}`,l=t.getPropertyValue(u).trim();l?e.style.setProperty(u,l):e.style.removeProperty(u)}})}_syncPanelVisualState(){const e=this._portalEl;if(!e)return;this._setPanelFlag("open",this._open),this._applyPanelVariantData(e),this._applyPanelTokens(e);const t=this._panelSurface();t&&(t.setAttribute("aria-hidden","false"),t.setAttribute("aria-busy","false"),t.removeAttribute("hidden"),t.style.display="block",t.style.visibility="visible",t.style.opacity="1",t.style.transform="translateY(0px) scale(1)",t.style.pointerEvents="auto");const r=e.querySelector(".state-row");r&&(r.textContent=""),this._schedulePanelSubmenuLayout()}_rebuildPanel(){if(!this._open)return;const e=this._selectedIndex(),t=this._items[e];if(e<0||!t){this._teardownPanel();return}this._teardownPanel();const r=this._buildPanelContent(e);this._portalEl=r,this._portalSurfaceEl=r.querySelector(".surface"),this._portalContentHostEl=r.querySelector("ui-listbox.content-host"),this._panelForIndex=e;const a=P.createPortalContainer();if(!a){this._portalEl=null,this._panelForIndex=-1;return}a.appendChild(r),this._positioner=I.createPositioner({anchor:t,floating:this._panelSurface()||r,placement:O(this.getAttribute("placement")),offset:6,flip:!0,shift:!0,fitViewport:!0,observeScroll:!1}),this._dismissableLayer=k.createDismissableLayer({node:this._panelSurface()||r,trigger:t,closeOnEscape:!0,closeOnPointerOutside:!0,onDismiss:()=>this.close()})}_teardownPanel(){var e,t,r;if((e=this._dismissableLayer)==null||e.destroy(),this._dismissableLayer=null,(t=this._positioner)==null||t.destroy(),this._positioner=null,(r=this._portalEl)!=null&&r.parentElement)try{this._portalEl.parentElement.removeChild(this._portalEl)}catch{}this._portalEl=null,this._portalSurfaceEl=null,this._portalContentHostEl=null,this._panelForIndex=-1,this._submenuRaf!=null&&(cancelAnimationFrame(this._submenuRaf),this._submenuRaf=null),this._resetTypeahead()}_selectIndex(e,t){const r=this._selectedIndex(),a=x(e,this._items.length);a<0||(this._setSelectedAttribute(a),this.setAttribute("open",""),this._syncState(),this.dispatchEvent(new CustomEvent("change",{detail:{selected:a,previous:r,open:!0,reason:t},bubbles:!0})))}_focusItem(e){const t=this._items[e];t&&(this._focusIndex=e,m.syncRovingTabStops(this._items,t,{activeAttribute:null}),m.focusRovingItem(t))}_queryPanelItems(){return this._queryPanelItemsIn(this._panelListbox())}_focusPanelItem(e){var t;e&&((t=this._panelListbox())==null||t.setActiveItem(e,{focus:!0,owner:this._panelSurface(),scroll:!0}))}_focusPanelFirst(){var e;(e=this._panelListbox())==null||e.focusBoundary("first",{focus:!0,owner:this._panelSurface(),scroll:!0})}_focusPanelLast(){var e;(e=this._panelListbox())==null||e.focusBoundary("last",{focus:!0,owner:this._panelSurface(),scroll:!0})}_movePanelFocus(e){var s,o,u;const t=document.activeElement,r=t&&((s=this._portalEl)!=null&&s.contains(t))?t.closest(c()):null,a=(r==null?void 0:r.closest(".submenu"))||this._panelListbox();((u=this._panelListbox())==null?void 0:u.move(e,{container:a,current:t&&((o=this._portalEl)!=null&&o.contains(t))?t:null,focus:!0,owner:this._panelSurface(),scroll:!0}))||null||this._focusPanelFirst()}_resetTypeahead(){this._typeaheadBuffer="",this._typeaheadTimer!=null&&(window.clearTimeout(this._typeaheadTimer),this._typeaheadTimer=null)}_isTypeaheadKey(e){return e.ctrlKey||e.metaKey||e.altKey?!1:e.key.length===1&&/\S/.test(e.key)}_typeaheadOnBar(e){if(!this.typeahead||!this._isTypeaheadKey(e))return!1;this._typeaheadBuffer=`${this._typeaheadBuffer}${e.key.toLowerCase()}`.slice(0,24),this._typeaheadTimer!=null&&window.clearTimeout(this._typeaheadTimer),this._typeaheadTimer=window.setTimeout(()=>this._resetTypeahead(),420);const t=this._items.findIndex(a=>a===e.target||a.contains(e.target)),r=E.findTypeaheadMatch(this._items,this._typeaheadBuffer,{startIndex:t,getLabel:a=>a.getAttribute("aria-label")||a.textContent||"",getDisabled:b});return r<0?!1:(e.preventDefault(),this._focusItem(r),this._open&&this._selectIndex(r,"keyboard"),!0)}_typeaheadOnPanel(e){var s,o,u;if(!this.typeahead||!this._isTypeaheadKey(e))return!1;this._typeaheadBuffer=`${this._typeaheadBuffer}${e.key.toLowerCase()}`.slice(0,24),this._typeaheadTimer!=null&&window.clearTimeout(this._typeaheadTimer),this._typeaheadTimer=window.setTimeout(()=>this._resetTypeahead(),420);const t=document.activeElement,r=t&&((s=this._portalEl)!=null&&s.contains(t))?t.closest(c()):null,a=(r==null?void 0:r.closest(".submenu"))||this._panelListbox();return((u=this._panelListbox())==null?void 0:u.typeahead(this._typeaheadBuffer,{container:a,current:t&&((o=this._portalEl)!=null&&o.contains(t))?t:null,focus:!0,owner:this._panelSurface(),scroll:!0}))||null?(e.preventDefault(),!0):!1}_applyPanelSelectionBehavior(e){const t=e.getAttribute("role");if(t==="menuitemcheckbox"){const s=e.getAttribute("aria-checked")!=="true";e.setAttribute("aria-checked",s?"true":"false"),e.setAttribute("data-state",s?"checked":"unchecked");return}if(t!=="menuitemradio")return;const r=e.closest(".submenu")||this._panelListbox();if(!r)return;const a=e.getAttribute("data-group")||e.getAttribute("name")||"";Array.from(r.querySelectorAll('[role="menuitemradio"]')).forEach(s=>{a&&(s.getAttribute("data-group")||s.getAttribute("name")||"")!==a||(s.setAttribute("aria-checked","false"),s.setAttribute("data-state","unchecked"))}),e.setAttribute("aria-checked","true"),e.setAttribute("data-state","checked")}_onClick(e){const t=e.composedPath(),r=this._items.findIndex(i=>t.includes(i));if(r<0)return;if(this._focusItem(r),this._selectedIndex()===r&&this._open){this.close(),this._syncState();return}this._selectIndex(r,"click")}_onMouseMove(e){if(!this._open)return;const t=e.composedPath(),r=this._items.findIndex(a=>t.includes(a));r<0||r!==this._selectedIndex()&&this._selectIndex(r,"programmatic")}_isInternalScrollEvent(e){var a;const t=typeof e.composedPath=="function"?e.composedPath():[];if(this._portalEl&&t.includes(this._portalEl)||this._items.some(i=>t.includes(i)))return!0;const r=e.target;return!!(r instanceof Node&&((a=this._portalEl)!=null&&a.contains(r)||this._items.some(i=>i.contains(r))))}_onDocScroll(e){!this._open||!this.closeOnScroll||this._isInternalScrollEvent(e)||this.close()}_onPanelPointerOver(e){var a;if(!this._open)return;const t=S(e);if(!t||v(t))return;const r=t.closest(".submenu")||this._panelListbox();(a=this._panelListbox())==null||a.setActiveItem(t,{container:r,focus:!1,owner:this._panelSurface(),scroll:!1}),this._submenuFor(t)?this._openPanelSubmenu(t,!1):this._setOpenPanelBranch(t,!1)}_onPanelPointerLeave(e){if(!(e.currentTarget instanceof HTMLElement))return;const t=e.relatedTarget;t instanceof Node&&e.currentTarget.contains(t)||this._clearPanelSubmenuState()}_onPanelFocusIn(e){const t=e.target;if(!(t instanceof HTMLElement))return;const r=t.closest(c());r&&(this._submenuFor(r)?this._setOpenPanelBranch(r,!0):this._setOpenPanelBranch(r,!1))}_onKeyDown(e){const t=this._items.findIndex(o=>o===e.target||o.contains(e.target));if(t<0)return;const r=getComputedStyle(this).direction==="rtl"?"rtl":"ltr";let a=!1,i=t;const s=m.resolveRovingFocusIndex(this._items,{activeIndex:t,selectedIndex:this._selectedIndex(),getDisabled:b});e.key==="ArrowRight"?(i=m.moveRovingFocusIndex(this._items,t,r==="rtl"?-1:1,{wrap:this._loopEnabled(),fallbackIndex:s,getDisabled:b}),a=!0):e.key==="ArrowLeft"?(i=m.moveRovingFocusIndex(this._items,t,r==="rtl"?1:-1,{wrap:this._loopEnabled(),fallbackIndex:s,getDisabled:b}),a=!0):e.key==="Home"?(i=m.getRovingFocusBoundaryIndex(this._items,"first",b),a=!0):e.key==="End"?(i=m.getRovingFocusBoundaryIndex(this._items,"last",b),a=!0):e.key==="Enter"||e.key===" "?(this._selectIndex(t,"keyboard"),a=!0):e.key==="ArrowDown"?(this._selectIndex(t,"keyboard"),setTimeout(()=>this._focusPanelFirst(),0),a=!0):e.key==="ArrowUp"&&(this._selectIndex(t,"keyboard"),setTimeout(()=>this._focusPanelLast(),0),a=!0),!(!a&&this._typeaheadOnBar(e))&&a&&(e.preventDefault(),i>=0&&i!==t&&(this._focusItem(i),this._open&&this._selectIndex(i,"keyboard")))}_onDocKeyDown(e){var i;if(!this._open||!(!!this._portalEl&&e.composedPath().includes(this._portalEl))||this._typeaheadOnPanel(e))return;if(e.key==="ArrowDown"){e.preventDefault(),this._movePanelFocus(1);return}if(e.key==="ArrowUp"){e.preventDefault(),this._movePanelFocus(-1);return}if(e.key==="Home"){e.preventDefault(),this._focusPanelFirst();return}if(e.key==="End"){e.preventDefault(),this._focusPanelLast();return}const r=document.activeElement,a=r==null?void 0:r.closest(c());if(e.key==="ArrowRight"&&a&&this._openPanelSubmenu(a,!0)){e.preventDefault();return}if(e.key==="ArrowLeft"&&a&&this._closeParentPanelSubmenu(a)){e.preventDefault();return}if(e.key==="Tab"){this.close();return}if(e.key==="Enter"||e.key===" "){if(!r||!((i=this._portalEl)!=null&&i.contains(r))||!a||v(a)||(e.preventDefault(),this._openPanelSubmenu(a,!0)))return;a.click()}}shouldRenderOnAttributeChange(e,t,r){return!1}}typeof customElements<"u"&&!customElements.get("ui-menubar")&&customElements.define("ui-menubar",A);exports.UIMenubar=A;
|
|
455
|
+
`;const a=r.querySelector("ui-listbox.content-host"),i=r.querySelector(".surface");if(!a||!i)return r;if(i.id=t?.id||`ui-menubar-panel-${this._uid}-${e}`,i.setAttribute("aria-labelledby",this._items[e]?.id||""),this._applyPanelVariantData(r),this._applyPanelTokens(r),t){const s=t.cloneNode(!0);s.setAttribute("slot","menu"),a.appendChild(s)}if(this._hydratePanelItems(a),a.refresh(),!a.querySelector(l())){const s=document.createElement("div");s.className="empty-state",s.textContent="No items",a.appendChild(s)}return r.addEventListener("click",s=>{const o=x(s);if(!o||g(o))return;if(this._submenuFor(o)){s.preventDefault(),this._openPanelSubmenu(o,!0);return}this._applyPanelSelectionBehavior(o);const u=o.getAttribute("data-index"),c=u!=null&&!Number.isNaN(Number(u))?Number(u):void 0;this.dispatchEvent(new CustomEvent("select",{detail:{selected:e,index:c,value:o.getAttribute("data-value")||o.getAttribute("value")||void 0,label:o.getAttribute("aria-label")||o.textContent?.trim()||void 0,checked:o.getAttribute("aria-checked")==="true",item:o},bubbles:!0})),this.closeOnSelect?this.close():this._focusPanelItem(o)}),r.addEventListener("pointerover",this._onPanelPointerOver),r.addEventListener("pointerleave",this._onPanelPointerLeave),r.addEventListener("focusin",this._onPanelFocusIn),r}_applyPanelVariantData(e){const t=p(this,"variant"),r=z(this.getAttribute("size")||this.getAttribute("density")),a=p(this,"density"),i=this.getAttribute("radius"),s=p(this,"shape"),o=p(this,"elevation"),u=p(this,"tone"),c=t==="default"||t===""?"":t==="glass"?"soft":t==="line"?"outline":t;c?e.setAttribute("data-variant",c):e.removeAttribute("data-variant"),r!=="md"?e.setAttribute("data-size",r):e.removeAttribute("data-size"),a&&a!=="default"?e.setAttribute("data-density",a):e.removeAttribute("data-density"),i?e.setAttribute("data-radius",i):e.removeAttribute("data-radius"),s&&s!=="default"?e.setAttribute("data-shape",s):e.removeAttribute("data-shape"),o&&o!=="default"?e.setAttribute("data-elevation",o):e.removeAttribute("data-elevation"),u&&u!=="default"&&u!=="brand"?e.setAttribute("data-tone",u):e.removeAttribute("data-tone"),this._open?e.setAttribute("data-open","true"):e.removeAttribute("data-open");const b=v(i||s||null);b?(e.style.setProperty("--ui-menubar-panel-radius",b),e.style.setProperty("--ui-menubar-panel-item-radius",b==="999px"?"999px":`calc(${b} - 2px)`)):(e.style.removeProperty("--ui-menubar-panel-radius"),e.style.removeProperty("--ui-menubar-panel-item-radius"))}_applyPanelTokens(e){const t=window.getComputedStyle(this);["--ui-color-primary","--ui-color-primary-hover","--ui-color-foreground-on-primary","--ui-color-background","--ui-color-surface","--ui-color-surface-alt","--ui-color-text","--ui-color-muted","--ui-color-border","--ui-color-focus-ring","--ui-color-success","--ui-color-danger","--ui-color-warning","--ui-primary","--ui-primary-hover","--ui-foreground","--ui-background","--ui-surface","--ui-surface-alt","--ui-text","--ui-muted","--ui-border","--ui-focus-ring","--ui-radius","--color-background","--color-surface","--color-panel","--color-panel-solid","--color-panel-translucent","--color-overlay","--accent-contrast","--accent-surface","--accent-indicator","--accent-track","--ui-menubar-ring","--ui-menubar-z","--ui-menubar-panel-bg","--ui-menubar-panel-color","--ui-menubar-panel-border","--ui-menubar-panel-shadow","--ui-menubar-panel-radius","--ui-menubar-panel-padding","--ui-menubar-panel-min-width","--ui-menubar-panel-item-radius","--ui-menubar-panel-item-gap","--ui-menubar-panel-item-min-height","--ui-menubar-panel-item-pad-y","--ui-menubar-panel-item-pad-x","--ui-menubar-panel-item-font-size","--ui-menubar-panel-item-font-weight","--ui-menubar-panel-item-line-height","--ui-menubar-panel-separator-margin","--ui-menubar-panel-item-hover-bg","--ui-menubar-panel-item-active-color"].forEach(a=>{const i=t.getPropertyValue(a).trim();i?e.style.setProperty(a,i):e.style.removeProperty(a)}),T.forEach(a=>{const i=t.getPropertyValue(a).trim();i?e.style.setProperty(a,i):e.style.removeProperty(a)}),D.forEach(({prefix:a,from:i,to:s})=>{for(let o=i;o<=s;o+=1){const u=`${a}${o}`,c=t.getPropertyValue(u).trim();c?e.style.setProperty(u,c):e.style.removeProperty(u)}})}_syncPanelVisualState(){const e=this._portalEl;if(!e)return;this._setPanelFlag("open",this._open),this._applyPanelVariantData(e),this._applyPanelTokens(e);const t=this._panelSurface();t&&(t.setAttribute("aria-hidden","false"),t.setAttribute("aria-busy","false"),t.removeAttribute("hidden"),t.style.display="block",t.style.visibility="visible",t.style.opacity="1",t.style.transform="translateY(0px) scale(1)",t.style.pointerEvents="auto");const r=e.querySelector(".state-row");r&&(r.textContent=""),this._schedulePanelSubmenuLayout()}_rebuildPanel(){if(!this._open)return;const e=this._selectedIndex(),t=this._items[e];if(e<0||!t){this._teardownPanel();return}this._teardownPanel();const r=this._buildPanelContent(e);this._portalEl=r,this._portalSurfaceEl=r.querySelector(".surface"),this._portalContentHostEl=r.querySelector("ui-listbox.content-host"),this._panelForIndex=e;const a=P.createPortalContainer();if(!a){this._portalEl=null,this._panelForIndex=-1;return}a.appendChild(r),this._positioner=I.createPositioner({anchor:t,floating:this._panelSurface()||r,placement:O(this.getAttribute("placement")),offset:6,flip:!0,shift:!0,fitViewport:!0,observeScroll:!1}),this._dismissableLayer=k.createDismissableLayer({node:this._panelSurface()||r,trigger:t,closeOnEscape:!0,closeOnPointerOutside:!0,onDismiss:()=>this.close()})}_teardownPanel(){if(this._dismissableLayer?.destroy(),this._dismissableLayer=null,this._positioner?.destroy(),this._positioner=null,this._portalEl?.parentElement)try{this._portalEl.parentElement.removeChild(this._portalEl)}catch{}this._portalEl=null,this._portalSurfaceEl=null,this._portalContentHostEl=null,this._panelForIndex=-1,this._submenuRaf!=null&&(cancelAnimationFrame(this._submenuRaf),this._submenuRaf=null),this._resetTypeahead()}_selectIndex(e,t){const r=this._selectedIndex(),a=y(e,this._items.length);a<0||(this._setSelectedAttribute(a),this.setAttribute("open",""),this._syncState(),this.dispatchEvent(new CustomEvent("change",{detail:{selected:a,previous:r,open:!0,reason:t},bubbles:!0})))}_focusItem(e){const t=this._items[e];t&&(this._focusIndex=e,m.syncRovingTabStops(this._items,t,{activeAttribute:null}),m.focusRovingItem(t))}_queryPanelItems(){return this._queryPanelItemsIn(this._panelListbox())}_focusPanelItem(e){e&&this._panelListbox()?.setActiveItem(e,{focus:!0,owner:this._panelSurface(),scroll:!0})}_focusPanelFirst(){this._panelListbox()?.focusBoundary("first",{focus:!0,owner:this._panelSurface(),scroll:!0})}_focusPanelLast(){this._panelListbox()?.focusBoundary("last",{focus:!0,owner:this._panelSurface(),scroll:!0})}_movePanelFocus(e){const t=document.activeElement,a=(t&&this._portalEl?.contains(t)?t.closest(l()):null)?.closest(".submenu")||this._panelListbox();this._panelListbox()?.move(e,{container:a,current:t&&this._portalEl?.contains(t)?t:null,focus:!0,owner:this._panelSurface(),scroll:!0})||this._focusPanelFirst()}_resetTypeahead(){this._typeaheadBuffer="",this._typeaheadTimer!=null&&(window.clearTimeout(this._typeaheadTimer),this._typeaheadTimer=null)}_isTypeaheadKey(e){return e.ctrlKey||e.metaKey||e.altKey?!1:e.key.length===1&&/\S/.test(e.key)}_typeaheadOnBar(e){if(!this.typeahead||!this._isTypeaheadKey(e))return!1;this._typeaheadBuffer=`${this._typeaheadBuffer}${e.key.toLowerCase()}`.slice(0,24),this._typeaheadTimer!=null&&window.clearTimeout(this._typeaheadTimer),this._typeaheadTimer=window.setTimeout(()=>this._resetTypeahead(),420);const t=this._items.findIndex(a=>a===e.target||a.contains(e.target)),r=E.findTypeaheadMatch(this._items,this._typeaheadBuffer,{startIndex:t,getLabel:a=>a.getAttribute("aria-label")||a.textContent||"",getDisabled:d});return r<0?!1:(e.preventDefault(),this._focusItem(r),this._open&&this._selectIndex(r,"keyboard"),!0)}_typeaheadOnPanel(e){if(!this.typeahead||!this._isTypeaheadKey(e))return!1;this._typeaheadBuffer=`${this._typeaheadBuffer}${e.key.toLowerCase()}`.slice(0,24),this._typeaheadTimer!=null&&window.clearTimeout(this._typeaheadTimer),this._typeaheadTimer=window.setTimeout(()=>this._resetTypeahead(),420);const t=document.activeElement,a=(t&&this._portalEl?.contains(t)?t.closest(l()):null)?.closest(".submenu")||this._panelListbox();return this._panelListbox()?.typeahead(this._typeaheadBuffer,{container:a,current:t&&this._portalEl?.contains(t)?t:null,focus:!0,owner:this._panelSurface(),scroll:!0})||null?(e.preventDefault(),!0):!1}_applyPanelSelectionBehavior(e){const t=e.getAttribute("role");if(t==="menuitemcheckbox"){const s=e.getAttribute("aria-checked")!=="true";e.setAttribute("aria-checked",s?"true":"false"),e.setAttribute("data-state",s?"checked":"unchecked");return}if(t!=="menuitemradio")return;const r=e.closest(".submenu")||this._panelListbox();if(!r)return;const a=e.getAttribute("data-group")||e.getAttribute("name")||"";Array.from(r.querySelectorAll('[role="menuitemradio"]')).forEach(s=>{a&&(s.getAttribute("data-group")||s.getAttribute("name")||"")!==a||(s.setAttribute("aria-checked","false"),s.setAttribute("data-state","unchecked"))}),e.setAttribute("aria-checked","true"),e.setAttribute("data-state","checked")}_onClick(e){const t=e.composedPath(),r=this._items.findIndex(i=>t.includes(i));if(r<0)return;if(this._focusItem(r),this._selectedIndex()===r&&this._open){this.close(),this._syncState();return}this._selectIndex(r,"click")}_onMouseMove(e){if(!this._open)return;const t=e.composedPath(),r=this._items.findIndex(a=>t.includes(a));r<0||r!==this._selectedIndex()&&this._selectIndex(r,"programmatic")}_isInternalScrollEvent(e){const t=typeof e.composedPath=="function"?e.composedPath():[];if(this._portalEl&&t.includes(this._portalEl)||this._items.some(a=>t.includes(a)))return!0;const r=e.target;return!!(r instanceof Node&&(this._portalEl?.contains(r)||this._items.some(a=>a.contains(r))))}_onDocScroll(e){!this._open||!this.closeOnScroll||this._isInternalScrollEvent(e)||this.close()}_onPanelPointerOver(e){if(!this._open)return;const t=x(e);if(!t||g(t))return;const r=t.closest(".submenu")||this._panelListbox();this._panelListbox()?.setActiveItem(t,{container:r,focus:!1,owner:this._panelSurface(),scroll:!1}),this._submenuFor(t)?this._openPanelSubmenu(t,!1):this._setOpenPanelBranch(t,!1)}_onPanelPointerLeave(e){if(!(e.currentTarget instanceof HTMLElement))return;const t=e.relatedTarget;t instanceof Node&&e.currentTarget.contains(t)||this._clearPanelSubmenuState()}_onPanelFocusIn(e){const t=e.target;if(!(t instanceof HTMLElement))return;const r=t.closest(l());r&&(this._submenuFor(r)?this._setOpenPanelBranch(r,!0):this._setOpenPanelBranch(r,!1))}_onKeyDown(e){const t=this._items.findIndex(o=>o===e.target||o.contains(e.target));if(t<0)return;const r=getComputedStyle(this).direction==="rtl"?"rtl":"ltr";let a=!1,i=t;const s=m.resolveRovingFocusIndex(this._items,{activeIndex:t,selectedIndex:this._selectedIndex(),getDisabled:d});e.key==="ArrowRight"?(i=m.moveRovingFocusIndex(this._items,t,r==="rtl"?-1:1,{wrap:this._loopEnabled(),fallbackIndex:s,getDisabled:d}),a=!0):e.key==="ArrowLeft"?(i=m.moveRovingFocusIndex(this._items,t,r==="rtl"?1:-1,{wrap:this._loopEnabled(),fallbackIndex:s,getDisabled:d}),a=!0):e.key==="Home"?(i=m.getRovingFocusBoundaryIndex(this._items,"first",d),a=!0):e.key==="End"?(i=m.getRovingFocusBoundaryIndex(this._items,"last",d),a=!0):e.key==="Enter"||e.key===" "?(this._selectIndex(t,"keyboard"),a=!0):e.key==="ArrowDown"?(this._selectIndex(t,"keyboard"),setTimeout(()=>this._focusPanelFirst(),0),a=!0):e.key==="ArrowUp"&&(this._selectIndex(t,"keyboard"),setTimeout(()=>this._focusPanelLast(),0),a=!0),!(!a&&this._typeaheadOnBar(e))&&a&&(e.preventDefault(),i>=0&&i!==t&&(this._focusItem(i),this._open&&this._selectIndex(i,"keyboard")))}_onDocKeyDown(e){if(!this._open||!(!!this._portalEl&&e.composedPath().includes(this._portalEl))||this._typeaheadOnPanel(e))return;if(e.key==="ArrowDown"){e.preventDefault(),this._movePanelFocus(1);return}if(e.key==="ArrowUp"){e.preventDefault(),this._movePanelFocus(-1);return}if(e.key==="Home"){e.preventDefault(),this._focusPanelFirst();return}if(e.key==="End"){e.preventDefault(),this._focusPanelLast();return}const r=document.activeElement,a=r?.closest(l());if(e.key==="ArrowRight"&&a&&this._openPanelSubmenu(a,!0)){e.preventDefault();return}if(e.key==="ArrowLeft"&&a&&this._closeParentPanelSubmenu(a)){e.preventDefault();return}if(e.key==="Tab"){this.close();return}if(e.key==="Enter"||e.key===" "){if(!r||!this._portalEl?.contains(r)||!a||g(a)||(e.preventDefault(),this._openPanelSubmenu(a,!0)))return;a.click()}}shouldRenderOnAttributeChange(e,t,r){return!1}}typeof customElements<"u"&&!customElements.get("ui-menubar")&&customElements.define("ui-menubar",S);exports.UIMenubar=S;
|