arame-data-grid-pro 1.0.6 → 1.0.8
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/README.md +3 -3
- package/dist/advanced-filter-table/advanced-filter-data-table.element.d.ts +1 -1
- package/dist/advanced-filter-table/expression-engine.d.ts +2 -2
- package/dist/advanced-filter-table/index.cjs +5 -5
- package/dist/advanced-filter-table/index.cjs.map +1 -1
- package/dist/advanced-filter-table/index.js +165 -160
- package/dist/advanced-filter-table/index.js.map +1 -1
- package/dist/advanced-filter-table/types.d.ts +21 -14
- package/dist/{base-table-controller-BXMQn5v2.cjs → base-table-controller-CAWc7Hre.cjs} +2 -2
- package/dist/base-table-controller-CAWc7Hre.cjs.map +1 -0
- package/dist/{base-table-controller-DWbA88mL.js → base-table-controller-DO-etV2a.js} +3 -2
- package/dist/base-table-controller-DO-etV2a.js.map +1 -0
- package/dist/calculated-table/calculated-data-table.element.d.ts +2 -2
- package/dist/calculated-table/calculation-engine.d.ts +4 -4
- package/dist/calculated-table/index.cjs +2 -2
- package/dist/calculated-table/index.cjs.map +1 -1
- package/dist/calculated-table/index.js +2 -2
- package/dist/calculated-table/index.js.map +1 -1
- package/dist/calculated-table/types.d.ts +13 -13
- package/dist/column-visibility-table/column-visibility-table.element.d.ts +1 -1
- package/dist/column-visibility-table/index.cjs +1 -1
- package/dist/column-visibility-table/index.cjs.map +1 -1
- package/dist/column-visibility-table/index.js +1 -1
- package/dist/column-visibility-table/index.js.map +1 -1
- package/dist/column-visibility-table/types.d.ts +7 -7
- package/dist/common/base-table-controller.d.ts +5 -5
- package/dist/common/base-table-types.d.ts +7 -7
- package/dist/common/configurable-table-types.d.ts +1 -1
- package/dist/common/index.cjs +1 -1
- package/dist/common/index.cjs.map +1 -1
- package/dist/common/index.js +1 -1
- package/dist/common/index.js.map +1 -1
- package/dist/common/table-state-manager.d.ts +4 -4
- package/dist/common/universal-exporter.d.ts +6 -6
- package/dist/context-menu-table/context-menu-data-table.element.d.ts +1 -1
- package/dist/context-menu-table/index.cjs +1 -1
- package/dist/context-menu-table/index.cjs.map +1 -1
- package/dist/context-menu-table/index.js +1 -1
- package/dist/context-menu-table/index.js.map +1 -1
- package/dist/context-menu-table/types.d.ts +11 -11
- package/dist/core/data-engine.d.ts +1 -1
- package/dist/editable-table/editable-data-table.element.d.ts +3 -3
- package/dist/editable-table/index.cjs +1 -1
- package/dist/editable-table/index.cjs.map +1 -1
- package/dist/editable-table/index.js +1 -1
- package/dist/editable-table/index.js.map +1 -1
- package/dist/editable-table/types.d.ts +22 -22
- package/dist/expandable-table/expandable-data-table.element.d.ts +1 -1
- package/dist/expandable-table/index.cjs +1 -1
- package/dist/expandable-table/index.cjs.map +1 -1
- package/dist/expandable-table/index.js +40 -39
- package/dist/expandable-table/index.js.map +1 -1
- package/dist/expandable-table/types.d.ts +8 -8
- package/dist/filterable-table/filter-engine.d.ts +1 -1
- package/dist/filterable-table/filterable-data-table.element.d.ts +2 -2
- package/dist/filterable-table/index.cjs +1 -1
- package/dist/filterable-table/index.cjs.map +1 -1
- package/dist/filterable-table/index.js +69 -68
- package/dist/filterable-table/index.js.map +1 -1
- package/dist/filterable-table/types.d.ts +12 -12
- package/dist/grouped-table/group-engine.d.ts +2 -2
- package/dist/grouped-table/grouped-data-table.element.d.ts +1 -1
- package/dist/grouped-table/index.cjs +1 -1
- package/dist/grouped-table/index.cjs.map +1 -1
- package/dist/grouped-table/index.js +1 -1
- package/dist/grouped-table/index.js.map +1 -1
- package/dist/grouped-table/types.d.ts +13 -13
- package/dist/header-filter-table/filter-engine.d.ts +2 -2
- package/dist/header-filter-table/header-filter-data-table.element.d.ts +1 -1
- package/dist/header-filter-table/index.cjs +2 -2
- package/dist/header-filter-table/index.cjs.map +1 -1
- package/dist/header-filter-table/index.js +3 -2
- package/dist/header-filter-table/index.js.map +1 -1
- package/dist/header-filter-table/types.d.ts +10 -10
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +188 -187
- package/dist/index.js.map +1 -1
- package/dist/infinite-table/index.cjs +1 -1
- package/dist/infinite-table/index.cjs.map +1 -1
- package/dist/infinite-table/index.js +1 -1
- package/dist/infinite-table/index.js.map +1 -1
- package/dist/infinite-table/infinite-data-table.element.d.ts +1 -1
- package/dist/infinite-table/types.d.ts +11 -11
- package/dist/sticky-table/index.cjs +1 -1
- package/dist/sticky-table/index.cjs.map +1 -1
- package/dist/sticky-table/index.js +1 -1
- package/dist/sticky-table/index.js.map +1 -1
- package/dist/sticky-table/sticky-data-table.element.d.ts +1 -1
- package/dist/sticky-table/types.d.ts +7 -7
- package/dist/tree-table/index.cjs +4 -4
- package/dist/tree-table/index.cjs.map +1 -1
- package/dist/tree-table/index.js +96 -95
- package/dist/tree-table/index.js.map +1 -1
- package/dist/tree-table/tree-data-table.element.d.ts +1 -1
- package/dist/tree-table/tree-engine.d.ts +6 -6
- package/dist/tree-table/types.d.ts +11 -11
- package/dist/types.d.ts +22 -22
- package/dist/ui/pro-data-grid.element.d.ts +1 -1
- package/package.json +1 -1
- package/dist/base-table-controller-BXMQn5v2.cjs.map +0 -1
- package/dist/base-table-controller-DWbA88mL.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -7,51 +7,51 @@ function C(f, b) {
|
|
|
7
7
|
if (!i.includes("."))
|
|
8
8
|
return i === "__proto__" || i === "constructor" || i === "prototype" ? void 0 : f[i];
|
|
9
9
|
const t = i.split(".");
|
|
10
|
-
let
|
|
10
|
+
let n = f;
|
|
11
11
|
for (const e of t) {
|
|
12
|
-
if (e === "__proto__" || e === "constructor" || e === "prototype" ||
|
|
13
|
-
|
|
12
|
+
if (e === "__proto__" || e === "constructor" || e === "prototype" || n == null || typeof n != "object") return;
|
|
13
|
+
n = n[e];
|
|
14
14
|
}
|
|
15
|
-
return
|
|
15
|
+
return n;
|
|
16
16
|
}
|
|
17
17
|
function R(f, b, i, t) {
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
if (!
|
|
18
|
+
const n = i.trim().toLowerCase(), e = n ? t.filter((o) => o.field).map((o) => o.field) : [], r = b.map((o) => {
|
|
19
|
+
const s = o.value.trim().toLowerCase();
|
|
20
|
+
if (!s) return null;
|
|
21
21
|
const a = t.find((d) => d.id === o.columnId);
|
|
22
22
|
return !a || !a.field ? null : {
|
|
23
23
|
field: a.field,
|
|
24
24
|
operator: o.operator || "contains",
|
|
25
|
-
targetVal:
|
|
25
|
+
targetVal: s
|
|
26
26
|
};
|
|
27
27
|
}).filter((o) => o !== null);
|
|
28
|
-
return !
|
|
29
|
-
if (
|
|
30
|
-
let
|
|
28
|
+
return !n && r.length === 0 ? f : f.filter((o) => {
|
|
29
|
+
if (n) {
|
|
30
|
+
let s = !1;
|
|
31
31
|
for (const a of e) {
|
|
32
32
|
const d = C(o, a);
|
|
33
|
-
if (d != null && String(d).toLowerCase().includes(
|
|
34
|
-
|
|
33
|
+
if (d != null && String(d).toLowerCase().includes(n)) {
|
|
34
|
+
s = !0;
|
|
35
35
|
break;
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
|
-
if (!
|
|
38
|
+
if (!s) return !1;
|
|
39
39
|
}
|
|
40
|
-
for (const
|
|
41
|
-
const a = C(o,
|
|
42
|
-
switch (
|
|
40
|
+
for (const s of r) {
|
|
41
|
+
const a = C(o, s.field), d = a == null ? "" : String(a).toLowerCase();
|
|
42
|
+
switch (s.operator) {
|
|
43
43
|
case "equals":
|
|
44
|
-
if (d !==
|
|
44
|
+
if (d !== s.targetVal) return !1;
|
|
45
45
|
break;
|
|
46
46
|
case "startsWith":
|
|
47
|
-
if (!d.startsWith(
|
|
47
|
+
if (!d.startsWith(s.targetVal)) return !1;
|
|
48
48
|
break;
|
|
49
49
|
case "endsWith":
|
|
50
|
-
if (!d.endsWith(
|
|
50
|
+
if (!d.endsWith(s.targetVal)) return !1;
|
|
51
51
|
break;
|
|
52
52
|
case "contains":
|
|
53
53
|
default:
|
|
54
|
-
if (!d.includes(
|
|
54
|
+
if (!d.includes(s.targetVal)) return !1;
|
|
55
55
|
break;
|
|
56
56
|
}
|
|
57
57
|
}
|
|
@@ -60,16 +60,16 @@ function R(f, b, i, t) {
|
|
|
60
60
|
}
|
|
61
61
|
function I(f, b, i) {
|
|
62
62
|
if (!b.length) return f;
|
|
63
|
-
const t = new Map(i.map((e) => [e.id, e])),
|
|
63
|
+
const t = new Map(i.map((e) => [e.id, e])), n = b.map((e) => {
|
|
64
64
|
const r = t.get(e.columnId);
|
|
65
65
|
return !r || !r.field ? null : { crit: e, col: r };
|
|
66
66
|
}).filter((e) => e !== null);
|
|
67
|
-
return
|
|
68
|
-
for (const { crit: o, col:
|
|
69
|
-
const a = C(e,
|
|
67
|
+
return n.length ? [...f].sort((e, r) => {
|
|
68
|
+
for (const { crit: o, col: s } of n) {
|
|
69
|
+
const a = C(e, s.field), d = C(r, s.field);
|
|
70
70
|
let c = 0;
|
|
71
|
-
if (
|
|
72
|
-
c =
|
|
71
|
+
if (s.comparator)
|
|
72
|
+
c = s.comparator(a, d, e, r);
|
|
73
73
|
else {
|
|
74
74
|
if (a === d) continue;
|
|
75
75
|
a == null && d == null ? c = 0 : a == null ? c = -1 : d == null ? c = 1 : typeof a == "number" && typeof d == "number" ? c = a - d : c = String(a).localeCompare(String(d), void 0, { numeric: !0 });
|
|
@@ -81,8 +81,8 @@ function I(f, b, i) {
|
|
|
81
81
|
}) : f;
|
|
82
82
|
}
|
|
83
83
|
function A(f, b, i) {
|
|
84
|
-
const t = f.length,
|
|
85
|
-
return { pagedRows: f.slice(r, r + i), totalPages:
|
|
84
|
+
const t = f.length, n = Math.max(1, Math.ceil(t / i)), r = Math.max(0, Math.min(b, n - 1)) * i;
|
|
85
|
+
return { pagedRows: f.slice(r, r + i), totalPages: n, totalRows: t };
|
|
86
86
|
}
|
|
87
87
|
function S(f) {
|
|
88
88
|
if (f == null) return "";
|
|
@@ -99,24 +99,24 @@ function D(f, b, i = "export.csv") {
|
|
|
99
99
|
e.push(c.join(","));
|
|
100
100
|
}
|
|
101
101
|
const r = e.join(`\r
|
|
102
|
-
`), o = new Blob([r], { type: "text/csv;charset=utf-8;" }),
|
|
103
|
-
a.href =
|
|
102
|
+
`), o = new Blob([r], { type: "text/csv;charset=utf-8;" }), s = URL.createObjectURL(o), a = document.createElement("a");
|
|
103
|
+
a.href = s, a.setAttribute("download", i), document.body.appendChild(a), a.click(), document.body.removeChild(a), URL.revokeObjectURL(s);
|
|
104
104
|
}
|
|
105
|
-
function P(f, b, i, t,
|
|
105
|
+
function P(f, b, i, t, n = 3) {
|
|
106
106
|
const e = i * t;
|
|
107
107
|
if (i === 0 || b <= 0)
|
|
108
108
|
return { startIndex: 0, endIndex: 0, topOffset: 0, totalHeight: 0 };
|
|
109
109
|
const r = Math.floor(f / t), o = Math.min(
|
|
110
110
|
i - 1,
|
|
111
111
|
Math.ceil((f + b) / t)
|
|
112
|
-
),
|
|
113
|
-
return { startIndex:
|
|
112
|
+
), s = Math.max(0, r - n), a = Math.min(i - 1, o + n), d = s * t;
|
|
113
|
+
return { startIndex: s, endIndex: a, topOffset: d, totalHeight: e };
|
|
114
114
|
}
|
|
115
115
|
function l(f, b, i) {
|
|
116
116
|
const t = document.createElement(f);
|
|
117
117
|
if (b && (t.className = b), i)
|
|
118
|
-
for (const [
|
|
119
|
-
typeof e == "boolean" ? e ? t.setAttribute(
|
|
118
|
+
for (const [n, e] of Object.entries(i))
|
|
119
|
+
typeof e == "boolean" ? e ? t.setAttribute(n, "") : t.removeAttribute(n) : t.setAttribute(n, String(e));
|
|
120
120
|
return t;
|
|
121
121
|
}
|
|
122
122
|
function y(f) {
|
|
@@ -237,8 +237,8 @@ class T extends HTMLElement {
|
|
|
237
237
|
disconnectedCallback() {
|
|
238
238
|
this._abortController && this._abortController.abort(), this._searchDebounceTimer && clearTimeout(this._searchDebounceTimer), this.resizeObserver && this.resizeObserver.disconnect(), this.scrollHandler && this.tableContainerEl && this.tableContainerEl.removeEventListener("scroll", this.scrollHandler);
|
|
239
239
|
}
|
|
240
|
-
attributeChangedCallback(i, t,
|
|
241
|
-
i === "density" &&
|
|
240
|
+
attributeChangedCallback(i, t, n) {
|
|
241
|
+
i === "density" && n && (this._options.density = n), i === "mobile-layout" && n && (this._options.mobileLayout = n);
|
|
242
242
|
}
|
|
243
243
|
// --- Initial Layout Setup ---
|
|
244
244
|
initLayout() {
|
|
@@ -267,7 +267,7 @@ class T extends HTMLElement {
|
|
|
267
267
|
async triggerServerLoad(i = !1) {
|
|
268
268
|
if (!this._options.serverSide || !this._options.serverDataLoader) return;
|
|
269
269
|
this._abortController && this._isLoading && this._abortController.abort(), this._abortController = new AbortController();
|
|
270
|
-
const t = this._abortController.signal,
|
|
270
|
+
const t = this._abortController.signal, n = ++this._currentRequestId;
|
|
271
271
|
this._isLoading = !0, this._loadError = null;
|
|
272
272
|
const e = !i;
|
|
273
273
|
this._isInitialLoad = i, this.dispatchGridEvent("pdg:loading", {
|
|
@@ -285,15 +285,16 @@ class T extends HTMLElement {
|
|
|
285
285
|
};
|
|
286
286
|
try {
|
|
287
287
|
const o = await this._options.serverDataLoader(r);
|
|
288
|
-
if (
|
|
288
|
+
if (n !== this._currentRequestId || t.aborted)
|
|
289
289
|
return;
|
|
290
290
|
this._rows = o.rows, this._pagination.totalRows = o.totalRows, this._pagination.totalPages = Math.max(1, Math.ceil(o.totalRows / this._pagination.pageSize)), this._isInitialLoad = !1;
|
|
291
291
|
} catch (o) {
|
|
292
|
-
|
|
292
|
+
const s = o;
|
|
293
|
+
if ((s == null ? void 0 : s.name) === "AbortError" || t.aborted)
|
|
293
294
|
return;
|
|
294
|
-
this._loadError =
|
|
295
|
+
this._loadError = s, this.dispatchGridEvent("pdg:error", { error: o, queryParams: r });
|
|
295
296
|
} finally {
|
|
296
|
-
|
|
297
|
+
n === this._currentRequestId && (this._isLoading = !1, this.dispatchGridEvent("pdg:loading", {
|
|
297
298
|
loading: !1,
|
|
298
299
|
isInitial: !1,
|
|
299
300
|
isRefresh: !1
|
|
@@ -310,38 +311,38 @@ class T extends HTMLElement {
|
|
|
310
311
|
saveState() {
|
|
311
312
|
var e;
|
|
312
313
|
if (!((e = this._options.statePersistence) != null && e.enabled)) return;
|
|
313
|
-
const i = this._options.statePersistence.storage || "localStorage", t = this._options.statePersistence.key || "arame-grid-state",
|
|
314
|
-
this._options.statePersistence.saveColumnWidths !== !1 && (
|
|
314
|
+
const i = this._options.statePersistence.storage || "localStorage", t = this._options.statePersistence.key || "arame-grid-state", n = {};
|
|
315
|
+
this._options.statePersistence.saveColumnWidths !== !1 && (n.columnWidths = this._columns.map((r) => ({ id: r.id, width: r.width }))), this._options.statePersistence.saveColumnVisibility !== !1 && (n.columnVisibility = this._columns.map((r) => ({ id: r.id, visible: r.visible !== !1 }))), this._options.statePersistence.saveColumnOrder !== !1 && (n.columnOrder = this._columns.map((r) => r.id)), this._options.statePersistence.saveSort !== !1 && (n.sortCriteria = this._sortCriteria), this._options.statePersistence.saveFilter !== !1 && (n.globalSearch = this._globalSearch);
|
|
315
316
|
try {
|
|
316
|
-
(i === "sessionStorage" ? sessionStorage : localStorage).setItem(t, JSON.stringify(
|
|
317
|
+
(i === "sessionStorage" ? sessionStorage : localStorage).setItem(t, JSON.stringify(n));
|
|
317
318
|
} catch {
|
|
318
319
|
}
|
|
319
320
|
}
|
|
320
321
|
restoreState() {
|
|
321
|
-
var
|
|
322
|
-
if (!((
|
|
322
|
+
var n;
|
|
323
|
+
if (!((n = this._options.statePersistence) != null && n.enabled)) return;
|
|
323
324
|
const i = this._options.statePersistence.storage || "localStorage", t = this._options.statePersistence.key || "arame-grid-state";
|
|
324
325
|
try {
|
|
325
326
|
const r = (i === "sessionStorage" ? sessionStorage : localStorage).getItem(t);
|
|
326
327
|
if (!r) return;
|
|
327
328
|
const o = JSON.parse(r);
|
|
328
329
|
if (o.columnWidths && Array.isArray(o.columnWidths)) {
|
|
329
|
-
const
|
|
330
|
+
const s = new Map((o.columnWidths || []).map((a) => [a.id, a.width]));
|
|
330
331
|
this._columns.forEach((a) => {
|
|
331
|
-
|
|
332
|
+
s.has(a.id) && (a.width = s.get(a.id));
|
|
332
333
|
});
|
|
333
334
|
}
|
|
334
335
|
if (o.columnVisibility && Array.isArray(o.columnVisibility)) {
|
|
335
|
-
const
|
|
336
|
+
const s = new Map((o.columnVisibility || []).map((a) => [a.id, a.visible]));
|
|
336
337
|
this._columns.forEach((a) => {
|
|
337
|
-
|
|
338
|
+
s.has(a.id) && (a.visible = s.get(a.id));
|
|
338
339
|
});
|
|
339
340
|
}
|
|
340
341
|
if (o.columnOrder && Array.isArray(o.columnOrder) && o.columnOrder.length > 0) {
|
|
341
|
-
const
|
|
342
|
+
const s = new Map(this._columns.map((d) => [d.id, d])), a = [];
|
|
342
343
|
o.columnOrder.forEach((d) => {
|
|
343
|
-
|
|
344
|
-
}),
|
|
344
|
+
s.has(d) && (a.push(s.get(d)), s.delete(d));
|
|
345
|
+
}), s.forEach((d) => a.push(d)), this._columns = a;
|
|
345
346
|
}
|
|
346
347
|
o.sortCriteria && Array.isArray(o.sortCriteria) && (this._sortCriteria = o.sortCriteria), typeof o.globalSearch == "string" && (this._globalSearch = o.globalSearch);
|
|
347
348
|
} catch {
|
|
@@ -366,29 +367,29 @@ class T extends HTMLElement {
|
|
|
366
367
|
const e = l("td", "pdg-td");
|
|
367
368
|
t.appendChild(e);
|
|
368
369
|
}
|
|
369
|
-
let
|
|
370
|
+
let n = 0;
|
|
370
371
|
if (this._columns.forEach((e) => {
|
|
371
372
|
if (e.visible === !1) return;
|
|
372
|
-
|
|
373
|
+
n++;
|
|
373
374
|
const r = l("td", "pdg-td");
|
|
374
375
|
if (e.width && (r.style.width = e.width), e.aggregation) {
|
|
375
376
|
const o = i.map((c) => C(c, e.field)).filter((c) => c != null);
|
|
376
|
-
let
|
|
377
|
+
let s = 0;
|
|
377
378
|
if (e.aggregation === "sum")
|
|
378
|
-
|
|
379
|
+
s = o.reduce((c, h) => c + (Number(h) || 0), 0);
|
|
379
380
|
else if (e.aggregation === "avg") {
|
|
380
381
|
const c = o.reduce((h, g) => h + (Number(g) || 0), 0);
|
|
381
|
-
|
|
382
|
-
} else e.aggregation === "count" ?
|
|
382
|
+
s = o.length ? c / o.length : 0;
|
|
383
|
+
} else e.aggregation === "count" ? s = o.length : e.aggregation === "min" ? s = o.length ? Math.min(...o.map((c) => Number(c) || 0)) : 0 : e.aggregation === "max" ? s = o.length ? Math.max(...o.map((c) => Number(c) || 0)) : 0 : typeof e.aggregation == "function" && (s = e.aggregation(o, i));
|
|
383
384
|
const a = l("span", "pdg-agg-label");
|
|
384
385
|
a.textContent = typeof e.aggregation == "string" ? e.aggregation.toUpperCase() : "TOTAL";
|
|
385
386
|
const d = l("span", "pdg-agg-value");
|
|
386
|
-
e.aggregationFormatter ? d.textContent = e.aggregationFormatter(
|
|
387
|
-
} else if (
|
|
387
|
+
e.aggregationFormatter ? d.textContent = e.aggregationFormatter(s) : e.formatter ? d.textContent = e.formatter(s, {}) : typeof s == "number" ? d.textContent = Number.isInteger(s) ? s.toLocaleString() : s.toFixed(2) : d.textContent = String(s), r.appendChild(a), r.appendChild(d);
|
|
388
|
+
} else if (n === 1) {
|
|
388
389
|
const o = l("span", "pdg-agg-label");
|
|
389
390
|
o.textContent = "SUMMARY";
|
|
390
|
-
const
|
|
391
|
-
|
|
391
|
+
const s = l("span");
|
|
392
|
+
s.style.fontSize = "0.8rem", s.style.color = "var(--pdg-text-muted)", s.textContent = `${i.length} matching rows`, r.appendChild(o), r.appendChild(s);
|
|
392
393
|
} else
|
|
393
394
|
r.textContent = "—", r.style.color = "var(--pdg-text-muted)", r.style.fontSize = "0.8rem";
|
|
394
395
|
t.appendChild(r);
|
|
@@ -399,17 +400,17 @@ class T extends HTMLElement {
|
|
|
399
400
|
this.tfootEl.appendChild(t);
|
|
400
401
|
}
|
|
401
402
|
cacheRowPositions() {
|
|
402
|
-
var
|
|
403
|
-
if (this._previousRowRects.clear(), !(((
|
|
403
|
+
var n;
|
|
404
|
+
if (this._previousRowRects.clear(), !(((n = this._options.animations) == null ? void 0 : n.enabled) !== !1 && !window.matchMedia("(prefers-reduced-motion: reduce)").matches)) return;
|
|
404
405
|
this.tbodyEl.querySelectorAll(".pdg-row[data-row-id]").forEach((e) => {
|
|
405
406
|
const r = e.getAttribute("data-row-id");
|
|
406
407
|
r && this._previousRowRects.set(r, e.getBoundingClientRect());
|
|
407
408
|
});
|
|
408
409
|
}
|
|
409
410
|
applyRowFLIPAnimations() {
|
|
410
|
-
var r, o,
|
|
411
|
+
var r, o, s;
|
|
411
412
|
if (!(((r = this._options.animations) == null ? void 0 : r.enabled) !== !1 && !window.matchMedia("(prefers-reduced-motion: reduce)").matches) || this._previousRowRects.size === 0) return;
|
|
412
|
-
const t = ((o = this._options.animations) == null ? void 0 : o.duration) ?? 250,
|
|
413
|
+
const t = ((o = this._options.animations) == null ? void 0 : o.duration) ?? 250, n = ((s = this._options.animations) == null ? void 0 : s.easing) ?? "ease-out";
|
|
413
414
|
this.tbodyEl.querySelectorAll(".pdg-row[data-row-id]").forEach((a) => {
|
|
414
415
|
const d = a.getAttribute("data-row-id");
|
|
415
416
|
if (!d) return;
|
|
@@ -419,7 +420,7 @@ class T extends HTMLElement {
|
|
|
419
420
|
if (g !== 0) {
|
|
420
421
|
const p = a;
|
|
421
422
|
p.style.transition = "none", p.style.transform = `translateY(${g}px)`, requestAnimationFrame(() => {
|
|
422
|
-
p.style.transition = `transform ${t}ms ${
|
|
423
|
+
p.style.transition = `transform ${t}ms ${n}`, p.style.transform = "";
|
|
423
424
|
const u = () => {
|
|
424
425
|
p.style.transition = "", p.removeEventListener("transitionend", u);
|
|
425
426
|
};
|
|
@@ -449,8 +450,8 @@ class T extends HTMLElement {
|
|
|
449
450
|
this._columnFilters,
|
|
450
451
|
i,
|
|
451
452
|
this._columns
|
|
452
|
-
),
|
|
453
|
-
return { processed:
|
|
453
|
+
), n = this._options.sorting === !1 ? t : I(t, this._sortCriteria, this._columns);
|
|
454
|
+
return { processed: n, totalFilteredCount: n.length };
|
|
454
455
|
}
|
|
455
456
|
renderToolbar() {
|
|
456
457
|
y(this.toolbarEl);
|
|
@@ -465,24 +466,24 @@ class T extends HTMLElement {
|
|
|
465
466
|
e.addEventListener("input", (r) => {
|
|
466
467
|
if (this._globalSearch = r.target.value, this._pagination.pageIndex = 0, this._options.serverSide) {
|
|
467
468
|
this._searchDebounceTimer && clearTimeout(this._searchDebounceTimer);
|
|
468
|
-
const
|
|
469
|
+
const s = this._options.searchDebounceMs ?? 300;
|
|
469
470
|
this._searchDebounceTimer = setTimeout(() => {
|
|
470
471
|
this.triggerServerLoad(!1);
|
|
471
|
-
},
|
|
472
|
+
}, s);
|
|
472
473
|
} else
|
|
473
474
|
this.render();
|
|
474
475
|
const o = {};
|
|
475
|
-
this._columnFilters.forEach((
|
|
476
|
+
this._columnFilters.forEach((s) => o[s.columnId] = s.value), this.dispatchGridEvent("pdg:filter", {
|
|
476
477
|
filters: o,
|
|
477
478
|
globalSearch: this._globalSearch
|
|
478
479
|
});
|
|
479
480
|
}), i.appendChild(e);
|
|
480
481
|
}
|
|
481
|
-
const t = l("div", "pdg-toolbar-right"),
|
|
482
|
-
|
|
482
|
+
const t = l("div", "pdg-toolbar-right"), n = l("button", "pdg-btn", { type: "button" });
|
|
483
|
+
n.textContent = "Export CSV", n.addEventListener("click", () => {
|
|
483
484
|
const { processed: e } = this.getProcessedData();
|
|
484
485
|
D(e, this._columns);
|
|
485
|
-
}), t.appendChild(
|
|
486
|
+
}), t.appendChild(n), this.toolbarEl.appendChild(i), this.toolbarEl.appendChild(t);
|
|
486
487
|
}
|
|
487
488
|
renderHeader() {
|
|
488
489
|
y(this.theadEl);
|
|
@@ -494,13 +495,13 @@ class T extends HTMLElement {
|
|
|
494
495
|
if (this._options.selectable) {
|
|
495
496
|
const t = l("th", "pdg-th pdg-th-select");
|
|
496
497
|
if (t.style.width = "40px", this._options.multiSelect) {
|
|
497
|
-
const
|
|
498
|
+
const n = l("input", "pdg-checkbox", {
|
|
498
499
|
type: "checkbox",
|
|
499
500
|
"aria-label": "Select all rows"
|
|
500
501
|
}), { processed: e } = this.getProcessedData();
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
}), t.appendChild(
|
|
502
|
+
n.checked = e.length > 0 && this._selectedIds.size === e.length, n.indeterminate = this._selectedIds.size > 0 && this._selectedIds.size < e.length, n.addEventListener("change", () => {
|
|
503
|
+
n.checked ? e.forEach((r) => this._selectedIds.add(this.getRowId(r))) : this._selectedIds.clear(), this.dispatchSelection(), this.renderBody();
|
|
504
|
+
}), t.appendChild(n);
|
|
504
505
|
}
|
|
505
506
|
i.appendChild(t);
|
|
506
507
|
}
|
|
@@ -508,60 +509,60 @@ class T extends HTMLElement {
|
|
|
508
509
|
const t = l("th", "pdg-th pdg-th-expand");
|
|
509
510
|
t.style.width = "40px", i.appendChild(t);
|
|
510
511
|
}
|
|
511
|
-
if (this._columns.forEach((t,
|
|
512
|
+
if (this._columns.forEach((t, n) => {
|
|
512
513
|
if (t.visible === !1) return;
|
|
513
514
|
const e = l("th", "pdg-th");
|
|
514
|
-
e.setAttribute("data-col-index", String(
|
|
515
|
+
e.setAttribute("data-col-index", String(n)), t.width && (e.style.width = t.width), this._justDroppedColId === t.id && e.classList.add("pdg-drop-success");
|
|
515
516
|
const r = l("div", "pdg-th-inner");
|
|
516
|
-
this._options.columnReordering && t.reorderable !== !1 && (e.classList.add("pdg-th-draggable"), e.setAttribute("draggable", "true"), e.setAttribute("tabindex", "0"), e.setAttribute("aria-description", "Press Left or Right arrow to reorder column"), e.addEventListener("dragstart", (
|
|
517
|
-
this._draggedColIndex =
|
|
517
|
+
this._options.columnReordering && t.reorderable !== !1 && (e.classList.add("pdg-th-draggable"), e.setAttribute("draggable", "true"), e.setAttribute("tabindex", "0"), e.setAttribute("aria-description", "Press Left or Right arrow to reorder column"), e.addEventListener("dragstart", (s) => {
|
|
518
|
+
this._draggedColIndex = n, e.classList.add("pdg-th-dragging"), s.dataTransfer && (s.dataTransfer.effectAllowed = "move", s.dataTransfer.setData("text/plain", String(n))), this.announceLive(`Started dragging column ${t.header}. Move over a column to reorder.`);
|
|
518
519
|
}), e.addEventListener("dragend", () => {
|
|
519
|
-
this._draggedColIndex = null, this.theadEl.querySelectorAll(".pdg-th").forEach((
|
|
520
|
-
|
|
520
|
+
this._draggedColIndex = null, this.theadEl.querySelectorAll(".pdg-th").forEach((s) => {
|
|
521
|
+
s.classList.remove("pdg-th-dragging", "pdg-drag-over-left", "pdg-drag-over-right", "pdg-drag-not-allowed");
|
|
521
522
|
});
|
|
522
|
-
}), e.addEventListener("dragover", (
|
|
523
|
-
if (
|
|
524
|
-
if (this._draggedColIndex ===
|
|
525
|
-
|
|
523
|
+
}), e.addEventListener("dragover", (s) => {
|
|
524
|
+
if (s.preventDefault(), this._draggedColIndex === null) return;
|
|
525
|
+
if (this._draggedColIndex === n) {
|
|
526
|
+
s.dataTransfer && (s.dataTransfer.dropEffect = "none"), e.classList.add("pdg-drag-not-allowed"), e.classList.remove("pdg-drag-over-left", "pdg-drag-over-right");
|
|
526
527
|
return;
|
|
527
528
|
}
|
|
528
|
-
|
|
529
|
+
s.dataTransfer && (s.dataTransfer.dropEffect = "move"), e.classList.remove("pdg-drag-not-allowed");
|
|
529
530
|
const a = e.getBoundingClientRect();
|
|
530
|
-
|
|
531
|
+
s.clientX - a.left < a.width / 2 ? (e.classList.add("pdg-drag-over-left"), e.classList.remove("pdg-drag-over-right")) : (e.classList.add("pdg-drag-over-right"), e.classList.remove("pdg-drag-over-left"));
|
|
531
532
|
}), e.addEventListener("dragleave", () => {
|
|
532
533
|
e.classList.remove("pdg-drag-over-left", "pdg-drag-over-right", "pdg-drag-not-allowed");
|
|
533
|
-
}), e.addEventListener("drop", (
|
|
534
|
-
|
|
534
|
+
}), e.addEventListener("drop", (s) => {
|
|
535
|
+
s.preventDefault();
|
|
535
536
|
const a = this._draggedColIndex;
|
|
536
|
-
if (e.classList.remove("pdg-drag-over-left", "pdg-drag-over-right", "pdg-drag-not-allowed", "pdg-th-dragging"), a != null && a !==
|
|
537
|
+
if (e.classList.remove("pdg-drag-over-left", "pdg-drag-over-right", "pdg-drag-not-allowed", "pdg-th-dragging"), a != null && a !== n) {
|
|
537
538
|
const d = e.getBoundingClientRect();
|
|
538
|
-
let h =
|
|
539
|
+
let h = s.clientX - d.left < d.width / 2 ? n : n + 1;
|
|
539
540
|
a < h && h--, h = Math.max(0, Math.min(h, this._columns.length - 1)), h !== a && this.reorderColumn(a, h);
|
|
540
541
|
}
|
|
541
542
|
this._draggedColIndex = null;
|
|
542
|
-
}), e.addEventListener("keydown", (
|
|
543
|
-
|
|
543
|
+
}), e.addEventListener("keydown", (s) => {
|
|
544
|
+
s.key === "ArrowLeft" && n > 0 ? (s.preventDefault(), this.reorderColumn(n, n - 1)) : s.key === "ArrowRight" && n < this._columns.length - 1 && (s.preventDefault(), this.reorderColumn(n, n + 1));
|
|
544
545
|
}));
|
|
545
546
|
const o = l("span", "pdg-th-title");
|
|
546
547
|
if (o.textContent = t.header, r.appendChild(o), t.sortable && this._options.sorting !== !1) {
|
|
547
548
|
e.classList.add("pdg-sortable");
|
|
548
|
-
const
|
|
549
|
-
a.textContent = (
|
|
549
|
+
const s = this._sortCriteria.find((d) => d.columnId === t.id), a = l("span", "pdg-sort-icon");
|
|
550
|
+
a.textContent = (s == null ? void 0 : s.direction) === "asc" ? " ▲" : (s == null ? void 0 : s.direction) === "desc" ? " ▼" : " ⇅", r.appendChild(a), e.addEventListener("click", () => this.handleSortClick(t.id));
|
|
550
551
|
}
|
|
551
552
|
if (e.appendChild(r), this._options.resizable !== !1 && t.resizable !== !1) {
|
|
552
|
-
const
|
|
553
|
+
const s = l("div", "pdg-col-resizer", {
|
|
553
554
|
title: "Drag to resize, double click to auto-fit"
|
|
554
555
|
});
|
|
555
|
-
|
|
556
|
-
a.preventDefault(), a.stopPropagation(),
|
|
556
|
+
s.addEventListener("mousedown", (a) => {
|
|
557
|
+
a.preventDefault(), a.stopPropagation(), s.classList.add("is-resizing");
|
|
557
558
|
const d = a.pageX, c = e.offsetWidth, h = (p) => {
|
|
558
559
|
const u = p.pageX - d, m = Math.max(t.minWidth || 70, c + u);
|
|
559
560
|
e.style.width = `${m}px`, t.width = `${m}px`;
|
|
560
561
|
}, g = () => {
|
|
561
|
-
|
|
562
|
+
s.classList.remove("is-resizing"), window.removeEventListener("mousemove", h), window.removeEventListener("mouseup", g), this.saveState(), this.announceLive(`Resized column ${t.header} to ${e.offsetWidth}px`);
|
|
562
563
|
};
|
|
563
564
|
window.addEventListener("mousemove", h), window.addEventListener("mouseup", g);
|
|
564
|
-
}),
|
|
565
|
+
}), s.addEventListener("dblclick", (a) => {
|
|
565
566
|
a.preventDefault(), a.stopPropagation();
|
|
566
567
|
let d = t.header.length;
|
|
567
568
|
for (const h of this._rows) {
|
|
@@ -573,7 +574,7 @@ class T extends HTMLElement {
|
|
|
573
574
|
}
|
|
574
575
|
const c = Math.max(t.minWidth || 80, Math.min(t.maxWidth || 500, d * 10 + 40));
|
|
575
576
|
e.style.width = `${c}px`, t.width = `${c}px`, this.saveState(), this.announceLive(`Auto-fitted column ${t.header} to ${c}px`);
|
|
576
|
-
}), e.appendChild(
|
|
577
|
+
}), e.appendChild(s);
|
|
577
578
|
}
|
|
578
579
|
i.appendChild(e);
|
|
579
580
|
}), this._options.deletable) {
|
|
@@ -583,15 +584,15 @@ class T extends HTMLElement {
|
|
|
583
584
|
this.theadEl.appendChild(i);
|
|
584
585
|
}
|
|
585
586
|
reorderColumn(i, t) {
|
|
586
|
-
const
|
|
587
|
-
e.splice(i, 1), e.splice(t, 0,
|
|
587
|
+
const n = this._columns[i], e = [...this._columns];
|
|
588
|
+
e.splice(i, 1), e.splice(t, 0, n), this._columns = e, this._justDroppedColId = n.id, setTimeout(() => {
|
|
588
589
|
this._justDroppedColId = null, this.theadEl.querySelectorAll(".pdg-th.pdg-drop-success").forEach((r) => {
|
|
589
590
|
r.classList.remove("pdg-drop-success");
|
|
590
591
|
});
|
|
591
|
-
}, 600), this.announceLive(`Moved column ${
|
|
592
|
+
}, 600), this.announceLive(`Moved column ${n.header} to position ${t + 1} of ${e.length}.`), this.dispatchGridEvent("pdg:column-reorder", {
|
|
592
593
|
fromIndex: i,
|
|
593
594
|
toIndex: t,
|
|
594
|
-
column:
|
|
595
|
+
column: n,
|
|
595
596
|
columns: e
|
|
596
597
|
}), this.render();
|
|
597
598
|
}
|
|
@@ -603,12 +604,12 @@ class T extends HTMLElement {
|
|
|
603
604
|
handleSortClick(i) {
|
|
604
605
|
if (this._options.sorting === !1) return;
|
|
605
606
|
const t = this._sortCriteria.findIndex((e) => e.columnId === i);
|
|
606
|
-
let
|
|
607
|
+
let n = "asc";
|
|
607
608
|
if (t > -1) {
|
|
608
609
|
const e = this._sortCriteria[t];
|
|
609
|
-
e.direction === "asc" ?
|
|
610
|
+
e.direction === "asc" ? n = "desc" : e.direction === "desc" && (n = null);
|
|
610
611
|
}
|
|
611
|
-
this._options.multiSort ?
|
|
612
|
+
this._options.multiSort ? n === null ? this._sortCriteria.splice(t, 1) : t > -1 ? this._sortCriteria[t].direction = n : this._sortCriteria.push({ columnId: i, direction: n }) : this._sortCriteria = n ? [{ columnId: i, direction: n }] : [], this.dispatchGridEvent("pdg:sort", { criteria: [...this._sortCriteria] }), this._options.serverSide ? this.triggerServerLoad(!1) : this.render();
|
|
612
613
|
}
|
|
613
614
|
renderBody() {
|
|
614
615
|
if (y(this.tbodyEl), this._isLoading && this._isInitialLoad && !this._options.keepPreviousDataWhileLoading) {
|
|
@@ -617,35 +618,35 @@ class T extends HTMLElement {
|
|
|
617
618
|
}
|
|
618
619
|
const { processed: i, totalFilteredCount: t } = this.getProcessedData();
|
|
619
620
|
if (i.length === 0) {
|
|
620
|
-
const r = l("tr", "pdg-row pdg-row-empty"), o = this._columns.length + (this._options.selectable ? 1 : 0) + (this._options.expandable ? 1 : 0) + (this._options.rowReordering ? 1 : 0) + (this._options.deletable ? 1 : 0),
|
|
621
|
-
|
|
621
|
+
const r = l("tr", "pdg-row pdg-row-empty"), o = this._columns.length + (this._options.selectable ? 1 : 0) + (this._options.expandable ? 1 : 0) + (this._options.rowReordering ? 1 : 0) + (this._options.deletable ? 1 : 0), s = l("td", "pdg-td", { colspan: o });
|
|
622
|
+
s.style.textAlign = "center", s.textContent = this._options.emptyMessage || "No matching records found.", r.appendChild(s), this.tbodyEl.appendChild(r);
|
|
622
623
|
return;
|
|
623
624
|
}
|
|
624
|
-
let
|
|
625
|
+
let n = [];
|
|
625
626
|
if (this._options.virtualize) {
|
|
626
|
-
const r = this._options.rowHeight || 48, o = this.tableContainerEl.clientHeight || 400,
|
|
627
|
-
|
|
627
|
+
const r = this._options.rowHeight || 48, o = this.tableContainerEl.clientHeight || 400, s = this.tableContainerEl.scrollTop, { startIndex: a, endIndex: d, topOffset: c, totalHeight: h } = P(
|
|
628
|
+
s,
|
|
628
629
|
o,
|
|
629
630
|
i.length,
|
|
630
631
|
r
|
|
631
632
|
);
|
|
632
|
-
|
|
633
|
+
n = i.slice(a, d + 1), this.virtualSpacerEl || (this.virtualSpacerEl = l("div", "pdg-virtual-spacer"), this.tableContainerEl.appendChild(this.virtualSpacerEl)), this.virtualSpacerEl.style.height = `${h}px`, this.tableEl.style.transform = `translateY(${c}px)`;
|
|
633
634
|
} else if (this._options.serverSide)
|
|
634
|
-
|
|
635
|
+
n = i;
|
|
635
636
|
else if (this._options.pagination === !1)
|
|
636
|
-
|
|
637
|
+
n = i, this._pagination.totalPages = 1, this._pagination.totalRows = t;
|
|
637
638
|
else {
|
|
638
639
|
const { pagedRows: r, totalPages: o } = A(
|
|
639
640
|
i,
|
|
640
641
|
this._pagination.pageIndex,
|
|
641
642
|
this._pagination.pageSize
|
|
642
643
|
);
|
|
643
|
-
|
|
644
|
+
n = r, this._pagination.totalPages = o, this._pagination.totalRows = t;
|
|
644
645
|
}
|
|
645
646
|
const e = this._options.rowReordering && (!this._sortCriteria.length || this._options.allowRowReorderWhenSorted);
|
|
646
|
-
for (let r = 0; r <
|
|
647
|
-
const o =
|
|
648
|
-
if (h.setAttribute("data-row-id", String(
|
|
647
|
+
for (let r = 0; r < n.length; r++) {
|
|
648
|
+
const o = n[r], s = this.getRowId(o), a = this._selectedIds.has(s), d = this._expandedIds.has(s), c = this._justDroppedRowId === s, h = l("tr", `pdg-row ${a ? "pdg-row-selected" : ""} ${c ? "pdg-drop-success" : ""}`);
|
|
649
|
+
if (h.setAttribute("data-row-id", String(s)), this._options.rowReordering) {
|
|
649
650
|
const g = l("td", "pdg-td pdg-td-drag");
|
|
650
651
|
if (e) {
|
|
651
652
|
const p = l("span", "pdg-drag-handle", {
|
|
@@ -676,11 +677,11 @@ class T extends HTMLElement {
|
|
|
676
677
|
if (h.classList.remove("pdg-drag-over-top", "pdg-drag-over-bottom", "pdg-drag-not-allowed", "pdg-row-dragging"), m != null && m !== r) {
|
|
677
678
|
const v = h.getBoundingClientRect();
|
|
678
679
|
let w = u.clientY - v.top < v.height / 2 ? r : r + 1;
|
|
679
|
-
m < w && w--, w = Math.max(0, Math.min(w,
|
|
680
|
+
m < w && w--, w = Math.max(0, Math.min(w, n.length - 1)), w !== m && this.reorderRow(m, w);
|
|
680
681
|
}
|
|
681
682
|
this._draggedRowIndex = null;
|
|
682
683
|
}), p.addEventListener("keydown", (u) => {
|
|
683
|
-
u.key === "ArrowUp" && r > 0 ? (u.preventDefault(), this.reorderRow(r, r - 1)) : u.key === "ArrowDown" && r <
|
|
684
|
+
u.key === "ArrowUp" && r > 0 ? (u.preventDefault(), this.reorderRow(r, r - 1)) : u.key === "ArrowDown" && r < n.length - 1 && (u.preventDefault(), this.reorderRow(r, r + 1));
|
|
684
685
|
}), g.appendChild(p);
|
|
685
686
|
} else
|
|
686
687
|
g.title = "Row reordering is disabled while active sort is applied.";
|
|
@@ -689,10 +690,10 @@ class T extends HTMLElement {
|
|
|
689
690
|
if (this._options.selectable) {
|
|
690
691
|
const g = l("td", "pdg-td pdg-td-select"), p = l("input", "pdg-checkbox", {
|
|
691
692
|
type: "checkbox",
|
|
692
|
-
"aria-label": `Select row ${
|
|
693
|
+
"aria-label": `Select row ${s}`
|
|
693
694
|
});
|
|
694
695
|
p.checked = a, p.addEventListener("change", () => {
|
|
695
|
-
this._options.multiSelect || this._selectedIds.clear(), p.checked ? this._selectedIds.add(
|
|
696
|
+
this._options.multiSelect || this._selectedIds.clear(), p.checked ? this._selectedIds.add(s) : this._selectedIds.delete(s), this.dispatchSelection(), this.render();
|
|
696
697
|
}), g.appendChild(p), h.appendChild(g);
|
|
697
698
|
}
|
|
698
699
|
if (this._options.expandable) {
|
|
@@ -701,8 +702,8 @@ class T extends HTMLElement {
|
|
|
701
702
|
"aria-label": d ? "Collapse row" : "Expand row"
|
|
702
703
|
});
|
|
703
704
|
p.textContent = d ? "▼" : "▶", p.addEventListener("click", () => {
|
|
704
|
-
d ? this._expandedIds.delete(
|
|
705
|
-
rowId:
|
|
705
|
+
d ? this._expandedIds.delete(s) : this._expandedIds.add(s), this.dispatchGridEvent("pdg:row-expand", {
|
|
706
|
+
rowId: s,
|
|
706
707
|
expanded: !d,
|
|
707
708
|
row: o
|
|
708
709
|
}), this.renderBody();
|
|
@@ -711,10 +712,10 @@ class T extends HTMLElement {
|
|
|
711
712
|
for (const g of this._columns) {
|
|
712
713
|
if (g.visible === !1) continue;
|
|
713
714
|
const p = l("td", "pdg-td", { "data-header": g.header }), u = C(o, g.field);
|
|
714
|
-
if (this._editingCell && this._editingCell.rowId ===
|
|
715
|
+
if (this._editingCell && this._editingCell.rowId === s && this._editingCell.columnId === g.id)
|
|
715
716
|
p.classList.add("pdg-cell-editing"), this.renderCellEditor(p, o, g, u);
|
|
716
|
-
else if (this._options.editable && g.editable !== !1 && (p.classList.add("pdg-cell-editable"), p.setAttribute("tabindex", "0"), p.setAttribute("aria-label", `${g.header}: ${u}. Double click or press Enter to edit`), p.addEventListener("dblclick", () => this.startCellEdit(
|
|
717
|
-
E.key === "Enter" && (E.preventDefault(), this.startCellEdit(
|
|
717
|
+
else if (this._options.editable && g.editable !== !1 && (p.classList.add("pdg-cell-editable"), p.setAttribute("tabindex", "0"), p.setAttribute("aria-label", `${g.header}: ${u}. Double click or press Enter to edit`), p.addEventListener("dblclick", () => this.startCellEdit(s, g.id, o, u)), p.addEventListener("keydown", (E) => {
|
|
718
|
+
E.key === "Enter" && (E.preventDefault(), this.startCellEdit(s, g.id, o, u));
|
|
718
719
|
})), g.renderer) {
|
|
719
720
|
const E = g.renderer(u, o, r);
|
|
720
721
|
typeof E == "string" ? p.innerHTML = E : p.appendChild(E);
|
|
@@ -724,10 +725,10 @@ class T extends HTMLElement {
|
|
|
724
725
|
if (this._options.deletable) {
|
|
725
726
|
const g = l("td", "pdg-td pdg-td-actions"), p = l("button", "pdg-btn pdg-btn-sm pdg-btn-danger", {
|
|
726
727
|
type: "button",
|
|
727
|
-
"aria-label": `Delete row ${
|
|
728
|
+
"aria-label": `Delete row ${s}`
|
|
728
729
|
});
|
|
729
730
|
p.textContent = "✕", p.addEventListener("click", (u) => {
|
|
730
|
-
u.stopPropagation(), this.handleDeleteRow(
|
|
731
|
+
u.stopPropagation(), this.handleDeleteRow(s, o);
|
|
731
732
|
}), g.appendChild(p), h.appendChild(g);
|
|
732
733
|
}
|
|
733
734
|
if (this.tbodyEl.appendChild(h), this._options.expandable && d && this._options.rowDetailRenderer) {
|
|
@@ -737,9 +738,9 @@ class T extends HTMLElement {
|
|
|
737
738
|
}
|
|
738
739
|
}
|
|
739
740
|
reorderRow(i, t) {
|
|
740
|
-
const
|
|
741
|
-
e.splice(i, 1), e.splice(t, 0,
|
|
742
|
-
const r = this.getRowId(
|
|
741
|
+
const n = this._rows[i], e = [...this._rows];
|
|
742
|
+
e.splice(i, 1), e.splice(t, 0, n), this._rows = e;
|
|
743
|
+
const r = this.getRowId(n);
|
|
743
744
|
this._justDroppedRowId = r, setTimeout(() => {
|
|
744
745
|
this._justDroppedRowId = null, this.tbodyEl.querySelectorAll(".pdg-row.pdg-drop-success").forEach((o) => {
|
|
745
746
|
o.classList.remove("pdg-drop-success");
|
|
@@ -747,28 +748,28 @@ class T extends HTMLElement {
|
|
|
747
748
|
}, 600), this.announceLive(`Moved row ${i + 1} to position ${t + 1} of ${e.length}.`), this.dispatchGridEvent("pdg:row-reorder", {
|
|
748
749
|
fromIndex: i,
|
|
749
750
|
toIndex: t,
|
|
750
|
-
row:
|
|
751
|
+
row: n,
|
|
751
752
|
rows: e
|
|
752
753
|
}), this.render();
|
|
753
754
|
}
|
|
754
755
|
// --- In-place Cell Editing Logic ---
|
|
755
|
-
startCellEdit(i, t,
|
|
756
|
+
startCellEdit(i, t, n, e) {
|
|
756
757
|
this._editingCell = { rowId: i, columnId: t, initialValue: e }, this.dispatchGridEvent("pdg:edit-start", {
|
|
757
758
|
rowId: i,
|
|
758
759
|
columnId: t,
|
|
759
|
-
row:
|
|
760
|
+
row: n,
|
|
760
761
|
value: e
|
|
761
762
|
}), this.render();
|
|
762
763
|
}
|
|
763
|
-
renderCellEditor(i, t,
|
|
764
|
+
renderCellEditor(i, t, n, e) {
|
|
764
765
|
const r = l("div", "pdg-edit-container");
|
|
765
|
-
if (
|
|
766
|
-
const a =
|
|
766
|
+
if (n.customEditor) {
|
|
767
|
+
const a = n.customEditor({
|
|
767
768
|
value: e,
|
|
768
769
|
row: t,
|
|
769
|
-
column:
|
|
770
|
-
onCommit: (d) => this.saveCellEdit(t,
|
|
771
|
-
onCancel: () => this.cancelCellEdit(t,
|
|
770
|
+
column: n,
|
|
771
|
+
onCommit: (d) => this.saveCellEdit(t, n, d),
|
|
772
|
+
onCancel: () => this.cancelCellEdit(t, n)
|
|
772
773
|
});
|
|
773
774
|
r.appendChild(a), i.appendChild(r);
|
|
774
775
|
return;
|
|
@@ -776,62 +777,62 @@ class T extends HTMLElement {
|
|
|
776
777
|
const o = l("input", "pdg-edit-input", {
|
|
777
778
|
type: typeof e == "number" ? "number" : "text",
|
|
778
779
|
value: e == null ? "" : String(e)
|
|
779
|
-
}),
|
|
780
|
-
|
|
780
|
+
}), s = l("span", "pdg-edit-error-msg");
|
|
781
|
+
s.style.display = "none", o.addEventListener("keydown", (a) => {
|
|
781
782
|
if (a.key === "Enter") {
|
|
782
783
|
a.preventDefault();
|
|
783
|
-
const d = typeof e == "number" ? Number(o.value) : o.value, c =
|
|
784
|
+
const d = typeof e == "number" ? Number(o.value) : o.value, c = n.validator ? n.validator(d, e, t, n) : null;
|
|
784
785
|
if (c) {
|
|
785
|
-
|
|
786
|
+
s.textContent = c, s.style.display = "block", this.dispatchGridEvent("pdg:edit-validation-error", {
|
|
786
787
|
rowId: this.getRowId(t),
|
|
787
|
-
columnId:
|
|
788
|
+
columnId: n.id,
|
|
788
789
|
row: t,
|
|
789
790
|
error: c,
|
|
790
791
|
invalidValue: d
|
|
791
792
|
});
|
|
792
793
|
return;
|
|
793
794
|
}
|
|
794
|
-
this.saveCellEdit(t,
|
|
795
|
-
} else a.key === "Escape" && (a.preventDefault(), this.cancelCellEdit(t,
|
|
795
|
+
this.saveCellEdit(t, n, d);
|
|
796
|
+
} else a.key === "Escape" && (a.preventDefault(), this.cancelCellEdit(t, n));
|
|
796
797
|
}), o.addEventListener("blur", () => {
|
|
797
798
|
const a = typeof e == "number" ? Number(o.value) : o.value;
|
|
798
|
-
if (
|
|
799
|
-
this.cancelCellEdit(t,
|
|
799
|
+
if (n.validator && n.validator(a, e, t, n)) {
|
|
800
|
+
this.cancelCellEdit(t, n);
|
|
800
801
|
return;
|
|
801
802
|
}
|
|
802
|
-
this.saveCellEdit(t,
|
|
803
|
-
}), r.appendChild(o), r.appendChild(
|
|
803
|
+
this.saveCellEdit(t, n, a);
|
|
804
|
+
}), r.appendChild(o), r.appendChild(s), i.appendChild(r), requestAnimationFrame(() => {
|
|
804
805
|
o.focus(), o.select();
|
|
805
806
|
});
|
|
806
807
|
}
|
|
807
808
|
cancelCellEdit(i, t) {
|
|
808
809
|
if (!this._editingCell) return;
|
|
809
|
-
const { rowId:
|
|
810
|
+
const { rowId: n, initialValue: e } = this._editingCell;
|
|
810
811
|
this._editingCell = null, this.dispatchGridEvent("pdg:edit-cancel", {
|
|
811
|
-
rowId:
|
|
812
|
+
rowId: n,
|
|
812
813
|
columnId: t.id,
|
|
813
814
|
row: i,
|
|
814
815
|
value: e
|
|
815
816
|
}), this.render();
|
|
816
817
|
}
|
|
817
|
-
saveCellEdit(i, t,
|
|
818
|
+
saveCellEdit(i, t, n) {
|
|
818
819
|
if (!this._editingCell) return;
|
|
819
820
|
const e = this._editingCell.initialValue, r = this._editingCell.rowId;
|
|
820
821
|
if (this._editingCell = null, t.field) {
|
|
821
822
|
const o = String(t.field);
|
|
822
823
|
if (o !== "__proto__" && o !== "constructor" && o !== "prototype")
|
|
823
824
|
if (!o.includes("."))
|
|
824
|
-
i[o] =
|
|
825
|
+
i[o] = n;
|
|
825
826
|
else {
|
|
826
|
-
const
|
|
827
|
+
const s = o.split(".");
|
|
827
828
|
let a = i;
|
|
828
|
-
for (let c = 0; c <
|
|
829
|
-
const h =
|
|
829
|
+
for (let c = 0; c < s.length - 1; c++) {
|
|
830
|
+
const h = s[c];
|
|
830
831
|
if (h === "__proto__" || h === "constructor" || h === "prototype") break;
|
|
831
832
|
(a[h] == null || typeof a[h] != "object") && (a[h] = {}), a = a[h];
|
|
832
833
|
}
|
|
833
|
-
const d =
|
|
834
|
-
d !== "__proto__" && d !== "constructor" && d !== "prototype" && (a[d] =
|
|
834
|
+
const d = s[s.length - 1];
|
|
835
|
+
d !== "__proto__" && d !== "constructor" && d !== "prototype" && (a[d] = n);
|
|
835
836
|
}
|
|
836
837
|
}
|
|
837
838
|
for (const o of this._columns)
|
|
@@ -845,7 +846,7 @@ class T extends HTMLElement {
|
|
|
845
846
|
columnId: t.id,
|
|
846
847
|
row: i,
|
|
847
848
|
oldValue: e,
|
|
848
|
-
newValue:
|
|
849
|
+
newValue: n
|
|
849
850
|
}), this.render();
|
|
850
851
|
}
|
|
851
852
|
// --- Deletion Logic ---
|
|
@@ -854,28 +855,28 @@ class T extends HTMLElement {
|
|
|
854
855
|
const e = this._options.deleteConfirmMessage ? this._options.deleteConfirmMessage(t) : "Are you sure you want to delete this record?";
|
|
855
856
|
if (!window.confirm(e)) return;
|
|
856
857
|
}
|
|
857
|
-
const
|
|
858
|
-
this._rows = this._rows.filter((e) => e[
|
|
858
|
+
const n = this._options.rowIdKey || "id";
|
|
859
|
+
this._rows = this._rows.filter((e) => e[n] !== i), this._selectedIds.delete(i), this._expandedIds.delete(i), this.dispatchGridEvent("pdg:delete", { rowId: i, row: t }), this.render();
|
|
859
860
|
}
|
|
860
861
|
// --- Loading Skeleton View ---
|
|
861
862
|
renderLoadingSkeletons() {
|
|
862
863
|
const i = this._options.skeletonCount || 5, t = this._columns.length + (this._options.selectable ? 1 : 0) + (this._options.expandable ? 1 : 0) + (this._options.rowReordering ? 1 : 0) + (this._options.deletable ? 1 : 0);
|
|
863
|
-
for (let
|
|
864
|
+
for (let n = 0; n < i; n++) {
|
|
864
865
|
const e = l("tr", "pdg-row pdg-skeleton-row");
|
|
865
866
|
for (let r = 0; r < t; r++) {
|
|
866
|
-
const o = l("td", "pdg-td"),
|
|
867
|
-
o.appendChild(
|
|
867
|
+
const o = l("td", "pdg-td"), s = l("div", "pdg-skeleton-cell");
|
|
868
|
+
o.appendChild(s), e.appendChild(o);
|
|
868
869
|
}
|
|
869
870
|
this.tbodyEl.appendChild(e);
|
|
870
871
|
}
|
|
871
872
|
}
|
|
872
873
|
renderFooter() {
|
|
873
874
|
if (y(this.footerEl), this._options.pagination === !1) return;
|
|
874
|
-
const i = l("div", "pdg-pagination-info"), t = this._pagination.totalRows,
|
|
875
|
+
const i = l("div", "pdg-pagination-info"), t = this._pagination.totalRows, n = t > 0 ? this._pagination.pageIndex * this._pagination.pageSize + 1 : 0, e = Math.min(
|
|
875
876
|
(this._pagination.pageIndex + 1) * this._pagination.pageSize,
|
|
876
877
|
t
|
|
877
878
|
);
|
|
878
|
-
i.textContent = `Showing ${
|
|
879
|
+
i.textContent = `Showing ${n} to ${e} of ${t} entries (Page ${this._pagination.pageIndex + 1} of ${this._pagination.totalPages})`;
|
|
879
880
|
const r = l("div", "pdg-pagination-controls"), o = l("button", "pdg-btn pdg-btn-sm", {
|
|
880
881
|
type: "button",
|
|
881
882
|
title: "First Page",
|
|
@@ -884,14 +885,14 @@ class T extends HTMLElement {
|
|
|
884
885
|
o.textContent = "«", o.addEventListener("click", () => {
|
|
885
886
|
this._pagination.pageIndex > 0 && this.goToPage(0);
|
|
886
887
|
}), r.appendChild(o);
|
|
887
|
-
const
|
|
888
|
+
const s = l("button", "pdg-btn pdg-btn-sm", {
|
|
888
889
|
type: "button",
|
|
889
890
|
title: "Previous Page",
|
|
890
891
|
disabled: this._pagination.pageIndex === 0
|
|
891
892
|
});
|
|
892
|
-
|
|
893
|
+
s.textContent = "‹ Prev", s.addEventListener("click", () => {
|
|
893
894
|
this._pagination.pageIndex > 0 && this.goToPage(this._pagination.pageIndex - 1);
|
|
894
|
-
}), r.appendChild(
|
|
895
|
+
}), r.appendChild(s);
|
|
895
896
|
const a = this._pagination.totalPages, d = this._pagination.pageIndex, c = 2;
|
|
896
897
|
for (let m = 0; m < a; m++)
|
|
897
898
|
if (m === 0 || m === a - 1 || m >= d - c && m <= d + c) {
|
|
@@ -955,11 +956,11 @@ class T extends HTMLElement {
|
|
|
955
956
|
getSelectedRowsTSV() {
|
|
956
957
|
const i = this.getSelectedRows();
|
|
957
958
|
if (i.length === 0) return "";
|
|
958
|
-
const t = this._columns.filter((r) => r.visible !== !1 && r.field),
|
|
959
|
-
let
|
|
960
|
-
return
|
|
959
|
+
const t = this._columns.filter((r) => r.visible !== !1 && r.field), n = t.map((r) => r.header).join(" "), e = i.map((r) => t.map((o) => {
|
|
960
|
+
let s = C(r, o.field);
|
|
961
|
+
return s == null ? "" : String(s).replace(/[\t\r\n]+/g, " ");
|
|
961
962
|
}).join(" "));
|
|
962
|
-
return [
|
|
963
|
+
return [n, ...e].join(`\r
|
|
963
964
|
`);
|
|
964
965
|
}
|
|
965
966
|
async copySelectionToClipboard() {
|
|
@@ -980,8 +981,8 @@ class T extends HTMLElement {
|
|
|
980
981
|
batchUpdateSelected(i) {
|
|
981
982
|
if (!i || Object.keys(i).length === 0) return 0;
|
|
982
983
|
let t = 0;
|
|
983
|
-
return this._rows.forEach((
|
|
984
|
-
this._selectedIds.has(this.getRowId(
|
|
984
|
+
return this._rows.forEach((n) => {
|
|
985
|
+
this._selectedIds.has(this.getRowId(n)) && (Object.assign(n, i), t++);
|
|
985
986
|
}), t > 0 && this.render(), t;
|
|
986
987
|
}
|
|
987
988
|
/** Resets global search and all column filters, then reloads data. */
|