@rozie-ui/data-table-lit 0.2.7 → 0.3.1
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 -2
- package/dist/index.cjs +650 -299
- package/dist/index.d.cts +56 -15
- package/dist/index.d.mts +56 -15
- package/dist/index.mjs +650 -299
- package/package.json +2 -2
- package/src/DataTable.ts +1221 -435
- package/src/helpers/columnDefUtils.ts +35 -0
- package/src/helpers/indexMath.ts +25 -0
- package/src/helpers/rowValueUtils.ts +62 -0
- package/src/helpers/tsvGrid.ts +115 -0
package/dist/index.mjs
CHANGED
|
@@ -7,6 +7,163 @@ import { repeat } from "lit/directives/repeat.js";
|
|
|
7
7
|
import "@rozie-ui/popover-lit";
|
|
8
8
|
import { createTable, getCoreRowModel, getExpandedRowModel, getFacetedMinMaxValues, getFacetedRowModel, getFacetedUniqueValues, getFilteredRowModel, getGroupedRowModel, getPaginationRowModel, getSortedRowModel } from "@tanstack/table-core";
|
|
9
9
|
import { Virtualizer, elementScroll, measureElement, observeElementOffset, observeElementRect } from "@tanstack/virtual-core";
|
|
10
|
+
//#region src/helpers/columnDefUtils.ts
|
|
11
|
+
const isSafeKey = (k) => k !== "__proto__" && k !== "constructor" && k !== "prototype";
|
|
12
|
+
const wrapAggregationFn = (fn) => {
|
|
13
|
+
if (typeof fn === "string") return fn;
|
|
14
|
+
if (typeof fn !== "function") return void 0;
|
|
15
|
+
return (columnId, leafRows, childRows) => {
|
|
16
|
+
try {
|
|
17
|
+
return fn(columnId, leafRows, childRows);
|
|
18
|
+
} catch (err) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
//#endregion
|
|
24
|
+
//#region src/helpers/indexMath.ts
|
|
25
|
+
const clamp = (v, lo, hi) => v < lo ? lo : v > hi ? hi : v;
|
|
26
|
+
const focusables = (cellEl) => {
|
|
27
|
+
if (!cellEl || !cellEl.querySelectorAll) return [];
|
|
28
|
+
return Array.prototype.slice.call(cellEl.querySelectorAll("button,[href],input,select,textarea,[tabindex]:not([tabindex=\"-1\"])")).filter((n) => !n.disabled);
|
|
29
|
+
};
|
|
30
|
+
const applyUpdater = (updater, current) => typeof updater === "function" ? updater(current) : updater;
|
|
31
|
+
//#endregion
|
|
32
|
+
//#region src/helpers/tsvGrid.ts
|
|
33
|
+
const escapeTsvField = (s) => {
|
|
34
|
+
if (s.indexOf(" ") >= 0 || s.indexOf("\n") >= 0 || s.indexOf("\r") >= 0 || s.indexOf("\"") >= 0) return "\"" + s.replace(/"/g, "\"\"") + "\"";
|
|
35
|
+
return s;
|
|
36
|
+
};
|
|
37
|
+
const parseTsv = (text) => {
|
|
38
|
+
const str = text != null ? String(text) : "";
|
|
39
|
+
if (str === "" || str.length > 2e6) return [];
|
|
40
|
+
const rows = [];
|
|
41
|
+
let row = [];
|
|
42
|
+
let field = "";
|
|
43
|
+
let inQuotes = false;
|
|
44
|
+
let i = 0;
|
|
45
|
+
const n = str.length;
|
|
46
|
+
while (i < n) {
|
|
47
|
+
const ch = str[i];
|
|
48
|
+
if (inQuotes) {
|
|
49
|
+
if (ch === "\"") {
|
|
50
|
+
if (i + 1 < n && str[i + 1] === "\"") {
|
|
51
|
+
field = field + "\"";
|
|
52
|
+
i = i + 2;
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
inQuotes = false;
|
|
56
|
+
i = i + 1;
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
field = field + ch;
|
|
60
|
+
i = i + 1;
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
if (ch === "\"" && field === "") {
|
|
64
|
+
inQuotes = true;
|
|
65
|
+
i = i + 1;
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
if (ch === " ") {
|
|
69
|
+
row.push(field);
|
|
70
|
+
field = "";
|
|
71
|
+
i = i + 1;
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
if (ch === "\r") {
|
|
75
|
+
if (i + 1 < n && str[i + 1] === "\n") i = i + 1;
|
|
76
|
+
row.push(field);
|
|
77
|
+
field = "";
|
|
78
|
+
rows.push(row);
|
|
79
|
+
row = [];
|
|
80
|
+
i = i + 1;
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
if (ch === "\n") {
|
|
84
|
+
row.push(field);
|
|
85
|
+
field = "";
|
|
86
|
+
rows.push(row);
|
|
87
|
+
row = [];
|
|
88
|
+
i = i + 1;
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
field = field + ch;
|
|
92
|
+
i = i + 1;
|
|
93
|
+
}
|
|
94
|
+
row.push(field);
|
|
95
|
+
rows.push(row);
|
|
96
|
+
if (rows.length > 1) {
|
|
97
|
+
const last = rows[rows.length - 1];
|
|
98
|
+
if (last.length === 1 && last[0] === "") rows.pop();
|
|
99
|
+
}
|
|
100
|
+
return rows;
|
|
101
|
+
};
|
|
102
|
+
const tileGridToBox = (grid, box) => {
|
|
103
|
+
const srcRows = grid.length;
|
|
104
|
+
let srcCols = 0;
|
|
105
|
+
for (let i = 0; i < srcRows; i++) {
|
|
106
|
+
const w = grid[i] && grid[i].length ? grid[i].length : 0;
|
|
107
|
+
if (w > srcCols) srcCols = w;
|
|
108
|
+
}
|
|
109
|
+
if (srcRows <= 0 || srcCols <= 0) return grid;
|
|
110
|
+
const boxRows = box.r1 - box.r0 + 1;
|
|
111
|
+
const boxCols = box.c1 - box.c0 + 1;
|
|
112
|
+
const rows = boxRows > srcRows ? boxRows : srcRows;
|
|
113
|
+
const cols = boxCols > srcCols ? boxCols : srcCols;
|
|
114
|
+
const out = [];
|
|
115
|
+
for (let r = 0; r < rows; r++) {
|
|
116
|
+
const srcLine = grid[r % srcRows] || [];
|
|
117
|
+
const line = [];
|
|
118
|
+
for (let c = 0; c < cols; c++) {
|
|
119
|
+
const v = srcLine[c % srcCols];
|
|
120
|
+
line.push(v != null ? v : "");
|
|
121
|
+
}
|
|
122
|
+
out.push(line);
|
|
123
|
+
}
|
|
124
|
+
return out;
|
|
125
|
+
};
|
|
126
|
+
const tileIndex = (i, lo, hi) => {
|
|
127
|
+
const span = hi - lo + 1;
|
|
128
|
+
if (span <= 1) return lo;
|
|
129
|
+
let k = (i - lo) % span;
|
|
130
|
+
if (k < 0) k = k + span;
|
|
131
|
+
return lo + k;
|
|
132
|
+
};
|
|
133
|
+
//#endregion
|
|
134
|
+
//#region src/helpers/rowValueUtils.ts
|
|
135
|
+
const replaceRowValue = (rows, rowIndex, field, value) => {
|
|
136
|
+
const src = rows || [];
|
|
137
|
+
const out = [];
|
|
138
|
+
for (let i = 0; i < src.length; i++) if (i === rowIndex) out.push({
|
|
139
|
+
...src[i] || {},
|
|
140
|
+
[field]: value
|
|
141
|
+
});
|
|
142
|
+
else out.push(src[i]);
|
|
143
|
+
return out;
|
|
144
|
+
};
|
|
145
|
+
const replaceRowValues = (rows, rowIndex, fieldValues) => {
|
|
146
|
+
const src = rows || [];
|
|
147
|
+
const fv = fieldValues || {};
|
|
148
|
+
const out = [];
|
|
149
|
+
for (let i = 0; i < src.length; i++) if (i === rowIndex) out.push({
|
|
150
|
+
...src[i] || {},
|
|
151
|
+
...fv
|
|
152
|
+
});
|
|
153
|
+
else out.push(src[i]);
|
|
154
|
+
return out;
|
|
155
|
+
};
|
|
156
|
+
const indexOfRowIn = (rows, rowOriginal, rowId) => {
|
|
157
|
+
const list = rows || [];
|
|
158
|
+
for (let i = 0; i < list.length; i++) {
|
|
159
|
+
const r = list[i];
|
|
160
|
+
if (!r) continue;
|
|
161
|
+
if (rowId != null && r.id === rowId) return i;
|
|
162
|
+
if (rowOriginal != null && r.original === rowOriginal) return i;
|
|
163
|
+
}
|
|
164
|
+
return -1;
|
|
165
|
+
};
|
|
166
|
+
//#endregion
|
|
10
167
|
//#region \0@oxc-project+runtime@0.127.0/helpers/decorate.js
|
|
11
168
|
function __decorate(decorators, target, key, desc) {
|
|
12
169
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -130,6 +287,7 @@ let DataTable = class DataTable extends SignalWatcher(LitElement) {
|
|
|
130
287
|
this.undoLimit = 100;
|
|
131
288
|
this.virtual = false;
|
|
132
289
|
this.estimateRowHeight = 40;
|
|
290
|
+
this.autoMeasure = false;
|
|
133
291
|
this.maxHeight = "";
|
|
134
292
|
this._dataDefault = signal([]);
|
|
135
293
|
this._sortingDefault = signal([]);
|
|
@@ -217,7 +375,11 @@ let DataTable = class DataTable extends SignalWatcher(LitElement) {
|
|
|
217
375
|
this.virtualizer = null;
|
|
218
376
|
this.virtualizerCleanup = null;
|
|
219
377
|
this.gridScrollEl = null;
|
|
378
|
+
this.colVirtualizer = null;
|
|
379
|
+
this.colVirtualizerCleanup = null;
|
|
220
380
|
this.remeasurePending = false;
|
|
381
|
+
this.remeasureRaf = null;
|
|
382
|
+
this.remeasureDisposed = false;
|
|
221
383
|
this.GRID_PAGE_STEP = 10;
|
|
222
384
|
this.gridRoot = null;
|
|
223
385
|
this.programmatic = 0;
|
|
@@ -255,18 +417,6 @@ let DataTable = class DataTable extends SignalWatcher(LitElement) {
|
|
|
255
417
|
columnSizingInfo: this._columnSizingInfo.value
|
|
256
418
|
});
|
|
257
419
|
this.currentData = () => this.data != null ? this.data : this._dataDefault.value;
|
|
258
|
-
this.isSafeKey = (k) => k !== "__proto__" && k !== "constructor" && k !== "prototype";
|
|
259
|
-
this.wrapAggregationFn = (fn) => {
|
|
260
|
-
if (typeof fn === "string") return fn;
|
|
261
|
-
if (typeof fn !== "function") return void 0;
|
|
262
|
-
return (columnId, leafRows, childRows) => {
|
|
263
|
-
try {
|
|
264
|
-
return fn(columnId, leafRows, childRows);
|
|
265
|
-
} catch (err) {
|
|
266
|
-
return;
|
|
267
|
-
}
|
|
268
|
-
};
|
|
269
|
-
};
|
|
270
420
|
this.buildConfigDef = (c) => {
|
|
271
421
|
if (!c) return null;
|
|
272
422
|
if (Array.isArray(c.columns)) {
|
|
@@ -280,7 +430,7 @@ let DataTable = class DataTable extends SignalWatcher(LitElement) {
|
|
|
280
430
|
if (gid == null) gid = c.header != null ? "__grp_" + kids.map((k) => k.id).join("_") : null;
|
|
281
431
|
if (gid == null) return null;
|
|
282
432
|
const id = String(gid);
|
|
283
|
-
if (!
|
|
433
|
+
if (!isSafeKey(id)) return null;
|
|
284
434
|
return {
|
|
285
435
|
id,
|
|
286
436
|
header: c.header != null ? c.header : id,
|
|
@@ -290,7 +440,7 @@ let DataTable = class DataTable extends SignalWatcher(LitElement) {
|
|
|
290
440
|
const rawId = c.id != null ? c.id : c.field;
|
|
291
441
|
if (rawId == null) return null;
|
|
292
442
|
const id = String(rawId);
|
|
293
|
-
if (!
|
|
443
|
+
if (!isSafeKey(id)) return null;
|
|
294
444
|
return {
|
|
295
445
|
id,
|
|
296
446
|
accessorKey: c.field != null ? c.field : id,
|
|
@@ -300,7 +450,7 @@ let DataTable = class DataTable extends SignalWatcher(LitElement) {
|
|
|
300
450
|
filterable: c.filterable === true,
|
|
301
451
|
expandable: c.expandable === true,
|
|
302
452
|
groupable: c.groupable !== false,
|
|
303
|
-
aggregationFn:
|
|
453
|
+
aggregationFn: wrapAggregationFn(c.aggregationFn),
|
|
304
454
|
pinned: c.pinned != null ? c.pinned : "",
|
|
305
455
|
width: c.width != null ? c.width : "",
|
|
306
456
|
meta: {
|
|
@@ -311,10 +461,15 @@ let DataTable = class DataTable extends SignalWatcher(LitElement) {
|
|
|
311
461
|
}
|
|
312
462
|
};
|
|
313
463
|
};
|
|
464
|
+
this.columnDefsCache = null;
|
|
465
|
+
this.columnDefsCacheColumnsRef = void 0;
|
|
466
|
+
this.columnDefsCacheColRegRef = void 0;
|
|
314
467
|
this.columnDefs = () => {
|
|
468
|
+
const cfg = this.columns || [];
|
|
469
|
+
const reg = this._colReg.value || {};
|
|
470
|
+
if (this.columnDefsCache && this.columns === this.columnDefsCacheColumnsRef && this._colReg.value === this.columnDefsCacheColRegRef) return this.columnDefsCache;
|
|
315
471
|
const byId = Object.create(null);
|
|
316
472
|
const order = [];
|
|
317
|
-
const cfg = this.columns || [];
|
|
318
473
|
for (const c of cfg) {
|
|
319
474
|
const def = this.buildConfigDef(c);
|
|
320
475
|
if (!def) continue;
|
|
@@ -322,9 +477,8 @@ let DataTable = class DataTable extends SignalWatcher(LitElement) {
|
|
|
322
477
|
if (!(id in byId)) order.push(id);
|
|
323
478
|
byId[id] = def;
|
|
324
479
|
}
|
|
325
|
-
const reg = this._colReg.value || {};
|
|
326
480
|
for (const id in reg) {
|
|
327
|
-
if (!
|
|
481
|
+
if (!isSafeKey(id)) continue;
|
|
328
482
|
const spec = reg[id];
|
|
329
483
|
if (!spec) continue;
|
|
330
484
|
if (!(id in byId)) order.push(id);
|
|
@@ -337,7 +491,7 @@ let DataTable = class DataTable extends SignalWatcher(LitElement) {
|
|
|
337
491
|
filterable: spec.filterable === true,
|
|
338
492
|
expandable: spec.expandable === true,
|
|
339
493
|
groupable: spec.groupable !== false,
|
|
340
|
-
aggregationFn:
|
|
494
|
+
aggregationFn: wrapAggregationFn(spec.aggregationFn),
|
|
341
495
|
pinned: spec.pinned != null ? spec.pinned : "",
|
|
342
496
|
width: spec.width != null ? spec.width : "",
|
|
343
497
|
meta: {
|
|
@@ -350,6 +504,9 @@ let DataTable = class DataTable extends SignalWatcher(LitElement) {
|
|
|
350
504
|
}
|
|
351
505
|
const out = [];
|
|
352
506
|
for (const id of order) if (byId[id]) out.push(byId[id]);
|
|
507
|
+
this.columnDefsCache = out;
|
|
508
|
+
this.columnDefsCacheColumnsRef = this.columns;
|
|
509
|
+
this.columnDefsCacheColRegRef = this._colReg.value;
|
|
353
510
|
return out;
|
|
354
511
|
};
|
|
355
512
|
this.SELECT_COL_ID = "__rdt_select";
|
|
@@ -392,7 +549,6 @@ let DataTable = class DataTable extends SignalWatcher(LitElement) {
|
|
|
392
549
|
}));
|
|
393
550
|
this.programmatic--;
|
|
394
551
|
};
|
|
395
|
-
this.applyUpdater = (updater, current) => typeof updater === "function" ? updater(current) : updater;
|
|
396
552
|
this.writeExpanded = (next) => {
|
|
397
553
|
if (this.programmatic) return;
|
|
398
554
|
this.programmatic++;
|
|
@@ -604,48 +760,101 @@ let DataTable = class DataTable extends SignalWatcher(LitElement) {
|
|
|
604
760
|
};
|
|
605
761
|
this.refreshRowModel = null;
|
|
606
762
|
this.onSortingChangeCb = (updater) => {
|
|
607
|
-
this.writeSorting(
|
|
763
|
+
this.writeSorting(applyUpdater(updater, this.currentState().sorting));
|
|
608
764
|
};
|
|
609
765
|
this.onExpandedChangeCb = (updater) => {
|
|
610
|
-
this.writeExpanded(
|
|
766
|
+
this.writeExpanded(applyUpdater(updater, this.currentState().expanded));
|
|
611
767
|
};
|
|
612
768
|
this.onGroupingChangeCb = (updater) => {
|
|
613
|
-
this.writeGrouping(
|
|
769
|
+
this.writeGrouping(applyUpdater(updater, this.currentState().grouping));
|
|
614
770
|
};
|
|
615
771
|
this.onGlobalFilterChangeCb = (updater) => {
|
|
616
|
-
this.writeGlobalFilter(
|
|
772
|
+
this.writeGlobalFilter(applyUpdater(updater, this.currentState().globalFilter));
|
|
617
773
|
};
|
|
618
774
|
this.onColumnFiltersChangeCb = (updater) => {
|
|
619
|
-
this.writeColumnFilters(
|
|
775
|
+
this.writeColumnFilters(applyUpdater(updater, this.currentState().columnFilters));
|
|
620
776
|
};
|
|
621
777
|
this.onPaginationChangeCb = (updater) => {
|
|
622
|
-
this.writePagination(
|
|
778
|
+
this.writePagination(applyUpdater(updater, this.currentState().pagination));
|
|
623
779
|
};
|
|
624
780
|
this.onRowSelectionChangeCb = (updater) => {
|
|
625
|
-
this.writeRowSelection(
|
|
781
|
+
this.writeRowSelection(applyUpdater(updater, this.currentState().rowSelection));
|
|
626
782
|
};
|
|
627
783
|
this.onColumnVisibilityChangeCb = (updater) => {
|
|
628
|
-
this.writeColumnVisibility(
|
|
784
|
+
this.writeColumnVisibility(applyUpdater(updater, this.currentState().columnVisibility));
|
|
629
785
|
};
|
|
630
786
|
this.onColumnSizingChangeCb = (updater) => {
|
|
631
|
-
this.writeColumnSizing(
|
|
787
|
+
this.writeColumnSizing(applyUpdater(updater, this.currentState().columnSizing));
|
|
632
788
|
};
|
|
633
789
|
this.onColumnOrderChangeCb = (updater) => {
|
|
634
|
-
this.writeColumnOrder(
|
|
790
|
+
this.writeColumnOrder(applyUpdater(updater, this.currentState().columnOrder));
|
|
635
791
|
};
|
|
636
792
|
this.onColumnPinningChangeCb = (updater) => {
|
|
637
|
-
this.writeColumnPinning(
|
|
793
|
+
this.writeColumnPinning(applyUpdater(updater, this.currentState().columnPinning));
|
|
638
794
|
};
|
|
639
795
|
this.onColumnSizingInfoChangeCb = (updater) => {
|
|
640
|
-
const next =
|
|
796
|
+
const next = applyUpdater(updater, this._columnSizingInfo.value);
|
|
641
797
|
this._columnSizingInfo.value = next != null ? next : this._columnSizingInfo.value;
|
|
642
798
|
};
|
|
799
|
+
this.resolveVirtual = () => {
|
|
800
|
+
const v = this.virtual;
|
|
801
|
+
if (typeof v === "string") {
|
|
802
|
+
if (v === "rows") return "rows";
|
|
803
|
+
if (v === "columns") return "columns";
|
|
804
|
+
if (v === "both") return "both";
|
|
805
|
+
return "off";
|
|
806
|
+
}
|
|
807
|
+
return v === true ? "rows" : "off";
|
|
808
|
+
};
|
|
809
|
+
this.rowsWindowed = () => {
|
|
810
|
+
const s = this.resolveVirtual();
|
|
811
|
+
return s === "rows" || s === "both";
|
|
812
|
+
};
|
|
813
|
+
this.colsWindowed = () => {
|
|
814
|
+
const s = this.resolveVirtual();
|
|
815
|
+
return s === "columns" || s === "both";
|
|
816
|
+
};
|
|
817
|
+
this.isWindowed = () => this.rowsWindowed() || this.colsWindowed();
|
|
818
|
+
this.autoMeasureOn = () => this.autoMeasure === true;
|
|
819
|
+
this.columnCount = () => this.visibleColCount();
|
|
820
|
+
this.columnSize = (i) => {
|
|
821
|
+
if (!this.table || !this.table.getVisibleLeafColumns) return 150;
|
|
822
|
+
const c = this.table.getVisibleLeafColumns()[i];
|
|
823
|
+
return c && typeof c.getSize === "function" ? c.getSize() : 150;
|
|
824
|
+
};
|
|
825
|
+
this.forcedColumns = () => {
|
|
826
|
+
if (!this.colsWindowed()) return [];
|
|
827
|
+
const out = [];
|
|
828
|
+
if (this.table && this.table.getVisibleLeafColumns) {
|
|
829
|
+
const cols = this.table.getVisibleLeafColumns();
|
|
830
|
+
for (let i = 0; i < cols.length; i++) {
|
|
831
|
+
const c = cols[i];
|
|
832
|
+
if (c && c.getIsPinned && c.getIsPinned()) out.push(i);
|
|
833
|
+
}
|
|
834
|
+
}
|
|
835
|
+
if (!this._activeIsHeader.value && this._activeColIndex.value >= 0 && out.indexOf(this._activeColIndex.value) === -1) out.push(this._activeColIndex.value);
|
|
836
|
+
if (this._editingRow.value >= 0 && this._editingCol.value >= 0 && out.indexOf(this._editingCol.value) === -1) out.push(this._editingCol.value);
|
|
837
|
+
return out;
|
|
838
|
+
};
|
|
839
|
+
this.windowedCells = (row) => {
|
|
840
|
+
this._windowVer.value;
|
|
841
|
+
const cells = this.visibleCellsFor(row);
|
|
842
|
+
if (!this.colsWindowed()) return cells;
|
|
843
|
+
const idx = this.windowedColIndices();
|
|
844
|
+
const out = [];
|
|
845
|
+
for (let i = 0; i < idx.length; i++) {
|
|
846
|
+
const cell = cells[idx[i]];
|
|
847
|
+
if (cell) out.push(cell);
|
|
848
|
+
}
|
|
849
|
+
return out;
|
|
850
|
+
};
|
|
643
851
|
this.windowSource = () => {
|
|
644
852
|
if (!this.table) return [];
|
|
645
|
-
if (this.
|
|
853
|
+
if (this.rowsWindowed()) return this.table.getPrePaginationRowModel().rows;
|
|
646
854
|
return this.table.getRowModel().rows;
|
|
647
855
|
};
|
|
648
856
|
this.scheduleRemeasure = () => {
|
|
857
|
+
if (this.remeasureDisposed) return;
|
|
649
858
|
if (this.remeasurePending) return;
|
|
650
859
|
this.remeasurePending = true;
|
|
651
860
|
let ranMicro = false;
|
|
@@ -653,6 +862,7 @@ let DataTable = class DataTable extends SignalWatcher(LitElement) {
|
|
|
653
862
|
this.remeasureWindow();
|
|
654
863
|
};
|
|
655
864
|
const rafPass = () => {
|
|
865
|
+
this.remeasureRaf = null;
|
|
656
866
|
this.remeasurePending = false;
|
|
657
867
|
this.remeasureWindow();
|
|
658
868
|
};
|
|
@@ -660,9 +870,18 @@ let DataTable = class DataTable extends SignalWatcher(LitElement) {
|
|
|
660
870
|
ranMicro = true;
|
|
661
871
|
queueMicrotask(microPass);
|
|
662
872
|
}
|
|
663
|
-
if (typeof requestAnimationFrame === "function") requestAnimationFrame(rafPass);
|
|
873
|
+
if (typeof requestAnimationFrame === "function") this.remeasureRaf = requestAnimationFrame(rafPass);
|
|
664
874
|
else if (ranMicro) this.remeasurePending = false;
|
|
665
|
-
else setTimeout(rafPass, 0);
|
|
875
|
+
else this.remeasureRaf = setTimeout(rafPass, 0);
|
|
876
|
+
};
|
|
877
|
+
this.teardownRemeasure = () => {
|
|
878
|
+
this.remeasureDisposed = true;
|
|
879
|
+
if (this.remeasureRaf != null) {
|
|
880
|
+
if (typeof requestAnimationFrame === "function") cancelAnimationFrame(this.remeasureRaf);
|
|
881
|
+
else clearTimeout(this.remeasureRaf);
|
|
882
|
+
this.remeasureRaf = null;
|
|
883
|
+
}
|
|
884
|
+
this.remeasurePending = false;
|
|
666
885
|
};
|
|
667
886
|
this.pinnedEditIndex = () => {
|
|
668
887
|
if (this._editingRow.value >= 0) return this._editingRow.value;
|
|
@@ -675,19 +894,123 @@ let DataTable = class DataTable extends SignalWatcher(LitElement) {
|
|
|
675
894
|
return ms && ms[pin] ? ms[pin] : null;
|
|
676
895
|
};
|
|
677
896
|
this.remeasureWindow = () => {
|
|
897
|
+
if (this.remeasureDisposed) return;
|
|
678
898
|
if (!this.virtualizer || !this.gridRoot) return;
|
|
679
899
|
if (this.virtualizer.scrollState) return;
|
|
680
900
|
const trs = this.gridRoot.querySelectorAll("tbody.rdt-tbody > tr[data-index]");
|
|
681
901
|
for (const tr of trs) this.virtualizer.measureElement(tr);
|
|
902
|
+
if (this.afterRowRemeasure) this.afterRowRemeasure();
|
|
682
903
|
};
|
|
683
904
|
this.virtualItemKey = (i) => {
|
|
684
905
|
const src = this.windowSource();
|
|
685
906
|
return src && src[i] ? src[i].id : void 0;
|
|
686
907
|
};
|
|
908
|
+
this.COL_OVERSCAN = 3;
|
|
909
|
+
this.colRtlObserver = null;
|
|
910
|
+
this.colRtlObserverEl = null;
|
|
911
|
+
this.isColRtl = () => {
|
|
912
|
+
if (!this.gridScrollEl || typeof getComputedStyle !== "function") return false;
|
|
913
|
+
return getComputedStyle(this.gridScrollEl).direction === "rtl";
|
|
914
|
+
};
|
|
915
|
+
this.ensureColRtlWatch = () => {
|
|
916
|
+
if (!this.gridScrollEl || this.colRtlObserverEl === this.gridScrollEl || typeof MutationObserver !== "function") return;
|
|
917
|
+
if (this.colRtlObserver) this.colRtlObserver.disconnect();
|
|
918
|
+
this.colRtlObserver = new MutationObserver(() => {
|
|
919
|
+
if (this.colVirtualizer) this.colVirtualizer.setOptions({
|
|
920
|
+
...this.colVirtualizer.options,
|
|
921
|
+
isRtl: this.isColRtl()
|
|
922
|
+
});
|
|
923
|
+
});
|
|
924
|
+
this.colRtlObserver.observe(this.gridScrollEl, {
|
|
925
|
+
attributes: true,
|
|
926
|
+
attributeFilter: ["dir"]
|
|
927
|
+
});
|
|
928
|
+
this.colRtlObserverEl = this.gridScrollEl;
|
|
929
|
+
};
|
|
930
|
+
this.teardownColRtlWatch = () => {
|
|
931
|
+
if (this.colRtlObserver) this.colRtlObserver.disconnect();
|
|
932
|
+
this.colRtlObserver = null;
|
|
933
|
+
this.colRtlObserverEl = null;
|
|
934
|
+
};
|
|
935
|
+
this.columnVirtualizerOptions = () => {
|
|
936
|
+
this.ensureColRtlWatch();
|
|
937
|
+
return {
|
|
938
|
+
count: this.columnCount(),
|
|
939
|
+
getScrollElement: () => this.gridScrollEl,
|
|
940
|
+
estimateSize: (i) => this.columnSize(i),
|
|
941
|
+
horizontal: true,
|
|
942
|
+
isRtl: this.isColRtl(),
|
|
943
|
+
observeElementRect,
|
|
944
|
+
observeElementOffset,
|
|
945
|
+
scrollToFn: elementScroll,
|
|
946
|
+
measureElement,
|
|
947
|
+
overscan: this.COL_OVERSCAN,
|
|
948
|
+
onChange: () => {
|
|
949
|
+
this._windowVer.value = this._windowVer.value + 1;
|
|
950
|
+
}
|
|
951
|
+
};
|
|
952
|
+
};
|
|
953
|
+
this.measuredRowTotal = 0;
|
|
954
|
+
this.measuredRowCount = 0;
|
|
955
|
+
this.lastFedRowEstimate = 0;
|
|
956
|
+
this.foldedRowHeights = {};
|
|
957
|
+
this.windowVerBumpPending = false;
|
|
958
|
+
this.bumpWindowVer = () => {
|
|
959
|
+
if (this.windowVerBumpPending) return;
|
|
960
|
+
this.windowVerBumpPending = true;
|
|
961
|
+
const flush = () => {
|
|
962
|
+
this.windowVerBumpPending = false;
|
|
963
|
+
this._windowVer.value = this._windowVer.value + 1;
|
|
964
|
+
};
|
|
965
|
+
if (typeof queueMicrotask !== "undefined") queueMicrotask(flush);
|
|
966
|
+
else setTimeout(flush, 0);
|
|
967
|
+
};
|
|
968
|
+
this.ESTIMATE_REFEED_DELTA_PX = 4;
|
|
969
|
+
this.estimateRowSize = (i) => {
|
|
970
|
+
if (!this.autoMeasureOn()) return this.estimateRowHeight;
|
|
971
|
+
if (this.measuredRowCount === 0) return this.estimateRowHeight;
|
|
972
|
+
return Math.round(this.measuredRowTotal / this.measuredRowCount);
|
|
973
|
+
};
|
|
974
|
+
this.foldMeasuredRow = (index, height) => {
|
|
975
|
+
const prev = this.foldedRowHeights[index];
|
|
976
|
+
if (prev === height) return;
|
|
977
|
+
if (prev == null) {
|
|
978
|
+
this.measuredRowTotal = this.measuredRowTotal + height;
|
|
979
|
+
this.measuredRowCount = this.measuredRowCount + 1;
|
|
980
|
+
} else this.measuredRowTotal = this.measuredRowTotal - prev + height;
|
|
981
|
+
this.foldedRowHeights[index] = height;
|
|
982
|
+
};
|
|
983
|
+
this.refineRowEstimate = () => {
|
|
984
|
+
if (!this.autoMeasureOn() || !this.virtualizer) return;
|
|
985
|
+
const items = this.virtualizer.getVirtualItems();
|
|
986
|
+
const measurements = this.virtualizer.getMeasurements();
|
|
987
|
+
for (let i = 0; i < items.length; i++) {
|
|
988
|
+
const idx = items[i].index;
|
|
989
|
+
const m = measurements && measurements[idx];
|
|
990
|
+
if (m) this.foldMeasuredRow(idx, m.size);
|
|
991
|
+
}
|
|
992
|
+
if (this.virtualizer.scrollState) return;
|
|
993
|
+
const est = this.estimateRowSize(0);
|
|
994
|
+
if (Math.abs(est - this.lastFedRowEstimate) < this.ESTIMATE_REFEED_DELTA_PX) return;
|
|
995
|
+
const anchorIndex = items.length ? items[0].index : -1;
|
|
996
|
+
const anchorStart = items.length ? items[0].start : 0;
|
|
997
|
+
this.virtualizer.setOptions(this.virtualizerOptions());
|
|
998
|
+
this.virtualizer._willUpdate();
|
|
999
|
+
this.lastFedRowEstimate = est;
|
|
1000
|
+
if (anchorIndex >= 0 && this.gridScrollEl) {
|
|
1001
|
+
const freshMeasurements = this.virtualizer.getMeasurements();
|
|
1002
|
+
const fresh = freshMeasurements && freshMeasurements[anchorIndex];
|
|
1003
|
+
if (fresh) {
|
|
1004
|
+
const delta = fresh.start - anchorStart;
|
|
1005
|
+
if (delta !== 0) this.gridScrollEl.scrollTop = this.gridScrollEl.scrollTop + delta;
|
|
1006
|
+
}
|
|
1007
|
+
}
|
|
1008
|
+
this.bumpWindowVer();
|
|
1009
|
+
};
|
|
687
1010
|
this.virtualizerOptions = () => ({
|
|
688
1011
|
count: this.windowSource().length,
|
|
689
1012
|
getScrollElement: () => this.gridScrollEl,
|
|
690
|
-
estimateSize: () => this.
|
|
1013
|
+
estimateSize: (i) => this.estimateRowSize(i),
|
|
691
1014
|
observeElementRect,
|
|
692
1015
|
observeElementOffset,
|
|
693
1016
|
scrollToFn: elementScroll,
|
|
@@ -695,7 +1018,7 @@ let DataTable = class DataTable extends SignalWatcher(LitElement) {
|
|
|
695
1018
|
overscan: 8,
|
|
696
1019
|
getItemKey: this.virtualItemKey,
|
|
697
1020
|
onChange: () => {
|
|
698
|
-
this.
|
|
1021
|
+
this.bumpWindowVer();
|
|
699
1022
|
this.scheduleRemeasure();
|
|
700
1023
|
}
|
|
701
1024
|
});
|
|
@@ -704,8 +1027,8 @@ let DataTable = class DataTable extends SignalWatcher(LitElement) {
|
|
|
704
1027
|
this._windowVer.value;
|
|
705
1028
|
this._editVer.value;
|
|
706
1029
|
if (!this.virtualizer) {
|
|
707
|
-
if (!this.
|
|
708
|
-
vi:
|
|
1030
|
+
if (!this.rowsWindowed()) return (this._rows.value || []).map((r, i) => ({
|
|
1031
|
+
vi: { index: i },
|
|
709
1032
|
row: r
|
|
710
1033
|
}));
|
|
711
1034
|
return [];
|
|
@@ -741,7 +1064,7 @@ let DataTable = class DataTable extends SignalWatcher(LitElement) {
|
|
|
741
1064
|
this.padTop = () => {
|
|
742
1065
|
this._windowVer.value;
|
|
743
1066
|
this._editVer.value;
|
|
744
|
-
if (!this.
|
|
1067
|
+
if (!this.rowsWindowed() || !this.virtualizer) return 0;
|
|
745
1068
|
const items = this.virtualizer.getVirtualItems();
|
|
746
1069
|
let pad = items.length ? items[0].start : 0;
|
|
747
1070
|
const pin = this.pinnedEditIndex();
|
|
@@ -755,7 +1078,7 @@ let DataTable = class DataTable extends SignalWatcher(LitElement) {
|
|
|
755
1078
|
this.padBottom = () => {
|
|
756
1079
|
this._windowVer.value;
|
|
757
1080
|
this._editVer.value;
|
|
758
|
-
if (!this.
|
|
1081
|
+
if (!this.rowsWindowed() || !this.virtualizer) return 0;
|
|
759
1082
|
const items = this.virtualizer.getVirtualItems();
|
|
760
1083
|
if (!items.length) return 0;
|
|
761
1084
|
let pad = this.virtualizer.getTotalSize() - items[items.length - 1].end;
|
|
@@ -776,11 +1099,59 @@ let DataTable = class DataTable extends SignalWatcher(LitElement) {
|
|
|
776
1099
|
return false;
|
|
777
1100
|
};
|
|
778
1101
|
this.rowIsOutsideWindow = (r) => {
|
|
779
|
-
if (!this.
|
|
1102
|
+
if (!this.rowsWindowed() || !this.virtualizer) return false;
|
|
780
1103
|
const items = this.virtualizer.getVirtualItems();
|
|
781
1104
|
for (const it of items) if (it.index === r) return false;
|
|
782
1105
|
return true;
|
|
783
1106
|
};
|
|
1107
|
+
this.windowedColIndices = () => {
|
|
1108
|
+
this._windowVer.value;
|
|
1109
|
+
this._editVer.value;
|
|
1110
|
+
if (!this.colsWindowed()) {
|
|
1111
|
+
const n = this.columnCount();
|
|
1112
|
+
const out = [];
|
|
1113
|
+
for (let i = 0; i < n; i++) out.push(i);
|
|
1114
|
+
return out;
|
|
1115
|
+
}
|
|
1116
|
+
if (!this.colVirtualizer) return [];
|
|
1117
|
+
const idx = this.colVirtualizer.getVirtualItems().map((it) => it.index);
|
|
1118
|
+
const forced = this.forcedColumns();
|
|
1119
|
+
for (let i = 0; i < forced.length; i++) if (idx.indexOf(forced[i]) === -1) idx.push(forced[i]);
|
|
1120
|
+
idx.sort((a, b) => a - b);
|
|
1121
|
+
return idx;
|
|
1122
|
+
};
|
|
1123
|
+
this.colPadLeft = () => {
|
|
1124
|
+
this._windowVer.value;
|
|
1125
|
+
this._editVer.value;
|
|
1126
|
+
if (!this.colsWindowed() || !this.colVirtualizer) return 0;
|
|
1127
|
+
const items = this.colVirtualizer.getVirtualItems();
|
|
1128
|
+
let pad = items.length ? items[0].start : 0;
|
|
1129
|
+
if (items.length) {
|
|
1130
|
+
const firstIdx = items[0].index;
|
|
1131
|
+
const forced = this.forcedColumns();
|
|
1132
|
+
for (let i = 0; i < forced.length; i++) if (forced[i] < firstIdx) pad = pad - this.columnSize(forced[i]);
|
|
1133
|
+
}
|
|
1134
|
+
return pad < 0 ? 0 : pad;
|
|
1135
|
+
};
|
|
1136
|
+
this.colPadRight = () => {
|
|
1137
|
+
this._windowVer.value;
|
|
1138
|
+
this._editVer.value;
|
|
1139
|
+
if (!this.colsWindowed() || !this.colVirtualizer) return 0;
|
|
1140
|
+
const items = this.colVirtualizer.getVirtualItems();
|
|
1141
|
+
if (!items.length) return 0;
|
|
1142
|
+
let pad = this.colVirtualizer.getTotalSize() - items[items.length - 1].end;
|
|
1143
|
+
const lastIdx = items[items.length - 1].index;
|
|
1144
|
+
const forced = this.forcedColumns();
|
|
1145
|
+
for (let i = 0; i < forced.length; i++) if (forced[i] > lastIdx) pad = pad - this.columnSize(forced[i]);
|
|
1146
|
+
return pad < 0 ? 0 : pad;
|
|
1147
|
+
};
|
|
1148
|
+
this.colIsOutsideWindow = (c) => {
|
|
1149
|
+
if (!this.colsWindowed() || !this.colVirtualizer) return false;
|
|
1150
|
+
const items = this.colVirtualizer.getVirtualItems();
|
|
1151
|
+
for (const it of items) if (it.index === c) return false;
|
|
1152
|
+
return true;
|
|
1153
|
+
};
|
|
1154
|
+
this.afterRowRemeasure = this.refineRowEstimate;
|
|
784
1155
|
this.announceState = {
|
|
785
1156
|
sorting: null,
|
|
786
1157
|
columnFilters: null,
|
|
@@ -1153,7 +1524,7 @@ let DataTable = class DataTable extends SignalWatcher(LitElement) {
|
|
|
1153
1524
|
};
|
|
1154
1525
|
this.getRowIndexRelativeToPage = (absRow) => {
|
|
1155
1526
|
const abs = absRow == null ? this.toAbsRow(this._activeRow.value) : Math.trunc(Number(absRow)) || 0;
|
|
1156
|
-
if (this.
|
|
1527
|
+
if (this.rowsWindowed()) return abs;
|
|
1157
1528
|
return abs - this.pageRowOffset();
|
|
1158
1529
|
};
|
|
1159
1530
|
this.cut = () => this.cutRange();
|
|
@@ -1164,12 +1535,12 @@ let DataTable = class DataTable extends SignalWatcher(LitElement) {
|
|
|
1164
1535
|
this.colIndexOf = (row, cellCtx) => this.tick() >= 0 ? this.visibleCellsFor(row).indexOf(cellCtx) : -1;
|
|
1165
1536
|
this.headerColIndexOf = (hg, header) => (hg && hg.headers ? hg.headers : []).indexOf(header);
|
|
1166
1537
|
this.pageRowOffset = () => {
|
|
1167
|
-
if (!this.isGrid() || this.
|
|
1538
|
+
if (!this.isGrid() || this.rowsWindowed()) return 0;
|
|
1168
1539
|
return this.pageIndex() * this.pageSize();
|
|
1169
1540
|
};
|
|
1170
1541
|
this.toAbsRow = (localRow) => localRow + this.pageRowOffset();
|
|
1171
1542
|
this.prePaginationRowCount = () => {
|
|
1172
|
-
if (!this.table || this.
|
|
1543
|
+
if (!this.table || this.rowsWindowed()) return this.bodyRowCount();
|
|
1173
1544
|
const pm = this.table.getPrePaginationRowModel();
|
|
1174
1545
|
return pm && pm.rows ? pm.rows.length : this.bodyRowCount();
|
|
1175
1546
|
};
|
|
@@ -1204,8 +1575,11 @@ let DataTable = class DataTable extends SignalWatcher(LitElement) {
|
|
|
1204
1575
|
const c = nextCol == null ? this._activeColIndex.value : nextCol;
|
|
1205
1576
|
const lvl = nextLevel == null ? this._activeHeaderLevel.value : nextLevel;
|
|
1206
1577
|
const header = nextIsHeader == null ? this._activeIsHeader.value : nextIsHeader;
|
|
1207
|
-
|
|
1208
|
-
|
|
1578
|
+
const rowOut = this.rowsWindowed() && this.virtualizer && this.rowIsOutsideWindow(r);
|
|
1579
|
+
const colOut = this.colsWindowed() && this.colVirtualizer && this.colIsOutsideWindow(c);
|
|
1580
|
+
if (!header && (rowOut || colOut)) {
|
|
1581
|
+
if (rowOut) this.virtualizer.scrollToIndex(r, { align: "center" });
|
|
1582
|
+
if (colOut) this.colVirtualizer.scrollToIndex(c, { align: "center" });
|
|
1209
1583
|
let focusAttempts = 0;
|
|
1210
1584
|
const myEpoch = this.focusIntentEpoch;
|
|
1211
1585
|
const focusWhenReady = () => {
|
|
@@ -1244,7 +1618,6 @@ let DataTable = class DataTable extends SignalWatcher(LitElement) {
|
|
|
1244
1618
|
return hg.length ? (hg[hg.length - 1].headers || []).length : 0;
|
|
1245
1619
|
};
|
|
1246
1620
|
this.bodyRowCount = () => (this._rows.value || []).length;
|
|
1247
|
-
this.clamp = (v, lo, hi) => v < lo ? lo : v > hi ? hi : v;
|
|
1248
1621
|
this.headerLeafLevel = () => {
|
|
1249
1622
|
const hg = this._headerGroups.value || [];
|
|
1250
1623
|
return hg.length ? hg.length - 1 : 0;
|
|
@@ -1290,7 +1663,7 @@ let DataTable = class DataTable extends SignalWatcher(LitElement) {
|
|
|
1290
1663
|
};
|
|
1291
1664
|
this.moveCol = (delta) => {
|
|
1292
1665
|
const max = (this._activeIsHeader.value ? this.headerCountAtLevel(this._activeHeaderLevel.value) : this.visibleColCount()) - 1;
|
|
1293
|
-
const nextCol =
|
|
1666
|
+
const nextCol = clamp(this._activeColIndex.value + delta, 0, max < 0 ? 0 : max);
|
|
1294
1667
|
this._activeColIndex.value = nextCol;
|
|
1295
1668
|
return nextCol;
|
|
1296
1669
|
};
|
|
@@ -1320,7 +1693,7 @@ let DataTable = class DataTable extends SignalWatcher(LitElement) {
|
|
|
1320
1693
|
isHeader: true,
|
|
1321
1694
|
level: this._activeHeaderLevel.value
|
|
1322
1695
|
};
|
|
1323
|
-
const landRow =
|
|
1696
|
+
const landRow = clamp(delta - 1, 0, maxRow);
|
|
1324
1697
|
this._activeIsHeader.value = false;
|
|
1325
1698
|
this._activeRow.value = landRow;
|
|
1326
1699
|
return {
|
|
@@ -1359,7 +1732,7 @@ let DataTable = class DataTable extends SignalWatcher(LitElement) {
|
|
|
1359
1732
|
level: leafLevel
|
|
1360
1733
|
};
|
|
1361
1734
|
}
|
|
1362
|
-
const nextRow =
|
|
1735
|
+
const nextRow = clamp(this._activeRow.value + delta, 0, maxRow);
|
|
1363
1736
|
this._activeRow.value = nextRow;
|
|
1364
1737
|
this._activeIsHeader.value = false;
|
|
1365
1738
|
return {
|
|
@@ -1408,19 +1781,14 @@ let DataTable = class DataTable extends SignalWatcher(LitElement) {
|
|
|
1408
1781
|
const rowKey = this._activeIsHeader.value ? "__header" : String(this._activeRow.value);
|
|
1409
1782
|
return this.resolveCellEl(rowKey, this._activeColIndex.value, this._activeIsHeader.value ? this._activeHeaderLevel.value : null);
|
|
1410
1783
|
};
|
|
1411
|
-
this.focusables = (cellEl) => {
|
|
1412
|
-
if (!cellEl || !cellEl.querySelectorAll) return [];
|
|
1413
|
-
return Array.prototype.slice.call(cellEl.querySelectorAll("button,[href],input,select,textarea,[tabindex]:not([tabindex=\"-1\"])")).filter((n) => !n.disabled);
|
|
1414
|
-
};
|
|
1415
1784
|
this.enterControl = () => {
|
|
1416
|
-
const
|
|
1417
|
-
const list = this.focusables(cellEl);
|
|
1785
|
+
const list = focusables(this.currentCellEl());
|
|
1418
1786
|
if (!list.length) return;
|
|
1419
1787
|
this._activeInControl.value = true;
|
|
1420
1788
|
list[0].focus();
|
|
1421
1789
|
};
|
|
1422
1790
|
this.cycleWithinCell = (cellEl, forward) => {
|
|
1423
|
-
const list =
|
|
1791
|
+
const list = focusables(cellEl);
|
|
1424
1792
|
if (!list.length) return;
|
|
1425
1793
|
const active = this.gridRoot ? this.gridRoot.getRootNode().activeElement : null;
|
|
1426
1794
|
const cur = list.indexOf(active);
|
|
@@ -1791,7 +2159,7 @@ let DataTable = class DataTable extends SignalWatcher(LitElement) {
|
|
|
1791
2159
|
}
|
|
1792
2160
|
}
|
|
1793
2161
|
const maxCol = colN - 1;
|
|
1794
|
-
const col =
|
|
2162
|
+
const col = clamp(this._activeColIndex.value, 0, maxCol < 0 ? 0 : maxCol);
|
|
1795
2163
|
if (col !== this._activeColIndex.value) this._activeColIndex.value = col;
|
|
1796
2164
|
if (rowN <= 0) {
|
|
1797
2165
|
this._activeIsHeader.value = true;
|
|
@@ -1809,16 +2177,48 @@ let DataTable = class DataTable extends SignalWatcher(LitElement) {
|
|
|
1809
2177
|
if (!this._activeIsHeader.value) {
|
|
1810
2178
|
const lastRow = rowN - 1;
|
|
1811
2179
|
const maxRow = lastRow < 0 ? 0 : lastRow;
|
|
1812
|
-
const row =
|
|
2180
|
+
const row = clamp(this._activeRow.value, 0, maxRow);
|
|
1813
2181
|
if (row !== this._activeRow.value) this._activeRow.value = row;
|
|
1814
2182
|
}
|
|
1815
2183
|
this.clampRange(rowN - 1, colN - 1);
|
|
1816
2184
|
if (recoverFocus) {
|
|
1817
|
-
const recRow =
|
|
1818
|
-
const recCol =
|
|
2185
|
+
const recRow = clamp(doomedRow, 0, rowN - 1);
|
|
2186
|
+
const recCol = clamp(doomedCol, 0, maxCol < 0 ? 0 : maxCol);
|
|
1819
2187
|
this.recoverGridFocus(String(recRow), recCol, null);
|
|
1820
2188
|
}
|
|
1821
2189
|
};
|
|
2190
|
+
this.windowedHeadersFor = (hg, hgLevel) => {
|
|
2191
|
+
const headers = hg && hg.headers || [];
|
|
2192
|
+
if (!this.colsWindowed()) return headers.map((h) => ({
|
|
2193
|
+
header: h,
|
|
2194
|
+
span: h && h.colSpan > 1 ? h.colSpan : 1
|
|
2195
|
+
}));
|
|
2196
|
+
const idx = this.windowedColIndices();
|
|
2197
|
+
const idxSet = {};
|
|
2198
|
+
for (let i = 0; i < idx.length; i++) idxSet[idx[i]] = true;
|
|
2199
|
+
let cursor = 0;
|
|
2200
|
+
const out = [];
|
|
2201
|
+
for (let i = 0; i < headers.length; i++) {
|
|
2202
|
+
const h = headers[i];
|
|
2203
|
+
const leafCount = h && h.colSpan ? h.colSpan : 1;
|
|
2204
|
+
const start = cursor;
|
|
2205
|
+
const end = cursor + leafCount;
|
|
2206
|
+
cursor = end;
|
|
2207
|
+
let span = 0;
|
|
2208
|
+
for (let c = start; c < end; c++) if (idxSet[c]) span = span + 1;
|
|
2209
|
+
if (span > 0) out.push({
|
|
2210
|
+
header: h,
|
|
2211
|
+
span
|
|
2212
|
+
});
|
|
2213
|
+
}
|
|
2214
|
+
return out;
|
|
2215
|
+
};
|
|
2216
|
+
this.windowedColSpan = () => this.colsWindowed() ? this.windowedColIndices().length + 2 : this.visibleColCount();
|
|
2217
|
+
this.remeasureColumnWindow = () => {
|
|
2218
|
+
if (!this.colsWindowed() || !this.colVirtualizer) return;
|
|
2219
|
+
this.colVirtualizer.setOptions(this.columnVirtualizerOptions());
|
|
2220
|
+
this.colVirtualizer._willUpdate();
|
|
2221
|
+
};
|
|
1822
2222
|
this.gridEmptyFallback = false;
|
|
1823
2223
|
this.rangeTransition = false;
|
|
1824
2224
|
this.rangeClickPending = false;
|
|
@@ -1847,8 +2247,8 @@ let DataTable = class DataTable extends SignalWatcher(LitElement) {
|
|
|
1847
2247
|
focus: null
|
|
1848
2248
|
};
|
|
1849
2249
|
const clampCorner = (c) => c == null ? null : {
|
|
1850
|
-
rowIndex:
|
|
1851
|
-
colIndex:
|
|
2250
|
+
rowIndex: clamp(c.rowIndex, 0, maxRow),
|
|
2251
|
+
colIndex: clamp(c.colIndex, 0, maxCol)
|
|
1852
2252
|
};
|
|
1853
2253
|
return {
|
|
1854
2254
|
anchor: clampCorner(a),
|
|
@@ -1891,8 +2291,8 @@ let DataTable = class DataTable extends SignalWatcher(LitElement) {
|
|
|
1891
2291
|
colIndex: this._activeColIndex.value
|
|
1892
2292
|
};
|
|
1893
2293
|
}
|
|
1894
|
-
const nextRow =
|
|
1895
|
-
const nextCol =
|
|
2294
|
+
const nextRow = clamp(focus.rowIndex + dRow, 0, maxRow);
|
|
2295
|
+
const nextCol = clamp(focus.colIndex + dCol, 0, maxCol);
|
|
1896
2296
|
const nextFocus = {
|
|
1897
2297
|
rowIndex: nextRow,
|
|
1898
2298
|
colIndex: nextCol
|
|
@@ -1916,8 +2316,8 @@ let DataTable = class DataTable extends SignalWatcher(LitElement) {
|
|
|
1916
2316
|
colIndex: this._activeColIndex.value
|
|
1917
2317
|
};
|
|
1918
2318
|
const nextFocus = {
|
|
1919
|
-
rowIndex:
|
|
1920
|
-
colIndex:
|
|
2319
|
+
rowIndex: clamp(Math.trunc(Number(rIdx)) || 0, 0, maxRow),
|
|
2320
|
+
colIndex: clamp(Math.trunc(Number(cIdx)) || 0, 0, maxCol)
|
|
1921
2321
|
};
|
|
1922
2322
|
this._rangeAnchor.value = anchor;
|
|
1923
2323
|
this._rangeFocus.value = nextFocus;
|
|
@@ -1961,16 +2361,16 @@ let DataTable = class DataTable extends SignalWatcher(LitElement) {
|
|
|
1961
2361
|
return;
|
|
1962
2362
|
}
|
|
1963
2363
|
if (a) {
|
|
1964
|
-
const ar =
|
|
1965
|
-
const ac =
|
|
2364
|
+
const ar = clamp(a.rowIndex, 0, maxRow);
|
|
2365
|
+
const ac = clamp(a.colIndex, 0, maxCol);
|
|
1966
2366
|
if (ar !== a.rowIndex || ac !== a.colIndex) this._rangeAnchor.value = {
|
|
1967
2367
|
rowIndex: ar,
|
|
1968
2368
|
colIndex: ac
|
|
1969
2369
|
};
|
|
1970
2370
|
}
|
|
1971
2371
|
if (f) {
|
|
1972
|
-
const fr =
|
|
1973
|
-
const fc =
|
|
2372
|
+
const fr = clamp(f.rowIndex, 0, maxRow);
|
|
2373
|
+
const fc = clamp(f.colIndex, 0, maxCol);
|
|
1974
2374
|
if (fr !== f.rowIndex || fc !== f.colIndex) this._rangeFocus.value = {
|
|
1975
2375
|
rowIndex: fr,
|
|
1976
2376
|
colIndex: fc
|
|
@@ -1992,10 +2392,10 @@ let DataTable = class DataTable extends SignalWatcher(LitElement) {
|
|
|
1992
2392
|
const maxRow = this.bodyRowCount() - 1;
|
|
1993
2393
|
const maxCol = this.visibleColCount() - 1;
|
|
1994
2394
|
if (maxRow < 0 || maxCol < 0) return null;
|
|
1995
|
-
const ar =
|
|
1996
|
-
const ac =
|
|
1997
|
-
const fr =
|
|
1998
|
-
const fc =
|
|
2395
|
+
const ar = clamp(a.rowIndex, 0, maxRow);
|
|
2396
|
+
const ac = clamp(a.colIndex, 0, maxCol);
|
|
2397
|
+
const fr = clamp(f.rowIndex, 0, maxRow);
|
|
2398
|
+
const fc = clamp(f.colIndex, 0, maxCol);
|
|
1999
2399
|
return {
|
|
2000
2400
|
r0: ar < fr ? ar : fr,
|
|
2001
2401
|
r1: ar > fr ? ar : fr,
|
|
@@ -2003,10 +2403,6 @@ let DataTable = class DataTable extends SignalWatcher(LitElement) {
|
|
|
2003
2403
|
c1: ac > fc ? ac : fc
|
|
2004
2404
|
};
|
|
2005
2405
|
};
|
|
2006
|
-
this.escapeTsvField = (s) => {
|
|
2007
|
-
if (s.indexOf(" ") >= 0 || s.indexOf("\n") >= 0 || s.indexOf("\r") >= 0 || s.indexOf("\"") >= 0) return "\"" + s.replace(/"/g, "\"\"") + "\"";
|
|
2008
|
-
return s;
|
|
2009
|
-
};
|
|
2010
2406
|
this.rangeToTsv = () => {
|
|
2011
2407
|
const box = this.normalizedRange();
|
|
2012
2408
|
const r0 = box ? box.r0 : this._activeRow.value;
|
|
@@ -2018,77 +2414,12 @@ let DataTable = class DataTable extends SignalWatcher(LitElement) {
|
|
|
2018
2414
|
const cells = [];
|
|
2019
2415
|
for (let c = c0; c <= c1; c++) {
|
|
2020
2416
|
const v = this.cellValueAt(r, c);
|
|
2021
|
-
cells.push(
|
|
2417
|
+
cells.push(escapeTsvField(v == null ? "" : String(v)));
|
|
2022
2418
|
}
|
|
2023
2419
|
lines.push(cells.join(" "));
|
|
2024
2420
|
}
|
|
2025
2421
|
return lines.join("\n");
|
|
2026
2422
|
};
|
|
2027
|
-
this.parseTsv = (text) => {
|
|
2028
|
-
const str = text != null ? String(text) : "";
|
|
2029
|
-
if (str === "" || str.length > 2e6) return [];
|
|
2030
|
-
const rows = [];
|
|
2031
|
-
let row = [];
|
|
2032
|
-
let field = "";
|
|
2033
|
-
let inQuotes = false;
|
|
2034
|
-
let i = 0;
|
|
2035
|
-
const n = str.length;
|
|
2036
|
-
while (i < n) {
|
|
2037
|
-
const ch = str[i];
|
|
2038
|
-
if (inQuotes) {
|
|
2039
|
-
if (ch === "\"") {
|
|
2040
|
-
if (i + 1 < n && str[i + 1] === "\"") {
|
|
2041
|
-
field = field + "\"";
|
|
2042
|
-
i = i + 2;
|
|
2043
|
-
continue;
|
|
2044
|
-
}
|
|
2045
|
-
inQuotes = false;
|
|
2046
|
-
i = i + 1;
|
|
2047
|
-
continue;
|
|
2048
|
-
}
|
|
2049
|
-
field = field + ch;
|
|
2050
|
-
i = i + 1;
|
|
2051
|
-
continue;
|
|
2052
|
-
}
|
|
2053
|
-
if (ch === "\"" && field === "") {
|
|
2054
|
-
inQuotes = true;
|
|
2055
|
-
i = i + 1;
|
|
2056
|
-
continue;
|
|
2057
|
-
}
|
|
2058
|
-
if (ch === " ") {
|
|
2059
|
-
row.push(field);
|
|
2060
|
-
field = "";
|
|
2061
|
-
i = i + 1;
|
|
2062
|
-
continue;
|
|
2063
|
-
}
|
|
2064
|
-
if (ch === "\r") {
|
|
2065
|
-
if (i + 1 < n && str[i + 1] === "\n") i = i + 1;
|
|
2066
|
-
row.push(field);
|
|
2067
|
-
field = "";
|
|
2068
|
-
rows.push(row);
|
|
2069
|
-
row = [];
|
|
2070
|
-
i = i + 1;
|
|
2071
|
-
continue;
|
|
2072
|
-
}
|
|
2073
|
-
if (ch === "\n") {
|
|
2074
|
-
row.push(field);
|
|
2075
|
-
field = "";
|
|
2076
|
-
rows.push(row);
|
|
2077
|
-
row = [];
|
|
2078
|
-
i = i + 1;
|
|
2079
|
-
continue;
|
|
2080
|
-
}
|
|
2081
|
-
field = field + ch;
|
|
2082
|
-
i = i + 1;
|
|
2083
|
-
}
|
|
2084
|
-
row.push(field);
|
|
2085
|
-
rows.push(row);
|
|
2086
|
-
if (rows.length > 1) {
|
|
2087
|
-
const last = rows[rows.length - 1];
|
|
2088
|
-
if (last.length === 1 && last[0] === "") rows.pop();
|
|
2089
|
-
}
|
|
2090
|
-
return rows;
|
|
2091
|
-
};
|
|
2092
2423
|
this.copyRange = () => {
|
|
2093
2424
|
if (!this.clipboardActiveAllowed()) return;
|
|
2094
2425
|
if (typeof navigator === "undefined" || !navigator.clipboard || !navigator.clipboard.writeText) return;
|
|
@@ -2124,7 +2455,7 @@ let DataTable = class DataTable extends SignalWatcher(LitElement) {
|
|
|
2124
2455
|
const field = this.fieldOfColId(colId);
|
|
2125
2456
|
const srcIndex = this.sourceIndexOfRow(r);
|
|
2126
2457
|
const oldValue = rowObj ? rowObj[field] : null;
|
|
2127
|
-
next =
|
|
2458
|
+
next = replaceRowValue(next, srcIndex, field, value);
|
|
2128
2459
|
committed.push({
|
|
2129
2460
|
rowId: this.rowIdAt(r),
|
|
2130
2461
|
columnId: colId,
|
|
@@ -2159,30 +2490,6 @@ let DataTable = class DataTable extends SignalWatcher(LitElement) {
|
|
|
2159
2490
|
const row = (this._rows.value || [])[rowIndex];
|
|
2160
2491
|
return row ? row.id : null;
|
|
2161
2492
|
};
|
|
2162
|
-
this.tileGridToBox = (grid, box) => {
|
|
2163
|
-
const srcRows = grid.length;
|
|
2164
|
-
let srcCols = 0;
|
|
2165
|
-
for (let i = 0; i < srcRows; i++) {
|
|
2166
|
-
const w = grid[i] && grid[i].length ? grid[i].length : 0;
|
|
2167
|
-
if (w > srcCols) srcCols = w;
|
|
2168
|
-
}
|
|
2169
|
-
if (srcRows <= 0 || srcCols <= 0) return grid;
|
|
2170
|
-
const boxRows = box.r1 - box.r0 + 1;
|
|
2171
|
-
const boxCols = box.c1 - box.c0 + 1;
|
|
2172
|
-
const rows = boxRows > srcRows ? boxRows : srcRows;
|
|
2173
|
-
const cols = boxCols > srcCols ? boxCols : srcCols;
|
|
2174
|
-
const out = [];
|
|
2175
|
-
for (let r = 0; r < rows; r++) {
|
|
2176
|
-
const srcLine = grid[r % srcRows] || [];
|
|
2177
|
-
const line = [];
|
|
2178
|
-
for (let c = 0; c < cols; c++) {
|
|
2179
|
-
const v = srcLine[c % srcCols];
|
|
2180
|
-
line.push(v != null ? v : "");
|
|
2181
|
-
}
|
|
2182
|
-
out.push(line);
|
|
2183
|
-
}
|
|
2184
|
-
return out;
|
|
2185
|
-
};
|
|
2186
2493
|
this.pasteRange = () => {
|
|
2187
2494
|
if (!this.clipboardActiveAllowed()) return;
|
|
2188
2495
|
if (typeof navigator === "undefined" || !navigator.clipboard || !navigator.clipboard.readText) return;
|
|
@@ -2203,9 +2510,9 @@ let DataTable = class DataTable extends SignalWatcher(LitElement) {
|
|
|
2203
2510
|
}
|
|
2204
2511
|
if (!p || !p.then) return;
|
|
2205
2512
|
p.then((text) => {
|
|
2206
|
-
const grid =
|
|
2513
|
+
const grid = parseTsv(text);
|
|
2207
2514
|
if (!grid.length) return;
|
|
2208
|
-
const tiled =
|
|
2515
|
+
const tiled = tileGridToBox(grid, destBox);
|
|
2209
2516
|
this.applyGridToRange(tiled, anchorRow, anchorCol);
|
|
2210
2517
|
}).catch(() => {});
|
|
2211
2518
|
};
|
|
@@ -2243,13 +2550,6 @@ let DataTable = class DataTable extends SignalWatcher(LitElement) {
|
|
|
2243
2550
|
}
|
|
2244
2551
|
this.applyGridToRange(grid, r0, c0);
|
|
2245
2552
|
};
|
|
2246
|
-
this.tileIndex = (i, lo, hi) => {
|
|
2247
|
-
const span = hi - lo + 1;
|
|
2248
|
-
if (span <= 1) return lo;
|
|
2249
|
-
let k = (i - lo) % span;
|
|
2250
|
-
if (k < 0) k = k + span;
|
|
2251
|
-
return lo + k;
|
|
2252
|
-
};
|
|
2253
2553
|
this.fillRange = (sourceBox, endCell) => {
|
|
2254
2554
|
let box;
|
|
2255
2555
|
if (sourceBox && sourceBox.r0 != null && endCell) {
|
|
@@ -2279,8 +2579,8 @@ let DataTable = class DataTable extends SignalWatcher(LitElement) {
|
|
|
2279
2579
|
for (let r = box.r0; r <= box.r1; r++) {
|
|
2280
2580
|
const cols = [];
|
|
2281
2581
|
for (let c = box.c0; c <= box.c1; c++) {
|
|
2282
|
-
const sr =
|
|
2283
|
-
const sc =
|
|
2582
|
+
const sr = tileIndex(r, src.r0, src.r1);
|
|
2583
|
+
const sc = tileIndex(c, src.c0, src.c1);
|
|
2284
2584
|
const v = this.cellValueAt(sr, sc);
|
|
2285
2585
|
cols.push(v == null ? "" : String(v));
|
|
2286
2586
|
}
|
|
@@ -2291,6 +2591,30 @@ let DataTable = class DataTable extends SignalWatcher(LitElement) {
|
|
|
2291
2591
|
this.fillDragging = false;
|
|
2292
2592
|
this.fillDragMove = null;
|
|
2293
2593
|
this.fillDragUp = null;
|
|
2594
|
+
this.fillEdgeScrollRaf = null;
|
|
2595
|
+
this.FILL_EDGE_SCROLL_PX = 24;
|
|
2596
|
+
this.FILL_EDGE_SCROLL_STEP = 16;
|
|
2597
|
+
this.edgeDelta = (clientX, clientY) => {
|
|
2598
|
+
if (!this.gridScrollEl) return {
|
|
2599
|
+
dx: 0,
|
|
2600
|
+
dy: 0
|
|
2601
|
+
};
|
|
2602
|
+
const rect = this.gridScrollEl.getBoundingClientRect();
|
|
2603
|
+
let dx = 0;
|
|
2604
|
+
let dy = 0;
|
|
2605
|
+
if (this.colsWindowed()) {
|
|
2606
|
+
if (clientX - rect.left < this.FILL_EDGE_SCROLL_PX) dx = -this.FILL_EDGE_SCROLL_STEP;
|
|
2607
|
+
else if (rect.right - clientX < this.FILL_EDGE_SCROLL_PX) dx = this.FILL_EDGE_SCROLL_STEP;
|
|
2608
|
+
}
|
|
2609
|
+
if (this.rowsWindowed()) {
|
|
2610
|
+
if (clientY - rect.top < this.FILL_EDGE_SCROLL_PX) dy = -this.FILL_EDGE_SCROLL_STEP;
|
|
2611
|
+
else if (rect.bottom - clientY < this.FILL_EDGE_SCROLL_PX) dy = this.FILL_EDGE_SCROLL_STEP;
|
|
2612
|
+
}
|
|
2613
|
+
return {
|
|
2614
|
+
dx,
|
|
2615
|
+
dy
|
|
2616
|
+
};
|
|
2617
|
+
};
|
|
2294
2618
|
this.teardownFillDrag = () => {
|
|
2295
2619
|
if (typeof document !== "undefined") {
|
|
2296
2620
|
if (this.fillDragMove) document.removeEventListener("pointermove", this.fillDragMove);
|
|
@@ -2299,6 +2623,10 @@ let DataTable = class DataTable extends SignalWatcher(LitElement) {
|
|
|
2299
2623
|
this.fillDragMove = null;
|
|
2300
2624
|
this.fillDragUp = null;
|
|
2301
2625
|
this.fillDragging = false;
|
|
2626
|
+
if (this.fillEdgeScrollRaf != null) {
|
|
2627
|
+
if (typeof cancelAnimationFrame === "function") cancelAnimationFrame(this.fillEdgeScrollRaf);
|
|
2628
|
+
this.fillEdgeScrollRaf = null;
|
|
2629
|
+
}
|
|
2302
2630
|
};
|
|
2303
2631
|
this.cellIndexFromPoint = (clientX, clientY) => {
|
|
2304
2632
|
if (typeof document === "undefined" || !document.elementFromPoint) return null;
|
|
@@ -2333,14 +2661,42 @@ let DataTable = class DataTable extends SignalWatcher(LitElement) {
|
|
|
2333
2661
|
r: sourceBox.r1,
|
|
2334
2662
|
c: sourceBox.c1
|
|
2335
2663
|
} : null;
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2664
|
+
let lastClientX = 0;
|
|
2665
|
+
let lastClientY = 0;
|
|
2666
|
+
const applyPointAt = (clientX, clientY) => {
|
|
2667
|
+
const cell = this.cellIndexFromPoint(clientX, clientY);
|
|
2339
2668
|
if (cell && (!lastCell || cell.r !== lastCell.r || cell.c !== lastCell.c)) {
|
|
2340
2669
|
lastCell = cell;
|
|
2341
2670
|
this.setRangeFocus(cell.r, cell.c);
|
|
2342
2671
|
}
|
|
2343
2672
|
};
|
|
2673
|
+
const scrollStep = () => {
|
|
2674
|
+
if (!this.fillDragging) {
|
|
2675
|
+
this.fillEdgeScrollRaf = null;
|
|
2676
|
+
return;
|
|
2677
|
+
}
|
|
2678
|
+
const d = this.edgeDelta(lastClientX, lastClientY);
|
|
2679
|
+
if (d.dx === 0 && d.dy === 0) {
|
|
2680
|
+
this.fillEdgeScrollRaf = null;
|
|
2681
|
+
return;
|
|
2682
|
+
}
|
|
2683
|
+
if (this.gridScrollEl) {
|
|
2684
|
+
if (d.dx !== 0) this.gridScrollEl.scrollLeft = this.gridScrollEl.scrollLeft + d.dx;
|
|
2685
|
+
if (d.dy !== 0) this.gridScrollEl.scrollTop = this.gridScrollEl.scrollTop + d.dy;
|
|
2686
|
+
}
|
|
2687
|
+
applyPointAt(lastClientX, lastClientY);
|
|
2688
|
+
this.fillEdgeScrollRaf = requestAnimationFrame(scrollStep);
|
|
2689
|
+
};
|
|
2690
|
+
const move = (ev) => {
|
|
2691
|
+
if (!this.fillDragging) return;
|
|
2692
|
+
lastClientX = ev.clientX;
|
|
2693
|
+
lastClientY = ev.clientY;
|
|
2694
|
+
applyPointAt(ev.clientX, ev.clientY);
|
|
2695
|
+
if (this.fillEdgeScrollRaf == null && typeof requestAnimationFrame === "function") {
|
|
2696
|
+
const d = this.edgeDelta(ev.clientX, ev.clientY);
|
|
2697
|
+
if (d.dx !== 0 || d.dy !== 0) this.fillEdgeScrollRaf = requestAnimationFrame(scrollStep);
|
|
2698
|
+
}
|
|
2699
|
+
};
|
|
2344
2700
|
const up = () => {
|
|
2345
2701
|
this.teardownFillDrag();
|
|
2346
2702
|
if (lastCell && sourceBox && (lastCell.r !== sourceBox.r1 || lastCell.c !== sourceBox.c1)) this.fillRange(sourceBox, lastCell);
|
|
@@ -2429,16 +2785,6 @@ let DataTable = class DataTable extends SignalWatcher(LitElement) {
|
|
|
2429
2785
|
this.setInvalid = (msg) => {
|
|
2430
2786
|
this._invalidMsg.value = msg != null ? msg : "";
|
|
2431
2787
|
};
|
|
2432
|
-
this.replaceRowValue = (rows, rowIndex, field, value) => {
|
|
2433
|
-
const src = rows || [];
|
|
2434
|
-
const out = [];
|
|
2435
|
-
for (let i = 0; i < src.length; i++) if (i === rowIndex) out.push({
|
|
2436
|
-
...src[i] || {},
|
|
2437
|
-
[field]: value
|
|
2438
|
-
});
|
|
2439
|
-
else out.push(src[i]);
|
|
2440
|
-
return out;
|
|
2441
|
-
};
|
|
2442
2788
|
this.sourceIndexOfRow = (visibleRowIndex) => {
|
|
2443
2789
|
const row = (this._rows.value || [])[visibleRowIndex];
|
|
2444
2790
|
if (!row) return visibleRowIndex;
|
|
@@ -2545,16 +2891,6 @@ let DataTable = class DataTable extends SignalWatcher(LitElement) {
|
|
|
2545
2891
|
if (typeof requestAnimationFrame === "function") requestAnimationFrame(tryFocus);
|
|
2546
2892
|
else setTimeout(tryFocus, 0);
|
|
2547
2893
|
};
|
|
2548
|
-
this.indexOfRowIn = (rows, rowOriginal, rowId) => {
|
|
2549
|
-
const list = rows || [];
|
|
2550
|
-
for (let i = 0; i < list.length; i++) {
|
|
2551
|
-
const r = list[i];
|
|
2552
|
-
if (!r) continue;
|
|
2553
|
-
if (rowId != null && r.id === rowId) return i;
|
|
2554
|
-
if (rowOriginal != null && r.original === rowOriginal) return i;
|
|
2555
|
-
}
|
|
2556
|
-
return -1;
|
|
2557
|
-
};
|
|
2558
2894
|
this.endEdit = () => {
|
|
2559
2895
|
this._editingRow.value = -1;
|
|
2560
2896
|
this._editingCol.value = -1;
|
|
@@ -2616,7 +2952,7 @@ let DataTable = class DataTable extends SignalWatcher(LitElement) {
|
|
|
2616
2952
|
this.committedThisSession = true;
|
|
2617
2953
|
if (changed) {
|
|
2618
2954
|
const srcIndex = this.sourceIndexOfRow(this._editingRow.value);
|
|
2619
|
-
const next =
|
|
2955
|
+
const next = replaceRowValue(this.currentData(), srcIndex, field, newValue);
|
|
2620
2956
|
this.writeData(next);
|
|
2621
2957
|
this.dispatchEvent(new CustomEvent("cell-edit-commit", {
|
|
2622
2958
|
detail: {
|
|
@@ -2659,7 +2995,7 @@ let DataTable = class DataTable extends SignalWatcher(LitElement) {
|
|
|
2659
2995
|
const field = def && def.accessorKey != null ? def.accessorKey : colId;
|
|
2660
2996
|
const srcIndex = this.sourceIndexOfRow(this._activeRow.value);
|
|
2661
2997
|
this.committedThisSession = true;
|
|
2662
|
-
this.writeData(
|
|
2998
|
+
this.writeData(replaceRowValue(this.currentData(), srcIndex, field, newValue));
|
|
2663
2999
|
this.dispatchEvent(new CustomEvent("cell-edit-commit", {
|
|
2664
3000
|
detail: {
|
|
2665
3001
|
rowId,
|
|
@@ -2794,7 +3130,7 @@ let DataTable = class DataTable extends SignalWatcher(LitElement) {
|
|
|
2794
3130
|
this.editTransition = true;
|
|
2795
3131
|
if (changed) {
|
|
2796
3132
|
const srcIndex = this.sourceIndexOfRow(rowIndex);
|
|
2797
|
-
const next =
|
|
3133
|
+
const next = replaceRowValues(this.currentData(), srcIndex, fieldValues);
|
|
2798
3134
|
this.writeData(next);
|
|
2799
3135
|
this.dispatchEvent(new CustomEvent("row-edit-commit", {
|
|
2800
3136
|
detail: {
|
|
@@ -2824,17 +3160,6 @@ let DataTable = class DataTable extends SignalWatcher(LitElement) {
|
|
|
2824
3160
|
this.editTransition = false;
|
|
2825
3161
|
this.focusCellWhenReady(focusRow, focusCol);
|
|
2826
3162
|
};
|
|
2827
|
-
this.replaceRowValues = (rows, rowIndex, fieldValues) => {
|
|
2828
|
-
const src = rows || [];
|
|
2829
|
-
const fv = fieldValues || {};
|
|
2830
|
-
const out = [];
|
|
2831
|
-
for (let i = 0; i < src.length; i++) if (i === rowIndex) out.push({
|
|
2832
|
-
...src[i] || {},
|
|
2833
|
-
...fv
|
|
2834
|
-
});
|
|
2835
|
-
else out.push(src[i]);
|
|
2836
|
-
return out;
|
|
2837
|
-
};
|
|
2838
3163
|
this.nextEditableCell = (fromRow, fromCol) => {
|
|
2839
3164
|
const rowList = this._rows.value || [];
|
|
2840
3165
|
const rowCount = rowList.length;
|
|
@@ -3019,8 +3344,8 @@ let DataTable = class DataTable extends SignalWatcher(LitElement) {
|
|
|
3019
3344
|
const lastRow = this.bodyRowCount() - 1;
|
|
3020
3345
|
const maxRow = lastRow < 0 ? 0 : lastRow;
|
|
3021
3346
|
const maxCol = this.visibleColCount() - 1;
|
|
3022
|
-
const r =
|
|
3023
|
-
const c =
|
|
3347
|
+
const r = clamp(Math.trunc(Number(rowIndex)) || 0, 0, maxRow);
|
|
3348
|
+
const c = clamp(Math.trunc(Number(colIndex)) || 0, 0, maxCol < 0 ? 0 : maxCol);
|
|
3024
3349
|
this.committedThisSession = false;
|
|
3025
3350
|
this._activeIsHeader.value = false;
|
|
3026
3351
|
this._activeRow.value = r;
|
|
@@ -3037,7 +3362,7 @@ let DataTable = class DataTable extends SignalWatcher(LitElement) {
|
|
|
3037
3362
|
this.editRow = (rowIndex) => {
|
|
3038
3363
|
const lastRow = this.bodyRowCount() - 1;
|
|
3039
3364
|
const maxRow = lastRow < 0 ? 0 : lastRow;
|
|
3040
|
-
const r =
|
|
3365
|
+
const r = clamp(Math.trunc(Number(rowIndex)) || 0, 0, maxRow);
|
|
3041
3366
|
const row = (this._rows.value || [])[r];
|
|
3042
3367
|
if (!row) return;
|
|
3043
3368
|
this._activeIsHeader.value = false;
|
|
@@ -3071,12 +3396,13 @@ let DataTable = class DataTable extends SignalWatcher(LitElement) {
|
|
|
3071
3396
|
if (!this.isGrid()) return;
|
|
3072
3397
|
this.focusIntentEpoch = this.focusIntentEpoch + 1;
|
|
3073
3398
|
const maxCol = this.visibleColCount() - 1;
|
|
3074
|
-
const c =
|
|
3399
|
+
const c = clamp(Math.trunc(Number(colIndex)) || 0, 0, maxCol < 0 ? 0 : maxCol);
|
|
3075
3400
|
const absLast = this.prePaginationRowCount() - 1;
|
|
3076
|
-
const absRow =
|
|
3401
|
+
const absRow = clamp(Math.trunc(Number(rowIndex)) || 0, 0, absLast < 0 ? 0 : absLast);
|
|
3077
3402
|
const prevAbs = this.toAbsRow(this._activeRow.value);
|
|
3403
|
+
const prevCol = this._activeColIndex.value;
|
|
3078
3404
|
const prevIsHeader = this._activeIsHeader.value;
|
|
3079
|
-
if (this.
|
|
3405
|
+
if (this.rowsWindowed()) {
|
|
3080
3406
|
this._activeIsHeader.value = false;
|
|
3081
3407
|
this._activeInControl.value = false;
|
|
3082
3408
|
this._activeRow.value = absRow;
|
|
@@ -3095,7 +3421,7 @@ let DataTable = class DataTable extends SignalWatcher(LitElement) {
|
|
|
3095
3421
|
if (switched) this.focusAbsCellWhenReady(absRow, localRow, c);
|
|
3096
3422
|
else this.focusActiveCell(localRow, c, false);
|
|
3097
3423
|
}
|
|
3098
|
-
if (absRow !== prevAbs || prevIsHeader) this.dispatchEvent(new CustomEvent("activecell-change", {
|
|
3424
|
+
if (absRow !== prevAbs || c !== prevCol || prevIsHeader) this.dispatchEvent(new CustomEvent("activecell-change", {
|
|
3099
3425
|
detail: {
|
|
3100
3426
|
rowIndex: absRow,
|
|
3101
3427
|
colIndex: c
|
|
@@ -3179,6 +3505,13 @@ let DataTable = class DataTable extends SignalWatcher(LitElement) {
|
|
|
3179
3505
|
font: var(--rdt-font, 14px system-ui, sans-serif);
|
|
3180
3506
|
color: var(--rdt-color, inherit);
|
|
3181
3507
|
}
|
|
3508
|
+
.rozie-data-table.rdt-col-windowed[data-rozie-s-d5dcab4c] {
|
|
3509
|
+
table-layout: fixed;
|
|
3510
|
+
}
|
|
3511
|
+
.rozie-data-table.rdt-col-windowed[data-rozie-s-d5dcab4c] .rdt-th[data-rozie-s-d5dcab4c],
|
|
3512
|
+
.rozie-data-table.rdt-col-windowed[data-rozie-s-d5dcab4c] .rdt-td[data-rozie-s-d5dcab4c] {
|
|
3513
|
+
box-sizing: border-box;
|
|
3514
|
+
}
|
|
3182
3515
|
.rdt-sr-live[data-rozie-s-d5dcab4c] {
|
|
3183
3516
|
position: absolute;
|
|
3184
3517
|
width: 1px;
|
|
@@ -3715,10 +4048,11 @@ let DataTable = class DataTable extends SignalWatcher(LitElement) {
|
|
|
3715
4048
|
this._rows.value = nextRows;
|
|
3716
4049
|
this._headerGroups.value = nextGroups;
|
|
3717
4050
|
this._rowModelVer.value = this._rowModelVer.value + 1;
|
|
3718
|
-
if (this.
|
|
4051
|
+
if (this.rowsWindowed() && this.virtualizer) {
|
|
3719
4052
|
this.virtualizer.setOptions(this.virtualizerOptions());
|
|
3720
4053
|
this.virtualizer._willUpdate();
|
|
3721
4054
|
}
|
|
4055
|
+
this.remeasureColumnWindow();
|
|
3722
4056
|
const nextRowCount = nextRows.length;
|
|
3723
4057
|
const nextColCount = nextRows.length ? nextRows[0].getVisibleCells().length : nextGroups.length ? (nextGroups[nextGroups.length - 1].headers || []).length : 0;
|
|
3724
4058
|
this.clampActiveCell(nextRowCount, nextColCount);
|
|
@@ -3731,7 +4065,7 @@ let DataTable = class DataTable extends SignalWatcher(LitElement) {
|
|
|
3731
4065
|
if (this.pendingEditFollow && this.isGrid()) {
|
|
3732
4066
|
const follow = this.pendingEditFollow;
|
|
3733
4067
|
this.pendingEditFollow = null;
|
|
3734
|
-
const followIdx =
|
|
4068
|
+
const followIdx = indexOfRowIn(nextRows, follow.rowOriginal, follow.rowId);
|
|
3735
4069
|
if (followIdx >= 0) this.focusCellWhenReady(followIdx, follow.col);
|
|
3736
4070
|
}
|
|
3737
4071
|
this.syncIndeterminate();
|
|
@@ -3740,17 +4074,28 @@ let DataTable = class DataTable extends SignalWatcher(LitElement) {
|
|
|
3740
4074
|
};
|
|
3741
4075
|
this.refreshRowModel();
|
|
3742
4076
|
this.gridRoot = this._ref__rozieRoot ? this._ref__rozieRoot.querySelector(".rozie-data-table") : null;
|
|
3743
|
-
if (this.
|
|
3744
|
-
|
|
4077
|
+
if (this.isWindowed()) this.gridScrollEl = this._ref__rozieRoot ? this._ref__rozieRoot.querySelector(".rdt-scroll") : null;
|
|
4078
|
+
if (this.rowsWindowed()) {
|
|
3745
4079
|
this.virtualizer = new Virtualizer(this.virtualizerOptions());
|
|
3746
4080
|
this.virtualizerCleanup = this.virtualizer._didMount();
|
|
3747
|
-
|
|
4081
|
+
}
|
|
4082
|
+
if (this.colsWindowed()) {
|
|
4083
|
+
this.colVirtualizer = new Virtualizer(this.columnVirtualizerOptions());
|
|
4084
|
+
this.colVirtualizerCleanup = this.colVirtualizer._didMount();
|
|
4085
|
+
}
|
|
4086
|
+
if (this.isWindowed()) this._windowVer.value = this._windowVer.value + 1;
|
|
4087
|
+
if (this.isWindowed()) {
|
|
3748
4088
|
const afterFirstFrame = () => {
|
|
3749
|
-
this.
|
|
3750
|
-
|
|
3751
|
-
|
|
3752
|
-
|
|
3753
|
-
|
|
4089
|
+
if (this.rowsWindowed()) {
|
|
4090
|
+
this.remeasureWindow();
|
|
4091
|
+
if (!(this.gridScrollEl ? this.gridScrollEl.clientHeight : 0)) console.warn("[rozie-data-table] virtual is on but the scroll container has no bounded height; set maxHeight or --rozie-data-table-max-height");
|
|
4092
|
+
const pg = this.pagination;
|
|
4093
|
+
const pgConfigured = pg != null && !(pg.pageIndex === 0 && pg.pageSize === 10);
|
|
4094
|
+
if (this.manual !== true && pgConfigured) console.warn("[rozie-data-table] virtual+pagination: client pagination is configured but virtual windowing replaces it — the pagination chrome is auto-suppressed. Remove the pagination prop or set manual to silence this.");
|
|
4095
|
+
}
|
|
4096
|
+
if (this.colsWindowed()) {
|
|
4097
|
+
if (!(this.gridScrollEl ? this.gridScrollEl.clientWidth : 0)) console.warn("[rozie-data-table] virtual is on for columns but the scroll container has no bounded width; set a CSS width on an ancestor so the column window can be measured");
|
|
4098
|
+
}
|
|
3754
4099
|
};
|
|
3755
4100
|
if (typeof requestAnimationFrame === "function") requestAnimationFrame(() => requestAnimationFrame(afterFirstFrame));
|
|
3756
4101
|
else setTimeout(afterFirstFrame, 0);
|
|
@@ -3835,10 +4180,11 @@ ${this.groupable ? html`<div class="rdt-group-bar-host" data-rozie-s-d5dcab4c>
|
|
|
3835
4180
|
})()} @rozie-group-bar-apply-grouping=${($event) => this.applyGrouping($event.detail)} @rozie-group-bar-clear-grouping=${($event) => this.clearGrouping($event.detail)}>
|
|
3836
4181
|
${repeat(this.groupingKeys(), (gk, _idx) => gk, (gk, _idx) => html`<span class="rdt-group-token" data-group-token="" data-rozie-s-d5dcab4c>${rozieDisplay(gk)}</span>`)}
|
|
3837
4182
|
</slot>`}
|
|
3838
|
-
</div>` : nothing}${this.
|
|
4183
|
+
</div>` : nothing}${this.isWindowed() ? html`<div class="rdt-scroll" style=${rozieStyle(this.rowsWindowed() && this.maxHeight ? "max-height:" + this.maxHeight + ";overflow:auto;--rozie-data-table-max-height:" + this.maxHeight : "overflow:auto")} data-rozie-s-d5dcab4c>
|
|
3839
4184
|
<table class="${Object.entries({
|
|
3840
4185
|
"rozie-data-table": true,
|
|
3841
|
-
"rdt-sticky": this.stickyHeader
|
|
4186
|
+
"rdt-sticky": this.stickyHeader,
|
|
4187
|
+
"rdt-col-windowed": this.colsWindowed()
|
|
3842
4188
|
}).filter(([, v]) => v).map(([k]) => k).join(" ")}" role=${rozieAttr(this.tableRole())} aria-rowcount=${rozieAttr(this.gridAriaRowCount())} @keydown=${($event) => {
|
|
3843
4189
|
this.onGridKeyDown($event);
|
|
3844
4190
|
}} @focusin=${($event) => {
|
|
@@ -3854,14 +4200,15 @@ ${this.groupable ? html`<div class="rdt-group-bar-host" data-rozie-s-d5dcab4c>
|
|
|
3854
4200
|
}} data-rozie-s-d5dcab4c>
|
|
3855
4201
|
<thead class="rdt-thead" role="rowgroup" data-rozie-s-d5dcab4c>
|
|
3856
4202
|
${repeat(this._headerGroups.value, (hg, hgLevel) => hg.id, (hg, hgLevel) => html`<tr class="rdt-tr" role="row" aria-rowindex=${rozieAttr(hgLevel + 1)} data-rozie-s-d5dcab4c>
|
|
3857
|
-
|
|
4203
|
+
|
|
4204
|
+
${this.colsWindowed() ? html`<th class="rdt-col-spacer" aria-hidden="true" style=${rozieStyle("width:" + this.colPadLeft() + "px;padding:0;border:0")} data-rozie-s-d5dcab4c></th>` : nothing}${repeat(this.windowedHeadersFor(hg, hgLevel), (wh, _idx) => wh.header.id, (wh, _idx) => html`<th class="${Object.entries({
|
|
3858
4205
|
"rdt-th": true,
|
|
3859
|
-
"rdt-select-th": this.isSelectColumn(header.column.id),
|
|
3860
|
-
"rdt-expander-th": this.isExpanderColumn(header.column.id),
|
|
3861
|
-
"rdt-th-resizing": this.columnIsResizing(header.column.id),
|
|
3862
|
-
"rdt-cell-active": this.isActiveCell("__header", this.headerColIndexOf(hg, header), hgLevel)
|
|
3863
|
-
}).filter(([, v]) => v).map(([k]) => k).join(" ")}" role="columnheader" data-col=${rozieAttr(header.column.id)} data-grid-cell="" data-row="__header" data-header-level=${rozieAttr(hgLevel)} colspan=${rozieAttr(
|
|
3864
|
-
${this.isSelectColumn(header.column.id) ? html`<span style="display:contents" data-rozie-s-d5dcab4c>
|
|
4206
|
+
"rdt-select-th": this.isSelectColumn(wh.header.column.id),
|
|
4207
|
+
"rdt-expander-th": this.isExpanderColumn(wh.header.column.id),
|
|
4208
|
+
"rdt-th-resizing": this.columnIsResizing(wh.header.column.id),
|
|
4209
|
+
"rdt-cell-active": this.isActiveCell("__header", this.headerColIndexOf(hg, wh.header), hgLevel)
|
|
4210
|
+
}).filter(([, v]) => v).map(([k]) => k).join(" ")}" role="columnheader" data-col=${rozieAttr(wh.header.column.id)} data-grid-cell="" data-row="__header" data-header-level=${rozieAttr(hgLevel)} colspan=${rozieAttr(wh.span > 1 ? wh.span : null)} data-col-index=${rozieAttr(this.headerColIndexOf(hg, wh.header))} tabindex=${rozieAttr(this.cellTabindex("__header", this.headerColIndexOf(hg, wh.header), hgLevel))} aria-sort=${rozieAttr(this.ariaSortFor(wh.header.column.id))} style=${rozieStyle(this.thStyle(wh.header.column.id))} data-rozie-s-d5dcab4c>
|
|
4211
|
+
${this.isSelectColumn(wh.header.column.id) ? html`<span style="display:contents" data-rozie-s-d5dcab4c>
|
|
3865
4212
|
${this.selectAll !== void 0 ? this.selectAll({
|
|
3866
4213
|
checked: this.isAllRowsSelected(),
|
|
3867
4214
|
indeterminate: this.isSomeRowsSelected(),
|
|
@@ -3879,102 +4226,103 @@ ${this.groupable ? html`<div class="rdt-group-bar-host" data-rozie-s-d5dcab4c>
|
|
|
3879
4226
|
${this.selectionMode === "multiple" ? html`<input class="rdt-select-all" type="checkbox" aria-label="Select all rows" ?checked=${this.isAllRowsSelected()} @change=${($event) => {
|
|
3880
4227
|
this.onToggleAllRows($event);
|
|
3881
4228
|
}} data-rozie-s-d5dcab4c />` : nothing}</slot>`}
|
|
3882
|
-
</span>` : this.isExpanderColumn(header.column.id) ? html`<span style="display:contents" data-rozie-s-d5dcab4c></span>` : html`<span style="display:contents" data-rozie-s-d5dcab4c>
|
|
3883
|
-
${header.column.getCanSort && header.column.getCanSort() ? html`<button class="rdt-sort-btn" type="button" @click=${($event) => {
|
|
3884
|
-
this.onHeaderSort(header.column.id, $event);
|
|
4229
|
+
</span>` : this.isExpanderColumn(wh.header.column.id) ? html`<span style="display:contents" data-rozie-s-d5dcab4c></span>` : html`<span style="display:contents" data-rozie-s-d5dcab4c>
|
|
4230
|
+
${wh.header.column.getCanSort && wh.header.column.getCanSort() ? html`<button class="rdt-sort-btn" type="button" @click=${($event) => {
|
|
4231
|
+
this.onHeaderSort(wh.header.column.id, $event);
|
|
3885
4232
|
}} data-rozie-s-d5dcab4c>
|
|
3886
4233
|
<span class="rdt-header-label" data-rozie-s-d5dcab4c>
|
|
3887
4234
|
${this.colHeader !== void 0 ? this.colHeader({
|
|
3888
|
-
columnId: header.column.id,
|
|
3889
|
-
column: header.column,
|
|
3890
|
-
label: this.headerLabel(header.column.id)
|
|
4235
|
+
columnId: wh.header.column.id,
|
|
4236
|
+
column: wh.header.column,
|
|
4237
|
+
label: this.headerLabel(wh.header.column.id)
|
|
3891
4238
|
}) : html`<slot name="colHeader" data-rozie-params=${(() => {
|
|
3892
4239
|
try {
|
|
3893
4240
|
return JSON.stringify({
|
|
3894
|
-
columnId: header.column.id,
|
|
3895
|
-
column: header.column,
|
|
3896
|
-
label: this.headerLabel(header.column.id)
|
|
4241
|
+
columnId: wh.header.column.id,
|
|
4242
|
+
column: wh.header.column,
|
|
4243
|
+
label: this.headerLabel(wh.header.column.id)
|
|
3897
4244
|
});
|
|
3898
4245
|
} catch {
|
|
3899
4246
|
return "{}";
|
|
3900
4247
|
}
|
|
3901
|
-
})()}>${rozieDisplay(this.headerLabel(header.column.id))}</slot>`}
|
|
4248
|
+
})()}>${rozieDisplay(this.headerLabel(wh.header.column.id))}</slot>`}
|
|
3902
4249
|
</span>
|
|
3903
|
-
<span class="rdt-sort-ind" aria-hidden="true" data-rozie-s-d5dcab4c>${rozieDisplay(this.sortIndicator(header.column.id))}</span>
|
|
4250
|
+
<span class="rdt-sort-ind" aria-hidden="true" data-rozie-s-d5dcab4c>${rozieDisplay(this.sortIndicator(wh.header.column.id))}</span>
|
|
3904
4251
|
</button>` : html`<span style="display:contents" data-rozie-s-d5dcab4c>
|
|
3905
4252
|
<span class="rdt-header-label" data-rozie-s-d5dcab4c>
|
|
3906
4253
|
${this.colHeader !== void 0 ? this.colHeader({
|
|
3907
|
-
columnId: header.column.id,
|
|
3908
|
-
column: header.column,
|
|
3909
|
-
label: this.headerLabel(header.column.id)
|
|
4254
|
+
columnId: wh.header.column.id,
|
|
4255
|
+
column: wh.header.column,
|
|
4256
|
+
label: this.headerLabel(wh.header.column.id)
|
|
3910
4257
|
}) : html`<slot name="colHeader" data-rozie-params=${(() => {
|
|
3911
4258
|
try {
|
|
3912
4259
|
return JSON.stringify({
|
|
3913
|
-
columnId: header.column.id,
|
|
3914
|
-
column: header.column,
|
|
3915
|
-
label: this.headerLabel(header.column.id)
|
|
4260
|
+
columnId: wh.header.column.id,
|
|
4261
|
+
column: wh.header.column,
|
|
4262
|
+
label: this.headerLabel(wh.header.column.id)
|
|
3916
4263
|
});
|
|
3917
4264
|
} catch {
|
|
3918
4265
|
return "{}";
|
|
3919
4266
|
}
|
|
3920
|
-
})()}>${rozieDisplay(this.headerLabel(header.column.id))}</slot>`}
|
|
4267
|
+
})()}>${rozieDisplay(this.headerLabel(wh.header.column.id))}</slot>`}
|
|
3921
4268
|
</span>
|
|
3922
|
-
</span>`}<rozie-popover trigger="click" placement="bottom-end" strategy="fixed" .offset=${4} data-rozie-s-d5dcab4c><button class="rdt-col-menu-trigger" type="button" aria-label=${rozieAttr("Column options for " + this.headerLabel(header.column.id))} data-rozie-s-d5dcab4c slot="anchor">⋯</button><div class="rdt-col-menu" role="menu" data-rozie-s-d5dcab4c>
|
|
3923
|
-
<button class="rdt-col-menu-item" type="button" role="menuitem" aria-pressed=${this.columnPinSide(header.column.id) === "left"} @click=${($event) => {
|
|
3924
|
-
this.onPinColumn(header.column.id, "left", $event);
|
|
4269
|
+
</span>`}<rozie-popover trigger="click" placement="bottom-end" strategy="fixed" .offset=${4} data-rozie-s-d5dcab4c><button class="rdt-col-menu-trigger" type="button" aria-label=${rozieAttr("Column options for " + this.headerLabel(wh.header.column.id))} data-rozie-s-d5dcab4c slot="anchor">⋯</button><div class="rdt-col-menu" role="menu" data-rozie-s-d5dcab4c>
|
|
4270
|
+
<button class="rdt-col-menu-item" type="button" role="menuitem" aria-pressed=${this.columnPinSide(wh.header.column.id) === "left"} @click=${($event) => {
|
|
4271
|
+
this.onPinColumn(wh.header.column.id, "left", $event);
|
|
3925
4272
|
}} data-rozie-s-d5dcab4c>Pin left</button>
|
|
3926
|
-
<button class="rdt-col-menu-item" type="button" role="menuitem" aria-pressed=${this.columnPinSide(header.column.id) === "right"} @click=${($event) => {
|
|
3927
|
-
this.onPinColumn(header.column.id, "right", $event);
|
|
4273
|
+
<button class="rdt-col-menu-item" type="button" role="menuitem" aria-pressed=${this.columnPinSide(wh.header.column.id) === "right"} @click=${($event) => {
|
|
4274
|
+
this.onPinColumn(wh.header.column.id, "right", $event);
|
|
3928
4275
|
}} data-rozie-s-d5dcab4c>Pin right</button>
|
|
3929
|
-
<button class="rdt-col-menu-item" type="button" role="menuitem" aria-pressed=${!this.columnPinSide(header.column.id)} @click=${($event) => {
|
|
3930
|
-
this.onPinColumn(header.column.id, false, $event);
|
|
4276
|
+
<button class="rdt-col-menu-item" type="button" role="menuitem" aria-pressed=${!this.columnPinSide(wh.header.column.id)} @click=${($event) => {
|
|
4277
|
+
this.onPinColumn(wh.header.column.id, false, $event);
|
|
3931
4278
|
}} data-rozie-s-d5dcab4c>Unpin</button>
|
|
3932
4279
|
<hr class="rdt-col-menu-sep" data-rozie-s-d5dcab4c />
|
|
3933
4280
|
<button class="rdt-col-menu-item" type="button" role="menuitem" @click=${($event) => {
|
|
3934
|
-
this.onHideColumn(header.column.id, $event);
|
|
4281
|
+
this.onHideColumn(wh.header.column.id, $event);
|
|
3935
4282
|
}} data-rozie-s-d5dcab4c>Hide column</button>
|
|
3936
4283
|
</div></rozie-popover>
|
|
3937
|
-
<button class="rdt-resize-handle" type="button" aria-label=${rozieAttr("Resize " + this.headerLabel(header.column.id))} @pointerdown=${($event) => {
|
|
3938
|
-
this.onResizeStart(header.column.id, $event);
|
|
4284
|
+
<button class="rdt-resize-handle" type="button" aria-label=${rozieAttr("Resize " + this.headerLabel(wh.header.column.id))} @pointerdown=${($event) => {
|
|
4285
|
+
this.onResizeStart(wh.header.column.id, $event);
|
|
3939
4286
|
}} @touchstart=${($event) => {
|
|
3940
|
-
this.onResizeStart(header.column.id, $event);
|
|
4287
|
+
this.onResizeStart(wh.header.column.id, $event);
|
|
3941
4288
|
}} data-rozie-s-d5dcab4c><span class="rdt-resize-grip" aria-hidden="true" data-rozie-s-d5dcab4c></span></button>
|
|
3942
4289
|
</span>`}</th>`)}
|
|
3943
|
-
|
|
4290
|
+
|
|
4291
|
+
${this.colsWindowed() ? html`<th class="rdt-col-spacer" aria-hidden="true" style=${rozieStyle("width:" + this.colPadRight() + "px;padding:0;border:0")} data-rozie-s-d5dcab4c></th>` : nothing}</tr>`)}
|
|
3944
4292
|
|
|
3945
4293
|
${this.hasAnyFilterableColumn() ? html`<tr class="rdt-filter-row" data-rozie-s-d5dcab4c>
|
|
3946
|
-
${repeat(this._headerGroups.value[this._headerGroups.value.length - 1].
|
|
3947
|
-
${this.isSelectColumn(header.column.id) ? html`<span style="display:contents" data-rozie-s-d5dcab4c></span>` : this.isExpanderColumn(header.column.id) ? html`<span style="display:contents" data-rozie-s-d5dcab4c></span>` : html`<span style="display:contents" data-rozie-s-d5dcab4c>
|
|
3948
|
-
${this.columnIsFilterable(header.column.id) && !this.hasFilterSlot() ? html`<input class="rdt-col-filter" type="text" aria-label=${rozieAttr("Filter " + this.headerLabel(header.column.id))} .value=${this.columnFilterValue(header.column.id)} @input=${($event) => {
|
|
3949
|
-
this.onColumnFilterInput(header.column.id, $event);
|
|
4294
|
+
${this.colsWindowed() ? html`<th class="rdt-col-spacer" aria-hidden="true" style=${rozieStyle("width:" + this.colPadLeft() + "px;padding:0;border:0")} data-rozie-s-d5dcab4c></th>` : nothing}${repeat(this.windowedHeadersFor(this._headerGroups.value[this._headerGroups.value.length - 1], this._headerGroups.value.length - 1), (wh, _idx) => wh.header.id, (wh, _idx) => html`<th class="rdt-filter-cell" role="presentation" data-col=${rozieAttr(wh.header.column.id)} style=${rozieStyle(this.pinStyle(wh.header.column.id))} data-rozie-s-d5dcab4c>
|
|
4295
|
+
${this.isSelectColumn(wh.header.column.id) ? html`<span style="display:contents" data-rozie-s-d5dcab4c></span>` : this.isExpanderColumn(wh.header.column.id) ? html`<span style="display:contents" data-rozie-s-d5dcab4c></span>` : html`<span style="display:contents" data-rozie-s-d5dcab4c>
|
|
4296
|
+
${this.columnIsFilterable(wh.header.column.id) && !this.hasFilterSlot() ? html`<input class="rdt-col-filter" type="text" aria-label=${rozieAttr("Filter " + this.headerLabel(wh.header.column.id))} .value=${this.columnFilterValue(wh.header.column.id)} @input=${($event) => {
|
|
4297
|
+
this.onColumnFilterInput(wh.header.column.id, $event);
|
|
3950
4298
|
}} @click=${($event) => {
|
|
3951
4299
|
this.stopEvent($event);
|
|
3952
|
-
}} data-rozie-s-d5dcab4c />` : nothing}${this.columnIsFilterable(header.column.id) ? html`<span style="display:contents" data-rozie-s-d5dcab4c>
|
|
4300
|
+
}} data-rozie-s-d5dcab4c />` : nothing}${this.columnIsFilterable(wh.header.column.id) ? html`<span style="display:contents" data-rozie-s-d5dcab4c>
|
|
3953
4301
|
${this.filter !== void 0 ? this.filter({
|
|
3954
|
-
columnId: header.column.id,
|
|
3955
|
-
value: this.columnFilterValue(header.column.id),
|
|
3956
|
-
uniqueValues: this.getFacetedUniqueValues(header.column.id),
|
|
3957
|
-
minMax: this.getFacetedMinMaxValues(header.column.id),
|
|
4302
|
+
columnId: wh.header.column.id,
|
|
4303
|
+
value: this.columnFilterValue(wh.header.column.id),
|
|
4304
|
+
uniqueValues: this.getFacetedUniqueValues(wh.header.column.id),
|
|
4305
|
+
minMax: this.getFacetedMinMaxValues(wh.header.column.id),
|
|
3958
4306
|
setFilter: this.setColumnFilter
|
|
3959
4307
|
}) : html`<slot name="filter" data-rozie-params=${(() => {
|
|
3960
4308
|
try {
|
|
3961
4309
|
return JSON.stringify({
|
|
3962
|
-
columnId: header.column.id,
|
|
3963
|
-
value: this.columnFilterValue(header.column.id),
|
|
3964
|
-
uniqueValues: this.getFacetedUniqueValues(header.column.id),
|
|
3965
|
-
minMax: this.getFacetedMinMaxValues(header.column.id)
|
|
4310
|
+
columnId: wh.header.column.id,
|
|
4311
|
+
value: this.columnFilterValue(wh.header.column.id),
|
|
4312
|
+
uniqueValues: this.getFacetedUniqueValues(wh.header.column.id),
|
|
4313
|
+
minMax: this.getFacetedMinMaxValues(wh.header.column.id)
|
|
3966
4314
|
});
|
|
3967
4315
|
} catch {
|
|
3968
4316
|
return "{}";
|
|
3969
4317
|
}
|
|
3970
4318
|
})()} @rozie-filter-set-filter=${($event) => this.setColumnFilter($event.detail)}></slot>`}
|
|
3971
4319
|
</span>` : nothing}</span>`}</th>`)}
|
|
3972
|
-
|
|
4320
|
+
${this.colsWindowed() ? html`<th class="rdt-col-spacer" aria-hidden="true" style=${rozieStyle("width:" + this.colPadRight() + "px;padding:0;border:0")} data-rozie-s-d5dcab4c></th>` : nothing}</tr>` : nothing}</thead>
|
|
3973
4321
|
|
|
3974
4322
|
<tbody class="rdt-tbody" role="rowgroup" data-rozie-s-d5dcab4c>
|
|
3975
4323
|
|
|
3976
4324
|
<tr class="rdt-spacer" aria-hidden="true" data-rozie-s-d5dcab4c>
|
|
3977
|
-
<td colspan=${rozieAttr(this.
|
|
4325
|
+
<td colspan=${rozieAttr(this.windowedColSpan())} style=${rozieStyle("height:" + this.padTop() + "px;padding:0;border:0")} data-rozie-s-d5dcab4c></td>
|
|
3978
4326
|
</tr>
|
|
3979
4327
|
|
|
3980
4328
|
${repeat(this.windowedRows(), (wr, _idx) => wr.row.id, (wr, _idx) => html`
|
|
@@ -3983,7 +4331,8 @@ ${this.groupable ? html`<div class="rdt-group-bar-host" data-rozie-s-d5dcab4c>
|
|
|
3983
4331
|
"rdt-group-header": this.rowIsGrouped(wr.row),
|
|
3984
4332
|
"rdt-row-pinned": wr.pinned
|
|
3985
4333
|
}).filter(([, v]) => v).map(([k]) => k).join(" ")}" role="row" data-row=${rozieAttr(wr.vi.index)} aria-rowindex=${rozieAttr(this.headerRowCount() + wr.vi.index + 1)} data-index=${rozieAttr(wr.vi.index)} data-pinned=${rozieAttr(wr.pinned ? "true" : null)} data-depth=${rozieAttr(wr.row.depth)} data-group-header=${rozieAttr(this.rowIsGrouped(wr.row) ? wr.row.id : null)} data-group-leaf=${rozieAttr(this.groupingActive() && !this.rowIsGrouped(wr.row) ? wr.row.id : null)} aria-expanded=${rozieAttr(this.rowIsGrouped(wr.row) ? !!this.rowIsExpanded(wr.row) : null)} aria-selected=${rozieAttr(this.selectionMode !== "none" ? !!this.rowIsSelected(wr.row) : null)} aria-level=${rozieAttr(this.groupingActive() ? wr.row.depth + 1 : null)} data-rozie-s-d5dcab4c>
|
|
3986
|
-
|
|
4334
|
+
|
|
4335
|
+
${this.colsWindowed() ? html`<td class="rdt-col-spacer" aria-hidden="true" style=${rozieStyle("width:" + this.colPadLeft() + "px;padding:0;border:0")} data-rozie-s-d5dcab4c></td>` : nothing}${repeat(this.windowedCells(wr.row), (cell, _idx) => cell.id, (cell, _idx) => html`<td class="${Object.entries({
|
|
3987
4336
|
"rdt-td": true,
|
|
3988
4337
|
"rdt-select-td": this.isSelectColumn(cell.column.id),
|
|
3989
4338
|
"rdt-expander-td": this.isExpanderColumn(cell.column.id),
|
|
@@ -4109,10 +4458,11 @@ ${this.groupable ? html`<div class="rdt-group-bar-host" data-rozie-s-d5dcab4c>
|
|
|
4109
4458
|
</span>`}${this.isFillHandleCell(wr.vi.index, this.colIndexOf(wr.row, cell)) ? html`<span class="rdt-fill-handle" data-fill-handle="" data-testid="fill-handle" aria-hidden="true" @pointerdown=${($event) => {
|
|
4110
4459
|
this.onFillHandlePointerDown($event);
|
|
4111
4460
|
}} data-rozie-s-d5dcab4c></span>` : nothing}</td>`)}
|
|
4112
|
-
|
|
4461
|
+
|
|
4462
|
+
${this.colsWindowed() ? html`<td class="rdt-col-spacer" aria-hidden="true" style=${rozieStyle("width:" + this.colPadRight() + "px;padding:0;border:0")} data-rozie-s-d5dcab4c></td>` : nothing}</tr>
|
|
4113
4463
|
|
|
4114
4464
|
${this.rowShowsDetail(wr.row) ? html`<tr class="rdt-detail-row" role="row" data-detail-row=${rozieAttr(wr.row.id)} data-rozie-s-d5dcab4c>
|
|
4115
|
-
<td class="rdt-detail-cell" colspan=${rozieAttr(this.
|
|
4465
|
+
<td class="rdt-detail-cell" colspan=${rozieAttr(this.windowedColSpan())} data-rozie-s-d5dcab4c>
|
|
4116
4466
|
${this.detail !== void 0 ? this.detail({ row: wr.row.original }) : html`<slot name="detail" data-rozie-params=${(() => {
|
|
4117
4467
|
try {
|
|
4118
4468
|
return JSON.stringify({ row: wr.row.original });
|
|
@@ -4124,7 +4474,7 @@ ${this.groupable ? html`<div class="rdt-group-bar-host" data-rozie-s-d5dcab4c>
|
|
|
4124
4474
|
</tr>` : nothing}`)}
|
|
4125
4475
|
|
|
4126
4476
|
<tr class="rdt-spacer" aria-hidden="true" data-rozie-s-d5dcab4c>
|
|
4127
|
-
<td colspan=${rozieAttr(this.
|
|
4477
|
+
<td colspan=${rozieAttr(this.windowedColSpan())} style=${rozieStyle("height:" + this.padBottom() + "px;padding:0;border:0")} data-rozie-s-d5dcab4c></td>
|
|
4128
4478
|
</tr>
|
|
4129
4479
|
</tbody>
|
|
4130
4480
|
</table>
|
|
@@ -4416,7 +4766,7 @@ ${this.groupable ? html`<div class="rdt-group-bar-host" data-rozie-s-d5dcab4c>
|
|
|
4416
4766
|
</td>
|
|
4417
4767
|
</tr>` : nothing}`)}
|
|
4418
4768
|
</tbody>
|
|
4419
|
-
</table>`}${!this.
|
|
4769
|
+
</table>`}${!this.rowsWindowed() ? html`<div class="rdt-pagination" role="group" aria-label="Pagination" data-rozie-s-d5dcab4c>
|
|
4420
4770
|
<button class="rdt-page-btn rdt-page-prev" type="button" ?disabled=${!this.canPrevPage()} @click=${($event) => {
|
|
4421
4771
|
this.onPrevPage();
|
|
4422
4772
|
}} data-rozie-s-d5dcab4c>Prev</button>
|
|
@@ -4604,14 +4954,15 @@ __decorate([property({
|
|
|
4604
4954
|
type: Number,
|
|
4605
4955
|
reflect: true
|
|
4606
4956
|
})], DataTable.prototype, "undoLimit", void 0);
|
|
4607
|
-
__decorate([property({
|
|
4608
|
-
type: Boolean,
|
|
4609
|
-
reflect: true
|
|
4610
|
-
})], DataTable.prototype, "virtual", void 0);
|
|
4957
|
+
__decorate([property({ converter: { fromAttribute: (v) => v === null ? false : v === "true" ? true : v === "false" ? false : v === "" ? true : v } })], DataTable.prototype, "virtual", void 0);
|
|
4611
4958
|
__decorate([property({
|
|
4612
4959
|
type: Number,
|
|
4613
4960
|
reflect: true
|
|
4614
4961
|
})], DataTable.prototype, "estimateRowHeight", void 0);
|
|
4962
|
+
__decorate([property({
|
|
4963
|
+
type: Boolean,
|
|
4964
|
+
reflect: true
|
|
4965
|
+
})], DataTable.prototype, "autoMeasure", void 0);
|
|
4615
4966
|
__decorate([property({
|
|
4616
4967
|
type: String,
|
|
4617
4968
|
reflect: true
|