@mintplayer/web-components 2.16.0 → 2.18.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 (120) hide show
  1. package/accordion/index.mjs +5 -5
  2. package/calendar/index.mjs +1 -1
  3. package/carousel/index.mjs +57 -143
  4. package/charts/core/index.mjs +30 -20
  5. package/charts/core/src/attributes.d.ts +18 -0
  6. package/charts/core/src/index.d.ts +2 -0
  7. package/charts/core/src/view-window.d.ts +46 -0
  8. package/charts/hierarchy/index.mjs +245 -256
  9. package/charts/hierarchy/src/components/mp-hierarchy-chart.d.ts +1 -3
  10. package/charts/sparkline/index.mjs +27 -26
  11. package/charts/trend/index.mjs +21 -20
  12. package/checkbox/index.mjs +1 -1
  13. package/checkbox/src/components/mp-checkbox.d.ts +1 -0
  14. package/chunks/attributes-L3eKsbdy.mjs +16 -0
  15. package/chunks/color-mode-warning-71FmlzWX.mjs +13 -0
  16. package/chunks/{form-check.styles-B0pxJ6YC.mjs → form-check.styles-DqvBnspm.mjs} +24 -3
  17. package/chunks/{mp-calendar.element-CJ8-t-Zn.mjs → mp-calendar.element-BIHS9SZZ.mjs} +11 -6
  18. package/chunks/{mp-checkbox-CzwS7Y_t.mjs → mp-checkbox-zV83gILn.mjs} +44 -36
  19. package/chunks/{mp-datatable-B7st6G-I.mjs → mp-datatable-CEpSxlkd.mjs} +660 -357
  20. package/chunks/{mp-datetime-picker.element-DsWA1AFs.mjs → mp-datetime-picker.element-Cxu5-qRE.mjs} +29 -32
  21. package/chunks/{mp-pagination-Dea75mD4.mjs → mp-pagination-hGy4dL7p.mjs} +9 -4
  22. package/chunks/{mp-radio-cL46sUA0.mjs → mp-radio-BhRVNdKp.mjs} +32 -28
  23. package/chunks/{mp-select-BNrbPwN4.mjs → mp-select-CgqYFvUj.mjs} +41 -26
  24. package/chunks/{mp-splitter-Ckn1kN4v.mjs → mp-splitter-DLehrw3Y.mjs} +144 -120
  25. package/chunks/{mp-timepicker.element-CwaAAOcm.mjs → mp-timepicker.element-BiB9lkgc.mjs} +58 -45
  26. package/chunks/{mp-toggle-button-eo_aTQtu.mjs → mp-toggle-button-CaS9uYLE.mjs} +26 -24
  27. package/chunks/{mp-treeview-C8iltDbq.mjs → mp-treeview-CaMTDrvY.mjs} +51 -50
  28. package/chunks/{overlay-controller-DifgO6jT.mjs → overlay-controller-BHDagokg.mjs} +96 -92
  29. package/chunks/{id-DNZVAnGC.mjs → resource.service--lqLwEqk.mjs} +144 -206
  30. package/chunks/view-window-DGvFiDnW.mjs +263 -0
  31. package/code-snippet/index.mjs +70 -66
  32. package/code-snippet/src/hljs-loaders.generated.d.ts +1 -1
  33. package/custom-elements.json +66193 -0
  34. package/datatable/index.mjs +1 -1
  35. package/datatable/src/components/column-resize.d.ts +11 -0
  36. package/datatable/src/components/index.d.ts +1 -1
  37. package/datatable/src/components/mp-datatable.d.ts +264 -20
  38. package/datatable/src/index.d.ts +1 -1
  39. package/datatable/src/types/labels.d.ts +11 -0
  40. package/datepicker/index.mjs +10 -9
  41. package/datetime-picker/index.mjs +1 -1
  42. package/datetime-picker/src/mp-datetime-picker.element.d.ts +3 -0
  43. package/dock/index.mjs +430 -463
  44. package/dock/src/components/mint-dock-manager.element.d.ts +25 -2
  45. package/dock/src/core/resize.d.ts +60 -0
  46. package/dropdown-menu/index.mjs +4 -2
  47. package/dropdown-menu/src/components/mp-dropdown-menu.d.ts +6 -1
  48. package/dropdown-menu/src/index.d.ts +1 -1
  49. package/dropdown-menu/src/types/dropdown.d.ts +14 -1
  50. package/dropdown-menu/src/types/index.d.ts +1 -1
  51. package/file-manager/index.mjs +63 -61
  52. package/file-manager/src/components/mp-file-manager.d.ts +4 -3
  53. package/multi-range/index.mjs +56 -50
  54. package/multi-range/src/mint-multi-range.element.d.ts +4 -10
  55. package/multi-range/src/pointer-geometry.d.ts +31 -0
  56. package/navbar/index.mjs +89 -439
  57. package/overlay/index.mjs +1 -1
  58. package/overlay/src/overlay-controller.d.ts +0 -14
  59. package/overlay/src/placement.d.ts +48 -0
  60. package/package.json +7 -1
  61. package/pagination/index.mjs +1 -1
  62. package/phone-input/index.mjs +44 -40
  63. package/phone-input/src/components/stack.d.ts +8 -0
  64. package/query-builder/index.mjs +418 -466
  65. package/query-builder/src/dnd/drag-controller.d.ts +12 -8
  66. package/query-builder/src/mp-query-builder.element.d.ts +5 -1
  67. package/query-builder/src/mp-query-condition.element.d.ts +1 -0
  68. package/radio/index.mjs +1 -1
  69. package/radio-group/index.mjs +1 -1
  70. package/ribbon/index.mjs +477 -498
  71. package/ribbon/src/core/band-text-color.d.ts +10 -0
  72. package/ribbon/src/core/key-tip-allocator.d.ts +10 -0
  73. package/ribbon/src/core/plan-reduce-steps.d.ts +62 -0
  74. package/ribbon/src/mp-ribbon.element.d.ts +0 -27
  75. package/scheduler/index.mjs +726 -711
  76. package/scheduler/src/components/mp-scheduler.d.ts +19 -3
  77. package/scheduler/src/drag/drag-manager.d.ts +1 -9
  78. package/scheduler/src/input/input-handler.d.ts +12 -2
  79. package/scheduler/src/utils/geometry.d.ts +39 -0
  80. package/scheduler/src/views/timeline-view.d.ts +0 -1
  81. package/scheduler-core/index.mjs +84 -71
  82. package/scheduler-core/src/services/resource.service.d.ts +0 -12
  83. package/scheduler-core/src/services/timeline.service.d.ts +0 -9
  84. package/select/index.mjs +1 -1
  85. package/select/src/components/mp-select.d.ts +1 -0
  86. package/signature-pad/index.mjs +21 -23
  87. package/signature-pad/src/canvas-point.d.ts +26 -0
  88. package/signature-pad/src/mp-signature-pad.element.d.ts +1 -7
  89. package/splitter/index.mjs +1 -1
  90. package/splitter/src/components/mp-splitter.d.ts +16 -0
  91. package/splitter/src/managers/index.d.ts +1 -0
  92. package/splitter/src/managers/rescale-panel-sizes.d.ts +14 -0
  93. package/swiper-core/index.mjs +2 -2
  94. package/theming/bs-theme-preboot.js +1 -0
  95. package/theming/color-mode.css +36 -0
  96. package/theming/index.d.ts +1 -0
  97. package/theming/index.mjs +327 -0
  98. package/theming/src/components/mp-theme-toggle.d.ts +71 -0
  99. package/theming/src/cookie.d.ts +31 -0
  100. package/theming/src/index.d.ts +5 -0
  101. package/theming/src/preboot.d.ts +1 -0
  102. package/theming/src/resolve.d.ts +36 -0
  103. package/theming/src/store.d.ts +27 -0
  104. package/theming/src/styles/theme-toggle.styles.d.ts +2 -0
  105. package/theming/src/testing/fake-broadcast-channel.d.ts +35 -0
  106. package/theming/src/toggle-modes.d.ts +23 -0
  107. package/tile-manager/index.mjs +252 -211
  108. package/tile-manager/src/components/mint-tile-manager.element.d.ts +8 -0
  109. package/tile-manager/src/utils/grid-geometry.d.ts +49 -0
  110. package/timeline/index.mjs +156 -164
  111. package/timeline/src/components/mp-timeline.d.ts +41 -7
  112. package/timepicker/index.mjs +7 -4
  113. package/timepicker/src/mp-time-list.element.d.ts +26 -0
  114. package/timepicker/src/mp-timepicker.element.d.ts +3 -0
  115. package/toggle-button/index.mjs +1 -1
  116. package/tree-select/index.mjs +21 -9
  117. package/treeview/index.mjs +1 -1
  118. package/treeview/src/components/mp-treeview.d.ts +6 -4
  119. package/chunks/color-DIeST-IS.mjs +0 -224
  120. package/query-builder/src/mp-query-condition.element.template.d.ts +0 -2
@@ -138,6 +138,8 @@ export declare class MintTileManagerElement extends LitElement {
138
138
  */
139
139
  private updateLayoutCache;
140
140
  private computeActiveTransform;
141
+ /** The numbers the pure drag geometry needs: pointer, live grid origin, grab offset. */
142
+ private dragPointer;
141
143
  connectedCallback(): void;
142
144
  disconnectedCallback(): void;
143
145
  protected firstUpdated(): void;
@@ -153,6 +155,12 @@ export declare class MintTileManagerElement extends LitElement {
153
155
  private cleanupTouchArming;
154
156
  private beginDragFromTouchArm;
155
157
  private beginDrag;
158
+ /**
159
+ * Enter the drag state for a pointer at (x, y). Refreshes the layout cache
160
+ * once at gesture start, so the metrics are fresh even if the grid resized
161
+ * since the last cache tick. Returns false when there is no grid to drag in.
162
+ */
163
+ private startDrag;
156
164
  private beginResize;
157
165
  private announceDragBegin;
158
166
  private announceResizeBegin;
@@ -0,0 +1,49 @@
1
+ import { GridRect } from '../types/grid-rect';
2
+ import { TilePosition } from '../types/tile-position';
3
+ /**
4
+ * Pure grid geometry for `mp-tile-manager`'s pointer gestures. Everything here
5
+ * takes plain numbers, so the snapping maths is testable without a layout
6
+ * engine; the element only reads the rects and hands the numbers over.
7
+ */
8
+ /** Cached per-cell layout metrics, in CSS pixels. */
9
+ export interface CellMetrics {
10
+ width: number;
11
+ height: number;
12
+ gapX: number;
13
+ gapY: number;
14
+ }
15
+ export interface GridPoint {
16
+ x: number;
17
+ y: number;
18
+ }
19
+ /** Inputs shared by the drag helpers: where the pointer is, relative to what. */
20
+ export interface DragPointer {
21
+ /** Pointer position in viewport coordinates. */
22
+ pointer: GridPoint;
23
+ /** The grid's top-left corner in viewport coordinates. */
24
+ gridOrigin: GridPoint;
25
+ /** Where on the tile the pointer grabbed it, relative to the tile's top-left. */
26
+ pointerOffset: GridPoint;
27
+ }
28
+ /** Grid-relative top-left pixel of the cell a tile starts in. */
29
+ export declare function cellOrigin(position: Pick<TilePosition, 'colStart' | 'rowStart'>, cell: CellMetrics): GridPoint;
30
+ /**
31
+ * Snap a dragged tile to the nearest cell. The column is clamped so the whole
32
+ * span stays inside `cols`; the row is only clamped at the top (the grid grows
33
+ * downwards). Returns null when the cell has no size, so the gesture keeps its
34
+ * last valid target instead of handing NaN to the packer.
35
+ */
36
+ export declare function pointerToGridRect(drag: DragPointer, span: Pick<TilePosition, 'colSpan' | 'rowSpan'>, cell: CellMetrics, cols: number): GridRect | null;
37
+ /**
38
+ * The visual offset of a dragged tile from its snapped cell, so the tile
39
+ * tracks the pointer between snaps. Rounded to whole pixels.
40
+ */
41
+ export declare function dragTranslate(drag: DragPointer, snapped: GridRect, cell: CellMetrics): GridPoint;
42
+ export type ResizeHandle = 'side' | 'bottom' | 'corner';
43
+ /**
44
+ * Spans for a resize gesture: the pointer delta since pointerdown, snapped to
45
+ * whole cells. The side handle changes only columns, the bottom handle only
46
+ * rows. Columns are clamped so the tile never crosses the last column. Null
47
+ * when the cell has no size (same reason as pointerToGridRect).
48
+ */
49
+ export declare function resizeSpans(delta: GridPoint, handle: ResizeHandle, startSpans: Pick<TilePosition, 'colSpan' | 'rowSpan'>, colStart: number, cell: CellMetrics, cols: number): Pick<TilePosition, 'colSpan' | 'rowSpan'> | null;
@@ -1,8 +1,8 @@
1
- import { unsafeCSS as g, LitElement as _, nothing as a, html as m, isServer as u } from "lit";
1
+ import { unsafeCSS as v, LitElement as x, nothing as a, html as u, isServer as p } from "lit";
2
2
  import "lit/directives/ref.js";
3
- import { H as x } from "../chunks/host-aria-WSGs7SPQ.mjs";
4
- import { resolveSides as b } from "../timeline-core/index.mjs";
5
- const S = g(`:host {
3
+ import { H as I } from "../chunks/host-aria-WSGs7SPQ.mjs";
4
+ import { resolveSides as g } from "../timeline-core/index.mjs";
5
+ const y = v(`:host {
6
6
  display: block;
7
7
  box-sizing: border-box;
8
8
  --mp-tl-gap: 1rem;
@@ -49,7 +49,7 @@ const S = g(`:host {
49
49
 
50
50
  :host([orientation=horizontal][reverse]) .timeline {
51
51
  flex-direction: row-reverse;
52
- }`), I = g(`:host {
52
+ }`), A = v(`:host {
53
53
  display: block;
54
54
  box-sizing: border-box;
55
55
  outline: none;
@@ -207,12 +207,12 @@ const S = g(`:host {
207
207
  min-height: 0;
208
208
  min-width: var(--mp-tl-gap);
209
209
  }`);
210
- class y extends _ {
210
+ class k extends x {
211
211
  constructor() {
212
212
  super(...arguments), this._itemId = null, this._title = null, this._description = null, this._time = null, this._icon = null, this._color = null, this._itemClass = null, this._disabled = !1, this._selected = !1;
213
213
  }
214
214
  static {
215
- this.styles = [I];
215
+ this.styles = [A];
216
216
  }
217
217
  static get observedAttributes() {
218
218
  return [
@@ -340,7 +340,7 @@ class y extends _ {
340
340
  e ? this.hasAttribute(t) || this.setAttribute(t, "") : this.hasAttribute(t) && this.removeAttribute(t);
341
341
  }
342
342
  render() {
343
- return m`
343
+ return u`
344
344
  <div class="item ${this._itemClass ?? ""}">
345
345
  <div class="opposite">
346
346
  <slot name="opposite"><slot name="timestamp">${this._time ?? a}</slot></slot>
@@ -349,7 +349,7 @@ class y extends _ {
349
349
  <span class="marker">
350
350
  <slot name="marker">
351
351
  <span class="marker-dot">
352
- ${this._icon ? m`<i class=${this._icon} aria-hidden="true"></i>` : a}
352
+ ${this._icon ? u`<i class=${this._icon} aria-hidden="true"></i>` : a}
353
353
  </span>
354
354
  </slot>
355
355
  </span>
@@ -369,75 +369,50 @@ class y extends _ {
369
369
  `;
370
370
  }
371
371
  }
372
- typeof customElements < "u" && !customElements.get("mp-timeline-item") && customElements.define("mp-timeline-item", y);
373
- const p = /* @__PURE__ */ new Set([
372
+ typeof customElements < "u" && !customElements.get("mp-timeline-item") && customElements.define("mp-timeline-item", k);
373
+ const f = /* @__PURE__ */ new Set([
374
374
  "start",
375
375
  "end",
376
376
  "alternate",
377
377
  "alternate-reverse"
378
- ]), f = /* @__PURE__ */ new Set(["none", "single", "multiple"]);
379
- class k extends _ {
378
+ ]), _ = /* @__PURE__ */ new Set(["none", "single", "multiple"]);
379
+ class E extends x {
380
380
  constructor() {
381
- super(...arguments), this._items = [], this._selectedSet = /* @__PURE__ */ new Set(), this._orientation = "vertical", this._align = "start", this._reverse = !1, this._selectable = "none", this._activatable = !1, this._isServerSide = !1, this._inputLabel = null, this.hostAria = new x(this, {
381
+ super(...arguments), this._items = [], this._selectedSet = /* @__PURE__ */ new Set(), this._orientation = "vertical", this._align = "start", this._reverse = !1, this._selectable = "none", this._activatable = !1, this._isServerSide = !1, this._inputLabel = null, this.hostAria = new I(this, {
382
382
  referenceTarget: () => this.renderRoot?.querySelector(".timeline") ?? null
383
- }), this._selectionExplicit = !1, this._selectionSeeded = !1, this._activeIndex = -1, this._anchorIndex = -1, this._observer = null, this.onSlotChange = () => {
383
+ }), this._selectionExplicit = !1, this._selectionSeeded = !1, this._activeIndex = -1, this._anchorIndex = -1, this._observer = null, this.syncDeclarative = () => {
384
384
  this.seedDeclarativeSelection(), this.enhanceDeclarativeItems();
385
385
  }, this.onClick = (t) => {
386
- const { el: e, index: i } = this.itemFromEvent(t);
387
- if (!e || i < 0 || e.hasAttribute("disabled")) return;
388
- const n = this.modelFor(e, i);
389
- if (this.dispatchEvent(
390
- new CustomEvent("item-click", {
391
- detail: { item: n, index: i, originalEvent: t },
392
- bubbles: !0,
393
- composed: !0
394
- })
395
- ), this._selectable !== "none") {
396
- const s = t;
397
- this.applySelection(i, { toggle: s.ctrlKey || s.metaKey, range: s.shiftKey }), this.setActiveIndex(i);
398
- }
386
+ const { index: e } = this.itemFromEvent(t);
387
+ if (this.emitItemClick(e, t) && this.roving)
388
+ if (this.setActiveIndex(e), this._selectable !== "none") {
389
+ const i = t;
390
+ this.applySelection(e, { toggle: i.ctrlKey || i.metaKey, range: i.shiftKey });
391
+ } else
392
+ this.refreshItems();
399
393
  }, this.onKeydown = (t) => {
400
- if (this._selectable === "none") {
401
- if (!this._activatable) return;
402
- this.onActivatableKeydown(t);
403
- return;
404
- }
394
+ if (!this.roving) return;
405
395
  const e = this.itemElements;
406
396
  if (!e.length) return;
407
- const i = this.itemFromEvent(t).index;
408
- switch (t.key) {
409
- case "ArrowDown":
410
- case "ArrowRight": {
411
- t.preventDefault(), this.moveFocus(i, 1, e);
412
- return;
413
- }
414
- case "ArrowUp":
415
- case "ArrowLeft": {
416
- t.preventDefault(), this.moveFocus(i, -1, e);
417
- return;
418
- }
419
- case "Home": {
420
- t.preventDefault(), this.moveFocusTo(this.firstFocusable(e), e);
421
- return;
422
- }
423
- case "End": {
424
- t.preventDefault(), this.moveFocusTo(this.lastFocusable(e), e);
425
- return;
426
- }
427
- case "Enter":
428
- case " ": {
429
- if (i < 0) return;
430
- t.preventDefault(), this.applySelection(i, {
431
- toggle: t.key === " " && this._selectable === "multiple",
432
- range: t.shiftKey
433
- });
397
+ const i = this.itemFromEvent(t).index, s = this.navigationTarget(t.key, i, e);
398
+ if (s !== void 0) {
399
+ t.preventDefault(), this.moveFocusTo(s, e);
400
+ return;
401
+ }
402
+ if (!(t.key !== "Enter" && t.key !== " " || i < 0)) {
403
+ if (t.preventDefault(), this._selectable === "none") {
404
+ this.emitItemClick(i, t);
434
405
  return;
435
406
  }
407
+ this.applySelection(i, {
408
+ toggle: t.key === " " && this._selectable === "multiple",
409
+ range: t.shiftKey
410
+ });
436
411
  }
437
412
  };
438
413
  }
439
414
  static {
440
- this.styles = [S];
415
+ this.styles = [y];
441
416
  }
442
417
  static get observedAttributes() {
443
418
  return [
@@ -495,7 +470,7 @@ class k extends _ {
495
470
  return this._align;
496
471
  }
497
472
  set align(t) {
498
- const e = p.has(t) ? t : "start";
473
+ const e = f.has(t) ? t : "start";
499
474
  this._align !== e && (this._align = e, this.reflectString("align", e), this.requestUpdate());
500
475
  }
501
476
  get reverse() {
@@ -509,9 +484,21 @@ class k extends _ {
509
484
  return this._selectable;
510
485
  }
511
486
  set selectable(t) {
512
- const e = f.has(t) ? t : "none";
487
+ const e = _.has(t) ? t : "none";
513
488
  this._selectable !== e && (this._selectable = e, this.reflectString("selectable", e), this.requestUpdate());
514
489
  }
490
+ /**
491
+ * Opt-in keyboard reachability for click-only consumers (no selection): rows
492
+ * become buttons in a group with a roving tab stop, and Enter/Space emit
493
+ * `item-click`.
494
+ */
495
+ get activatable() {
496
+ return this._activatable;
497
+ }
498
+ set activatable(t) {
499
+ const e = !!t;
500
+ this._activatable !== e && (this._activatable = e, this.reflectBoolean("activatable", e), this.requestUpdate());
501
+ }
515
502
  get isServerSide() {
516
503
  return this._isServerSide;
517
504
  }
@@ -521,9 +508,7 @@ class k extends _ {
521
508
  }
522
509
  // ----- lifecycle ---------------------------------------------------------
523
510
  connectedCallback() {
524
- super.connectedCallback(), !u && !this._observer && (this._observer = new MutationObserver(() => {
525
- this.seedDeclarativeSelection(), this.enhanceDeclarativeItems();
526
- }), this._observer.observe(this, {
511
+ super.connectedCallback(), !p && !this._observer && (this._observer = new MutationObserver(this.syncDeclarative), this._observer.observe(this, {
527
512
  childList: !0,
528
513
  subtree: !0,
529
514
  attributes: !0,
@@ -540,13 +525,13 @@ class k extends _ {
540
525
  this._orientation = i === "horizontal" ? "horizontal" : "vertical";
541
526
  break;
542
527
  case "align":
543
- this._align = i && p.has(i) ? i : "start";
528
+ this._align = i && f.has(i) ? i : "start";
544
529
  break;
545
530
  case "reverse":
546
531
  this._reverse = i !== null && i !== "false";
547
532
  break;
548
533
  case "selectable":
549
- this._selectable = i && f.has(i) ? i : "none";
534
+ this._selectable = i && _.has(i) ? i : "none";
550
535
  break;
551
536
  case "is-server-side":
552
537
  this._isServerSide = i !== null && i !== "false";
@@ -566,7 +551,7 @@ class k extends _ {
566
551
  }
567
552
  }
568
553
  updated() {
569
- !u && this._items.length === 0 && this.enhanceDeclarativeItems(), this.hostAria.syncReferences();
554
+ !p && this._items.length === 0 && this.syncDeclarative(), this.hostAria.syncReferences();
570
555
  }
571
556
  reflectString(t, e) {
572
557
  this.getAttribute(t) !== e && this.setAttribute(t, e);
@@ -587,7 +572,7 @@ class k extends _ {
587
572
  // ----- render ------------------------------------------------------------
588
573
  render() {
589
574
  const t = this._selectable !== "none" ? "listbox" : this._activatable ? "group" : "list";
590
- return m`
575
+ return u`
591
576
  <div
592
577
  class="timeline"
593
578
  role=${t}
@@ -599,32 +584,32 @@ class k extends _ {
599
584
  @click=${this.onClick}
600
585
  @keydown=${this.onKeydown}
601
586
  >
602
- ${this._items.length ? this.renderDataItems() : m`<slot @slotchange=${this.onSlotChange}></slot>`}
587
+ ${this._items.length ? this.renderDataItems() : u`<slot @slotchange=${this.syncDeclarative}></slot>`}
603
588
  </div>
604
589
  `;
605
590
  }
606
591
  renderDataItems() {
607
- const t = this._items, e = this._orientation, i = this._selectable, n = this._reverse, s = b(t.length, this._align, n), l = this.resolvedActiveIndex(t.length, (r) => !t[r].disabled);
608
- return m`
609
- ${t.map((r, o) => {
610
- const c = this.idForItem(r, o), h = n ? o === 0 : o === t.length - 1, d = i !== "none" && this.isSelected(c), A = r.time instanceof Date ? r.time.toLocaleDateString() : r.time;
611
- return m`<mp-timeline-item
592
+ const t = this._items, e = this._orientation, i = this._selectable, s = this._reverse, n = g(t.length, this._align, s), l = this.resolvedActiveIndex(t.length, (r) => !t[r].disabled);
593
+ return u`
594
+ ${t.map((r, c) => {
595
+ const o = this.idForItem(r, c), h = s ? c === 0 : c === t.length - 1, m = i !== "none" && this.isSelected(o), S = r.time instanceof Date ? r.time.toLocaleDateString() : r.time;
596
+ return u`<mp-timeline-item
612
597
  item-id=${r.id ?? a}
613
598
  title=${r.title ?? a}
614
599
  description=${r.description ?? a}
615
- time=${A ?? a}
600
+ time=${S ?? a}
616
601
  icon=${r.icon ?? a}
617
602
  color=${r.color ?? a}
618
603
  item-class=${r.cssClass ?? a}
619
604
  ?disabled=${!!r.disabled}
620
- side=${s[o]}
605
+ side=${n[c]}
621
606
  orientation=${e}
622
607
  ?last=${h}
623
- role=${i !== "none" ? "option" : this._activatable ? "button" : "listitem"}
624
- ?selected=${d}
625
- aria-selected=${i !== "none" ? d ? "true" : "false" : a}
626
- tabindex=${i !== "none" || this._activatable ? o === l ? "0" : "-1" : a}
627
- data-index=${o}
608
+ role=${this.itemRole}
609
+ ?selected=${m}
610
+ aria-selected=${i !== "none" ? m ? "true" : "false" : a}
611
+ tabindex=${this.roving ? c === l ? "0" : "-1" : a}
612
+ data-index=${c}
628
613
  ></mp-timeline-item>`;
629
614
  })}
630
615
  `;
@@ -639,70 +624,83 @@ class k extends _ {
639
624
  seedDeclarativeSelection() {
640
625
  if (this._selectionExplicit || this._selectionSeeded) return;
641
626
  const t = this.declarativeItems;
642
- t.length && (t.forEach((e, i) => {
643
- e.hasAttribute("selected") && this._selectedSet.add(this.idForElement(e, i));
644
- }), this._selectionSeeded = !0);
627
+ if (!t.length) return;
628
+ const e = t.flatMap(
629
+ (i, s) => i.hasAttribute("selected") ? [this.idForElement(i, s)] : []
630
+ );
631
+ this._selectedSet = /* @__PURE__ */ new Set([...this._selectedSet, ...e]), this._selectionSeeded = !0;
645
632
  }
633
+ /**
634
+ * Projects the container state onto slotted items — the same role, selection
635
+ * and roving-tabindex contract `renderDataItems` renders in data mode.
636
+ */
646
637
  enhanceDeclarativeItems() {
647
638
  const t = this.declarativeItems;
648
639
  if (!t.length) return;
649
- const e = this._orientation, i = this._selectable, n = this._reverse, s = b(t.length, this._align, n), l = n ? 0 : t.length - 1, r = this.resolvedActiveIndex(t.length, (o) => !t[o].hasAttribute("disabled"));
650
- t.forEach((o, c) => {
651
- if (o.setAttribute("side", s[c]), o.setAttribute("orientation", e), c === l ? o.setAttribute("last", "") : o.removeAttribute("last"), i !== "none") {
652
- const h = this.isSelected(this.idForElement(o, c));
653
- o.setAttribute("role", "option"), h ? o.setAttribute("selected", "") : o.removeAttribute("selected"), o.setAttribute("aria-selected", h ? "true" : "false"), o.setAttribute("tabindex", c === r ? "0" : "-1");
640
+ const e = this._orientation, i = this._selectable !== "none", s = this.roving, n = this.itemRole, l = g(t.length, this._align, this._reverse), r = this._reverse ? 0 : t.length - 1, c = this.resolvedActiveIndex(t.length, (o) => d(t[o]));
641
+ t.map((o, h) => {
642
+ if (o.setAttribute("side", l[h]), o.setAttribute("orientation", e), o.toggleAttribute("last", h === r), o.setAttribute("role", n), i) {
643
+ const m = this.isSelected(this.idForElement(o, h));
644
+ o.toggleAttribute("selected", m), o.setAttribute("aria-selected", m ? "true" : "false");
654
645
  } else
655
- o.setAttribute("role", "listitem"), o.removeAttribute("aria-selected"), o.removeAttribute("tabindex");
646
+ o.removeAttribute("aria-selected");
647
+ return s ? o.setAttribute("tabindex", h === c ? "0" : "-1") : o.removeAttribute("tabindex"), o;
656
648
  });
657
649
  }
658
- /** The item-click emission shared by pointer and keyboard activation. */
650
+ /** Re-applies roving tabindex / selection state after an interaction. */
651
+ refreshItems() {
652
+ this._items.length ? this.requestUpdate() : this.enhanceDeclarativeItems();
653
+ }
654
+ // ----- interaction -------------------------------------------------------
655
+ /** Items are keyboard-reachable when selectable, or opted in via `activatable`. */
656
+ get roving() {
657
+ return this._selectable !== "none" || this._activatable;
658
+ }
659
+ /**
660
+ * activatable-without-selection = buttons in a group: a `listitem` may not be
661
+ * interactive, so the item role follows what the items actually are.
662
+ */
663
+ get itemRole() {
664
+ return this._selectable !== "none" ? "option" : this._activatable ? "button" : "listitem";
665
+ }
666
+ /**
667
+ * The item-click emission shared by pointer and keyboard activation.
668
+ * Returns false when there is no enabled item at `index`.
669
+ */
659
670
  emitItemClick(t, e) {
660
671
  const i = this.itemElements[t];
661
- if (!i || i.hasAttribute("disabled")) return;
662
- const n = this.modelFor(i, t);
663
- this.dispatchEvent(
672
+ return !i || !d(i) ? !1 : (this.dispatchEvent(
664
673
  new CustomEvent("item-click", {
665
- detail: { item: n, index: t, originalEvent: e },
674
+ detail: { item: this.modelFor(i, t), index: t, originalEvent: e },
666
675
  bubbles: !0,
667
676
  composed: !0
668
677
  })
669
- );
678
+ ), !0);
670
679
  }
671
- /** Arrows rove; Enter/Space emit item-click — activation without selection. */
672
- onActivatableKeydown(t) {
673
- const e = this.itemElements;
674
- if (!e.length) return;
675
- const i = this.itemFromEvent(t).index;
676
- switch (t.key) {
680
+ /** The index a navigation key moves to, or undefined for a non-navigation key. */
681
+ navigationTarget(t, e, i) {
682
+ switch (t) {
677
683
  case "ArrowDown":
678
684
  case "ArrowRight":
679
- t.preventDefault(), this.moveFocus(i, 1, e);
680
- return;
685
+ return this.stepFrom(e, 1, i);
681
686
  case "ArrowUp":
682
687
  case "ArrowLeft":
683
- t.preventDefault(), this.moveFocus(i, -1, e);
684
- return;
688
+ return this.stepFrom(e, -1, i);
685
689
  case "Home":
686
- t.preventDefault(), this.moveFocusTo(this.firstFocusable(e), e);
687
- return;
690
+ return i.findIndex(d);
688
691
  case "End":
689
- t.preventDefault(), this.moveFocusTo(this.lastFocusable(e), e);
690
- return;
691
- case "Enter":
692
- case " ": {
693
- if (i < 0) return;
694
- t.preventDefault(), this.emitItemClick(i, t);
692
+ return i.reduce((s, n, l) => d(n) ? l : s, -1);
693
+ default:
695
694
  return;
696
- }
697
695
  }
698
696
  }
699
697
  itemFromEvent(t) {
700
698
  const i = t.composedPath().find(
701
- (s) => s instanceof HTMLElement && s.tagName === "MP-TIMELINE-ITEM"
699
+ (n) => n instanceof HTMLElement && n.tagName === "MP-TIMELINE-ITEM"
702
700
  );
703
701
  if (!i) return { el: null, index: -1 };
704
- const n = this.itemElements.indexOf(i);
705
- return { el: i, index: n };
702
+ const s = this.itemElements.indexOf(i);
703
+ return { el: i, index: s };
706
704
  }
707
705
  modelFor(t, e) {
708
706
  return this._items.length ? this._items[e] : {
@@ -717,38 +715,34 @@ class k extends _ {
717
715
  }
718
716
  // ----- selection ---------------------------------------------------------
719
717
  applySelection(t, e) {
720
- const i = this.itemElements, n = i[t];
721
- if (!n || n.hasAttribute("disabled")) return;
722
- const s = this.idForId(t, n), l = new Set(this._selectedSet);
718
+ const i = this.itemElements, s = i[t];
719
+ if (!s || !d(s)) return;
720
+ const n = this.idForId(t, s), l = new Set(this._selectedSet);
723
721
  if (this._selectable === "single")
724
- this._selectedSet = /* @__PURE__ */ new Set([s]);
722
+ this._selectedSet = /* @__PURE__ */ new Set([n]);
725
723
  else if (e.range && this._anchorIndex >= 0) {
726
- const [r, o] = [Math.min(this._anchorIndex, t), Math.max(this._anchorIndex, t)], c = new Set(this._selectedSet);
727
- for (let h = r; h <= o; h++) {
728
- const d = i[h];
729
- d && !d.hasAttribute("disabled") && c.add(this.idForId(h, d));
730
- }
731
- this._selectedSet = c;
724
+ const r = Math.min(this._anchorIndex, t), c = Math.max(this._anchorIndex, t), o = i.slice(r, c + 1).flatMap((h, m) => d(h) ? [this.idForId(r + m, h)] : []);
725
+ this._selectedSet = /* @__PURE__ */ new Set([...this._selectedSet, ...o]);
732
726
  } else if (e.toggle) {
733
727
  const r = new Set(this._selectedSet);
734
- r.has(s) ? r.delete(s) : r.add(s), this._selectedSet = r, this._anchorIndex = t;
728
+ r.has(n) ? r.delete(n) : r.add(n), this._selectedSet = r, this._anchorIndex = t;
735
729
  } else
736
- this._selectedSet = /* @__PURE__ */ new Set([s]), this._anchorIndex = t;
730
+ this._selectedSet = /* @__PURE__ */ new Set([n]), this._anchorIndex = t;
737
731
  this.emitSelectionChange(l), this.requestUpdate(), this._items.length === 0 && this.enhanceDeclarativeItems();
738
732
  }
739
733
  idForId(t, e) {
740
734
  return this._items.length ? this.idForItem(this._items[t], t) : this.idForElement(e, t);
741
735
  }
742
736
  emitSelectionChange(t) {
743
- const e = this._selectedSet, i = [...e].filter((l) => !t.has(l)), n = [...t].filter((l) => !e.has(l));
744
- if (!i.length && !n.length) return;
745
- const s = (l) => l.map((r) => this.modelById(r)).filter((r) => r !== null);
737
+ const e = this._selectedSet, i = [...e].filter((l) => !t.has(l)), s = [...t].filter((l) => !e.has(l));
738
+ if (!i.length && !s.length) return;
739
+ const n = (l) => l.map((r) => this.modelById(r)).filter((r) => r !== null);
746
740
  this.dispatchEvent(
747
741
  new CustomEvent("selection-change", {
748
742
  detail: {
749
- selected: s([...e]),
750
- added: s(i),
751
- removed: s(n)
743
+ selected: n([...e]),
744
+ added: n(i),
745
+ removed: n(s)
752
746
  },
753
747
  bubbles: !0,
754
748
  composed: !0
@@ -757,44 +751,42 @@ class k extends _ {
757
751
  }
758
752
  modelById(t) {
759
753
  if (this._items.length) {
760
- const n = this._items.findIndex((s, l) => this.idForItem(s, l) === t);
761
- return n >= 0 ? this._items[n] : null;
754
+ const s = this._items.findIndex((n, l) => this.idForItem(n, l) === t);
755
+ return s >= 0 ? this._items[s] : null;
762
756
  }
763
- const e = this.declarativeItems, i = e.findIndex((n, s) => this.idForElement(n, s) === t);
757
+ const e = this.declarativeItems, i = e.findIndex((s, n) => this.idForElement(s, n) === t);
764
758
  return i >= 0 ? this.modelFor(e[i], i) : null;
765
759
  }
766
760
  // ----- roving tabindex ---------------------------------------------------
767
761
  resolvedActiveIndex(t, e) {
768
- if (this._activeIndex >= 0 && this._activeIndex < t && e(this._activeIndex))
769
- return this._activeIndex;
770
- for (let i = 0; i < t; i++) if (e(i)) return i;
771
- return -1;
762
+ return this._activeIndex >= 0 && this._activeIndex < t && e(this._activeIndex) ? this._activeIndex : Array.from({ length: t }, (i, s) => s).find(e) ?? -1;
772
763
  }
773
764
  setActiveIndex(t) {
774
765
  this._activeIndex = t;
775
766
  }
776
- moveFocus(t, e, i) {
777
- let s = t < 0 ? this.resolvedActiveIndex(i.length, (l) => !i[l].hasAttribute("disabled")) : t;
778
- for (let l = 0; l < i.length && (s = (s + e + i.length) % i.length, !!i[s].hasAttribute("disabled")); l++)
779
- ;
780
- this.moveFocusTo(s, i);
767
+ /**
768
+ * The next enabled item from `from` in direction `dir`, wrapping; -1 when no
769
+ * item is enabled. A `from` of -1 (focus not on an item) starts at the
770
+ * current tab stop.
771
+ */
772
+ stepFrom(t, e, i) {
773
+ const s = i.length, n = t < 0 ? this.resolvedActiveIndex(s, (l) => d(i[l])) : t;
774
+ return Array.from({ length: s }, (l, r) => ((n + e * (r + 1)) % s + s) % s).find(
775
+ (l) => d(i[l])
776
+ ) ?? -1;
781
777
  }
782
778
  moveFocusTo(t, e) {
783
- t < 0 || t >= e.length || (this.setActiveIndex(t), this._items.length ? this.requestUpdate() : this.enhanceDeclarativeItems(), requestAnimationFrame(() => this.itemElements[t]?.focus()));
784
- }
785
- firstFocusable(t) {
786
- return t.findIndex((e) => !e.hasAttribute("disabled"));
787
- }
788
- lastFocusable(t) {
789
- for (let e = t.length - 1; e >= 0; e--) if (!t[e].hasAttribute("disabled")) return e;
790
- return -1;
779
+ t < 0 || t >= e.length || (this.setActiveIndex(t), this.refreshItems(), requestAnimationFrame(() => this.itemElements[t]?.focus()));
791
780
  }
792
781
  }
793
- typeof customElements < "u" && !customElements.get("mp-timeline") && customElements.define("mp-timeline", k);
782
+ function d(b) {
783
+ return !b.hasAttribute("disabled");
784
+ }
785
+ typeof customElements < "u" && !customElements.get("mp-timeline") && customElements.define("mp-timeline", E);
794
786
  export {
795
- k as MpTimeline,
796
- y as MpTimelineItem,
797
- b as resolveSides,
798
- I as timelineItemStyles,
799
- S as timelineStyles
787
+ E as MpTimeline,
788
+ k as MpTimelineItem,
789
+ g as resolveSides,
790
+ A as timelineItemStyles,
791
+ y as timelineStyles
800
792
  };