@prioticket/design-system-web 1.7.0-beta.1 → 1.7.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.
@@ -1,25 +1,25 @@
1
- import { css as b, LitElement as _, nothing as g, html as d } from "lit";
2
- import { property as c, state as u, customElement as y } from "lit/decorators.js";
3
- import { repeat as f } from "lit/directives/repeat.js";
1
+ import { css as y, LitElement as w, nothing as p, html as h } from "lit";
2
+ import { property as g, state as u, customElement as v } from "lit/decorators.js";
3
+ import { repeat as x } from "lit/directives/repeat.js";
4
4
  import { classMap as m } from "lit/directives/class-map.js";
5
- import { ref as v } from "lit/directives/ref.js";
5
+ import { ref as C } from "lit/directives/ref.js";
6
6
  import "./pd-icon.es.js";
7
7
  import "./pd-checkbox.es.js";
8
8
  import "./pd-text-field.es.js";
9
9
  import "./pd-icon-button.es.js";
10
10
  import "./pd-select.es.js";
11
11
  import "./pd-menu-item.es.js";
12
- var w = Object.defineProperty, C = Object.getOwnPropertyDescriptor, l = (e, t, a, r) => {
13
- for (var s = r > 1 ? void 0 : r ? C(t, a) : t, n = e.length - 1, o; n >= 0; n--)
14
- (o = e[n]) && (s = (r ? o(t, a, s) : o(s)) || s);
15
- return r && s && w(t, a, s), s;
12
+ var S = Object.defineProperty, D = Object.getOwnPropertyDescriptor, d = (e, t, a, r) => {
13
+ for (var s = r > 1 ? void 0 : r ? D(t, a) : t, o = e.length - 1, n; o >= 0; o--)
14
+ (n = e[o]) && (s = (r ? n(t, a, s) : n(s)) || s);
15
+ return r && s && S(t, a, s), s;
16
16
  };
17
- let i = class extends _ {
17
+ let l = class extends w {
18
18
  constructor() {
19
19
  super(...arguments), this.columns = [], this.data = [], this.rowKey = (e, t) => {
20
20
  const a = e.id;
21
21
  return a != null ? String(a) : `__idx_${t}`;
22
- }, this.selectable = !1, this.sortable = !1, this.pagination = !1, this.pageSize = 10, this.pageIndex = 0, this.totalItems = 0, this.draggableRows = !1, this.draggableColumns = !1, this.loading = !1, this.clearSelectionOnDataChange = !1, this.currencyCode = "EUR", this.pageSizeOptions = [5, 10, 25, 50, 100], this._sortColumn = null, this._sortDirection = "asc", this._selectedRowKeys = /* @__PURE__ */ new Set(), this._draggedRowIndex = null, this._dragOverRowIndex = null, this._isDragHandleGrabbed = !1, this._draggedColumnIndex = null, this._dragOverColumnIndex = null, this._displayDataCache = [], this._displayDataCacheKey = "", this._reactRoots = /* @__PURE__ */ new Map(), this._uniqueId = Math.random().toString(36).substring(2, 9);
22
+ }, this.selectable = !1, this.sortable = !1, this.pagination = !1, this.pageSize = 10, this.pageIndex = 0, this.totalItems = 0, this.draggableRows = !1, this.draggableColumns = !1, this.loading = !1, this.clearSelectionOnDataChange = !1, this.currencyCode = "EUR", this.pageSizeOptions = [5, 10, 25, 50, 100], this._sortColumn = null, this._sortDirection = "asc", this._selectedRowKeys = /* @__PURE__ */ new Set(), this._draggedRowIndex = null, this._dragOverRowIndex = null, this._isDragHandleGrabbed = !1, this._draggedColumnIndex = null, this._dragOverColumnIndex = null, this._flipPositions = /* @__PURE__ */ new Map(), this._flipPending = !1, this._displayDataCache = [], this._displayDataCacheKey = "", this._displayToDataIndexMap = /* @__PURE__ */ new Map(), this._reactRoots = /* @__PURE__ */ new Map(), this._dataRevision = 0, this._uniqueId = Math.random().toString(36).substring(2, 9);
23
23
  }
24
24
  // ---------------------------------------------------------------------------
25
25
  // Getters
@@ -49,7 +49,10 @@ let i = class extends _ {
49
49
  const a = this.pageIndex * this.pageSize, r = a + this.pageSize;
50
50
  t = t.slice(a, r);
51
51
  }
52
- return this._displayDataCacheKey = e, this._displayDataCache = t, t;
52
+ this._displayDataCacheKey = e, this._displayDataCache = t, this._displayToDataIndexMap = /* @__PURE__ */ new Map();
53
+ for (let a = 0; a < t.length; a++)
54
+ this._displayToDataIndexMap.set(t[a], this.data.indexOf(t[a]));
55
+ return t;
53
56
  }
54
57
  // ---------------------------------------------------------------------------
55
58
  // Lifecycle
@@ -58,44 +61,74 @@ let i = class extends _ {
58
61
  super.disconnectedCallback(), this._reactRoots.forEach(({ unmount: e }) => e()), this._reactRoots.clear();
59
62
  }
60
63
  willUpdate(e) {
61
- super.willUpdate(e), e.has("data") && this.clearSelectionOnDataChange && (this._selectedRowKeys = /* @__PURE__ */ new Set()), (e.has("data") || e.has("pageSize")) && this.pageIndex >= this._totalPages && this._totalPages > 0 && (this.pageIndex = this._totalPages - 1);
64
+ super.willUpdate(e), e.has("data") && this._dataRevision++, e.has("data") && this.clearSelectionOnDataChange && (this._selectedRowKeys = /* @__PURE__ */ new Set()), (e.has("data") || e.has("pageSize")) && this.pageIndex >= this._totalPages && this._totalPages > 0 && (this.pageIndex = this._totalPages - 1);
65
+ }
66
+ updated(e) {
67
+ super.updated(e), this._flipPending && (this._flipPending = !1, this._playFlipAnimation());
62
68
  }
63
69
  // ---------------------------------------------------------------------------
64
- // Private Methods - Data Processing
70
+ // FLIP Animation
65
71
  // ---------------------------------------------------------------------------
72
+ /**
73
+ * Captures the current Y position of every visible row.
74
+ * Must be called BEFORE data changes trigger a re-render.
75
+ */
76
+ _captureRowPositions() {
77
+ this._flipPositions.clear();
78
+ const e = this.shadowRoot?.querySelector("tbody");
79
+ if (!e) return;
80
+ const t = e.querySelectorAll('tr[role="row"]'), a = this._displayData;
81
+ t.forEach((r, s) => {
82
+ const o = a[s];
83
+ if (!o) return;
84
+ const n = this._displayToDataIndexMap.get(o) ?? this.data.indexOf(o), i = this._getRowKey(o, n);
85
+ this._flipPositions.set(i, r.getBoundingClientRect().top);
86
+ });
87
+ }
88
+ /**
89
+ * After re-render, computes the delta between old and new positions
90
+ * and animates rows from their old position to the new one.
91
+ */
92
+ _playFlipAnimation() {
93
+ const e = this.shadowRoot?.querySelector("tbody");
94
+ if (!e || this._flipPositions.size === 0) return;
95
+ const t = e.querySelectorAll('tr[role="row"]'), a = this._displayData;
96
+ t.forEach((r, s) => {
97
+ const o = a[s];
98
+ if (!o) return;
99
+ const n = this._displayToDataIndexMap.get(o) ?? this.data.indexOf(o), i = this._getRowKey(o, n), c = this._flipPositions.get(i);
100
+ if (c === void 0) return;
101
+ const f = r.getBoundingClientRect().top, b = c - f;
102
+ Math.abs(b) < 1 || (r.style.transform = `translateY(${b}px)`, r.style.transition = "none", requestAnimationFrame(() => {
103
+ r.style.transition = "transform 200ms cubic-bezier(0.2, 0, 0, 1)", r.style.transform = "";
104
+ const _ = () => {
105
+ r.style.transition = "", r.removeEventListener("transitionend", _);
106
+ };
107
+ r.addEventListener("transitionend", _, { once: !0 });
108
+ }));
109
+ }), this._flipPositions.clear();
110
+ }
66
111
  _computeCacheKey() {
67
- let e = "empty";
68
- if (this.data.length > 0) {
69
- const t = this.rowKey(this.data[0], 0), a = this.rowKey(this.data[this.data.length - 1], this.data.length - 1), r = this.data.length > 2 ? this.rowKey(this.data[Math.floor(this.data.length / 2)], Math.floor(this.data.length / 2)) : "";
70
- e = `${this.data.length}-${t}-${r}-${a}`;
71
- }
72
- return `${e}|${this._sortColumn}|${this._sortDirection}|${this.pageIndex}|${this.pageSize}|${this.totalItems}`;
112
+ return `${this._dataRevision}|${this._sortColumn}|${this._sortDirection}|${this.pageIndex}|${this.pageSize}|${this.totalItems}`;
73
113
  }
74
114
  _sortData(e) {
75
115
  const t = this._sortColumn, a = this._sortDirection;
76
116
  return [...e].sort((r, s) => {
77
- const n = r[t], o = s[t];
78
- if (n == null && o == null) return 0;
79
- if (n == null) return a === "asc" ? 1 : -1;
80
- if (o == null) return a === "asc" ? -1 : 1;
81
- if (typeof n == "number" && typeof o == "number")
82
- return a === "asc" ? n - o : o - n;
83
- if (n instanceof Date && o instanceof Date)
84
- return a === "asc" ? n.getTime() - o.getTime() : o.getTime() - n.getTime();
85
- const p = String(n).toLowerCase(), h = String(o).toLowerCase();
86
- return p < h ? a === "asc" ? -1 : 1 : p > h ? a === "asc" ? 1 : -1 : 0;
117
+ const o = r[t], n = s[t];
118
+ if (o == null && n == null) return 0;
119
+ if (o == null) return a === "asc" ? 1 : -1;
120
+ if (n == null) return a === "asc" ? -1 : 1;
121
+ if (typeof o == "number" && typeof n == "number")
122
+ return a === "asc" ? o - n : n - o;
123
+ if (o instanceof Date && n instanceof Date)
124
+ return a === "asc" ? o.getTime() - n.getTime() : n.getTime() - o.getTime();
125
+ const i = String(o).toLowerCase(), c = String(n).toLowerCase();
126
+ return i < c ? a === "asc" ? -1 : 1 : i > c ? a === "asc" ? 1 : -1 : 0;
87
127
  });
88
128
  }
89
129
  _getRowKey(e, t) {
90
130
  return this.rowKey(e, t);
91
131
  }
92
- /**
93
- * Finds the actual index of a row in the full data array.
94
- * This is critical for stable row keys when pagination is active.
95
- */
96
- _getActualDataIndex(e) {
97
- return this.data.indexOf(e);
98
- }
99
132
  _isColumnSortable(e) {
100
133
  return e.sortable !== void 0 ? e.sortable : this.sortable;
101
134
  }
@@ -157,19 +190,19 @@ let i = class extends _ {
157
190
  }));
158
191
  }
159
192
  _handleCellChange(e, t, a, r) {
160
- const s = r.target, n = e[a.id];
161
- let o = s.value;
193
+ const s = r.target, o = e[a.id];
194
+ let n = s.value;
162
195
  if (a.type === "number" || a.type === "currency") {
163
- const p = parseFloat(s.value);
164
- o = isNaN(p) ? null : p;
196
+ const i = parseFloat(s.value);
197
+ n = isNaN(i) ? null : i;
165
198
  }
166
199
  this.dispatchEvent(new CustomEvent("pd-table-cell-change", {
167
200
  detail: {
168
201
  row: e,
169
202
  rowIndex: t,
170
203
  columnId: a.id,
171
- value: o,
172
- previousValue: n
204
+ value: n,
205
+ previousValue: o
173
206
  },
174
207
  bubbles: !0,
175
208
  composed: !0
@@ -177,6 +210,11 @@ let i = class extends _ {
177
210
  }
178
211
  // ---------------------------------------------------------------------------
179
212
  // Event Handlers - Drag and Drop
213
+ //
214
+ // All drag handlers work with DISPLAY indices (0-based position in the
215
+ // visible rows after sorting/pagination). When emitting the reorder event
216
+ // we map display indices back to this.data indices so the consumer can
217
+ // splice the original array correctly.
180
218
  // ---------------------------------------------------------------------------
181
219
  _onDragStart(e, t) {
182
220
  if (!this.draggableRows || !this._isDragHandleGrabbed) {
@@ -184,27 +222,19 @@ let i = class extends _ {
184
222
  return;
185
223
  }
186
224
  this._draggedRowIndex = t, e.dataTransfer && (e.dataTransfer.effectAllowed = "move", e.dataTransfer.setData("text/plain", String(t))), requestAnimationFrame(() => {
187
- e.target.classList.add("dragging");
225
+ (e.target.closest?.("tr") ?? e.target).classList.add("dragging");
188
226
  });
189
227
  }
190
228
  _onDragOver(e, t) {
191
229
  !this.draggableRows || this._draggedRowIndex === null || (e.preventDefault(), e.dataTransfer && (e.dataTransfer.dropEffect = "move"), this._dragOverRowIndex !== t && (this._dragOverRowIndex = t));
192
230
  }
193
231
  _onDragEnd(e) {
194
- this._resetDragState(), e.target.classList.remove("dragging");
232
+ this._resetDragState(), (e.target.closest?.("tr") ?? e.target).classList.remove("dragging");
195
233
  }
196
234
  _onDrop(e, t) {
197
235
  if (e.preventDefault(), !this.draggableRows || this._draggedRowIndex === null) return;
198
236
  const a = this._draggedRowIndex;
199
- a !== t && (this._sortColumn = null, this._sortDirection = "asc", this.dispatchEvent(new CustomEvent("pd-table-row-reorder", {
200
- detail: {
201
- fromIndex: a,
202
- toIndex: t,
203
- item: this.data[a]
204
- },
205
- bubbles: !0,
206
- composed: !0
207
- }))), this._resetDragState();
237
+ a !== t && this._emitReorder(a, t), this._resetDragState();
208
238
  }
209
239
  _resetDragState() {
210
240
  this._draggedRowIndex = null, this._dragOverRowIndex = null, this._isDragHandleGrabbed = !1;
@@ -216,14 +246,31 @@ let i = class extends _ {
216
246
  this._isDragHandleGrabbed = !1;
217
247
  }
218
248
  _handleDragHandleKeyDown(e, t) {
219
- e.key === "ArrowUp" && t > 0 ? (e.preventDefault(), this._emitReorder(t, t - 1)) : e.key === "ArrowDown" && t < this.data.length - 1 && (e.preventDefault(), this._emitReorder(t, t + 1));
249
+ const a = this._displayData;
250
+ e.key === "ArrowUp" && t > 0 ? (e.preventDefault(), this._emitReorder(t, t - 1)) : e.key === "ArrowDown" && t < a.length - 1 && (e.preventDefault(), this._emitReorder(t, t + 1));
220
251
  }
252
+ /**
253
+ * Maps display indices to this.data indices, performs the reorder
254
+ * internally, and emits the event with the complete reordered array.
255
+ *
256
+ * When sorting is active the user sees a sorted view; dragging within it
257
+ * means "I accept this sorted order AND want to adjust it." We therefore
258
+ * **materialize** the sort into the data array before applying the drag,
259
+ * so the result matches what the user visually intended.
260
+ */
221
261
  _emitReorder(e, t) {
222
- this._sortColumn = null, this._sortDirection = "asc", this.dispatchEvent(new CustomEvent("pd-table-row-reorder", {
262
+ const a = this._displayData, r = a[e], s = a[t];
263
+ if (!r || !s) return;
264
+ this._captureRowPositions(), this._flipPending = !0, this._sortColumn && (this.data = this._sortData([...this.data])), this._sortColumn = null, this._sortDirection = "asc";
265
+ const o = this.data.indexOf(r), n = this.data.indexOf(s);
266
+ if (o === -1 || n === -1) return;
267
+ const i = [...this.data], [c] = i.splice(o, 1);
268
+ i.splice(n, 0, c), this.data = i, this.dispatchEvent(new CustomEvent("pd-table-row-reorder", {
223
269
  detail: {
224
- fromIndex: e,
225
- toIndex: t,
226
- item: this.data[e]
270
+ fromIndex: o,
271
+ toIndex: n,
272
+ item: r,
273
+ data: i
227
274
  },
228
275
  bubbles: !0,
229
276
  composed: !0
@@ -300,16 +347,16 @@ let i = class extends _ {
300
347
  // ---------------------------------------------------------------------------
301
348
  _renderHeader() {
302
349
  const e = this.data.length > 0 && this._selectedRowKeys.size === this.data.length, t = this._selectedRowKeys.size > 0 && this._selectedRowKeys.size < this.data.length;
303
- return d`
350
+ return h`
304
351
  <thead>
305
352
  <tr role="row">
306
- ${this.draggableRows ? d`
353
+ ${this.draggableRows ? h`
307
354
  <th class="drag-handle-header" role="columnheader" aria-label="Reorder">
308
355
  <span class="visually-hidden">Reorder</span>
309
356
  </th>
310
- ` : g}
357
+ ` : p}
311
358
 
312
- ${this.selectable ? d`
359
+ ${this.selectable ? h`
313
360
  <th class="checkbox-cell" role="columnheader">
314
361
  <pd-checkbox
315
362
  aria-label="Select all rows"
@@ -318,7 +365,7 @@ let i = class extends _ {
318
365
  @change=${this._handleSelectAll}
319
366
  ></pd-checkbox>
320
367
  </th>
321
- ` : g}
368
+ ` : p}
322
369
 
323
370
  ${this.columns.map((a, r) => this._renderHeaderCell(a, r))}
324
371
  </tr>
@@ -326,8 +373,8 @@ let i = class extends _ {
326
373
  `;
327
374
  }
328
375
  _renderHeaderCell(e, t) {
329
- const a = this._isColumnSortable(e), r = this._getColumnAlignment(e), s = this._sortColumn === e.id, n = this._draggedColumnIndex === t, o = this._dragOverColumnIndex === t && !n, p = s ? this._sortDirection === "asc" ? "ascending" : "descending" : "none";
330
- return d`
376
+ const a = this._isColumnSortable(e), r = this._getColumnAlignment(e), s = this._sortColumn === e.id, o = this._draggedColumnIndex === t, n = this._dragOverColumnIndex === t && !o, i = s ? this._sortDirection === "asc" ? "ascending" : "descending" : "none";
377
+ return h`
331
378
  <th
332
379
  role="columnheader"
333
380
  class=${m({
@@ -335,36 +382,36 @@ let i = class extends _ {
335
382
  sorted: s,
336
383
  [`align-${r}`]: !0,
337
384
  "column-draggable": this.draggableColumns,
338
- "column-dragging": n,
339
- "column-drag-over": o
385
+ "column-dragging": o,
386
+ "column-drag-over": n
340
387
  })}
341
388
  style=${e.width ? `width: ${e.width};` : ""}${e.minWidth ? ` min-width: ${e.minWidth};` : ""}
342
- aria-sort=${a ? p : g}
343
- tabindex=${a || this.draggableColumns ? "0" : g}
389
+ aria-sort=${a ? i : p}
390
+ tabindex=${a || this.draggableColumns ? "0" : p}
344
391
  draggable=${this.draggableColumns ? "true" : "false"}
345
392
  @click=${() => this._handleSort(e)}
346
- @keydown=${(h) => {
347
- this._handleHeaderKeyDown(h, e), this._handleColumnHeaderKeyDown(h, t);
393
+ @keydown=${(c) => {
394
+ this._handleHeaderKeyDown(c, e), this._handleColumnHeaderKeyDown(c, t);
348
395
  }}
349
- @dragstart=${(h) => this._onColumnDragStart(h, t)}
350
- @dragover=${(h) => this._onColumnDragOver(h, t)}
351
- @drop=${(h) => this._onColumnDrop(h, t)}
352
- @dragend=${(h) => this._onColumnDragEnd(h)}
396
+ @dragstart=${(c) => this._onColumnDragStart(c, t)}
397
+ @dragover=${(c) => this._onColumnDragOver(c, t)}
398
+ @drop=${(c) => this._onColumnDrop(c, t)}
399
+ @dragend=${(c) => this._onColumnDragEnd(c)}
353
400
  >
354
401
  <div class=${m({
355
402
  "header-content": !0,
356
403
  [`align-${r}`]: !0
357
404
  })}>
358
- ${this.draggableColumns ? d`
405
+ ${this.draggableColumns ? h`
359
406
  <pd-icon
360
407
  class="column-drag-handle"
361
408
  name="drag_indicator"
362
409
  size="small"
363
410
  aria-hidden="true"
364
411
  ></pd-icon>
365
- ` : g}
412
+ ` : p}
366
413
  <span class="header-text">${e.header}</span>
367
- ${a ? d`
414
+ ${a ? h`
368
415
  <pd-icon
369
416
  class=${m({
370
417
  "sort-icon": !0,
@@ -375,7 +422,7 @@ let i = class extends _ {
375
422
  size="small"
376
423
  aria-hidden="true"
377
424
  ></pd-icon>
378
- ` : g}
425
+ ` : p}
379
426
  </div>
380
427
  </th>
381
428
  `;
@@ -387,8 +434,8 @@ let i = class extends _ {
387
434
  if (a.cellTemplate) {
388
435
  const s = a.cellTemplate(e, t);
389
436
  if (this._isReactElement(s)) {
390
- const n = `${this.rowKey(e, t)}-${a.id}`;
391
- return this._renderReactCellContent(s, n);
437
+ const o = `${this.rowKey(e, t)}-${a.id}`;
438
+ return this._renderReactCellContent(s, o);
392
439
  }
393
440
  return s;
394
441
  }
@@ -410,13 +457,13 @@ let i = class extends _ {
410
457
  }
411
458
  _renderEditableCell(e, t, a, r) {
412
459
  const s = a.type === "number" || a.type === "currency" ? "number" : "text";
413
- return d`
460
+ return h`
414
461
  <pd-text-field
415
462
  type=${s}
416
463
  .value=${r != null ? String(r) : ""}
417
464
  aria-label="${a.header}"
418
- @change=${(n) => this._handleCellChange(e, t, a, n)}
419
- @click=${(n) => n.stopPropagation()}
465
+ @change=${(o) => this._handleCellChange(e, t, a, o)}
466
+ @click=${(o) => o.stopPropagation()}
420
467
  style="width: 100%;"
421
468
  ></pd-text-field>
422
469
  `;
@@ -445,7 +492,7 @@ let i = class extends _ {
445
492
  }
446
493
  _renderBoolean(e) {
447
494
  const t = !!e;
448
- return d`
495
+ return h`
449
496
  <pd-icon
450
497
  name=${t ? "check" : "close"}
451
498
  size="small"
@@ -458,7 +505,7 @@ let i = class extends _ {
458
505
  return typeof e == "object" && e !== null && "$$typeof" in e;
459
506
  }
460
507
  _renderReactCellContent(e, t) {
461
- return d`<span style="display:contents" ${v((a) => {
508
+ return h`<span style="display:contents" ${C((a) => {
462
509
  if (!a) {
463
510
  this._reactRoots.get(t)?.unmount(), this._reactRoots.delete(t);
464
511
  return;
@@ -472,10 +519,10 @@ let i = class extends _ {
472
519
  if (this._reactRoots.has(t))
473
520
  this._reactRoots.get(t).render(e);
474
521
  else {
475
- const n = s(a);
476
- n.render(e), this._reactRoots.set(t, {
477
- render: (o) => n.render(o),
478
- unmount: () => n.unmount()
522
+ const o = s(a);
523
+ o.render(e), this._reactRoots.set(t, {
524
+ render: (n) => o.render(n),
525
+ unmount: () => o.unmount()
479
526
  });
480
527
  }
481
528
  });
@@ -484,26 +531,32 @@ let i = class extends _ {
484
531
  // ---------------------------------------------------------------------------
485
532
  // Rendering - Rows
486
533
  // ---------------------------------------------------------------------------
487
- _renderRow(e, t) {
488
- const a = this._getRowKey(e, t), r = this._selectedRowKeys.has(a), s = this._draggedRowIndex === t, n = this._dragOverRowIndex === t && !s;
489
- return d`
534
+ /**
535
+ * Renders a single table row.
536
+ * @param row The data item
537
+ * @param displayIndex 0-based position in the visible (sorted/paginated) list — used for drag-and-drop
538
+ * @param dataIndex Position in the original this.data array — used for row keys, selection, and events
539
+ */
540
+ _renderRow(e, t, a) {
541
+ const r = this._getRowKey(e, a), s = this._selectedRowKeys.has(r), o = this._draggedRowIndex === t, n = this._dragOverRowIndex === t && !o;
542
+ return h`
490
543
  <tr
491
544
  role="row"
492
545
  class=${m({
493
- selected: r,
546
+ selected: s,
494
547
  draggable: this.draggableRows,
495
- dragging: s,
548
+ dragging: o,
496
549
  "drag-over": n
497
550
  })}
498
- aria-selected=${this.selectable ? String(r) : g}
551
+ aria-selected=${this.selectable ? String(s) : p}
499
552
  draggable=${this.draggableRows ? "true" : "false"}
500
- @dragstart=${(o) => this._onDragStart(o, t)}
501
- @dragover=${(o) => this._onDragOver(o, t)}
502
- @drop=${(o) => this._onDrop(o, t)}
503
- @dragend=${(o) => this._onDragEnd(o)}
504
- @click=${() => this._handleRowClick(e, t)}
553
+ @dragstart=${(i) => this._onDragStart(i, t)}
554
+ @dragover=${(i) => this._onDragOver(i, t)}
555
+ @drop=${(i) => this._onDrop(i, t)}
556
+ @dragend=${(i) => this._onDragEnd(i)}
557
+ @click=${() => this._handleRowClick(e, a)}
505
558
  >
506
- ${this.draggableRows ? d`
559
+ ${this.draggableRows ? h`
507
560
  <td class="drag-handle-cell" role="cell">
508
561
  <pd-icon
509
562
  name="drag_indicator"
@@ -514,34 +567,34 @@ let i = class extends _ {
514
567
  aria-label="Drag to reorder row. Use arrow keys to move up or down."
515
568
  @mousedown=${this._handleDragHandleMouseDown}
516
569
  @mouseup=${this._handleDragHandleMouseUp}
517
- @keydown=${(o) => this._handleDragHandleKeyDown(o, t)}
570
+ @keydown=${(i) => this._handleDragHandleKeyDown(i, t)}
518
571
  ></pd-icon>
519
572
  </td>
520
- ` : g}
573
+ ` : p}
521
574
 
522
- ${this.selectable ? d`
575
+ ${this.selectable ? h`
523
576
  <td class="checkbox-cell" role="cell">
524
577
  <pd-checkbox
525
578
  aria-label="Select row"
526
- ?checked=${r}
527
- @change=${(o) => {
528
- const p = o.target;
529
- this._handleSelectRow(e, t, p.checked);
579
+ ?checked=${s}
580
+ @change=${(i) => {
581
+ const c = i.target;
582
+ this._handleSelectRow(e, a, c.checked);
530
583
  }}
531
- @click=${(o) => o.stopPropagation()}
584
+ @click=${(i) => i.stopPropagation()}
532
585
  ></pd-checkbox>
533
586
  </td>
534
- ` : g}
587
+ ` : p}
535
588
 
536
- ${this.columns.map((o) => d`
589
+ ${this.columns.map((i) => h`
537
590
  <td
538
591
  role="cell"
539
592
  class=${m({
540
- [`align-${this._getColumnAlignment(o)}`]: !0,
541
- editable: !!o.editable
593
+ [`align-${this._getColumnAlignment(i)}`]: !0,
594
+ editable: !!i.editable
542
595
  })}
543
596
  >
544
- ${this._renderCell(e, t, o)}
597
+ ${this._renderCell(e, a, i)}
545
598
  </td>
546
599
  `)}
547
600
  </tr>
@@ -551,7 +604,7 @@ let i = class extends _ {
551
604
  // Rendering - States
552
605
  // ---------------------------------------------------------------------------
553
606
  _renderEmptyState() {
554
- return d`
607
+ return h`
555
608
  <tr class="state-row">
556
609
  <td colspan=${this._getColspan()} class="no-data">
557
610
  <slot name="no-data">
@@ -565,7 +618,7 @@ let i = class extends _ {
565
618
  `;
566
619
  }
567
620
  _renderLoadingState() {
568
- return d`
621
+ return h`
569
622
  <tr class="state-row">
570
623
  <td colspan=${this._getColspan()} class="loading-cell">
571
624
  <slot name="loading">
@@ -581,9 +634,9 @@ let i = class extends _ {
581
634
  // Rendering - Pagination
582
635
  // ---------------------------------------------------------------------------
583
636
  _renderPagination() {
584
- if (!this.pagination) return g;
637
+ if (!this.pagination) return p;
585
638
  const e = this._totalCount, t = e === 0 ? 0 : this.pageIndex * this.pageSize + 1, a = Math.min((this.pageIndex + 1) * this.pageSize, e), r = this.pageIndex === 0, s = this.pageIndex >= this._totalPages - 1 || e === 0;
586
- return d`
639
+ return h`
587
640
  <nav class="pagination">
588
641
  <div class="items-per-page">
589
642
  <label id="page-size-label-${this._uniqueId}">Items per page:</label>
@@ -592,9 +645,9 @@ let i = class extends _ {
592
645
  variant="filled"
593
646
  aria-labelledby="page-size-label-${this._uniqueId}"
594
647
  .value=${this.pageSize.toString()}
595
- .options=${this.pageSizeOptions.map((n) => ({
596
- value: String(n),
597
- label: String(n)
648
+ .options=${this.pageSizeOptions.map((o) => ({
649
+ value: String(o),
650
+ label: String(o)
598
651
  }))}
599
652
  @change=${this._handlePageSizeChange}
600
653
  ></pd-select>
@@ -641,7 +694,7 @@ let i = class extends _ {
641
694
  // ---------------------------------------------------------------------------
642
695
  render() {
643
696
  const e = this._displayData, t = e.length === 0 && !this.loading;
644
- return d`
697
+ return h`
645
698
  <div class="table-wrapper">
646
699
  <div class="table-container">
647
700
  <table
@@ -651,17 +704,17 @@ let i = class extends _ {
651
704
  >
652
705
  ${this._renderHeader()}
653
706
  <tbody>
654
- ${this.loading ? this._renderLoadingState() : g}
655
- ${t ? this._renderEmptyState() : g}
656
- ${this.loading ? g : f(
707
+ ${this.loading ? this._renderLoadingState() : p}
708
+ ${t ? this._renderEmptyState() : p}
709
+ ${this.loading ? p : x(
657
710
  e,
658
711
  (a) => {
659
- const r = this._getActualDataIndex(a);
712
+ const r = this._displayToDataIndexMap.get(a) ?? this.data.indexOf(a);
660
713
  return this._getRowKey(a, r);
661
714
  },
662
- (a) => {
663
- const r = this._getActualDataIndex(a);
664
- return this._renderRow(a, r);
715
+ (a, r) => {
716
+ const s = this._displayToDataIndexMap.get(a) ?? this.data.indexOf(a);
717
+ return this._renderRow(a, r, s);
665
718
  }
666
719
  )}
667
720
  </tbody>
@@ -714,7 +767,7 @@ let i = class extends _ {
714
767
  this._displayDataCacheKey = "";
715
768
  }
716
769
  };
717
- i.styles = b`
770
+ l.styles = y`
718
771
  :host {
719
772
  display: block;
720
773
 
@@ -874,7 +927,8 @@ i.styles = b`
874
927
  }
875
928
 
876
929
  tr.dragging {
877
- opacity: 0.5;
930
+ opacity: 0.4;
931
+ z-index: 1;
878
932
  }
879
933
 
880
934
  tr.dragging td {
@@ -885,6 +939,11 @@ i.styles = b`
885
939
  box-shadow: inset 0 2px 0 0 var(--md-sys-color-primary);
886
940
  }
887
941
 
942
+ /* Rows use will-change during FLIP animation for GPU acceleration */
943
+ tr[role="row"] {
944
+ will-change: auto;
945
+ }
946
+
888
947
  /* Column Drag States */
889
948
  th.column-draggable {
890
949
  cursor: grab;
@@ -1062,81 +1121,81 @@ i.styles = b`
1062
1121
  }
1063
1122
  }
1064
1123
  `;
1065
- l([
1066
- c({ type: Array })
1067
- ], i.prototype, "columns", 2);
1068
- l([
1069
- c({ type: Array })
1070
- ], i.prototype, "data", 2);
1071
- l([
1072
- c({ attribute: !1 })
1073
- ], i.prototype, "rowKey", 2);
1074
- l([
1075
- c({ type: Boolean })
1076
- ], i.prototype, "selectable", 2);
1077
- l([
1078
- c({ type: Boolean })
1079
- ], i.prototype, "sortable", 2);
1080
- l([
1081
- c({ type: Boolean })
1082
- ], i.prototype, "pagination", 2);
1083
- l([
1084
- c({ type: Number })
1085
- ], i.prototype, "pageSize", 2);
1086
- l([
1087
- c({ type: Number })
1088
- ], i.prototype, "pageIndex", 2);
1089
- l([
1090
- c({ type: Number })
1091
- ], i.prototype, "totalItems", 2);
1092
- l([
1093
- c({ type: Boolean, attribute: "draggable-rows" })
1094
- ], i.prototype, "draggableRows", 2);
1095
- l([
1096
- c({ type: Boolean, attribute: "draggable-columns" })
1097
- ], i.prototype, "draggableColumns", 2);
1098
- l([
1099
- c({ type: Boolean })
1100
- ], i.prototype, "loading", 2);
1101
- l([
1102
- c({ type: Boolean, attribute: "clear-selection-on-data-change" })
1103
- ], i.prototype, "clearSelectionOnDataChange", 2);
1104
- l([
1105
- c({ type: String, attribute: "currency-code" })
1106
- ], i.prototype, "currencyCode", 2);
1107
- l([
1108
- c({ type: String })
1109
- ], i.prototype, "locale", 2);
1110
- l([
1111
- c({ type: Array, attribute: "page-size-options" })
1112
- ], i.prototype, "pageSizeOptions", 2);
1113
- l([
1124
+ d([
1125
+ g({ type: Array })
1126
+ ], l.prototype, "columns", 2);
1127
+ d([
1128
+ g({ type: Array })
1129
+ ], l.prototype, "data", 2);
1130
+ d([
1131
+ g({ attribute: !1 })
1132
+ ], l.prototype, "rowKey", 2);
1133
+ d([
1134
+ g({ type: Boolean })
1135
+ ], l.prototype, "selectable", 2);
1136
+ d([
1137
+ g({ type: Boolean })
1138
+ ], l.prototype, "sortable", 2);
1139
+ d([
1140
+ g({ type: Boolean })
1141
+ ], l.prototype, "pagination", 2);
1142
+ d([
1143
+ g({ type: Number })
1144
+ ], l.prototype, "pageSize", 2);
1145
+ d([
1146
+ g({ type: Number })
1147
+ ], l.prototype, "pageIndex", 2);
1148
+ d([
1149
+ g({ type: Number })
1150
+ ], l.prototype, "totalItems", 2);
1151
+ d([
1152
+ g({ type: Boolean, attribute: "draggable-rows" })
1153
+ ], l.prototype, "draggableRows", 2);
1154
+ d([
1155
+ g({ type: Boolean, attribute: "draggable-columns" })
1156
+ ], l.prototype, "draggableColumns", 2);
1157
+ d([
1158
+ g({ type: Boolean })
1159
+ ], l.prototype, "loading", 2);
1160
+ d([
1161
+ g({ type: Boolean, attribute: "clear-selection-on-data-change" })
1162
+ ], l.prototype, "clearSelectionOnDataChange", 2);
1163
+ d([
1164
+ g({ type: String, attribute: "currency-code" })
1165
+ ], l.prototype, "currencyCode", 2);
1166
+ d([
1167
+ g({ type: String })
1168
+ ], l.prototype, "locale", 2);
1169
+ d([
1170
+ g({ type: Array, attribute: "page-size-options" })
1171
+ ], l.prototype, "pageSizeOptions", 2);
1172
+ d([
1114
1173
  u()
1115
- ], i.prototype, "_sortColumn", 2);
1116
- l([
1174
+ ], l.prototype, "_sortColumn", 2);
1175
+ d([
1117
1176
  u()
1118
- ], i.prototype, "_sortDirection", 2);
1119
- l([
1177
+ ], l.prototype, "_sortDirection", 2);
1178
+ d([
1120
1179
  u()
1121
- ], i.prototype, "_selectedRowKeys", 2);
1122
- l([
1180
+ ], l.prototype, "_selectedRowKeys", 2);
1181
+ d([
1123
1182
  u()
1124
- ], i.prototype, "_draggedRowIndex", 2);
1125
- l([
1183
+ ], l.prototype, "_draggedRowIndex", 2);
1184
+ d([
1126
1185
  u()
1127
- ], i.prototype, "_dragOverRowIndex", 2);
1128
- l([
1186
+ ], l.prototype, "_dragOverRowIndex", 2);
1187
+ d([
1129
1188
  u()
1130
- ], i.prototype, "_isDragHandleGrabbed", 2);
1131
- l([
1189
+ ], l.prototype, "_isDragHandleGrabbed", 2);
1190
+ d([
1132
1191
  u()
1133
- ], i.prototype, "_draggedColumnIndex", 2);
1134
- l([
1192
+ ], l.prototype, "_draggedColumnIndex", 2);
1193
+ d([
1135
1194
  u()
1136
- ], i.prototype, "_dragOverColumnIndex", 2);
1137
- i = l([
1138
- y("pd-table")
1139
- ], i);
1195
+ ], l.prototype, "_dragOverColumnIndex", 2);
1196
+ l = d([
1197
+ v("pd-table")
1198
+ ], l);
1140
1199
  export {
1141
- i as PdTable
1200
+ l as PdTable
1142
1201
  };