@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.cjs
CHANGED
|
@@ -11,6 +11,163 @@ let lit_directives_repeat_js = require("lit/directives/repeat.js");
|
|
|
11
11
|
require("@rozie-ui/popover-lit");
|
|
12
12
|
let _tanstack_table_core = require("@tanstack/table-core");
|
|
13
13
|
let _tanstack_virtual_core = require("@tanstack/virtual-core");
|
|
14
|
+
//#region src/helpers/columnDefUtils.ts
|
|
15
|
+
const isSafeKey = (k) => k !== "__proto__" && k !== "constructor" && k !== "prototype";
|
|
16
|
+
const wrapAggregationFn = (fn) => {
|
|
17
|
+
if (typeof fn === "string") return fn;
|
|
18
|
+
if (typeof fn !== "function") return void 0;
|
|
19
|
+
return (columnId, leafRows, childRows) => {
|
|
20
|
+
try {
|
|
21
|
+
return fn(columnId, leafRows, childRows);
|
|
22
|
+
} catch (err) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
//#endregion
|
|
28
|
+
//#region src/helpers/indexMath.ts
|
|
29
|
+
const clamp = (v, lo, hi) => v < lo ? lo : v > hi ? hi : v;
|
|
30
|
+
const focusables = (cellEl) => {
|
|
31
|
+
if (!cellEl || !cellEl.querySelectorAll) return [];
|
|
32
|
+
return Array.prototype.slice.call(cellEl.querySelectorAll("button,[href],input,select,textarea,[tabindex]:not([tabindex=\"-1\"])")).filter((n) => !n.disabled);
|
|
33
|
+
};
|
|
34
|
+
const applyUpdater = (updater, current) => typeof updater === "function" ? updater(current) : updater;
|
|
35
|
+
//#endregion
|
|
36
|
+
//#region src/helpers/tsvGrid.ts
|
|
37
|
+
const escapeTsvField = (s) => {
|
|
38
|
+
if (s.indexOf(" ") >= 0 || s.indexOf("\n") >= 0 || s.indexOf("\r") >= 0 || s.indexOf("\"") >= 0) return "\"" + s.replace(/"/g, "\"\"") + "\"";
|
|
39
|
+
return s;
|
|
40
|
+
};
|
|
41
|
+
const parseTsv = (text) => {
|
|
42
|
+
const str = text != null ? String(text) : "";
|
|
43
|
+
if (str === "" || str.length > 2e6) return [];
|
|
44
|
+
const rows = [];
|
|
45
|
+
let row = [];
|
|
46
|
+
let field = "";
|
|
47
|
+
let inQuotes = false;
|
|
48
|
+
let i = 0;
|
|
49
|
+
const n = str.length;
|
|
50
|
+
while (i < n) {
|
|
51
|
+
const ch = str[i];
|
|
52
|
+
if (inQuotes) {
|
|
53
|
+
if (ch === "\"") {
|
|
54
|
+
if (i + 1 < n && str[i + 1] === "\"") {
|
|
55
|
+
field = field + "\"";
|
|
56
|
+
i = i + 2;
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
inQuotes = false;
|
|
60
|
+
i = i + 1;
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
field = field + ch;
|
|
64
|
+
i = i + 1;
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
if (ch === "\"" && field === "") {
|
|
68
|
+
inQuotes = true;
|
|
69
|
+
i = i + 1;
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
if (ch === " ") {
|
|
73
|
+
row.push(field);
|
|
74
|
+
field = "";
|
|
75
|
+
i = i + 1;
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
if (ch === "\r") {
|
|
79
|
+
if (i + 1 < n && str[i + 1] === "\n") i = i + 1;
|
|
80
|
+
row.push(field);
|
|
81
|
+
field = "";
|
|
82
|
+
rows.push(row);
|
|
83
|
+
row = [];
|
|
84
|
+
i = i + 1;
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
if (ch === "\n") {
|
|
88
|
+
row.push(field);
|
|
89
|
+
field = "";
|
|
90
|
+
rows.push(row);
|
|
91
|
+
row = [];
|
|
92
|
+
i = i + 1;
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
field = field + ch;
|
|
96
|
+
i = i + 1;
|
|
97
|
+
}
|
|
98
|
+
row.push(field);
|
|
99
|
+
rows.push(row);
|
|
100
|
+
if (rows.length > 1) {
|
|
101
|
+
const last = rows[rows.length - 1];
|
|
102
|
+
if (last.length === 1 && last[0] === "") rows.pop();
|
|
103
|
+
}
|
|
104
|
+
return rows;
|
|
105
|
+
};
|
|
106
|
+
const tileGridToBox = (grid, box) => {
|
|
107
|
+
const srcRows = grid.length;
|
|
108
|
+
let srcCols = 0;
|
|
109
|
+
for (let i = 0; i < srcRows; i++) {
|
|
110
|
+
const w = grid[i] && grid[i].length ? grid[i].length : 0;
|
|
111
|
+
if (w > srcCols) srcCols = w;
|
|
112
|
+
}
|
|
113
|
+
if (srcRows <= 0 || srcCols <= 0) return grid;
|
|
114
|
+
const boxRows = box.r1 - box.r0 + 1;
|
|
115
|
+
const boxCols = box.c1 - box.c0 + 1;
|
|
116
|
+
const rows = boxRows > srcRows ? boxRows : srcRows;
|
|
117
|
+
const cols = boxCols > srcCols ? boxCols : srcCols;
|
|
118
|
+
const out = [];
|
|
119
|
+
for (let r = 0; r < rows; r++) {
|
|
120
|
+
const srcLine = grid[r % srcRows] || [];
|
|
121
|
+
const line = [];
|
|
122
|
+
for (let c = 0; c < cols; c++) {
|
|
123
|
+
const v = srcLine[c % srcCols];
|
|
124
|
+
line.push(v != null ? v : "");
|
|
125
|
+
}
|
|
126
|
+
out.push(line);
|
|
127
|
+
}
|
|
128
|
+
return out;
|
|
129
|
+
};
|
|
130
|
+
const tileIndex = (i, lo, hi) => {
|
|
131
|
+
const span = hi - lo + 1;
|
|
132
|
+
if (span <= 1) return lo;
|
|
133
|
+
let k = (i - lo) % span;
|
|
134
|
+
if (k < 0) k = k + span;
|
|
135
|
+
return lo + k;
|
|
136
|
+
};
|
|
137
|
+
//#endregion
|
|
138
|
+
//#region src/helpers/rowValueUtils.ts
|
|
139
|
+
const replaceRowValue = (rows, rowIndex, field, value) => {
|
|
140
|
+
const src = rows || [];
|
|
141
|
+
const out = [];
|
|
142
|
+
for (let i = 0; i < src.length; i++) if (i === rowIndex) out.push({
|
|
143
|
+
...src[i] || {},
|
|
144
|
+
[field]: value
|
|
145
|
+
});
|
|
146
|
+
else out.push(src[i]);
|
|
147
|
+
return out;
|
|
148
|
+
};
|
|
149
|
+
const replaceRowValues = (rows, rowIndex, fieldValues) => {
|
|
150
|
+
const src = rows || [];
|
|
151
|
+
const fv = fieldValues || {};
|
|
152
|
+
const out = [];
|
|
153
|
+
for (let i = 0; i < src.length; i++) if (i === rowIndex) out.push({
|
|
154
|
+
...src[i] || {},
|
|
155
|
+
...fv
|
|
156
|
+
});
|
|
157
|
+
else out.push(src[i]);
|
|
158
|
+
return out;
|
|
159
|
+
};
|
|
160
|
+
const indexOfRowIn = (rows, rowOriginal, rowId) => {
|
|
161
|
+
const list = rows || [];
|
|
162
|
+
for (let i = 0; i < list.length; i++) {
|
|
163
|
+
const r = list[i];
|
|
164
|
+
if (!r) continue;
|
|
165
|
+
if (rowId != null && r.id === rowId) return i;
|
|
166
|
+
if (rowOriginal != null && r.original === rowOriginal) return i;
|
|
167
|
+
}
|
|
168
|
+
return -1;
|
|
169
|
+
};
|
|
170
|
+
//#endregion
|
|
14
171
|
//#region \0@oxc-project+runtime@0.127.0/helpers/decorate.js
|
|
15
172
|
function __decorate(decorators, target, key, desc) {
|
|
16
173
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -134,6 +291,7 @@ let DataTable = class DataTable extends (0, _lit_labs_preact_signals.SignalWatch
|
|
|
134
291
|
this.undoLimit = 100;
|
|
135
292
|
this.virtual = false;
|
|
136
293
|
this.estimateRowHeight = 40;
|
|
294
|
+
this.autoMeasure = false;
|
|
137
295
|
this.maxHeight = "";
|
|
138
296
|
this._dataDefault = (0, _lit_labs_preact_signals.signal)([]);
|
|
139
297
|
this._sortingDefault = (0, _lit_labs_preact_signals.signal)([]);
|
|
@@ -221,7 +379,11 @@ let DataTable = class DataTable extends (0, _lit_labs_preact_signals.SignalWatch
|
|
|
221
379
|
this.virtualizer = null;
|
|
222
380
|
this.virtualizerCleanup = null;
|
|
223
381
|
this.gridScrollEl = null;
|
|
382
|
+
this.colVirtualizer = null;
|
|
383
|
+
this.colVirtualizerCleanup = null;
|
|
224
384
|
this.remeasurePending = false;
|
|
385
|
+
this.remeasureRaf = null;
|
|
386
|
+
this.remeasureDisposed = false;
|
|
225
387
|
this.GRID_PAGE_STEP = 10;
|
|
226
388
|
this.gridRoot = null;
|
|
227
389
|
this.programmatic = 0;
|
|
@@ -259,18 +421,6 @@ let DataTable = class DataTable extends (0, _lit_labs_preact_signals.SignalWatch
|
|
|
259
421
|
columnSizingInfo: this._columnSizingInfo.value
|
|
260
422
|
});
|
|
261
423
|
this.currentData = () => this.data != null ? this.data : this._dataDefault.value;
|
|
262
|
-
this.isSafeKey = (k) => k !== "__proto__" && k !== "constructor" && k !== "prototype";
|
|
263
|
-
this.wrapAggregationFn = (fn) => {
|
|
264
|
-
if (typeof fn === "string") return fn;
|
|
265
|
-
if (typeof fn !== "function") return void 0;
|
|
266
|
-
return (columnId, leafRows, childRows) => {
|
|
267
|
-
try {
|
|
268
|
-
return fn(columnId, leafRows, childRows);
|
|
269
|
-
} catch (err) {
|
|
270
|
-
return;
|
|
271
|
-
}
|
|
272
|
-
};
|
|
273
|
-
};
|
|
274
424
|
this.buildConfigDef = (c) => {
|
|
275
425
|
if (!c) return null;
|
|
276
426
|
if (Array.isArray(c.columns)) {
|
|
@@ -284,7 +434,7 @@ let DataTable = class DataTable extends (0, _lit_labs_preact_signals.SignalWatch
|
|
|
284
434
|
if (gid == null) gid = c.header != null ? "__grp_" + kids.map((k) => k.id).join("_") : null;
|
|
285
435
|
if (gid == null) return null;
|
|
286
436
|
const id = String(gid);
|
|
287
|
-
if (!
|
|
437
|
+
if (!isSafeKey(id)) return null;
|
|
288
438
|
return {
|
|
289
439
|
id,
|
|
290
440
|
header: c.header != null ? c.header : id,
|
|
@@ -294,7 +444,7 @@ let DataTable = class DataTable extends (0, _lit_labs_preact_signals.SignalWatch
|
|
|
294
444
|
const rawId = c.id != null ? c.id : c.field;
|
|
295
445
|
if (rawId == null) return null;
|
|
296
446
|
const id = String(rawId);
|
|
297
|
-
if (!
|
|
447
|
+
if (!isSafeKey(id)) return null;
|
|
298
448
|
return {
|
|
299
449
|
id,
|
|
300
450
|
accessorKey: c.field != null ? c.field : id,
|
|
@@ -304,7 +454,7 @@ let DataTable = class DataTable extends (0, _lit_labs_preact_signals.SignalWatch
|
|
|
304
454
|
filterable: c.filterable === true,
|
|
305
455
|
expandable: c.expandable === true,
|
|
306
456
|
groupable: c.groupable !== false,
|
|
307
|
-
aggregationFn:
|
|
457
|
+
aggregationFn: wrapAggregationFn(c.aggregationFn),
|
|
308
458
|
pinned: c.pinned != null ? c.pinned : "",
|
|
309
459
|
width: c.width != null ? c.width : "",
|
|
310
460
|
meta: {
|
|
@@ -315,10 +465,15 @@ let DataTable = class DataTable extends (0, _lit_labs_preact_signals.SignalWatch
|
|
|
315
465
|
}
|
|
316
466
|
};
|
|
317
467
|
};
|
|
468
|
+
this.columnDefsCache = null;
|
|
469
|
+
this.columnDefsCacheColumnsRef = void 0;
|
|
470
|
+
this.columnDefsCacheColRegRef = void 0;
|
|
318
471
|
this.columnDefs = () => {
|
|
472
|
+
const cfg = this.columns || [];
|
|
473
|
+
const reg = this._colReg.value || {};
|
|
474
|
+
if (this.columnDefsCache && this.columns === this.columnDefsCacheColumnsRef && this._colReg.value === this.columnDefsCacheColRegRef) return this.columnDefsCache;
|
|
319
475
|
const byId = Object.create(null);
|
|
320
476
|
const order = [];
|
|
321
|
-
const cfg = this.columns || [];
|
|
322
477
|
for (const c of cfg) {
|
|
323
478
|
const def = this.buildConfigDef(c);
|
|
324
479
|
if (!def) continue;
|
|
@@ -326,9 +481,8 @@ let DataTable = class DataTable extends (0, _lit_labs_preact_signals.SignalWatch
|
|
|
326
481
|
if (!(id in byId)) order.push(id);
|
|
327
482
|
byId[id] = def;
|
|
328
483
|
}
|
|
329
|
-
const reg = this._colReg.value || {};
|
|
330
484
|
for (const id in reg) {
|
|
331
|
-
if (!
|
|
485
|
+
if (!isSafeKey(id)) continue;
|
|
332
486
|
const spec = reg[id];
|
|
333
487
|
if (!spec) continue;
|
|
334
488
|
if (!(id in byId)) order.push(id);
|
|
@@ -341,7 +495,7 @@ let DataTable = class DataTable extends (0, _lit_labs_preact_signals.SignalWatch
|
|
|
341
495
|
filterable: spec.filterable === true,
|
|
342
496
|
expandable: spec.expandable === true,
|
|
343
497
|
groupable: spec.groupable !== false,
|
|
344
|
-
aggregationFn:
|
|
498
|
+
aggregationFn: wrapAggregationFn(spec.aggregationFn),
|
|
345
499
|
pinned: spec.pinned != null ? spec.pinned : "",
|
|
346
500
|
width: spec.width != null ? spec.width : "",
|
|
347
501
|
meta: {
|
|
@@ -354,6 +508,9 @@ let DataTable = class DataTable extends (0, _lit_labs_preact_signals.SignalWatch
|
|
|
354
508
|
}
|
|
355
509
|
const out = [];
|
|
356
510
|
for (const id of order) if (byId[id]) out.push(byId[id]);
|
|
511
|
+
this.columnDefsCache = out;
|
|
512
|
+
this.columnDefsCacheColumnsRef = this.columns;
|
|
513
|
+
this.columnDefsCacheColRegRef = this._colReg.value;
|
|
357
514
|
return out;
|
|
358
515
|
};
|
|
359
516
|
this.SELECT_COL_ID = "__rdt_select";
|
|
@@ -396,7 +553,6 @@ let DataTable = class DataTable extends (0, _lit_labs_preact_signals.SignalWatch
|
|
|
396
553
|
}));
|
|
397
554
|
this.programmatic--;
|
|
398
555
|
};
|
|
399
|
-
this.applyUpdater = (updater, current) => typeof updater === "function" ? updater(current) : updater;
|
|
400
556
|
this.writeExpanded = (next) => {
|
|
401
557
|
if (this.programmatic) return;
|
|
402
558
|
this.programmatic++;
|
|
@@ -608,48 +764,101 @@ let DataTable = class DataTable extends (0, _lit_labs_preact_signals.SignalWatch
|
|
|
608
764
|
};
|
|
609
765
|
this.refreshRowModel = null;
|
|
610
766
|
this.onSortingChangeCb = (updater) => {
|
|
611
|
-
this.writeSorting(
|
|
767
|
+
this.writeSorting(applyUpdater(updater, this.currentState().sorting));
|
|
612
768
|
};
|
|
613
769
|
this.onExpandedChangeCb = (updater) => {
|
|
614
|
-
this.writeExpanded(
|
|
770
|
+
this.writeExpanded(applyUpdater(updater, this.currentState().expanded));
|
|
615
771
|
};
|
|
616
772
|
this.onGroupingChangeCb = (updater) => {
|
|
617
|
-
this.writeGrouping(
|
|
773
|
+
this.writeGrouping(applyUpdater(updater, this.currentState().grouping));
|
|
618
774
|
};
|
|
619
775
|
this.onGlobalFilterChangeCb = (updater) => {
|
|
620
|
-
this.writeGlobalFilter(
|
|
776
|
+
this.writeGlobalFilter(applyUpdater(updater, this.currentState().globalFilter));
|
|
621
777
|
};
|
|
622
778
|
this.onColumnFiltersChangeCb = (updater) => {
|
|
623
|
-
this.writeColumnFilters(
|
|
779
|
+
this.writeColumnFilters(applyUpdater(updater, this.currentState().columnFilters));
|
|
624
780
|
};
|
|
625
781
|
this.onPaginationChangeCb = (updater) => {
|
|
626
|
-
this.writePagination(
|
|
782
|
+
this.writePagination(applyUpdater(updater, this.currentState().pagination));
|
|
627
783
|
};
|
|
628
784
|
this.onRowSelectionChangeCb = (updater) => {
|
|
629
|
-
this.writeRowSelection(
|
|
785
|
+
this.writeRowSelection(applyUpdater(updater, this.currentState().rowSelection));
|
|
630
786
|
};
|
|
631
787
|
this.onColumnVisibilityChangeCb = (updater) => {
|
|
632
|
-
this.writeColumnVisibility(
|
|
788
|
+
this.writeColumnVisibility(applyUpdater(updater, this.currentState().columnVisibility));
|
|
633
789
|
};
|
|
634
790
|
this.onColumnSizingChangeCb = (updater) => {
|
|
635
|
-
this.writeColumnSizing(
|
|
791
|
+
this.writeColumnSizing(applyUpdater(updater, this.currentState().columnSizing));
|
|
636
792
|
};
|
|
637
793
|
this.onColumnOrderChangeCb = (updater) => {
|
|
638
|
-
this.writeColumnOrder(
|
|
794
|
+
this.writeColumnOrder(applyUpdater(updater, this.currentState().columnOrder));
|
|
639
795
|
};
|
|
640
796
|
this.onColumnPinningChangeCb = (updater) => {
|
|
641
|
-
this.writeColumnPinning(
|
|
797
|
+
this.writeColumnPinning(applyUpdater(updater, this.currentState().columnPinning));
|
|
642
798
|
};
|
|
643
799
|
this.onColumnSizingInfoChangeCb = (updater) => {
|
|
644
|
-
const next =
|
|
800
|
+
const next = applyUpdater(updater, this._columnSizingInfo.value);
|
|
645
801
|
this._columnSizingInfo.value = next != null ? next : this._columnSizingInfo.value;
|
|
646
802
|
};
|
|
803
|
+
this.resolveVirtual = () => {
|
|
804
|
+
const v = this.virtual;
|
|
805
|
+
if (typeof v === "string") {
|
|
806
|
+
if (v === "rows") return "rows";
|
|
807
|
+
if (v === "columns") return "columns";
|
|
808
|
+
if (v === "both") return "both";
|
|
809
|
+
return "off";
|
|
810
|
+
}
|
|
811
|
+
return v === true ? "rows" : "off";
|
|
812
|
+
};
|
|
813
|
+
this.rowsWindowed = () => {
|
|
814
|
+
const s = this.resolveVirtual();
|
|
815
|
+
return s === "rows" || s === "both";
|
|
816
|
+
};
|
|
817
|
+
this.colsWindowed = () => {
|
|
818
|
+
const s = this.resolveVirtual();
|
|
819
|
+
return s === "columns" || s === "both";
|
|
820
|
+
};
|
|
821
|
+
this.isWindowed = () => this.rowsWindowed() || this.colsWindowed();
|
|
822
|
+
this.autoMeasureOn = () => this.autoMeasure === true;
|
|
823
|
+
this.columnCount = () => this.visibleColCount();
|
|
824
|
+
this.columnSize = (i) => {
|
|
825
|
+
if (!this.table || !this.table.getVisibleLeafColumns) return 150;
|
|
826
|
+
const c = this.table.getVisibleLeafColumns()[i];
|
|
827
|
+
return c && typeof c.getSize === "function" ? c.getSize() : 150;
|
|
828
|
+
};
|
|
829
|
+
this.forcedColumns = () => {
|
|
830
|
+
if (!this.colsWindowed()) return [];
|
|
831
|
+
const out = [];
|
|
832
|
+
if (this.table && this.table.getVisibleLeafColumns) {
|
|
833
|
+
const cols = this.table.getVisibleLeafColumns();
|
|
834
|
+
for (let i = 0; i < cols.length; i++) {
|
|
835
|
+
const c = cols[i];
|
|
836
|
+
if (c && c.getIsPinned && c.getIsPinned()) out.push(i);
|
|
837
|
+
}
|
|
838
|
+
}
|
|
839
|
+
if (!this._activeIsHeader.value && this._activeColIndex.value >= 0 && out.indexOf(this._activeColIndex.value) === -1) out.push(this._activeColIndex.value);
|
|
840
|
+
if (this._editingRow.value >= 0 && this._editingCol.value >= 0 && out.indexOf(this._editingCol.value) === -1) out.push(this._editingCol.value);
|
|
841
|
+
return out;
|
|
842
|
+
};
|
|
843
|
+
this.windowedCells = (row) => {
|
|
844
|
+
this._windowVer.value;
|
|
845
|
+
const cells = this.visibleCellsFor(row);
|
|
846
|
+
if (!this.colsWindowed()) return cells;
|
|
847
|
+
const idx = this.windowedColIndices();
|
|
848
|
+
const out = [];
|
|
849
|
+
for (let i = 0; i < idx.length; i++) {
|
|
850
|
+
const cell = cells[idx[i]];
|
|
851
|
+
if (cell) out.push(cell);
|
|
852
|
+
}
|
|
853
|
+
return out;
|
|
854
|
+
};
|
|
647
855
|
this.windowSource = () => {
|
|
648
856
|
if (!this.table) return [];
|
|
649
|
-
if (this.
|
|
857
|
+
if (this.rowsWindowed()) return this.table.getPrePaginationRowModel().rows;
|
|
650
858
|
return this.table.getRowModel().rows;
|
|
651
859
|
};
|
|
652
860
|
this.scheduleRemeasure = () => {
|
|
861
|
+
if (this.remeasureDisposed) return;
|
|
653
862
|
if (this.remeasurePending) return;
|
|
654
863
|
this.remeasurePending = true;
|
|
655
864
|
let ranMicro = false;
|
|
@@ -657,6 +866,7 @@ let DataTable = class DataTable extends (0, _lit_labs_preact_signals.SignalWatch
|
|
|
657
866
|
this.remeasureWindow();
|
|
658
867
|
};
|
|
659
868
|
const rafPass = () => {
|
|
869
|
+
this.remeasureRaf = null;
|
|
660
870
|
this.remeasurePending = false;
|
|
661
871
|
this.remeasureWindow();
|
|
662
872
|
};
|
|
@@ -664,9 +874,18 @@ let DataTable = class DataTable extends (0, _lit_labs_preact_signals.SignalWatch
|
|
|
664
874
|
ranMicro = true;
|
|
665
875
|
queueMicrotask(microPass);
|
|
666
876
|
}
|
|
667
|
-
if (typeof requestAnimationFrame === "function") requestAnimationFrame(rafPass);
|
|
877
|
+
if (typeof requestAnimationFrame === "function") this.remeasureRaf = requestAnimationFrame(rafPass);
|
|
668
878
|
else if (ranMicro) this.remeasurePending = false;
|
|
669
|
-
else setTimeout(rafPass, 0);
|
|
879
|
+
else this.remeasureRaf = setTimeout(rafPass, 0);
|
|
880
|
+
};
|
|
881
|
+
this.teardownRemeasure = () => {
|
|
882
|
+
this.remeasureDisposed = true;
|
|
883
|
+
if (this.remeasureRaf != null) {
|
|
884
|
+
if (typeof requestAnimationFrame === "function") cancelAnimationFrame(this.remeasureRaf);
|
|
885
|
+
else clearTimeout(this.remeasureRaf);
|
|
886
|
+
this.remeasureRaf = null;
|
|
887
|
+
}
|
|
888
|
+
this.remeasurePending = false;
|
|
670
889
|
};
|
|
671
890
|
this.pinnedEditIndex = () => {
|
|
672
891
|
if (this._editingRow.value >= 0) return this._editingRow.value;
|
|
@@ -679,19 +898,123 @@ let DataTable = class DataTable extends (0, _lit_labs_preact_signals.SignalWatch
|
|
|
679
898
|
return ms && ms[pin] ? ms[pin] : null;
|
|
680
899
|
};
|
|
681
900
|
this.remeasureWindow = () => {
|
|
901
|
+
if (this.remeasureDisposed) return;
|
|
682
902
|
if (!this.virtualizer || !this.gridRoot) return;
|
|
683
903
|
if (this.virtualizer.scrollState) return;
|
|
684
904
|
const trs = this.gridRoot.querySelectorAll("tbody.rdt-tbody > tr[data-index]");
|
|
685
905
|
for (const tr of trs) this.virtualizer.measureElement(tr);
|
|
906
|
+
if (this.afterRowRemeasure) this.afterRowRemeasure();
|
|
686
907
|
};
|
|
687
908
|
this.virtualItemKey = (i) => {
|
|
688
909
|
const src = this.windowSource();
|
|
689
910
|
return src && src[i] ? src[i].id : void 0;
|
|
690
911
|
};
|
|
912
|
+
this.COL_OVERSCAN = 3;
|
|
913
|
+
this.colRtlObserver = null;
|
|
914
|
+
this.colRtlObserverEl = null;
|
|
915
|
+
this.isColRtl = () => {
|
|
916
|
+
if (!this.gridScrollEl || typeof getComputedStyle !== "function") return false;
|
|
917
|
+
return getComputedStyle(this.gridScrollEl).direction === "rtl";
|
|
918
|
+
};
|
|
919
|
+
this.ensureColRtlWatch = () => {
|
|
920
|
+
if (!this.gridScrollEl || this.colRtlObserverEl === this.gridScrollEl || typeof MutationObserver !== "function") return;
|
|
921
|
+
if (this.colRtlObserver) this.colRtlObserver.disconnect();
|
|
922
|
+
this.colRtlObserver = new MutationObserver(() => {
|
|
923
|
+
if (this.colVirtualizer) this.colVirtualizer.setOptions({
|
|
924
|
+
...this.colVirtualizer.options,
|
|
925
|
+
isRtl: this.isColRtl()
|
|
926
|
+
});
|
|
927
|
+
});
|
|
928
|
+
this.colRtlObserver.observe(this.gridScrollEl, {
|
|
929
|
+
attributes: true,
|
|
930
|
+
attributeFilter: ["dir"]
|
|
931
|
+
});
|
|
932
|
+
this.colRtlObserverEl = this.gridScrollEl;
|
|
933
|
+
};
|
|
934
|
+
this.teardownColRtlWatch = () => {
|
|
935
|
+
if (this.colRtlObserver) this.colRtlObserver.disconnect();
|
|
936
|
+
this.colRtlObserver = null;
|
|
937
|
+
this.colRtlObserverEl = null;
|
|
938
|
+
};
|
|
939
|
+
this.columnVirtualizerOptions = () => {
|
|
940
|
+
this.ensureColRtlWatch();
|
|
941
|
+
return {
|
|
942
|
+
count: this.columnCount(),
|
|
943
|
+
getScrollElement: () => this.gridScrollEl,
|
|
944
|
+
estimateSize: (i) => this.columnSize(i),
|
|
945
|
+
horizontal: true,
|
|
946
|
+
isRtl: this.isColRtl(),
|
|
947
|
+
observeElementRect: _tanstack_virtual_core.observeElementRect,
|
|
948
|
+
observeElementOffset: _tanstack_virtual_core.observeElementOffset,
|
|
949
|
+
scrollToFn: _tanstack_virtual_core.elementScroll,
|
|
950
|
+
measureElement: _tanstack_virtual_core.measureElement,
|
|
951
|
+
overscan: this.COL_OVERSCAN,
|
|
952
|
+
onChange: () => {
|
|
953
|
+
this._windowVer.value = this._windowVer.value + 1;
|
|
954
|
+
}
|
|
955
|
+
};
|
|
956
|
+
};
|
|
957
|
+
this.measuredRowTotal = 0;
|
|
958
|
+
this.measuredRowCount = 0;
|
|
959
|
+
this.lastFedRowEstimate = 0;
|
|
960
|
+
this.foldedRowHeights = {};
|
|
961
|
+
this.windowVerBumpPending = false;
|
|
962
|
+
this.bumpWindowVer = () => {
|
|
963
|
+
if (this.windowVerBumpPending) return;
|
|
964
|
+
this.windowVerBumpPending = true;
|
|
965
|
+
const flush = () => {
|
|
966
|
+
this.windowVerBumpPending = false;
|
|
967
|
+
this._windowVer.value = this._windowVer.value + 1;
|
|
968
|
+
};
|
|
969
|
+
if (typeof queueMicrotask !== "undefined") queueMicrotask(flush);
|
|
970
|
+
else setTimeout(flush, 0);
|
|
971
|
+
};
|
|
972
|
+
this.ESTIMATE_REFEED_DELTA_PX = 4;
|
|
973
|
+
this.estimateRowSize = (i) => {
|
|
974
|
+
if (!this.autoMeasureOn()) return this.estimateRowHeight;
|
|
975
|
+
if (this.measuredRowCount === 0) return this.estimateRowHeight;
|
|
976
|
+
return Math.round(this.measuredRowTotal / this.measuredRowCount);
|
|
977
|
+
};
|
|
978
|
+
this.foldMeasuredRow = (index, height) => {
|
|
979
|
+
const prev = this.foldedRowHeights[index];
|
|
980
|
+
if (prev === height) return;
|
|
981
|
+
if (prev == null) {
|
|
982
|
+
this.measuredRowTotal = this.measuredRowTotal + height;
|
|
983
|
+
this.measuredRowCount = this.measuredRowCount + 1;
|
|
984
|
+
} else this.measuredRowTotal = this.measuredRowTotal - prev + height;
|
|
985
|
+
this.foldedRowHeights[index] = height;
|
|
986
|
+
};
|
|
987
|
+
this.refineRowEstimate = () => {
|
|
988
|
+
if (!this.autoMeasureOn() || !this.virtualizer) return;
|
|
989
|
+
const items = this.virtualizer.getVirtualItems();
|
|
990
|
+
const measurements = this.virtualizer.getMeasurements();
|
|
991
|
+
for (let i = 0; i < items.length; i++) {
|
|
992
|
+
const idx = items[i].index;
|
|
993
|
+
const m = measurements && measurements[idx];
|
|
994
|
+
if (m) this.foldMeasuredRow(idx, m.size);
|
|
995
|
+
}
|
|
996
|
+
if (this.virtualizer.scrollState) return;
|
|
997
|
+
const est = this.estimateRowSize(0);
|
|
998
|
+
if (Math.abs(est - this.lastFedRowEstimate) < this.ESTIMATE_REFEED_DELTA_PX) return;
|
|
999
|
+
const anchorIndex = items.length ? items[0].index : -1;
|
|
1000
|
+
const anchorStart = items.length ? items[0].start : 0;
|
|
1001
|
+
this.virtualizer.setOptions(this.virtualizerOptions());
|
|
1002
|
+
this.virtualizer._willUpdate();
|
|
1003
|
+
this.lastFedRowEstimate = est;
|
|
1004
|
+
if (anchorIndex >= 0 && this.gridScrollEl) {
|
|
1005
|
+
const freshMeasurements = this.virtualizer.getMeasurements();
|
|
1006
|
+
const fresh = freshMeasurements && freshMeasurements[anchorIndex];
|
|
1007
|
+
if (fresh) {
|
|
1008
|
+
const delta = fresh.start - anchorStart;
|
|
1009
|
+
if (delta !== 0) this.gridScrollEl.scrollTop = this.gridScrollEl.scrollTop + delta;
|
|
1010
|
+
}
|
|
1011
|
+
}
|
|
1012
|
+
this.bumpWindowVer();
|
|
1013
|
+
};
|
|
691
1014
|
this.virtualizerOptions = () => ({
|
|
692
1015
|
count: this.windowSource().length,
|
|
693
1016
|
getScrollElement: () => this.gridScrollEl,
|
|
694
|
-
estimateSize: () => this.
|
|
1017
|
+
estimateSize: (i) => this.estimateRowSize(i),
|
|
695
1018
|
observeElementRect: _tanstack_virtual_core.observeElementRect,
|
|
696
1019
|
observeElementOffset: _tanstack_virtual_core.observeElementOffset,
|
|
697
1020
|
scrollToFn: _tanstack_virtual_core.elementScroll,
|
|
@@ -699,7 +1022,7 @@ let DataTable = class DataTable extends (0, _lit_labs_preact_signals.SignalWatch
|
|
|
699
1022
|
overscan: 8,
|
|
700
1023
|
getItemKey: this.virtualItemKey,
|
|
701
1024
|
onChange: () => {
|
|
702
|
-
this.
|
|
1025
|
+
this.bumpWindowVer();
|
|
703
1026
|
this.scheduleRemeasure();
|
|
704
1027
|
}
|
|
705
1028
|
});
|
|
@@ -708,8 +1031,8 @@ let DataTable = class DataTable extends (0, _lit_labs_preact_signals.SignalWatch
|
|
|
708
1031
|
this._windowVer.value;
|
|
709
1032
|
this._editVer.value;
|
|
710
1033
|
if (!this.virtualizer) {
|
|
711
|
-
if (!this.
|
|
712
|
-
vi:
|
|
1034
|
+
if (!this.rowsWindowed()) return (this._rows.value || []).map((r, i) => ({
|
|
1035
|
+
vi: { index: i },
|
|
713
1036
|
row: r
|
|
714
1037
|
}));
|
|
715
1038
|
return [];
|
|
@@ -745,7 +1068,7 @@ let DataTable = class DataTable extends (0, _lit_labs_preact_signals.SignalWatch
|
|
|
745
1068
|
this.padTop = () => {
|
|
746
1069
|
this._windowVer.value;
|
|
747
1070
|
this._editVer.value;
|
|
748
|
-
if (!this.
|
|
1071
|
+
if (!this.rowsWindowed() || !this.virtualizer) return 0;
|
|
749
1072
|
const items = this.virtualizer.getVirtualItems();
|
|
750
1073
|
let pad = items.length ? items[0].start : 0;
|
|
751
1074
|
const pin = this.pinnedEditIndex();
|
|
@@ -759,7 +1082,7 @@ let DataTable = class DataTable extends (0, _lit_labs_preact_signals.SignalWatch
|
|
|
759
1082
|
this.padBottom = () => {
|
|
760
1083
|
this._windowVer.value;
|
|
761
1084
|
this._editVer.value;
|
|
762
|
-
if (!this.
|
|
1085
|
+
if (!this.rowsWindowed() || !this.virtualizer) return 0;
|
|
763
1086
|
const items = this.virtualizer.getVirtualItems();
|
|
764
1087
|
if (!items.length) return 0;
|
|
765
1088
|
let pad = this.virtualizer.getTotalSize() - items[items.length - 1].end;
|
|
@@ -780,11 +1103,59 @@ let DataTable = class DataTable extends (0, _lit_labs_preact_signals.SignalWatch
|
|
|
780
1103
|
return false;
|
|
781
1104
|
};
|
|
782
1105
|
this.rowIsOutsideWindow = (r) => {
|
|
783
|
-
if (!this.
|
|
1106
|
+
if (!this.rowsWindowed() || !this.virtualizer) return false;
|
|
784
1107
|
const items = this.virtualizer.getVirtualItems();
|
|
785
1108
|
for (const it of items) if (it.index === r) return false;
|
|
786
1109
|
return true;
|
|
787
1110
|
};
|
|
1111
|
+
this.windowedColIndices = () => {
|
|
1112
|
+
this._windowVer.value;
|
|
1113
|
+
this._editVer.value;
|
|
1114
|
+
if (!this.colsWindowed()) {
|
|
1115
|
+
const n = this.columnCount();
|
|
1116
|
+
const out = [];
|
|
1117
|
+
for (let i = 0; i < n; i++) out.push(i);
|
|
1118
|
+
return out;
|
|
1119
|
+
}
|
|
1120
|
+
if (!this.colVirtualizer) return [];
|
|
1121
|
+
const idx = this.colVirtualizer.getVirtualItems().map((it) => it.index);
|
|
1122
|
+
const forced = this.forcedColumns();
|
|
1123
|
+
for (let i = 0; i < forced.length; i++) if (idx.indexOf(forced[i]) === -1) idx.push(forced[i]);
|
|
1124
|
+
idx.sort((a, b) => a - b);
|
|
1125
|
+
return idx;
|
|
1126
|
+
};
|
|
1127
|
+
this.colPadLeft = () => {
|
|
1128
|
+
this._windowVer.value;
|
|
1129
|
+
this._editVer.value;
|
|
1130
|
+
if (!this.colsWindowed() || !this.colVirtualizer) return 0;
|
|
1131
|
+
const items = this.colVirtualizer.getVirtualItems();
|
|
1132
|
+
let pad = items.length ? items[0].start : 0;
|
|
1133
|
+
if (items.length) {
|
|
1134
|
+
const firstIdx = items[0].index;
|
|
1135
|
+
const forced = this.forcedColumns();
|
|
1136
|
+
for (let i = 0; i < forced.length; i++) if (forced[i] < firstIdx) pad = pad - this.columnSize(forced[i]);
|
|
1137
|
+
}
|
|
1138
|
+
return pad < 0 ? 0 : pad;
|
|
1139
|
+
};
|
|
1140
|
+
this.colPadRight = () => {
|
|
1141
|
+
this._windowVer.value;
|
|
1142
|
+
this._editVer.value;
|
|
1143
|
+
if (!this.colsWindowed() || !this.colVirtualizer) return 0;
|
|
1144
|
+
const items = this.colVirtualizer.getVirtualItems();
|
|
1145
|
+
if (!items.length) return 0;
|
|
1146
|
+
let pad = this.colVirtualizer.getTotalSize() - items[items.length - 1].end;
|
|
1147
|
+
const lastIdx = items[items.length - 1].index;
|
|
1148
|
+
const forced = this.forcedColumns();
|
|
1149
|
+
for (let i = 0; i < forced.length; i++) if (forced[i] > lastIdx) pad = pad - this.columnSize(forced[i]);
|
|
1150
|
+
return pad < 0 ? 0 : pad;
|
|
1151
|
+
};
|
|
1152
|
+
this.colIsOutsideWindow = (c) => {
|
|
1153
|
+
if (!this.colsWindowed() || !this.colVirtualizer) return false;
|
|
1154
|
+
const items = this.colVirtualizer.getVirtualItems();
|
|
1155
|
+
for (const it of items) if (it.index === c) return false;
|
|
1156
|
+
return true;
|
|
1157
|
+
};
|
|
1158
|
+
this.afterRowRemeasure = this.refineRowEstimate;
|
|
788
1159
|
this.announceState = {
|
|
789
1160
|
sorting: null,
|
|
790
1161
|
columnFilters: null,
|
|
@@ -1157,7 +1528,7 @@ let DataTable = class DataTable extends (0, _lit_labs_preact_signals.SignalWatch
|
|
|
1157
1528
|
};
|
|
1158
1529
|
this.getRowIndexRelativeToPage = (absRow) => {
|
|
1159
1530
|
const abs = absRow == null ? this.toAbsRow(this._activeRow.value) : Math.trunc(Number(absRow)) || 0;
|
|
1160
|
-
if (this.
|
|
1531
|
+
if (this.rowsWindowed()) return abs;
|
|
1161
1532
|
return abs - this.pageRowOffset();
|
|
1162
1533
|
};
|
|
1163
1534
|
this.cut = () => this.cutRange();
|
|
@@ -1168,12 +1539,12 @@ let DataTable = class DataTable extends (0, _lit_labs_preact_signals.SignalWatch
|
|
|
1168
1539
|
this.colIndexOf = (row, cellCtx) => this.tick() >= 0 ? this.visibleCellsFor(row).indexOf(cellCtx) : -1;
|
|
1169
1540
|
this.headerColIndexOf = (hg, header) => (hg && hg.headers ? hg.headers : []).indexOf(header);
|
|
1170
1541
|
this.pageRowOffset = () => {
|
|
1171
|
-
if (!this.isGrid() || this.
|
|
1542
|
+
if (!this.isGrid() || this.rowsWindowed()) return 0;
|
|
1172
1543
|
return this.pageIndex() * this.pageSize();
|
|
1173
1544
|
};
|
|
1174
1545
|
this.toAbsRow = (localRow) => localRow + this.pageRowOffset();
|
|
1175
1546
|
this.prePaginationRowCount = () => {
|
|
1176
|
-
if (!this.table || this.
|
|
1547
|
+
if (!this.table || this.rowsWindowed()) return this.bodyRowCount();
|
|
1177
1548
|
const pm = this.table.getPrePaginationRowModel();
|
|
1178
1549
|
return pm && pm.rows ? pm.rows.length : this.bodyRowCount();
|
|
1179
1550
|
};
|
|
@@ -1208,8 +1579,11 @@ let DataTable = class DataTable extends (0, _lit_labs_preact_signals.SignalWatch
|
|
|
1208
1579
|
const c = nextCol == null ? this._activeColIndex.value : nextCol;
|
|
1209
1580
|
const lvl = nextLevel == null ? this._activeHeaderLevel.value : nextLevel;
|
|
1210
1581
|
const header = nextIsHeader == null ? this._activeIsHeader.value : nextIsHeader;
|
|
1211
|
-
|
|
1212
|
-
|
|
1582
|
+
const rowOut = this.rowsWindowed() && this.virtualizer && this.rowIsOutsideWindow(r);
|
|
1583
|
+
const colOut = this.colsWindowed() && this.colVirtualizer && this.colIsOutsideWindow(c);
|
|
1584
|
+
if (!header && (rowOut || colOut)) {
|
|
1585
|
+
if (rowOut) this.virtualizer.scrollToIndex(r, { align: "center" });
|
|
1586
|
+
if (colOut) this.colVirtualizer.scrollToIndex(c, { align: "center" });
|
|
1213
1587
|
let focusAttempts = 0;
|
|
1214
1588
|
const myEpoch = this.focusIntentEpoch;
|
|
1215
1589
|
const focusWhenReady = () => {
|
|
@@ -1248,7 +1622,6 @@ let DataTable = class DataTable extends (0, _lit_labs_preact_signals.SignalWatch
|
|
|
1248
1622
|
return hg.length ? (hg[hg.length - 1].headers || []).length : 0;
|
|
1249
1623
|
};
|
|
1250
1624
|
this.bodyRowCount = () => (this._rows.value || []).length;
|
|
1251
|
-
this.clamp = (v, lo, hi) => v < lo ? lo : v > hi ? hi : v;
|
|
1252
1625
|
this.headerLeafLevel = () => {
|
|
1253
1626
|
const hg = this._headerGroups.value || [];
|
|
1254
1627
|
return hg.length ? hg.length - 1 : 0;
|
|
@@ -1294,7 +1667,7 @@ let DataTable = class DataTable extends (0, _lit_labs_preact_signals.SignalWatch
|
|
|
1294
1667
|
};
|
|
1295
1668
|
this.moveCol = (delta) => {
|
|
1296
1669
|
const max = (this._activeIsHeader.value ? this.headerCountAtLevel(this._activeHeaderLevel.value) : this.visibleColCount()) - 1;
|
|
1297
|
-
const nextCol =
|
|
1670
|
+
const nextCol = clamp(this._activeColIndex.value + delta, 0, max < 0 ? 0 : max);
|
|
1298
1671
|
this._activeColIndex.value = nextCol;
|
|
1299
1672
|
return nextCol;
|
|
1300
1673
|
};
|
|
@@ -1324,7 +1697,7 @@ let DataTable = class DataTable extends (0, _lit_labs_preact_signals.SignalWatch
|
|
|
1324
1697
|
isHeader: true,
|
|
1325
1698
|
level: this._activeHeaderLevel.value
|
|
1326
1699
|
};
|
|
1327
|
-
const landRow =
|
|
1700
|
+
const landRow = clamp(delta - 1, 0, maxRow);
|
|
1328
1701
|
this._activeIsHeader.value = false;
|
|
1329
1702
|
this._activeRow.value = landRow;
|
|
1330
1703
|
return {
|
|
@@ -1363,7 +1736,7 @@ let DataTable = class DataTable extends (0, _lit_labs_preact_signals.SignalWatch
|
|
|
1363
1736
|
level: leafLevel
|
|
1364
1737
|
};
|
|
1365
1738
|
}
|
|
1366
|
-
const nextRow =
|
|
1739
|
+
const nextRow = clamp(this._activeRow.value + delta, 0, maxRow);
|
|
1367
1740
|
this._activeRow.value = nextRow;
|
|
1368
1741
|
this._activeIsHeader.value = false;
|
|
1369
1742
|
return {
|
|
@@ -1412,19 +1785,14 @@ let DataTable = class DataTable extends (0, _lit_labs_preact_signals.SignalWatch
|
|
|
1412
1785
|
const rowKey = this._activeIsHeader.value ? "__header" : String(this._activeRow.value);
|
|
1413
1786
|
return this.resolveCellEl(rowKey, this._activeColIndex.value, this._activeIsHeader.value ? this._activeHeaderLevel.value : null);
|
|
1414
1787
|
};
|
|
1415
|
-
this.focusables = (cellEl) => {
|
|
1416
|
-
if (!cellEl || !cellEl.querySelectorAll) return [];
|
|
1417
|
-
return Array.prototype.slice.call(cellEl.querySelectorAll("button,[href],input,select,textarea,[tabindex]:not([tabindex=\"-1\"])")).filter((n) => !n.disabled);
|
|
1418
|
-
};
|
|
1419
1788
|
this.enterControl = () => {
|
|
1420
|
-
const
|
|
1421
|
-
const list = this.focusables(cellEl);
|
|
1789
|
+
const list = focusables(this.currentCellEl());
|
|
1422
1790
|
if (!list.length) return;
|
|
1423
1791
|
this._activeInControl.value = true;
|
|
1424
1792
|
list[0].focus();
|
|
1425
1793
|
};
|
|
1426
1794
|
this.cycleWithinCell = (cellEl, forward) => {
|
|
1427
|
-
const list =
|
|
1795
|
+
const list = focusables(cellEl);
|
|
1428
1796
|
if (!list.length) return;
|
|
1429
1797
|
const active = this.gridRoot ? this.gridRoot.getRootNode().activeElement : null;
|
|
1430
1798
|
const cur = list.indexOf(active);
|
|
@@ -1795,7 +2163,7 @@ let DataTable = class DataTable extends (0, _lit_labs_preact_signals.SignalWatch
|
|
|
1795
2163
|
}
|
|
1796
2164
|
}
|
|
1797
2165
|
const maxCol = colN - 1;
|
|
1798
|
-
const col =
|
|
2166
|
+
const col = clamp(this._activeColIndex.value, 0, maxCol < 0 ? 0 : maxCol);
|
|
1799
2167
|
if (col !== this._activeColIndex.value) this._activeColIndex.value = col;
|
|
1800
2168
|
if (rowN <= 0) {
|
|
1801
2169
|
this._activeIsHeader.value = true;
|
|
@@ -1813,16 +2181,48 @@ let DataTable = class DataTable extends (0, _lit_labs_preact_signals.SignalWatch
|
|
|
1813
2181
|
if (!this._activeIsHeader.value) {
|
|
1814
2182
|
const lastRow = rowN - 1;
|
|
1815
2183
|
const maxRow = lastRow < 0 ? 0 : lastRow;
|
|
1816
|
-
const row =
|
|
2184
|
+
const row = clamp(this._activeRow.value, 0, maxRow);
|
|
1817
2185
|
if (row !== this._activeRow.value) this._activeRow.value = row;
|
|
1818
2186
|
}
|
|
1819
2187
|
this.clampRange(rowN - 1, colN - 1);
|
|
1820
2188
|
if (recoverFocus) {
|
|
1821
|
-
const recRow =
|
|
1822
|
-
const recCol =
|
|
2189
|
+
const recRow = clamp(doomedRow, 0, rowN - 1);
|
|
2190
|
+
const recCol = clamp(doomedCol, 0, maxCol < 0 ? 0 : maxCol);
|
|
1823
2191
|
this.recoverGridFocus(String(recRow), recCol, null);
|
|
1824
2192
|
}
|
|
1825
2193
|
};
|
|
2194
|
+
this.windowedHeadersFor = (hg, hgLevel) => {
|
|
2195
|
+
const headers = hg && hg.headers || [];
|
|
2196
|
+
if (!this.colsWindowed()) return headers.map((h) => ({
|
|
2197
|
+
header: h,
|
|
2198
|
+
span: h && h.colSpan > 1 ? h.colSpan : 1
|
|
2199
|
+
}));
|
|
2200
|
+
const idx = this.windowedColIndices();
|
|
2201
|
+
const idxSet = {};
|
|
2202
|
+
for (let i = 0; i < idx.length; i++) idxSet[idx[i]] = true;
|
|
2203
|
+
let cursor = 0;
|
|
2204
|
+
const out = [];
|
|
2205
|
+
for (let i = 0; i < headers.length; i++) {
|
|
2206
|
+
const h = headers[i];
|
|
2207
|
+
const leafCount = h && h.colSpan ? h.colSpan : 1;
|
|
2208
|
+
const start = cursor;
|
|
2209
|
+
const end = cursor + leafCount;
|
|
2210
|
+
cursor = end;
|
|
2211
|
+
let span = 0;
|
|
2212
|
+
for (let c = start; c < end; c++) if (idxSet[c]) span = span + 1;
|
|
2213
|
+
if (span > 0) out.push({
|
|
2214
|
+
header: h,
|
|
2215
|
+
span
|
|
2216
|
+
});
|
|
2217
|
+
}
|
|
2218
|
+
return out;
|
|
2219
|
+
};
|
|
2220
|
+
this.windowedColSpan = () => this.colsWindowed() ? this.windowedColIndices().length + 2 : this.visibleColCount();
|
|
2221
|
+
this.remeasureColumnWindow = () => {
|
|
2222
|
+
if (!this.colsWindowed() || !this.colVirtualizer) return;
|
|
2223
|
+
this.colVirtualizer.setOptions(this.columnVirtualizerOptions());
|
|
2224
|
+
this.colVirtualizer._willUpdate();
|
|
2225
|
+
};
|
|
1826
2226
|
this.gridEmptyFallback = false;
|
|
1827
2227
|
this.rangeTransition = false;
|
|
1828
2228
|
this.rangeClickPending = false;
|
|
@@ -1851,8 +2251,8 @@ let DataTable = class DataTable extends (0, _lit_labs_preact_signals.SignalWatch
|
|
|
1851
2251
|
focus: null
|
|
1852
2252
|
};
|
|
1853
2253
|
const clampCorner = (c) => c == null ? null : {
|
|
1854
|
-
rowIndex:
|
|
1855
|
-
colIndex:
|
|
2254
|
+
rowIndex: clamp(c.rowIndex, 0, maxRow),
|
|
2255
|
+
colIndex: clamp(c.colIndex, 0, maxCol)
|
|
1856
2256
|
};
|
|
1857
2257
|
return {
|
|
1858
2258
|
anchor: clampCorner(a),
|
|
@@ -1895,8 +2295,8 @@ let DataTable = class DataTable extends (0, _lit_labs_preact_signals.SignalWatch
|
|
|
1895
2295
|
colIndex: this._activeColIndex.value
|
|
1896
2296
|
};
|
|
1897
2297
|
}
|
|
1898
|
-
const nextRow =
|
|
1899
|
-
const nextCol =
|
|
2298
|
+
const nextRow = clamp(focus.rowIndex + dRow, 0, maxRow);
|
|
2299
|
+
const nextCol = clamp(focus.colIndex + dCol, 0, maxCol);
|
|
1900
2300
|
const nextFocus = {
|
|
1901
2301
|
rowIndex: nextRow,
|
|
1902
2302
|
colIndex: nextCol
|
|
@@ -1920,8 +2320,8 @@ let DataTable = class DataTable extends (0, _lit_labs_preact_signals.SignalWatch
|
|
|
1920
2320
|
colIndex: this._activeColIndex.value
|
|
1921
2321
|
};
|
|
1922
2322
|
const nextFocus = {
|
|
1923
|
-
rowIndex:
|
|
1924
|
-
colIndex:
|
|
2323
|
+
rowIndex: clamp(Math.trunc(Number(rIdx)) || 0, 0, maxRow),
|
|
2324
|
+
colIndex: clamp(Math.trunc(Number(cIdx)) || 0, 0, maxCol)
|
|
1925
2325
|
};
|
|
1926
2326
|
this._rangeAnchor.value = anchor;
|
|
1927
2327
|
this._rangeFocus.value = nextFocus;
|
|
@@ -1965,16 +2365,16 @@ let DataTable = class DataTable extends (0, _lit_labs_preact_signals.SignalWatch
|
|
|
1965
2365
|
return;
|
|
1966
2366
|
}
|
|
1967
2367
|
if (a) {
|
|
1968
|
-
const ar =
|
|
1969
|
-
const ac =
|
|
2368
|
+
const ar = clamp(a.rowIndex, 0, maxRow);
|
|
2369
|
+
const ac = clamp(a.colIndex, 0, maxCol);
|
|
1970
2370
|
if (ar !== a.rowIndex || ac !== a.colIndex) this._rangeAnchor.value = {
|
|
1971
2371
|
rowIndex: ar,
|
|
1972
2372
|
colIndex: ac
|
|
1973
2373
|
};
|
|
1974
2374
|
}
|
|
1975
2375
|
if (f) {
|
|
1976
|
-
const fr =
|
|
1977
|
-
const fc =
|
|
2376
|
+
const fr = clamp(f.rowIndex, 0, maxRow);
|
|
2377
|
+
const fc = clamp(f.colIndex, 0, maxCol);
|
|
1978
2378
|
if (fr !== f.rowIndex || fc !== f.colIndex) this._rangeFocus.value = {
|
|
1979
2379
|
rowIndex: fr,
|
|
1980
2380
|
colIndex: fc
|
|
@@ -1996,10 +2396,10 @@ let DataTable = class DataTable extends (0, _lit_labs_preact_signals.SignalWatch
|
|
|
1996
2396
|
const maxRow = this.bodyRowCount() - 1;
|
|
1997
2397
|
const maxCol = this.visibleColCount() - 1;
|
|
1998
2398
|
if (maxRow < 0 || maxCol < 0) return null;
|
|
1999
|
-
const ar =
|
|
2000
|
-
const ac =
|
|
2001
|
-
const fr =
|
|
2002
|
-
const fc =
|
|
2399
|
+
const ar = clamp(a.rowIndex, 0, maxRow);
|
|
2400
|
+
const ac = clamp(a.colIndex, 0, maxCol);
|
|
2401
|
+
const fr = clamp(f.rowIndex, 0, maxRow);
|
|
2402
|
+
const fc = clamp(f.colIndex, 0, maxCol);
|
|
2003
2403
|
return {
|
|
2004
2404
|
r0: ar < fr ? ar : fr,
|
|
2005
2405
|
r1: ar > fr ? ar : fr,
|
|
@@ -2007,10 +2407,6 @@ let DataTable = class DataTable extends (0, _lit_labs_preact_signals.SignalWatch
|
|
|
2007
2407
|
c1: ac > fc ? ac : fc
|
|
2008
2408
|
};
|
|
2009
2409
|
};
|
|
2010
|
-
this.escapeTsvField = (s) => {
|
|
2011
|
-
if (s.indexOf(" ") >= 0 || s.indexOf("\n") >= 0 || s.indexOf("\r") >= 0 || s.indexOf("\"") >= 0) return "\"" + s.replace(/"/g, "\"\"") + "\"";
|
|
2012
|
-
return s;
|
|
2013
|
-
};
|
|
2014
2410
|
this.rangeToTsv = () => {
|
|
2015
2411
|
const box = this.normalizedRange();
|
|
2016
2412
|
const r0 = box ? box.r0 : this._activeRow.value;
|
|
@@ -2022,77 +2418,12 @@ let DataTable = class DataTable extends (0, _lit_labs_preact_signals.SignalWatch
|
|
|
2022
2418
|
const cells = [];
|
|
2023
2419
|
for (let c = c0; c <= c1; c++) {
|
|
2024
2420
|
const v = this.cellValueAt(r, c);
|
|
2025
|
-
cells.push(
|
|
2421
|
+
cells.push(escapeTsvField(v == null ? "" : String(v)));
|
|
2026
2422
|
}
|
|
2027
2423
|
lines.push(cells.join(" "));
|
|
2028
2424
|
}
|
|
2029
2425
|
return lines.join("\n");
|
|
2030
2426
|
};
|
|
2031
|
-
this.parseTsv = (text) => {
|
|
2032
|
-
const str = text != null ? String(text) : "";
|
|
2033
|
-
if (str === "" || str.length > 2e6) return [];
|
|
2034
|
-
const rows = [];
|
|
2035
|
-
let row = [];
|
|
2036
|
-
let field = "";
|
|
2037
|
-
let inQuotes = false;
|
|
2038
|
-
let i = 0;
|
|
2039
|
-
const n = str.length;
|
|
2040
|
-
while (i < n) {
|
|
2041
|
-
const ch = str[i];
|
|
2042
|
-
if (inQuotes) {
|
|
2043
|
-
if (ch === "\"") {
|
|
2044
|
-
if (i + 1 < n && str[i + 1] === "\"") {
|
|
2045
|
-
field = field + "\"";
|
|
2046
|
-
i = i + 2;
|
|
2047
|
-
continue;
|
|
2048
|
-
}
|
|
2049
|
-
inQuotes = false;
|
|
2050
|
-
i = i + 1;
|
|
2051
|
-
continue;
|
|
2052
|
-
}
|
|
2053
|
-
field = field + ch;
|
|
2054
|
-
i = i + 1;
|
|
2055
|
-
continue;
|
|
2056
|
-
}
|
|
2057
|
-
if (ch === "\"" && field === "") {
|
|
2058
|
-
inQuotes = true;
|
|
2059
|
-
i = i + 1;
|
|
2060
|
-
continue;
|
|
2061
|
-
}
|
|
2062
|
-
if (ch === " ") {
|
|
2063
|
-
row.push(field);
|
|
2064
|
-
field = "";
|
|
2065
|
-
i = i + 1;
|
|
2066
|
-
continue;
|
|
2067
|
-
}
|
|
2068
|
-
if (ch === "\r") {
|
|
2069
|
-
if (i + 1 < n && str[i + 1] === "\n") i = i + 1;
|
|
2070
|
-
row.push(field);
|
|
2071
|
-
field = "";
|
|
2072
|
-
rows.push(row);
|
|
2073
|
-
row = [];
|
|
2074
|
-
i = i + 1;
|
|
2075
|
-
continue;
|
|
2076
|
-
}
|
|
2077
|
-
if (ch === "\n") {
|
|
2078
|
-
row.push(field);
|
|
2079
|
-
field = "";
|
|
2080
|
-
rows.push(row);
|
|
2081
|
-
row = [];
|
|
2082
|
-
i = i + 1;
|
|
2083
|
-
continue;
|
|
2084
|
-
}
|
|
2085
|
-
field = field + ch;
|
|
2086
|
-
i = i + 1;
|
|
2087
|
-
}
|
|
2088
|
-
row.push(field);
|
|
2089
|
-
rows.push(row);
|
|
2090
|
-
if (rows.length > 1) {
|
|
2091
|
-
const last = rows[rows.length - 1];
|
|
2092
|
-
if (last.length === 1 && last[0] === "") rows.pop();
|
|
2093
|
-
}
|
|
2094
|
-
return rows;
|
|
2095
|
-
};
|
|
2096
2427
|
this.copyRange = () => {
|
|
2097
2428
|
if (!this.clipboardActiveAllowed()) return;
|
|
2098
2429
|
if (typeof navigator === "undefined" || !navigator.clipboard || !navigator.clipboard.writeText) return;
|
|
@@ -2128,7 +2459,7 @@ let DataTable = class DataTable extends (0, _lit_labs_preact_signals.SignalWatch
|
|
|
2128
2459
|
const field = this.fieldOfColId(colId);
|
|
2129
2460
|
const srcIndex = this.sourceIndexOfRow(r);
|
|
2130
2461
|
const oldValue = rowObj ? rowObj[field] : null;
|
|
2131
|
-
next =
|
|
2462
|
+
next = replaceRowValue(next, srcIndex, field, value);
|
|
2132
2463
|
committed.push({
|
|
2133
2464
|
rowId: this.rowIdAt(r),
|
|
2134
2465
|
columnId: colId,
|
|
@@ -2163,30 +2494,6 @@ let DataTable = class DataTable extends (0, _lit_labs_preact_signals.SignalWatch
|
|
|
2163
2494
|
const row = (this._rows.value || [])[rowIndex];
|
|
2164
2495
|
return row ? row.id : null;
|
|
2165
2496
|
};
|
|
2166
|
-
this.tileGridToBox = (grid, box) => {
|
|
2167
|
-
const srcRows = grid.length;
|
|
2168
|
-
let srcCols = 0;
|
|
2169
|
-
for (let i = 0; i < srcRows; i++) {
|
|
2170
|
-
const w = grid[i] && grid[i].length ? grid[i].length : 0;
|
|
2171
|
-
if (w > srcCols) srcCols = w;
|
|
2172
|
-
}
|
|
2173
|
-
if (srcRows <= 0 || srcCols <= 0) return grid;
|
|
2174
|
-
const boxRows = box.r1 - box.r0 + 1;
|
|
2175
|
-
const boxCols = box.c1 - box.c0 + 1;
|
|
2176
|
-
const rows = boxRows > srcRows ? boxRows : srcRows;
|
|
2177
|
-
const cols = boxCols > srcCols ? boxCols : srcCols;
|
|
2178
|
-
const out = [];
|
|
2179
|
-
for (let r = 0; r < rows; r++) {
|
|
2180
|
-
const srcLine = grid[r % srcRows] || [];
|
|
2181
|
-
const line = [];
|
|
2182
|
-
for (let c = 0; c < cols; c++) {
|
|
2183
|
-
const v = srcLine[c % srcCols];
|
|
2184
|
-
line.push(v != null ? v : "");
|
|
2185
|
-
}
|
|
2186
|
-
out.push(line);
|
|
2187
|
-
}
|
|
2188
|
-
return out;
|
|
2189
|
-
};
|
|
2190
2497
|
this.pasteRange = () => {
|
|
2191
2498
|
if (!this.clipboardActiveAllowed()) return;
|
|
2192
2499
|
if (typeof navigator === "undefined" || !navigator.clipboard || !navigator.clipboard.readText) return;
|
|
@@ -2207,9 +2514,9 @@ let DataTable = class DataTable extends (0, _lit_labs_preact_signals.SignalWatch
|
|
|
2207
2514
|
}
|
|
2208
2515
|
if (!p || !p.then) return;
|
|
2209
2516
|
p.then((text) => {
|
|
2210
|
-
const grid =
|
|
2517
|
+
const grid = parseTsv(text);
|
|
2211
2518
|
if (!grid.length) return;
|
|
2212
|
-
const tiled =
|
|
2519
|
+
const tiled = tileGridToBox(grid, destBox);
|
|
2213
2520
|
this.applyGridToRange(tiled, anchorRow, anchorCol);
|
|
2214
2521
|
}).catch(() => {});
|
|
2215
2522
|
};
|
|
@@ -2247,13 +2554,6 @@ let DataTable = class DataTable extends (0, _lit_labs_preact_signals.SignalWatch
|
|
|
2247
2554
|
}
|
|
2248
2555
|
this.applyGridToRange(grid, r0, c0);
|
|
2249
2556
|
};
|
|
2250
|
-
this.tileIndex = (i, lo, hi) => {
|
|
2251
|
-
const span = hi - lo + 1;
|
|
2252
|
-
if (span <= 1) return lo;
|
|
2253
|
-
let k = (i - lo) % span;
|
|
2254
|
-
if (k < 0) k = k + span;
|
|
2255
|
-
return lo + k;
|
|
2256
|
-
};
|
|
2257
2557
|
this.fillRange = (sourceBox, endCell) => {
|
|
2258
2558
|
let box;
|
|
2259
2559
|
if (sourceBox && sourceBox.r0 != null && endCell) {
|
|
@@ -2283,8 +2583,8 @@ let DataTable = class DataTable extends (0, _lit_labs_preact_signals.SignalWatch
|
|
|
2283
2583
|
for (let r = box.r0; r <= box.r1; r++) {
|
|
2284
2584
|
const cols = [];
|
|
2285
2585
|
for (let c = box.c0; c <= box.c1; c++) {
|
|
2286
|
-
const sr =
|
|
2287
|
-
const sc =
|
|
2586
|
+
const sr = tileIndex(r, src.r0, src.r1);
|
|
2587
|
+
const sc = tileIndex(c, src.c0, src.c1);
|
|
2288
2588
|
const v = this.cellValueAt(sr, sc);
|
|
2289
2589
|
cols.push(v == null ? "" : String(v));
|
|
2290
2590
|
}
|
|
@@ -2295,6 +2595,30 @@ let DataTable = class DataTable extends (0, _lit_labs_preact_signals.SignalWatch
|
|
|
2295
2595
|
this.fillDragging = false;
|
|
2296
2596
|
this.fillDragMove = null;
|
|
2297
2597
|
this.fillDragUp = null;
|
|
2598
|
+
this.fillEdgeScrollRaf = null;
|
|
2599
|
+
this.FILL_EDGE_SCROLL_PX = 24;
|
|
2600
|
+
this.FILL_EDGE_SCROLL_STEP = 16;
|
|
2601
|
+
this.edgeDelta = (clientX, clientY) => {
|
|
2602
|
+
if (!this.gridScrollEl) return {
|
|
2603
|
+
dx: 0,
|
|
2604
|
+
dy: 0
|
|
2605
|
+
};
|
|
2606
|
+
const rect = this.gridScrollEl.getBoundingClientRect();
|
|
2607
|
+
let dx = 0;
|
|
2608
|
+
let dy = 0;
|
|
2609
|
+
if (this.colsWindowed()) {
|
|
2610
|
+
if (clientX - rect.left < this.FILL_EDGE_SCROLL_PX) dx = -this.FILL_EDGE_SCROLL_STEP;
|
|
2611
|
+
else if (rect.right - clientX < this.FILL_EDGE_SCROLL_PX) dx = this.FILL_EDGE_SCROLL_STEP;
|
|
2612
|
+
}
|
|
2613
|
+
if (this.rowsWindowed()) {
|
|
2614
|
+
if (clientY - rect.top < this.FILL_EDGE_SCROLL_PX) dy = -this.FILL_EDGE_SCROLL_STEP;
|
|
2615
|
+
else if (rect.bottom - clientY < this.FILL_EDGE_SCROLL_PX) dy = this.FILL_EDGE_SCROLL_STEP;
|
|
2616
|
+
}
|
|
2617
|
+
return {
|
|
2618
|
+
dx,
|
|
2619
|
+
dy
|
|
2620
|
+
};
|
|
2621
|
+
};
|
|
2298
2622
|
this.teardownFillDrag = () => {
|
|
2299
2623
|
if (typeof document !== "undefined") {
|
|
2300
2624
|
if (this.fillDragMove) document.removeEventListener("pointermove", this.fillDragMove);
|
|
@@ -2303,6 +2627,10 @@ let DataTable = class DataTable extends (0, _lit_labs_preact_signals.SignalWatch
|
|
|
2303
2627
|
this.fillDragMove = null;
|
|
2304
2628
|
this.fillDragUp = null;
|
|
2305
2629
|
this.fillDragging = false;
|
|
2630
|
+
if (this.fillEdgeScrollRaf != null) {
|
|
2631
|
+
if (typeof cancelAnimationFrame === "function") cancelAnimationFrame(this.fillEdgeScrollRaf);
|
|
2632
|
+
this.fillEdgeScrollRaf = null;
|
|
2633
|
+
}
|
|
2306
2634
|
};
|
|
2307
2635
|
this.cellIndexFromPoint = (clientX, clientY) => {
|
|
2308
2636
|
if (typeof document === "undefined" || !document.elementFromPoint) return null;
|
|
@@ -2337,14 +2665,42 @@ let DataTable = class DataTable extends (0, _lit_labs_preact_signals.SignalWatch
|
|
|
2337
2665
|
r: sourceBox.r1,
|
|
2338
2666
|
c: sourceBox.c1
|
|
2339
2667
|
} : null;
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2668
|
+
let lastClientX = 0;
|
|
2669
|
+
let lastClientY = 0;
|
|
2670
|
+
const applyPointAt = (clientX, clientY) => {
|
|
2671
|
+
const cell = this.cellIndexFromPoint(clientX, clientY);
|
|
2343
2672
|
if (cell && (!lastCell || cell.r !== lastCell.r || cell.c !== lastCell.c)) {
|
|
2344
2673
|
lastCell = cell;
|
|
2345
2674
|
this.setRangeFocus(cell.r, cell.c);
|
|
2346
2675
|
}
|
|
2347
2676
|
};
|
|
2677
|
+
const scrollStep = () => {
|
|
2678
|
+
if (!this.fillDragging) {
|
|
2679
|
+
this.fillEdgeScrollRaf = null;
|
|
2680
|
+
return;
|
|
2681
|
+
}
|
|
2682
|
+
const d = this.edgeDelta(lastClientX, lastClientY);
|
|
2683
|
+
if (d.dx === 0 && d.dy === 0) {
|
|
2684
|
+
this.fillEdgeScrollRaf = null;
|
|
2685
|
+
return;
|
|
2686
|
+
}
|
|
2687
|
+
if (this.gridScrollEl) {
|
|
2688
|
+
if (d.dx !== 0) this.gridScrollEl.scrollLeft = this.gridScrollEl.scrollLeft + d.dx;
|
|
2689
|
+
if (d.dy !== 0) this.gridScrollEl.scrollTop = this.gridScrollEl.scrollTop + d.dy;
|
|
2690
|
+
}
|
|
2691
|
+
applyPointAt(lastClientX, lastClientY);
|
|
2692
|
+
this.fillEdgeScrollRaf = requestAnimationFrame(scrollStep);
|
|
2693
|
+
};
|
|
2694
|
+
const move = (ev) => {
|
|
2695
|
+
if (!this.fillDragging) return;
|
|
2696
|
+
lastClientX = ev.clientX;
|
|
2697
|
+
lastClientY = ev.clientY;
|
|
2698
|
+
applyPointAt(ev.clientX, ev.clientY);
|
|
2699
|
+
if (this.fillEdgeScrollRaf == null && typeof requestAnimationFrame === "function") {
|
|
2700
|
+
const d = this.edgeDelta(ev.clientX, ev.clientY);
|
|
2701
|
+
if (d.dx !== 0 || d.dy !== 0) this.fillEdgeScrollRaf = requestAnimationFrame(scrollStep);
|
|
2702
|
+
}
|
|
2703
|
+
};
|
|
2348
2704
|
const up = () => {
|
|
2349
2705
|
this.teardownFillDrag();
|
|
2350
2706
|
if (lastCell && sourceBox && (lastCell.r !== sourceBox.r1 || lastCell.c !== sourceBox.c1)) this.fillRange(sourceBox, lastCell);
|
|
@@ -2433,16 +2789,6 @@ let DataTable = class DataTable extends (0, _lit_labs_preact_signals.SignalWatch
|
|
|
2433
2789
|
this.setInvalid = (msg) => {
|
|
2434
2790
|
this._invalidMsg.value = msg != null ? msg : "";
|
|
2435
2791
|
};
|
|
2436
|
-
this.replaceRowValue = (rows, rowIndex, field, value) => {
|
|
2437
|
-
const src = rows || [];
|
|
2438
|
-
const out = [];
|
|
2439
|
-
for (let i = 0; i < src.length; i++) if (i === rowIndex) out.push({
|
|
2440
|
-
...src[i] || {},
|
|
2441
|
-
[field]: value
|
|
2442
|
-
});
|
|
2443
|
-
else out.push(src[i]);
|
|
2444
|
-
return out;
|
|
2445
|
-
};
|
|
2446
2792
|
this.sourceIndexOfRow = (visibleRowIndex) => {
|
|
2447
2793
|
const row = (this._rows.value || [])[visibleRowIndex];
|
|
2448
2794
|
if (!row) return visibleRowIndex;
|
|
@@ -2549,16 +2895,6 @@ let DataTable = class DataTable extends (0, _lit_labs_preact_signals.SignalWatch
|
|
|
2549
2895
|
if (typeof requestAnimationFrame === "function") requestAnimationFrame(tryFocus);
|
|
2550
2896
|
else setTimeout(tryFocus, 0);
|
|
2551
2897
|
};
|
|
2552
|
-
this.indexOfRowIn = (rows, rowOriginal, rowId) => {
|
|
2553
|
-
const list = rows || [];
|
|
2554
|
-
for (let i = 0; i < list.length; i++) {
|
|
2555
|
-
const r = list[i];
|
|
2556
|
-
if (!r) continue;
|
|
2557
|
-
if (rowId != null && r.id === rowId) return i;
|
|
2558
|
-
if (rowOriginal != null && r.original === rowOriginal) return i;
|
|
2559
|
-
}
|
|
2560
|
-
return -1;
|
|
2561
|
-
};
|
|
2562
2898
|
this.endEdit = () => {
|
|
2563
2899
|
this._editingRow.value = -1;
|
|
2564
2900
|
this._editingCol.value = -1;
|
|
@@ -2620,7 +2956,7 @@ let DataTable = class DataTable extends (0, _lit_labs_preact_signals.SignalWatch
|
|
|
2620
2956
|
this.committedThisSession = true;
|
|
2621
2957
|
if (changed) {
|
|
2622
2958
|
const srcIndex = this.sourceIndexOfRow(this._editingRow.value);
|
|
2623
|
-
const next =
|
|
2959
|
+
const next = replaceRowValue(this.currentData(), srcIndex, field, newValue);
|
|
2624
2960
|
this.writeData(next);
|
|
2625
2961
|
this.dispatchEvent(new CustomEvent("cell-edit-commit", {
|
|
2626
2962
|
detail: {
|
|
@@ -2663,7 +2999,7 @@ let DataTable = class DataTable extends (0, _lit_labs_preact_signals.SignalWatch
|
|
|
2663
2999
|
const field = def && def.accessorKey != null ? def.accessorKey : colId;
|
|
2664
3000
|
const srcIndex = this.sourceIndexOfRow(this._activeRow.value);
|
|
2665
3001
|
this.committedThisSession = true;
|
|
2666
|
-
this.writeData(
|
|
3002
|
+
this.writeData(replaceRowValue(this.currentData(), srcIndex, field, newValue));
|
|
2667
3003
|
this.dispatchEvent(new CustomEvent("cell-edit-commit", {
|
|
2668
3004
|
detail: {
|
|
2669
3005
|
rowId,
|
|
@@ -2798,7 +3134,7 @@ let DataTable = class DataTable extends (0, _lit_labs_preact_signals.SignalWatch
|
|
|
2798
3134
|
this.editTransition = true;
|
|
2799
3135
|
if (changed) {
|
|
2800
3136
|
const srcIndex = this.sourceIndexOfRow(rowIndex);
|
|
2801
|
-
const next =
|
|
3137
|
+
const next = replaceRowValues(this.currentData(), srcIndex, fieldValues);
|
|
2802
3138
|
this.writeData(next);
|
|
2803
3139
|
this.dispatchEvent(new CustomEvent("row-edit-commit", {
|
|
2804
3140
|
detail: {
|
|
@@ -2828,17 +3164,6 @@ let DataTable = class DataTable extends (0, _lit_labs_preact_signals.SignalWatch
|
|
|
2828
3164
|
this.editTransition = false;
|
|
2829
3165
|
this.focusCellWhenReady(focusRow, focusCol);
|
|
2830
3166
|
};
|
|
2831
|
-
this.replaceRowValues = (rows, rowIndex, fieldValues) => {
|
|
2832
|
-
const src = rows || [];
|
|
2833
|
-
const fv = fieldValues || {};
|
|
2834
|
-
const out = [];
|
|
2835
|
-
for (let i = 0; i < src.length; i++) if (i === rowIndex) out.push({
|
|
2836
|
-
...src[i] || {},
|
|
2837
|
-
...fv
|
|
2838
|
-
});
|
|
2839
|
-
else out.push(src[i]);
|
|
2840
|
-
return out;
|
|
2841
|
-
};
|
|
2842
3167
|
this.nextEditableCell = (fromRow, fromCol) => {
|
|
2843
3168
|
const rowList = this._rows.value || [];
|
|
2844
3169
|
const rowCount = rowList.length;
|
|
@@ -3023,8 +3348,8 @@ let DataTable = class DataTable extends (0, _lit_labs_preact_signals.SignalWatch
|
|
|
3023
3348
|
const lastRow = this.bodyRowCount() - 1;
|
|
3024
3349
|
const maxRow = lastRow < 0 ? 0 : lastRow;
|
|
3025
3350
|
const maxCol = this.visibleColCount() - 1;
|
|
3026
|
-
const r =
|
|
3027
|
-
const c =
|
|
3351
|
+
const r = clamp(Math.trunc(Number(rowIndex)) || 0, 0, maxRow);
|
|
3352
|
+
const c = clamp(Math.trunc(Number(colIndex)) || 0, 0, maxCol < 0 ? 0 : maxCol);
|
|
3028
3353
|
this.committedThisSession = false;
|
|
3029
3354
|
this._activeIsHeader.value = false;
|
|
3030
3355
|
this._activeRow.value = r;
|
|
@@ -3041,7 +3366,7 @@ let DataTable = class DataTable extends (0, _lit_labs_preact_signals.SignalWatch
|
|
|
3041
3366
|
this.editRow = (rowIndex) => {
|
|
3042
3367
|
const lastRow = this.bodyRowCount() - 1;
|
|
3043
3368
|
const maxRow = lastRow < 0 ? 0 : lastRow;
|
|
3044
|
-
const r =
|
|
3369
|
+
const r = clamp(Math.trunc(Number(rowIndex)) || 0, 0, maxRow);
|
|
3045
3370
|
const row = (this._rows.value || [])[r];
|
|
3046
3371
|
if (!row) return;
|
|
3047
3372
|
this._activeIsHeader.value = false;
|
|
@@ -3075,12 +3400,13 @@ let DataTable = class DataTable extends (0, _lit_labs_preact_signals.SignalWatch
|
|
|
3075
3400
|
if (!this.isGrid()) return;
|
|
3076
3401
|
this.focusIntentEpoch = this.focusIntentEpoch + 1;
|
|
3077
3402
|
const maxCol = this.visibleColCount() - 1;
|
|
3078
|
-
const c =
|
|
3403
|
+
const c = clamp(Math.trunc(Number(colIndex)) || 0, 0, maxCol < 0 ? 0 : maxCol);
|
|
3079
3404
|
const absLast = this.prePaginationRowCount() - 1;
|
|
3080
|
-
const absRow =
|
|
3405
|
+
const absRow = clamp(Math.trunc(Number(rowIndex)) || 0, 0, absLast < 0 ? 0 : absLast);
|
|
3081
3406
|
const prevAbs = this.toAbsRow(this._activeRow.value);
|
|
3407
|
+
const prevCol = this._activeColIndex.value;
|
|
3082
3408
|
const prevIsHeader = this._activeIsHeader.value;
|
|
3083
|
-
if (this.
|
|
3409
|
+
if (this.rowsWindowed()) {
|
|
3084
3410
|
this._activeIsHeader.value = false;
|
|
3085
3411
|
this._activeInControl.value = false;
|
|
3086
3412
|
this._activeRow.value = absRow;
|
|
@@ -3099,7 +3425,7 @@ let DataTable = class DataTable extends (0, _lit_labs_preact_signals.SignalWatch
|
|
|
3099
3425
|
if (switched) this.focusAbsCellWhenReady(absRow, localRow, c);
|
|
3100
3426
|
else this.focusActiveCell(localRow, c, false);
|
|
3101
3427
|
}
|
|
3102
|
-
if (absRow !== prevAbs || prevIsHeader) this.dispatchEvent(new CustomEvent("activecell-change", {
|
|
3428
|
+
if (absRow !== prevAbs || c !== prevCol || prevIsHeader) this.dispatchEvent(new CustomEvent("activecell-change", {
|
|
3103
3429
|
detail: {
|
|
3104
3430
|
rowIndex: absRow,
|
|
3105
3431
|
colIndex: c
|
|
@@ -3183,6 +3509,13 @@ let DataTable = class DataTable extends (0, _lit_labs_preact_signals.SignalWatch
|
|
|
3183
3509
|
font: var(--rdt-font, 14px system-ui, sans-serif);
|
|
3184
3510
|
color: var(--rdt-color, inherit);
|
|
3185
3511
|
}
|
|
3512
|
+
.rozie-data-table.rdt-col-windowed[data-rozie-s-d5dcab4c] {
|
|
3513
|
+
table-layout: fixed;
|
|
3514
|
+
}
|
|
3515
|
+
.rozie-data-table.rdt-col-windowed[data-rozie-s-d5dcab4c] .rdt-th[data-rozie-s-d5dcab4c],
|
|
3516
|
+
.rozie-data-table.rdt-col-windowed[data-rozie-s-d5dcab4c] .rdt-td[data-rozie-s-d5dcab4c] {
|
|
3517
|
+
box-sizing: border-box;
|
|
3518
|
+
}
|
|
3186
3519
|
.rdt-sr-live[data-rozie-s-d5dcab4c] {
|
|
3187
3520
|
position: absolute;
|
|
3188
3521
|
width: 1px;
|
|
@@ -3719,10 +4052,11 @@ let DataTable = class DataTable extends (0, _lit_labs_preact_signals.SignalWatch
|
|
|
3719
4052
|
this._rows.value = nextRows;
|
|
3720
4053
|
this._headerGroups.value = nextGroups;
|
|
3721
4054
|
this._rowModelVer.value = this._rowModelVer.value + 1;
|
|
3722
|
-
if (this.
|
|
4055
|
+
if (this.rowsWindowed() && this.virtualizer) {
|
|
3723
4056
|
this.virtualizer.setOptions(this.virtualizerOptions());
|
|
3724
4057
|
this.virtualizer._willUpdate();
|
|
3725
4058
|
}
|
|
4059
|
+
this.remeasureColumnWindow();
|
|
3726
4060
|
const nextRowCount = nextRows.length;
|
|
3727
4061
|
const nextColCount = nextRows.length ? nextRows[0].getVisibleCells().length : nextGroups.length ? (nextGroups[nextGroups.length - 1].headers || []).length : 0;
|
|
3728
4062
|
this.clampActiveCell(nextRowCount, nextColCount);
|
|
@@ -3735,7 +4069,7 @@ let DataTable = class DataTable extends (0, _lit_labs_preact_signals.SignalWatch
|
|
|
3735
4069
|
if (this.pendingEditFollow && this.isGrid()) {
|
|
3736
4070
|
const follow = this.pendingEditFollow;
|
|
3737
4071
|
this.pendingEditFollow = null;
|
|
3738
|
-
const followIdx =
|
|
4072
|
+
const followIdx = indexOfRowIn(nextRows, follow.rowOriginal, follow.rowId);
|
|
3739
4073
|
if (followIdx >= 0) this.focusCellWhenReady(followIdx, follow.col);
|
|
3740
4074
|
}
|
|
3741
4075
|
this.syncIndeterminate();
|
|
@@ -3744,17 +4078,28 @@ let DataTable = class DataTable extends (0, _lit_labs_preact_signals.SignalWatch
|
|
|
3744
4078
|
};
|
|
3745
4079
|
this.refreshRowModel();
|
|
3746
4080
|
this.gridRoot = this._ref__rozieRoot ? this._ref__rozieRoot.querySelector(".rozie-data-table") : null;
|
|
3747
|
-
if (this.
|
|
3748
|
-
|
|
4081
|
+
if (this.isWindowed()) this.gridScrollEl = this._ref__rozieRoot ? this._ref__rozieRoot.querySelector(".rdt-scroll") : null;
|
|
4082
|
+
if (this.rowsWindowed()) {
|
|
3749
4083
|
this.virtualizer = new _tanstack_virtual_core.Virtualizer(this.virtualizerOptions());
|
|
3750
4084
|
this.virtualizerCleanup = this.virtualizer._didMount();
|
|
3751
|
-
|
|
4085
|
+
}
|
|
4086
|
+
if (this.colsWindowed()) {
|
|
4087
|
+
this.colVirtualizer = new _tanstack_virtual_core.Virtualizer(this.columnVirtualizerOptions());
|
|
4088
|
+
this.colVirtualizerCleanup = this.colVirtualizer._didMount();
|
|
4089
|
+
}
|
|
4090
|
+
if (this.isWindowed()) this._windowVer.value = this._windowVer.value + 1;
|
|
4091
|
+
if (this.isWindowed()) {
|
|
3752
4092
|
const afterFirstFrame = () => {
|
|
3753
|
-
this.
|
|
3754
|
-
|
|
3755
|
-
|
|
3756
|
-
|
|
3757
|
-
|
|
4093
|
+
if (this.rowsWindowed()) {
|
|
4094
|
+
this.remeasureWindow();
|
|
4095
|
+
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");
|
|
4096
|
+
const pg = this.pagination;
|
|
4097
|
+
const pgConfigured = pg != null && !(pg.pageIndex === 0 && pg.pageSize === 10);
|
|
4098
|
+
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.");
|
|
4099
|
+
}
|
|
4100
|
+
if (this.colsWindowed()) {
|
|
4101
|
+
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");
|
|
4102
|
+
}
|
|
3758
4103
|
};
|
|
3759
4104
|
if (typeof requestAnimationFrame === "function") requestAnimationFrame(() => requestAnimationFrame(afterFirstFrame));
|
|
3760
4105
|
else setTimeout(afterFirstFrame, 0);
|
|
@@ -3839,10 +4184,11 @@ ${this.groupable ? lit.html`<div class="rdt-group-bar-host" data-rozie-s-d5dcab4
|
|
|
3839
4184
|
})()} @rozie-group-bar-apply-grouping=${($event) => this.applyGrouping($event.detail)} @rozie-group-bar-clear-grouping=${($event) => this.clearGrouping($event.detail)}>
|
|
3840
4185
|
${(0, lit_directives_repeat_js.repeat)(this.groupingKeys(), (gk, _idx) => gk, (gk, _idx) => lit.html`<span class="rdt-group-token" data-group-token="" data-rozie-s-d5dcab4c>${(0, _rozie_runtime_lit.rozieDisplay)(gk)}</span>`)}
|
|
3841
4186
|
</slot>`}
|
|
3842
|
-
</div>` : lit.nothing}${this.
|
|
4187
|
+
</div>` : lit.nothing}${this.isWindowed() ? lit.html`<div class="rdt-scroll" style=${(0, _rozie_runtime_lit.rozieStyle)(this.rowsWindowed() && this.maxHeight ? "max-height:" + this.maxHeight + ";overflow:auto;--rozie-data-table-max-height:" + this.maxHeight : "overflow:auto")} data-rozie-s-d5dcab4c>
|
|
3843
4188
|
<table class="${Object.entries({
|
|
3844
4189
|
"rozie-data-table": true,
|
|
3845
|
-
"rdt-sticky": this.stickyHeader
|
|
4190
|
+
"rdt-sticky": this.stickyHeader,
|
|
4191
|
+
"rdt-col-windowed": this.colsWindowed()
|
|
3846
4192
|
}).filter(([, v]) => v).map(([k]) => k).join(" ")}" role=${(0, _rozie_runtime_lit.rozieAttr)(this.tableRole())} aria-rowcount=${(0, _rozie_runtime_lit.rozieAttr)(this.gridAriaRowCount())} @keydown=${($event) => {
|
|
3847
4193
|
this.onGridKeyDown($event);
|
|
3848
4194
|
}} @focusin=${($event) => {
|
|
@@ -3858,14 +4204,15 @@ ${this.groupable ? lit.html`<div class="rdt-group-bar-host" data-rozie-s-d5dcab4
|
|
|
3858
4204
|
}} data-rozie-s-d5dcab4c>
|
|
3859
4205
|
<thead class="rdt-thead" role="rowgroup" data-rozie-s-d5dcab4c>
|
|
3860
4206
|
${(0, lit_directives_repeat_js.repeat)(this._headerGroups.value, (hg, hgLevel) => hg.id, (hg, hgLevel) => lit.html`<tr class="rdt-tr" role="row" aria-rowindex=${(0, _rozie_runtime_lit.rozieAttr)(hgLevel + 1)} data-rozie-s-d5dcab4c>
|
|
3861
|
-
|
|
4207
|
+
|
|
4208
|
+
${this.colsWindowed() ? lit.html`<th class="rdt-col-spacer" aria-hidden="true" style=${(0, _rozie_runtime_lit.rozieStyle)("width:" + this.colPadLeft() + "px;padding:0;border:0")} data-rozie-s-d5dcab4c></th>` : lit.nothing}${(0, lit_directives_repeat_js.repeat)(this.windowedHeadersFor(hg, hgLevel), (wh, _idx) => wh.header.id, (wh, _idx) => lit.html`<th class="${Object.entries({
|
|
3862
4209
|
"rdt-th": true,
|
|
3863
|
-
"rdt-select-th": this.isSelectColumn(header.column.id),
|
|
3864
|
-
"rdt-expander-th": this.isExpanderColumn(header.column.id),
|
|
3865
|
-
"rdt-th-resizing": this.columnIsResizing(header.column.id),
|
|
3866
|
-
"rdt-cell-active": this.isActiveCell("__header", this.headerColIndexOf(hg, header), hgLevel)
|
|
3867
|
-
}).filter(([, v]) => v).map(([k]) => k).join(" ")}" role="columnheader" data-col=${(0, _rozie_runtime_lit.rozieAttr)(header.column.id)} data-grid-cell="" data-row="__header" data-header-level=${(0, _rozie_runtime_lit.rozieAttr)(hgLevel)} colspan=${(0, _rozie_runtime_lit.rozieAttr)(
|
|
3868
|
-
${this.isSelectColumn(header.column.id) ? lit.html`<span style="display:contents" data-rozie-s-d5dcab4c>
|
|
4210
|
+
"rdt-select-th": this.isSelectColumn(wh.header.column.id),
|
|
4211
|
+
"rdt-expander-th": this.isExpanderColumn(wh.header.column.id),
|
|
4212
|
+
"rdt-th-resizing": this.columnIsResizing(wh.header.column.id),
|
|
4213
|
+
"rdt-cell-active": this.isActiveCell("__header", this.headerColIndexOf(hg, wh.header), hgLevel)
|
|
4214
|
+
}).filter(([, v]) => v).map(([k]) => k).join(" ")}" role="columnheader" data-col=${(0, _rozie_runtime_lit.rozieAttr)(wh.header.column.id)} data-grid-cell="" data-row="__header" data-header-level=${(0, _rozie_runtime_lit.rozieAttr)(hgLevel)} colspan=${(0, _rozie_runtime_lit.rozieAttr)(wh.span > 1 ? wh.span : null)} data-col-index=${(0, _rozie_runtime_lit.rozieAttr)(this.headerColIndexOf(hg, wh.header))} tabindex=${(0, _rozie_runtime_lit.rozieAttr)(this.cellTabindex("__header", this.headerColIndexOf(hg, wh.header), hgLevel))} aria-sort=${(0, _rozie_runtime_lit.rozieAttr)(this.ariaSortFor(wh.header.column.id))} style=${(0, _rozie_runtime_lit.rozieStyle)(this.thStyle(wh.header.column.id))} data-rozie-s-d5dcab4c>
|
|
4215
|
+
${this.isSelectColumn(wh.header.column.id) ? lit.html`<span style="display:contents" data-rozie-s-d5dcab4c>
|
|
3869
4216
|
${this.selectAll !== void 0 ? this.selectAll({
|
|
3870
4217
|
checked: this.isAllRowsSelected(),
|
|
3871
4218
|
indeterminate: this.isSomeRowsSelected(),
|
|
@@ -3883,102 +4230,103 @@ ${this.groupable ? lit.html`<div class="rdt-group-bar-host" data-rozie-s-d5dcab4
|
|
|
3883
4230
|
${this.selectionMode === "multiple" ? lit.html`<input class="rdt-select-all" type="checkbox" aria-label="Select all rows" ?checked=${this.isAllRowsSelected()} @change=${($event) => {
|
|
3884
4231
|
this.onToggleAllRows($event);
|
|
3885
4232
|
}} data-rozie-s-d5dcab4c />` : lit.nothing}</slot>`}
|
|
3886
|
-
</span>` : this.isExpanderColumn(header.column.id) ? lit.html`<span style="display:contents" data-rozie-s-d5dcab4c></span>` : lit.html`<span style="display:contents" data-rozie-s-d5dcab4c>
|
|
3887
|
-
${header.column.getCanSort && header.column.getCanSort() ? lit.html`<button class="rdt-sort-btn" type="button" @click=${($event) => {
|
|
3888
|
-
this.onHeaderSort(header.column.id, $event);
|
|
4233
|
+
</span>` : this.isExpanderColumn(wh.header.column.id) ? lit.html`<span style="display:contents" data-rozie-s-d5dcab4c></span>` : lit.html`<span style="display:contents" data-rozie-s-d5dcab4c>
|
|
4234
|
+
${wh.header.column.getCanSort && wh.header.column.getCanSort() ? lit.html`<button class="rdt-sort-btn" type="button" @click=${($event) => {
|
|
4235
|
+
this.onHeaderSort(wh.header.column.id, $event);
|
|
3889
4236
|
}} data-rozie-s-d5dcab4c>
|
|
3890
4237
|
<span class="rdt-header-label" data-rozie-s-d5dcab4c>
|
|
3891
4238
|
${this.colHeader !== void 0 ? this.colHeader({
|
|
3892
|
-
columnId: header.column.id,
|
|
3893
|
-
column: header.column,
|
|
3894
|
-
label: this.headerLabel(header.column.id)
|
|
4239
|
+
columnId: wh.header.column.id,
|
|
4240
|
+
column: wh.header.column,
|
|
4241
|
+
label: this.headerLabel(wh.header.column.id)
|
|
3895
4242
|
}) : lit.html`<slot name="colHeader" data-rozie-params=${(() => {
|
|
3896
4243
|
try {
|
|
3897
4244
|
return JSON.stringify({
|
|
3898
|
-
columnId: header.column.id,
|
|
3899
|
-
column: header.column,
|
|
3900
|
-
label: this.headerLabel(header.column.id)
|
|
4245
|
+
columnId: wh.header.column.id,
|
|
4246
|
+
column: wh.header.column,
|
|
4247
|
+
label: this.headerLabel(wh.header.column.id)
|
|
3901
4248
|
});
|
|
3902
4249
|
} catch {
|
|
3903
4250
|
return "{}";
|
|
3904
4251
|
}
|
|
3905
|
-
})()}>${(0, _rozie_runtime_lit.rozieDisplay)(this.headerLabel(header.column.id))}</slot>`}
|
|
4252
|
+
})()}>${(0, _rozie_runtime_lit.rozieDisplay)(this.headerLabel(wh.header.column.id))}</slot>`}
|
|
3906
4253
|
</span>
|
|
3907
|
-
<span class="rdt-sort-ind" aria-hidden="true" data-rozie-s-d5dcab4c>${(0, _rozie_runtime_lit.rozieDisplay)(this.sortIndicator(header.column.id))}</span>
|
|
4254
|
+
<span class="rdt-sort-ind" aria-hidden="true" data-rozie-s-d5dcab4c>${(0, _rozie_runtime_lit.rozieDisplay)(this.sortIndicator(wh.header.column.id))}</span>
|
|
3908
4255
|
</button>` : lit.html`<span style="display:contents" data-rozie-s-d5dcab4c>
|
|
3909
4256
|
<span class="rdt-header-label" data-rozie-s-d5dcab4c>
|
|
3910
4257
|
${this.colHeader !== void 0 ? this.colHeader({
|
|
3911
|
-
columnId: header.column.id,
|
|
3912
|
-
column: header.column,
|
|
3913
|
-
label: this.headerLabel(header.column.id)
|
|
4258
|
+
columnId: wh.header.column.id,
|
|
4259
|
+
column: wh.header.column,
|
|
4260
|
+
label: this.headerLabel(wh.header.column.id)
|
|
3914
4261
|
}) : lit.html`<slot name="colHeader" data-rozie-params=${(() => {
|
|
3915
4262
|
try {
|
|
3916
4263
|
return JSON.stringify({
|
|
3917
|
-
columnId: header.column.id,
|
|
3918
|
-
column: header.column,
|
|
3919
|
-
label: this.headerLabel(header.column.id)
|
|
4264
|
+
columnId: wh.header.column.id,
|
|
4265
|
+
column: wh.header.column,
|
|
4266
|
+
label: this.headerLabel(wh.header.column.id)
|
|
3920
4267
|
});
|
|
3921
4268
|
} catch {
|
|
3922
4269
|
return "{}";
|
|
3923
4270
|
}
|
|
3924
|
-
})()}>${(0, _rozie_runtime_lit.rozieDisplay)(this.headerLabel(header.column.id))}</slot>`}
|
|
4271
|
+
})()}>${(0, _rozie_runtime_lit.rozieDisplay)(this.headerLabel(wh.header.column.id))}</slot>`}
|
|
3925
4272
|
</span>
|
|
3926
|
-
</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=${(0, _rozie_runtime_lit.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>
|
|
3927
|
-
<button class="rdt-col-menu-item" type="button" role="menuitem" aria-pressed=${this.columnPinSide(header.column.id) === "left"} @click=${($event) => {
|
|
3928
|
-
this.onPinColumn(header.column.id, "left", $event);
|
|
4273
|
+
</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=${(0, _rozie_runtime_lit.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>
|
|
4274
|
+
<button class="rdt-col-menu-item" type="button" role="menuitem" aria-pressed=${this.columnPinSide(wh.header.column.id) === "left"} @click=${($event) => {
|
|
4275
|
+
this.onPinColumn(wh.header.column.id, "left", $event);
|
|
3929
4276
|
}} data-rozie-s-d5dcab4c>Pin left</button>
|
|
3930
|
-
<button class="rdt-col-menu-item" type="button" role="menuitem" aria-pressed=${this.columnPinSide(header.column.id) === "right"} @click=${($event) => {
|
|
3931
|
-
this.onPinColumn(header.column.id, "right", $event);
|
|
4277
|
+
<button class="rdt-col-menu-item" type="button" role="menuitem" aria-pressed=${this.columnPinSide(wh.header.column.id) === "right"} @click=${($event) => {
|
|
4278
|
+
this.onPinColumn(wh.header.column.id, "right", $event);
|
|
3932
4279
|
}} data-rozie-s-d5dcab4c>Pin right</button>
|
|
3933
|
-
<button class="rdt-col-menu-item" type="button" role="menuitem" aria-pressed=${!this.columnPinSide(header.column.id)} @click=${($event) => {
|
|
3934
|
-
this.onPinColumn(header.column.id, false, $event);
|
|
4280
|
+
<button class="rdt-col-menu-item" type="button" role="menuitem" aria-pressed=${!this.columnPinSide(wh.header.column.id)} @click=${($event) => {
|
|
4281
|
+
this.onPinColumn(wh.header.column.id, false, $event);
|
|
3935
4282
|
}} data-rozie-s-d5dcab4c>Unpin</button>
|
|
3936
4283
|
<hr class="rdt-col-menu-sep" data-rozie-s-d5dcab4c />
|
|
3937
4284
|
<button class="rdt-col-menu-item" type="button" role="menuitem" @click=${($event) => {
|
|
3938
|
-
this.onHideColumn(header.column.id, $event);
|
|
4285
|
+
this.onHideColumn(wh.header.column.id, $event);
|
|
3939
4286
|
}} data-rozie-s-d5dcab4c>Hide column</button>
|
|
3940
4287
|
</div></rozie-popover>
|
|
3941
|
-
<button class="rdt-resize-handle" type="button" aria-label=${(0, _rozie_runtime_lit.rozieAttr)("Resize " + this.headerLabel(header.column.id))} @pointerdown=${($event) => {
|
|
3942
|
-
this.onResizeStart(header.column.id, $event);
|
|
4288
|
+
<button class="rdt-resize-handle" type="button" aria-label=${(0, _rozie_runtime_lit.rozieAttr)("Resize " + this.headerLabel(wh.header.column.id))} @pointerdown=${($event) => {
|
|
4289
|
+
this.onResizeStart(wh.header.column.id, $event);
|
|
3943
4290
|
}} @touchstart=${($event) => {
|
|
3944
|
-
this.onResizeStart(header.column.id, $event);
|
|
4291
|
+
this.onResizeStart(wh.header.column.id, $event);
|
|
3945
4292
|
}} data-rozie-s-d5dcab4c><span class="rdt-resize-grip" aria-hidden="true" data-rozie-s-d5dcab4c></span></button>
|
|
3946
4293
|
</span>`}</th>`)}
|
|
3947
|
-
|
|
4294
|
+
|
|
4295
|
+
${this.colsWindowed() ? lit.html`<th class="rdt-col-spacer" aria-hidden="true" style=${(0, _rozie_runtime_lit.rozieStyle)("width:" + this.colPadRight() + "px;padding:0;border:0")} data-rozie-s-d5dcab4c></th>` : lit.nothing}</tr>`)}
|
|
3948
4296
|
|
|
3949
4297
|
${this.hasAnyFilterableColumn() ? lit.html`<tr class="rdt-filter-row" data-rozie-s-d5dcab4c>
|
|
3950
|
-
${(0, lit_directives_repeat_js.repeat)(this._headerGroups.value[this._headerGroups.value.length - 1].
|
|
3951
|
-
${this.isSelectColumn(header.column.id) ? lit.html`<span style="display:contents" data-rozie-s-d5dcab4c></span>` : this.isExpanderColumn(header.column.id) ? lit.html`<span style="display:contents" data-rozie-s-d5dcab4c></span>` : lit.html`<span style="display:contents" data-rozie-s-d5dcab4c>
|
|
3952
|
-
${this.columnIsFilterable(header.column.id) && !this.hasFilterSlot() ? lit.html`<input class="rdt-col-filter" type="text" aria-label=${(0, _rozie_runtime_lit.rozieAttr)("Filter " + this.headerLabel(header.column.id))} .value=${this.columnFilterValue(header.column.id)} @input=${($event) => {
|
|
3953
|
-
this.onColumnFilterInput(header.column.id, $event);
|
|
4298
|
+
${this.colsWindowed() ? lit.html`<th class="rdt-col-spacer" aria-hidden="true" style=${(0, _rozie_runtime_lit.rozieStyle)("width:" + this.colPadLeft() + "px;padding:0;border:0")} data-rozie-s-d5dcab4c></th>` : lit.nothing}${(0, lit_directives_repeat_js.repeat)(this.windowedHeadersFor(this._headerGroups.value[this._headerGroups.value.length - 1], this._headerGroups.value.length - 1), (wh, _idx) => wh.header.id, (wh, _idx) => lit.html`<th class="rdt-filter-cell" role="presentation" data-col=${(0, _rozie_runtime_lit.rozieAttr)(wh.header.column.id)} style=${(0, _rozie_runtime_lit.rozieStyle)(this.pinStyle(wh.header.column.id))} data-rozie-s-d5dcab4c>
|
|
4299
|
+
${this.isSelectColumn(wh.header.column.id) ? lit.html`<span style="display:contents" data-rozie-s-d5dcab4c></span>` : this.isExpanderColumn(wh.header.column.id) ? lit.html`<span style="display:contents" data-rozie-s-d5dcab4c></span>` : lit.html`<span style="display:contents" data-rozie-s-d5dcab4c>
|
|
4300
|
+
${this.columnIsFilterable(wh.header.column.id) && !this.hasFilterSlot() ? lit.html`<input class="rdt-col-filter" type="text" aria-label=${(0, _rozie_runtime_lit.rozieAttr)("Filter " + this.headerLabel(wh.header.column.id))} .value=${this.columnFilterValue(wh.header.column.id)} @input=${($event) => {
|
|
4301
|
+
this.onColumnFilterInput(wh.header.column.id, $event);
|
|
3954
4302
|
}} @click=${($event) => {
|
|
3955
4303
|
this.stopEvent($event);
|
|
3956
|
-
}} data-rozie-s-d5dcab4c />` : lit.nothing}${this.columnIsFilterable(header.column.id) ? lit.html`<span style="display:contents" data-rozie-s-d5dcab4c>
|
|
4304
|
+
}} data-rozie-s-d5dcab4c />` : lit.nothing}${this.columnIsFilterable(wh.header.column.id) ? lit.html`<span style="display:contents" data-rozie-s-d5dcab4c>
|
|
3957
4305
|
${this.filter !== void 0 ? this.filter({
|
|
3958
|
-
columnId: header.column.id,
|
|
3959
|
-
value: this.columnFilterValue(header.column.id),
|
|
3960
|
-
uniqueValues: this.getFacetedUniqueValues(header.column.id),
|
|
3961
|
-
minMax: this.getFacetedMinMaxValues(header.column.id),
|
|
4306
|
+
columnId: wh.header.column.id,
|
|
4307
|
+
value: this.columnFilterValue(wh.header.column.id),
|
|
4308
|
+
uniqueValues: this.getFacetedUniqueValues(wh.header.column.id),
|
|
4309
|
+
minMax: this.getFacetedMinMaxValues(wh.header.column.id),
|
|
3962
4310
|
setFilter: this.setColumnFilter
|
|
3963
4311
|
}) : lit.html`<slot name="filter" data-rozie-params=${(() => {
|
|
3964
4312
|
try {
|
|
3965
4313
|
return JSON.stringify({
|
|
3966
|
-
columnId: header.column.id,
|
|
3967
|
-
value: this.columnFilterValue(header.column.id),
|
|
3968
|
-
uniqueValues: this.getFacetedUniqueValues(header.column.id),
|
|
3969
|
-
minMax: this.getFacetedMinMaxValues(header.column.id)
|
|
4314
|
+
columnId: wh.header.column.id,
|
|
4315
|
+
value: this.columnFilterValue(wh.header.column.id),
|
|
4316
|
+
uniqueValues: this.getFacetedUniqueValues(wh.header.column.id),
|
|
4317
|
+
minMax: this.getFacetedMinMaxValues(wh.header.column.id)
|
|
3970
4318
|
});
|
|
3971
4319
|
} catch {
|
|
3972
4320
|
return "{}";
|
|
3973
4321
|
}
|
|
3974
4322
|
})()} @rozie-filter-set-filter=${($event) => this.setColumnFilter($event.detail)}></slot>`}
|
|
3975
4323
|
</span>` : lit.nothing}</span>`}</th>`)}
|
|
3976
|
-
|
|
4324
|
+
${this.colsWindowed() ? lit.html`<th class="rdt-col-spacer" aria-hidden="true" style=${(0, _rozie_runtime_lit.rozieStyle)("width:" + this.colPadRight() + "px;padding:0;border:0")} data-rozie-s-d5dcab4c></th>` : lit.nothing}</tr>` : lit.nothing}</thead>
|
|
3977
4325
|
|
|
3978
4326
|
<tbody class="rdt-tbody" role="rowgroup" data-rozie-s-d5dcab4c>
|
|
3979
4327
|
|
|
3980
4328
|
<tr class="rdt-spacer" aria-hidden="true" data-rozie-s-d5dcab4c>
|
|
3981
|
-
<td colspan=${(0, _rozie_runtime_lit.rozieAttr)(this.
|
|
4329
|
+
<td colspan=${(0, _rozie_runtime_lit.rozieAttr)(this.windowedColSpan())} style=${(0, _rozie_runtime_lit.rozieStyle)("height:" + this.padTop() + "px;padding:0;border:0")} data-rozie-s-d5dcab4c></td>
|
|
3982
4330
|
</tr>
|
|
3983
4331
|
|
|
3984
4332
|
${(0, lit_directives_repeat_js.repeat)(this.windowedRows(), (wr, _idx) => wr.row.id, (wr, _idx) => lit.html`
|
|
@@ -3987,7 +4335,8 @@ ${this.groupable ? lit.html`<div class="rdt-group-bar-host" data-rozie-s-d5dcab4
|
|
|
3987
4335
|
"rdt-group-header": this.rowIsGrouped(wr.row),
|
|
3988
4336
|
"rdt-row-pinned": wr.pinned
|
|
3989
4337
|
}).filter(([, v]) => v).map(([k]) => k).join(" ")}" role="row" data-row=${(0, _rozie_runtime_lit.rozieAttr)(wr.vi.index)} aria-rowindex=${(0, _rozie_runtime_lit.rozieAttr)(this.headerRowCount() + wr.vi.index + 1)} data-index=${(0, _rozie_runtime_lit.rozieAttr)(wr.vi.index)} data-pinned=${(0, _rozie_runtime_lit.rozieAttr)(wr.pinned ? "true" : null)} data-depth=${(0, _rozie_runtime_lit.rozieAttr)(wr.row.depth)} data-group-header=${(0, _rozie_runtime_lit.rozieAttr)(this.rowIsGrouped(wr.row) ? wr.row.id : null)} data-group-leaf=${(0, _rozie_runtime_lit.rozieAttr)(this.groupingActive() && !this.rowIsGrouped(wr.row) ? wr.row.id : null)} aria-expanded=${(0, _rozie_runtime_lit.rozieAttr)(this.rowIsGrouped(wr.row) ? !!this.rowIsExpanded(wr.row) : null)} aria-selected=${(0, _rozie_runtime_lit.rozieAttr)(this.selectionMode !== "none" ? !!this.rowIsSelected(wr.row) : null)} aria-level=${(0, _rozie_runtime_lit.rozieAttr)(this.groupingActive() ? wr.row.depth + 1 : null)} data-rozie-s-d5dcab4c>
|
|
3990
|
-
|
|
4338
|
+
|
|
4339
|
+
${this.colsWindowed() ? lit.html`<td class="rdt-col-spacer" aria-hidden="true" style=${(0, _rozie_runtime_lit.rozieStyle)("width:" + this.colPadLeft() + "px;padding:0;border:0")} data-rozie-s-d5dcab4c></td>` : lit.nothing}${(0, lit_directives_repeat_js.repeat)(this.windowedCells(wr.row), (cell, _idx) => cell.id, (cell, _idx) => lit.html`<td class="${Object.entries({
|
|
3991
4340
|
"rdt-td": true,
|
|
3992
4341
|
"rdt-select-td": this.isSelectColumn(cell.column.id),
|
|
3993
4342
|
"rdt-expander-td": this.isExpanderColumn(cell.column.id),
|
|
@@ -4113,10 +4462,11 @@ ${this.groupable ? lit.html`<div class="rdt-group-bar-host" data-rozie-s-d5dcab4
|
|
|
4113
4462
|
</span>`}${this.isFillHandleCell(wr.vi.index, this.colIndexOf(wr.row, cell)) ? lit.html`<span class="rdt-fill-handle" data-fill-handle="" data-testid="fill-handle" aria-hidden="true" @pointerdown=${($event) => {
|
|
4114
4463
|
this.onFillHandlePointerDown($event);
|
|
4115
4464
|
}} data-rozie-s-d5dcab4c></span>` : lit.nothing}</td>`)}
|
|
4116
|
-
|
|
4465
|
+
|
|
4466
|
+
${this.colsWindowed() ? lit.html`<td class="rdt-col-spacer" aria-hidden="true" style=${(0, _rozie_runtime_lit.rozieStyle)("width:" + this.colPadRight() + "px;padding:0;border:0")} data-rozie-s-d5dcab4c></td>` : lit.nothing}</tr>
|
|
4117
4467
|
|
|
4118
4468
|
${this.rowShowsDetail(wr.row) ? lit.html`<tr class="rdt-detail-row" role="row" data-detail-row=${(0, _rozie_runtime_lit.rozieAttr)(wr.row.id)} data-rozie-s-d5dcab4c>
|
|
4119
|
-
<td class="rdt-detail-cell" colspan=${(0, _rozie_runtime_lit.rozieAttr)(this.
|
|
4469
|
+
<td class="rdt-detail-cell" colspan=${(0, _rozie_runtime_lit.rozieAttr)(this.windowedColSpan())} data-rozie-s-d5dcab4c>
|
|
4120
4470
|
${this.detail !== void 0 ? this.detail({ row: wr.row.original }) : lit.html`<slot name="detail" data-rozie-params=${(() => {
|
|
4121
4471
|
try {
|
|
4122
4472
|
return JSON.stringify({ row: wr.row.original });
|
|
@@ -4128,7 +4478,7 @@ ${this.groupable ? lit.html`<div class="rdt-group-bar-host" data-rozie-s-d5dcab4
|
|
|
4128
4478
|
</tr>` : lit.nothing}`)}
|
|
4129
4479
|
|
|
4130
4480
|
<tr class="rdt-spacer" aria-hidden="true" data-rozie-s-d5dcab4c>
|
|
4131
|
-
<td colspan=${(0, _rozie_runtime_lit.rozieAttr)(this.
|
|
4481
|
+
<td colspan=${(0, _rozie_runtime_lit.rozieAttr)(this.windowedColSpan())} style=${(0, _rozie_runtime_lit.rozieStyle)("height:" + this.padBottom() + "px;padding:0;border:0")} data-rozie-s-d5dcab4c></td>
|
|
4132
4482
|
</tr>
|
|
4133
4483
|
</tbody>
|
|
4134
4484
|
</table>
|
|
@@ -4420,7 +4770,7 @@ ${this.groupable ? lit.html`<div class="rdt-group-bar-host" data-rozie-s-d5dcab4
|
|
|
4420
4770
|
</td>
|
|
4421
4771
|
</tr>` : lit.nothing}`)}
|
|
4422
4772
|
</tbody>
|
|
4423
|
-
</table>`}${!this.
|
|
4773
|
+
</table>`}${!this.rowsWindowed() ? lit.html`<div class="rdt-pagination" role="group" aria-label="Pagination" data-rozie-s-d5dcab4c>
|
|
4424
4774
|
<button class="rdt-page-btn rdt-page-prev" type="button" ?disabled=${!this.canPrevPage()} @click=${($event) => {
|
|
4425
4775
|
this.onPrevPage();
|
|
4426
4776
|
}} data-rozie-s-d5dcab4c>Prev</button>
|
|
@@ -4608,14 +4958,15 @@ __decorate([(0, lit_decorators_js.property)({
|
|
|
4608
4958
|
type: Number,
|
|
4609
4959
|
reflect: true
|
|
4610
4960
|
})], DataTable.prototype, "undoLimit", void 0);
|
|
4611
|
-
__decorate([(0, lit_decorators_js.property)({
|
|
4612
|
-
type: Boolean,
|
|
4613
|
-
reflect: true
|
|
4614
|
-
})], DataTable.prototype, "virtual", void 0);
|
|
4961
|
+
__decorate([(0, lit_decorators_js.property)({ converter: { fromAttribute: (v) => v === null ? false : v === "true" ? true : v === "false" ? false : v === "" ? true : v } })], DataTable.prototype, "virtual", void 0);
|
|
4615
4962
|
__decorate([(0, lit_decorators_js.property)({
|
|
4616
4963
|
type: Number,
|
|
4617
4964
|
reflect: true
|
|
4618
4965
|
})], DataTable.prototype, "estimateRowHeight", void 0);
|
|
4966
|
+
__decorate([(0, lit_decorators_js.property)({
|
|
4967
|
+
type: Boolean,
|
|
4968
|
+
reflect: true
|
|
4969
|
+
})], DataTable.prototype, "autoMeasure", void 0);
|
|
4619
4970
|
__decorate([(0, lit_decorators_js.property)({
|
|
4620
4971
|
type: String,
|
|
4621
4972
|
reflect: true
|