@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
@@ -1,30 +1,30 @@
1
- import { unsafeCSS as F, LitElement as E, nothing as u, render as v } from "lit";
2
- import { O as I } from "./overlay-controller-DifgO6jT.mjs";
3
- import { s as L, i as M } from "./install-light-styles-DbCAGFOC.mjs";
4
- import { L as P } from "./live-announcer-Bi0orG4n.mjs";
5
- import { a as k, F as z } from "./focus-restore-DxuP1Oe2.mjs";
6
- import { H as q } from "./host-aria-WSGs7SPQ.mjs";
1
+ import { unsafeCSS as E, LitElement as M, nothing as u, render as v } from "lit";
2
+ import { O as L } from "./overlay-controller-BHDagokg.mjs";
3
+ import { s as I, i as q } from "./install-light-styles-DbCAGFOC.mjs";
4
+ import { L as z } from "./live-announcer-Bi0orG4n.mjs";
5
+ import { a as K, F as A } from "./focus-restore-DxuP1Oe2.mjs";
6
+ import { H as U } from "./host-aria-WSGs7SPQ.mjs";
7
7
  import { repeat as x } from "lit/directives/repeat.js";
8
- import { live as K } from "lit/directives/live.js";
9
- import { classMap as C } from "lit/directives/class-map.js";
8
+ import { live as O } from "lit/directives/live.js";
9
+ import { classMap as w } from "lit/directives/class-map.js";
10
10
  import { styleMap as _ } from "lit/directives/style-map.js";
11
- import "./mp-pagination-Dea75mD4.mjs";
12
- import "./mp-checkbox-CzwS7Y_t.mjs";
13
- const A = {
11
+ import "./mp-pagination-hGy4dL7p.mjs";
12
+ import "./mp-checkbox-zV83gILn.mjs";
13
+ const T = {
14
14
  eq: "equals",
15
15
  neq: "does not equal",
16
16
  lt: "is less than",
17
17
  lte: "is at most",
18
18
  gt: "is greater than",
19
19
  gte: "is at least"
20
- }, U = {
20
+ }, D = {
21
21
  eq: "=",
22
22
  neq: "≠",
23
23
  lt: "<",
24
24
  lte: "≤",
25
25
  gt: ">",
26
26
  gte: "≥"
27
- }, T = ["eq", "neq", "lt", "lte", "gt", "gte"], O = {
27
+ }, N = ["eq", "neq", "lt", "lte", "gt", "gte"], W = {
28
28
  treeChevronColumn: "Expand or collapse",
29
29
  deselectAll: "Deselect all",
30
30
  selectAll: "Select all",
@@ -34,6 +34,7 @@ const A = {
34
34
  rowsPerPage: "Rows per page",
35
35
  resizeColumn: (n) => `Resize column ${n}`,
36
36
  selectRow: (n) => `Select row ${n}`,
37
+ selectRowNamed: (n) => `Select ${n}`,
37
38
  filterColumn: (n) => `Filter ${n}`,
38
39
  filterColumnActive: (n, e) => e ? `Filter ${n}, filtered by ${e}` : `Filter ${n}, filtered`,
39
40
  filterClear: (n) => `Clear the filter on ${n}`,
@@ -52,19 +53,20 @@ const A = {
52
53
  announceFilter: (n, e) => e === 0 ? `Filter cleared on ${n}` : e === 1 ? `1 value selected in ${n}` : `${e} values selected in ${n}`,
53
54
  filterOperator: "Comparison",
54
55
  filterOperand: "Value to compare with",
55
- filterOperatorLabel: (n) => A[n],
56
+ filterOperatorLabel: (n) => T[n],
56
57
  announceComparisonFilter: (n, e, t) => t === "" ? `Filter cleared on ${n}` : `${n} ${e} ${t}`,
57
58
  announceSorted: (n, e) => e === "none" ? `Sorting removed from ${n}` : `Sorted by ${n}, ${e}`,
58
59
  announcePage: (n, e) => `Page ${n} of ${e}`,
59
60
  announceSelection: (n) => n === 1 ? "1 row selected" : `${n} rows selected`,
60
- announceLoaded: (n) => n === 1 ? "Loaded 1 row" : `Loaded ${n} rows`
61
- }, D = F(`@charset "UTF-8";
61
+ announceLoaded: (n) => n === 1 ? "Loaded 1 row" : `Loaded ${n} rows`,
62
+ rangeIncomplete: "Range not selected: some rows in it have not loaded yet"
63
+ }, B = E(`@charset "UTF-8";
62
64
  mp-datatable {
63
65
  display: block;
64
66
  width: 100%;
65
67
  position: relative;
66
68
  --mp-datatable-border-color: var(--bs-border-color, rgba(0, 0, 0, 0.125));
67
- --mp-datatable-row-hover-bg: var(--bs-table-hover-bg, rgba(0, 0, 0, 0.04));
69
+ --mp-datatable-row-hover-bg: var(--bs-table-hover-bg, rgba(var(--bs-emphasis-color-rgb), 0.04));
68
70
  --mp-datatable-row-selected-bg: var(--bs-list-group-active-bg, var(--bs-primary, #0d6efd));
69
71
  --mp-datatable-row-selected-color: var(--bs-list-group-active-color, #fff);
70
72
  --mp-datatable-cut-opacity: 0.55;
@@ -269,6 +271,10 @@ tr[data-mps=datatable] > .checkbox-cell[data-mps=datatable] {
269
271
  text-overflow: clip;
270
272
  }
271
273
 
274
+ .checkbox-cell.checkbox-cell-toggles[data-mps=datatable] {
275
+ cursor: pointer;
276
+ }
277
+
272
278
  .tree-chevron-cell[data-mps=datatable] {
273
279
  width: 2rem;
274
280
  padding-right: 0;
@@ -358,7 +364,7 @@ tr.filter-row[data-mps=datatable] th[data-mps=datatable] {
358
364
  }
359
365
 
360
366
  .filter-trigger:hover[data-mps=datatable] {
361
- background-color: var(--mp-datatable-row-hover-bg, rgba(0, 0, 0, 0.04));
367
+ background-color: var(--mp-datatable-row-hover-bg, rgba(var(--bs-emphasis-color-rgb), 0.04));
362
368
  }
363
369
 
364
370
  .filter-trigger:focus-visible[data-mps=datatable] {
@@ -367,7 +373,7 @@ tr.filter-row[data-mps=datatable] th[data-mps=datatable] {
367
373
  }
368
374
 
369
375
  .filter-trigger[aria-expanded=true][data-mps=datatable] {
370
- background-color: var(--mp-datatable-row-hover-bg, rgba(0, 0, 0, 0.04));
376
+ background-color: var(--mp-datatable-row-hover-bg, rgba(var(--bs-emphasis-color-rgb), 0.04));
371
377
  border-color: var(--mp-datatable-border-color);
372
378
  }
373
379
 
@@ -514,7 +520,7 @@ tr.filter-row[data-mps=datatable] th[data-mps=datatable] {
514
520
  }
515
521
 
516
522
  .filter-option:hover[data-mps=datatable] {
517
- background-color: var(--mp-datatable-row-hover-bg, rgba(0, 0, 0, 0.04));
523
+ background-color: var(--mp-datatable-row-hover-bg, rgba(var(--bs-emphasis-color-rgb), 0.04));
518
524
  }
519
525
 
520
526
  .filter-remaining[data-mps=datatable] {
@@ -544,12 +550,12 @@ tr.filter-row[data-mps=datatable] th[data-mps=datatable] {
544
550
  transition: none !important;
545
551
  }
546
552
  }`);
547
- function N(n, e, t) {
553
+ function H(n, e, t) {
548
554
  if (t) {
549
- const i = n.findIndex((s) => s.property === e);
550
- return i === -1 ? [...n, { property: e, direction: "ascending" }] : n[i].direction === "ascending" ? n.map(
551
- (s, r) => r === i ? { ...s, direction: "descending" } : s
552
- ) : n.filter((s, r) => r !== i);
555
+ const s = n.findIndex((i) => i.property === e);
556
+ return s === -1 ? [...n, { property: e, direction: "ascending" }] : n[s].direction === "ascending" ? n.map(
557
+ (i, r) => r === s ? { ...i, direction: "descending" } : i
558
+ ) : n.filter((i, r) => r !== s);
553
559
  }
554
560
  const a = n.length === 1 && n[0].property === e;
555
561
  return [
@@ -561,10 +567,10 @@ function N(n, e, t) {
561
567
  }
562
568
  function y(n, e) {
563
569
  return e.length === 0 ? n.slice() : n.map((t, a) => ({ row: t, index: a })).sort((t, a) => {
564
- for (const i of e) {
565
- const s = S(t.row, i.property), r = S(a.row, i.property), o = W(s, r);
570
+ for (const s of e) {
571
+ const i = S(t.row, s.property), r = S(a.row, s.property), o = V(i, r);
566
572
  if (o !== 0)
567
- return i.direction === "ascending" ? o : -o;
573
+ return s.direction === "ascending" ? o : -o;
568
574
  }
569
575
  return t.index - a.index;
570
576
  }).map(({ row: t }) => t);
@@ -573,23 +579,27 @@ function S(n, e) {
573
579
  if (!(n == null || typeof n != "object"))
574
580
  return n[e];
575
581
  }
576
- function W(n, e) {
582
+ function V(n, e) {
577
583
  return n === e ? 0 : n == null ? 1 : e == null ? -1 : typeof n == "number" && typeof e == "number" ? n - e : n instanceof Date && e instanceof Date ? n.getTime() - e.getTime() : String(n).localeCompare(String(e));
578
584
  }
579
- const h = L("datatable");
585
+ const F = 40, R = 10;
580
586
  function $(n, e) {
587
+ return Math.max(F, n + e);
588
+ }
589
+ const c = I("datatable");
590
+ function P(n, e) {
581
591
  return n === e || n !== n && e !== e;
582
592
  }
583
593
  function g(n, e) {
584
- return n.some((t) => $(t.value, e));
594
+ return n.some((t) => P(t.value, e));
585
595
  }
586
- const H = 250;
587
- let B = 0;
588
- class V extends E {
596
+ const G = 250;
597
+ let j = 0;
598
+ class X extends M {
589
599
  constructor() {
590
- super(...arguments), this.instanceId = `mp-datatable-${++B}`, this._caption = null, this._inputLabel = null, this.hostAria = new q(this, {
600
+ super(...arguments), this.instanceId = `mp-datatable-${++j}`, this._caption = null, this._inputLabel = null, this.hostAria = new U(this, {
591
601
  referenceTarget: () => this.renderRoot?.querySelector("table") ?? null
592
- }), this.labels = void 0, this._columns = [], this._data = [], this._sortColumns = [], this._selectionMode = "none", this._selectedIds = /* @__PURE__ */ new Set(), this._cutIds = /* @__PURE__ */ new Set(), this._focusedRowKey = null, this.liveAnnouncer = new P(this), this.rowFocusRestore = new k(this, new z(
602
+ }), this._labels = void 0, this._columns = [], this._data = [], this._sortColumns = [], this._selectionMode = "none", this._selectedIds = /* @__PURE__ */ new Set(), this._selectedRowCache = /* @__PURE__ */ new Map(), this._cutIds = /* @__PURE__ */ new Set(), this._focusedRowKey = null, this.liveAnnouncer = new z(this), this.rowFocusRestore = new K(this, new A(
593
603
  () => this.renderRoot ?? null,
594
604
  {
595
605
  selector: 'tbody tr[data-row-key]:not([data-placeholder="true"])',
@@ -598,8 +608,8 @@ class V extends E {
598
608
  }
599
609
  )), this._rowKey = (e, t) => {
600
610
  const a = e;
601
- return a && a.id != null ? String(a.id) : `row-${t}`;
602
- }, this._columnWidths = /* @__PURE__ */ new Map(), this._hasMeasuredInitial = !1, this._loading = !1, this._emptyMessage = "No data", this._pagination = !1, this._page = 1, this._perPage = 20, this._perPageOptions = [10, 20, 50], this._autoSort = !0, this._totalRecords = null, this._virtualScroll = !1, this._itemSize = 40, this._virtualBuffer = 10, this._virtualRange = { startIndex: 0, endIndex: 0 }, this._scrollElement = null, this._resizeObserver = null, this._scrollListener = null, this._viewportHeight = 0, this._openFilterColumn = null, this._mountedFilterColumn = null, this._consumerMountedFilter = !1, this._filterUid = `mp-dt-${Math.random().toString(36).slice(2, 9)}`, this._distincts = null, this._filterStates = /* @__PURE__ */ new Map(), this._tree = !1, this._idKey = null, this._childCountKey = null, this._treeIndent = 1.25, this._expandedIds = /* @__PURE__ */ new Set(), this._selectionStrategy = "flat", this._childCache = /* @__PURE__ */ new Map(), this._childTotals = /* @__PURE__ */ new Map(), this._pendingFetches = /* @__PURE__ */ new Set(), this._pageCache = /* @__PURE__ */ new Map(), this._pendingPageFetches = /* @__PURE__ */ new Set(), this._fetch = null, this._fetchGeneration = 0, this._initialFetchDone = !1, this._reloadScheduled = !1, this._lastReloadKey = null, this._cachedFlatList = null, this._cachedIndeterminateKeys = null, this._resizableColumns = !0, this.filterOverlay = new I(this, {
611
+ return a && a.id != null ? String(a.id) : (this.warnPositionalKeyOnce(), `row-${t}`);
612
+ }, this._warnedPositionalKey = !1, this._columnWidths = /* @__PURE__ */ new Map(), this._hasMeasuredInitial = !1, this._loading = !1, this._emptyMessage = "No data", this._pagination = !1, this._page = 1, this._perPage = 20, this._perPageOptions = [10, 20, 50], this._autoSort = !0, this._totalRecords = null, this._virtualScroll = !1, this._itemSize = 40, this._virtualBuffer = 10, this._virtualRange = { startIndex: 0, endIndex: 0 }, this._scrollElement = null, this._resizeObserver = null, this._scrollListener = null, this._viewportHeight = 0, this._openFilterColumn = null, this._mountedFilterColumn = null, this._consumerMountedFilter = !1, this._filterUid = `mp-dt-${Math.random().toString(36).slice(2, 9)}`, this._distincts = null, this._filterStates = /* @__PURE__ */ new Map(), this._tree = !1, this._idKey = null, this._childCountKey = null, this._treeIndent = 1.25, this._expandedIds = /* @__PURE__ */ new Set(), this._selectionStrategy = "flat", this._childCache = /* @__PURE__ */ new Map(), this._childTotals = /* @__PURE__ */ new Map(), this._pendingFetches = /* @__PURE__ */ new Set(), this._pageCache = /* @__PURE__ */ new Map(), this._pendingPageFetches = /* @__PURE__ */ new Set(), this._fetch = null, this._fetchGeneration = 0, this._initialFetchDone = !1, this._reloadScheduled = !1, this._lastReloadKey = null, this._cachedFlatList = null, this._cachedIndeterminateKeys = null, this._rowLabel = null, this._resizableColumns = !0, this.filterOverlay = new L(this, {
603
613
  portal: !0,
604
614
  modal: !0,
605
615
  scrollStrategy: "reposition",
@@ -630,10 +640,10 @@ class V extends E {
630
640
  })
631
641
  );
632
642
  }
633
- }), this._selectionAnchorKey = null, this.resizeState = null, this.onColumnResizeMove = (e) => {
643
+ }), this._keyByRowMemo = null, this._selectionAnchorKey = null, this.resizeState = null, this.onColumnResizeMove = (e) => {
634
644
  if (!this.resizeState) return;
635
- const t = e.clientX - this.resizeState.startX, a = Math.max(40, this.resizeState.startWidth + t);
636
- this._columnWidths = new Map(this._columnWidths), this._columnWidths.set(this.resizeState.columnName, a), this.requestUpdate();
645
+ const t = $(this.resizeState.startWidth, e.clientX - this.resizeState.startX);
646
+ this._columnWidths = new Map(this._columnWidths), this._columnWidths.set(this.resizeState.columnName, t), this.requestUpdate();
637
647
  }, this.onColumnResizeEnd = (e) => {
638
648
  if (this.resizeState) {
639
649
  this.resizeState.handle.classList.remove("active"), this.resizeState.handle.removeEventListener("pointermove", this.onColumnResizeMove), this.resizeState.handle.removeEventListener("pointerup", this.onColumnResizeEnd), this.resizeState.handle.removeEventListener("pointercancel", this.onColumnResizeEnd);
@@ -693,9 +703,22 @@ class V extends E {
693
703
  const t = e ?? null;
694
704
  this._caption !== t && (this._caption = t, this.requestUpdate());
695
705
  }
706
+ /**
707
+ * User-visible strings, overridable per key for localisation
708
+ * (see DatatableLabels). Property-only: it holds functions. Re-renders on
709
+ * assignment, so switching language on a mounted table renames every
710
+ * control (row-checkbox names included) without waiting for an unrelated
711
+ * update.
712
+ */
713
+ get labels() {
714
+ return this._labels;
715
+ }
716
+ set labels(e) {
717
+ e !== this._labels && (this._labels = e, this.requestUpdate());
718
+ }
696
719
  /** Merged view of labels — consumer keys over the English defaults. */
697
720
  get mergedLabels() {
698
- return { ...O, ...this.labels ?? {} };
721
+ return { ...W, ...this.labels ?? {} };
699
722
  }
700
723
  /** Optional invisible accessible name for the <table>. Host aria-label wins. */
701
724
  get inputLabel() {
@@ -705,6 +728,15 @@ class V extends E {
705
728
  const t = e ?? null;
706
729
  this._inputLabel !== t && (this._inputLabel = t, this.requestUpdate());
707
730
  }
731
+ /**
732
+ * Warn rather than throw: a static table without ids keeps working, and only
733
+ * a fetched or selectable one is actually harmed by a positional key.
734
+ */
735
+ warnPositionalKeyOnce() {
736
+ this._warnedPositionalKey || !this._fetch && this._selectionMode === "none" || (this._warnedPositionalKey = !0, console.warn(
737
+ "[mp-datatable] A row has no `id` and no `rowKey` is set, so it is keyed by its position. A positional key names a different row after a re-fetch, sort or expansion, so a selection cannot survive them. Set `rowKey` to return a stable identity."
738
+ ));
739
+ }
708
740
  /** When true, the WC sorts `data` itself using `sortRows`. Set `false` if the consumer sorts externally. */
709
741
  get autoSort() {
710
742
  return this._autoSort;
@@ -736,7 +768,7 @@ class V extends E {
736
768
  return this._itemSize;
737
769
  }
738
770
  set itemSize(e) {
739
- const t = Math.max(1, Math.floor(e || 0)) || 40;
771
+ const t = Number.isFinite(e) && e > 0 ? Math.max(1, Math.floor(e)) : 40;
740
772
  this._itemSize !== t && (this._itemSize = t, this.requestUpdate());
741
773
  }
742
774
  /** Off-screen row buffer (each side) for virtual scrolling. */
@@ -793,16 +825,25 @@ class V extends E {
793
825
  * loop and the consumer provides nothing else — no page-1 seeding via `data`,
794
826
  * no separate `totalRecords`, no event bridge. Works with any framework or
795
827
  * none (`el.fetch = fn`). Setting it kicks off the initial page-1 load.
828
+ *
829
+ * Pass a STABLE function. Assigning the same function again is a no-op, but
830
+ * a new closure on every render is a new callback, and each one reloads. To
831
+ * re-query with an unchanged callback, call `reload()`.
796
832
  */
797
833
  get fetch() {
798
834
  return this._fetch;
799
835
  }
800
836
  set fetch(e) {
801
- if (this._fetch = typeof e == "function" ? e : null, this._fetch) {
802
- this._autoSort = !1, this._initialFetchDone = !1, this._lastReloadKey = null, this.scheduleFetchReload();
803
- return;
804
- }
805
- this._totalRecords = null, this._pageCache.clear(), this._pendingPageFetches.clear(), this._childCache.clear(), this._childTotals.clear(), this._pendingFetches.clear(), this._fetchGeneration++, this._initialFetchDone = !1, this._lastReloadKey = null, this.requestUpdate();
837
+ this.assignFetch(e) && this.scheduleFetchReload();
838
+ }
839
+ /**
840
+ * Assigns the callback without scheduling a load; true when a load is due.
841
+ * Shared by the setter and `applyFetchState`, which schedules once for all
842
+ * of its fields.
843
+ */
844
+ assignFetch(e) {
845
+ const t = typeof e == "function" ? e : null;
846
+ return t === this._fetch ? !1 : (this._fetch = t, this._fetch ? (this._autoSort = !1, this._initialFetchDone = !1, this._lastReloadKey = null, !0) : (this._totalRecords = null, this._pageCache.clear(), this._pendingPageFetches.clear(), this._childCache.clear(), this._childTotals.clear(), this._pendingFetches.clear(), this._fetchGeneration++, this._initialFetchDone = !1, this._lastReloadKey = null, this.requestUpdate(), !1));
806
847
  }
807
848
  /**
808
849
  * Consumer-supplied source of distinct values for the filter panels.
@@ -823,19 +864,101 @@ class V extends E {
823
864
  return [...this._sortColumns];
824
865
  }
825
866
  set sortColumns(e) {
826
- this._sortColumns = Array.isArray(e) ? [...e] : [], this.requestUpdate(), this.scheduleFetchReload();
867
+ this.assignSortColumns(e) && (this.requestUpdate(), this.scheduleFetchReload());
868
+ }
869
+ /**
870
+ * Assigns without scheduling; false when the value is structurally equal. A
871
+ * wrapper echoing back the array it was just given is not a sort change, and
872
+ * must not cost a re-render or a request (#407).
873
+ */
874
+ assignSortColumns(e) {
875
+ const t = Array.isArray(e) ? [...e] : [];
876
+ return t.length === this._sortColumns.length && t.every((s, i) => s.property === this._sortColumns[i].property && s.direction === this._sortColumns[i].direction) ? !1 : (this._sortColumns = t, !0);
877
+ }
878
+ /**
879
+ * Re-queries the `fetch` callback for the current sort, page and page size,
880
+ * even though none of them changed (the server data did). One request,
881
+ * coalesced with any change already pending in the same task.
882
+ *
883
+ * The loaded windows and tree children are dropped, because they may be
884
+ * stale. The selection is NOT: every selected key and its remembered row
885
+ * survive, so a re-fetched row simply replaces the remembered one.
886
+ *
887
+ * `resetPage: true` also returns to page 1 (and emits
888
+ * `mp-datatable-page-change` when that moves the page). A no-op without a
889
+ * `fetch` callback, apart from the page reset.
890
+ */
891
+ reload({ resetPage: e = !1 } = {}) {
892
+ e && this.assignPage(1) && (this.requestUpdate(), this.dispatchEvent(
893
+ new CustomEvent("mp-datatable-page-change", {
894
+ detail: { page: 1 },
895
+ bubbles: !0,
896
+ composed: !0
897
+ })
898
+ )), this._lastReloadKey = null, this.scheduleFetchReload();
899
+ }
900
+ /**
901
+ * Applies any of `fetch`, `sortColumns`, `page` and `perPage` as ONE change:
902
+ * every provided field is assigned first, then exactly one reload is
903
+ * scheduled. Assigning them one by one through the setters can split across
904
+ * ticks and cost two requests; this cannot (#407). Framework wrappers that
905
+ * forward several of these inputs should call this rather than the setters.
906
+ *
907
+ * A field that is absent (or `undefined`) is left alone, except `fetch`: a
908
+ * present `fetch` key is always assigned, so `{ fetch: null }` removes the
909
+ * callback. `perPage` returns to page 1 unless `page` is also given.
910
+ * Unchanged values cost nothing, as with the setters.
911
+ *
912
+ * When `perPage` changes and the given `page` would lie past the last page
913
+ * of the known row count (20 → 50 per page while on page 5 of 100 rows), the
914
+ * page is clamped to the last page and `mp-datatable-page-change` reports
915
+ * it, so a wrapper's page state follows. With no known count (a fetch table
916
+ * before its first response, or a new `fetch` in the same call) the page is
917
+ * kept as given.
918
+ */
919
+ applyFetchState(e) {
920
+ const t = "fetch" in e && this.assignFetch(e.fetch);
921
+ e.sortColumns !== void 0 && this.assignSortColumns(e.sortColumns);
922
+ const a = e.perPage !== void 0 && this.assignPerPage(e.perPage);
923
+ e.page !== void 0 && (this.assignPage(e.page), a && !t && this.clampPageToKnownTotal()), this.requestUpdate(), this.scheduleFetchReload();
827
924
  }
828
925
  get selectionMode() {
829
926
  return this._selectionMode;
830
927
  }
831
928
  set selectionMode(e) {
832
- this._selectionMode = e, e === "none" && this._selectedIds.clear(), this.requestUpdate();
929
+ if (this._selectionMode = e, e === "none") {
930
+ this._selectionAnchorKey = null;
931
+ const t = this._selectedIds.size > 0;
932
+ this.commitSelection([]), t && this.emitSelectionChange();
933
+ }
934
+ this.requestUpdate();
935
+ }
936
+ /** Modes that select many rows and render the checkbox column. */
937
+ get isMulti() {
938
+ return this._selectionMode === "multiple" || this._selectionMode === "checkbox";
833
939
  }
834
940
  get selectedIds() {
835
941
  return [...this._selectedIds];
836
942
  }
837
943
  set selectedIds(e) {
838
- this._selectedIds = new Set(e ?? []), this.requestUpdate();
944
+ const t = new Set(e ?? []);
945
+ t.size === this._selectedIds.size && [...t].every((a) => this._selectedIds.has(a)) || (this._selectedIds = t, this.pruneSelectedRowCache(), t.size > 0 && this.rememberLiveSelectedRows(), this.requestUpdate());
946
+ }
947
+ /**
948
+ * The selected rows, index-aligned with `selectedIds` (`undefined` for a key
949
+ * whose row the element has never seen). See `SelectionChangeEventDetail`.
950
+ *
951
+ * Setting it REPLACES the selection: the keys are derived through `rowKey`,
952
+ * and the rows are remembered, so a host that owns row objects (the Angular
953
+ * wrapper's `selection` model) can seed rows that are not loaded here — they
954
+ * are reported back in `selectedRows` even while off-page.
955
+ */
956
+ get selectedRows() {
957
+ return this.resolveRows([...this._selectedIds]);
958
+ }
959
+ set selectedRows(e) {
960
+ const t = e ?? [], a = this.rowKeyLookup(), s = t.map((i) => [a(i), i]);
961
+ this.isSameSelectedRows(s) || (this._selectedIds = new Set(s.map(([i]) => i)), this._selectedRowCache = new Map(s), this.requestUpdate());
839
962
  }
840
963
  get cutIds() {
841
964
  return [...this._cutIds];
@@ -849,6 +972,27 @@ class V extends E {
849
972
  set focusedRowKey(e) {
850
973
  this._focusedRowKey = e, this.requestUpdate();
851
974
  }
975
+ /**
976
+ * Names a row for its selection checkbox ("Select {label}"). Property-only (it
977
+ * holds a function). When unset, or when it returns an empty string, the
978
+ * trimmed text of the row's first data cell is used, and when that is empty
979
+ * too, the row number ("Select row N").
980
+ *
981
+ * The name is a string handed to the checkbox: an `aria-labelledby` pointing
982
+ * at the cell could not cross the checkbox's shadow boundary.
983
+ */
984
+ get rowLabel() {
985
+ return this._rowLabel;
986
+ }
987
+ set rowLabel(e) {
988
+ this._rowLabel = typeof e == "function" ? e : null, this.requestUpdate();
989
+ }
990
+ /**
991
+ * Row identity: selection, focus and row-view reuse are keyed by it. It must
992
+ * be stable, and derived from the row rather than its index: a row that is
993
+ * not loaded is keyed `rowKey(row, -1)`, so an index-based key maps every
994
+ * off-page row onto `row--1`. Required with `fetch`.
995
+ */
852
996
  get rowKey() {
853
997
  return this._rowKey;
854
998
  }
@@ -930,15 +1074,40 @@ class V extends E {
930
1074
  return this._page;
931
1075
  }
932
1076
  set page(e) {
1077
+ this.assignPage(e) && (this.requestUpdate(), this.scheduleFetchReload());
1078
+ }
1079
+ /** Assigns without scheduling; true when the page changed. */
1080
+ assignPage(e) {
933
1081
  const t = Math.max(1, Math.floor(e || 1));
934
- this._page !== t && (this._page = t, this.requestUpdate(), this.scheduleFetchReload());
1082
+ return this._page === t ? !1 : (this._page = t, !0);
935
1083
  }
936
1084
  get perPage() {
937
1085
  return this._perPage;
938
1086
  }
939
1087
  set perPage(e) {
1088
+ this.assignPerPage(e) && (this.requestUpdate(), this.scheduleFetchReload());
1089
+ }
1090
+ /**
1091
+ * Moves a page past the end back to the last page, when the row count is
1092
+ * known: the server's `totalRecords` with `fetch`, the data length without.
1093
+ * Reported through `mp-datatable-page-change` when it moves the page.
1094
+ */
1095
+ clampPageToKnownTotal() {
1096
+ const e = this._fetch ? this._totalRecords : this._data.length;
1097
+ if (e == null) return;
1098
+ const t = Math.max(1, Math.ceil(e / this._perPage));
1099
+ this._page <= t || (this._page = t, this.dispatchEvent(
1100
+ new CustomEvent("mp-datatable-page-change", {
1101
+ detail: { page: t },
1102
+ bubbles: !0,
1103
+ composed: !0
1104
+ })
1105
+ ));
1106
+ }
1107
+ /** Assigns without scheduling (and returns to page 1); true when it changed. */
1108
+ assignPerPage(e) {
940
1109
  const t = Math.max(1, Math.floor(e || 1));
941
- this._perPage !== t && (this._perPage = t, this._page = 1, this.requestUpdate(), this.scheduleFetchReload());
1110
+ return this._perPage === t ? !1 : (this._perPage = t, this._page = 1, !0);
942
1111
  }
943
1112
  get perPageOptions() {
944
1113
  return [...this._perPageOptions];
@@ -979,12 +1148,12 @@ class V extends E {
979
1148
  else if (e === "aria-labelledby" || e === "aria-describedby")
980
1149
  this.hostAria.syncReferences();
981
1150
  else if (e === "selection-mode") {
982
- const i = a;
983
- (i === "none" || i === "single" || i === "multiple") && (this.selectionMode = i);
1151
+ const s = a ?? "none";
1152
+ (s === "none" || s === "single" || s === "multiple" || s === "checkbox") && (this.selectionMode = s);
984
1153
  } else if (e === "pagination")
985
1154
  this.pagination = a !== null;
986
1155
  else if (e === "resizable-columns")
987
- this.resizableColumns = a !== null;
1156
+ this.resizableColumns = a !== "false";
988
1157
  else if (e === "auto-sort")
989
1158
  this.autoSort = a !== "false";
990
1159
  else if (e === "empty-message")
@@ -992,13 +1161,13 @@ class V extends E {
992
1161
  else if (e === "virtual-scroll")
993
1162
  this.virtualScroll = a !== null;
994
1163
  else if (e === "item-size") {
995
- const i = Number(a);
996
- Number.isFinite(i) && (this.itemSize = i);
1164
+ const s = Number(a);
1165
+ Number.isFinite(s) && (this.itemSize = s);
997
1166
  } else if (e === "tree")
998
1167
  this.tree = a !== null;
999
1168
  else if (e === "tree-indent") {
1000
- const i = Number(a);
1001
- Number.isFinite(i) && (this.treeIndent = i);
1169
+ const s = a === null ? 1.25 : Number(a);
1170
+ Number.isFinite(s) && (this.treeIndent = s);
1002
1171
  } else e === "selection-strategy" && (this.selectionStrategy = a === "cascading" ? "cascading" : "flat");
1003
1172
  }
1004
1173
  get resizableColumns() {
@@ -1017,11 +1186,11 @@ class V extends E {
1017
1186
  super.willUpdate(e), this._cachedFlatList = null, this._cachedIndeterminateKeys = null;
1018
1187
  }
1019
1188
  updated(e) {
1020
- super.updated(e), this.refreshVirtualRange(), this.maybeMeasureInitialColumnWidths();
1189
+ super.updated(e), this.refreshVirtualRange(), this.nameRowCheckboxes(), this.maybeMeasureInitialColumnWidths();
1021
1190
  const t = this.renderRoot?.querySelectorAll(".resize-handle:not([aria-valuenow])") ?? [];
1022
1191
  for (const a of t) {
1023
- const i = a.closest("th");
1024
- i && a.setAttribute("aria-valuenow", String(Math.round(i.getBoundingClientRect().width)));
1192
+ const s = a.closest("th");
1193
+ s && a.setAttribute("aria-valuenow", String(Math.round(s.getBoundingClientRect().width)));
1025
1194
  }
1026
1195
  this._openFilterColumn && this.renderFilterPanel(), this.publishHeaderHeight();
1027
1196
  }
@@ -1050,14 +1219,14 @@ class V extends E {
1050
1219
  if (this._hasMeasuredInitial || this._columns.length === 0 || this._data.length === 0 || !this.renderRoot || this.renderRoot.querySelectorAll('tbody tr[data-row-key]:not([data-placeholder="true"])').length === 0) return;
1051
1220
  const t = new Map(this._columnWidths);
1052
1221
  let a = !1;
1053
- for (const i of this._columns) {
1054
- if (t.has(i.name)) continue;
1055
- if (typeof i.width == "number") {
1056
- t.set(i.name, i.width), a = !0;
1222
+ for (const s of this._columns) {
1223
+ if (t.has(s.name)) continue;
1224
+ if (typeof s.width == "number") {
1225
+ t.set(s.name, s.width), a = !0;
1057
1226
  continue;
1058
1227
  }
1059
- const s = this.measureColumnWidth(i.name);
1060
- s != null && (t.set(i.name, s), a = !0);
1228
+ const i = this.measureColumnWidth(s.name);
1229
+ i != null && (t.set(s.name, i), a = !0);
1061
1230
  }
1062
1231
  a && (this._columnWidths = t, this._hasMeasuredInitial = !0, this.requestUpdate());
1063
1232
  }
@@ -1077,16 +1246,16 @@ class V extends E {
1077
1246
  if (!this._virtualScroll || !this._scrollElement) return;
1078
1247
  const e = this._scrollElement.scrollTop, t = this._scrollElement.clientHeight;
1079
1248
  this._viewportHeight = t;
1080
- const a = this.getEffectiveData().length, i = this._itemSize, s = Math.max(0, Math.floor(e / i) - this._virtualBuffer), r = Math.ceil(t / i), o = Math.min(a, s + r + this._virtualBuffer * 2);
1081
- (s !== this._virtualRange.startIndex || o !== this._virtualRange.endIndex) && (this._virtualRange = { startIndex: s, endIndex: o }, this.requestUpdate()), this._tree && this.maybeFetchPlaceholdersInViewport(), this.isRootWindowed() && this.maybeFetchPagesInViewport();
1249
+ const a = this.getEffectiveData().length, s = this._itemSize, i = Math.max(0, Math.floor(e / s) - this._virtualBuffer), r = Math.ceil(t / s), o = Math.min(a, i + r + this._virtualBuffer * 2);
1250
+ (i !== this._virtualRange.startIndex || o !== this._virtualRange.endIndex) && (this._virtualRange = { startIndex: i, endIndex: o }, this.requestUpdate()), this._tree && this.maybeFetchPlaceholdersInViewport(), this.isRootWindowed() && this.maybeFetchPagesInViewport();
1082
1251
  }
1083
1252
  /**
1084
1253
  * Walk the visible viewport for placeholder rows whose parent isn't cached
1085
1254
  * and isn't already in-flight. Emit a fetch-request per such parent.
1086
1255
  */
1087
1256
  maybeFetchPlaceholdersInViewport() {
1088
- const e = this.getFlatList(), { startIndex: t, endIndex: a } = this._virtualRange, i = this._virtualScroll ? t : 0, s = this._virtualScroll ? a : e.length, r = /* @__PURE__ */ new Set();
1089
- for (let o = i; o < s; o++) {
1257
+ const e = this.getFlatList(), { startIndex: t, endIndex: a } = this._virtualRange, s = this._virtualScroll ? t : 0, i = this._virtualScroll ? a : e.length, r = /* @__PURE__ */ new Set();
1258
+ for (let o = s; o < i; o++) {
1090
1259
  const l = e[o];
1091
1260
  !l.isPlaceholder || l.parentId == null || this._childCache.has(l.parentId) || this._pendingFetches.has(l.parentId) || r.add(l.parentId);
1092
1261
  }
@@ -1100,32 +1269,33 @@ class V extends E {
1100
1269
  * wrapper's first-page fetch).
1101
1270
  */
1102
1271
  maybeFetchPagesInViewport() {
1103
- const e = this.getFlatList(), { startIndex: t, endIndex: a } = this._virtualRange, i = this._virtualScroll ? t : 0, s = this._virtualScroll ? a : e.length, r = /* @__PURE__ */ new Set();
1104
- for (let o = i; o < s; o++) {
1272
+ const e = this.getFlatList(), { startIndex: t, endIndex: a } = this._virtualRange, s = this._virtualScroll ? t : 0, i = this._virtualScroll ? a : e.length, r = /* @__PURE__ */ new Set();
1273
+ for (let o = s; o < i; o++) {
1105
1274
  const l = e[o];
1106
1275
  !l.isPlaceholder || l.page == null || l.page <= 1 || this._pageCache.has(l.page) || this._pendingPageFetches.has(l.page) || r.add(l.page);
1107
1276
  }
1108
1277
  for (const o of r) this.fetchWindowPage(o);
1109
1278
  }
1110
1279
  render() {
1111
- const e = this.computeVisibleRows(), t = this._totalRecords ?? this._data.length, a = this.pagination && !this._tree ? Math.max(1, Math.ceil(t / this._perPage)) : 1, i = this._selectionMode === "multiple", s = this._columns.length + (i ? 1 : 0) + (this._tree ? 1 : 0), r = this.getVirtualSpacerHeights(), o = this.hasFilterRow ? 2 : 1, l = (this._tree || this.isRootWindowed() ? this.getFlatList().length : this._data.length) + o;
1112
- return h`
1280
+ const e = this.computeVisibleRows(), t = this._totalRecords ?? this._data.length, a = this.pagination && !this._tree ? Math.max(1, Math.ceil(t / this._perPage)) : 1, s = this.isMulti, i = this._columns.length + (s ? 1 : 0) + (this._tree ? 1 : 0), r = this.getVirtualSpacerHeights(), o = this.hasFilterRow ? 2 : 1, l = (this._tree || this.isRootWindowed() ? this.getFlatList().length : this._data.length) + o;
1281
+ return c`
1113
1282
  ${this.liveAnnouncer.template()}
1114
1283
  <div class="datatable-shell">
1115
1284
  <div class="datatable-scroll ${this._virtualScroll ? "datatable-virtual" : ""}" role="presentation">
1116
1285
  <table
1117
1286
  role=${this._tree ? "treegrid" : this._selectionMode !== "none" ? "grid" : u}
1287
+ aria-multiselectable=${this.isMulti ? "true" : u}
1118
1288
  aria-rowcount=${l}
1119
- aria-colcount=${s}
1289
+ aria-colcount=${i}
1120
1290
  aria-busy=${this._loading ? "true" : u}
1121
1291
  aria-label=${this.getAttribute("aria-label") ?? this._inputLabel ?? u}
1122
1292
  class=${this._hasMeasuredInitial ? "measured" : ""}
1123
1293
  >
1124
- ${this._caption ? h`<caption>${this._caption}</caption>` : u}
1294
+ ${this._caption ? c`<caption>${this._caption}</caption>` : u}
1125
1295
  <thead>
1126
1296
  <tr role="row" aria-rowindex="1">
1127
- ${this._tree ? h`<th class="tree-chevron-cell" scope="col" aria-label=${this.mergedLabels.treeChevronColumn}></th>` : u}
1128
- ${i ? h`<th class="checkbox-cell" scope="col">
1297
+ ${this._tree ? c`<th class="tree-chevron-cell" scope="col" aria-label=${this.mergedLabels.treeChevronColumn}></th>` : u}
1298
+ ${s ? c`<th class="checkbox-cell" scope="col">
1129
1299
  <mp-checkbox
1130
1300
  aria-label=${this.mergedLabels.deselectAll}
1131
1301
  aria-hidden=${this._selectedIds.size === 0 ? "true" : u}
@@ -1135,19 +1305,19 @@ class V extends E {
1135
1305
  @change=${this.onDeselectAll}
1136
1306
  ></mp-checkbox>
1137
1307
  </th>` : u}
1138
- ${this._columns.map((d, c) => this.renderHeader(d, c))}
1308
+ ${this._columns.map((h, d) => this.renderHeader(h, d))}
1139
1309
  </tr>
1140
- ${this.hasFilterRow ? this.renderFilterRow(i) : u}
1310
+ ${this.hasFilterRow ? this.renderFilterRow(s) : u}
1141
1311
  </thead>
1142
1312
  <tbody>
1143
- ${this._loading ? h`<tr><td colspan=${s} class="loading-state">Loading…</td></tr>` : e.length === 0 ? h`<tr><td colspan=${s} class="empty-state">${this._emptyMessage}</td></tr>` : h`
1144
- ${r.top > 0 ? h`<tr class="virtual-spacer" aria-hidden="true"><td colspan=${s} style=${_({ height: `${r.top}px`, padding: "0", border: "0" })}></td></tr>` : u}
1313
+ ${this._loading ? c`<tr><td colspan=${i} class="loading-state">Loading…</td></tr>` : e.length === 0 ? c`<tr><td colspan=${i} class="empty-state">${this._emptyMessage}</td></tr>` : c`
1314
+ ${r.top > 0 ? c`<tr class="virtual-spacer" aria-hidden="true"><td colspan=${i} style=${_({ height: `${r.top}px`, padding: "0", border: "0" })}></td></tr>` : u}
1145
1315
  ${x(
1146
1316
  e,
1147
- ({ key: d }) => d,
1148
- ({ key: d, rowIndex: c, flat: p }) => this.renderRow(p, d, c, i)
1317
+ ({ key: h }) => h,
1318
+ ({ key: h, rowIndex: d, flat: p }) => this.renderRow(p, h, d, s)
1149
1319
  )}
1150
- ${r.bottom > 0 ? h`<tr class="virtual-spacer" aria-hidden="true"><td colspan=${s} style=${_({ height: `${r.bottom}px`, padding: "0", border: "0" })}></td></tr>` : u}
1320
+ ${r.bottom > 0 ? c`<tr class="virtual-spacer" aria-hidden="true"><td colspan=${i} style=${_({ height: `${r.bottom}px`, padding: "0", border: "0" })}></td></tr>` : u}
1151
1321
  `}
1152
1322
  </tbody>
1153
1323
  </table>
@@ -1204,23 +1374,23 @@ class V extends E {
1204
1374
  return a.ctx = {
1205
1375
  values: () => a.view,
1206
1376
  loading: () => a.loading,
1207
- search: (i) => this.setFilterSearch(t, i),
1208
- apply: (i, s) => this.applyFilter(t, i, s),
1377
+ search: (s) => this.setFilterSearch(t, s),
1378
+ apply: (s, i) => this.applyFilter(t, s, i),
1209
1379
  // Clearing emits the shape of the column's OWN mode. A comparison column
1210
1380
  // emitting an empty `selected` array would be reporting a values-mode
1211
1381
  // filter it never had, and a consumer switching on `mode` would miss it.
1212
1382
  clear: () => this.clearFilter(t),
1213
- onChange: (i) => (a.listeners.add(i), () => a.listeners.delete(i))
1383
+ onChange: (s) => (a.listeners.add(s), () => a.listeners.delete(s))
1214
1384
  }, a;
1215
1385
  }
1216
1386
  /** State for a filterable column, created on demand. */
1217
1387
  filterState(e) {
1218
1388
  const t = this._filterStates.get(e);
1219
1389
  if (t) return t;
1220
- const a = this._columns.find((s) => s.name === e);
1390
+ const a = this._columns.find((i) => i.name === e);
1221
1391
  if (!a?.filterable) return null;
1222
- const i = this.createFilterState(a);
1223
- return this._filterStates.set(e, i), i;
1392
+ const s = this.createFilterState(a);
1393
+ return this._filterStates.set(e, s), s;
1224
1394
  }
1225
1395
  notifyFilterListeners(e) {
1226
1396
  e.listeners.forEach((t) => t()), this.requestUpdate();
@@ -1237,9 +1407,9 @@ class V extends E {
1237
1407
  * non-empty, so the list cannot collapse to the selection.
1238
1408
  */
1239
1409
  applyFilter(e, t, a) {
1240
- const i = this.filterState(e);
1241
- if (!i) return;
1242
- i.selection.values.length === 0 && t.length > 0 && i.snapshot == null && i.loaded && (i.snapshot = [...i.loaded.matching, ...i.loaded.remaining]), t.length === 0 && (i.snapshot = null), i.selection = { ...i.selection, values: [...t], inverse: a }, this.rebucket(i), this.notifyFilterListeners(i);
1410
+ const s = this.filterState(e);
1411
+ if (!s) return;
1412
+ s.selection.values.length === 0 && t.length > 0 && s.snapshot == null && s.loaded && (s.snapshot = [...s.loaded.matching, ...s.loaded.remaining]), t.length === 0 && (s.snapshot = null), s.selection = { ...s.selection, values: [...t], inverse: a }, this.rebucket(s), this.notifyFilterListeners(s);
1243
1413
  const r = this._columns.find((o) => o.name === e);
1244
1414
  this.liveAnnouncer.announce(
1245
1415
  this.mergedLabels.announceFilter(r?.label ?? e, t.length)
@@ -1272,14 +1442,14 @@ class V extends E {
1272
1442
  * would filter everything away the moment its panel opened.
1273
1443
  */
1274
1444
  applyComparison(e, t, a) {
1275
- const i = this.filterState(e);
1276
- if (!i) return;
1277
- const s = this._columns.find((l) => l.name === e), r = this.parseOperand(a, s?.filterInputType);
1278
- i.operandText = a, i.selection = { ...i.selection, operator: t, operand: r }, this.notifyFilterListeners(i);
1445
+ const s = this.filterState(e);
1446
+ if (!s) return;
1447
+ const i = this._columns.find((l) => l.name === e), r = this.parseOperand(a, i?.filterInputType);
1448
+ s.operandText = a, s.selection = { ...s.selection, operator: t, operand: r }, this.notifyFilterListeners(s);
1279
1449
  const o = this.mergedLabels;
1280
1450
  this.liveAnnouncer.announce(
1281
1451
  o.announceComparisonFilter(
1282
- s?.label ?? e,
1452
+ i?.label ?? e,
1283
1453
  o.filterOperatorLabel(t),
1284
1454
  r == null ? "" : String(r)
1285
1455
  )
@@ -1306,10 +1476,10 @@ class V extends E {
1306
1476
  const a = this.filterState(e);
1307
1477
  if (!a) return;
1308
1478
  a.term = t, this.rebucket(a), this.notifyFilterListeners(a);
1309
- const i = a.loadedTerm ?? "";
1310
- (a.loaded?.hasMore || !t.startsWith(i)) && (a.debounce != null && clearTimeout(a.debounce), a.debounce = setTimeout(() => {
1479
+ const s = a.loadedTerm ?? "";
1480
+ (a.loaded?.hasMore || !t.startsWith(s)) && (a.debounce != null && clearTimeout(a.debounce), a.debounce = setTimeout(() => {
1311
1481
  a.debounce = null, this.loadDistincts(e, t);
1312
- }, H));
1482
+ }, G));
1313
1483
  }
1314
1484
  /**
1315
1485
  * Loads (or recomputes) one column's value list.
@@ -1322,19 +1492,19 @@ class V extends E {
1322
1492
  async loadDistincts(e, t) {
1323
1493
  const a = this.filterState(e);
1324
1494
  if (!a) return;
1325
- const i = ++a.generation;
1495
+ const s = ++a.generation;
1326
1496
  if (a.controller?.abort(), this._distincts) {
1327
- const s = new AbortController();
1328
- a.controller = s, a.loading = !0, this.notifyFilterListeners(a);
1497
+ const i = new AbortController();
1498
+ a.controller = i, a.loading = !0, this.notifyFilterListeners(a);
1329
1499
  try {
1330
- const r = await this._distincts({ column: e, search: t, signal: s.signal });
1331
- if (i !== a.generation) return;
1500
+ const r = await this._distincts({ column: e, search: t, signal: i.signal });
1501
+ if (s !== a.generation) return;
1332
1502
  if (a.loading = !1, a.controller = null, r) {
1333
1503
  a.loaded = r, a.loadedTerm = t, this.rebucket(a), this.notifyFilterListeners(a);
1334
1504
  return;
1335
1505
  }
1336
1506
  } catch {
1337
- if (i !== a.generation) return;
1507
+ if (s !== a.generation) return;
1338
1508
  a.loading = !1, a.controller = null, a.loaded = null, a.loadedTerm = t, this.notifyFilterListeners(a);
1339
1509
  return;
1340
1510
  }
@@ -1373,10 +1543,10 @@ class V extends E {
1373
1543
  localDistincts(e) {
1374
1544
  if (this._fetch != null || this.isExternallyPaged() || this._childCache.size > 0) return null;
1375
1545
  const t = this.mergedLabels, a = [];
1376
- return this._data.forEach((i) => {
1377
- const s = i?.[e];
1378
- g(a, s) || a.push({ value: s, label: t.filterValue(s) });
1379
- }), a.sort((i, s) => i.label.localeCompare(s.label)), { matching: a, remaining: [], hasMore: !1 };
1546
+ return this._data.forEach((s) => {
1547
+ const i = s?.[e];
1548
+ g(a, i) || a.push({ value: i, label: t.filterValue(i) });
1549
+ }), a.sort((s, i) => s.label.localeCompare(i.label)), { matching: a, remaining: [], hasMore: !1 };
1380
1550
  }
1381
1551
  /**
1382
1552
  * Re-derives `matching` / `remaining` from the snapshot and the search term.
@@ -1391,9 +1561,9 @@ class V extends E {
1391
1561
  e.view = null;
1392
1562
  return;
1393
1563
  }
1394
- const t = e.term.trim().toLowerCase(), a = (o) => t === "" || o.label.toLowerCase().includes(t), i = [...e.loaded.matching, ...e.loaded.remaining], s = e.snapshot ? e.snapshot.filter((o) => g(i, o.value)) : e.loaded.matching, r = e.snapshot ? e.snapshot.filter((o) => !g(i, o.value)) : e.loaded.remaining;
1564
+ const t = e.term.trim().toLowerCase(), a = (o) => t === "" || o.label.toLowerCase().includes(t), s = [...e.loaded.matching, ...e.loaded.remaining], i = e.snapshot ? e.snapshot.filter((o) => g(s, o.value)) : e.loaded.matching, r = e.snapshot ? e.snapshot.filter((o) => !g(s, o.value)) : e.loaded.remaining;
1395
1565
  e.view = {
1396
- matching: s.filter(a),
1566
+ matching: i.filter(a),
1397
1567
  remaining: r.filter(a),
1398
1568
  hasMore: e.loaded.hasMore
1399
1569
  };
@@ -1451,7 +1621,7 @@ class V extends E {
1451
1621
  if (!t) return;
1452
1622
  const a = this.filterState(t.name);
1453
1623
  v(
1454
- h`
1624
+ c`
1455
1625
  <div
1456
1626
  class="filter-panel"
1457
1627
  id=${this.filterPanelId}
@@ -1463,18 +1633,18 @@ class V extends E {
1463
1633
  `,
1464
1634
  e
1465
1635
  );
1466
- const i = e.querySelector(".filter-panel-body");
1467
- if (!i || !a) return;
1468
- if (this._mountedFilterColumn === t.name && i.firstChild) {
1469
- this._consumerMountedFilter || this.renderDefaultFilterPanel(t, a, i);
1636
+ const s = e.querySelector(".filter-panel-body");
1637
+ if (!s || !a) return;
1638
+ if (this._mountedFilterColumn === t.name && s.firstChild) {
1639
+ this._consumerMountedFilter || this.renderDefaultFilterPanel(t, a, s);
1470
1640
  return;
1471
1641
  }
1472
- const s = t.filterRenderer?.(t, a.ctx) ?? null;
1473
- if (s) {
1474
- i.replaceChildren(s), this._consumerMountedFilter = !0, this._mountedFilterColumn = t.name;
1642
+ const i = t.filterRenderer?.(t, a.ctx) ?? null;
1643
+ if (i) {
1644
+ s.replaceChildren(i), this._consumerMountedFilter = !0, this._mountedFilterColumn = t.name;
1475
1645
  return;
1476
1646
  }
1477
- this._consumerMountedFilter = !1, this.renderDefaultFilterPanel(t, a, i), this._mountedFilterColumn = t.name;
1647
+ this._consumerMountedFilter = !1, this.renderDefaultFilterPanel(t, a, s), this._mountedFilterColumn = t.name;
1478
1648
  }
1479
1649
  /**
1480
1650
  * The built-in panel: clear, search, invert, checkbox list.
@@ -1490,27 +1660,27 @@ class V extends E {
1490
1660
  this.renderComparisonFilterPanel(e, t, a);
1491
1661
  return;
1492
1662
  }
1493
- const i = this.mergedLabels, s = e.label ?? e.name, r = t.view, o = t.selection.values, l = [
1663
+ const s = this.mergedLabels, i = e.label ?? e.name, r = t.view, o = t.selection.values, l = [
1494
1664
  ...o,
1495
- ...(r?.matching ?? []).filter((c) => !g(o, c.value)),
1496
- ...(r?.remaining ?? []).filter((c) => !g(o, c.value))
1497
- ], d = (c) => !!r && g(r.remaining, c);
1665
+ ...(r?.matching ?? []).filter((d) => !g(o, d.value)),
1666
+ ...(r?.remaining ?? []).filter((d) => !g(o, d.value))
1667
+ ], h = (d) => !!r && g(r.remaining, d);
1498
1668
  v(
1499
- h`
1669
+ c`
1500
1670
  <button
1501
1671
  type="button"
1502
1672
  class="filter-clear"
1503
1673
  ?disabled=${o.length === 0 && !t.selection.inverse}
1504
1674
  @click=${() => this.onFilterClear(e.name)}
1505
1675
  >
1506
- ${i.filterClear(s)}
1676
+ ${s.filterClear(i)}
1507
1677
  </button>
1508
1678
  <input
1509
1679
  type="search"
1510
1680
  class="filter-search"
1511
1681
  .value=${t.term}
1512
- aria-label=${i.filterSearch}
1513
- @input=${(c) => t.ctx.search(c.target.value)}
1682
+ aria-label=${s.filterSearch}
1683
+ @input=${(d) => t.ctx.search(d.target.value)}
1514
1684
  />
1515
1685
  <button
1516
1686
  type="button"
@@ -1518,27 +1688,27 @@ class V extends E {
1518
1688
  aria-pressed=${t.selection.inverse ? "true" : "false"}
1519
1689
  @click=${() => t.ctx.apply(o, !t.selection.inverse)}
1520
1690
  >
1521
- ${i.filterInvert}
1691
+ ${s.filterInvert}
1522
1692
  </button>
1523
- <div class="filter-options" role="group" aria-label=${i.filterGroup(s)}>
1524
- ${t.loading ? h`<span class="filter-loading">${i.loading}</span>` : u}
1693
+ <div class="filter-options" role="group" aria-label=${s.filterGroup(i)}>
1694
+ ${t.loading ? c`<span class="filter-loading">${s.loading}</span>` : u}
1525
1695
  ${x(
1526
1696
  l,
1527
- (c) => c.value,
1528
- (c) => h`
1529
- <label class=${C({ "filter-option": !0, "filter-remaining": d(c.value) })}>
1697
+ (d) => d.value,
1698
+ (d) => c`
1699
+ <label class=${w({ "filter-option": !0, "filter-remaining": h(d.value) })}>
1530
1700
  <input
1531
1701
  type="checkbox"
1532
- .checked=${g(o, c.value)}
1533
- @change=${(p) => this.onFilterToggle(e.name, c, p.target.checked)}
1702
+ .checked=${g(o, d.value)}
1703
+ @change=${(p) => this.onFilterToggle(e.name, d, p.target.checked)}
1534
1704
  />
1535
- <span>${c.label}</span>
1705
+ <span>${d.label}</span>
1536
1706
  </label>
1537
1707
  `
1538
1708
  )}
1539
- ${l.length === 0 && !t.loading ? h`<span class="filter-no-values">${i.filterNoValues}</span>` : u}
1709
+ ${l.length === 0 && !t.loading ? c`<span class="filter-no-values">${s.filterNoValues}</span>` : u}
1540
1710
  </div>
1541
- ${r?.hasMore ? h`<span class="filter-has-more">${i.filterHasMore}</span>` : u}
1711
+ ${r?.hasMore ? c`<span class="filter-has-more">${s.filterHasMore}</span>` : u}
1542
1712
  `,
1543
1713
  a
1544
1714
  );
@@ -1552,37 +1722,37 @@ class V extends E {
1552
1722
  * displayed.
1553
1723
  */
1554
1724
  renderComparisonFilterPanel(e, t, a) {
1555
- const i = this.mergedLabels, s = e.label ?? e.name, r = e.filterOperators?.length ? e.filterOperators : T, o = t.selection.operator ?? r[0], l = t.selection.operand, d = e.filterInputType ?? "number", c = () => a.querySelector(".filter-operand")?.value ?? "", p = () => a.querySelector(".filter-operator")?.value ?? o;
1725
+ const s = this.mergedLabels, i = e.label ?? e.name, r = e.filterOperators?.length ? e.filterOperators : N, o = t.selection.operator ?? r[0], l = t.selection.operand, h = e.filterInputType ?? "number", d = () => a.querySelector(".filter-operand")?.value ?? "", p = () => a.querySelector(".filter-operator")?.value ?? o;
1556
1726
  v(
1557
- h`
1727
+ c`
1558
1728
  <button
1559
1729
  type="button"
1560
1730
  class="filter-clear"
1561
1731
  ?disabled=${l == null}
1562
1732
  @click=${() => this.onFilterClear(e.name)}
1563
1733
  >
1564
- ${i.filterClear(s)}
1734
+ ${s.filterClear(i)}
1565
1735
  </button>
1566
1736
  <div class="filter-comparison">
1567
1737
  <select
1568
1738
  class="filter-operator"
1569
- aria-label=${i.filterOperator}
1570
- @change=${() => this.applyComparison(e.name, p(), c())}
1739
+ aria-label=${s.filterOperator}
1740
+ @change=${() => this.applyComparison(e.name, p(), d())}
1571
1741
  >
1572
1742
  ${r.map(
1573
- (f) => h`
1743
+ (f) => c`
1574
1744
  <option value=${f} ?selected=${f === o}>
1575
- ${U[f]} ${i.filterOperatorLabel(f)}
1745
+ ${D[f]} ${s.filterOperatorLabel(f)}
1576
1746
  </option>
1577
1747
  `
1578
1748
  )}
1579
1749
  </select>
1580
1750
  <input
1581
1751
  class="filter-operand"
1582
- type=${d}
1583
- .value=${K(t.operandText)}
1584
- aria-label=${i.filterOperand}
1585
- @input=${() => this.applyComparison(e.name, p(), c())}
1752
+ type=${h}
1753
+ .value=${O(t.operandText)}
1754
+ aria-label=${s.filterOperand}
1755
+ @input=${() => this.applyComparison(e.name, p(), d())}
1586
1756
  />
1587
1757
  </div>
1588
1758
  `,
@@ -1590,10 +1760,10 @@ class V extends E {
1590
1760
  );
1591
1761
  }
1592
1762
  onFilterToggle(e, t, a) {
1593
- const i = this.filterState(e);
1594
- if (!i) return;
1595
- const s = a ? [...i.selection.values, t] : i.selection.values.filter((r) => !$(r.value, t.value));
1596
- i.ctx.apply(s, i.selection.inverse);
1763
+ const s = this.filterState(e);
1764
+ if (!s) return;
1765
+ const i = a ? [...s.selection.values, t] : s.selection.values.filter((r) => !P(r.value, t.value));
1766
+ s.ctx.apply(i, s.selection.inverse);
1597
1767
  }
1598
1768
  onFilterClear(e) {
1599
1769
  const t = this.filterState(e);
@@ -1611,23 +1781,23 @@ class V extends E {
1611
1781
  * is width-neutral — see the note on that rule in `datatable.light.scss`.
1612
1782
  */
1613
1783
  renderFilterRow(e) {
1614
- return h`
1784
+ return c`
1615
1785
  <tr role="row" aria-rowindex="2" class="filter-row">
1616
- ${this._tree ? h`<th class="filter-cell tree-chevron-cell"></th>` : u}
1617
- ${e ? h`<th class="filter-cell checkbox-cell"></th>` : u}
1786
+ ${this._tree ? c`<th class="filter-cell tree-chevron-cell"></th>` : u}
1787
+ ${e ? c`<th class="filter-cell checkbox-cell"></th>` : u}
1618
1788
  ${this._columns.map((t) => this.renderFilterCell(t))}
1619
1789
  </tr>
1620
1790
  `;
1621
1791
  }
1622
1792
  renderFilterCell(e) {
1623
1793
  if (!e.filterable)
1624
- return h`<th class="filter-cell p-0" data-column=${e.name} scope="col"></th>`;
1625
- const t = this._openFilterColumn === e.name, a = this.mergedLabels, i = e.label ?? e.name, s = e.filterActive ? a.filterColumnActive(i, e.filterSummary) : a.filterColumn(i);
1626
- return h`
1794
+ return c`<th class="filter-cell p-0" data-column=${e.name} scope="col"></th>`;
1795
+ const t = this._openFilterColumn === e.name, a = this.mergedLabels, s = e.label ?? e.name, i = e.filterActive ? a.filterColumnActive(s, e.filterSummary) : a.filterColumn(s);
1796
+ return c`
1627
1797
  <th class="filter-cell p-0" data-column=${e.name} scope="col">
1628
1798
  <button
1629
1799
  type="button"
1630
- class=${C({
1800
+ class=${w({
1631
1801
  "filter-trigger": !0,
1632
1802
  "p-2": !0,
1633
1803
  "rounded-0": !0,
@@ -1637,64 +1807,64 @@ class V extends E {
1637
1807
  id=${this.filterTriggerId(e.name)}
1638
1808
  aria-expanded=${t ? "true" : "false"}
1639
1809
  aria-controls=${t ? this.filterPanelId : u}
1640
- aria-label=${s}
1810
+ aria-label=${i}
1641
1811
  @click=${(r) => this.onFilterTriggerClick(e, r)}
1642
1812
  >
1643
1813
  <svg class="filter-icon" viewBox="0 0 16 16" aria-hidden="true" focusable="false">
1644
1814
  <path d="M2 3h12l-4.5 5.25V13L6.5 11.5V8.25L2 3z" />
1645
1815
  </svg>
1646
- ${e.filterSummary ? h`<span class="filter-summary">${e.filterSummary}</span>` : u}
1816
+ ${e.filterSummary ? c`<span class="filter-summary">${e.filterSummary}</span>` : u}
1647
1817
  </button>
1648
1818
  </th>
1649
1819
  `;
1650
1820
  }
1651
1821
  renderHeader(e, t) {
1652
- const a = e.sortable ?? !0, i = this._sortColumns.findIndex((d) => d.property === e.name), s = i >= 0 ? this._sortColumns[i].direction : null, r = this._columnWidths.get(e.name) ?? e.width, o = e.headerRenderer ? e.headerRenderer(e) : e.label ?? e.name, l = {};
1653
- return typeof r == "number" && (l.width = `${r}px`, l.minWidth = `${r}px`), h`
1822
+ const a = e.sortable ?? !0, s = this._sortColumns.findIndex((h) => h.property === e.name), i = s >= 0 ? this._sortColumns[s].direction : null, r = this._columnWidths.get(e.name) ?? e.width, o = e.headerRenderer ? e.headerRenderer(e) : e.label ?? e.name, l = {};
1823
+ return typeof r == "number" && (l.width = `${r}px`, l.minWidth = `${r}px`), c`
1654
1824
  <th
1655
1825
  scope="col"
1656
1826
  data-column=${e.name}
1657
1827
  data-sortable=${a ? "true" : "false"}
1658
- aria-sort=${s ? s === "ascending" ? "ascending" : "descending" : "none"}
1828
+ aria-sort=${i ? i === "ascending" ? "ascending" : "descending" : "none"}
1659
1829
  style=${_(l)}
1660
1830
  >
1661
- ${a ? h`<button
1831
+ ${a ? c`<button
1662
1832
  type="button"
1663
1833
  class="header-cell header-sort"
1664
- @click=${(d) => this.onHeaderClick(e, d)}
1834
+ @click=${(h) => this.onHeaderClick(e, h)}
1665
1835
  >
1666
- <span>${w(o)}</span>
1667
- ${i >= 0 && this._sortColumns.length > 1 ? h`<span class="sort-index">${i + 1}</span>` : u}
1668
- </button>` : h`<span class="header-cell">
1669
- <span>${w(o)}</span>
1836
+ <span>${C(o)}</span>
1837
+ ${s >= 0 && this._sortColumns.length > 1 ? c`<span class="sort-index">${s + 1}</span>` : u}
1838
+ </button>` : c`<span class="header-cell">
1839
+ <span>${C(o)}</span>
1670
1840
  </span>`}
1671
- ${this._resizableColumns ? h`<span
1841
+ ${this._resizableColumns ? c`<span
1672
1842
  class="resize-handle"
1673
1843
  role="separator"
1674
1844
  tabindex="0"
1675
1845
  aria-orientation="vertical"
1676
1846
  aria-label=${this.mergedLabels.resizeColumn(e.label ?? e.name)}
1677
- aria-valuemin="40"
1847
+ aria-valuemin=${F}
1678
1848
  aria-valuenow=${Math.round(r ?? 0) || u}
1679
- @pointerdown=${(d) => this.startColumnResize(e, d)}
1680
- @keydown=${(d) => this.onResizeHandleKeydown(e, d)}
1849
+ @pointerdown=${(h) => this.startColumnResize(e, h)}
1850
+ @keydown=${(h) => this.onResizeHandleKeydown(e, h)}
1681
1851
  ></span>` : u}
1682
1852
  </th>
1683
1853
  `;
1684
1854
  }
1685
- renderRow(e, t, a, i) {
1686
- const { row: s, depth: r, isExpanded: o, isPlaceholder: l } = e, d = !l && this._selectedIds.has(t), c = !l && this._cutIds.has(t), p = !l && this._focusedRowKey === t, f = l ? 0 : this.extractChildCount(s), b = this._tree && !l && f > 0, R = !l && s != null && this.isParentIndeterminate(s);
1687
- return h`
1855
+ renderRow(e, t, a, s) {
1856
+ const { row: i, depth: r, isExpanded: o, isPlaceholder: l } = e, h = !l && this._selectedIds.has(t), d = !l && this._cutIds.has(t), p = !l && this._focusedRowKey === t, f = l ? 0 : this.extractChildCount(i), b = this._tree && !l && f > 0, k = !l && i != null && this.isParentIndeterminate(i, t);
1857
+ return c`
1688
1858
  <tr
1689
1859
  role="row"
1690
1860
  aria-rowindex=${a + 1 + (this.hasFilterRow ? 2 : 1)}
1691
1861
  aria-level=${this._tree ? r + 1 : u}
1692
1862
  aria-expanded=${this._tree && f > 0 ? o ? "true" : "false" : u}
1693
1863
  aria-busy=${l ? "true" : u}
1694
- aria-selected=${!l && this._selectionMode !== "none" ? d ? "true" : "false" : u}
1864
+ aria-selected=${!l && this._selectionMode !== "none" ? h ? "true" : "false" : u}
1695
1865
  data-row-key=${t}
1696
- data-selected=${d ? "true" : "false"}
1697
- data-cut=${c ? "true" : "false"}
1866
+ data-selected=${h ? "true" : "false"}
1867
+ data-cut=${d ? "true" : "false"}
1698
1868
  data-focused=${p ? "true" : "false"}
1699
1869
  data-placeholder=${l ? "true" : "false"}
1700
1870
  data-depth=${this._tree ? String(r) : u}
@@ -1703,51 +1873,74 @@ class V extends E {
1703
1873
  @focus=${l ? null : () => {
1704
1874
  this._focusedRowKey = t, this.requestUpdate();
1705
1875
  }}
1706
- @click=${l ? null : (m) => this.onRowClick(s, t, a, m)}
1707
- @dblclick=${l ? null : (m) => this.onRowDblClick(s, t, a, m)}
1708
- @contextmenu=${l ? null : (m) => this.onRowContextMenu(s, t, a, m)}
1709
- @keydown=${l ? null : (m) => this.onRowKeydown(s, t, a, e.parentId, r, o, f, m)}
1876
+ @click=${l ? null : (m) => this.onRowClick(i, t, a, m)}
1877
+ @dblclick=${l ? null : (m) => this.onRowDblClick(i, t, a, m)}
1878
+ @contextmenu=${l ? null : (m) => this.onRowContextMenu(i, t, a, m)}
1879
+ @keydown=${l ? null : (m) => this.onRowKeydown(i, t, a, e.parentId, r, o, f, m)}
1710
1880
  >
1711
- ${this._tree ? h`<td class="tree-chevron-cell" style=${_({ paddingInlineStart: `${r * this._treeIndent}rem` })}>
1712
- ${b ? h`<button
1881
+ ${this._tree ? c`<td class="tree-chevron-cell" style=${_({ paddingInlineStart: `${r * this._treeIndent}rem` })}>
1882
+ ${b ? c`<button
1713
1883
  type="button"
1714
1884
  class="tree-chevron"
1715
1885
  aria-label=${o ? this.mergedLabels.collapseRow : this.mergedLabels.expandRow}
1716
1886
  aria-expanded=${o ? "true" : "false"}
1717
1887
  data-expanded=${o ? "true" : "false"}
1718
- @click=${(m) => this.toggleExpand(s, e.parentId, r, m)}
1888
+ @click=${(m) => this.toggleExpand(i, e.parentId, r, m)}
1719
1889
  >${o ? "▾" : "▸"}</button>` : u}
1720
1890
  </td>` : u}
1721
- ${i ? h`<td class="checkbox-cell" @click=${(m) => m.stopPropagation()}>
1722
- ${l ? u : h`<mp-checkbox
1723
- aria-label=${this.mergedLabels.selectRow(a + 1)}
1724
- .checked=${d}
1725
- .indeterminate=${R}
1726
- @change=${(m) => this.onRowCheckboxToggle(s, t, a, m)}
1891
+ ${s ? c`<td
1892
+ class=${w({ "checkbox-cell": !0, "checkbox-cell-toggles": this._selectionMode === "checkbox" })}
1893
+ @click=${l ? (m) => m.stopPropagation() : (m) => this.onCheckboxCellClick(i, t, m)}
1894
+ @dblclick=${(m) => m.stopPropagation()}
1895
+ >
1896
+ ${l ? u : c`<mp-checkbox
1897
+ .checked=${h}
1898
+ .indeterminate=${k}
1899
+ @change=${() => this.onRowCheckboxToggle(i, t)}
1727
1900
  ></mp-checkbox>`}
1728
1901
  </td>` : u}
1729
- ${this._rowRenderer ? this.renderRowFromRenderer(s, a, { depth: r, isExpanded: o, isPlaceholder: l }) : l ? h`<td colspan=${this._columns.length} class="tree-placeholder-cell" aria-label=${this.mergedLabels.loading}>…</td>` : this._columns.map((m) => this.renderCell(s, m, a))}
1902
+ ${this._rowRenderer ? this.renderRowFromRenderer(i, a, { depth: r, isExpanded: o, isPlaceholder: l }) : l ? c`<td colspan=${this._columns.length} class="tree-placeholder-cell" aria-label=${this.mergedLabels.loading}>…</td>` : this._columns.map((m) => this.renderCell(i, m, a))}
1730
1903
  </tr>
1731
1904
  `;
1732
1905
  }
1906
+ /**
1907
+ * Names every rendered row checkbox (D14): `rowLabel(row)`, else the trimmed
1908
+ * text of the row's first data cell, else the row number.
1909
+ *
1910
+ * Runs after each render rather than in the template because the cell text
1911
+ * only exists once the cell is rendered — and it may be consumer DOM from a
1912
+ * `cellRenderer` or `rowRenderer` — so a re-rendered cell renames its
1913
+ * checkbox on the same update. The attribute is written only when it
1914
+ * changes, so an unchanged name costs no mutation.
1915
+ */
1916
+ nameRowCheckboxes() {
1917
+ if (!this.isMulti) return;
1918
+ const e = this.mergedLabels, t = new Map(this.computeVisibleRows().map((s) => [s.key, s])), a = this.renderRoot.querySelectorAll('tbody tr[data-row-key]:not([data-placeholder="true"])');
1919
+ for (const s of a) {
1920
+ const i = s.querySelector(":scope > td.checkbox-cell > mp-checkbox"), r = t.get(s.dataset.rowKey ?? "");
1921
+ if (!i || !r) continue;
1922
+ const o = this._rowLabel?.(r.row)?.trim(), l = s.querySelector(":scope > td:not(.checkbox-cell):not(.tree-chevron-cell)")?.textContent?.trim(), h = o || l, d = h ? e.selectRowNamed(h) : e.selectRow(r.rowIndex + 1);
1923
+ i.getAttribute("aria-label") !== d && i.setAttribute("aria-label", d);
1924
+ }
1925
+ }
1733
1926
  renderRowFromRenderer(e, t, a) {
1734
- const i = this._rowRenderer(e, t, a);
1735
- if (i == null)
1736
- return a.isPlaceholder ? h`<td colspan=${this._columns.length} class="tree-placeholder-cell" aria-label=${this.mergedLabels.loading}>…</td>` : this._columns.map((s) => this.renderCell(e, s, t));
1737
- if (Array.isArray(i) || j(i)) {
1738
- const s = [];
1739
- for (const r of i) s.push(r);
1740
- return s;
1927
+ const s = this._rowRenderer(e, t, a);
1928
+ if (s == null)
1929
+ return a.isPlaceholder ? c`<td colspan=${this._columns.length} class="tree-placeholder-cell" aria-label=${this.mergedLabels.loading}>…</td>` : this._columns.map((i) => this.renderCell(e, i, t));
1930
+ if (Array.isArray(s) || J(s)) {
1931
+ const i = [];
1932
+ for (const r of s) i.push(r);
1933
+ return i;
1741
1934
  }
1742
- return i;
1935
+ return s;
1743
1936
  }
1744
1937
  renderCell(e, t, a) {
1745
- const i = t.cellRenderer ? t.cellRenderer(e, t, a) : G(e, t);
1746
- return h`<td class=${t.cellClass ?? ""} data-column=${t.name}>${w(i)}</td>`;
1938
+ const s = t.cellRenderer ? t.cellRenderer(e, t, a) : Y(e, t);
1939
+ return c`<td class=${t.cellClass ?? ""} data-column=${t.name}>${C(s)}</td>`;
1747
1940
  }
1748
1941
  renderFooter(e) {
1749
- const t = Array.from({ length: e }, (a, i) => i + 1);
1750
- return h`
1942
+ const t = Array.from({ length: e }, (a, s) => s + 1);
1943
+ return c`
1751
1944
  <div class="datatable-footer">
1752
1945
  <mp-pagination
1753
1946
  class="datatable-per-page"
@@ -1807,65 +2000,94 @@ class V extends E {
1807
2000
  if (this._cachedFlatList !== null) return this._cachedFlatList;
1808
2001
  if (!this._tree) {
1809
2002
  if (this.isRootWindowed()) {
1810
- const r = this._totalRecords ?? this._data.length, o = Math.max(1, this._perPage), l = new Array(r);
1811
- for (let d = 0; d < r; d++) {
1812
- const c = Math.floor(d / o) + 1, p = d % o, f = c === 1 ? this._data[p] : this._pageCache.get(c)?.[p];
1813
- l[d] = f !== void 0 ? { row: f, key: this._rowKey(f, d), depth: 0, parentId: null, isExpanded: !1, isPlaceholder: !1 } : { row: void 0, key: `__placeholder-flat-${d}`, depth: 0, parentId: null, page: c, isExpanded: !1, isPlaceholder: !0 };
2003
+ const o = this._totalRecords ?? this._data.length, l = Math.max(1, this._perPage), h = new Array(o);
2004
+ for (let d = 0; d < o; d++) {
2005
+ const p = Math.floor(d / l) + 1, f = d % l, b = p === 1 ? this._data[f] : this._pageCache.get(p)?.[f];
2006
+ h[d] = b !== void 0 ? { row: b, key: this._rowKey(b, d), depth: 0, parentId: null, isExpanded: !1, isPlaceholder: !1 } : { row: void 0, key: `__placeholder-flat-${d}`, depth: 0, parentId: null, page: p, isExpanded: !1, isPlaceholder: !0 };
1814
2007
  }
1815
- return this._cachedFlatList = l;
2008
+ return this._cachedFlatList = h;
1816
2009
  }
1817
- const s = (() => {
1818
- let r = this._data;
1819
- if (this._autoSort && this._sortColumns.length > 0 && (r = y(r, this._sortColumns)), this._pagination && !this.isExternallyPaged()) {
1820
- const o = (this._page - 1) * this._perPage;
1821
- r = r.slice(o, o + this._perPage);
1822
- }
1823
- return r;
1824
- })();
1825
- return this._cachedFlatList = s.map((r, o) => ({
1826
- row: r,
1827
- key: this._rowKey(r, o),
2010
+ const i = this._pagination ? (this._page - 1) * this._perPage : 0, r = this._pagination && !this.isExternallyPaged() ? this.localSortedRows().slice(i, i + this._perPage) : this.localSortedRows();
2011
+ return this._cachedFlatList = r.map((o, l) => ({
2012
+ row: o,
2013
+ key: this._rowKey(o, i + l),
1828
2014
  depth: 0,
1829
2015
  parentId: null,
1830
2016
  isExpanded: !1,
1831
2017
  isPlaceholder: !1
1832
2018
  }));
1833
2019
  }
1834
- const e = [], t = Math.max(1, this._perPage), a = (s) => this._autoSort && this._sortColumns.length > 0 ? y(s, this._sortColumns) : s, i = (s, r, o) => {
1835
- const l = this.extractId(s), d = l != null && this._expandedIds.has(l), c = this.extractChildCount(s);
1836
- if (e.push({ row: s, key: this._rowKey(s, e.length), depth: r, parentId: o, isExpanded: d, isPlaceholder: !1 }), !d || c === 0 || l == null) return;
2020
+ const e = [], t = Math.max(1, this._perPage), a = (i) => this._autoSort && this._sortColumns.length > 0 ? y(i, this._sortColumns) : i, s = (i, r, o) => {
2021
+ const l = this.extractId(i), h = l != null && this._expandedIds.has(l), d = this.extractChildCount(i);
2022
+ if (e.push({ row: i, key: this._rowKey(i, e.length), depth: r, parentId: o, isExpanded: h, isPlaceholder: !1 }), !h || d === 0 || l == null) return;
1837
2023
  const p = this._childCache.get(l);
1838
2024
  if (p && p.length > 0) {
1839
- for (const b of a(p)) i(b, r + 1, l);
2025
+ for (const b of a(p)) s(b, r + 1, l);
1840
2026
  const f = this._childTotals.get(l) ?? p.length;
1841
2027
  for (let b = 0; b < Math.max(0, f - p.length); b++)
1842
2028
  e.push({ row: void 0, key: `__placeholder-${String(l)}-${p.length + b}`, depth: r + 1, parentId: l, isExpanded: !1, isPlaceholder: !0 });
1843
2029
  } else
1844
- for (let f = 0; f < c; f++)
2030
+ for (let f = 0; f < d; f++)
1845
2031
  e.push({ row: void 0, key: `__placeholder-${String(l)}-${f}`, depth: r + 1, parentId: l, isExpanded: !1, isPlaceholder: !0 });
1846
2032
  };
1847
2033
  if (this.isRootWindowed()) {
1848
- const s = this._totalRecords ?? this._data.length;
1849
- for (let r = 0; r < s; r++) {
1850
- const o = Math.floor(r / t) + 1, l = r % t, d = o === 1 ? this._data[l] : this._pageCache.get(o)?.[l];
1851
- d === void 0 ? e.push({ row: void 0, key: `__placeholder-root-${r}`, depth: 0, parentId: null, page: o, isExpanded: !1, isPlaceholder: !0 }) : i(d, 0, null);
2034
+ const i = this._totalRecords ?? this._data.length;
2035
+ for (let r = 0; r < i; r++) {
2036
+ const o = Math.floor(r / t) + 1, l = r % t, h = o === 1 ? this._data[l] : this._pageCache.get(o)?.[l];
2037
+ h === void 0 ? e.push({ row: void 0, key: `__placeholder-root-${r}`, depth: 0, parentId: null, page: o, isExpanded: !1, isPlaceholder: !0 }) : s(h, 0, null);
1852
2038
  }
1853
2039
  } else {
1854
- const s = this._autoSort && this._sortColumns.length > 0 ? y(this._data, this._sortColumns) : this._data;
1855
- for (const r of s) i(r, 0, null);
2040
+ const i = this._autoSort && this._sortColumns.length > 0 ? y(this._data, this._sortColumns) : this._data;
2041
+ for (const r of i) s(r, 0, null);
1856
2042
  }
1857
2043
  return this._cachedFlatList = e;
1858
2044
  }
2045
+ /** `_data` in display order: client-sorted when the WC owns sorting. */
2046
+ localSortedRows() {
2047
+ return this._autoSort && this._sortColumns.length > 0 ? y(this._data, this._sortColumns) : this._data;
2048
+ }
2049
+ /**
2050
+ * Drops the flat-list memo. It is otherwise reset only in `willUpdate`, so a
2051
+ * path that runs between a data change and the next render (a programmatic
2052
+ * setter, an event fired before the re-render) would read the old rows.
2053
+ */
2054
+ freshFlatList() {
2055
+ return this._cachedFlatList = null, this.getFlatList();
2056
+ }
2057
+ /**
2058
+ * Every loaded row that has a renderer-assigned key, as `[key, row]`. The keys
2059
+ * are the ones the renderer uses (K1): a positional fallback key only means
2060
+ * anything at the row's rendered index. With local pagination every page is
2061
+ * loaded, so rows of the other pages are keyed by their global index too.
2062
+ */
2063
+ liveRowEntries(e) {
2064
+ const t = e.filter((a) => !a.isPlaceholder).map((a) => [a.key, a.row]);
2065
+ return this._tree || !this._pagination || this.isExternallyPaged() ? t : this.localSortedRows().map((a, s) => [this._rowKey(a, s), a]);
2066
+ }
2067
+ /**
2068
+ * The key the renderer gives a row object. A row outside the live entries (a
2069
+ * child of a collapsed parent, a row only the host knows) has no rendered
2070
+ * index, so it falls back to an index-free `rowKey` call — exact for any
2071
+ * id-based key, and a positional key is already warned about.
2072
+ */
2073
+ keyOfRow(e) {
2074
+ const t = this.getFlatList();
2075
+ return this._keyByRowMemo?.list !== t && (this._keyByRowMemo = { list: t, byRow: new Map(this.liveRowEntries(t).map(([a, s]) => [s, a])) }), this._keyByRowMemo.byRow.get(e) ?? this._rowKey(e, -1);
2076
+ }
2077
+ /** `keyOfRow` against the current data, for paths that may run before a re-render. */
2078
+ rowKeyLookup() {
2079
+ return this.freshFlatList(), (e) => this.keyOfRow(e);
2080
+ }
1859
2081
  computeVisibleRows() {
1860
2082
  const e = this.getFlatList(), t = this._tree ? 0 : this._pagination ? (this._page - 1) * this._perPage : 0;
1861
- let a = e, i = 0;
2083
+ let a = e, s = 0;
1862
2084
  if (this._virtualScroll) {
1863
- const { startIndex: s, endIndex: r } = this._virtualRange;
1864
- a = e.slice(s, r), i = s;
2085
+ const { startIndex: i, endIndex: r } = this._virtualRange;
2086
+ a = e.slice(i, r), s = i;
1865
2087
  }
1866
- return a.map((s, r) => {
1867
- const o = t + i + r;
1868
- return { row: s.row, rowIndex: o, key: s.key, flat: s };
2088
+ return a.map((i, r) => {
2089
+ const o = t + s + r;
2090
+ return { row: i.row, rowIndex: o, key: i.key, flat: i };
1869
2091
  });
1870
2092
  }
1871
2093
  // ─── Tree-mode helpers ───────────────────────────────────────────────────
@@ -1877,21 +2099,18 @@ class V extends E {
1877
2099
  const t = e[this._childCountKey];
1878
2100
  return typeof t == "number" && t > 0 ? t : 0;
1879
2101
  }
1880
- /** Walks the loaded subtree of `row` and returns the rowKey for every descendant. */
1881
- collectDescendantKeys(e) {
2102
+ /**
2103
+ * Walks the loaded subtree of `row` and returns `[key, row]` for every
2104
+ * descendant — the row too, because a cascade selects it and the selection
2105
+ * remembers the rows it selected.
2106
+ */
2107
+ collectDescendants(e) {
1882
2108
  const t = this.extractId(e), a = t != null ? this._childCache.get(t) : void 0;
1883
- if (!a) return [];
1884
- const i = [];
1885
- for (const s of a) {
1886
- i.push(this._rowKey(s, -1));
1887
- const r = this.collectDescendantKeys(s);
1888
- for (const o of r) i.push(o);
1889
- }
1890
- return i;
2109
+ return a ? a.flatMap((s) => [[this.keyOfRow(s), s], ...this.collectDescendants(s)]) : [];
1891
2110
  }
1892
2111
  /** Some-but-not-all loaded descendants selected → indeterminate parent checkbox. */
1893
- isParentIndeterminate(e) {
1894
- return this._selectionStrategy !== "cascading" || e == null ? !1 : this.getIndeterminateKeys().has(this._rowKey(e, -1));
2112
+ isParentIndeterminate(e, t) {
2113
+ return this._selectionStrategy !== "cascading" || e == null ? !1 : this.getIndeterminateKeys().has(t);
1895
2114
  }
1896
2115
  /**
1897
2116
  * Per-render memo: the set of row keys whose loaded subtree is partially
@@ -1906,16 +2125,16 @@ class V extends E {
1906
2125
  if (this._selectionStrategy !== "cascading" || !this._tree)
1907
2126
  return this._cachedIndeterminateKeys = e;
1908
2127
  const t = (a) => {
1909
- const i = this.extractId(a);
1910
- if (i == null) return { selected: 0, total: 0 };
1911
- const s = this._childCache.get(i);
1912
- if (!s || s.length === 0) return { selected: 0, total: 0 };
2128
+ const s = this.extractId(a);
2129
+ if (s == null) return { selected: 0, total: 0 };
2130
+ const i = this._childCache.get(s);
2131
+ if (!i || i.length === 0) return { selected: 0, total: 0 };
1913
2132
  let r = 0, o = 0;
1914
- for (const l of s) {
1915
- const d = this._rowKey(l, -1), c = this._selectedIds.has(d) ? 1 : 0, p = t(l);
1916
- r += c + p.selected, o += 1 + p.total;
2133
+ for (const l of i) {
2134
+ const h = this.keyOfRow(l), d = this._selectedIds.has(h) ? 1 : 0, p = t(l);
2135
+ r += d + p.selected, o += 1 + p.total;
1917
2136
  }
1918
- return o > 0 && r > 0 && r < o && e.add(this._rowKey(a, -1)), { selected: r, total: o };
2137
+ return o > 0 && r > 0 && r < o && e.add(this.keyOfRow(a)), { selected: r, total: o };
1919
2138
  };
1920
2139
  for (const a of this._data) t(a);
1921
2140
  return this._cachedIndeterminateKeys = e;
@@ -1925,19 +2144,19 @@ class V extends E {
1925
2144
  * children aren't cached yet so the wrapper can bridge to the consumer's
1926
2145
  * `[fetch]` callback. Always fires `expanded-ids-change`.
1927
2146
  */
1928
- toggleExpand(e, t, a, i) {
1929
- i.stopPropagation(), i.preventDefault();
1930
- const s = this.extractId(e);
1931
- if (s == null) return;
2147
+ toggleExpand(e, t, a, s) {
2148
+ s.stopPropagation(), s.preventDefault();
2149
+ const i = this.extractId(e);
2150
+ if (i == null) return;
1932
2151
  const r = new Set(this._expandedIds);
1933
2152
  let o;
1934
- r.has(s) ? (r.delete(s), o = !1) : (r.add(s), o = !0), this._expandedIds = r, o ? (this.dispatchEvent(
2153
+ r.has(i) ? (r.delete(i), o = !1) : (r.add(i), o = !0), this._expandedIds = r, o ? (this.dispatchEvent(
1935
2154
  new CustomEvent("mp-datatable-row-expand", {
1936
2155
  detail: { row: e, depth: a, parentId: t },
1937
2156
  bubbles: !0,
1938
2157
  composed: !0
1939
2158
  })
1940
- ), this.extractChildCount(e) > 0 && !this._childCache.has(s) && !this._pendingFetches.has(s) && this.fetchChildren(s)) : this.dispatchEvent(
2159
+ ), this.extractChildCount(e) > 0 && !this._childCache.has(i) && !this._pendingFetches.has(i) && this.fetchChildren(i)) : this.dispatchEvent(
1941
2160
  new CustomEvent("mp-datatable-row-collapse", {
1942
2161
  detail: { row: e, depth: a, parentId: t },
1943
2162
  bubbles: !0,
@@ -1969,8 +2188,8 @@ class V extends E {
1969
2188
  const a = await this._fetch({ parentId: null, page: e, perPage: this._perPage, sortColumns: [...this._sortColumns] });
1970
2189
  if (t !== this._fetchGeneration || !this._fetch) return;
1971
2190
  this._pendingPageFetches.delete(e), this._pageCache.set(e, [...a?.data ?? []]);
1972
- const i = a?.totalRecords == null ? null : Math.max(0, Math.floor(a.totalRecords));
1973
- i != null && (this._totalRecords = i), this.requestUpdate();
2191
+ const s = a?.totalRecords == null ? null : Math.max(0, Math.floor(a.totalRecords));
2192
+ s != null && (this._totalRecords = s), this.requestUpdate();
1974
2193
  } catch (a) {
1975
2194
  this._pendingPageFetches.delete(e), console.error("[mp-datatable] fetch failed for root page", e, a);
1976
2195
  }
@@ -2002,14 +2221,14 @@ class V extends E {
2002
2221
  let a;
2003
2222
  try {
2004
2223
  a = await this._fetch({ parentId: null, page: e, perPage: this._perPage, sortColumns: [...this._sortColumns] });
2005
- } catch (s) {
2006
- console.error("[mp-datatable] fetch failed for page", e, s);
2224
+ } catch (i) {
2225
+ console.error("[mp-datatable] fetch failed for page", e, i);
2007
2226
  return;
2008
2227
  }
2009
2228
  if (t !== this._fetchGeneration || !this._fetch) return;
2010
2229
  this._data = [...a?.data ?? []];
2011
- const i = a?.totalRecords == null ? null : Math.max(0, Math.floor(a.totalRecords));
2012
- this._totalRecords = i, this._initialFetchDone = !0, this.requestUpdate();
2230
+ const s = a?.totalRecords == null ? null : Math.max(0, Math.floor(a.totalRecords));
2231
+ this._totalRecords = s, this._initialFetchDone = !0, this.requestUpdate();
2013
2232
  }
2014
2233
  /**
2015
2234
  * Coalesce sort/perPage/page changes (which arrive both as user actions and
@@ -2028,32 +2247,48 @@ class V extends E {
2028
2247
  this._initialFetchDone && e === this._lastReloadKey || (this._lastReloadKey = e, this._fetchGeneration++, this._pageCache.clear(), this._pendingPageFetches.clear(), this._childCache.clear(), this._childTotals.clear(), this._pendingFetches.clear(), this.loadPage(this._virtualScroll ? 1 : this._page));
2029
2248
  }));
2030
2249
  }
2031
- /** Keyboard handling on a tree-mode row. Arrow keys + Enter/Space toggle expansion. */
2032
- onRowKeydown(e, t, a, i, s, r, o, l) {
2250
+ /**
2251
+ * Row keymap, the same in every mode: ArrowUp/Down move, ArrowRight/Left
2252
+ * expand/collapse a tree row, Enter opens (row-click), Space selects.
2253
+ * 'single'/'multiple': Enter and Space both select with the click modifiers
2254
+ * and emit row-click. 'checkbox': Enter only emits row-click, Space only
2255
+ * toggles the row's checkbox.
2256
+ */
2257
+ onRowKeydown(e, t, a, s, i, r, o, l) {
2033
2258
  if (!l.altKey && l.composedPath()[0] === l.currentTarget) {
2034
2259
  if (l.key === "ArrowDown" || l.key === "ArrowUp") {
2035
2260
  l.preventDefault();
2036
- const d = Array.from(
2261
+ const h = Array.from(
2037
2262
  this.renderRoot.querySelectorAll("tbody tr[data-row-key]")
2038
- ), c = d.findIndex((f) => f.dataset.rowKey === t), p = d[c + (l.key === "ArrowDown" ? 1 : -1)];
2263
+ ), d = h.findIndex((f) => f.dataset.rowKey === t), p = h[d + (l.key === "ArrowDown" ? 1 : -1)];
2039
2264
  p && p.focus();
2040
2265
  return;
2041
2266
  }
2042
2267
  if (this._tree) {
2043
2268
  if (l.key === "ArrowRight" && o > 0 && !r) {
2044
- this.toggleExpand(e, i, s, l);
2269
+ this.toggleExpand(e, s, i, l);
2045
2270
  return;
2046
2271
  }
2047
2272
  if (l.key === "ArrowLeft" && r) {
2048
- this.toggleExpand(e, i, s, l);
2273
+ this.toggleExpand(e, s, i, l);
2049
2274
  return;
2050
2275
  }
2051
- if ((l.key === "Enter" || l.key === " ") && o > 0) {
2052
- this.toggleExpand(e, i, s, l);
2276
+ }
2277
+ if ((l.key === "Enter" || l.key === " ") && this._selectionMode === "checkbox") {
2278
+ if (l.preventDefault(), this._focusedRowKey = t, l.key === " ") {
2279
+ l.shiftKey || this.onRowCheckboxToggle(e, t), this.requestUpdate();
2053
2280
  return;
2054
2281
  }
2282
+ this.requestUpdate(), this.dispatchEvent(
2283
+ new CustomEvent("mp-datatable-row-click", {
2284
+ detail: { row: e, rowIndex: a, rowKey: t, originalEvent: l },
2285
+ bubbles: !0,
2286
+ composed: !0
2287
+ })
2288
+ );
2289
+ return;
2055
2290
  }
2056
- (l.key === "Enter" || l.key === " ") && this._selectionMode !== "none" && (l.preventDefault(), this._focusedRowKey = t, this.handleSelectionOnClick(t, l), this.requestUpdate(), this.dispatchEvent(
2291
+ (l.key === "Enter" || l.key === " ") && this._selectionMode !== "none" && (l.preventDefault(), this._focusedRowKey = t, this.handleSelectionOnClick(e, t, l), this.requestUpdate(), this.dispatchEvent(
2057
2292
  new CustomEvent("mp-datatable-row-click", {
2058
2293
  detail: { row: e, rowIndex: a, rowKey: t, originalEvent: l },
2059
2294
  bubbles: !0,
@@ -2065,69 +2300,81 @@ class V extends E {
2065
2300
  hasRowClickListeners() {
2066
2301
  return !0;
2067
2302
  }
2303
+ /**
2304
+ * Bound only to the sort <button>, which renders only for sortable columns;
2305
+ * the resize handle is the button's sibling, so its clicks never land here.
2306
+ */
2068
2307
  onHeaderClick(e, t) {
2069
- if (!(e.sortable ?? !0) || t.target.closest(".resize-handle")) return;
2070
- const s = N(this._sortColumns, e.name, t.shiftKey);
2071
- this._sortColumns = s, this._page = 1;
2072
- const r = s.find((o) => o.property === e.name);
2308
+ const a = H(this._sortColumns, e.name, t.shiftKey);
2309
+ this._sortColumns = a, this._page = 1;
2310
+ const s = a.find((i) => i.property === e.name);
2073
2311
  this.liveAnnouncer.announce(
2074
2312
  this.mergedLabels.announceSorted(
2075
2313
  e.label ?? e.name,
2076
- r ? r.direction === "ascending" ? "ascending" : "descending" : "none"
2314
+ s ? s.direction === "ascending" ? "ascending" : "descending" : "none"
2077
2315
  )
2078
2316
  ), this.requestUpdate(), this.scheduleFetchReload(), this.dispatchEvent(
2079
2317
  new CustomEvent("mp-datatable-sort-change", {
2080
- detail: { sortColumns: s },
2318
+ detail: { sortColumns: a },
2081
2319
  bubbles: !0,
2082
2320
  composed: !0
2083
2321
  })
2084
2322
  );
2085
2323
  }
2086
- onRowClick(e, t, a, i) {
2087
- i.target.closest('input[type="checkbox"]') || (this._focusedRowKey = t, this.handleSelectionOnClick(t, i), this.requestUpdate(), this.dispatchEvent(
2324
+ onRowClick(e, t, a, s) {
2325
+ this._focusedRowKey = t, this._selectionMode !== "checkbox" && this.handleSelectionOnClick(e, t, s), this.requestUpdate(), this.dispatchEvent(
2088
2326
  new CustomEvent("mp-datatable-row-click", {
2089
- detail: { row: e, rowIndex: a, rowKey: t, originalEvent: i },
2327
+ detail: { row: e, rowIndex: a, rowKey: t, originalEvent: s },
2090
2328
  bubbles: !0,
2091
2329
  composed: !0
2092
2330
  })
2093
- ));
2331
+ );
2094
2332
  }
2095
- onRowDblClick(e, t, a, i) {
2333
+ onRowDblClick(e, t, a, s) {
2096
2334
  this.dispatchEvent(
2097
2335
  new CustomEvent("mp-datatable-row-dblclick", {
2098
- detail: { row: e, rowIndex: a, rowKey: t, originalEvent: i },
2336
+ detail: { row: e, rowIndex: a, rowKey: t, originalEvent: s },
2099
2337
  bubbles: !0,
2100
2338
  composed: !0
2101
2339
  })
2102
2340
  );
2103
2341
  }
2104
- onRowContextMenu(e, t, a, i) {
2105
- this._selectionMode !== "none" && !this._selectedIds.has(t) && (this._selectedIds = /* @__PURE__ */ new Set([t]), this._focusedRowKey = t, this.emitSelectionChange(), this.requestUpdate()), this.dispatchEvent(
2342
+ onRowContextMenu(e, t, a, s) {
2343
+ this._selectionMode !== "none" && this._selectionMode !== "checkbox" && !this._selectedIds.has(t) && (this.commitSelection([t], [[t, e]]), this._focusedRowKey = t, this.emitSelectionChange(), this.requestUpdate()), this.dispatchEvent(
2106
2344
  new CustomEvent("mp-datatable-row-contextmenu", {
2107
- detail: { row: e, rowIndex: a, rowKey: t, originalEvent: i },
2345
+ detail: { row: e, rowIndex: a, rowKey: t, originalEvent: s },
2108
2346
  bubbles: !0,
2109
2347
  composed: !0,
2110
2348
  cancelable: !0
2111
2349
  })
2112
- );
2350
+ ) || s.preventDefault();
2113
2351
  }
2114
- onRowCheckboxToggle(e, t, a, i) {
2115
- if (this._selectionMode !== "none") {
2116
- if (this._selectionMode === "single")
2117
- this._selectedIds = /* @__PURE__ */ new Set([t]);
2118
- else {
2119
- const s = new Set(this._selectedIds), r = !s.has(t);
2120
- if (r ? s.add(t) : s.delete(t), this._tree && this._selectionStrategy === "cascading" && e != null) {
2121
- const o = this.collectDescendantKeys(e);
2122
- if (r)
2123
- for (const l of o) s.add(l);
2124
- else
2125
- for (const l of o) s.delete(l);
2126
- }
2127
- this._selectedIds = s;
2128
- }
2129
- this.emitSelectionChange(), this.requestUpdate();
2130
- }
2352
+ /**
2353
+ * A click anywhere in the checkbox cell, in every mode. The cell is
2354
+ * selection-only, so neither its click nor its double-click reaches the row
2355
+ * (D12: a double-click on a checkbox used to open the row).
2356
+ *
2357
+ * In 'checkbox' mode the whole cell is the hit target, not just the 20px box.
2358
+ * A click that went through the checkbox's own shadow root is the checkbox
2359
+ * operating itself (its change handler toggles), so it is left alone; every
2360
+ * other click toggles here. `closest('mp-checkbox')` cannot tell the two
2361
+ * apart: a click on the checkbox host's padding is retargeted to the host yet
2362
+ * fires no change, so it would be swallowed (spike S1). No focus() and no
2363
+ * preventDefault(): the browser focuses the row natively, which keeps Enter,
2364
+ * Space and the arrow keys working from there (spike S4).
2365
+ */
2366
+ onCheckboxCellClick(e, t, a) {
2367
+ if (a.stopPropagation(), this._selectionMode !== "checkbox") return;
2368
+ const s = a.currentTarget.querySelector("mp-checkbox")?.shadowRoot;
2369
+ s && a.composedPath().includes(s) || this.onRowCheckboxToggle(e, t);
2370
+ }
2371
+ /** Row checkboxes render only in the multi-select modes, so this is multi-select toggling. */
2372
+ onRowCheckboxToggle(e, t) {
2373
+ const a = !this._selectedIds.has(t), s = [
2374
+ [t, e],
2375
+ ...this._tree && this._selectionStrategy === "cascading" ? this.collectDescendants(e) : []
2376
+ ], i = new Set(s.map(([r]) => r));
2377
+ a ? this.commitSelection([...this._selectedIds, ...i], s) : this.commitSelection([...this._selectedIds].filter((r) => !i.has(r))), this.emitSelectionChange(), this.requestUpdate();
2131
2378
  }
2132
2379
  /**
2133
2380
  * Clears the entire selection. The header checkbox is only rendered when
@@ -2137,30 +2384,81 @@ class V extends E {
2137
2384
  * therefore one-way: visible → deselect-all → hidden again.
2138
2385
  */
2139
2386
  onDeselectAll() {
2140
- this._selectedIds.size !== 0 && (this._selectedIds = /* @__PURE__ */ new Set(), this.emitSelectionChange(), this.requestUpdate());
2387
+ this._selectedIds.size !== 0 && (this.commitSelection([]), this.emitSelectionChange(), this.requestUpdate());
2141
2388
  }
2142
- handleSelectionOnClick(e, t) {
2389
+ handleSelectionOnClick(e, t, a) {
2143
2390
  if (this._selectionMode !== "none") {
2144
2391
  if (this._selectionMode === "single") {
2145
- this._selectedIds = /* @__PURE__ */ new Set([e]), this.emitSelectionChange();
2392
+ this.commitSelection([t], [[t, e]]), this.emitSelectionChange();
2146
2393
  return;
2147
2394
  }
2148
- if (t.shiftKey && this._selectionAnchorKey && this._selectionAnchorKey !== e) {
2149
- const a = this.computeVisibleRows(), i = a.findIndex((r) => r.key === this._selectionAnchorKey), s = a.findIndex((r) => r.key === e);
2150
- if (i >= 0 && s >= 0) {
2151
- const [r, o] = i < s ? [i, s] : [s, i], l = a.slice(r, o + 1).map((d) => d.key);
2152
- this._selectedIds = /* @__PURE__ */ new Set([...this._selectedIds, ...l]), this.emitSelectionChange();
2395
+ if (a.shiftKey && this._selectionAnchorKey && this._selectionAnchorKey !== t) {
2396
+ const s = this.getFlatList(), i = s.findIndex((o) => !o.isPlaceholder && o.key === this._selectionAnchorKey), r = s.findIndex((o) => o.key === t);
2397
+ if (i >= 0 && r >= 0) {
2398
+ const [o, l] = i < r ? [i, r] : [r, i], h = s.slice(o, l + 1);
2399
+ if (h.some((p) => p.isPlaceholder)) {
2400
+ this.liveAnnouncer.announce(this.mergedLabels.rangeIncomplete);
2401
+ return;
2402
+ }
2403
+ const d = h.map((p) => [p.key, p.row]);
2404
+ this.commitSelection([...this._selectedIds, ...d.map(([p]) => p)], d), this.emitSelectionChange();
2153
2405
  return;
2154
2406
  }
2155
2407
  }
2156
- if (t.ctrlKey || t.metaKey) {
2157
- const a = new Set(this._selectedIds);
2158
- a.has(e) ? a.delete(e) : a.add(e), this._selectedIds = a, this._selectionAnchorKey = e, this.emitSelectionChange();
2408
+ if (a.ctrlKey || a.metaKey) {
2409
+ const s = new Set(this._selectedIds);
2410
+ s.has(t) ? s.delete(t) : s.add(t), this.commitSelection(s, [[t, e]]), this._selectionAnchorKey = t, this.emitSelectionChange();
2159
2411
  return;
2160
2412
  }
2161
- this._selectedIds = /* @__PURE__ */ new Set([e]), this._selectionAnchorKey = e, this.emitSelectionChange();
2413
+ this.commitSelection([t], [[t, e]]), this._selectionAnchorKey = t, this.emitSelectionChange();
2162
2414
  }
2163
2415
  }
2416
+ /**
2417
+ * The one write path for a user-driven selection change. `rows` supplies the
2418
+ * row of each key being selected; the remembered rows are then pruned to the
2419
+ * new keys, so a deselected row is forgotten in the same step.
2420
+ */
2421
+ commitSelection(e, t = []) {
2422
+ this._selectedIds = new Set(e);
2423
+ for (const [a, s] of t)
2424
+ s !== void 0 && this._selectedIds.has(a) && this._selectedRowCache.set(a, s);
2425
+ this.pruneSelectedRowCache();
2426
+ }
2427
+ /**
2428
+ * Every row the element holds right now, by key: the loaded rows (keyed as
2429
+ * the renderer keys them, K1) plus the fetched children of collapsed parents
2430
+ * (through `keyOfRow`'s index-free fallback).
2431
+ */
2432
+ liveRowMap() {
2433
+ const e = new Map(this.liveRowEntries(this.freshFlatList()));
2434
+ for (const t of this._childCache.values())
2435
+ for (const a of t) {
2436
+ const s = this.keyOfRow(a);
2437
+ e.has(s) || e.set(s, a);
2438
+ }
2439
+ return e;
2440
+ }
2441
+ /** Remembers the loaded row of every selected key (a loaded row always wins, D2). */
2442
+ rememberLiveSelectedRows() {
2443
+ for (const [e, t] of this.liveRowMap())
2444
+ t !== void 0 && this._selectedIds.has(e) && this._selectedRowCache.set(e, t);
2445
+ }
2446
+ /**
2447
+ * True when `pairs` is exactly the current selection: the same keys in the
2448
+ * same order, each with the row object the element would report for it.
2449
+ */
2450
+ isSameSelectedRows(e) {
2451
+ if (e.length !== this._selectedIds.size) return !1;
2452
+ const t = [...this._selectedIds];
2453
+ if (!e.every(([s], i) => s === t[i])) return !1;
2454
+ const a = this.resolveRows(t);
2455
+ return e.every(([, s], i) => s === a[i]);
2456
+ }
2457
+ /** Forgets the rows of keys that left the selection. One pass, deletes in place. */
2458
+ pruneSelectedRowCache() {
2459
+ for (const e of this._selectedRowCache.keys())
2460
+ this._selectedIds.has(e) || this._selectedRowCache.delete(e);
2461
+ }
2164
2462
  emitSelectionChange() {
2165
2463
  const e = [...this._selectedIds];
2166
2464
  this.liveAnnouncer.announce(this.mergedLabels.announceSelection(e.length)), this.dispatchEvent(
@@ -2172,19 +2470,21 @@ class V extends E {
2172
2470
  );
2173
2471
  }
2174
2472
  /**
2175
- * Resolve row keys → row objects across every loaded source (page-1 `_data`,
2176
- * fetched windows in `_pageCache`, tree children in `_childCache`). One pass
2177
- * builds a key→row index; unresolvable ids are skipped.
2473
+ * Resolves keys to rows, index-aligned with `ids` (D3): the loaded row if
2474
+ * there is one, else the row remembered at selection time, else `undefined`.
2475
+ *
2476
+ * A loaded row also refreshes the remembered one, so a re-fetched row object
2477
+ * always wins over a stale copy. Loaded rows are keyed exactly as the
2478
+ * renderer keys them (K1); children of collapsed parents have no rendered
2479
+ * index and go through `keyOfRow`'s index-free fallback.
2178
2480
  */
2179
2481
  resolveRows(e) {
2180
2482
  if (e.length === 0) return [];
2181
- const t = /* @__PURE__ */ new Map(), a = (i) => {
2182
- for (const s of i) t.set(this._rowKey(s, -1), s);
2183
- };
2184
- a(this._data);
2185
- for (const i of this._pageCache.values()) a(i);
2186
- for (const i of this._childCache.values()) a(i);
2187
- return e.map((i) => t.get(i)).filter((i) => i !== void 0);
2483
+ const t = this.liveRowMap();
2484
+ return e.map((a) => {
2485
+ const s = t.get(a);
2486
+ return s === void 0 ? this._selectedRowCache.get(a) : (this._selectedIds.has(a) && this._selectedRowCache.set(a, s), s);
2487
+ });
2188
2488
  }
2189
2489
  gotoPage(e) {
2190
2490
  const t = this._totalRecords ?? this._data.length, a = Math.max(1, Math.ceil(t / this._perPage));
@@ -2204,35 +2504,38 @@ class V extends E {
2204
2504
  onResizeHandleKeydown(e, t) {
2205
2505
  if (!this._resizableColumns || t.key !== "ArrowLeft" && t.key !== "ArrowRight") return;
2206
2506
  t.preventDefault(), t.stopPropagation();
2207
- const i = t.currentTarget.closest("th"), s = this._columnWidths.get(e.name) ?? i?.getBoundingClientRect().width ?? 100, r = Math.max(40, s + (t.key === "ArrowRight" ? 10 : -10));
2507
+ const s = t.currentTarget.closest("th"), i = this._columnWidths.get(e.name) ?? s?.getBoundingClientRect().width ?? 100, r = $(
2508
+ i,
2509
+ t.key === "ArrowRight" ? R : -R
2510
+ );
2208
2511
  this._columnWidths = new Map(this._columnWidths), this._columnWidths.set(e.name, r), this.requestUpdate();
2209
2512
  }
2210
2513
  startColumnResize(e, t) {
2211
2514
  if (!this._resizableColumns) return;
2212
2515
  t.preventDefault(), t.stopPropagation();
2213
- const a = t.currentTarget, i = a.closest("th");
2214
- if (!i) return;
2215
- const s = i.getBoundingClientRect().width;
2216
- this.resizeState = { columnName: e.name, startX: t.clientX, startWidth: s, handle: a }, a.classList.add("active"), a.setPointerCapture(t.pointerId), a.addEventListener("pointermove", this.onColumnResizeMove), a.addEventListener("pointerup", this.onColumnResizeEnd), a.addEventListener("pointercancel", this.onColumnResizeEnd);
2516
+ const a = t.currentTarget, s = a.closest("th");
2517
+ if (!s) return;
2518
+ const i = s.getBoundingClientRect().width;
2519
+ this.resizeState = { columnName: e.name, startX: t.clientX, startWidth: i, handle: a }, a.classList.add("active"), a.setPointerCapture(t.pointerId), a.addEventListener("pointermove", this.onColumnResizeMove), a.addEventListener("pointerup", this.onColumnResizeEnd), a.addEventListener("pointercancel", this.onColumnResizeEnd);
2217
2520
  }
2218
2521
  }
2219
- function G(n, e) {
2522
+ function Y(n, e) {
2220
2523
  if (n == null || typeof n != "object") return "";
2221
2524
  const t = n[e.name];
2222
2525
  return t == null ? "" : String(t);
2223
2526
  }
2224
- function j(n) {
2527
+ function J(n) {
2225
2528
  return n != null && typeof n != "string" && typeof n[Symbol.iterator] == "function";
2226
2529
  }
2227
- function w(n) {
2530
+ function C(n) {
2228
2531
  return n == null || n === !1 ? u : (n instanceof Node || typeof n == "object" && "_$litType$" in n, n);
2229
2532
  }
2230
- M("datatable", D);
2231
- typeof customElements < "u" && !customElements.get("mp-datatable") && customElements.define("mp-datatable", V);
2533
+ q("datatable", B);
2534
+ typeof customElements < "u" && !customElements.get("mp-datatable") && customElements.define("mp-datatable", X);
2232
2535
  export {
2233
- O as D,
2234
- V as M,
2235
- N as c,
2236
- D as d,
2536
+ W as D,
2537
+ X as M,
2538
+ H as c,
2539
+ B as d,
2237
2540
  y as s
2238
2541
  };