@orangelogic/design-system 2.208.0 → 2.210.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.
|
@@ -4,17 +4,17 @@ import { c as y } from "../chunks/custom-element.L4WJXn1j.js";
|
|
|
4
4
|
import { L as x } from "../chunks/i18n.DbXTTLXx.js";
|
|
5
5
|
import { i as w, x as b } from "../chunks/lit-element.jLBm65_O.js";
|
|
6
6
|
import { r as k } from "../chunks/state.CSDxrqLd.js";
|
|
7
|
-
import { e as
|
|
8
|
-
import { n as
|
|
9
|
-
import
|
|
7
|
+
import { e as M } from "../chunks/query.BBf1UFkC.js";
|
|
8
|
+
import { n as A } from "../chunks/when.Dr1es41R.js";
|
|
9
|
+
import I 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,
|
|
13
|
-
for (var a = s > 1 ? void 0 : s ? C(
|
|
14
|
-
(h = e[o]) && (a = (s ? h(
|
|
15
|
-
return s && a && E(
|
|
11
|
+
const S = w`: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, s) => {
|
|
13
|
+
for (var a = s > 1 ? void 0 : s ? C(t, i) : t, o = e.length - 1, h; o >= 0; o--)
|
|
14
|
+
(h = e[o]) && (a = (s ? h(t, i, a) : h(a)) || a);
|
|
15
|
+
return s && a && E(t, i, a), a;
|
|
16
16
|
};
|
|
17
|
-
function
|
|
17
|
+
function f(e) {
|
|
18
18
|
return e.tagName.toLowerCase() === "cx-menu" && e instanceof l && e.getAttribute("role") === "menu";
|
|
19
19
|
}
|
|
20
20
|
let l = class extends g {
|
|
@@ -24,7 +24,7 @@ let l = class extends g {
|
|
|
24
24
|
connectedCallback() {
|
|
25
25
|
super.connectedCallback(), this.slotMutationObserver = new MutationObserver((e) => {
|
|
26
26
|
if (e.every(
|
|
27
|
-
(
|
|
27
|
+
(i) => i.type === "attributes" && (i.attributeName === "checked" || i.attributeName === "active")
|
|
28
28
|
)) {
|
|
29
29
|
this.syncTabIndexToSelection();
|
|
30
30
|
return;
|
|
@@ -48,8 +48,8 @@ let l = class extends g {
|
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
handleClick(e) {
|
|
51
|
-
const
|
|
52
|
-
(n) =>
|
|
51
|
+
const t = ["menuitem", "menuitemcheckbox"], i = e.composedPath(), s = i.find(
|
|
52
|
+
(n) => t.includes(n?.getAttribute?.("role") || "")
|
|
53
53
|
);
|
|
54
54
|
if (!s)
|
|
55
55
|
return;
|
|
@@ -58,7 +58,7 @@ let l = class extends g {
|
|
|
58
58
|
this.setActiveMenu(a);
|
|
59
59
|
return;
|
|
60
60
|
}
|
|
61
|
-
if (
|
|
61
|
+
if (i.find(
|
|
62
62
|
(n) => n?.getAttribute?.("role") === "menu"
|
|
63
63
|
) !== this)
|
|
64
64
|
return;
|
|
@@ -68,9 +68,9 @@ let l = class extends g {
|
|
|
68
68
|
handleKeyDown(e) {
|
|
69
69
|
if (this.ignoredKeys.includes(e.key))
|
|
70
70
|
return;
|
|
71
|
-
const
|
|
72
|
-
if (
|
|
73
|
-
e.preventDefault(), this.bubbleKeyDown || e.stopPropagation(),
|
|
71
|
+
const t = e.target, i = this.isMenuItem(t) ? t : void 0;
|
|
72
|
+
if (i && (e.key === "Enter" || e.key === " "))
|
|
73
|
+
e.preventDefault(), this.bubbleKeyDown || e.stopPropagation(), i.click();
|
|
74
74
|
else if ([
|
|
75
75
|
"Home",
|
|
76
76
|
"End",
|
|
@@ -79,9 +79,9 @@ let l = class extends g {
|
|
|
79
79
|
"ArrowLeft",
|
|
80
80
|
"ArrowRight"
|
|
81
81
|
].includes(e.key)) {
|
|
82
|
-
const s = this.getAllItems(), a =
|
|
82
|
+
const s = this.getAllItems(), a = i ? s.indexOf(i) : -1;
|
|
83
83
|
let o = a === -1 ? s.findIndex((h) => h.getAttribute("tabindex") === "0") : a;
|
|
84
|
-
if (o === -1 && (o = 0), ["ArrowLeft", "ArrowRight"].includes(e.key) && !this.bubbleKeyDown && !(this.parentElement instanceof l) && !(this.parentElement instanceof
|
|
84
|
+
if (o === -1 && (o = 0), ["ArrowLeft", "ArrowRight"].includes(e.key) && !this.bubbleKeyDown && !(this.parentElement instanceof l) && !(this.parentElement instanceof I) && e.stopPropagation(), s.length > 0) {
|
|
85
85
|
const h = this.horizontal ? e.key === "ArrowRight" || o === s.length - 1 && e.key === "ArrowDown" : e.key === "ArrowDown", d = this.horizontal ? e.key === "ArrowLeft" || o === 0 && e.key === "ArrowUp" : e.key === "ArrowUp";
|
|
86
86
|
if (["ArrowRight", "ArrowDown", "ArrowLeft", "ArrowUp"].includes(
|
|
87
87
|
e.key
|
|
@@ -94,7 +94,7 @@ let l = class extends g {
|
|
|
94
94
|
else if (e.key === "Home") {
|
|
95
95
|
e.preventDefault();
|
|
96
96
|
let n = this.parentElement?.firstElementChild;
|
|
97
|
-
for (; n && !
|
|
97
|
+
for (; n && !f(n); )
|
|
98
98
|
n = n.nextElementSibling;
|
|
99
99
|
if (n) {
|
|
100
100
|
const r = n.getAllItems();
|
|
@@ -107,7 +107,7 @@ let l = class extends g {
|
|
|
107
107
|
} else if (e.key === "End") {
|
|
108
108
|
e.preventDefault();
|
|
109
109
|
let n = this.parentElement?.lastElementChild;
|
|
110
|
-
for (; n && !
|
|
110
|
+
for (; n && !f(n); )
|
|
111
111
|
n = n.previousElementSibling;
|
|
112
112
|
if (n) {
|
|
113
113
|
const r = n.getAllItems();
|
|
@@ -121,7 +121,7 @@ let l = class extends g {
|
|
|
121
121
|
if (o < 0 && !this.disabledTabLoop) {
|
|
122
122
|
e.preventDefault();
|
|
123
123
|
let n = this.previousElementSibling;
|
|
124
|
-
for (; n && !
|
|
124
|
+
for (; n && !f(n); )
|
|
125
125
|
n = n.previousElementSibling;
|
|
126
126
|
if (n) {
|
|
127
127
|
const r = n.getAllItems();
|
|
@@ -131,12 +131,12 @@ let l = class extends g {
|
|
|
131
131
|
}
|
|
132
132
|
} else {
|
|
133
133
|
let r = this.parentElement?.lastElementChild;
|
|
134
|
-
for (; r && !
|
|
134
|
+
for (; r && !f(r); )
|
|
135
135
|
r = r.previousElementSibling;
|
|
136
136
|
if (r) {
|
|
137
|
-
const
|
|
138
|
-
if (
|
|
139
|
-
|
|
137
|
+
const m = r.getAllItems();
|
|
138
|
+
if (m.length > 0) {
|
|
139
|
+
m[m.length - 1].focus();
|
|
140
140
|
return;
|
|
141
141
|
}
|
|
142
142
|
}
|
|
@@ -146,7 +146,7 @@ let l = class extends g {
|
|
|
146
146
|
if (o > s.length - 1 && !this.disabledTabLoop) {
|
|
147
147
|
e.preventDefault();
|
|
148
148
|
let n = this.nextElementSibling;
|
|
149
|
-
for (; n && !
|
|
149
|
+
for (; n && !f(n); )
|
|
150
150
|
n = n.nextElementSibling;
|
|
151
151
|
if (n) {
|
|
152
152
|
const r = n.getAllItems();
|
|
@@ -156,12 +156,12 @@ let l = class extends g {
|
|
|
156
156
|
}
|
|
157
157
|
} else {
|
|
158
158
|
let r = this.parentElement?.firstElementChild;
|
|
159
|
-
for (; r && !
|
|
159
|
+
for (; r && !f(r); )
|
|
160
160
|
r = r.nextElementSibling;
|
|
161
161
|
if (r) {
|
|
162
|
-
const
|
|
163
|
-
if (
|
|
164
|
-
|
|
162
|
+
const m = r.getAllItems();
|
|
163
|
+
if (m.length > 0) {
|
|
164
|
+
m[0].focus();
|
|
165
165
|
return;
|
|
166
166
|
}
|
|
167
167
|
}
|
|
@@ -174,18 +174,22 @@ let l = class extends g {
|
|
|
174
174
|
}
|
|
175
175
|
}
|
|
176
176
|
}
|
|
177
|
+
handleMouseDown(e) {
|
|
178
|
+
const t = e.target;
|
|
179
|
+
this.isMenuItem(t) && this.setCurrentItem(t);
|
|
180
|
+
}
|
|
177
181
|
handleSlotChange() {
|
|
178
182
|
this.syncTabIndexToSelection();
|
|
179
183
|
let e = null;
|
|
180
|
-
this.defaultSlot.assignedElements().filter((
|
|
181
|
-
const
|
|
182
|
-
return this.isMenuItem(
|
|
183
|
-
}).forEach((
|
|
184
|
-
const
|
|
185
|
-
e && s && (this.isMenuSection(e) && this.isMenuItem(
|
|
184
|
+
this.defaultSlot.assignedElements().filter((t) => {
|
|
185
|
+
const i = t;
|
|
186
|
+
return this.isMenuItem(i) || this.isMenuSection(i);
|
|
187
|
+
}).forEach((t) => {
|
|
188
|
+
const i = t, s = !i.inert && !i.hasAttribute("is-empty");
|
|
189
|
+
e && s && (this.isMenuSection(e) && this.isMenuItem(i) || this.isMenuSection(i) && i.childElementCount > 0) ? i.setAttribute(
|
|
186
190
|
"data-alternating-grouping",
|
|
187
191
|
this.horizontal ? "horizontal" : ""
|
|
188
|
-
) :
|
|
192
|
+
) : i.removeAttribute("data-alternating-grouping"), s && (e = i);
|
|
189
193
|
});
|
|
190
194
|
}
|
|
191
195
|
/** Sets `tabindex="0"` on the selected item (`checked`/`active`), or the first item if none is selected. */
|
|
@@ -193,15 +197,15 @@ let l = class extends g {
|
|
|
193
197
|
const e = this.getAllItems();
|
|
194
198
|
if (e.length === 0)
|
|
195
199
|
return;
|
|
196
|
-
let
|
|
197
|
-
for (const
|
|
198
|
-
|
|
199
|
-
(
|
|
200
|
+
let t;
|
|
201
|
+
for (const i of e)
|
|
202
|
+
i.setAttribute("tabindex", "-1"), !t && (i.checked || i.active) && (t = i);
|
|
203
|
+
(t ?? e[0]).setAttribute("tabindex", "0");
|
|
200
204
|
}
|
|
201
205
|
/** Moves `tabindex="0"` directly to `item`; used by `setCurrentItem()` for explicit external placement. */
|
|
202
206
|
setRovingTabIndex(e) {
|
|
203
|
-
for (const
|
|
204
|
-
|
|
207
|
+
for (const t of this.getAllItems())
|
|
208
|
+
t.setAttribute("tabindex", t === e ? "0" : "-1");
|
|
205
209
|
}
|
|
206
210
|
isMenuSection(e) {
|
|
207
211
|
return e instanceof HTMLElement ? e.tagName.toLowerCase() === "cx-menu-section" : !1;
|
|
@@ -213,39 +217,39 @@ let l = class extends g {
|
|
|
213
217
|
}
|
|
214
218
|
/** @internal Gets all slotted menu items, ignoring dividers, headers, and other elements. */
|
|
215
219
|
getAllItems() {
|
|
216
|
-
return this.defaultSlot.assignedElements({ flatten: !0 }).flatMap((
|
|
217
|
-
if (this.isMenuSection(
|
|
218
|
-
const
|
|
219
|
-
return
|
|
220
|
+
return this.defaultSlot.assignedElements({ flatten: !0 }).flatMap((t) => {
|
|
221
|
+
if (this.isMenuSection(t)) {
|
|
222
|
+
const i = t.shadowRoot?.querySelector("slot");
|
|
223
|
+
return i ? [...i.assignedElements({ flatten: !0 })] : [];
|
|
220
224
|
}
|
|
221
|
-
return
|
|
222
|
-
}).filter((
|
|
225
|
+
return t;
|
|
226
|
+
}).filter((t) => !(t.inert || !this.isMenuItem(t)));
|
|
223
227
|
}
|
|
224
228
|
/** @internal Gets all slotted submenus, used for 'multiple' variant */
|
|
225
229
|
getAllSubMenus() {
|
|
226
230
|
return [...this.querySelectorAll("cx-menu")];
|
|
227
231
|
}
|
|
228
232
|
setActiveMenu(e) {
|
|
229
|
-
const
|
|
230
|
-
let
|
|
231
|
-
|
|
232
|
-
s.name === e ? (s.active = !0,
|
|
233
|
-
}), this.adjustMenuSize(),
|
|
233
|
+
const t = this.getAllSubMenus();
|
|
234
|
+
let i = null;
|
|
235
|
+
t.forEach((s) => {
|
|
236
|
+
s.name === e ? (s.active = !0, i = s) : s.active = !1;
|
|
237
|
+
}), this.adjustMenuSize(), i && (this.resizeObserver && (this.resizeObserver.disconnect(), this.resizeObserver = null), this.resizeObserver = new ResizeObserver(() => {
|
|
234
238
|
this.adjustMenuSize();
|
|
235
|
-
}), this.resizeObserver.observe(
|
|
239
|
+
}), this.resizeObserver.observe(i));
|
|
236
240
|
}
|
|
237
241
|
async adjustMenuSize(e = 250) {
|
|
238
|
-
const
|
|
239
|
-
if (
|
|
240
|
-
await
|
|
241
|
-
const
|
|
242
|
+
const t = this.getActiveMenu();
|
|
243
|
+
if (t) {
|
|
244
|
+
await t.updateComplete;
|
|
245
|
+
const i = t.offsetWidth, s = t.offsetHeight;
|
|
242
246
|
this.animate(
|
|
243
247
|
[
|
|
244
248
|
{
|
|
245
249
|
height: this.style.height ?? `${s}px`,
|
|
246
|
-
width: this.style.width ?? `${
|
|
250
|
+
width: this.style.width ?? `${i}px`
|
|
247
251
|
},
|
|
248
|
-
{ height: `${s}px`, width: `${
|
|
252
|
+
{ height: `${s}px`, width: `${i}px` }
|
|
249
253
|
// Fade out
|
|
250
254
|
],
|
|
251
255
|
{
|
|
@@ -257,28 +261,28 @@ let l = class extends g {
|
|
|
257
261
|
this.style.width = "", this.style.height = "";
|
|
258
262
|
}
|
|
259
263
|
resetActiveMenu() {
|
|
260
|
-
this.getAllSubMenus().forEach((
|
|
261
|
-
|
|
264
|
+
this.getAllSubMenus().forEach((t) => {
|
|
265
|
+
t.default && this.setActiveMenu(t.name);
|
|
262
266
|
});
|
|
263
267
|
}
|
|
264
268
|
getActiveMenu() {
|
|
265
|
-
return this.getAllSubMenus().find((
|
|
269
|
+
return this.getAllSubMenus().find((t) => t.active) || void 0;
|
|
266
270
|
}
|
|
267
271
|
/** @internal Sets `tabindex="0"` on `item` and `tabindex="-1"` on all others. Call before focusing a menu item. */
|
|
268
272
|
setCurrentItem(e) {
|
|
269
273
|
this.setRovingTabIndex(e);
|
|
270
274
|
}
|
|
271
275
|
render() {
|
|
272
|
-
const e =
|
|
276
|
+
const e = A(
|
|
273
277
|
this.back,
|
|
274
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>`
|
|
275
279
|
);
|
|
276
|
-
return this.variant === p.Multiple ? b`${e}<slot @slotchange=${this.handleSlotChange} @click=${this.handleClick} @keydown=${this.handleKeyDown}></slot>` : b`${e}<slot @slotchange=${this.handleSlotChange} @click=${this.handleClick} @keydown=${this.handleKeyDown}></slot>`;
|
|
280
|
+
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>`;
|
|
277
281
|
}
|
|
278
282
|
};
|
|
279
|
-
l.styles = [v,
|
|
283
|
+
l.styles = [v, S];
|
|
280
284
|
c([
|
|
281
|
-
|
|
285
|
+
M("slot:not([name])")
|
|
282
286
|
], l.prototype, "defaultSlot", 2);
|
|
283
287
|
c([
|
|
284
288
|
u({ type: Boolean })
|