@orangelogic/design-system 2.44.0 → 2.45.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.
Files changed (27) hide show
  1. package/library/chunks/{color-swatch-group.DrpRd8Xw.js → color-swatch-group.CMz7zQdk.js} +1 -1
  2. package/library/chunks/{file-on-demand.ZcYwCR_s.js → file-on-demand.CODE3g50.js} +1 -1
  3. package/library/chunks/{list-editor.B_BRQoUp.js → list-editor.BZMql0Tj.js} +1 -1
  4. package/library/chunks/ref.BDmlFGTP.js +99 -0
  5. package/library/chunks/{tab-group.g2uXM2W8.js → tab-group.uF5JbAGa.js} +1 -1
  6. package/library/chunks/{table.Be9berv0.js → table.D6Abk0xC.js} +1 -1
  7. package/library/components/atoms.js +3 -3
  8. package/library/components/color-swatch-group.js +2 -2
  9. package/library/components/file-on-demand.js +2 -2
  10. package/library/components/list-editor.js +2 -2
  11. package/library/components/menu-item.js +678 -13
  12. package/library/components/menu.js +1 -1
  13. package/library/components/molecules.js +1 -1
  14. package/library/components/organisms.js +2 -2
  15. package/library/components/range.js +535 -396
  16. package/library/components/tab-group.js +2 -2
  17. package/library/components/table.js +1 -1
  18. package/library/components/types.js +204 -189
  19. package/library/package.json +1 -1
  20. package/library/packages/atoms/src/components/range/mark-controller.d.ts +34 -0
  21. package/library/packages/atoms/src/components/range/range.d.ts +6 -8
  22. package/library/packages/atoms/src/components/range/range.utils.d.ts +58 -1
  23. package/library/packages/organisms/src/downloader/downloader.d.ts +1 -0
  24. package/library/packages/tools/src/fetch-image/fetch-image.d.ts +6 -1
  25. package/library/react-web-component.d.ts +4 -0
  26. package/package.json +1 -1
  27. package/library/chunks/menu-item.DOFCmq0Z.js +0 -775
@@ -1,15 +1,680 @@
1
- import "../chunks/custom-element.fmLrnDZr.js";
2
- import "../chunks/component.styles.DtouHn2g.js";
3
- import "../chunks/i18n.D33BKrRs.js";
4
- import "../chunks/slot.DJLm4Dig.js";
5
- import "../chunks/watch.BCJD77bD.js";
6
- import "../chunks/query.BBf1UFkC.js";
7
- import "../chunks/class-map.DqNfBvJI.js";
8
- import "../chunks/if-defined.CKupVaWs.js";
9
- import "./icon.js";
10
- import "../chunks/popup.CJrePm7n.js";
11
- import "./spinner.js";
12
- import { C as x } from "../chunks/menu-item.DOFCmq0Z.js";
1
+ import { i as k, x as h, n as r, C as S, c as C } from "../chunks/custom-element.fmLrnDZr.js";
2
+ import { c as w } from "../chunks/component.styles.DtouHn2g.js";
3
+ import { d as v, L as _ } from "../chunks/i18n.D33BKrRs.js";
4
+ import { H as M, g as L } from "../chunks/slot.DJLm4Dig.js";
5
+ import { w as b } from "../chunks/watch.BCJD77bD.js";
6
+ import { e as d } from "../chunks/query.BBf1UFkC.js";
7
+ import { e as x } from "../chunks/class-map.DqNfBvJI.js";
8
+ import { o as m } from "../chunks/if-defined.CKupVaWs.js";
9
+ import P from "./icon.js";
10
+ import { C as E } from "../chunks/popup.CJrePm7n.js";
11
+ import z from "./spinner.js";
12
+ import { e as D, n as R } from "../chunks/ref.BDmlFGTP.js";
13
+ const $ = k`
14
+ :host {
15
+ --submenu-offset: -2px;
16
+ --prefix-font-size: var(--cx-font-size-small);
17
+ --prefix-color: var(--cx-color-neutral-500);
18
+ --label-color: var(--cx-color-neutral);
19
+ --suffix-color: var(--cx-color-neutral);
20
+ --font-weight: var(--cx-font-weight-regular);
21
+
22
+ display: block;
23
+ }
24
+
25
+ :host([inert]) {
26
+ display: none;
27
+ }
28
+
29
+ .menu-item {
30
+ position: relative;
31
+ display: flex;
32
+ align-items: stretch;
33
+ text-decoration: none;
34
+ font-family: var(--cx-font-sans);
35
+ font-size: var(--cx-font-size-small);
36
+ font-weight: var(--font-weight, var(--cx-font-weight-regular));
37
+ line-height: var(--cx-line-height-large);
38
+ letter-spacing: var(--cx-letter-spacing-normal);
39
+ color: var(--cx-color-neutral);
40
+ padding: var(--cx-spacing-x-small) var(--cx-spacing-small);
41
+ transition: var(--cx-transition-fast) fill;
42
+ background-color: var(--cx-menu-item-background-color, unset);
43
+ user-select: none;
44
+ -webkit-user-select: none;
45
+ white-space: nowrap;
46
+ cursor: pointer;
47
+ }
48
+
49
+ .menu-item.menu-item--disabled {
50
+ outline: none;
51
+ cursor: default;
52
+ }
53
+
54
+ .menu-item.menu-item--disabled .menu-item__label,
55
+ .menu-item.menu-item--disabled .menu-item__prefix,
56
+ .menu-item.menu-item--disabled .menu-item__chevron {
57
+ opacity: 0.5;
58
+ }
59
+
60
+ .menu-item.menu-item--disabled .menu-item__suffix:not(:slotted(cx-tooltip)) {
61
+ opacity: 0.5;
62
+ }
63
+
64
+ .menu-item.menu-item--loading {
65
+ outline: none;
66
+ cursor: wait;
67
+ }
68
+
69
+ .menu-item.menu-item--loading *:not(cx-spinner) {
70
+ opacity: 0.5;
71
+ }
72
+
73
+ .menu-item--loading cx-spinner {
74
+ --indicator-color: currentColor;
75
+ --track-width: 1px;
76
+ position: absolute;
77
+ font-size: 0.75em;
78
+ top: calc(50% - 0.5em);
79
+ left: 0.65rem;
80
+ opacity: 1;
81
+ }
82
+
83
+ .menu-item .menu-item__label {
84
+ color: var(--label-color, var(--cx-color-neutral));
85
+ flex: 1 1 auto;
86
+ display: inline-block;
87
+ text-overflow: ellipsis;
88
+ overflow: hidden;
89
+ margin: auto;
90
+ }
91
+
92
+ .menu-item--checked .menu-item__label {
93
+ color: var(--cx-color-primary);
94
+ }
95
+
96
+ .menu-item .menu-item__prefix {
97
+ color: var(--prefix-color, var(--cx-color-neutral-500));
98
+ font-size: var(--prefix-font-size, var(--cx-font-size-small));
99
+ flex: 0 0 auto;
100
+ display: flex;
101
+ align-items: center;
102
+ }
103
+
104
+ .menu-item--checked {
105
+ --prefix-color: var(--cx-color-primary);
106
+ --suffix-color: var(--cx-color-primary);
107
+ }
108
+
109
+ .menu-item--checked .menu-item__check {
110
+ color: var(--cx-color-primary);
111
+ }
112
+
113
+ .menu-item .menu-item__prefix::slotted(*) {
114
+ margin-inline-end: var(--cx-spacing-x-small);
115
+ }
116
+
117
+ .menu-item .menu-item__suffix {
118
+ color: var(--suffix-color);
119
+ flex: 0 0 auto;
120
+ display: flex;
121
+ align-items: center;
122
+ }
123
+
124
+ .menu-item .menu-item__suffix::slotted(*) {
125
+ margin-inline-start: var(--cx-spacing-x-small);
126
+ }
127
+
128
+ /* Safe triangle */
129
+ .menu-item--submenu-expanded::after {
130
+ content: '';
131
+ position: fixed;
132
+ z-index: calc(var(--cx-z-index-dropdown) - 1);
133
+ top: 0;
134
+ right: 0;
135
+ bottom: 0;
136
+ left: 0;
137
+ clip-path: polygon(
138
+ var(--safe-triangle-cursor-x, 0) var(--safe-triangle-cursor-y, 0),
139
+ var(--safe-triangle-submenu-start-x, 0)
140
+ var(--safe-triangle-submenu-start-y, 0),
141
+ var(--safe-triangle-submenu-end-x, 0)
142
+ var(--safe-triangle-submenu-end-y, 0)
143
+ );
144
+ }
145
+
146
+ @media (pointer: none), (pointer: coarse) {
147
+ .menu-item--submenu-expanded::after {
148
+ display: none;
149
+ }
150
+ }
151
+
152
+ :host(:focus-visible) {
153
+ outline: var(--cx-focus-ring);
154
+ outline-offset: calc(-1 * var(--cx-focus-ring-width));
155
+ }
156
+
157
+ :host(:hover:not([aria-disabled='true'], :focus-visible, .disable-hover))
158
+ .menu-item,
159
+ .menu-item--submenu-expanded {
160
+ background-color: var(--cx-menu-item-background-color-hover);
161
+ color: var(--cx-color-neutral-1000);
162
+ }
163
+
164
+ :host(:not([aria-disabled='true'])) .menu-item--active {
165
+ background-color: var(
166
+ --cx-menu-item-background-color-active,
167
+ var(--cx-menu-item-background-color-hover)
168
+ );
169
+ color: var(--cx-color-neutral-1000);
170
+ }
171
+
172
+ :host(:hover:not([aria-disabled='true'], :focus-visible, .disable-hover))
173
+ .menu-item--active {
174
+ background-color: var(
175
+ --cx-menu-item-background-color-active-hover,
176
+ var(--cx-menu-item-background-color-active)
177
+ );
178
+ }
179
+
180
+ :host(:focus-visible) .menu-item {
181
+ outline: none;
182
+ background-color: var(--cx-menu-item-background-color-hover);
183
+ opacity: 1;
184
+ }
185
+
186
+ .menu-item .menu-item__check,
187
+ .menu-item .menu-item__chevron {
188
+ flex: 0 0 auto;
189
+ align-items: center;
190
+ justify-content: center;
191
+ width: 1.5em;
192
+ visibility: hidden;
193
+ }
194
+
195
+ .menu-item .menu-item__check {
196
+ display: var(--checked-icon-display, flex);
197
+ margin-right: var(--cx-spacing-2x-small);
198
+ }
199
+
200
+ .menu-item .menu-item__chevron {
201
+ display: var(--submenu-icon-display, flex);
202
+ }
203
+
204
+ .menu-item--checked .menu-item__check,
205
+ .menu-item--has-submenu .menu-item__chevron {
206
+ visibility: visible;
207
+ }
208
+
209
+ /* Add elevation and z-index to submenus */
210
+ cx-popup::part(popup) {
211
+ border: var(--cx-panel-border-width) solid var(--cx-popup-border-color);
212
+ border-radius: var(--cx-border-radius-large);
213
+ box-shadow: var(--cx-shadow-large);
214
+ z-index: var(--cx-z-index-dropdown);
215
+ margin-left: var(--submenu-offset, -2px);
216
+ overflow: hidden;
217
+ }
218
+
219
+ .menu-item--rtl cx-popup::part(popup) {
220
+ margin-left: calc(-1 * var(--submenu-offset));
221
+ }
222
+
223
+ @media (forced-colors: active) {
224
+ :host(:hover:not([aria-disabled='true'])) .menu-item,
225
+ :host(:focus-visible) .menu-item {
226
+ outline: dashed 1px SelectedItem;
227
+ outline-offset: -1px;
228
+ }
229
+ }
230
+
231
+ /* When users slot a menu, make sure it conforms to the popup's auto-size */
232
+ ::slotted(cx-menu) {
233
+ max-width: var(--auto-size-available-width) !important;
234
+ max-height: var(--auto-size-available-height) !important;
235
+ }
236
+ `;
237
+ class T {
238
+ constructor(e, s) {
239
+ this.popupRef = D(), this.parent = null, this.enableSubmenuTimer = -1, this.isHorizontalMenu = !1, this.isConnected = !1, this.isPopupConnected = !1, this.skidding = 0, this.submenuOpenDelay = 100, (this.host = e).addController(this), this.hasSlotController = s, this.handleMouseMove = this.handleMouseMove.bind(this), this.handleMouseOver = this.handleMouseOver.bind(this), this.handleKeyDown = this.handleKeyDown.bind(this), this.handleClick = this.handleClick.bind(this), this.handleSubmenuIconClick = this.handleSubmenuIconClick.bind(this), this.handleDocumentMouseDown = this.handleDocumentMouseDown.bind(this), this.handleMouseLeave = this.handleMouseLeave.bind(this), this.handlePopupMouseover = this.handlePopupMouseover.bind(this), this.handlePopupReposition = this.handlePopupReposition.bind(this);
240
+ }
241
+ get popup() {
242
+ return this.popupRef.value;
243
+ }
244
+ hostConnected() {
245
+ this.parent = this.host.closest("cx-menu"), this.hasSlotController.test("submenu") && !this.host.disabled && (this.addListeners(), this.updateSkidding()), this.parent && (this.syncIsHorizontalMenu(), this.parentObserver = new MutationObserver(() => {
246
+ this.syncIsHorizontalMenu();
247
+ }), this.parentObserver.observe(this.parent, {
248
+ attributeFilter: ["horizontal"]
249
+ }));
250
+ }
251
+ hostDisconnected() {
252
+ this.removeListeners(), this.parentObserver && this.parentObserver.disconnect();
253
+ }
254
+ hostUpdated() {
255
+ this.removeListeners(), this.hasSlotController.test("submenu") && !this.host.disabled && (this.addListeners(), this.updateSkidding(), this.syncIsHorizontalMenu());
256
+ }
257
+ addListeners() {
258
+ this.isConnected || (this.host.addEventListener("mousemove", this.handleMouseMove), (this.host.submenuTrigger === "both" || this.host.submenuTrigger === "hover") && (this.host.addEventListener("mouseover", this.handleMouseOver), this.host.addEventListener("mouseleave", this.handleMouseLeave)), (this.host.submenuTrigger === "both" || this.host.submenuTrigger === "click") && (this.host.addEventListener("click", this.handleClick), this.host.submenuIcon?.addEventListener(
259
+ "click",
260
+ this.handleSubmenuIconClick
261
+ ), document.addEventListener("mousedown", this.handleDocumentMouseDown)), this.host.addEventListener("keydown", this.handleKeyDown), this.isConnected = !0), this.isPopupConnected || this.popupRef.value && (this.popupRef.value.addEventListener(
262
+ "mouseover",
263
+ this.handlePopupMouseover
264
+ ), this.popupRef.value.addEventListener(
265
+ "cx-reposition",
266
+ this.handlePopupReposition
267
+ ), this.isPopupConnected = !0);
268
+ }
269
+ removeListeners() {
270
+ this.isConnected && (this.host.removeEventListener("mousemove", this.handleMouseMove), this.host.removeEventListener("mouseover", this.handleMouseOver), this.host.removeEventListener("mouseleave", this.handleMouseLeave), this.host.removeEventListener("click", this.handleClick), this.host.submenuIcon?.removeEventListener(
271
+ "click",
272
+ this.handleSubmenuIconClick
273
+ ), document.removeEventListener("mousedown", this.handleDocumentMouseDown), this.host.removeEventListener("keydown", this.handleKeyDown), this.isConnected = !1), this.isPopupConnected && this.popupRef.value && (this.popupRef.value.removeEventListener(
274
+ "mouseover",
275
+ this.handlePopupMouseover
276
+ ), this.popupRef.value.removeEventListener(
277
+ "cx-reposition",
278
+ this.handlePopupReposition
279
+ ), this.isPopupConnected = !1);
280
+ }
281
+ syncIsHorizontalMenu() {
282
+ this.parent && (this.isHorizontalMenu = this.parent.hasAttribute("horizontal"));
283
+ }
284
+ // Set the safe triangle cursor position
285
+ handleMouseMove(e) {
286
+ const s = getComputedStyle(this.host).direction === "rtl" || this.popupRef.value?.dataset.currentPlacement?.startsWith("left");
287
+ this.host.style.setProperty(
288
+ "--safe-triangle-cursor-x",
289
+ `${e.clientX + (s ? 1 : 0)}px`
290
+ ), this.host.style.setProperty(
291
+ "--safe-triangle-cursor-y",
292
+ `${e.clientY}px`
293
+ );
294
+ }
295
+ handleMouseOver() {
296
+ this.hasSlotController.test("submenu") && this.enableSubmenu();
297
+ }
298
+ handleSubmenuEntry(e) {
299
+ const s = this.host.renderRoot.querySelector("slot[name='submenu']");
300
+ if (!s) {
301
+ console.error(
302
+ "Cannot activate a submenu if no corresponding menuitem can be found.",
303
+ this
304
+ );
305
+ return;
306
+ }
307
+ let t = null;
308
+ for (const a of s.assignedElements())
309
+ if (t = a.querySelectorAll("cx-menu-item, [role^='menuitem']"), t.length !== 0)
310
+ break;
311
+ if (!t || t.length === 0) {
312
+ this.host.lazy && (e.preventDefault(), e.stopPropagation(), this.enableSubmenu(!1));
313
+ return;
314
+ }
315
+ t[0].setAttribute("tabindex", "0");
316
+ for (let a = 1; a !== t.length; ++a)
317
+ t[a].setAttribute("tabindex", "-1");
318
+ this.popupRef.value && (e.preventDefault(), e.stopPropagation(), this.popupRef.value.active ? t[0] instanceof HTMLElement && t[0].focus() : (this.enableSubmenu(!1), this.popupRef.value.addEventListener("cx-opened", () => {
319
+ t[0] instanceof HTMLElement && t[0].focus();
320
+ }), this.host.requestUpdate()));
321
+ }
322
+ // Focus on the first menu-item of a submenu.
323
+ handleKeyDown(e) {
324
+ const s = () => {
325
+ e.preventDefault(), e.stopPropagation(), this.host.focus(), this.disableSubmenu();
326
+ };
327
+ switch (e.key) {
328
+ case "Tab": {
329
+ this.disableSubmenu();
330
+ break;
331
+ }
332
+ case "Escape": {
333
+ this.host.focus(), this.disableSubmenu();
334
+ break;
335
+ }
336
+ case "ArrowLeft": {
337
+ e.target !== this.host && !this.isHorizontalMenu && s();
338
+ break;
339
+ }
340
+ case "ArrowUp": {
341
+ e.target !== this.host && this.isHorizontalMenu && s();
342
+ break;
343
+ }
344
+ case "ArrowRight": {
345
+ this.isHorizontalMenu || this.handleSubmenuEntry(e);
346
+ break;
347
+ }
348
+ case "ArrowDown": {
349
+ this.isHorizontalMenu && this.handleSubmenuEntry(e);
350
+ break;
351
+ }
352
+ }
353
+ }
354
+ handleClick(e) {
355
+ e.target === this.host ? (e.preventDefault(), e.stopPropagation(), this.isExpanded() ? this.disableSubmenu() : e.isTrusted && this.enableSubmenu()) : e.target instanceof Element && (e.target.tagName === "cx-menu-item" || e.target.role?.startsWith("menuitem"));
356
+ }
357
+ handleSubmenuIconClick(e) {
358
+ e.preventDefault(), e.stopPropagation(), this.isExpanded() ? this.disableSubmenu() : this.enableSubmenu();
359
+ }
360
+ handleDocumentMouseDown(e) {
361
+ const s = e.composedPath();
362
+ this.host && !s.includes(this.host) && this.disableSubmenu();
363
+ }
364
+ // Close this submenu on focus outside of the parent or any descendants.
365
+ handleMouseLeave(e) {
366
+ e.relatedTarget && e.relatedTarget instanceof Element && this.host.contains(e.relatedTarget) || this.disableSubmenu();
367
+ }
368
+ // Prevent the parent menu-item from getting focus on mouse movement on the submenu
369
+ handlePopupMouseover(e) {
370
+ e.stopPropagation();
371
+ }
372
+ // Set the safe triangle values for the submenu when the position changes
373
+ handlePopupReposition() {
374
+ const s = this.host.renderRoot.querySelector("slot[name='submenu']")?.assignedElements({ flatten: !0 }).filter((p) => p.localName === "cx-menu")[0], t = getComputedStyle(this.host).direction === "rtl" || this.popupRef.value?.dataset.currentPlacement?.startsWith("left");
375
+ if (!s)
376
+ return;
377
+ const { height: a, left: l, top: u, width: c } = s.getBoundingClientRect();
378
+ this.host.style.setProperty(
379
+ "--safe-triangle-submenu-start-x",
380
+ `${t ? l + c : l}px`
381
+ ), this.host.style.setProperty("--safe-triangle-submenu-start-y", `${u}px`), this.host.style.setProperty(
382
+ "--safe-triangle-submenu-end-x",
383
+ `${t ? l + c : l}px`
384
+ ), this.host.style.setProperty(
385
+ "--safe-triangle-submenu-end-y",
386
+ `${u + a}px`
387
+ );
388
+ }
389
+ setSubmenuState(e) {
390
+ this.popupRef.value && this.popupRef.value.active !== e && (this.popupRef.value.active = e, this.host.requestUpdate());
391
+ }
392
+ // Shows the submenu. Supports disabling the opening delay, e.g. for keyboard events that want to set the focus to the
393
+ // newly opened menu.
394
+ enableSubmenu(e = !0) {
395
+ this.host.lazy && this.host.emit("cx-lazy-load"), e ? (window.clearTimeout(this.enableSubmenuTimer), this.enableSubmenuTimer = window.setTimeout(() => {
396
+ this.setSubmenuState(!0);
397
+ }, this.submenuOpenDelay)) : this.setSubmenuState(!0);
398
+ }
399
+ disableSubmenu() {
400
+ window.clearTimeout(this.enableSubmenuTimer), this.setSubmenuState(!1);
401
+ }
402
+ // Calculate the space the top of a menu takes-up, for aligning the popup menu-item with the activating element.
403
+ updateSkidding() {
404
+ if (!this.host.parentElement?.computedStyleMap)
405
+ return;
406
+ const e = this.host.parentElement.computedStyleMap(), s = v(this.host) === "rtl", t = this.host.submenuPlacement ?? (s ? "left-start" : "right-start"), a = t.startsWith("left") || t.startsWith("right");
407
+ let l = [];
408
+ a && (t.endsWith("-start") ? l = ["padding-top", "border-top-width", "margin-top"] : t.endsWith("-end") && (l = ["padding-bottom", "border-bottom-width", "margin-bottom"]));
409
+ const u = l.reduce((c, p) => {
410
+ const f = e.get(p) ?? new CSSUnitValue(0, "px"), g = (f instanceof CSSUnitValue ? f : new CSSUnitValue(0, "px")).to("px"), y = t.endsWith("-end") ? 1 : -1;
411
+ return c + g.value * y;
412
+ }, 0);
413
+ this.skidding = u;
414
+ }
415
+ isExpanded() {
416
+ return this.popupRef.value ? this.popupRef.value.active : !1;
417
+ }
418
+ renderSubmenu() {
419
+ const e = v(this.host) === "rtl";
420
+ if (!this.hasSlotController.test("submenu"))
421
+ return null;
422
+ const s = this.host.submenuPlacement ?? (e ? "left-start" : "right-start");
423
+ return h`
424
+ <cx-popup
425
+ ${R(this.popupRef)}
426
+ placement=${s}
427
+ anchor="anchor"
428
+ part="submenu-popup"
429
+ flip
430
+ flip-fallback-strategy="best-fit"
431
+ skidding=${this.skidding}
432
+ strategy="overlay"
433
+ auto-size="both"
434
+ auto-size-padding="10"
435
+ ?shift=${!!this.host.shiftBoundary}
436
+ .flipBoundary=${this.host.flipBoundary}
437
+ .shiftBoundary=${this.host.shiftBoundary}
438
+ >
439
+ <slot name="submenu"></slot>
440
+ </cx-popup>
441
+ `;
442
+ }
443
+ }
444
+ var O = Object.defineProperty, H = Object.getOwnPropertyDescriptor, n = (o, e, s, t) => {
445
+ for (var a = t > 1 ? void 0 : t ? H(e, s) : e, l = o.length - 1, u; l >= 0; l--)
446
+ (u = o[l]) && (a = (t ? u(e, s, a) : u(a)) || a);
447
+ return t && a && O(e, s, a), a;
448
+ };
449
+ let i = class extends S {
450
+ constructor() {
451
+ super(), this.type = "normal", this.submenuTrigger = "both", this.checked = !1, this.value = "", this.href = "", this.rel = "noreferrer noopener", this.loading = !1, this.disabled = !1, this.active = !1, this.readonly = !1, this.menu = "", this.lazy = !1, this.localize = new _(this), this.hasSlotController = new M(
452
+ this,
453
+ "submenu",
454
+ "submenu-icon"
455
+ ), this.submenuController = new T(
456
+ this,
457
+ this.hasSlotController
458
+ ), this.handleDocumentWheel = (o) => {
459
+ const e = o.composedPath();
460
+ this.submenuController.isExpanded() && (!this.submenuController.popup || !e.includes(this.submenuController.popup)) && (o.preventDefault(), this.submenuController.disableSubmenu());
461
+ }, this.handleHostClick = this.handleHostClick.bind(this), this.handleMouseOver = this.handleMouseOver.bind(this);
462
+ }
463
+ runFirstUpdated() {
464
+ this.addEventListener("click", this.handleHostClick), this.addEventListener("mouseover", this.handleMouseOver), document.addEventListener("wheel", this.handleDocumentWheel, {
465
+ passive: !1
466
+ });
467
+ }
468
+ disconnectedCallback() {
469
+ super.disconnectedCallback(), this.removeEventListener("click", this.handleHostClick), this.removeEventListener("mouseover", this.handleMouseOver), document.removeEventListener("wheel", this.handleDocumentWheel);
470
+ }
471
+ handleDefaultSlotChange() {
472
+ const o = this.getTextLabel();
473
+ if (typeof this.cachedTextLabel > "u") {
474
+ this.cachedTextLabel = o;
475
+ return;
476
+ }
477
+ o !== this.cachedTextLabel && (this.cachedTextLabel = o, this.emit("slotchange", {
478
+ bubbles: !0,
479
+ cancelable: !1,
480
+ composed: !1
481
+ }));
482
+ }
483
+ handleHostClick(o) {
484
+ (this.disabled || this.readonly) && (o.target === this && o.preventDefault(), o.stopImmediatePropagation()), this.href && this.anchor && this.anchor.click();
485
+ }
486
+ handleMouseOver(o) {
487
+ o.stopPropagation();
488
+ }
489
+ handleAnchorClick(o) {
490
+ o.stopPropagation();
491
+ }
492
+ handleCheckedChange() {
493
+ if (this.checked && this.type !== "checkbox") {
494
+ this.checked = !1, console.error(
495
+ 'The checked attribute can only be used on menu items with type="checkbox"',
496
+ this
497
+ );
498
+ return;
499
+ }
500
+ this.type === "checkbox" ? this.setAttribute("aria-checked", this.checked ? "true" : "false") : this.removeAttribute("aria-checked");
501
+ }
502
+ handleDisabledChange() {
503
+ this.setAttribute("aria-disabled", this.disabled ? "true" : "false");
504
+ }
505
+ handleTypeChange() {
506
+ this.type === "checkbox" ? (this.setAttribute("role", "menuitemcheckbox"), this.setAttribute("aria-checked", this.checked ? "true" : "false")) : (this.setAttribute("role", "menuitem"), this.removeAttribute("aria-checked"));
507
+ }
508
+ /** Returns a text label based on the contents of the menu item's default slot. */
509
+ getTextLabel() {
510
+ return L(this.defaultSlot);
511
+ }
512
+ isSubmenu() {
513
+ return this.hasSlotController.test("submenu") || !!this.menu.trim();
514
+ }
515
+ renderBase(o) {
516
+ const e = !!this.href, s = this.localize.dir() === "rtl", t = this.submenuController.isExpanded();
517
+ return e ? h`
518
+ <a
519
+ id="anchor"
520
+ part="base"
521
+ class=${x({
522
+ "menu-item": !0,
523
+ "menu-item--active": this.active,
524
+ "menu-item--checkbox": this.type === "checkbox",
525
+ "menu-item--checked": this.checked,
526
+ "menu-item--disabled": this.disabled,
527
+ "menu-item--has-submenu": this.isSubmenu(),
528
+ "menu-item--loading": this.loading,
529
+ "menu-item--rtl": s,
530
+ "menu-item--submenu-expanded": t
531
+ })}
532
+ aria-haspopup=${this.isSubmenu()}
533
+ href=${m(this.href)}
534
+ target=${m(this.target)}
535
+ download=${m(this.download)}
536
+ rel=${m(this.rel)}
537
+ aria-label=${this.getTextLabel()}
538
+ ?inert=${this.disabled}
539
+ @click=${this.handleAnchorClick}
540
+ >
541
+ ${o}
542
+ </a>
543
+ ` : h`
544
+ <div
545
+ id="anchor"
546
+ part="base"
547
+ class=${x({
548
+ "menu-item": !0,
549
+ "menu-item--active": this.active,
550
+ "menu-item--checkbox": this.type === "checkbox",
551
+ "menu-item--checked": this.checked,
552
+ "menu-item--disabled": this.disabled,
553
+ "menu-item--has-submenu": this.isSubmenu(),
554
+ "menu-item--loading": this.loading,
555
+ "menu-item--rtl": s,
556
+ "menu-item--submenu-expanded": t
557
+ })}
558
+ aria-haspopup=${this.isSubmenu()}
559
+ aria-label=${this.getTextLabel()}
560
+ >
561
+ ${o}
562
+ </div>
563
+ `;
564
+ }
565
+ render() {
566
+ const o = this.localize.dir() === "rtl";
567
+ let e;
568
+ return this.submenuPlacement && (this.submenuPlacement.startsWith("top") || this.submenuPlacement.startsWith("bottom")) ? e = "keyboard_arrow_down" : e = o ? "chevron_left" : "chevron_right", this.renderBase(h`
569
+ <span part="checked-icon" class="menu-item__check">
570
+ <cx-icon name="check"></cx-icon>
571
+ </span>
572
+
573
+ <slot name="prefix" part="prefix" class="menu-item__prefix"></slot>
574
+
575
+ <slot
576
+ part="label"
577
+ class="menu-item__label"
578
+ @slotchange=${this.handleDefaultSlotChange}
579
+ ></slot>
580
+
581
+ <slot name="suffix" part="suffix" class="menu-item__suffix"></slot>
582
+
583
+ <slot name="submenu-icon" part="submenu-icon" class="menu-item__chevron">
584
+ <cx-icon name=${e} aria-hidden="true"></cx-icon>
585
+ </slot>
586
+
587
+ ${this.submenuController.renderSubmenu()}
588
+ ${this.loading ? h`
589
+ <cx-spinner
590
+ part="spinner"
591
+ exportparts="base:spinner__base"
592
+ ></cx-spinner>
593
+ ` : ""}
594
+ `);
595
+ }
596
+ };
597
+ i.styles = [w, $];
598
+ i.dependencies = {
599
+ "cx-icon": P,
600
+ "cx-popup": E,
601
+ "cx-spinner": z
602
+ };
603
+ n([
604
+ d("slot:not([name])")
605
+ ], i.prototype, "defaultSlot", 2);
606
+ n([
607
+ d("a#anchor", !0)
608
+ ], i.prototype, "anchor", 2);
609
+ n([
610
+ d(".menu-item")
611
+ ], i.prototype, "menuItem", 2);
612
+ n([
613
+ d(".menu-item__chevron")
614
+ ], i.prototype, "submenuIcon", 2);
615
+ n([
616
+ r()
617
+ ], i.prototype, "type", 2);
618
+ n([
619
+ r({ attribute: "submenu-trigger" })
620
+ ], i.prototype, "submenuTrigger", 2);
621
+ n([
622
+ r({ reflect: !0, type: Boolean })
623
+ ], i.prototype, "checked", 2);
624
+ n([
625
+ r()
626
+ ], i.prototype, "value", 2);
627
+ n([
628
+ r()
629
+ ], i.prototype, "href", 2);
630
+ n([
631
+ r()
632
+ ], i.prototype, "target", 2);
633
+ n([
634
+ r()
635
+ ], i.prototype, "rel", 2);
636
+ n([
637
+ r()
638
+ ], i.prototype, "download", 2);
639
+ n([
640
+ r({ reflect: !0, type: Boolean })
641
+ ], i.prototype, "loading", 2);
642
+ n([
643
+ r({ reflect: !0, type: Boolean })
644
+ ], i.prototype, "disabled", 2);
645
+ n([
646
+ r({ reflect: !0, type: Boolean })
647
+ ], i.prototype, "active", 2);
648
+ n([
649
+ r({ reflect: !0, type: Boolean })
650
+ ], i.prototype, "readonly", 2);
651
+ n([
652
+ r({ attribute: "flip-boundary", type: Object })
653
+ ], i.prototype, "flipBoundary", 2);
654
+ n([
655
+ r({ attribute: "shift-boundary", type: Object })
656
+ ], i.prototype, "shiftBoundary", 2);
657
+ n([
658
+ r({ reflect: !0 })
659
+ ], i.prototype, "menu", 2);
660
+ n([
661
+ r({ attribute: "submenu-placement" })
662
+ ], i.prototype, "submenuPlacement", 2);
663
+ n([
664
+ r({ reflect: !0, type: Boolean })
665
+ ], i.prototype, "lazy", 2);
666
+ n([
667
+ b("checked")
668
+ ], i.prototype, "handleCheckedChange", 1);
669
+ n([
670
+ b("disabled")
671
+ ], i.prototype, "handleDisabledChange", 1);
672
+ n([
673
+ b("type")
674
+ ], i.prototype, "handleTypeChange", 1);
675
+ i = n([
676
+ C("cx-menu-item")
677
+ ], i);
13
678
  export {
14
- x as default
679
+ i as default
15
680
  };
@@ -4,7 +4,7 @@ import { L as v } from "../chunks/i18n.D33BKrRs.js";
4
4
  import { r as y } from "../chunks/state.Dt9F_SuS.js";
5
5
  import { e as w } from "../chunks/query.BBf1UFkC.js";
6
6
  import { n as x } from "../chunks/when.Dr1es41R.js";
7
- import { C as M } from "../chunks/menu-item.DOFCmq0Z.js";
7
+ import M from "./menu-item.js";
8
8
  const k = f`
9
9
  :host {
10
10
  display: block;