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