@prioticket/design-system-web 1.6.3 → 1.7.0-beta.2
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.
- package/COMPONENT-DOCUMENTATION.md +1 -1
- package/component-documentation.json +2 -2
- package/custom-elements.json +123 -30
- package/dist/client-C4NwtAXt.js +20655 -0
- package/dist/client-CjTRT4wy.cjs +212 -0
- package/dist/components/pd-table.cjs.js +62 -56
- package/dist/components/pd-table.es.js +302 -206
- package/dist/types/components/pd-table.d.ts +55 -7
- package/package.json +1 -1
|
@@ -1,24 +1,25 @@
|
|
|
1
|
-
import { css as
|
|
2
|
-
import { property as
|
|
3
|
-
import { repeat as
|
|
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 C } from "lit/directives/ref.js";
|
|
5
6
|
import "./pd-icon.es.js";
|
|
6
7
|
import "./pd-checkbox.es.js";
|
|
7
8
|
import "./pd-text-field.es.js";
|
|
8
9
|
import "./pd-icon-button.es.js";
|
|
9
10
|
import "./pd-select.es.js";
|
|
10
11
|
import "./pd-menu-item.es.js";
|
|
11
|
-
var
|
|
12
|
-
for (var
|
|
13
|
-
(
|
|
14
|
-
return r &&
|
|
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;
|
|
15
16
|
};
|
|
16
|
-
let
|
|
17
|
+
let l = class extends w {
|
|
17
18
|
constructor() {
|
|
18
19
|
super(...arguments), this.columns = [], this.data = [], this.rowKey = (e, t) => {
|
|
19
20
|
const a = e.id;
|
|
20
21
|
return a != null ? String(a) : `__idx_${t}`;
|
|
21
|
-
}, 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._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);
|
|
22
23
|
}
|
|
23
24
|
// ---------------------------------------------------------------------------
|
|
24
25
|
// Getters
|
|
@@ -48,50 +49,86 @@ let i = class extends y {
|
|
|
48
49
|
const a = this.pageIndex * this.pageSize, r = a + this.pageSize;
|
|
49
50
|
t = t.slice(a, r);
|
|
50
51
|
}
|
|
51
|
-
|
|
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;
|
|
52
56
|
}
|
|
53
57
|
// ---------------------------------------------------------------------------
|
|
54
58
|
// Lifecycle
|
|
55
59
|
// ---------------------------------------------------------------------------
|
|
60
|
+
disconnectedCallback() {
|
|
61
|
+
super.disconnectedCallback(), this._reactRoots.forEach(({ unmount: e }) => e()), this._reactRoots.clear();
|
|
62
|
+
}
|
|
56
63
|
willUpdate(e) {
|
|
57
|
-
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());
|
|
58
68
|
}
|
|
59
69
|
// ---------------------------------------------------------------------------
|
|
60
|
-
//
|
|
70
|
+
// FLIP Animation
|
|
61
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
|
+
}
|
|
62
111
|
_computeCacheKey() {
|
|
63
|
-
|
|
64
|
-
if (this.data.length > 0) {
|
|
65
|
-
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)) : "";
|
|
66
|
-
e = `${this.data.length}-${t}-${r}-${a}`;
|
|
67
|
-
}
|
|
68
|
-
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}`;
|
|
69
113
|
}
|
|
70
114
|
_sortData(e) {
|
|
71
115
|
const t = this._sortColumn, a = this._sortDirection;
|
|
72
|
-
return [...e].sort((r,
|
|
73
|
-
const
|
|
74
|
-
if (
|
|
75
|
-
if (
|
|
76
|
-
if (
|
|
77
|
-
if (typeof
|
|
78
|
-
return a === "asc" ?
|
|
79
|
-
if (
|
|
80
|
-
return a === "asc" ?
|
|
81
|
-
const
|
|
82
|
-
return
|
|
116
|
+
return [...e].sort((r, s) => {
|
|
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;
|
|
83
127
|
});
|
|
84
128
|
}
|
|
85
129
|
_getRowKey(e, t) {
|
|
86
130
|
return this.rowKey(e, t);
|
|
87
131
|
}
|
|
88
|
-
/**
|
|
89
|
-
* Finds the actual index of a row in the full data array.
|
|
90
|
-
* This is critical for stable row keys when pagination is active.
|
|
91
|
-
*/
|
|
92
|
-
_getActualDataIndex(e) {
|
|
93
|
-
return this.data.indexOf(e);
|
|
94
|
-
}
|
|
95
132
|
_isColumnSortable(e) {
|
|
96
133
|
return e.sortable !== void 0 ? e.sortable : this.sortable;
|
|
97
134
|
}
|
|
@@ -121,13 +158,13 @@ let i = class extends y {
|
|
|
121
158
|
// ---------------------------------------------------------------------------
|
|
122
159
|
_handleSelectAll(e) {
|
|
123
160
|
const t = e.target, a = /* @__PURE__ */ new Set();
|
|
124
|
-
t.checked && this.data.forEach((r,
|
|
125
|
-
a.add(this._getRowKey(r,
|
|
161
|
+
t.checked && this.data.forEach((r, s) => {
|
|
162
|
+
a.add(this._getRowKey(r, s));
|
|
126
163
|
}), this._selectedRowKeys = a, this._emitSelectionChange();
|
|
127
164
|
}
|
|
128
165
|
_handleSelectRow(e, t, a) {
|
|
129
|
-
const r = this._getRowKey(e, t),
|
|
130
|
-
a ?
|
|
166
|
+
const r = this._getRowKey(e, t), s = new Set(this._selectedRowKeys);
|
|
167
|
+
a ? s.add(r) : s.delete(r), this._selectedRowKeys = s, this._emitSelectionChange();
|
|
131
168
|
}
|
|
132
169
|
_emitSelectionChange() {
|
|
133
170
|
const e = this.data.filter(
|
|
@@ -153,19 +190,19 @@ let i = class extends y {
|
|
|
153
190
|
}));
|
|
154
191
|
}
|
|
155
192
|
_handleCellChange(e, t, a, r) {
|
|
156
|
-
const
|
|
157
|
-
let
|
|
193
|
+
const s = r.target, o = e[a.id];
|
|
194
|
+
let n = s.value;
|
|
158
195
|
if (a.type === "number" || a.type === "currency") {
|
|
159
|
-
const
|
|
160
|
-
|
|
196
|
+
const i = parseFloat(s.value);
|
|
197
|
+
n = isNaN(i) ? null : i;
|
|
161
198
|
}
|
|
162
199
|
this.dispatchEvent(new CustomEvent("pd-table-cell-change", {
|
|
163
200
|
detail: {
|
|
164
201
|
row: e,
|
|
165
202
|
rowIndex: t,
|
|
166
203
|
columnId: a.id,
|
|
167
|
-
value:
|
|
168
|
-
previousValue:
|
|
204
|
+
value: n,
|
|
205
|
+
previousValue: o
|
|
169
206
|
},
|
|
170
207
|
bubbles: !0,
|
|
171
208
|
composed: !0
|
|
@@ -173,6 +210,11 @@ let i = class extends y {
|
|
|
173
210
|
}
|
|
174
211
|
// ---------------------------------------------------------------------------
|
|
175
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.
|
|
176
218
|
// ---------------------------------------------------------------------------
|
|
177
219
|
_onDragStart(e, t) {
|
|
178
220
|
if (!this.draggableRows || !this._isDragHandleGrabbed) {
|
|
@@ -180,27 +222,19 @@ let i = class extends y {
|
|
|
180
222
|
return;
|
|
181
223
|
}
|
|
182
224
|
this._draggedRowIndex = t, e.dataTransfer && (e.dataTransfer.effectAllowed = "move", e.dataTransfer.setData("text/plain", String(t))), requestAnimationFrame(() => {
|
|
183
|
-
e.target.classList.add("dragging");
|
|
225
|
+
(e.target.closest?.("tr") ?? e.target).classList.add("dragging");
|
|
184
226
|
});
|
|
185
227
|
}
|
|
186
228
|
_onDragOver(e, t) {
|
|
187
229
|
!this.draggableRows || this._draggedRowIndex === null || (e.preventDefault(), e.dataTransfer && (e.dataTransfer.dropEffect = "move"), this._dragOverRowIndex !== t && (this._dragOverRowIndex = t));
|
|
188
230
|
}
|
|
189
231
|
_onDragEnd(e) {
|
|
190
|
-
this._resetDragState(), e.target.classList.remove("dragging");
|
|
232
|
+
this._resetDragState(), (e.target.closest?.("tr") ?? e.target).classList.remove("dragging");
|
|
191
233
|
}
|
|
192
234
|
_onDrop(e, t) {
|
|
193
235
|
if (e.preventDefault(), !this.draggableRows || this._draggedRowIndex === null) return;
|
|
194
236
|
const a = this._draggedRowIndex;
|
|
195
|
-
a !== t &&
|
|
196
|
-
detail: {
|
|
197
|
-
fromIndex: a,
|
|
198
|
-
toIndex: t,
|
|
199
|
-
item: this.data[a]
|
|
200
|
-
},
|
|
201
|
-
bubbles: !0,
|
|
202
|
-
composed: !0
|
|
203
|
-
}))), this._resetDragState();
|
|
237
|
+
a !== t && this._emitReorder(a, t), this._resetDragState();
|
|
204
238
|
}
|
|
205
239
|
_resetDragState() {
|
|
206
240
|
this._draggedRowIndex = null, this._dragOverRowIndex = null, this._isDragHandleGrabbed = !1;
|
|
@@ -212,14 +246,31 @@ let i = class extends y {
|
|
|
212
246
|
this._isDragHandleGrabbed = !1;
|
|
213
247
|
}
|
|
214
248
|
_handleDragHandleKeyDown(e, t) {
|
|
215
|
-
|
|
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));
|
|
216
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
|
+
*/
|
|
217
261
|
_emitReorder(e, t) {
|
|
218
|
-
|
|
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", {
|
|
219
269
|
detail: {
|
|
220
|
-
fromIndex:
|
|
221
|
-
toIndex:
|
|
222
|
-
item:
|
|
270
|
+
fromIndex: o,
|
|
271
|
+
toIndex: n,
|
|
272
|
+
item: r,
|
|
273
|
+
data: i
|
|
223
274
|
},
|
|
224
275
|
bubbles: !0,
|
|
225
276
|
composed: !0
|
|
@@ -296,16 +347,16 @@ let i = class extends y {
|
|
|
296
347
|
// ---------------------------------------------------------------------------
|
|
297
348
|
_renderHeader() {
|
|
298
349
|
const e = this.data.length > 0 && this._selectedRowKeys.size === this.data.length, t = this._selectedRowKeys.size > 0 && this._selectedRowKeys.size < this.data.length;
|
|
299
|
-
return
|
|
350
|
+
return h`
|
|
300
351
|
<thead>
|
|
301
352
|
<tr role="row">
|
|
302
|
-
${this.draggableRows ?
|
|
353
|
+
${this.draggableRows ? h`
|
|
303
354
|
<th class="drag-handle-header" role="columnheader" aria-label="Reorder">
|
|
304
355
|
<span class="visually-hidden">Reorder</span>
|
|
305
356
|
</th>
|
|
306
|
-
` :
|
|
357
|
+
` : p}
|
|
307
358
|
|
|
308
|
-
${this.selectable ?
|
|
359
|
+
${this.selectable ? h`
|
|
309
360
|
<th class="checkbox-cell" role="columnheader">
|
|
310
361
|
<pd-checkbox
|
|
311
362
|
aria-label="Select all rows"
|
|
@@ -314,7 +365,7 @@ let i = class extends y {
|
|
|
314
365
|
@change=${this._handleSelectAll}
|
|
315
366
|
></pd-checkbox>
|
|
316
367
|
</th>
|
|
317
|
-
` :
|
|
368
|
+
` : p}
|
|
318
369
|
|
|
319
370
|
${this.columns.map((a, r) => this._renderHeaderCell(a, r))}
|
|
320
371
|
</tr>
|
|
@@ -322,56 +373,56 @@ let i = class extends y {
|
|
|
322
373
|
`;
|
|
323
374
|
}
|
|
324
375
|
_renderHeaderCell(e, t) {
|
|
325
|
-
const a = this._isColumnSortable(e), r = this._getColumnAlignment(e),
|
|
326
|
-
return
|
|
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`
|
|
327
378
|
<th
|
|
328
379
|
role="columnheader"
|
|
329
380
|
class=${m({
|
|
330
381
|
sortable: a,
|
|
331
|
-
sorted:
|
|
382
|
+
sorted: s,
|
|
332
383
|
[`align-${r}`]: !0,
|
|
333
384
|
"column-draggable": this.draggableColumns,
|
|
334
|
-
"column-dragging":
|
|
335
|
-
"column-drag-over":
|
|
385
|
+
"column-dragging": o,
|
|
386
|
+
"column-drag-over": n
|
|
336
387
|
})}
|
|
337
388
|
style=${e.width ? `width: ${e.width};` : ""}${e.minWidth ? ` min-width: ${e.minWidth};` : ""}
|
|
338
|
-
aria-sort=${a ?
|
|
339
|
-
tabindex=${a || this.draggableColumns ? "0" :
|
|
389
|
+
aria-sort=${a ? i : p}
|
|
390
|
+
tabindex=${a || this.draggableColumns ? "0" : p}
|
|
340
391
|
draggable=${this.draggableColumns ? "true" : "false"}
|
|
341
392
|
@click=${() => this._handleSort(e)}
|
|
342
|
-
@keydown=${(
|
|
343
|
-
this._handleHeaderKeyDown(
|
|
393
|
+
@keydown=${(c) => {
|
|
394
|
+
this._handleHeaderKeyDown(c, e), this._handleColumnHeaderKeyDown(c, t);
|
|
344
395
|
}}
|
|
345
|
-
@dragstart=${(
|
|
346
|
-
@dragover=${(
|
|
347
|
-
@drop=${(
|
|
348
|
-
@dragend=${(
|
|
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)}
|
|
349
400
|
>
|
|
350
401
|
<div class=${m({
|
|
351
402
|
"header-content": !0,
|
|
352
403
|
[`align-${r}`]: !0
|
|
353
404
|
})}>
|
|
354
|
-
${this.draggableColumns ?
|
|
405
|
+
${this.draggableColumns ? h`
|
|
355
406
|
<pd-icon
|
|
356
407
|
class="column-drag-handle"
|
|
357
408
|
name="drag_indicator"
|
|
358
409
|
size="small"
|
|
359
410
|
aria-hidden="true"
|
|
360
411
|
></pd-icon>
|
|
361
|
-
` :
|
|
412
|
+
` : p}
|
|
362
413
|
<span class="header-text">${e.header}</span>
|
|
363
|
-
${a ?
|
|
414
|
+
${a ? h`
|
|
364
415
|
<pd-icon
|
|
365
416
|
class=${m({
|
|
366
417
|
"sort-icon": !0,
|
|
367
|
-
"sort-icon-visible":
|
|
368
|
-
"sort-icon-desc":
|
|
418
|
+
"sort-icon-visible": s,
|
|
419
|
+
"sort-icon-desc": s && this._sortDirection === "desc"
|
|
369
420
|
})}
|
|
370
421
|
name="arrow_upward"
|
|
371
422
|
size="small"
|
|
372
423
|
aria-hidden="true"
|
|
373
424
|
></pd-icon>
|
|
374
|
-
` :
|
|
425
|
+
` : p}
|
|
375
426
|
</div>
|
|
376
427
|
</th>
|
|
377
428
|
`;
|
|
@@ -380,8 +431,14 @@ let i = class extends y {
|
|
|
380
431
|
// Rendering - Cells
|
|
381
432
|
// ---------------------------------------------------------------------------
|
|
382
433
|
_renderCell(e, t, a) {
|
|
383
|
-
if (a.cellTemplate)
|
|
384
|
-
|
|
434
|
+
if (a.cellTemplate) {
|
|
435
|
+
const s = a.cellTemplate(e, t);
|
|
436
|
+
if (this._isReactElement(s)) {
|
|
437
|
+
const o = `${this.rowKey(e, t)}-${a.id}`;
|
|
438
|
+
return this._renderReactCellContent(s, o);
|
|
439
|
+
}
|
|
440
|
+
return s;
|
|
441
|
+
}
|
|
385
442
|
const r = e[a.id];
|
|
386
443
|
if (a.editable)
|
|
387
444
|
return this._renderEditableCell(e, t, a, r);
|
|
@@ -399,14 +456,14 @@ let i = class extends y {
|
|
|
399
456
|
}
|
|
400
457
|
}
|
|
401
458
|
_renderEditableCell(e, t, a, r) {
|
|
402
|
-
const
|
|
403
|
-
return
|
|
459
|
+
const s = a.type === "number" || a.type === "currency" ? "number" : "text";
|
|
460
|
+
return h`
|
|
404
461
|
<pd-text-field
|
|
405
|
-
type=${
|
|
462
|
+
type=${s}
|
|
406
463
|
.value=${r != null ? String(r) : ""}
|
|
407
464
|
aria-label="${a.header}"
|
|
408
|
-
@change=${(
|
|
409
|
-
@click=${(
|
|
465
|
+
@change=${(o) => this._handleCellChange(e, t, a, o)}
|
|
466
|
+
@click=${(o) => o.stopPropagation()}
|
|
410
467
|
style="width: 100%;"
|
|
411
468
|
></pd-text-field>
|
|
412
469
|
`;
|
|
@@ -435,7 +492,7 @@ let i = class extends y {
|
|
|
435
492
|
}
|
|
436
493
|
_renderBoolean(e) {
|
|
437
494
|
const t = !!e;
|
|
438
|
-
return
|
|
495
|
+
return h`
|
|
439
496
|
<pd-icon
|
|
440
497
|
name=${t ? "check" : "close"}
|
|
441
498
|
size="small"
|
|
@@ -444,29 +501,62 @@ let i = class extends y {
|
|
|
444
501
|
></pd-icon>
|
|
445
502
|
`;
|
|
446
503
|
}
|
|
504
|
+
_isReactElement(e) {
|
|
505
|
+
return typeof e == "object" && e !== null && "$$typeof" in e;
|
|
506
|
+
}
|
|
507
|
+
_renderReactCellContent(e, t) {
|
|
508
|
+
return h`<span style="display:contents" ${C((a) => {
|
|
509
|
+
if (!a) {
|
|
510
|
+
this._reactRoots.get(t)?.unmount(), this._reactRoots.delete(t);
|
|
511
|
+
return;
|
|
512
|
+
}
|
|
513
|
+
const r = this._reactRoots.get(t);
|
|
514
|
+
if (r) {
|
|
515
|
+
r.render(e);
|
|
516
|
+
return;
|
|
517
|
+
}
|
|
518
|
+
import("../client-C4NwtAXt.js").then((s) => s.c).then(({ createRoot: s }) => {
|
|
519
|
+
if (this._reactRoots.has(t))
|
|
520
|
+
this._reactRoots.get(t).render(e);
|
|
521
|
+
else {
|
|
522
|
+
const o = s(a);
|
|
523
|
+
o.render(e), this._reactRoots.set(t, {
|
|
524
|
+
render: (n) => o.render(n),
|
|
525
|
+
unmount: () => o.unmount()
|
|
526
|
+
});
|
|
527
|
+
}
|
|
528
|
+
});
|
|
529
|
+
})}></span>`;
|
|
530
|
+
}
|
|
447
531
|
// ---------------------------------------------------------------------------
|
|
448
532
|
// Rendering - Rows
|
|
449
533
|
// ---------------------------------------------------------------------------
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
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`
|
|
453
543
|
<tr
|
|
454
544
|
role="row"
|
|
455
545
|
class=${m({
|
|
456
|
-
selected:
|
|
546
|
+
selected: s,
|
|
457
547
|
draggable: this.draggableRows,
|
|
458
548
|
dragging: o,
|
|
459
549
|
"drag-over": n
|
|
460
550
|
})}
|
|
461
|
-
aria-selected=${this.selectable ? String(
|
|
551
|
+
aria-selected=${this.selectable ? String(s) : p}
|
|
462
552
|
draggable=${this.draggableRows ? "true" : "false"}
|
|
463
|
-
@dragstart=${(
|
|
464
|
-
@dragover=${(
|
|
465
|
-
@drop=${(
|
|
466
|
-
@dragend=${(
|
|
467
|
-
@click=${() => this._handleRowClick(e,
|
|
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)}
|
|
468
558
|
>
|
|
469
|
-
${this.draggableRows ?
|
|
559
|
+
${this.draggableRows ? h`
|
|
470
560
|
<td class="drag-handle-cell" role="cell">
|
|
471
561
|
<pd-icon
|
|
472
562
|
name="drag_indicator"
|
|
@@ -477,34 +567,34 @@ let i = class extends y {
|
|
|
477
567
|
aria-label="Drag to reorder row. Use arrow keys to move up or down."
|
|
478
568
|
@mousedown=${this._handleDragHandleMouseDown}
|
|
479
569
|
@mouseup=${this._handleDragHandleMouseUp}
|
|
480
|
-
@keydown=${(
|
|
570
|
+
@keydown=${(i) => this._handleDragHandleKeyDown(i, t)}
|
|
481
571
|
></pd-icon>
|
|
482
572
|
</td>
|
|
483
|
-
` :
|
|
573
|
+
` : p}
|
|
484
574
|
|
|
485
|
-
${this.selectable ?
|
|
575
|
+
${this.selectable ? h`
|
|
486
576
|
<td class="checkbox-cell" role="cell">
|
|
487
577
|
<pd-checkbox
|
|
488
578
|
aria-label="Select row"
|
|
489
|
-
?checked=${
|
|
490
|
-
@change=${(
|
|
491
|
-
const
|
|
492
|
-
this._handleSelectRow(e,
|
|
579
|
+
?checked=${s}
|
|
580
|
+
@change=${(i) => {
|
|
581
|
+
const c = i.target;
|
|
582
|
+
this._handleSelectRow(e, a, c.checked);
|
|
493
583
|
}}
|
|
494
|
-
@click=${(
|
|
584
|
+
@click=${(i) => i.stopPropagation()}
|
|
495
585
|
></pd-checkbox>
|
|
496
586
|
</td>
|
|
497
|
-
` :
|
|
587
|
+
` : p}
|
|
498
588
|
|
|
499
|
-
${this.columns.map((
|
|
589
|
+
${this.columns.map((i) => h`
|
|
500
590
|
<td
|
|
501
591
|
role="cell"
|
|
502
592
|
class=${m({
|
|
503
|
-
[`align-${this._getColumnAlignment(
|
|
504
|
-
editable: !!
|
|
593
|
+
[`align-${this._getColumnAlignment(i)}`]: !0,
|
|
594
|
+
editable: !!i.editable
|
|
505
595
|
})}
|
|
506
596
|
>
|
|
507
|
-
${this._renderCell(e,
|
|
597
|
+
${this._renderCell(e, a, i)}
|
|
508
598
|
</td>
|
|
509
599
|
`)}
|
|
510
600
|
</tr>
|
|
@@ -514,7 +604,7 @@ let i = class extends y {
|
|
|
514
604
|
// Rendering - States
|
|
515
605
|
// ---------------------------------------------------------------------------
|
|
516
606
|
_renderEmptyState() {
|
|
517
|
-
return
|
|
607
|
+
return h`
|
|
518
608
|
<tr class="state-row">
|
|
519
609
|
<td colspan=${this._getColspan()} class="no-data">
|
|
520
610
|
<slot name="no-data">
|
|
@@ -528,7 +618,7 @@ let i = class extends y {
|
|
|
528
618
|
`;
|
|
529
619
|
}
|
|
530
620
|
_renderLoadingState() {
|
|
531
|
-
return
|
|
621
|
+
return h`
|
|
532
622
|
<tr class="state-row">
|
|
533
623
|
<td colspan=${this._getColspan()} class="loading-cell">
|
|
534
624
|
<slot name="loading">
|
|
@@ -544,9 +634,9 @@ let i = class extends y {
|
|
|
544
634
|
// Rendering - Pagination
|
|
545
635
|
// ---------------------------------------------------------------------------
|
|
546
636
|
_renderPagination() {
|
|
547
|
-
if (!this.pagination) return
|
|
548
|
-
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,
|
|
549
|
-
return
|
|
637
|
+
if (!this.pagination) return p;
|
|
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;
|
|
639
|
+
return h`
|
|
550
640
|
<nav class="pagination">
|
|
551
641
|
<div class="items-per-page">
|
|
552
642
|
<label id="page-size-label-${this._uniqueId}">Items per page:</label>
|
|
@@ -555,9 +645,9 @@ let i = class extends y {
|
|
|
555
645
|
variant="filled"
|
|
556
646
|
aria-labelledby="page-size-label-${this._uniqueId}"
|
|
557
647
|
.value=${this.pageSize.toString()}
|
|
558
|
-
.options=${this.pageSizeOptions.map((
|
|
559
|
-
value: String(
|
|
560
|
-
label: String(
|
|
648
|
+
.options=${this.pageSizeOptions.map((o) => ({
|
|
649
|
+
value: String(o),
|
|
650
|
+
label: String(o)
|
|
561
651
|
}))}
|
|
562
652
|
@change=${this._handlePageSizeChange}
|
|
563
653
|
></pd-select>
|
|
@@ -585,13 +675,13 @@ let i = class extends y {
|
|
|
585
675
|
<pd-icon-button
|
|
586
676
|
icon="chevron_right"
|
|
587
677
|
aria-label="Next page"
|
|
588
|
-
?disabled=${
|
|
678
|
+
?disabled=${s}
|
|
589
679
|
@click=${() => this._handlePageChange(this.pageIndex + 1)}
|
|
590
680
|
></pd-icon-button>
|
|
591
681
|
<pd-icon-button
|
|
592
682
|
icon="last_page"
|
|
593
683
|
aria-label="Last page"
|
|
594
|
-
?disabled=${
|
|
684
|
+
?disabled=${s}
|
|
595
685
|
@click=${() => this._handlePageChange(this._totalPages - 1)}
|
|
596
686
|
></pd-icon-button>
|
|
597
687
|
</div>
|
|
@@ -604,7 +694,7 @@ let i = class extends y {
|
|
|
604
694
|
// ---------------------------------------------------------------------------
|
|
605
695
|
render() {
|
|
606
696
|
const e = this._displayData, t = e.length === 0 && !this.loading;
|
|
607
|
-
return
|
|
697
|
+
return h`
|
|
608
698
|
<div class="table-wrapper">
|
|
609
699
|
<div class="table-container">
|
|
610
700
|
<table
|
|
@@ -614,17 +704,17 @@ let i = class extends y {
|
|
|
614
704
|
>
|
|
615
705
|
${this._renderHeader()}
|
|
616
706
|
<tbody>
|
|
617
|
-
${this.loading ? this._renderLoadingState() :
|
|
618
|
-
${t ? this._renderEmptyState() :
|
|
619
|
-
${this.loading ?
|
|
707
|
+
${this.loading ? this._renderLoadingState() : p}
|
|
708
|
+
${t ? this._renderEmptyState() : p}
|
|
709
|
+
${this.loading ? p : x(
|
|
620
710
|
e,
|
|
621
711
|
(a) => {
|
|
622
|
-
const r = this.
|
|
712
|
+
const r = this._displayToDataIndexMap.get(a) ?? this.data.indexOf(a);
|
|
623
713
|
return this._getRowKey(a, r);
|
|
624
714
|
},
|
|
625
|
-
(a) => {
|
|
626
|
-
const
|
|
627
|
-
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);
|
|
628
718
|
}
|
|
629
719
|
)}
|
|
630
720
|
</tbody>
|
|
@@ -677,7 +767,7 @@ let i = class extends y {
|
|
|
677
767
|
this._displayDataCacheKey = "";
|
|
678
768
|
}
|
|
679
769
|
};
|
|
680
|
-
|
|
770
|
+
l.styles = y`
|
|
681
771
|
:host {
|
|
682
772
|
display: block;
|
|
683
773
|
|
|
@@ -837,7 +927,8 @@ i.styles = b`
|
|
|
837
927
|
}
|
|
838
928
|
|
|
839
929
|
tr.dragging {
|
|
840
|
-
opacity: 0.
|
|
930
|
+
opacity: 0.4;
|
|
931
|
+
z-index: 1;
|
|
841
932
|
}
|
|
842
933
|
|
|
843
934
|
tr.dragging td {
|
|
@@ -848,6 +939,11 @@ i.styles = b`
|
|
|
848
939
|
box-shadow: inset 0 2px 0 0 var(--md-sys-color-primary);
|
|
849
940
|
}
|
|
850
941
|
|
|
942
|
+
/* Rows use will-change during FLIP animation for GPU acceleration */
|
|
943
|
+
tr[role="row"] {
|
|
944
|
+
will-change: auto;
|
|
945
|
+
}
|
|
946
|
+
|
|
851
947
|
/* Column Drag States */
|
|
852
948
|
th.column-draggable {
|
|
853
949
|
cursor: grab;
|
|
@@ -1025,81 +1121,81 @@ i.styles = b`
|
|
|
1025
1121
|
}
|
|
1026
1122
|
}
|
|
1027
1123
|
`;
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
],
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
],
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
],
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
],
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
],
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
],
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
],
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
],
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
],
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
],
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
],
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
],
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
],
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
],
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
],
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
],
|
|
1076
|
-
|
|
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([
|
|
1077
1173
|
u()
|
|
1078
|
-
],
|
|
1079
|
-
|
|
1174
|
+
], l.prototype, "_sortColumn", 2);
|
|
1175
|
+
d([
|
|
1080
1176
|
u()
|
|
1081
|
-
],
|
|
1082
|
-
|
|
1177
|
+
], l.prototype, "_sortDirection", 2);
|
|
1178
|
+
d([
|
|
1083
1179
|
u()
|
|
1084
|
-
],
|
|
1085
|
-
|
|
1180
|
+
], l.prototype, "_selectedRowKeys", 2);
|
|
1181
|
+
d([
|
|
1086
1182
|
u()
|
|
1087
|
-
],
|
|
1088
|
-
|
|
1183
|
+
], l.prototype, "_draggedRowIndex", 2);
|
|
1184
|
+
d([
|
|
1089
1185
|
u()
|
|
1090
|
-
],
|
|
1091
|
-
|
|
1186
|
+
], l.prototype, "_dragOverRowIndex", 2);
|
|
1187
|
+
d([
|
|
1092
1188
|
u()
|
|
1093
|
-
],
|
|
1094
|
-
|
|
1189
|
+
], l.prototype, "_isDragHandleGrabbed", 2);
|
|
1190
|
+
d([
|
|
1095
1191
|
u()
|
|
1096
|
-
],
|
|
1097
|
-
|
|
1192
|
+
], l.prototype, "_draggedColumnIndex", 2);
|
|
1193
|
+
d([
|
|
1098
1194
|
u()
|
|
1099
|
-
],
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
],
|
|
1195
|
+
], l.prototype, "_dragOverColumnIndex", 2);
|
|
1196
|
+
l = d([
|
|
1197
|
+
v("pd-table")
|
|
1198
|
+
], l);
|
|
1103
1199
|
export {
|
|
1104
|
-
|
|
1200
|
+
l as PdTable
|
|
1105
1201
|
};
|