@orangelogic/design-system 2.226.0 → 2.227.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/library/components/dropdown.js +62 -63
- package/library/components/menu.js +124 -114
- package/library/package.json +1 -1
- package/library/packages/atoms/src/components/dropdown/dropdown.d.ts +0 -1
- package/library/packages/atoms/src/components/menu/menu.d.ts +4 -3
- package/library/packages/react-web-component.d.ts +0 -4
- package/library/react-web-component.d.ts +0 -4
- package/package.json +1 -1
|
@@ -9,22 +9,22 @@ import { a as m } from "../chunks/tabbable.BwnZBHrm.js";
|
|
|
9
9
|
import { w as D } from "../chunks/watch.DJF5K-8U.js";
|
|
10
10
|
import { i as k, x as T } from "../chunks/lit-element.jLBm65_O.js";
|
|
11
11
|
import { e as h } from "../chunks/query.BBf1UFkC.js";
|
|
12
|
-
import { e as
|
|
13
|
-
import { o as
|
|
12
|
+
import { e as O } from "../chunks/class-map.BiVq-cVR.js";
|
|
13
|
+
import { o as _ } from "../chunks/if-defined.BRoBj_Rp.js";
|
|
14
14
|
import { s as y, g as f } from "../chunks/animation-registry.HmpwNuGH.js";
|
|
15
|
-
import { C as
|
|
16
|
-
import
|
|
17
|
-
import
|
|
15
|
+
import { C as L } from "../chunks/input.B1JamaTE.js";
|
|
16
|
+
import d from "./menu.js";
|
|
17
|
+
import A from "./popup.js";
|
|
18
18
|
import S from "./textarea.js";
|
|
19
|
-
const
|
|
20
|
-
var
|
|
21
|
-
for (var r = a > 1 ? void 0 : a ? K(t, i) : t, p = e.length - 1,
|
|
22
|
-
(
|
|
23
|
-
return a && r &&
|
|
19
|
+
const $ = k`:host{--panel-padding:0px;--panel-overflow:auto;display:inline-block}.dropdown::part(popup){z-index:var(--cx-z-index-dropdown)}.dropdown[data-current-placement^=top]::part(popup){transform-origin:bottom}.dropdown[data-current-placement^=bottom]::part(popup){transform-origin:top}.dropdown[data-current-placement^=left]::part(popup){transform-origin:100%}.dropdown[data-current-placement^=right]::part(popup){transform-origin:0}.dropdown__trigger{display:var(--trigger-display,block)}.dropdown__panel{padding:var(--panel-padding);background-color:var(--cx-panel-background-color);border:var(--cx-panel-border-width) solid var(--cx-panel-border-color);font-family:var(--cx-font-sans);font-size:var(--cx-font-size-medium);font-weight:var(--cx-font-weight-regular);box-shadow:var(--cx-shadow-large);border-radius:var(--cx-border-radius-large);pointer-events:none;max-height:min(var(--auto-size-available-height), var(--max-height,var(--auto-size-available-height)));overflow:var(--panel-overflow,auto);display:block}.dropdown--open .dropdown__panel{pointer-events:all}::slotted(cx-menu){border:none;max-width:min(100%, var(--auto-size-available-width))!important}.dropdown__trigger::slotted(cx-tooltip){line-height:1;display:inline-block}`;
|
|
20
|
+
var F = Object.defineProperty, K = Object.getOwnPropertyDescriptor, n = (e, t, i, a) => {
|
|
21
|
+
for (var r = a > 1 ? void 0 : a ? K(t, i) : t, p = e.length - 1, l; p >= 0; p--)
|
|
22
|
+
(l = e[p]) && (r = (a ? l(t, i, r) : l(r)) || r);
|
|
23
|
+
return a && r && F(t, i, r), r;
|
|
24
24
|
};
|
|
25
|
-
let
|
|
25
|
+
let o = class extends w {
|
|
26
26
|
constructor() {
|
|
27
|
-
super(), this.localize = new C(this), this.hasSlotController = new E(this, "[default]"), this.pendingFocusCancel = null, this.open = !1, this.placement = "bottom-start", this.disabled = !1, this.stayOpenOnSelect = !1, this.distance = 0, this.skidding = 0, this.hoist = !1, this.sync = void 0, this.autoWidthFactor = 1, this.ignoredKeys = [], this.noFlip = !1, this.flipPadding = 10, this.handleKeyDown = this.handleKeyDown.bind(this), this.handleDocumentKeyDown = this.handleDocumentKeyDown.bind(this), this.handleDocumentMouseDown = this.handleDocumentMouseDown.bind(this), this.
|
|
27
|
+
super(), this.localize = new C(this), this.hasSlotController = new E(this, "[default]"), this.pendingFocusCancel = null, this.open = !1, this.placement = "bottom-start", this.disabled = !1, this.stayOpenOnSelect = !1, this.distance = 0, this.skidding = 0, this.hoist = !1, this.sync = void 0, this.autoWidthFactor = 1, this.ignoredKeys = [], this.noFlip = !1, this.flipPadding = 10, this.handleKeyDown = this.handleKeyDown.bind(this), this.handleDocumentKeyDown = this.handleDocumentKeyDown.bind(this), this.handleDocumentMouseDown = this.handleDocumentMouseDown.bind(this), this.handlePanelSelect = this.handlePanelSelect.bind(this);
|
|
28
28
|
}
|
|
29
29
|
/**
|
|
30
30
|
* When hoisted, floating-ui still measures available space against the trigger's real overflow ancestors (e.g. a
|
|
@@ -52,27 +52,26 @@ let n = class extends w {
|
|
|
52
52
|
this.open && e.key === "Escape" && (e.stopPropagation(), this.hide(), this.focusOnTrigger());
|
|
53
53
|
}
|
|
54
54
|
handleDocumentKeyDown(e) {
|
|
55
|
-
e.key === "Escape" && this.open && (e.stopPropagation(), this.focusOnTrigger(), this.hide())
|
|
55
|
+
e.key === "Escape" && this.open && (e.stopPropagation(), this.focusOnTrigger(), this.hide()), e.key === "Tab" && this.open && requestAnimationFrame(() => {
|
|
56
|
+
this.containingElement?.matches(":focus-within") || this.hide();
|
|
57
|
+
});
|
|
56
58
|
}
|
|
59
|
+
// Listens in the capture phase, so an element outside that stops mousedown propagation still closes it.
|
|
57
60
|
handleDocumentMouseDown(e) {
|
|
58
61
|
const t = e.composedPath();
|
|
59
62
|
this.containingElement && !t.includes(this.containingElement) && this.hide();
|
|
60
63
|
}
|
|
61
|
-
handleDocumentFocusIn(e) {
|
|
62
|
-
const t = e.composedPath();
|
|
63
|
-
this.containingElement && !t.includes(this.containingElement) && this.hide();
|
|
64
|
-
}
|
|
65
64
|
handlePanelSelect(e) {
|
|
66
65
|
const t = e.target;
|
|
67
66
|
!this.stayOpenOnSelect && t.tagName.toLowerCase() === "cx-menu" && (this.hide(), this.focusOnTrigger());
|
|
68
67
|
}
|
|
69
68
|
async handleTriggerClick() {
|
|
70
69
|
this.open ? (this.hide(), this.panel.assignedElements().forEach(async (e) => {
|
|
71
|
-
e instanceof
|
|
70
|
+
e instanceof d && e.variant === "multiple" && e.resetActiveMenu();
|
|
72
71
|
})) : (this.show(), this.focusOnTrigger());
|
|
73
72
|
}
|
|
74
73
|
handleTriggerKeyDown(e) {
|
|
75
|
-
if (this.disabled || this.ignoredKeys.includes(e.key) || e.key === " " && (e.target instanceof
|
|
74
|
+
if (this.disabled || this.ignoredKeys.includes(e.key) || e.key === " " && (e.target instanceof L || e.target instanceof S || e.target instanceof HTMLInputElement || e.target instanceof HTMLTextAreaElement) || !["ArrowDown", "ArrowUp", "Home", "End", "Enter", " "].includes(
|
|
76
75
|
e.key
|
|
77
76
|
))
|
|
78
77
|
return;
|
|
@@ -162,10 +161,10 @@ let n = class extends w {
|
|
|
162
161
|
addOpenListeners() {
|
|
163
162
|
this.panel.addEventListener("cx-select", this.handlePanelSelect), "CloseWatcher" in globalThis ? (this.closeWatcher?.destroy(), this.closeWatcher = new CloseWatcher(), this.closeWatcher.onclose = () => {
|
|
164
163
|
this.hide(), this.focusOnTrigger();
|
|
165
|
-
}) : this.panel.addEventListener("keydown", this.handleKeyDown), document.addEventListener("keydown", this.handleDocumentKeyDown), document.addEventListener("mousedown", this.handleDocumentMouseDown
|
|
164
|
+
}) : this.panel.addEventListener("keydown", this.handleKeyDown), document.addEventListener("keydown", this.handleDocumentKeyDown), document.addEventListener("mousedown", this.handleDocumentMouseDown, !0);
|
|
166
165
|
}
|
|
167
166
|
removeOpenListeners() {
|
|
168
|
-
this.panel && (this.panel.removeEventListener("cx-select", this.handlePanelSelect), this.panel.removeEventListener("keydown", this.handleKeyDown)), document.removeEventListener("keydown", this.handleDocumentKeyDown), document.removeEventListener("mousedown", this.handleDocumentMouseDown
|
|
167
|
+
this.panel && (this.panel.removeEventListener("cx-select", this.handlePanelSelect), this.panel.removeEventListener("keydown", this.handleKeyDown)), document.removeEventListener("keydown", this.handleDocumentKeyDown), document.removeEventListener("mousedown", this.handleDocumentMouseDown, !0), this.closeWatcher?.destroy();
|
|
169
168
|
}
|
|
170
169
|
async handleOpenChange() {
|
|
171
170
|
if (this.disabled) {
|
|
@@ -178,7 +177,7 @@ let n = class extends w {
|
|
|
178
177
|
dir: this.localize.dir()
|
|
179
178
|
});
|
|
180
179
|
await g(this.popup.popup, e, t), this.emit("cx-after-show"), this.panel.assignedElements().forEach(async (i) => {
|
|
181
|
-
i instanceof
|
|
180
|
+
i instanceof d && i.variant === "multiple" && (await i.updateComplete, i.adjustMenuSize(0));
|
|
182
181
|
});
|
|
183
182
|
} else {
|
|
184
183
|
this.pendingFocusCancel?.(), this.pendingFocusCancel = null, this.emit("cx-hide"), this.removeOpenListeners(), await u(this);
|
|
@@ -186,59 +185,59 @@ let n = class extends w {
|
|
|
186
185
|
dir: this.localize.dir()
|
|
187
186
|
});
|
|
188
187
|
await g(this.popup.popup, e, t), this.panel.hidden = !0, this.popup.active = !1, this.emit("cx-after-hide"), this.panel.assignedElements().forEach(async (i) => {
|
|
189
|
-
i instanceof
|
|
188
|
+
i instanceof d && i.variant === "multiple" && i.resetActiveMenu();
|
|
190
189
|
});
|
|
191
190
|
}
|
|
192
191
|
}
|
|
193
192
|
render() {
|
|
194
|
-
return T`<cx-popup part="base" exportparts="popup:base__popup" id="dropdown" placement=${this.placement} distance=${this.distance} skidding=${this.skidding} strategy=${this.hoist ? "overlay" : "absolute"} ?flip=${!this.noFlip} shift auto-size="both" auto-size-padding="10" .autoSizeBoundary=${this.hoistBoundary} .flipBoundary=${this.hoistBoundary} .shiftBoundary=${this.hoistBoundary} flip-padding=${this.flipPadding} sync=${
|
|
193
|
+
return T`<cx-popup part="base" exportparts="popup:base__popup" id="dropdown" placement=${this.placement} distance=${this.distance} skidding=${this.skidding} strategy=${this.hoist ? "overlay" : "absolute"} ?flip=${!this.noFlip} shift auto-size="both" auto-size-padding="10" .autoSizeBoundary=${this.hoistBoundary} .flipBoundary=${this.hoistBoundary} .shiftBoundary=${this.hoistBoundary} flip-padding=${this.flipPadding} sync=${_(this.sync ? this.sync : void 0)} class=${O({
|
|
195
194
|
dropdown: !0,
|
|
196
195
|
"dropdown--open": this.open
|
|
197
196
|
})} auto-width-factor=${this.autoWidthFactor}><slot name="trigger" slot="anchor" part="trigger" class="dropdown__trigger" @click=${this.handleTriggerClick} @keydown=${this.handleTriggerKeyDown} @keyup=${this.handleTriggerKeyUp} @slotchange=${this.handleTriggerSlotChange}></slot><div aria-hidden=${this.open && this.hasSlotController.test("[default]") ? "false" : "true"} aria-labelledby="dropdown"><slot part="panel" class="dropdown__panel"></slot></div></cx-popup>`;
|
|
198
197
|
}
|
|
199
198
|
};
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
199
|
+
o.styles = [b, $];
|
|
200
|
+
o.dependencies = { "cx-popup": A };
|
|
201
|
+
n([
|
|
203
202
|
h(".dropdown")
|
|
204
|
-
],
|
|
205
|
-
|
|
203
|
+
], o.prototype, "popup", 2);
|
|
204
|
+
n([
|
|
206
205
|
h(".dropdown__trigger")
|
|
207
|
-
],
|
|
208
|
-
|
|
206
|
+
], o.prototype, "trigger", 2);
|
|
207
|
+
n([
|
|
209
208
|
h(".dropdown__panel")
|
|
210
|
-
],
|
|
211
|
-
|
|
209
|
+
], o.prototype, "panel", 2);
|
|
210
|
+
n([
|
|
212
211
|
s({ reflect: !0, type: Boolean })
|
|
213
|
-
],
|
|
214
|
-
|
|
212
|
+
], o.prototype, "open", 2);
|
|
213
|
+
n([
|
|
215
214
|
s({ reflect: !0 })
|
|
216
|
-
],
|
|
217
|
-
|
|
215
|
+
], o.prototype, "placement", 2);
|
|
216
|
+
n([
|
|
218
217
|
s({ reflect: !0, type: Boolean })
|
|
219
|
-
],
|
|
220
|
-
|
|
218
|
+
], o.prototype, "disabled", 2);
|
|
219
|
+
n([
|
|
221
220
|
s({ attribute: "stay-open-on-select", reflect: !0, type: Boolean })
|
|
222
|
-
],
|
|
223
|
-
|
|
221
|
+
], o.prototype, "stayOpenOnSelect", 2);
|
|
222
|
+
n([
|
|
224
223
|
s({ attribute: "containing-element" })
|
|
225
|
-
],
|
|
226
|
-
|
|
224
|
+
], o.prototype, "containingElement", 2);
|
|
225
|
+
n([
|
|
227
226
|
s({ type: Number })
|
|
228
|
-
],
|
|
229
|
-
|
|
227
|
+
], o.prototype, "distance", 2);
|
|
228
|
+
n([
|
|
230
229
|
s({ type: Number })
|
|
231
|
-
],
|
|
232
|
-
|
|
230
|
+
], o.prototype, "skidding", 2);
|
|
231
|
+
n([
|
|
233
232
|
s({ type: Boolean })
|
|
234
|
-
],
|
|
235
|
-
|
|
233
|
+
], o.prototype, "hoist", 2);
|
|
234
|
+
n([
|
|
236
235
|
s({ reflect: !0 })
|
|
237
|
-
],
|
|
238
|
-
|
|
236
|
+
], o.prototype, "sync", 2);
|
|
237
|
+
n([
|
|
239
238
|
s({ attribute: "auto-width-factor" })
|
|
240
|
-
],
|
|
241
|
-
|
|
239
|
+
], o.prototype, "autoWidthFactor", 2);
|
|
240
|
+
n([
|
|
242
241
|
s({
|
|
243
242
|
attribute: "ignored-keys",
|
|
244
243
|
converter: {
|
|
@@ -247,19 +246,19 @@ o([
|
|
|
247
246
|
},
|
|
248
247
|
type: String
|
|
249
248
|
})
|
|
250
|
-
],
|
|
251
|
-
|
|
249
|
+
], o.prototype, "ignoredKeys", 2);
|
|
250
|
+
n([
|
|
252
251
|
s({ attribute: "no-flip", reflect: !0, type: Boolean })
|
|
253
|
-
],
|
|
254
|
-
|
|
252
|
+
], o.prototype, "noFlip", 2);
|
|
253
|
+
n([
|
|
255
254
|
s({ attribute: "flip-padding", type: Number })
|
|
256
|
-
],
|
|
257
|
-
|
|
255
|
+
], o.prototype, "flipPadding", 2);
|
|
256
|
+
n([
|
|
258
257
|
D("open", { waitUntilFirstUpdate: !0 })
|
|
259
|
-
],
|
|
260
|
-
|
|
258
|
+
], o.prototype, "handleOpenChange", 1);
|
|
259
|
+
o = n([
|
|
261
260
|
v("cx-dropdown")
|
|
262
|
-
],
|
|
261
|
+
], o);
|
|
263
262
|
y("dropdown.show", {
|
|
264
263
|
keyframes: [
|
|
265
264
|
{ opacity: 0, scale: 0.9 },
|
|
@@ -275,5 +274,5 @@ y("dropdown.hide", {
|
|
|
275
274
|
options: { duration: 100, easing: "ease" }
|
|
276
275
|
});
|
|
277
276
|
export {
|
|
278
|
-
|
|
277
|
+
o as default
|
|
279
278
|
};
|
|
@@ -1,25 +1,26 @@
|
|
|
1
|
-
import { n as
|
|
2
|
-
import { c as
|
|
3
|
-
import { c as
|
|
1
|
+
import { n as d, C as v } from "../chunks/lib-cortex-element.CVMmyPMC.js";
|
|
2
|
+
import { c as y } from "../chunks/component.styles.CRO4Odto.js";
|
|
3
|
+
import { c as w } from "../chunks/custom-element.L4WJXn1j.js";
|
|
4
4
|
import { L as x } from "../chunks/i18n.CXIpdSSZ.js";
|
|
5
|
-
import { i as
|
|
6
|
-
import { r as
|
|
7
|
-
import { e as
|
|
5
|
+
import { i as k, x as b } from "../chunks/lit-element.jLBm65_O.js";
|
|
6
|
+
import { r as M } from "../chunks/state.CSDxrqLd.js";
|
|
7
|
+
import { e as g } from "../chunks/query.BBf1UFkC.js";
|
|
8
8
|
import { n as A } from "../chunks/when.Dr1es41R.js";
|
|
9
|
-
import
|
|
9
|
+
import S from "./menu-item.js";
|
|
10
10
|
var p = /* @__PURE__ */ ((e) => (e.Default = "default", e.Multiple = "multiple", e))(p || {});
|
|
11
|
-
const
|
|
12
|
-
var E = Object.defineProperty, C = Object.getOwnPropertyDescriptor, c = (e, t, i,
|
|
13
|
-
for (var
|
|
14
|
-
(
|
|
15
|
-
return
|
|
11
|
+
const I = k`:host{background:var(--cx-panel-background-color);border:solid var(--cx-panel-border-width) var(--cx-panel-border-color);border-radius:var(--cx-panel-border-radius,var(--cx-border-radius-large));padding:var(--cx-panel-padding,var(--cx-spacing-x-small) 0);--divider-color:var(--cx-panel-border-color);--divider-width:var(--cx-panel-border-width);--divider-spacing:var(--cx-spacing-x-small);display:block;position:relative;overflow:auto}:host([horizontal]){padding:0 var(--cx-spacing-x-small);flex-wrap:wrap;justify-content:space-between;display:flex}::slotted(cx-divider){--color:var(--divider-color);--width:var(--divider-width);--spacing:var(--divider-spacing)}::slotted([data-alternating-grouping]):before{content:" ";background-color:var(--divider-color);margin:var(--divider-spacing) 0;height:var(--divider-width);display:block}::slotted([data-alternating-grouping=horizontal]):before{height:100%;margin:0 var(--divider-spacing);width:var(--divider-width);display:inline-block}:host([horizontal]) ::slotted(cx-menu-section){flex-wrap:wrap;justify-content:space-between;display:flex}:host([horizontal]) ::slotted(cx-menu-item){display:flex}:host([variant=multiple]){position:relative;overflow:hidden}:host([variant=multiple]) ::slotted(cx-menu[name]){opacity:0;pointer-events:none;transition:opacity var(--cx-transition-fast) ease-in-out, transform var(--cx-transition-medium) ease-in-out;border:none;top:0;left:0;transform:translate(-50%);position:absolute!important}:host([variant=multiple]) ::slotted(cx-menu[active]){opacity:1;pointer-events:auto;transform:translate(0)}.back__button::part(checked-icon),.back__button::part(submenu-icon){display:none}.back__divider{--spacing:var(--cx-spacing-x-small)}`;
|
|
12
|
+
var E = Object.defineProperty, C = Object.getOwnPropertyDescriptor, c = (e, t, i, r) => {
|
|
13
|
+
for (var l = r > 1 ? void 0 : r ? C(t, i) : t, s = e.length - 1, u; s >= 0; s--)
|
|
14
|
+
(u = e[s]) && (l = (r ? u(t, i, l) : u(l)) || l);
|
|
15
|
+
return r && l && E(t, i, l), l;
|
|
16
16
|
};
|
|
17
|
-
function
|
|
18
|
-
return e.tagName.toLowerCase() === "cx-menu" && e instanceof
|
|
17
|
+
function m(e) {
|
|
18
|
+
return e.tagName.toLowerCase() === "cx-menu" && e instanceof a && e.getAttribute("role") === "menu" && // A hidden panel of a multiple menu is inert and can't take focus, so keyboard navigation skips it.
|
|
19
|
+
!e.inert;
|
|
19
20
|
}
|
|
20
|
-
let
|
|
21
|
+
let a = class extends v {
|
|
21
22
|
constructor() {
|
|
22
|
-
super(...arguments), this.localize = new x(this), this.horizontal = !1, this.variant = p.Default, this.active = !1, this.name = "", this.back = "", this.default = !1, this.bubbleKeyDown = !1, this.ignoredKeys = [], this.
|
|
23
|
+
super(...arguments), this.localize = new x(this), this.horizontal = !1, this.variant = p.Default, this.active = !1, this.name = "", this.back = "", this.default = !1, this.bubbleKeyDown = !1, this.ignoredKeys = [], this.noUncheck = !1, this.resizeObserver = null, this.slotMutationObserver = null;
|
|
23
24
|
}
|
|
24
25
|
connectedCallback() {
|
|
25
26
|
super.connectedCallback(), this.slotMutationObserver = new MutationObserver((e) => {
|
|
@@ -48,22 +49,22 @@ let l = class extends g {
|
|
|
48
49
|
}
|
|
49
50
|
}
|
|
50
51
|
handleClick(e) {
|
|
51
|
-
const t = ["menuitem", "menuitemcheckbox"], i = e.composedPath(),
|
|
52
|
+
const t = ["menuitem", "menuitemcheckbox"], i = e.composedPath(), r = i.find(
|
|
52
53
|
(n) => t.includes(n?.getAttribute?.("role") || "")
|
|
53
54
|
);
|
|
54
|
-
if (!
|
|
55
|
+
if (!r)
|
|
55
56
|
return;
|
|
56
|
-
const
|
|
57
|
-
if (
|
|
58
|
-
this.setActiveMenu(
|
|
57
|
+
const l = r.getAttribute("menu");
|
|
58
|
+
if (l) {
|
|
59
|
+
this.setActiveMenu(l);
|
|
59
60
|
return;
|
|
60
61
|
}
|
|
61
62
|
if (i.find(
|
|
62
63
|
(n) => n?.getAttribute?.("role") === "menu"
|
|
63
64
|
) !== this)
|
|
64
65
|
return;
|
|
65
|
-
const
|
|
66
|
-
|
|
66
|
+
const h = r;
|
|
67
|
+
h.type === "checkbox" && (h.checked && (this.noUncheck || h.noUncheck) || (h.checked = !h.checked)), this.emit("cx-select", { detail: { item: h } });
|
|
67
68
|
}
|
|
68
69
|
handleKeyDown(e) {
|
|
69
70
|
if (this.ignoredKeys.includes(e.key))
|
|
@@ -79,98 +80,98 @@ let l = class extends g {
|
|
|
79
80
|
"ArrowLeft",
|
|
80
81
|
"ArrowRight"
|
|
81
82
|
].includes(e.key)) {
|
|
82
|
-
const
|
|
83
|
-
let
|
|
84
|
-
if (
|
|
85
|
-
const
|
|
83
|
+
const r = this.getAllItems(), l = i ? r.indexOf(i) : -1;
|
|
84
|
+
let s = l === -1 ? r.findIndex((u) => u.getAttribute("tabindex") === "0") : l;
|
|
85
|
+
if (s === -1 && (s = 0), ["ArrowLeft", "ArrowRight"].includes(e.key) && !this.bubbleKeyDown && !(this.parentElement instanceof a) && !(this.parentElement instanceof S) && e.stopPropagation(), r.length > 0) {
|
|
86
|
+
const u = this.horizontal ? e.key === "ArrowRight" || s === r.length - 1 && e.key === "ArrowDown" : e.key === "ArrowDown", h = this.horizontal ? e.key === "ArrowLeft" || s === 0 && e.key === "ArrowUp" : e.key === "ArrowUp";
|
|
86
87
|
if (["ArrowRight", "ArrowDown", "ArrowLeft", "ArrowUp"].includes(
|
|
87
88
|
e.key
|
|
88
|
-
) && !
|
|
89
|
+
) && !u && !h)
|
|
89
90
|
return;
|
|
90
|
-
if (this.bubbleKeyDown || e.stopPropagation(),
|
|
91
|
-
|
|
92
|
-
else if (
|
|
93
|
-
|
|
91
|
+
if (this.bubbleKeyDown || e.stopPropagation(), u)
|
|
92
|
+
s++;
|
|
93
|
+
else if (h)
|
|
94
|
+
s--;
|
|
94
95
|
else if (e.key === "Home") {
|
|
95
96
|
e.preventDefault();
|
|
96
97
|
let n = this.parentElement?.firstElementChild;
|
|
97
|
-
for (; n && !
|
|
98
|
+
for (; n && !m(n); )
|
|
98
99
|
n = n.nextElementSibling;
|
|
99
100
|
if (n) {
|
|
100
|
-
const
|
|
101
|
-
if (
|
|
102
|
-
|
|
101
|
+
const o = n.getAllItems();
|
|
102
|
+
if (o.length > 0) {
|
|
103
|
+
o[0].focus();
|
|
103
104
|
return;
|
|
104
105
|
}
|
|
105
106
|
}
|
|
106
|
-
|
|
107
|
+
s = 0;
|
|
107
108
|
} else if (e.key === "End") {
|
|
108
109
|
e.preventDefault();
|
|
109
110
|
let n = this.parentElement?.lastElementChild;
|
|
110
|
-
for (; n && !
|
|
111
|
+
for (; n && !m(n); )
|
|
111
112
|
n = n.previousElementSibling;
|
|
112
113
|
if (n) {
|
|
113
|
-
const
|
|
114
|
-
if (
|
|
115
|
-
|
|
114
|
+
const o = n.getAllItems();
|
|
115
|
+
if (o.length > 0) {
|
|
116
|
+
o[o.length - 1].focus();
|
|
116
117
|
return;
|
|
117
118
|
}
|
|
118
119
|
}
|
|
119
|
-
|
|
120
|
+
s = 0;
|
|
120
121
|
}
|
|
121
|
-
if (
|
|
122
|
+
if (s < 0) {
|
|
122
123
|
e.preventDefault();
|
|
123
124
|
let n = this.previousElementSibling;
|
|
124
|
-
for (; n && !
|
|
125
|
+
for (; n && !m(n); )
|
|
125
126
|
n = n.previousElementSibling;
|
|
126
127
|
if (n) {
|
|
127
|
-
const
|
|
128
|
-
if (
|
|
129
|
-
|
|
128
|
+
const o = n.getAllItems();
|
|
129
|
+
if (o.length > 0) {
|
|
130
|
+
o[o.length - 1].focus();
|
|
130
131
|
return;
|
|
131
132
|
}
|
|
132
133
|
} else {
|
|
133
|
-
let
|
|
134
|
-
for (;
|
|
135
|
-
|
|
136
|
-
if (
|
|
137
|
-
const
|
|
138
|
-
if (
|
|
139
|
-
|
|
134
|
+
let o = this.parentElement?.lastElementChild;
|
|
135
|
+
for (; o && !m(o); )
|
|
136
|
+
o = o.previousElementSibling;
|
|
137
|
+
if (o) {
|
|
138
|
+
const f = o.getAllItems();
|
|
139
|
+
if (f.length > 0) {
|
|
140
|
+
f[f.length - 1].focus();
|
|
140
141
|
return;
|
|
141
142
|
}
|
|
142
143
|
}
|
|
143
|
-
|
|
144
|
+
s = 0;
|
|
144
145
|
}
|
|
145
146
|
}
|
|
146
|
-
if (
|
|
147
|
+
if (s > r.length - 1) {
|
|
147
148
|
e.preventDefault();
|
|
148
149
|
let n = this.nextElementSibling;
|
|
149
|
-
for (; n && !
|
|
150
|
+
for (; n && !m(n); )
|
|
150
151
|
n = n.nextElementSibling;
|
|
151
152
|
if (n) {
|
|
152
|
-
const
|
|
153
|
-
if (
|
|
154
|
-
|
|
153
|
+
const o = n.getAllItems();
|
|
154
|
+
if (o.length > 0) {
|
|
155
|
+
o[0].focus();
|
|
155
156
|
return;
|
|
156
157
|
}
|
|
157
158
|
} else {
|
|
158
|
-
let
|
|
159
|
-
for (;
|
|
160
|
-
|
|
161
|
-
if (
|
|
162
|
-
const
|
|
163
|
-
if (
|
|
164
|
-
|
|
159
|
+
let o = this.parentElement?.firstElementChild;
|
|
160
|
+
for (; o && !m(o); )
|
|
161
|
+
o = o.nextElementSibling;
|
|
162
|
+
if (o) {
|
|
163
|
+
const f = o.getAllItems();
|
|
164
|
+
if (f.length > 0) {
|
|
165
|
+
f[0].focus();
|
|
165
166
|
return;
|
|
166
167
|
}
|
|
167
168
|
}
|
|
168
|
-
|
|
169
|
+
s = 0;
|
|
169
170
|
}
|
|
170
171
|
}
|
|
171
|
-
if (
|
|
172
|
+
if (s < 0 || s > r.length - 1)
|
|
172
173
|
return;
|
|
173
|
-
e.preventDefault(), s
|
|
174
|
+
e.preventDefault(), r[s].focus();
|
|
174
175
|
}
|
|
175
176
|
}
|
|
176
177
|
}
|
|
@@ -185,11 +186,11 @@ let l = class extends g {
|
|
|
185
186
|
const i = t;
|
|
186
187
|
return this.isMenuItem(i) || this.isMenuSection(i);
|
|
187
188
|
}).forEach((t) => {
|
|
188
|
-
const i = t,
|
|
189
|
-
e &&
|
|
189
|
+
const i = t, r = !i.inert && !i.hasAttribute("is-empty");
|
|
190
|
+
e && r && (this.isMenuSection(e) && this.isMenuItem(i) || this.isMenuSection(i) && i.childElementCount > 0) ? i.setAttribute(
|
|
190
191
|
"data-alternating-grouping",
|
|
191
192
|
this.horizontal ? "horizontal" : ""
|
|
192
|
-
) : i.removeAttribute("data-alternating-grouping"),
|
|
193
|
+
) : i.removeAttribute("data-alternating-grouping"), r && (e = i);
|
|
193
194
|
});
|
|
194
195
|
}
|
|
195
196
|
/** Sets `tabindex="0"` on the selected item (`checked`/`active`), or the first item if none is selected. */
|
|
@@ -215,9 +216,16 @@ let l = class extends g {
|
|
|
215
216
|
e.getAttribute("role") ?? ""
|
|
216
217
|
) : !1;
|
|
217
218
|
}
|
|
218
|
-
/**
|
|
219
|
+
/** Focuses a panel's tab stop, so focus doesn't stay behind in the panel that is being hidden. */
|
|
220
|
+
focusPanelTabStop(e) {
|
|
221
|
+
const t = e.getAllItems();
|
|
222
|
+
(t.find((r) => r.getAttribute("tabindex") === "0") ?? t[0])?.focus({ preventScroll: !0 });
|
|
223
|
+
}
|
|
224
|
+
/** @internal Gets all menu items, back button first, ignoring dividers, headers, and other elements. */
|
|
219
225
|
getAllItems() {
|
|
220
|
-
return this.defaultSlot.assignedElements({ flatten: !0 }).flatMap(
|
|
226
|
+
return [this.backSlot, this.defaultSlot].flatMap((t) => t?.assignedElements({ flatten: !0 }) ?? []).flatMap(
|
|
227
|
+
(t) => t.slot === "back-button" && !this.isMenuItem(t) ? [...t.children] : t
|
|
228
|
+
).flatMap((t) => {
|
|
221
229
|
if (this.isMenuSection(t)) {
|
|
222
230
|
const i = t.shadowRoot?.querySelector("slot");
|
|
223
231
|
return i ? [...i.assignedElements({ flatten: !0 })] : [];
|
|
@@ -230,26 +238,28 @@ let l = class extends g {
|
|
|
230
238
|
return [...this.querySelectorAll("cx-menu")];
|
|
231
239
|
}
|
|
232
240
|
setActiveMenu(e) {
|
|
233
|
-
const t = this.getAllSubMenus();
|
|
234
|
-
let
|
|
241
|
+
const t = this.getAllSubMenus(), i = this.variant === p.Multiple, r = i && this.matches(":focus-within");
|
|
242
|
+
let l = null;
|
|
235
243
|
t.forEach((s) => {
|
|
236
|
-
s.name === e ? (s.active = !0,
|
|
237
|
-
}), this.adjustMenuSize(),
|
|
244
|
+
s.name === e ? (s.active = !0, l = s) : s.active = !1;
|
|
245
|
+
}), this.adjustMenuSize(), l && (this.resizeObserver && (this.resizeObserver.disconnect(), this.resizeObserver = null), this.resizeObserver = new ResizeObserver(() => {
|
|
238
246
|
this.adjustMenuSize();
|
|
239
|
-
}), this.resizeObserver.observe(i)
|
|
247
|
+
}), this.resizeObserver.observe(l), r && (l.inert = !1, this.focusPanelTabStop(l))), i && t.forEach((s) => {
|
|
248
|
+
s.parentElement === this && (s.inert = !s.active);
|
|
249
|
+
});
|
|
240
250
|
}
|
|
241
251
|
async adjustMenuSize(e = 250) {
|
|
242
252
|
const t = this.getActiveMenu();
|
|
243
253
|
if (t) {
|
|
244
254
|
await t.updateComplete;
|
|
245
|
-
const i = t.offsetWidth,
|
|
255
|
+
const i = t.offsetWidth, r = t.offsetHeight;
|
|
246
256
|
this.animate(
|
|
247
257
|
[
|
|
248
258
|
{
|
|
249
|
-
height: this.style.height ?? `${
|
|
259
|
+
height: this.style.height ?? `${r}px`,
|
|
250
260
|
width: this.style.width ?? `${i}px`
|
|
251
261
|
},
|
|
252
|
-
{ height: `${
|
|
262
|
+
{ height: `${r}px`, width: `${i}px` }
|
|
253
263
|
// Fade out
|
|
254
264
|
],
|
|
255
265
|
{
|
|
@@ -275,38 +285,41 @@ let l = class extends g {
|
|
|
275
285
|
render() {
|
|
276
286
|
const e = A(
|
|
277
287
|
this.back,
|
|
278
|
-
() => b`<slot name="back-button" role="menuitem" menu=${this.back}><cx-menu-item part="back-button" class="back__button" menu=${this.back}><cx-icon slot="prefix" name="chevron_left"></cx-icon>${this.localize.term("back")}</cx-menu-item><cx-divider class="back__divider"></cx-divider></slot>`
|
|
288
|
+
() => b`<slot name="back-button" role="menuitem" menu=${this.back} @slotchange=${this.handleSlotChange} @keydown=${this.handleKeyDown}><cx-menu-item part="back-button" class="back__button" menu=${this.back}><cx-icon slot="prefix" name="chevron_left"></cx-icon>${this.localize.term("back")}</cx-menu-item><cx-divider class="back__divider"></cx-divider></slot>`
|
|
279
289
|
);
|
|
280
290
|
return this.variant === p.Multiple ? b`${e}<slot @slotchange=${this.handleSlotChange} @click=${this.handleClick} @keydown=${this.handleKeyDown} @mousedown=${this.handleMouseDown}></slot>` : b`${e}<slot @slotchange=${this.handleSlotChange} @click=${this.handleClick} @keydown=${this.handleKeyDown} @mousedown=${this.handleMouseDown}></slot>`;
|
|
281
291
|
}
|
|
282
292
|
};
|
|
283
|
-
|
|
293
|
+
a.styles = [y, I];
|
|
284
294
|
c([
|
|
285
|
-
|
|
286
|
-
],
|
|
295
|
+
g("slot:not([name])")
|
|
296
|
+
], a.prototype, "defaultSlot", 2);
|
|
287
297
|
c([
|
|
288
|
-
|
|
289
|
-
],
|
|
298
|
+
g('slot[name="back-button"]')
|
|
299
|
+
], a.prototype, "backSlot", 2);
|
|
290
300
|
c([
|
|
291
|
-
|
|
292
|
-
],
|
|
301
|
+
d({ type: Boolean })
|
|
302
|
+
], a.prototype, "horizontal", 2);
|
|
293
303
|
c([
|
|
294
|
-
|
|
295
|
-
],
|
|
304
|
+
d({ reflect: !0 })
|
|
305
|
+
], a.prototype, "variant", 2);
|
|
296
306
|
c([
|
|
297
|
-
|
|
298
|
-
],
|
|
307
|
+
d({ reflect: !0, type: Boolean })
|
|
308
|
+
], a.prototype, "active", 2);
|
|
299
309
|
c([
|
|
300
|
-
|
|
301
|
-
],
|
|
310
|
+
d({ reflect: !0 })
|
|
311
|
+
], a.prototype, "name", 2);
|
|
302
312
|
c([
|
|
303
|
-
|
|
304
|
-
],
|
|
313
|
+
d({ reflect: !0 })
|
|
314
|
+
], a.prototype, "back", 2);
|
|
305
315
|
c([
|
|
306
|
-
|
|
307
|
-
],
|
|
316
|
+
d({ reflect: !0, type: Boolean })
|
|
317
|
+
], a.prototype, "default", 2);
|
|
308
318
|
c([
|
|
309
|
-
|
|
319
|
+
d({ attribute: "bubble-keydown", reflect: !0, type: Boolean })
|
|
320
|
+
], a.prototype, "bubbleKeyDown", 2);
|
|
321
|
+
c([
|
|
322
|
+
d({
|
|
310
323
|
attribute: "ignored-keys",
|
|
311
324
|
converter: {
|
|
312
325
|
fromAttribute: (e) => e?.split(" ") ?? [],
|
|
@@ -314,19 +327,16 @@ c([
|
|
|
314
327
|
},
|
|
315
328
|
type: String
|
|
316
329
|
})
|
|
317
|
-
],
|
|
318
|
-
c([
|
|
319
|
-
u({ attribute: "disabled-tab-loop", reflect: !0, type: Boolean })
|
|
320
|
-
], l.prototype, "disabledTabLoop", 2);
|
|
330
|
+
], a.prototype, "ignoredKeys", 2);
|
|
321
331
|
c([
|
|
322
|
-
|
|
323
|
-
],
|
|
332
|
+
d({ attribute: "no-uncheck", reflect: !0, type: Boolean })
|
|
333
|
+
], a.prototype, "noUncheck", 2);
|
|
324
334
|
c([
|
|
325
|
-
|
|
326
|
-
],
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
],
|
|
335
|
+
M()
|
|
336
|
+
], a.prototype, "resizeObserver", 2);
|
|
337
|
+
a = c([
|
|
338
|
+
w("cx-menu")
|
|
339
|
+
], a);
|
|
330
340
|
export {
|
|
331
|
-
|
|
341
|
+
a as default
|
|
332
342
|
};
|
package/library/package.json
CHANGED
|
@@ -111,7 +111,6 @@ export default class CxDropdown extends CortexElement {
|
|
|
111
111
|
private handleKeyDown;
|
|
112
112
|
private handleDocumentKeyDown;
|
|
113
113
|
private handleDocumentMouseDown;
|
|
114
|
-
private handleDocumentFocusIn;
|
|
115
114
|
private handlePanelSelect;
|
|
116
115
|
handleTriggerClick(): Promise<void>;
|
|
117
116
|
handleTriggerKeyDown(event: KeyboardEvent): void;
|
|
@@ -24,6 +24,7 @@ export default class CxMenu extends CortexElement {
|
|
|
24
24
|
static styles: CSSResultGroup;
|
|
25
25
|
private readonly localize;
|
|
26
26
|
defaultSlot: HTMLSlotElement;
|
|
27
|
+
backSlot: HTMLSlotElement | null;
|
|
27
28
|
horizontal: boolean;
|
|
28
29
|
/** The menu's variant */
|
|
29
30
|
variant: MenuMode.Default | MenuMode.Multiple;
|
|
@@ -39,8 +40,6 @@ export default class CxMenu extends CortexElement {
|
|
|
39
40
|
bubbleKeyDown: boolean;
|
|
40
41
|
/** Override the default keydown navigation behavior of the dropdown menu. */
|
|
41
42
|
ignoredKeys: string[];
|
|
42
|
-
/** @deprecated Only stops ArrowUp/ArrowDown wrapping now; Tab is no longer intercepted. */
|
|
43
|
-
disabledTabLoop: boolean;
|
|
44
43
|
/** When true, checkbox items don't toggle off when already checked (same as each item's own `no-uncheck`). */
|
|
45
44
|
noUncheck: boolean;
|
|
46
45
|
resizeObserver: ResizeObserver | null;
|
|
@@ -58,7 +57,9 @@ export default class CxMenu extends CortexElement {
|
|
|
58
57
|
private setRovingTabIndex;
|
|
59
58
|
private isMenuSection;
|
|
60
59
|
private isMenuItem;
|
|
61
|
-
/**
|
|
60
|
+
/** Focuses a panel's tab stop, so focus doesn't stay behind in the panel that is being hidden. */
|
|
61
|
+
private focusPanelTabStop;
|
|
62
|
+
/** @internal Gets all menu items, back button first, ignoring dividers, headers, and other elements. */
|
|
62
63
|
getAllItems(): CxMenuItem[];
|
|
63
64
|
/** @internal Gets all slotted submenus, used for 'multiple' variant */
|
|
64
65
|
getAllSubMenus(): CxMenu[];
|
|
@@ -5006,10 +5006,6 @@ interface CxMenuAttributes extends HTMLAttributes<CxMenu> {
|
|
|
5006
5006
|
* Override the default keydown navigation behavior of the dropdown menu.
|
|
5007
5007
|
*/
|
|
5008
5008
|
ignoredKeys?: string[];
|
|
5009
|
-
/**
|
|
5010
|
-
*
|
|
5011
|
-
*/
|
|
5012
|
-
disabledTabLoop?: boolean;
|
|
5013
5009
|
/**
|
|
5014
5010
|
* When true, checkbox items in this menu do not toggle off when already activated while checked—the same behavior as setting `no-uncheck` on each checkbox item.
|
|
5015
5011
|
*/
|
|
@@ -865,10 +865,6 @@
|
|
|
865
865
|
* Override the default keydown navigation behavior of the dropdown menu.
|
|
866
866
|
*/
|
|
867
867
|
ignoredKeys?: string[];
|
|
868
|
-
/**
|
|
869
|
-
* @deprecated Only stops ArrowUp/ArrowDown wrapping now; Tab is no longer intercepted.
|
|
870
|
-
*/
|
|
871
|
-
disabledTabLoop?: boolean;
|
|
872
868
|
/**
|
|
873
869
|
* When true, checkbox items don't toggle off when already checked (same as each item's own `no-uncheck`).
|
|
874
870
|
*/
|