@rozie-ui/data-table-solid 0.2.6 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -4,6 +4,196 @@ import { __rozieInjectStyle, createControllableSignal, parseInlineStyle, rozieAt
4
4
  import Popover from "@rozie-ui/popover-solid";
5
5
  import { createTable, getCoreRowModel, getExpandedRowModel, getFacetedMinMaxValues, getFacetedRowModel, getFacetedUniqueValues, getFilteredRowModel, getGroupedRowModel, getPaginationRowModel, getSortedRowModel } from "@tanstack/table-core";
6
6
  import { Virtualizer, elementScroll, measureElement, observeElementOffset, observeElementRect } from "@tanstack/virtual-core";
7
+ //#region src/helpers/columnDefUtils.ts
8
+ const isSafeKey = (k) => k !== "__proto__" && k !== "constructor" && k !== "prototype";
9
+ const wrapAggregationFn = (fn) => {
10
+ if (typeof fn === "string") return fn;
11
+ if (typeof fn !== "function") return void 0;
12
+ return (columnId, leafRows, childRows) => {
13
+ try {
14
+ return fn(columnId, leafRows, childRows);
15
+ } catch (err) {
16
+ return;
17
+ }
18
+ };
19
+ };
20
+ const collectNestedDefs = (list, out) => {
21
+ if (!Array.isArray(list)) return;
22
+ for (const d of list) {
23
+ if (!d || d.id == null) continue;
24
+ const id = String(d.id);
25
+ if (!(id in out)) out[id] = d;
26
+ if (Array.isArray(d.columns)) collectNestedDefs(d.columns, out);
27
+ }
28
+ };
29
+ const indexDefsById = (defs) => {
30
+ const out = Object.create(null);
31
+ if (!Array.isArray(defs)) return out;
32
+ for (const d of defs) {
33
+ if (!d || d.id == null) continue;
34
+ out[String(d.id)] = d;
35
+ }
36
+ for (const d of defs) if (d && Array.isArray(d.columns)) collectNestedDefs(d.columns, out);
37
+ return out;
38
+ };
39
+ const collectGroupableLeafDefs = (defs) => {
40
+ const out = [];
41
+ if (!Array.isArray(defs)) return out;
42
+ for (const d of defs) {
43
+ if (!d) continue;
44
+ if (Array.isArray(d.columns)) {
45
+ out.push(...collectGroupableLeafDefs(d.columns));
46
+ continue;
47
+ }
48
+ if (d.groupable === false) continue;
49
+ out.push(d);
50
+ }
51
+ return out;
52
+ };
53
+ //#endregion
54
+ //#region src/helpers/indexMath.ts
55
+ const clamp = (v, lo, hi) => v < lo ? lo : v > hi ? hi : v;
56
+ const focusables = (cellEl) => {
57
+ if (!cellEl || !cellEl.querySelectorAll) return [];
58
+ return Array.prototype.slice.call(cellEl.querySelectorAll("button,[href],input,select,textarea,[tabindex]:not([tabindex=\"-1\"])")).filter((n) => !n.disabled);
59
+ };
60
+ const applyUpdater = (updater, current) => typeof updater === "function" ? updater(current) : updater;
61
+ //#endregion
62
+ //#region src/helpers/tsvGrid.ts
63
+ const escapeTsvField = (s) => {
64
+ if (s.indexOf(" ") >= 0 || s.indexOf("\n") >= 0 || s.indexOf("\r") >= 0 || s.indexOf("\"") >= 0) return "\"" + s.replace(/"/g, "\"\"") + "\"";
65
+ return s;
66
+ };
67
+ const parseTsv = (text) => {
68
+ const str = text != null ? String(text) : "";
69
+ if (str === "" || str.length > 2e6) return [];
70
+ const rows = [];
71
+ let row = [];
72
+ let field = "";
73
+ let inQuotes = false;
74
+ let i = 0;
75
+ const n = str.length;
76
+ while (i < n) {
77
+ const ch = str[i];
78
+ if (inQuotes) {
79
+ if (ch === "\"") {
80
+ if (i + 1 < n && str[i + 1] === "\"") {
81
+ field = field + "\"";
82
+ i = i + 2;
83
+ continue;
84
+ }
85
+ inQuotes = false;
86
+ i = i + 1;
87
+ continue;
88
+ }
89
+ field = field + ch;
90
+ i = i + 1;
91
+ continue;
92
+ }
93
+ if (ch === "\"" && field === "") {
94
+ inQuotes = true;
95
+ i = i + 1;
96
+ continue;
97
+ }
98
+ if (ch === " ") {
99
+ row.push(field);
100
+ field = "";
101
+ i = i + 1;
102
+ continue;
103
+ }
104
+ if (ch === "\r") {
105
+ if (i + 1 < n && str[i + 1] === "\n") i = i + 1;
106
+ row.push(field);
107
+ field = "";
108
+ rows.push(row);
109
+ row = [];
110
+ i = i + 1;
111
+ continue;
112
+ }
113
+ if (ch === "\n") {
114
+ row.push(field);
115
+ field = "";
116
+ rows.push(row);
117
+ row = [];
118
+ i = i + 1;
119
+ continue;
120
+ }
121
+ field = field + ch;
122
+ i = i + 1;
123
+ }
124
+ row.push(field);
125
+ rows.push(row);
126
+ if (rows.length > 1) {
127
+ const last = rows[rows.length - 1];
128
+ if (last.length === 1 && last[0] === "") rows.pop();
129
+ }
130
+ return rows;
131
+ };
132
+ const tileGridToBox = (grid, box) => {
133
+ const srcRows = grid.length;
134
+ let srcCols = 0;
135
+ for (let i = 0; i < srcRows; i++) {
136
+ const w = grid[i] && grid[i].length ? grid[i].length : 0;
137
+ if (w > srcCols) srcCols = w;
138
+ }
139
+ if (srcRows <= 0 || srcCols <= 0) return grid;
140
+ const boxRows = box.r1 - box.r0 + 1;
141
+ const boxCols = box.c1 - box.c0 + 1;
142
+ const rows = boxRows > srcRows ? boxRows : srcRows;
143
+ const cols = boxCols > srcCols ? boxCols : srcCols;
144
+ const out = [];
145
+ for (let r = 0; r < rows; r++) {
146
+ const srcLine = grid[r % srcRows] || [];
147
+ const line = [];
148
+ for (let c = 0; c < cols; c++) {
149
+ const v = srcLine[c % srcCols];
150
+ line.push(v != null ? v : "");
151
+ }
152
+ out.push(line);
153
+ }
154
+ return out;
155
+ };
156
+ const tileIndex = (i, lo, hi) => {
157
+ const span = hi - lo + 1;
158
+ if (span <= 1) return lo;
159
+ let k = (i - lo) % span;
160
+ if (k < 0) k = k + span;
161
+ return lo + k;
162
+ };
163
+ //#endregion
164
+ //#region src/helpers/rowValueUtils.ts
165
+ const replaceRowValue = (rows, rowIndex, field, value) => {
166
+ const src = rows || [];
167
+ const out = [];
168
+ for (let i = 0; i < src.length; i++) if (i === rowIndex) out.push({
169
+ ...src[i] || {},
170
+ [field]: value
171
+ });
172
+ else out.push(src[i]);
173
+ return out;
174
+ };
175
+ const replaceRowValues = (rows, rowIndex, fieldValues) => {
176
+ const src = rows || [];
177
+ const fv = fieldValues || {};
178
+ const out = [];
179
+ for (let i = 0; i < src.length; i++) if (i === rowIndex) out.push({
180
+ ...src[i] || {},
181
+ ...fv
182
+ });
183
+ else out.push(src[i]);
184
+ return out;
185
+ };
186
+ const indexOfRowIn = (rows, rowOriginal, rowId) => {
187
+ const list = rows || [];
188
+ for (let i = 0; i < list.length; i++) {
189
+ const r = list[i];
190
+ if (!r) continue;
191
+ if (rowId != null && r.id === rowId) return i;
192
+ if (rowOriginal != null && r.original === rowOriginal) return i;
193
+ }
194
+ return -1;
195
+ };
196
+ //#endregion
7
197
  //#region src/DataTable.tsx
8
198
  __rozieInjectStyle("DataTable-d5dcab4c", `.rozie-data-table[data-rozie-s-d5dcab4c] {
9
199
  border-collapse: collapse;
@@ -11,6 +201,13 @@ __rozieInjectStyle("DataTable-d5dcab4c", `.rozie-data-table[data-rozie-s-d5dcab4
11
201
  font: var(--rdt-font, 14px system-ui, sans-serif);
12
202
  color: var(--rdt-color, inherit);
13
203
  }
204
+ .rozie-data-table.rdt-col-windowed[data-rozie-s-d5dcab4c] {
205
+ table-layout: fixed;
206
+ }
207
+ .rozie-data-table.rdt-col-windowed[data-rozie-s-d5dcab4c] .rdt-th[data-rozie-s-d5dcab4c],
208
+ .rozie-data-table.rdt-col-windowed[data-rozie-s-d5dcab4c] .rdt-td[data-rozie-s-d5dcab4c] {
209
+ box-sizing: border-box;
210
+ }
14
211
  .rdt-sr-live[data-rozie-s-d5dcab4c] {
15
212
  position: absolute;
16
213
  width: 1px;
@@ -328,6 +525,7 @@ function DataTable(_props) {
328
525
  undoLimit: 100,
329
526
  virtual: false,
330
527
  estimateRowHeight: 40,
528
+ autoMeasure: false,
331
529
  maxHeight: ""
332
530
  }, _props), [
333
531
  "data",
@@ -357,6 +555,7 @@ function DataTable(_props) {
357
555
  "undoLimit",
358
556
  "virtual",
359
557
  "estimateRowHeight",
558
+ "autoMeasure",
360
559
  "maxHeight",
361
560
  "children",
362
561
  "ref",
@@ -531,10 +730,11 @@ function DataTable(_props) {
531
730
  setRows(nextRows);
532
731
  setHeaderGroups(nextGroups);
533
732
  setRowModelVer(rowModelVer() + 1);
534
- if (local.virtual && virtualizer) {
733
+ if (rowsWindowed() && virtualizer) {
535
734
  virtualizer.setOptions(virtualizerOptions());
536
735
  virtualizer._willUpdate();
537
736
  }
737
+ remeasureColumnWindow();
538
738
  const nextRowCount = nextRows.length;
539
739
  clampActiveCell(nextRowCount, nextRows.length ? nextRows[0].getVisibleCells().length : nextGroups.length ? (nextGroups[nextGroups.length - 1].headers || []).length : 0);
540
740
  const pgState = table.getState().pagination;
@@ -555,17 +755,28 @@ function DataTable(_props) {
555
755
  };
556
756
  refreshRowModel();
557
757
  gridRoot = __rozieRootRef ? __rozieRootRef.querySelector(".rozie-data-table") : null;
558
- if (local.virtual) {
559
- gridScrollEl = __rozieRootRef ? __rozieRootRef.querySelector(".rdt-scroll") : null;
758
+ if (isWindowed()) gridScrollEl = __rozieRootRef ? __rozieRootRef.querySelector(".rdt-scroll") : null;
759
+ if (rowsWindowed()) {
560
760
  virtualizer = new Virtualizer(virtualizerOptions());
561
761
  virtualizerCleanup = virtualizer._didMount();
562
- setWindowVer(windowVer() + 1);
762
+ }
763
+ if (colsWindowed()) {
764
+ colVirtualizer = new Virtualizer(columnVirtualizerOptions());
765
+ colVirtualizerCleanup = colVirtualizer._didMount();
766
+ }
767
+ if (isWindowed()) setWindowVer(windowVer() + 1);
768
+ if (isWindowed()) {
563
769
  const afterFirstFrame = () => {
564
- remeasureWindow();
565
- if (!(gridScrollEl ? 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");
566
- const pg = pagination();
567
- const pgConfigured = pg != null && !(pg.pageIndex === 0 && pg.pageSize === 10);
568
- if (local.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.");
770
+ if (rowsWindowed()) {
771
+ remeasureWindow();
772
+ if (!(gridScrollEl ? 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");
773
+ const pg = pagination();
774
+ const pgConfigured = pg != null && !(pg.pageIndex === 0 && pg.pageSize === 10);
775
+ if (local.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.");
776
+ }
777
+ if (colsWindowed()) {
778
+ if (!(gridScrollEl ? 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");
779
+ }
569
780
  };
570
781
  if (typeof requestAnimationFrame === "function") requestAnimationFrame(() => requestAnimationFrame(afterFirstFrame));
571
782
  else setTimeout(afterFirstFrame, 0);
@@ -576,6 +787,9 @@ function DataTable(_props) {
576
787
  });
577
788
  onCleanup(() => {
578
789
  if (virtualizerCleanup) virtualizerCleanup();
790
+ if (colVirtualizerCleanup) colVirtualizerCleanup();
791
+ teardownColRtlWatch();
792
+ teardownRemeasure();
579
793
  teardownFillDrag();
580
794
  teardownRangeDrag();
581
795
  });
@@ -630,7 +844,11 @@ function DataTable(_props) {
630
844
  let virtualizer = null;
631
845
  let virtualizerCleanup = null;
632
846
  let gridScrollEl = null;
847
+ let colVirtualizer = null;
848
+ let colVirtualizerCleanup = null;
633
849
  let remeasurePending = false;
850
+ let remeasureRaf = null;
851
+ let remeasureDisposed = false;
634
852
  const GRID_PAGE_STEP = 10;
635
853
  let gridRoot = null;
636
854
  let programmatic = 0;
@@ -674,20 +892,6 @@ function DataTable(_props) {
674
892
  function currentData() {
675
893
  return data() != null ? data() : dataDefault();
676
894
  }
677
- function isSafeKey(k) {
678
- return k !== "__proto__" && k !== "constructor" && k !== "prototype";
679
- }
680
- function wrapAggregationFn(fn) {
681
- if (typeof fn === "string") return fn;
682
- if (typeof fn !== "function") return void 0;
683
- return (columnId, leafRows, childRows) => {
684
- try {
685
- return fn(columnId, leafRows, childRows);
686
- } catch (err) {
687
- return;
688
- }
689
- };
690
- }
691
895
  function buildConfigDef(c) {
692
896
  if (!c) return null;
693
897
  if (Array.isArray(c.columns)) {
@@ -732,10 +936,16 @@ function DataTable(_props) {
732
936
  }
733
937
  };
734
938
  }
939
+ let columnDefsCache = null;
940
+ let columnDefsCacheColumnsRef = void 0;
941
+ let columnDefsCacheColRegRef = void 0;
942
+ let columnDefsIndexCache = null;
735
943
  function columnDefs() {
944
+ const cfg = local.columns || [];
945
+ const reg = colReg() || {};
946
+ if (columnDefsCache && local.columns === columnDefsCacheColumnsRef && colReg() === columnDefsCacheColRegRef) return columnDefsCache;
736
947
  const byId = Object.create(null);
737
948
  const order = [];
738
- const cfg = local.columns || [];
739
949
  for (const c of cfg) {
740
950
  const def = buildConfigDef(c);
741
951
  if (!def) continue;
@@ -743,7 +953,6 @@ function DataTable(_props) {
743
953
  if (!(id in byId)) order.push(id);
744
954
  byId[id] = def;
745
955
  }
746
- const reg = colReg() || {};
747
956
  for (const id in reg) {
748
957
  if (!isSafeKey(id)) continue;
749
958
  const spec = reg[id];
@@ -771,8 +980,16 @@ function DataTable(_props) {
771
980
  }
772
981
  const out = [];
773
982
  for (const id of order) if (byId[id]) out.push(byId[id]);
983
+ columnDefsCache = out;
984
+ columnDefsCacheColumnsRef = local.columns;
985
+ columnDefsCacheColRegRef = colReg();
986
+ columnDefsIndexCache = indexDefsById(out);
774
987
  return out;
775
988
  }
989
+ function defIndex() {
990
+ columnDefs();
991
+ return columnDefsIndexCache || Object.create(null);
992
+ }
776
993
  const SELECT_COL_ID = "__rdt_select";
777
994
  const EXPANDER_COL_ID = "__rdt_expander";
778
995
  function selectionEnabled() {
@@ -811,9 +1028,6 @@ function DataTable(_props) {
811
1028
  _props.onSortChange?.(next);
812
1029
  programmatic--;
813
1030
  }
814
- function applyUpdater(updater, current) {
815
- return typeof updater === "function" ? updater(current) : updater;
816
- }
817
1031
  function writeExpanded(next) {
818
1032
  if (programmatic) return;
819
1033
  programmatic++;
@@ -1021,12 +1235,71 @@ function DataTable(_props) {
1021
1235
  const next = applyUpdater(updater, columnSizingInfo());
1022
1236
  setColumnSizingInfo(next != null ? next : columnSizingInfo());
1023
1237
  }
1238
+ function resolveVirtual() {
1239
+ const v = local.virtual;
1240
+ if (typeof v === "string") {
1241
+ if (v === "rows") return "rows";
1242
+ if (v === "columns") return "columns";
1243
+ if (v === "both") return "both";
1244
+ return "off";
1245
+ }
1246
+ return v === true ? "rows" : "off";
1247
+ }
1248
+ function rowsWindowed() {
1249
+ const s = resolveVirtual();
1250
+ return s === "rows" || s === "both";
1251
+ }
1252
+ function colsWindowed() {
1253
+ const s = resolveVirtual();
1254
+ return s === "columns" || s === "both";
1255
+ }
1256
+ function isWindowed() {
1257
+ return rowsWindowed() || colsWindowed();
1258
+ }
1259
+ function autoMeasureOn() {
1260
+ return local.autoMeasure === true;
1261
+ }
1262
+ function columnCount() {
1263
+ return visibleColCount();
1264
+ }
1265
+ function columnSize(i) {
1266
+ if (!table || !table.getVisibleLeafColumns) return 150;
1267
+ const c = table.getVisibleLeafColumns()[i];
1268
+ return c && typeof c.getSize === "function" ? c.getSize() : 150;
1269
+ }
1270
+ function forcedColumns() {
1271
+ if (!colsWindowed()) return [];
1272
+ const out = [];
1273
+ if (table && table.getVisibleLeafColumns) {
1274
+ const cols = table.getVisibleLeafColumns();
1275
+ for (let i = 0; i < cols.length; i++) {
1276
+ const c = cols[i];
1277
+ if (c && c.getIsPinned && c.getIsPinned()) out.push(i);
1278
+ }
1279
+ }
1280
+ if (!activeIsHeader() && activeColIndex() >= 0 && out.indexOf(activeColIndex()) === -1) out.push(activeColIndex());
1281
+ if (editingRow() >= 0 && editingCol() >= 0 && out.indexOf(editingCol()) === -1) out.push(editingCol());
1282
+ return out;
1283
+ }
1284
+ function windowedCells(row) {
1285
+ windowVer();
1286
+ const cells = visibleCellsFor(row);
1287
+ if (!colsWindowed()) return cells;
1288
+ const idx = windowedColIndices();
1289
+ const out = [];
1290
+ for (let i = 0; i < idx.length; i++) {
1291
+ const cell = cells[idx[i]];
1292
+ if (cell) out.push(cell);
1293
+ }
1294
+ return out;
1295
+ }
1024
1296
  function windowSource() {
1025
1297
  if (!table) return [];
1026
- if (local.virtual) return table.getPrePaginationRowModel().rows;
1298
+ if (rowsWindowed()) return table.getPrePaginationRowModel().rows;
1027
1299
  return table.getRowModel().rows;
1028
1300
  }
1029
1301
  function scheduleRemeasure() {
1302
+ if (remeasureDisposed) return;
1030
1303
  if (remeasurePending) return;
1031
1304
  remeasurePending = true;
1032
1305
  let ranMicro = false;
@@ -1034,6 +1307,7 @@ function DataTable(_props) {
1034
1307
  remeasureWindow();
1035
1308
  };
1036
1309
  const rafPass = () => {
1310
+ remeasureRaf = null;
1037
1311
  remeasurePending = false;
1038
1312
  remeasureWindow();
1039
1313
  };
@@ -1041,9 +1315,18 @@ function DataTable(_props) {
1041
1315
  ranMicro = true;
1042
1316
  queueMicrotask(microPass);
1043
1317
  }
1044
- if (typeof requestAnimationFrame === "function") requestAnimationFrame(rafPass);
1318
+ if (typeof requestAnimationFrame === "function") remeasureRaf = requestAnimationFrame(rafPass);
1045
1319
  else if (ranMicro) remeasurePending = false;
1046
- else setTimeout(rafPass, 0);
1320
+ else remeasureRaf = setTimeout(rafPass, 0);
1321
+ }
1322
+ function teardownRemeasure() {
1323
+ remeasureDisposed = true;
1324
+ if (remeasureRaf != null) {
1325
+ if (typeof requestAnimationFrame === "function") cancelAnimationFrame(remeasureRaf);
1326
+ else clearTimeout(remeasureRaf);
1327
+ remeasureRaf = null;
1328
+ }
1329
+ remeasurePending = false;
1047
1330
  }
1048
1331
  function pinnedEditIndex() {
1049
1332
  if (editingRow() >= 0) return editingRow();
@@ -1056,20 +1339,124 @@ function DataTable(_props) {
1056
1339
  return ms && ms[pin] ? ms[pin] : null;
1057
1340
  }
1058
1341
  function remeasureWindow() {
1342
+ if (remeasureDisposed) return;
1059
1343
  if (!virtualizer || !gridRoot) return;
1060
1344
  if (virtualizer.scrollState) return;
1061
1345
  const trs = gridRoot.querySelectorAll("tbody.rdt-tbody > tr[data-index]");
1062
1346
  for (const tr of trs) virtualizer.measureElement(tr);
1347
+ if (afterRowRemeasure) afterRowRemeasure();
1063
1348
  }
1064
1349
  function virtualItemKey(i) {
1065
1350
  const src = windowSource();
1066
1351
  return src && src[i] ? src[i].id : void 0;
1067
1352
  }
1353
+ const COL_OVERSCAN = 3;
1354
+ let colRtlObserver = null;
1355
+ let colRtlObserverEl = null;
1356
+ function isColRtl() {
1357
+ if (!gridScrollEl || typeof getComputedStyle !== "function") return false;
1358
+ return getComputedStyle(gridScrollEl).direction === "rtl";
1359
+ }
1360
+ function ensureColRtlWatch() {
1361
+ if (!gridScrollEl || colRtlObserverEl === gridScrollEl || typeof MutationObserver !== "function") return;
1362
+ if (colRtlObserver) colRtlObserver.disconnect();
1363
+ colRtlObserver = new MutationObserver(() => {
1364
+ if (colVirtualizer) colVirtualizer.setOptions({
1365
+ ...colVirtualizer.options,
1366
+ isRtl: isColRtl()
1367
+ });
1368
+ });
1369
+ colRtlObserver.observe(gridScrollEl, {
1370
+ attributes: true,
1371
+ attributeFilter: ["dir"]
1372
+ });
1373
+ colRtlObserverEl = gridScrollEl;
1374
+ }
1375
+ function teardownColRtlWatch() {
1376
+ if (colRtlObserver) colRtlObserver.disconnect();
1377
+ colRtlObserver = null;
1378
+ colRtlObserverEl = null;
1379
+ }
1380
+ function columnVirtualizerOptions() {
1381
+ ensureColRtlWatch();
1382
+ return {
1383
+ count: columnCount(),
1384
+ getScrollElement: () => gridScrollEl,
1385
+ estimateSize: (i) => columnSize(i),
1386
+ horizontal: true,
1387
+ isRtl: isColRtl(),
1388
+ observeElementRect,
1389
+ observeElementOffset,
1390
+ scrollToFn: elementScroll,
1391
+ measureElement,
1392
+ overscan: COL_OVERSCAN,
1393
+ onChange: () => {
1394
+ setWindowVer(windowVer() + 1);
1395
+ }
1396
+ };
1397
+ }
1398
+ let measuredRowTotal = 0;
1399
+ let measuredRowCount = 0;
1400
+ let lastFedRowEstimate = 0;
1401
+ let foldedRowHeights = {};
1402
+ let windowVerBumpPending = false;
1403
+ function bumpWindowVer() {
1404
+ if (windowVerBumpPending) return;
1405
+ windowVerBumpPending = true;
1406
+ const flush = () => {
1407
+ windowVerBumpPending = false;
1408
+ setWindowVer(windowVer() + 1);
1409
+ };
1410
+ if (typeof queueMicrotask !== "undefined") queueMicrotask(flush);
1411
+ else setTimeout(flush, 0);
1412
+ }
1413
+ const ESTIMATE_REFEED_DELTA_PX = 4;
1414
+ function estimateRowSize(i) {
1415
+ if (!autoMeasureOn()) return local.estimateRowHeight;
1416
+ if (measuredRowCount === 0) return local.estimateRowHeight;
1417
+ return Math.round(measuredRowTotal / measuredRowCount);
1418
+ }
1419
+ function foldMeasuredRow(index, height) {
1420
+ const prev = foldedRowHeights[index];
1421
+ if (prev === height) return;
1422
+ if (prev == null) {
1423
+ measuredRowTotal = measuredRowTotal + height;
1424
+ measuredRowCount = measuredRowCount + 1;
1425
+ } else measuredRowTotal = measuredRowTotal - prev + height;
1426
+ foldedRowHeights[index] = height;
1427
+ }
1428
+ function refineRowEstimate() {
1429
+ if (!autoMeasureOn() || !virtualizer) return;
1430
+ const items = virtualizer.getVirtualItems();
1431
+ const measurements = virtualizer.getMeasurements();
1432
+ for (let i = 0; i < items.length; i++) {
1433
+ const idx = items[i].index;
1434
+ const m = measurements && measurements[idx];
1435
+ if (m) foldMeasuredRow(idx, m.size);
1436
+ }
1437
+ if (virtualizer.scrollState) return;
1438
+ const est = estimateRowSize(0);
1439
+ if (Math.abs(est - lastFedRowEstimate) < ESTIMATE_REFEED_DELTA_PX) return;
1440
+ const anchorIndex = items.length ? items[0].index : -1;
1441
+ const anchorStart = items.length ? items[0].start : 0;
1442
+ virtualizer.setOptions(virtualizerOptions());
1443
+ virtualizer._willUpdate();
1444
+ lastFedRowEstimate = est;
1445
+ if (anchorIndex >= 0 && gridScrollEl) {
1446
+ const freshMeasurements = virtualizer.getMeasurements();
1447
+ const fresh = freshMeasurements && freshMeasurements[anchorIndex];
1448
+ if (fresh) {
1449
+ const delta = fresh.start - anchorStart;
1450
+ if (delta !== 0) gridScrollEl.scrollTop = gridScrollEl.scrollTop + delta;
1451
+ }
1452
+ }
1453
+ bumpWindowVer();
1454
+ }
1068
1455
  function virtualizerOptions() {
1069
1456
  return {
1070
1457
  count: windowSource().length,
1071
1458
  getScrollElement: () => gridScrollEl,
1072
- estimateSize: () => local.estimateRowHeight,
1459
+ estimateSize: (i) => estimateRowSize(i),
1073
1460
  observeElementRect,
1074
1461
  observeElementOffset,
1075
1462
  scrollToFn: elementScroll,
@@ -1077,7 +1464,7 @@ function DataTable(_props) {
1077
1464
  overscan: 8,
1078
1465
  getItemKey: virtualItemKey,
1079
1466
  onChange: () => {
1080
- setWindowVer(windowVer() + 1);
1467
+ bumpWindowVer();
1081
1468
  scheduleRemeasure();
1082
1469
  }
1083
1470
  };
@@ -1089,8 +1476,8 @@ function DataTable(_props) {
1089
1476
  windowVer();
1090
1477
  editVer();
1091
1478
  if (!virtualizer) {
1092
- if (!local.virtual) return (rows() || []).map((r) => ({
1093
- vi: null,
1479
+ if (!rowsWindowed()) return (rows() || []).map((r, i) => ({
1480
+ vi: { index: i },
1094
1481
  row: r
1095
1482
  }));
1096
1483
  return [];
@@ -1126,7 +1513,7 @@ function DataTable(_props) {
1126
1513
  function padTop() {
1127
1514
  windowVer();
1128
1515
  editVer();
1129
- if (!local.virtual || !virtualizer) return 0;
1516
+ if (!rowsWindowed() || !virtualizer) return 0;
1130
1517
  const items = virtualizer.getVirtualItems();
1131
1518
  let pad = items.length ? items[0].start : 0;
1132
1519
  const pin = pinnedEditIndex();
@@ -1140,7 +1527,7 @@ function DataTable(_props) {
1140
1527
  function padBottom() {
1141
1528
  windowVer();
1142
1529
  editVer();
1143
- if (!local.virtual || !virtualizer) return 0;
1530
+ if (!rowsWindowed() || !virtualizer) return 0;
1144
1531
  const items = virtualizer.getVirtualItems();
1145
1532
  if (!items.length) return 0;
1146
1533
  let pad = virtualizer.getTotalSize() - items[items.length - 1].end;
@@ -1161,11 +1548,59 @@ function DataTable(_props) {
1161
1548
  return false;
1162
1549
  }
1163
1550
  function rowIsOutsideWindow(r) {
1164
- if (!local.virtual || !virtualizer) return false;
1551
+ if (!rowsWindowed() || !virtualizer) return false;
1165
1552
  const items = virtualizer.getVirtualItems();
1166
1553
  for (const it of items) if (it.index === r) return false;
1167
1554
  return true;
1168
1555
  }
1556
+ function windowedColIndices() {
1557
+ windowVer();
1558
+ editVer();
1559
+ if (!colsWindowed()) {
1560
+ const n = columnCount();
1561
+ const out = [];
1562
+ for (let i = 0; i < n; i++) out.push(i);
1563
+ return out;
1564
+ }
1565
+ if (!colVirtualizer) return [];
1566
+ const idx = colVirtualizer.getVirtualItems().map((it) => it.index);
1567
+ const forced = forcedColumns();
1568
+ for (let i = 0; i < forced.length; i++) if (idx.indexOf(forced[i]) === -1) idx.push(forced[i]);
1569
+ idx.sort((a, b) => a - b);
1570
+ return idx;
1571
+ }
1572
+ function colPadLeft() {
1573
+ windowVer();
1574
+ editVer();
1575
+ if (!colsWindowed() || !colVirtualizer) return 0;
1576
+ const items = colVirtualizer.getVirtualItems();
1577
+ let pad = items.length ? items[0].start : 0;
1578
+ if (items.length) {
1579
+ const firstIdx = items[0].index;
1580
+ const forced = forcedColumns();
1581
+ for (let i = 0; i < forced.length; i++) if (forced[i] < firstIdx) pad = pad - columnSize(forced[i]);
1582
+ }
1583
+ return pad < 0 ? 0 : pad;
1584
+ }
1585
+ function colPadRight() {
1586
+ windowVer();
1587
+ editVer();
1588
+ if (!colsWindowed() || !colVirtualizer) return 0;
1589
+ const items = colVirtualizer.getVirtualItems();
1590
+ if (!items.length) return 0;
1591
+ let pad = colVirtualizer.getTotalSize() - items[items.length - 1].end;
1592
+ const lastIdx = items[items.length - 1].index;
1593
+ const forced = forcedColumns();
1594
+ for (let i = 0; i < forced.length; i++) if (forced[i] > lastIdx) pad = pad - columnSize(forced[i]);
1595
+ return pad < 0 ? 0 : pad;
1596
+ }
1597
+ function colIsOutsideWindow(c) {
1598
+ if (!colsWindowed() || !colVirtualizer) return false;
1599
+ const items = colVirtualizer.getVirtualItems();
1600
+ for (const it of items) if (it.index === c) return false;
1601
+ return true;
1602
+ }
1603
+ let afterRowRemeasure = refineRowEstimate;
1169
1604
  const announceState = {
1170
1605
  sorting: null,
1171
1606
  columnFilters: null,
@@ -1272,9 +1707,9 @@ function DataTable(_props) {
1272
1707
  return "";
1273
1708
  }
1274
1709
  function defFor(colId) {
1275
- const defs = columnDefs();
1276
- for (const d of defs) if (d.id === colId) return d;
1277
- return null;
1710
+ if (colId == null) return null;
1711
+ const d = defIndex()[String(colId)];
1712
+ return d != null ? d : null;
1278
1713
  }
1279
1714
  function visibleCellsFor(row) {
1280
1715
  return rowModelVer() >= 0 ? row.getVisibleCells() : [];
@@ -1467,6 +1902,9 @@ function DataTable(_props) {
1467
1902
  function rowIsGrouped(row) {
1468
1903
  return !!(tick() >= 0 && row && row.getIsGrouped && row.getIsGrouped());
1469
1904
  }
1905
+ function rowIndexIsGrouped(rowIndex) {
1906
+ return rowIsGrouped((rows() || [])[rowIndex]);
1907
+ }
1470
1908
  function groupingActive() {
1471
1909
  return tick() >= 0 && (currentState().grouping || []).length > 0;
1472
1910
  }
@@ -1480,21 +1918,54 @@ function DataTable(_props) {
1480
1918
  return !!(tick() >= 0 && cellCtx && cellCtx.getIsPlaceholder && cellCtx.getIsPlaceholder());
1481
1919
  }
1482
1920
  function groupSubRowCount(row) {
1483
- return row && row.getLeafRows ? row.getLeafRows().length : row && row.subRows ? row.subRows.length : 0;
1921
+ if (row && row.getLeafRows) {
1922
+ const leaves = row.getLeafRows();
1923
+ let n = 0;
1924
+ for (let i = 0; i < leaves.length; i++) {
1925
+ const r = leaves[i];
1926
+ if (!(r && r.getIsGrouped && r.getIsGrouped())) n = n + 1;
1927
+ }
1928
+ return n;
1929
+ }
1930
+ return row && row.subRows ? row.subRows.length : 0;
1931
+ }
1932
+ let groupRowDescriptorCache = null;
1933
+ let groupRowDescriptorCacheVer = void 0;
1934
+ function groupRowDescriptor(row) {
1935
+ const ver = rowModelVer();
1936
+ if (!groupRowDescriptorCache || groupRowDescriptorCacheVer !== ver) {
1937
+ groupRowDescriptorCache = Object.create(null);
1938
+ groupRowDescriptorCacheVer = ver;
1939
+ }
1940
+ const key = String(row.id);
1941
+ let d = groupRowDescriptorCache[key];
1942
+ if (!d) {
1943
+ const groupingColumnId = row.groupingColumnId != null ? row.groupingColumnId : "";
1944
+ const groupingValue = row.getGroupingValue ? row.getGroupingValue(groupingColumnId) : row.groupingValue;
1945
+ d = {
1946
+ isGroupRow: true,
1947
+ groupId: row.id,
1948
+ groupingColumnId,
1949
+ groupingValue,
1950
+ leafCount: groupSubRowCount(row)
1951
+ };
1952
+ groupRowDescriptorCache[key] = d;
1953
+ }
1954
+ return d;
1955
+ }
1956
+ function cellSlotRow(row) {
1957
+ return rowIsGrouped(row) ? groupRowDescriptor(row) : row ? row.original : null;
1484
1958
  }
1485
1959
  function groupingKeys() {
1486
1960
  return currentState().grouping || [];
1487
1961
  }
1488
1962
  function groupableColumns() {
1489
1963
  const out = [];
1490
- const defs = columnDefs();
1491
- for (const d of defs) {
1492
- if (!d || d.groupable === false) continue;
1493
- out.push({
1494
- id: d.id,
1495
- label: d.header != null ? d.header : d.id
1496
- });
1497
- }
1964
+ const defs = collectGroupableLeafDefs(columnDefs());
1965
+ for (const d of defs) out.push({
1966
+ id: d.id,
1967
+ label: d.header != null ? d.header : d.id
1968
+ });
1498
1969
  return out;
1499
1970
  }
1500
1971
  function stopEvent(evt) {
@@ -1582,7 +2053,7 @@ function DataTable(_props) {
1582
2053
  }
1583
2054
  function getRowIndexRelativeToPage(absRow) {
1584
2055
  const abs = absRow == null ? toAbsRow(activeRow()) : Math.trunc(Number(absRow)) || 0;
1585
- if (local.virtual) return abs;
2056
+ if (rowsWindowed()) return abs;
1586
2057
  return abs - pageRowOffset();
1587
2058
  }
1588
2059
  function cut() {
@@ -1607,14 +2078,14 @@ function DataTable(_props) {
1607
2078
  return (hg && hg.headers ? hg.headers : []).indexOf(header);
1608
2079
  }
1609
2080
  function pageRowOffset() {
1610
- if (!isGrid() || local.virtual) return 0;
2081
+ if (!isGrid() || rowsWindowed()) return 0;
1611
2082
  return pageIndex() * pageSize();
1612
2083
  }
1613
2084
  function toAbsRow(localRow) {
1614
2085
  return localRow + pageRowOffset();
1615
2086
  }
1616
2087
  function prePaginationRowCount() {
1617
- if (!table || local.virtual) return bodyRowCount();
2088
+ if (!table || rowsWindowed()) return bodyRowCount();
1618
2089
  const pm = table.getPrePaginationRowModel();
1619
2090
  return pm && pm.rows ? pm.rows.length : bodyRowCount();
1620
2091
  }
@@ -1649,8 +2120,11 @@ function DataTable(_props) {
1649
2120
  const c = nextCol == null ? activeColIndex() : nextCol;
1650
2121
  const lvl = nextLevel == null ? activeHeaderLevel() : nextLevel;
1651
2122
  const header = nextIsHeader == null ? activeIsHeader() : nextIsHeader;
1652
- if (local.virtual && virtualizer && !header && rowIsOutsideWindow(r)) {
1653
- virtualizer.scrollToIndex(r, { align: "center" });
2123
+ const rowOut = rowsWindowed() && virtualizer && rowIsOutsideWindow(r);
2124
+ const colOut = colsWindowed() && colVirtualizer && colIsOutsideWindow(c);
2125
+ if (!header && (rowOut || colOut)) {
2126
+ if (rowOut) virtualizer.scrollToIndex(r, { align: "center" });
2127
+ if (colOut) colVirtualizer.scrollToIndex(c, { align: "center" });
1654
2128
  let focusAttempts = 0;
1655
2129
  const myEpoch = focusIntentEpoch;
1656
2130
  const focusWhenReady = () => {
@@ -1698,9 +2172,6 @@ function DataTable(_props) {
1698
2172
  function bodyRowCount() {
1699
2173
  return (rows() || []).length;
1700
2174
  }
1701
- function clamp(v, lo, hi) {
1702
- return v < lo ? lo : v > hi ? hi : v;
1703
- }
1704
2175
  function headerLeafLevel() {
1705
2176
  const hg = headerGroups() || [];
1706
2177
  return hg.length ? hg.length - 1 : 0;
@@ -1863,10 +2334,6 @@ function DataTable(_props) {
1863
2334
  function currentCellEl() {
1864
2335
  return resolveCellEl(activeIsHeader() ? "__header" : String(activeRow()), activeColIndex(), activeIsHeader() ? activeHeaderLevel() : null);
1865
2336
  }
1866
- function focusables(cellEl) {
1867
- if (!cellEl || !cellEl.querySelectorAll) return [];
1868
- return Array.prototype.slice.call(cellEl.querySelectorAll("button,[href],input,select,textarea,[tabindex]:not([tabindex=\"-1\"])")).filter((n) => !n.disabled);
1869
- }
1870
2337
  function enterControl() {
1871
2338
  const list = focusables(currentCellEl());
1872
2339
  if (!list.length) return;
@@ -2269,6 +2736,40 @@ function DataTable(_props) {
2269
2736
  recoverGridFocus(String(recRow), recCol, null);
2270
2737
  }
2271
2738
  }
2739
+ function windowedHeadersFor(hg, hgLevel) {
2740
+ const headers = hg && hg.headers || [];
2741
+ if (!colsWindowed()) return headers.map((h) => ({
2742
+ header: h,
2743
+ span: h && h.colSpan > 1 ? h.colSpan : 1
2744
+ }));
2745
+ const idx = windowedColIndices();
2746
+ const idxSet = {};
2747
+ for (let i = 0; i < idx.length; i++) idxSet[idx[i]] = true;
2748
+ let cursor = 0;
2749
+ const out = [];
2750
+ for (let i = 0; i < headers.length; i++) {
2751
+ const h = headers[i];
2752
+ const leafCount = h && h.colSpan ? h.colSpan : 1;
2753
+ const start = cursor;
2754
+ const end = cursor + leafCount;
2755
+ cursor = end;
2756
+ let span = 0;
2757
+ for (let c = start; c < end; c++) if (idxSet[c]) span = span + 1;
2758
+ if (span > 0) out.push({
2759
+ header: h,
2760
+ span
2761
+ });
2762
+ }
2763
+ return out;
2764
+ }
2765
+ function windowedColSpan() {
2766
+ return colsWindowed() ? windowedColIndices().length + 2 : visibleColCount();
2767
+ }
2768
+ function remeasureColumnWindow() {
2769
+ if (!colsWindowed() || !colVirtualizer) return;
2770
+ colVirtualizer.setOptions(columnVirtualizerOptions());
2771
+ colVirtualizer._willUpdate();
2772
+ }
2272
2773
  let gridEmptyFallback = false;
2273
2774
  let rangeTransition = false;
2274
2775
  let rangeClickPending = false;
@@ -2451,10 +2952,6 @@ function DataTable(_props) {
2451
2952
  c1: ac > fc ? ac : fc
2452
2953
  };
2453
2954
  }
2454
- function escapeTsvField(s) {
2455
- if (s.indexOf(" ") >= 0 || s.indexOf("\n") >= 0 || s.indexOf("\r") >= 0 || s.indexOf("\"") >= 0) return "\"" + s.replace(/"/g, "\"\"") + "\"";
2456
- return s;
2457
- }
2458
2955
  function rangeToTsv() {
2459
2956
  const box = normalizedRange();
2460
2957
  const r0 = box ? box.r0 : activeRow();
@@ -2472,71 +2969,6 @@ function DataTable(_props) {
2472
2969
  }
2473
2970
  return lines.join("\n");
2474
2971
  }
2475
- function parseTsv(text) {
2476
- const str = text != null ? String(text) : "";
2477
- if (str === "" || str.length > 2e6) return [];
2478
- const rows = [];
2479
- let row = [];
2480
- let field = "";
2481
- let inQuotes = false;
2482
- let i = 0;
2483
- const n = str.length;
2484
- while (i < n) {
2485
- const ch = str[i];
2486
- if (inQuotes) {
2487
- if (ch === "\"") {
2488
- if (i + 1 < n && str[i + 1] === "\"") {
2489
- field = field + "\"";
2490
- i = i + 2;
2491
- continue;
2492
- }
2493
- inQuotes = false;
2494
- i = i + 1;
2495
- continue;
2496
- }
2497
- field = field + ch;
2498
- i = i + 1;
2499
- continue;
2500
- }
2501
- if (ch === "\"" && field === "") {
2502
- inQuotes = true;
2503
- i = i + 1;
2504
- continue;
2505
- }
2506
- if (ch === " ") {
2507
- row.push(field);
2508
- field = "";
2509
- i = i + 1;
2510
- continue;
2511
- }
2512
- if (ch === "\r") {
2513
- if (i + 1 < n && str[i + 1] === "\n") i = i + 1;
2514
- row.push(field);
2515
- field = "";
2516
- rows.push(row);
2517
- row = [];
2518
- i = i + 1;
2519
- continue;
2520
- }
2521
- if (ch === "\n") {
2522
- row.push(field);
2523
- field = "";
2524
- rows.push(row);
2525
- row = [];
2526
- i = i + 1;
2527
- continue;
2528
- }
2529
- field = field + ch;
2530
- i = i + 1;
2531
- }
2532
- row.push(field);
2533
- rows.push(row);
2534
- if (rows.length > 1) {
2535
- const last = rows[rows.length - 1];
2536
- if (last.length === 1 && last[0] === "") rows.pop();
2537
- }
2538
- return rows;
2539
- }
2540
2972
  function copyRange() {
2541
2973
  if (!clipboardActiveAllowed()) return;
2542
2974
  if (typeof navigator === "undefined" || !navigator.clipboard || !navigator.clipboard.writeText) return;
@@ -2559,11 +2991,13 @@ function DataTable(_props) {
2559
2991
  for (let gr = 0; gr < grid.length; gr++) {
2560
2992
  const r = originRow + gr;
2561
2993
  if (r > maxRow) break;
2994
+ const rowGrouped = rowIndexIsGrouped(r);
2562
2995
  const cols = grid[gr] || [];
2563
2996
  for (let gc = 0; gc < cols.length; gc++) {
2564
2997
  const c = originCol + gc;
2565
2998
  if (c > maxCol) break;
2566
2999
  total = total + 1;
3000
+ if (rowGrouped) continue;
2567
3001
  const colId = columnIdAt(r, c);
2568
3002
  if (colId == null || !columnEditable(colId)) continue;
2569
3003
  const rowObj = rowOriginalAt(r);
@@ -2603,30 +3037,6 @@ function DataTable(_props) {
2603
3037
  const row = (rows() || [])[rowIndex];
2604
3038
  return row ? row.id : null;
2605
3039
  }
2606
- function tileGridToBox(grid, box) {
2607
- const srcRows = grid.length;
2608
- let srcCols = 0;
2609
- for (let i = 0; i < srcRows; i++) {
2610
- const w = grid[i] && grid[i].length ? grid[i].length : 0;
2611
- if (w > srcCols) srcCols = w;
2612
- }
2613
- if (srcRows <= 0 || srcCols <= 0) return grid;
2614
- const boxRows = box.r1 - box.r0 + 1;
2615
- const boxCols = box.c1 - box.c0 + 1;
2616
- const rows = boxRows > srcRows ? boxRows : srcRows;
2617
- const cols = boxCols > srcCols ? boxCols : srcCols;
2618
- const out = [];
2619
- for (let r = 0; r < rows; r++) {
2620
- const srcLine = grid[r % srcRows] || [];
2621
- const line = [];
2622
- for (let c = 0; c < cols; c++) {
2623
- const v = srcLine[c % srcCols];
2624
- line.push(v != null ? v : "");
2625
- }
2626
- out.push(line);
2627
- }
2628
- return out;
2629
- }
2630
3040
  function pasteRange() {
2631
3041
  if (!clipboardActiveAllowed()) return;
2632
3042
  if (typeof navigator === "undefined" || !navigator.clipboard || !navigator.clipboard.readText) return;
@@ -2686,13 +3096,6 @@ function DataTable(_props) {
2686
3096
  }
2687
3097
  applyGridToRange(grid, r0, c0);
2688
3098
  }
2689
- function tileIndex(i, lo, hi) {
2690
- const span = hi - lo + 1;
2691
- if (span <= 1) return lo;
2692
- let k = (i - lo) % span;
2693
- if (k < 0) k = k + span;
2694
- return lo + k;
2695
- }
2696
3099
  function fillRange(sourceBox, endCell) {
2697
3100
  let box;
2698
3101
  if (sourceBox && sourceBox.r0 != null && endCell) {
@@ -2732,6 +3135,30 @@ function DataTable(_props) {
2732
3135
  let fillDragging = false;
2733
3136
  let fillDragMove = null;
2734
3137
  let fillDragUp = null;
3138
+ let fillEdgeScrollRaf = null;
3139
+ const FILL_EDGE_SCROLL_PX = 24;
3140
+ const FILL_EDGE_SCROLL_STEP = 16;
3141
+ function edgeDelta(clientX, clientY) {
3142
+ if (!gridScrollEl) return {
3143
+ dx: 0,
3144
+ dy: 0
3145
+ };
3146
+ const rect = gridScrollEl.getBoundingClientRect();
3147
+ let dx = 0;
3148
+ let dy = 0;
3149
+ if (colsWindowed()) {
3150
+ if (clientX - rect.left < FILL_EDGE_SCROLL_PX) dx = -FILL_EDGE_SCROLL_STEP;
3151
+ else if (rect.right - clientX < FILL_EDGE_SCROLL_PX) dx = FILL_EDGE_SCROLL_STEP;
3152
+ }
3153
+ if (rowsWindowed()) {
3154
+ if (clientY - rect.top < FILL_EDGE_SCROLL_PX) dy = -FILL_EDGE_SCROLL_STEP;
3155
+ else if (rect.bottom - clientY < FILL_EDGE_SCROLL_PX) dy = FILL_EDGE_SCROLL_STEP;
3156
+ }
3157
+ return {
3158
+ dx,
3159
+ dy
3160
+ };
3161
+ }
2735
3162
  function teardownFillDrag() {
2736
3163
  if (typeof document !== "undefined") {
2737
3164
  if (fillDragMove) document.removeEventListener("pointermove", fillDragMove);
@@ -2740,6 +3167,10 @@ function DataTable(_props) {
2740
3167
  fillDragMove = null;
2741
3168
  fillDragUp = null;
2742
3169
  fillDragging = false;
3170
+ if (fillEdgeScrollRaf != null) {
3171
+ if (typeof cancelAnimationFrame === "function") cancelAnimationFrame(fillEdgeScrollRaf);
3172
+ fillEdgeScrollRaf = null;
3173
+ }
2743
3174
  }
2744
3175
  function cellIndexFromPoint(clientX, clientY) {
2745
3176
  if (typeof document === "undefined" || !document.elementFromPoint) return null;
@@ -2774,14 +3205,42 @@ function DataTable(_props) {
2774
3205
  r: sourceBox.r1,
2775
3206
  c: sourceBox.c1
2776
3207
  } : null;
2777
- const move = (ev) => {
2778
- if (!fillDragging) return;
2779
- const cell = cellIndexFromPoint(ev.clientX, ev.clientY);
3208
+ let lastClientX = 0;
3209
+ let lastClientY = 0;
3210
+ const applyPointAt = (clientX, clientY) => {
3211
+ const cell = cellIndexFromPoint(clientX, clientY);
2780
3212
  if (cell && (!lastCell || cell.r !== lastCell.r || cell.c !== lastCell.c)) {
2781
3213
  lastCell = cell;
2782
3214
  setRangeFocus$local(cell.r, cell.c);
2783
3215
  }
2784
3216
  };
3217
+ const scrollStep = () => {
3218
+ if (!fillDragging) {
3219
+ fillEdgeScrollRaf = null;
3220
+ return;
3221
+ }
3222
+ const d = edgeDelta(lastClientX, lastClientY);
3223
+ if (d.dx === 0 && d.dy === 0) {
3224
+ fillEdgeScrollRaf = null;
3225
+ return;
3226
+ }
3227
+ if (gridScrollEl) {
3228
+ if (d.dx !== 0) gridScrollEl.scrollLeft = gridScrollEl.scrollLeft + d.dx;
3229
+ if (d.dy !== 0) gridScrollEl.scrollTop = gridScrollEl.scrollTop + d.dy;
3230
+ }
3231
+ applyPointAt(lastClientX, lastClientY);
3232
+ fillEdgeScrollRaf = requestAnimationFrame(scrollStep);
3233
+ };
3234
+ const move = (ev) => {
3235
+ if (!fillDragging) return;
3236
+ lastClientX = ev.clientX;
3237
+ lastClientY = ev.clientY;
3238
+ applyPointAt(ev.clientX, ev.clientY);
3239
+ if (fillEdgeScrollRaf == null && typeof requestAnimationFrame === "function") {
3240
+ const d = edgeDelta(ev.clientX, ev.clientY);
3241
+ if (d.dx !== 0 || d.dy !== 0) fillEdgeScrollRaf = requestAnimationFrame(scrollStep);
3242
+ }
3243
+ };
2785
3244
  const up = () => {
2786
3245
  teardownFillDrag();
2787
3246
  if (lastCell && sourceBox && (lastCell.r !== sourceBox.r1 || lastCell.c !== sourceBox.c1)) fillRange(sourceBox, lastCell);
@@ -2841,11 +3300,13 @@ function DataTable(_props) {
2841
3300
  return cell && cell.column ? cell.column.id : null;
2842
3301
  }
2843
3302
  function isActiveCellEditable() {
3303
+ if (rowIndexIsGrouped(activeRow())) return false;
2844
3304
  const colId = activeCellColumnId();
2845
3305
  return colId != null && columnEditable(colId);
2846
3306
  }
2847
3307
  function isEditing(rowIndex, colIndex) {
2848
3308
  if (editVer() < 0) return false;
3309
+ if (rowIndexIsGrouped(rowIndex)) return false;
2849
3310
  if (editingRowIndex() != null && editingRowIndex() === rowIndex) {
2850
3311
  const colId = columnIdAt(rowIndex, colIndex);
2851
3312
  return colId != null && columnEditable(colId);
@@ -2872,16 +3333,6 @@ function DataTable(_props) {
2872
3333
  function setInvalid(msg) {
2873
3334
  setInvalidMsg(msg != null ? msg : "");
2874
3335
  }
2875
- function replaceRowValue(rows, rowIndex, field, value) {
2876
- const src = rows || [];
2877
- const out = [];
2878
- for (let i = 0; i < src.length; i++) if (i === rowIndex) out.push({
2879
- ...src[i] || {},
2880
- [field]: value
2881
- });
2882
- else out.push(src[i]);
2883
- return out;
2884
- }
2885
3336
  function sourceIndexOfRow(visibleRowIndex) {
2886
3337
  const row = (rows() || [])[visibleRowIndex];
2887
3338
  if (!row) return visibleRowIndex;
@@ -2957,6 +3408,7 @@ function DataTable(_props) {
2957
3408
  return cell ? cell.getValue() : null;
2958
3409
  }
2959
3410
  function beginEdit(rowIndex, colIndex, seed) {
3411
+ if (rowIndexIsGrouped(rowIndex)) return;
2960
3412
  const colId = columnIdAt(rowIndex, colIndex);
2961
3413
  if (colId == null || !columnEditable(colId)) return;
2962
3414
  committedThisSession = false;
@@ -2988,16 +3440,6 @@ function DataTable(_props) {
2988
3440
  if (typeof requestAnimationFrame === "function") requestAnimationFrame(tryFocus);
2989
3441
  else setTimeout(tryFocus, 0);
2990
3442
  }
2991
- function indexOfRowIn(rows, rowOriginal, rowId) {
2992
- const list = rows || [];
2993
- for (let i = 0; i < list.length; i++) {
2994
- const r = list[i];
2995
- if (!r) continue;
2996
- if (rowId != null && r.id === rowId) return i;
2997
- if (rowOriginal != null && r.original === rowOriginal) return i;
2998
- }
2999
- return -1;
3000
- }
3001
3443
  function endEdit() {
3002
3444
  setEditingRow(-1);
3003
3445
  setEditingCol(-1);
@@ -3078,6 +3520,7 @@ function DataTable(_props) {
3078
3520
  return true;
3079
3521
  }
3080
3522
  function toggleActiveBooleanCell() {
3523
+ if (rowIndexIsGrouped(activeRow())) return;
3081
3524
  const colId = columnIdAt(activeRow(), activeColIndex());
3082
3525
  if (colId == null || !columnEditable(colId)) return;
3083
3526
  const row = (rows() || [])[activeRow()];
@@ -3163,6 +3606,7 @@ function DataTable(_props) {
3163
3606
  function beginRowEdit(row) {
3164
3607
  const rowIndex = rowIndexOf(row);
3165
3608
  if (rowIndex < 0) return;
3609
+ if (rowIndexIsGrouped(rowIndex)) return;
3166
3610
  const editable = editableColumnsForRow(rowIndex);
3167
3611
  if (editable.length === 0) return;
3168
3612
  committedThisSession = false;
@@ -3252,17 +3696,6 @@ function DataTable(_props) {
3252
3696
  editTransition = false;
3253
3697
  focusCellWhenReady(focusRow, focusCol);
3254
3698
  }
3255
- function replaceRowValues(rows, rowIndex, fieldValues) {
3256
- const src = rows || [];
3257
- const fv = fieldValues || {};
3258
- const out = [];
3259
- for (let i = 0; i < src.length; i++) if (i === rowIndex) out.push({
3260
- ...src[i] || {},
3261
- ...fv
3262
- });
3263
- else out.push(src[i]);
3264
- return out;
3265
- }
3266
3699
  function nextEditableCell(fromRow, fromCol) {
3267
3700
  const rowList = rows() || [];
3268
3701
  const rowCount = rowList.length;
@@ -3513,8 +3946,9 @@ function DataTable(_props) {
3513
3946
  const absLast = prePaginationRowCount() - 1;
3514
3947
  const absRow = clamp(Math.trunc(Number(rowIndex)) || 0, 0, absLast < 0 ? 0 : absLast);
3515
3948
  const prevAbs = toAbsRow(activeRow());
3949
+ const prevCol = activeColIndex();
3516
3950
  const prevIsHeader = activeIsHeader();
3517
- if (local.virtual) {
3951
+ if (rowsWindowed()) {
3518
3952
  setActiveIsHeader(false);
3519
3953
  setActiveInControl(false);
3520
3954
  setActiveRow(absRow);
@@ -3533,7 +3967,7 @@ function DataTable(_props) {
3533
3967
  if (switched) focusAbsCellWhenReady(absRow, localRow, c);
3534
3968
  else focusActiveCell(localRow, c, false);
3535
3969
  }
3536
- if (absRow !== prevAbs || prevIsHeader) _props.onActivecellChange?.({
3970
+ if (absRow !== prevAbs || c !== prevCol || prevIsHeader) _props.onActivecellChange?.({
3537
3971
  rowIndex: absRow,
3538
3972
  colIndex: c
3539
3973
  });
@@ -3649,7 +4083,7 @@ function DataTable(_props) {
3649
4083
  applyGrouping,
3650
4084
  clearGrouping
3651
4085
  }) ?? <Key each={groupingKeys()} by={(gk) => gk}>{(gk) => <span class={"rdt-group-token"} data-group-token="" data-rozie-s-d5dcab4c="">{rozieDisplay(gk())}</span>}</Key>}
3652
- </div></Show>}{<Show when={local.virtual} fallback={<table aria-rowcount={rozieAttr(gridAriaRowCount())} class={"rozie-data-table " + rozieClass({ "rdt-sticky": local.stickyHeader })} role={rozieAttr(tableRole())} onKeyDown={($event) => {
4086
+ </div></Show>}{<Show when={isWindowed()} fallback={<table aria-rowcount={rozieAttr(gridAriaRowCount())} class={"rozie-data-table " + rozieClass({ "rdt-sticky": local.stickyHeader })} role={rozieAttr(tableRole())} onKeyDown={($event) => {
3653
4087
  onGridKeyDown($event);
3654
4088
  }} onFocusIn={($event) => {
3655
4089
  syncActiveFromEvent($event);
@@ -3761,7 +4195,7 @@ function DataTable(_props) {
3761
4195
  {(_props.cellSlot ?? _props.slots?.["cell"])?.({
3762
4196
  columnId: cell().column.id,
3763
4197
  column: cell().column,
3764
- row: row().original,
4198
+ row: cellSlotRow(row()),
3765
4199
  value: cell().getValue()
3766
4200
  }) ?? rozieDisplay(cell().getValue())}
3767
4201
  </span>}><span style={{ display: "contents" }} data-rozie-s-d5dcab4c="" /></Show>}><span style={{ display: "contents" }} data-rozie-s-d5dcab4c="">
@@ -3795,7 +4229,7 @@ function DataTable(_props) {
3795
4229
  {(_props.editorSlot ?? _props.slots?.["editor"])?.({
3796
4230
  columnId: cell().column.id,
3797
4231
  column: cell().column,
3798
- row: row().original,
4232
+ row: cellSlotRow(row()),
3799
4233
  value: editorValueFor(cell().column.id),
3800
4234
  commit: editorCommitFor(cell().column.id),
3801
4235
  cancel: editorCancelFor(),
@@ -3809,14 +4243,14 @@ function DataTable(_props) {
3809
4243
  {(_props.cellSlot ?? _props.slots?.["cell"])?.({
3810
4244
  columnId: cell().column.id,
3811
4245
  column: cell().column,
3812
- row: row().original,
4246
+ row: cellSlotRow(row()),
3813
4247
  value: cell().getValue()
3814
4248
  }) ?? rozieDisplay(cell().getValue())}
3815
4249
  </span>
3816
4250
  <span class={"rdt-group-count"} data-rozie-s-d5dcab4c="">{rozieDisplay("(" + groupSubRowCount(row()) + ")")}</span>
3817
4251
  </span></Show>}><span style={{ display: "contents" }} data-rozie-s-d5dcab4c="">
3818
4252
  {(_props.selectCellSlot ?? _props.slots?.["selectCell"])?.({
3819
- row: row().original,
4253
+ row: cellSlotRow(row()),
3820
4254
  checked: rowIsSelected(row()),
3821
4255
  toggle: (e) => onToggleRow(row(), e)
3822
4256
  }) ?? <input type="checkbox" aria-label="Select row" class={"rdt-select-row"} checked={rowIsSelected(row())} onChange={($event) => {
@@ -3836,8 +4270,11 @@ function DataTable(_props) {
3836
4270
  </td>
3837
4271
  </tr></Show>}</>}</Key>
3838
4272
  </tbody>
3839
- </table>}><div class={"rdt-scroll"} style={parseInlineStyle(local.maxHeight ? "max-height:" + local.maxHeight + ";overflow:auto;--rozie-data-table-max-height:" + local.maxHeight : "overflow:auto")} data-rozie-s-d5dcab4c="">
3840
- <table aria-rowcount={rozieAttr(gridAriaRowCount())} class={"rozie-data-table " + rozieClass({ "rdt-sticky": local.stickyHeader })} role={rozieAttr(tableRole())} onKeyDown={($event) => {
4273
+ </table>}><div class={"rdt-scroll"} style={parseInlineStyle(rowsWindowed() && local.maxHeight ? "max-height:" + local.maxHeight + ";overflow:auto;--rozie-data-table-max-height:" + local.maxHeight : "overflow:auto")} data-rozie-s-d5dcab4c="">
4274
+ <table aria-rowcount={rozieAttr(gridAriaRowCount())} class={"rozie-data-table " + rozieClass({
4275
+ "rdt-sticky": local.stickyHeader,
4276
+ "rdt-col-windowed": colsWindowed()
4277
+ })} role={rozieAttr(tableRole())} onKeyDown={($event) => {
3841
4278
  onGridKeyDown($event);
3842
4279
  }} onFocusIn={($event) => {
3843
4280
  syncActiveFromEvent($event);
@@ -3852,53 +4289,54 @@ function DataTable(_props) {
3852
4289
  }} data-rozie-s-d5dcab4c="">
3853
4290
  <thead class={"rdt-thead"} role="rowgroup" data-rozie-s-d5dcab4c="">
3854
4291
  <Key each={headerGroups()} by={(hg) => hg.id}>{(hg, hgLevel) => <tr class={"rdt-tr"} role="row" aria-rowindex={rozieAttr(hgLevel() + 1)} data-rozie-s-d5dcab4c="">
3855
- <Key each={hg().headers} by={(header) => header.id}>{(header) => <th class={"rdt-th " + rozieClass({
3856
- "rdt-select-th": isSelectColumn(header().column.id),
3857
- "rdt-expander-th": isExpanderColumn(header().column.id),
3858
- "rdt-th-resizing": columnIsResizing(header().column.id),
3859
- "rdt-cell-active": isActiveCell("__header", headerColIndexOf(hg(), header()), hgLevel())
3860
- })} role="columnheader" data-col={rozieAttr(header().column.id)} data-grid-cell="" data-row="__header" data-header-level={rozieAttr(hgLevel())} colSpan={rozieAttr(header().colSpan > 1 ? header().colSpan : null)} data-col-index={rozieAttr(headerColIndexOf(hg(), header()))} tabIndex={rozieAttr(cellTabindex("__header", headerColIndexOf(hg(), header()), hgLevel()))} aria-sort={rozieAttr(ariaSortFor(header().column.id))} style={parseInlineStyle(thStyle(header().column.id))} data-rozie-s-d5dcab4c="">
3861
- {<Show when={isSelectColumn(header().column.id)} fallback={<Show when={isExpanderColumn(header().column.id)} fallback={<span style={{ display: "contents" }} data-rozie-s-d5dcab4c="">
3862
- {<Show when={header().column.getCanSort && header().column.getCanSort()} fallback={<span style={{ display: "contents" }} data-rozie-s-d5dcab4c="">
4292
+
4293
+ {<Show when={colsWindowed()}><th class={"rdt-col-spacer"} aria-hidden="true" style={parseInlineStyle("width:" + colPadLeft() + "px;padding:0;border:0")} data-rozie-s-d5dcab4c="" /></Show>}<Key each={windowedHeadersFor(hg(), hgLevel())} by={(wh) => wh.header.id}>{(wh) => <th class={"rdt-th " + rozieClass({
4294
+ "rdt-select-th": isSelectColumn(wh().header.column.id),
4295
+ "rdt-expander-th": isExpanderColumn(wh().header.column.id),
4296
+ "rdt-th-resizing": columnIsResizing(wh().header.column.id),
4297
+ "rdt-cell-active": isActiveCell("__header", headerColIndexOf(hg(), wh().header), hgLevel())
4298
+ })} 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(headerColIndexOf(hg(), wh().header))} tabIndex={rozieAttr(cellTabindex("__header", headerColIndexOf(hg(), wh().header), hgLevel()))} aria-sort={rozieAttr(ariaSortFor(wh().header.column.id))} style={parseInlineStyle(thStyle(wh().header.column.id))} data-rozie-s-d5dcab4c="">
4299
+ {<Show when={isSelectColumn(wh().header.column.id)} fallback={<Show when={isExpanderColumn(wh().header.column.id)} fallback={<span style={{ display: "contents" }} data-rozie-s-d5dcab4c="">
4300
+ {<Show when={wh().header.column.getCanSort && wh().header.column.getCanSort()} fallback={<span style={{ display: "contents" }} data-rozie-s-d5dcab4c="">
3863
4301
  <span class={"rdt-header-label"} data-rozie-s-d5dcab4c="">
3864
4302
  {(_props.colHeaderSlot ?? _props.slots?.["colHeader"])?.({
3865
- columnId: header().column.id,
3866
- column: header().column,
3867
- label: headerLabel(header().column.id)
3868
- }) ?? rozieDisplay(headerLabel(header().column.id))}
4303
+ columnId: wh().header.column.id,
4304
+ column: wh().header.column,
4305
+ label: headerLabel(wh().header.column.id)
4306
+ }) ?? rozieDisplay(headerLabel(wh().header.column.id))}
3869
4307
  </span>
3870
4308
  </span>}><button type="button" class={"rdt-sort-btn"} onClick={($event) => {
3871
- onHeaderSort(header().column.id, $event);
4309
+ onHeaderSort(wh().header.column.id, $event);
3872
4310
  }} data-rozie-s-d5dcab4c="">
3873
4311
  <span class={"rdt-header-label"} data-rozie-s-d5dcab4c="">
3874
4312
  {(_props.colHeaderSlot ?? _props.slots?.["colHeader"])?.({
3875
- columnId: header().column.id,
3876
- column: header().column,
3877
- label: headerLabel(header().column.id)
3878
- }) ?? rozieDisplay(headerLabel(header().column.id))}
4313
+ columnId: wh().header.column.id,
4314
+ column: wh().header.column,
4315
+ label: headerLabel(wh().header.column.id)
4316
+ }) ?? rozieDisplay(headerLabel(wh().header.column.id))}
3879
4317
  </span>
3880
- <span class={"rdt-sort-ind"} aria-hidden="true" data-rozie-s-d5dcab4c="">{rozieDisplay(sortIndicator(header().column.id))}</span>
4318
+ <span class={"rdt-sort-ind"} aria-hidden="true" data-rozie-s-d5dcab4c="">{rozieDisplay(sortIndicator(wh().header.column.id))}</span>
3881
4319
  </button></Show>}<Popover trigger="click" placement="bottom-end" strategy="fixed" offset={4} data-rozie-s-d5dcab4c="" anchorSlot={() => <>
3882
- <button type="button" class={"rdt-col-menu-trigger"} aria-label={rozieAttr("Column options for " + headerLabel(header().column.id))} data-rozie-s-d5dcab4c="">⋯</button>
4320
+ <button type="button" class={"rdt-col-menu-trigger"} aria-label={rozieAttr("Column options for " + headerLabel(wh().header.column.id))} data-rozie-s-d5dcab4c="">⋯</button>
3883
4321
  </>}><div class={"rdt-col-menu"} role="menu" data-rozie-s-d5dcab4c="">
3884
- <button type="button" role="menuitem" aria-pressed={columnPinSide(header().column.id) === "left"} class={"rdt-col-menu-item"} onClick={($event) => {
3885
- onPinColumn(header().column.id, "left", $event);
4322
+ <button type="button" role="menuitem" aria-pressed={columnPinSide(wh().header.column.id) === "left"} class={"rdt-col-menu-item"} onClick={($event) => {
4323
+ onPinColumn(wh().header.column.id, "left", $event);
3886
4324
  }} data-rozie-s-d5dcab4c="">Pin left</button>
3887
- <button type="button" role="menuitem" aria-pressed={columnPinSide(header().column.id) === "right"} class={"rdt-col-menu-item"} onClick={($event) => {
3888
- onPinColumn(header().column.id, "right", $event);
4325
+ <button type="button" role="menuitem" aria-pressed={columnPinSide(wh().header.column.id) === "right"} class={"rdt-col-menu-item"} onClick={($event) => {
4326
+ onPinColumn(wh().header.column.id, "right", $event);
3889
4327
  }} data-rozie-s-d5dcab4c="">Pin right</button>
3890
- <button type="button" role="menuitem" aria-pressed={!columnPinSide(header().column.id)} class={"rdt-col-menu-item"} onClick={($event) => {
3891
- onPinColumn(header().column.id, false, $event);
4328
+ <button type="button" role="menuitem" aria-pressed={!columnPinSide(wh().header.column.id)} class={"rdt-col-menu-item"} onClick={($event) => {
4329
+ onPinColumn(wh().header.column.id, false, $event);
3892
4330
  }} data-rozie-s-d5dcab4c="">Unpin</button>
3893
4331
  <hr class={"rdt-col-menu-sep"} data-rozie-s-d5dcab4c="" />
3894
4332
  <button type="button" role="menuitem" class={"rdt-col-menu-item"} onClick={($event) => {
3895
- onHideColumn(header().column.id, $event);
4333
+ onHideColumn(wh().header.column.id, $event);
3896
4334
  }} data-rozie-s-d5dcab4c="">Hide column</button>
3897
4335
  </div></Popover>
3898
- <button type="button" aria-label={rozieAttr("Resize " + headerLabel(header().column.id))} class={"rdt-resize-handle"} onPointerDown={($event) => {
3899
- onResizeStart(header().column.id, $event);
4336
+ <button type="button" aria-label={rozieAttr("Resize " + headerLabel(wh().header.column.id))} class={"rdt-resize-handle"} onPointerDown={($event) => {
4337
+ onResizeStart(wh().header.column.id, $event);
3900
4338
  }} onTouchStart={($event) => {
3901
- onResizeStart(header().column.id, $event);
4339
+ onResizeStart(wh().header.column.id, $event);
3902
4340
  }} data-rozie-s-d5dcab4c=""><span class={"rdt-resize-grip"} aria-hidden="true" data-rozie-s-d5dcab4c="" /></button>
3903
4341
  </span>}><span style={{ display: "contents" }} data-rozie-s-d5dcab4c="" /></Show>}><span style={{ display: "contents" }} data-rozie-s-d5dcab4c="">
3904
4342
  {(_props.selectAllSlot ?? _props.slots?.["selectAll"])?.({
@@ -3909,30 +4347,31 @@ function DataTable(_props) {
3909
4347
  onToggleAllRows($event);
3910
4348
  }} data-rozie-s-d5dcab4c="" /></Show>}
3911
4349
  </span></Show>}</th>}</Key>
3912
- </tr>}</Key>
4350
+
4351
+ {<Show when={colsWindowed()}><th class={"rdt-col-spacer"} aria-hidden="true" style={parseInlineStyle("width:" + colPadRight() + "px;padding:0;border:0")} data-rozie-s-d5dcab4c="" /></Show>}</tr>}</Key>
3913
4352
 
3914
4353
  {<Show when={hasAnyFilterableColumn()}><tr class={"rdt-filter-row"} data-rozie-s-d5dcab4c="">
3915
- <Key each={headerGroups()[headerGroups().length - 1].headers} by={(header) => header.id}>{(header) => <th class={"rdt-filter-cell"} role="presentation" style={parseInlineStyle(pinStyle(header().column.id))} data-rozie-s-d5dcab4c="">
3916
- {<Show when={isSelectColumn(header().column.id)} fallback={<Show when={isExpanderColumn(header().column.id)} fallback={<span style={{ display: "contents" }} data-rozie-s-d5dcab4c="">
3917
- {<Show when={columnIsFilterable(header().column.id) && !hasFilterSlot()}><input type="text" aria-label={rozieAttr("Filter " + headerLabel(header().column.id))} class={"rdt-col-filter"} value={columnFilterValue(header().column.id)} onInput={($event) => {
3918
- onColumnFilterInput(header().column.id, $event);
4354
+ {<Show when={colsWindowed()}><th class={"rdt-col-spacer"} aria-hidden="true" style={parseInlineStyle("width:" + colPadLeft() + "px;padding:0;border:0")} data-rozie-s-d5dcab4c="" /></Show>}<Key each={windowedHeadersFor(headerGroups()[headerGroups().length - 1], headerGroups().length - 1)} by={(wh) => wh.header.id}>{(wh) => <th class={"rdt-filter-cell"} role="presentation" data-col={rozieAttr(wh().header.column.id)} style={parseInlineStyle(pinStyle(wh().header.column.id))} data-rozie-s-d5dcab4c="">
4355
+ {<Show when={isSelectColumn(wh().header.column.id)} fallback={<Show when={isExpanderColumn(wh().header.column.id)} fallback={<span style={{ display: "contents" }} data-rozie-s-d5dcab4c="">
4356
+ {<Show when={columnIsFilterable(wh().header.column.id) && !hasFilterSlot()}><input type="text" aria-label={rozieAttr("Filter " + headerLabel(wh().header.column.id))} class={"rdt-col-filter"} value={columnFilterValue(wh().header.column.id)} onInput={($event) => {
4357
+ onColumnFilterInput(wh().header.column.id, $event);
3919
4358
  }} onClick={($event) => {
3920
4359
  stopEvent($event);
3921
- }} data-rozie-s-d5dcab4c="" /></Show>}{<Show when={columnIsFilterable(header().column.id)}><span style={{ display: "contents" }} data-rozie-s-d5dcab4c="">
4360
+ }} data-rozie-s-d5dcab4c="" /></Show>}{<Show when={columnIsFilterable(wh().header.column.id)}><span style={{ display: "contents" }} data-rozie-s-d5dcab4c="">
3922
4361
  {(_props.filterSlot ?? _props.slots?.["filter"])?.({
3923
- columnId: header().column.id,
3924
- value: columnFilterValue(header().column.id),
3925
- uniqueValues: getFacetedUniqueValues$1(header().column.id),
3926
- minMax: getFacetedMinMaxValues$1(header().column.id),
4362
+ columnId: wh().header.column.id,
4363
+ value: columnFilterValue(wh().header.column.id),
4364
+ uniqueValues: getFacetedUniqueValues$1(wh().header.column.id),
4365
+ minMax: getFacetedMinMaxValues$1(wh().header.column.id),
3927
4366
  setFilter: setColumnFilter
3928
4367
  })}
3929
4368
  </span></Show>}</span>}><span style={{ display: "contents" }} data-rozie-s-d5dcab4c="" /></Show>}><span style={{ display: "contents" }} data-rozie-s-d5dcab4c="" /></Show>}</th>}</Key>
3930
- </tr></Show>}</thead>
4369
+ {<Show when={colsWindowed()}><th class={"rdt-col-spacer"} aria-hidden="true" style={parseInlineStyle("width:" + colPadRight() + "px;padding:0;border:0")} data-rozie-s-d5dcab4c="" /></Show>}</tr></Show>}</thead>
3931
4370
 
3932
4371
  <tbody class={"rdt-tbody"} role="rowgroup" data-rozie-s-d5dcab4c="">
3933
4372
 
3934
4373
  <tr class={"rdt-spacer"} aria-hidden="true" data-rozie-s-d5dcab4c="">
3935
- <td colSpan={rozieAttr(visibleColCount())} style={parseInlineStyle("height:" + padTop() + "px;padding:0;border:0")} data-rozie-s-d5dcab4c="" />
4374
+ <td colSpan={rozieAttr(windowedColSpan())} style={parseInlineStyle("height:" + padTop() + "px;padding:0;border:0")} data-rozie-s-d5dcab4c="" />
3936
4375
  </tr>
3937
4376
 
3938
4377
  <Key each={windowedRows()} by={(wr) => wr.row.id}>{(wr) => <>
@@ -3940,7 +4379,8 @@ function DataTable(_props) {
3940
4379
  "rdt-group-header": rowIsGrouped(wr().row),
3941
4380
  "rdt-row-pinned": wr().pinned
3942
4381
  })} role="row" data-row={rozieAttr(wr().vi.index)} aria-rowindex={rozieAttr(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(rowIsGrouped(wr().row) ? wr().row.id : null)} data-group-leaf={rozieAttr(groupingActive() && !rowIsGrouped(wr().row) ? wr().row.id : null)} aria-expanded={(rowIsGrouped(wr().row) ? !!rowIsExpanded(wr().row) : null) ?? void 0} aria-selected={(local.selectionMode !== "none" ? !!rowIsSelected(wr().row) : null) ?? void 0} aria-level={rozieAttr(groupingActive() ? wr().row.depth + 1 : null)} data-rozie-s-d5dcab4c="">
3943
- <Key each={visibleCellsFor(wr().row)} by={(cell) => cell.id}>{(cell) => <td class={"rdt-td " + rozieClass({
4382
+
4383
+ {<Show when={colsWindowed()}><td class={"rdt-col-spacer"} aria-hidden="true" style={parseInlineStyle("width:" + colPadLeft() + "px;padding:0;border:0")} data-rozie-s-d5dcab4c="" /></Show>}<Key each={windowedCells(wr().row)} by={(cell) => cell.id}>{(cell) => <td class={"rdt-td " + rozieClass({
3944
4384
  "rdt-select-td": isSelectColumn(cell().column.id),
3945
4385
  "rdt-expander-td": isExpanderColumn(cell().column.id),
3946
4386
  "rdt-in-range": inRange(wr().vi.index, colIndexOf(wr().row, cell())),
@@ -3951,7 +4391,7 @@ function DataTable(_props) {
3951
4391
  {(_props.cellSlot ?? _props.slots?.["cell"])?.({
3952
4392
  columnId: cell().column.id,
3953
4393
  column: cell().column,
3954
- row: wr().row.original,
4394
+ row: cellSlotRow(wr().row),
3955
4395
  value: cell().getValue()
3956
4396
  }) ?? rozieDisplay(cell().getValue())}
3957
4397
  </span>}><span style={{ display: "contents" }} data-rozie-s-d5dcab4c="" /></Show>}><span style={{ display: "contents" }} data-rozie-s-d5dcab4c="">
@@ -3985,7 +4425,7 @@ function DataTable(_props) {
3985
4425
  {(_props.editorSlot ?? _props.slots?.["editor"])?.({
3986
4426
  columnId: cell().column.id,
3987
4427
  column: cell().column,
3988
- row: wr().row.original,
4428
+ row: cellSlotRow(wr().row),
3989
4429
  value: editorValueFor(cell().column.id),
3990
4430
  commit: editorCommitFor(cell().column.id),
3991
4431
  cancel: editorCancelFor(),
@@ -3999,14 +4439,14 @@ function DataTable(_props) {
3999
4439
  {(_props.cellSlot ?? _props.slots?.["cell"])?.({
4000
4440
  columnId: cell().column.id,
4001
4441
  column: cell().column,
4002
- row: wr().row.original,
4442
+ row: cellSlotRow(wr().row),
4003
4443
  value: cell().getValue()
4004
4444
  }) ?? rozieDisplay(cell().getValue())}
4005
4445
  </span>
4006
4446
  <span class={"rdt-group-count"} data-rozie-s-d5dcab4c="">{rozieDisplay("(" + groupSubRowCount(wr().row) + ")")}</span>
4007
4447
  </span></Show>}><span style={{ display: "contents" }} data-rozie-s-d5dcab4c="">
4008
4448
  {(_props.selectCellSlot ?? _props.slots?.["selectCell"])?.({
4009
- row: wr().row.original,
4449
+ row: cellSlotRow(wr().row),
4010
4450
  checked: rowIsSelected(wr().row),
4011
4451
  toggle: (e) => onToggleRow(wr().row, e)
4012
4452
  }) ?? <input type="checkbox" aria-label="Select row" class={"rdt-select-row"} checked={rowIsSelected(wr().row)} onChange={($event) => {
@@ -4018,20 +4458,21 @@ function DataTable(_props) {
4018
4458
  }} data-rozie-s-d5dcab4c="">{rozieDisplay(rowIsExpanded(wr().row) ? "▾" : "▸")}</button></Show>}</span></Show>}{<Show when={isFillHandleCell(wr().vi.index, colIndexOf(wr().row, cell()))}><span data-fill-handle="" data-testid="fill-handle" aria-hidden="true" class={"rdt-fill-handle"} onPointerDown={($event) => {
4019
4459
  onFillHandlePointerDown($event);
4020
4460
  }} data-rozie-s-d5dcab4c="" /></Show>}</td>}</Key>
4021
- </tr>
4461
+
4462
+ {<Show when={colsWindowed()}><td class={"rdt-col-spacer"} aria-hidden="true" style={parseInlineStyle("width:" + colPadRight() + "px;padding:0;border:0")} data-rozie-s-d5dcab4c="" /></Show>}</tr>
4022
4463
 
4023
4464
  {<Show when={rowShowsDetail(wr().row)}><tr class={"rdt-detail-row"} role="row" data-detail-row={rozieAttr(wr().row.id)} data-rozie-s-d5dcab4c="">
4024
- <td class={"rdt-detail-cell"} colSpan={rozieAttr(visibleColCount())} data-rozie-s-d5dcab4c="">
4465
+ <td class={"rdt-detail-cell"} colSpan={rozieAttr(windowedColSpan())} data-rozie-s-d5dcab4c="">
4025
4466
  {(_props.detailSlot ?? _props.slots?.["detail"])?.({ row: wr().row.original })}
4026
4467
  </td>
4027
4468
  </tr></Show>}</>}</Key>
4028
4469
 
4029
4470
  <tr class={"rdt-spacer"} aria-hidden="true" data-rozie-s-d5dcab4c="">
4030
- <td colSpan={rozieAttr(visibleColCount())} style={parseInlineStyle("height:" + padBottom() + "px;padding:0;border:0")} data-rozie-s-d5dcab4c="" />
4471
+ <td colSpan={rozieAttr(windowedColSpan())} style={parseInlineStyle("height:" + padBottom() + "px;padding:0;border:0")} data-rozie-s-d5dcab4c="" />
4031
4472
  </tr>
4032
4473
  </tbody>
4033
4474
  </table>
4034
- </div></Show>}{<Show when={!local.virtual}><div class={"rdt-pagination"} role="group" aria-label="Pagination" data-rozie-s-d5dcab4c="">
4475
+ </div></Show>}{<Show when={!rowsWindowed()}><div class={"rdt-pagination"} role="group" aria-label="Pagination" data-rozie-s-d5dcab4c="">
4035
4476
  <button type="button" class={"rdt-page-btn rdt-page-prev"} disabled={!canPrevPage()} onClick={($event) => {
4036
4477
  onPrevPage();
4037
4478
  }} data-rozie-s-d5dcab4c="">Prev</button>