@pretable/core 0.7.0 → 0.9.0
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.cjs +313 -16
- package/dist/index.d.cts +209 -1
- package/dist/index.d.ts +209 -1
- package/dist/index.mjs +313 -17
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -915,6 +915,72 @@ function isIndexedRowSelected(selection, ref, snapshot) {
|
|
|
915
915
|
return false;
|
|
916
916
|
return semanticRowSelected(rowSelectionProgram(selection, snapshot), ref.rowId);
|
|
917
917
|
}
|
|
918
|
+
function createIndexedRowSelection(requested, snapshot) {
|
|
919
|
+
let selection = createEmptyIndexedSelection();
|
|
920
|
+
if (requested.kind === "all") {
|
|
921
|
+
selection = selectAllVisibleRows(selection, snapshot);
|
|
922
|
+
} else {
|
|
923
|
+
for (const rowId of new Set(requested.rowIds)) {
|
|
924
|
+
selection = toggleIndexedRowSelection(selection, rowId, snapshot);
|
|
925
|
+
}
|
|
926
|
+
for (const range of requested.ranges ?? []) {
|
|
927
|
+
selection = selectIndexedRowRange(selection, range.startRowId, range.endRowId, snapshot);
|
|
928
|
+
}
|
|
929
|
+
}
|
|
930
|
+
for (const rowId of new Set(requested.excludedRowIds)) {
|
|
931
|
+
if (!isIndexedRowSelected(selection, dataRef(rowId), snapshot))
|
|
932
|
+
continue;
|
|
933
|
+
selection = toggleIndexedRowSelection(selection, rowId, snapshot);
|
|
934
|
+
}
|
|
935
|
+
return selection.rows;
|
|
936
|
+
}
|
|
937
|
+
function describeRowSelection(rows) {
|
|
938
|
+
const excluded = /* @__PURE__ */ new Set();
|
|
939
|
+
for (const range of rows.excludedRanges ?? []) {
|
|
940
|
+
excluded.add(range.startRowId);
|
|
941
|
+
excluded.add(range.endRowId);
|
|
942
|
+
}
|
|
943
|
+
const excludedRowIds = excluded.size === 0 ? {} : { excludedRowIds: Object.freeze([...excluded]) };
|
|
944
|
+
if (rows.kind === "all") {
|
|
945
|
+
return Object.freeze({ kind: "all", ...excludedRowIds });
|
|
946
|
+
}
|
|
947
|
+
const ranges = [...rows.ranges ?? []].map((range) => Object.freeze({ startRowId: range.startRowId, endRowId: range.endRowId }));
|
|
948
|
+
return Object.freeze({
|
|
949
|
+
kind: "explicit",
|
|
950
|
+
rowIds: Object.freeze([...rows.rowIds]),
|
|
951
|
+
...ranges.length === 0 ? {} : { ranges: Object.freeze(ranges) },
|
|
952
|
+
...excludedRowIds
|
|
953
|
+
});
|
|
954
|
+
}
|
|
955
|
+
function sameIndexedRowSelectionValue(left, right) {
|
|
956
|
+
if (left === right)
|
|
957
|
+
return true;
|
|
958
|
+
if (left.kind !== right.kind)
|
|
959
|
+
return false;
|
|
960
|
+
if (!sameRowRangeIndex(left.excludedRanges, right.excludedRanges))
|
|
961
|
+
return false;
|
|
962
|
+
if (left.kind !== "explicit" || right.kind !== "explicit")
|
|
963
|
+
return true;
|
|
964
|
+
if (left.rowIds.size !== right.rowIds.size)
|
|
965
|
+
return false;
|
|
966
|
+
for (const rowId of left.rowIds) {
|
|
967
|
+
if (!right.rowIds.has(rowId))
|
|
968
|
+
return false;
|
|
969
|
+
}
|
|
970
|
+
return sameRowRangeIndex(left.ranges, right.ranges);
|
|
971
|
+
}
|
|
972
|
+
function sameRowRangeIndex(left, right) {
|
|
973
|
+
if (left === right)
|
|
974
|
+
return true;
|
|
975
|
+
if ((left?.size ?? 0) !== (right?.size ?? 0))
|
|
976
|
+
return false;
|
|
977
|
+
const leftRanges = [...left ?? []];
|
|
978
|
+
const rightRanges = [...right ?? []];
|
|
979
|
+
return leftRanges.every((range, index) => {
|
|
980
|
+
const other = rightRanges[index];
|
|
981
|
+
return other !== void 0 && sameRowId(range.startRowId, other.startRowId) && sameRowId(range.endRowId, other.endRowId);
|
|
982
|
+
});
|
|
983
|
+
}
|
|
918
984
|
function getIndexedSelectionSummary(selection, snapshot) {
|
|
919
985
|
const visibleCount2 = snapshot.visibleDataRowCount;
|
|
920
986
|
const selectedCount = projectionFor(rowSelectionProgram(selection, snapshot), snapshot).runs?.selectedCount ?? 0;
|
|
@@ -924,6 +990,79 @@ function getIndexedSelectionSummary(selection, snapshot) {
|
|
|
924
990
|
visibleCount: visibleCount2
|
|
925
991
|
});
|
|
926
992
|
}
|
|
993
|
+
function datasetPosition(snapshot, rowId, loadedWindow) {
|
|
994
|
+
const rank = snapshot.dataIndexOf(dataRef(rowId));
|
|
995
|
+
if (rank < 0)
|
|
996
|
+
return -1;
|
|
997
|
+
return (loadedWindow?.start ?? 0) + rank;
|
|
998
|
+
}
|
|
999
|
+
function spanReadableInWindow(span, window) {
|
|
1000
|
+
return window.datasetKey !== void 0 && span.datasetKey === window.datasetKey;
|
|
1001
|
+
}
|
|
1002
|
+
function windowCarriesSpans(window) {
|
|
1003
|
+
return window !== null && window.datasetKey !== void 0;
|
|
1004
|
+
}
|
|
1005
|
+
function endpointPositions(range, snapshot, loadedWindow) {
|
|
1006
|
+
const liveStart = datasetPosition(snapshot, range.start.rowId, loadedWindow);
|
|
1007
|
+
const liveEnd = datasetPosition(snapshot, range.end.rowId, loadedWindow);
|
|
1008
|
+
const bothLive = liveStart >= 0 && liveEnd >= 0;
|
|
1009
|
+
if (bothLive)
|
|
1010
|
+
return { start: liveStart, end: liveEnd, bothLive };
|
|
1011
|
+
if (loadedWindow === null)
|
|
1012
|
+
return { start: void 0, end: void 0, bothLive };
|
|
1013
|
+
const remembered = range.datasetRowSpan !== void 0 && spanReadableInWindow(range.datasetRowSpan, loadedWindow) ? range.datasetRowSpan : void 0;
|
|
1014
|
+
return {
|
|
1015
|
+
start: liveStart >= 0 ? liveStart : remembered?.start,
|
|
1016
|
+
end: liveEnd >= 0 ? liveEnd : remembered?.end,
|
|
1017
|
+
bothLive
|
|
1018
|
+
};
|
|
1019
|
+
}
|
|
1020
|
+
function rangeDatasetSpan(range, snapshot, loadedWindow) {
|
|
1021
|
+
const { start, end, bothLive } = endpointPositions(range, snapshot, loadedWindow);
|
|
1022
|
+
const low = start ?? end;
|
|
1023
|
+
const high = end ?? start;
|
|
1024
|
+
if (low === void 0 || high === void 0)
|
|
1025
|
+
return void 0;
|
|
1026
|
+
return {
|
|
1027
|
+
lo: Math.min(low, high),
|
|
1028
|
+
hi: Math.max(low, high),
|
|
1029
|
+
// Both endpoints present is not on its own enough to call the extent
|
|
1030
|
+
// proven. Under a window that CAN carry spans, a range without one has no
|
|
1031
|
+
// positional identity: reconciliation stripped it, which it only does
|
|
1032
|
+
// when it could not locate the range in the current population. The rows
|
|
1033
|
+
// it still names really are selected — so it paints — but the extent it
|
|
1034
|
+
// reports is a remnant, not what the user chose, and saying otherwise is
|
|
1035
|
+
// the same "silent under-count wearing a verified flag" this whole
|
|
1036
|
+
// design exists to remove.
|
|
1037
|
+
verified: bothLive && (!windowCarriesSpans(loadedWindow) || range.datasetRowSpan !== void 0)
|
|
1038
|
+
};
|
|
1039
|
+
}
|
|
1040
|
+
function getIndexedCellSelectionSummary(selection, snapshot, loadedWindow) {
|
|
1041
|
+
const window = loadedWindow ?? null;
|
|
1042
|
+
const spans = [];
|
|
1043
|
+
let verified = true;
|
|
1044
|
+
for (const range of selection.ranges) {
|
|
1045
|
+
const span = rangeDatasetSpan(range, snapshot, window);
|
|
1046
|
+
if (span === void 0) {
|
|
1047
|
+
verified = false;
|
|
1048
|
+
continue;
|
|
1049
|
+
}
|
|
1050
|
+
if (!span.verified)
|
|
1051
|
+
verified = false;
|
|
1052
|
+
spans.push(span);
|
|
1053
|
+
}
|
|
1054
|
+
spans.sort((left, right) => left.lo - right.lo);
|
|
1055
|
+
let rowCount = 0;
|
|
1056
|
+
let covered = null;
|
|
1057
|
+
for (const span of spans) {
|
|
1058
|
+
const lo = covered === null || span.lo > covered ? span.lo : covered + 1;
|
|
1059
|
+
if (span.hi >= lo)
|
|
1060
|
+
rowCount += span.hi - lo + 1;
|
|
1061
|
+
if (covered === null || span.hi > covered)
|
|
1062
|
+
covered = span.hi;
|
|
1063
|
+
}
|
|
1064
|
+
return Object.freeze({ rowCount, verified });
|
|
1065
|
+
}
|
|
927
1066
|
function visibleAddress(address, snapshot) {
|
|
928
1067
|
return isVisibleData(snapshot, address.rowId);
|
|
929
1068
|
}
|
|
@@ -973,7 +1112,84 @@ function projectIndexedSelection(selection, previousSnapshot, snapshot, sequence
|
|
|
973
1112
|
const rows = cloneRowsWithProgram(selection.rows, nextProgram);
|
|
974
1113
|
return Object.freeze({ ...selection, rows });
|
|
975
1114
|
}
|
|
976
|
-
function
|
|
1115
|
+
function provenDeletedRow(rowId, loadedWindow, previous) {
|
|
1116
|
+
if (previous === void 0 || previous.window == null)
|
|
1117
|
+
return false;
|
|
1118
|
+
const previousRank = previous.snapshot.dataIndexOf(dataRef(rowId));
|
|
1119
|
+
if (previousRank < 0)
|
|
1120
|
+
return false;
|
|
1121
|
+
const previousAbsolute = previous.window.start + previousRank;
|
|
1122
|
+
return previousAbsolute >= loadedWindow.start && previousAbsolute < loadedWindow.start + loadedWindow.length;
|
|
1123
|
+
}
|
|
1124
|
+
function sameSpan(left, right) {
|
|
1125
|
+
if (left === right)
|
|
1126
|
+
return true;
|
|
1127
|
+
if (left === void 0 || right === void 0)
|
|
1128
|
+
return false;
|
|
1129
|
+
return left.start === right.start && left.end === right.end && left.datasetKey === right.datasetKey;
|
|
1130
|
+
}
|
|
1131
|
+
function withoutDatasetRowSpan(range) {
|
|
1132
|
+
if (range.datasetRowSpan === void 0)
|
|
1133
|
+
return range;
|
|
1134
|
+
return Object.freeze({ start: range.start, end: range.end });
|
|
1135
|
+
}
|
|
1136
|
+
function stampDatasetRowSpan(range, snapshot, loadedWindow) {
|
|
1137
|
+
if (loadedWindow === null)
|
|
1138
|
+
return range;
|
|
1139
|
+
if (!windowCarriesSpans(loadedWindow))
|
|
1140
|
+
return withoutDatasetRowSpan(range);
|
|
1141
|
+
const { start, end } = endpointPositions(range, snapshot, loadedWindow);
|
|
1142
|
+
if (start === void 0 || end === void 0) {
|
|
1143
|
+
return range.datasetRowSpan === void 0 || spanReadableInWindow(range.datasetRowSpan, loadedWindow) ? range : withoutDatasetRowSpan(range);
|
|
1144
|
+
}
|
|
1145
|
+
const next = Object.freeze({
|
|
1146
|
+
start,
|
|
1147
|
+
end,
|
|
1148
|
+
datasetKey: loadedWindow.datasetKey
|
|
1149
|
+
});
|
|
1150
|
+
if (sameSpan(range.datasetRowSpan, next))
|
|
1151
|
+
return range;
|
|
1152
|
+
return Object.freeze({ ...range, datasetRowSpan: next });
|
|
1153
|
+
}
|
|
1154
|
+
function adoptIndexedCellRangeSpans(ranges, replaced, snapshot, loadedWindow) {
|
|
1155
|
+
if (!windowCarriesSpans(loadedWindow))
|
|
1156
|
+
return ranges.map((range) => stampDatasetRowSpan(range, snapshot, loadedWindow));
|
|
1157
|
+
const remembered = /* @__PURE__ */ new Map();
|
|
1158
|
+
for (const range of replaced) {
|
|
1159
|
+
const span = range.datasetRowSpan;
|
|
1160
|
+
if (span === void 0)
|
|
1161
|
+
continue;
|
|
1162
|
+
if (!spanReadableInWindow(span, loadedWindow))
|
|
1163
|
+
continue;
|
|
1164
|
+
if (!remembered.has(range.start.rowId))
|
|
1165
|
+
remembered.set(range.start.rowId, span.start);
|
|
1166
|
+
if (!remembered.has(range.end.rowId))
|
|
1167
|
+
remembered.set(range.end.rowId, span.end);
|
|
1168
|
+
}
|
|
1169
|
+
return ranges.map((range) => {
|
|
1170
|
+
const own = endpointPositions(range, snapshot, loadedWindow);
|
|
1171
|
+
const start = own.start ?? remembered.get(range.start.rowId);
|
|
1172
|
+
const end = own.end ?? remembered.get(range.end.rowId);
|
|
1173
|
+
if (start === void 0 || end === void 0)
|
|
1174
|
+
return stampDatasetRowSpan(range, snapshot, loadedWindow);
|
|
1175
|
+
const next = Object.freeze({
|
|
1176
|
+
start,
|
|
1177
|
+
end,
|
|
1178
|
+
datasetKey: loadedWindow.datasetKey
|
|
1179
|
+
});
|
|
1180
|
+
if (sameSpan(range.datasetRowSpan, next))
|
|
1181
|
+
return range;
|
|
1182
|
+
return Object.freeze({ ...range, datasetRowSpan: next });
|
|
1183
|
+
});
|
|
1184
|
+
}
|
|
1185
|
+
function reconcileIndexedSelection(selection, snapshot, eviction) {
|
|
1186
|
+
const suppliedWindow = eviction?.window ?? null;
|
|
1187
|
+
const previous = eviction?.previous;
|
|
1188
|
+
const populationChanged = suppliedWindow !== null && previous?.window != null && // Value comparison, not `spanReadableInWindow`: two keyless windows are
|
|
1189
|
+
// not evidence of a change. A keyless consumer gets no span trust at all
|
|
1190
|
+
// (see `windowCarriesSpans`), so there is nothing here to invalidate.
|
|
1191
|
+
previous.window.datasetKey !== suppliedWindow.datasetKey;
|
|
1192
|
+
const retentionWindow = populationChanged ? null : suppliedWindow;
|
|
977
1193
|
let changed = false;
|
|
978
1194
|
rowSelectionProgram(selection, snapshot);
|
|
979
1195
|
const ranges = [];
|
|
@@ -981,11 +1197,41 @@ function reconcileIndexedSelection(selection, snapshot) {
|
|
|
981
1197
|
const startVisible = visibleAddress(range.start, snapshot);
|
|
982
1198
|
const endVisible = visibleAddress(range.end, snapshot);
|
|
983
1199
|
if (startVisible && endVisible) {
|
|
984
|
-
|
|
1200
|
+
const stamped = stampDatasetRowSpan(range, snapshot, suppliedWindow);
|
|
1201
|
+
if (stamped !== range)
|
|
1202
|
+
changed = true;
|
|
1203
|
+
ranges.push(stamped);
|
|
985
1204
|
} else if (startVisible || endVisible) {
|
|
986
1205
|
const survivor = startVisible ? range.start : range.end;
|
|
987
|
-
|
|
988
|
-
|
|
1206
|
+
const absentee = startVisible ? range.end : range.start;
|
|
1207
|
+
if (retentionWindow === null || provenDeletedRow(absentee.rowId, retentionWindow, previous)) {
|
|
1208
|
+
ranges.push(stampDatasetRowSpan(
|
|
1209
|
+
Object.freeze({ start: survivor, end: survivor }),
|
|
1210
|
+
snapshot,
|
|
1211
|
+
// `retentionWindow`, not `suppliedWindow`. On a population change
|
|
1212
|
+
// this is null, so the collapsed range gets NO span — which is
|
|
1213
|
+
// the whole point: it is a remnant of a selection the engine
|
|
1214
|
+
// could not locate in the new population, and a span would let
|
|
1215
|
+
// the summary call its one surviving row a proven extent. See
|
|
1216
|
+
// `rangeDatasetSpan`, which reads a missing span under a
|
|
1217
|
+
// span-carrying window as exactly that doubt.
|
|
1218
|
+
retentionWindow
|
|
1219
|
+
));
|
|
1220
|
+
changed = true;
|
|
1221
|
+
} else {
|
|
1222
|
+
const retained = stampDatasetRowSpan(range, snapshot, retentionWindow);
|
|
1223
|
+
if (retained !== range)
|
|
1224
|
+
changed = true;
|
|
1225
|
+
ranges.push(retained);
|
|
1226
|
+
}
|
|
1227
|
+
} else if (retentionWindow != null) {
|
|
1228
|
+
const startDeleted = provenDeletedRow(range.start.rowId, retentionWindow, previous);
|
|
1229
|
+
const endDeleted = provenDeletedRow(range.end.rowId, retentionWindow, previous);
|
|
1230
|
+
if (startDeleted || endDeleted) {
|
|
1231
|
+
changed = true;
|
|
1232
|
+
} else {
|
|
1233
|
+
ranges.push(range);
|
|
1234
|
+
}
|
|
989
1235
|
} else {
|
|
990
1236
|
changed = true;
|
|
991
1237
|
}
|
|
@@ -1067,7 +1313,7 @@ function orderPinnedColumns(columns) {
|
|
|
1067
1313
|
...columns.filter((column) => column.pinned === "right")
|
|
1068
1314
|
];
|
|
1069
1315
|
}
|
|
1070
|
-
function copySelection(selection) {
|
|
1316
|
+
function copySelection(selection, context) {
|
|
1071
1317
|
const rows = selection.rows.kind === "explicit" ? Object.freeze({
|
|
1072
1318
|
kind: "explicit",
|
|
1073
1319
|
rowIds: toImmutableIndexedSet(selection.rows.rowIds),
|
|
@@ -1080,10 +1326,15 @@ function copySelection(selection) {
|
|
|
1080
1326
|
preserveIndexedRowSelectionProgram(selection.rows, rows);
|
|
1081
1327
|
return Object.freeze({
|
|
1082
1328
|
rows,
|
|
1083
|
-
ranges: Object.freeze(selection.ranges.map((range) => Object.freeze({
|
|
1329
|
+
ranges: Object.freeze(adoptIndexedCellRangeSpans(selection.ranges.map((range) => Object.freeze({
|
|
1084
1330
|
start: Object.freeze({ ...range.start }),
|
|
1085
|
-
end: Object.freeze({ ...range.end })
|
|
1086
|
-
|
|
1331
|
+
end: Object.freeze({ ...range.end }),
|
|
1332
|
+
// Copied, not rebuilt from ids: this is the only public write
|
|
1333
|
+
// path, so dropping the span here un-counts every retained range
|
|
1334
|
+
// in the selection — including the ones the gesture never
|
|
1335
|
+
// touched.
|
|
1336
|
+
...range.datasetRowSpan === void 0 ? {} : { datasetRowSpan: Object.freeze({ ...range.datasetRowSpan }) }
|
|
1337
|
+
})), context.replaced, context.snapshot, context.loadedWindow)),
|
|
1087
1338
|
anchor: selection.anchor === null ? null : Object.freeze({ ...selection.anchor })
|
|
1088
1339
|
});
|
|
1089
1340
|
}
|
|
@@ -1117,6 +1368,13 @@ function sameRowRanges(left, right) {
|
|
|
1117
1368
|
return false;
|
|
1118
1369
|
}
|
|
1119
1370
|
}
|
|
1371
|
+
function sameDatasetRowSpan(left, right) {
|
|
1372
|
+
if (left === right)
|
|
1373
|
+
return true;
|
|
1374
|
+
if (left === void 0 || right === void 0)
|
|
1375
|
+
return false;
|
|
1376
|
+
return left.start === right.start && left.end === right.end && left.datasetKey === right.datasetKey;
|
|
1377
|
+
}
|
|
1120
1378
|
function sameSelection(left, right) {
|
|
1121
1379
|
if (left.rows.kind !== right.rows.kind)
|
|
1122
1380
|
return false;
|
|
@@ -1135,7 +1393,14 @@ function sameSelection(left, right) {
|
|
|
1135
1393
|
for (let index = 0; index < left.ranges.length; index += 1) {
|
|
1136
1394
|
const leftRange = left.ranges[index];
|
|
1137
1395
|
const rightRange = right.ranges[index];
|
|
1138
|
-
if (!sameValueZero(leftRange.start.rowId, rightRange.start.rowId) || leftRange.start.columnId !== rightRange.start.columnId || !sameValueZero(leftRange.end.rowId, rightRange.end.rowId) || leftRange.end.columnId !== rightRange.end.columnId
|
|
1396
|
+
if (!sameValueZero(leftRange.start.rowId, rightRange.start.rowId) || leftRange.start.columnId !== rightRange.start.columnId || !sameValueZero(leftRange.end.rowId, rightRange.end.rowId) || leftRange.end.columnId !== rightRange.end.columnId || // The span is part of a range's identity, not decoration on it: while
|
|
1397
|
+
// the rows are evicted it is the ONLY thing that says how large the
|
|
1398
|
+
// selection is, and two ranges over the same ids with different spans
|
|
1399
|
+
// select different numbers of rows. Comparing it is safe precisely
|
|
1400
|
+
// because `copySelection` recovers a missing span from the selection
|
|
1401
|
+
// being replaced — so a controlled `state` echo that drops the field
|
|
1402
|
+
// still compares equal, and the effect stays the no-op it has to be.
|
|
1403
|
+
!sameDatasetRowSpan(leftRange.datasetRowSpan, rightRange.datasetRowSpan)) {
|
|
1139
1404
|
return false;
|
|
1140
1405
|
}
|
|
1141
1406
|
}
|
|
@@ -1156,7 +1421,7 @@ function createGridUiCore(options) {
|
|
|
1156
1421
|
let draining = false;
|
|
1157
1422
|
let projecting = false;
|
|
1158
1423
|
let activeProjectionToken;
|
|
1159
|
-
let
|
|
1424
|
+
let observed;
|
|
1160
1425
|
let state = Object.freeze({
|
|
1161
1426
|
viewport: options.viewport ? normalizeViewport(options.viewport) : EMPTY_VIEWPORT,
|
|
1162
1427
|
focus: Object.freeze({ ref: null, columnId: null }),
|
|
@@ -1226,11 +1491,12 @@ function createGridUiCore(options) {
|
|
|
1226
1491
|
const observationError = (message, cause) => cause instanceof PretableGridUiError && cause.code === "row-model-observation-failed" ? cause : new PretableGridUiError("row-model-observation-failed", message, cause);
|
|
1227
1492
|
const snapshotForInteraction = () => {
|
|
1228
1493
|
try {
|
|
1229
|
-
return
|
|
1494
|
+
return observed?.snapshot ?? options.rowModel.getState().snapshot;
|
|
1230
1495
|
} catch (cause) {
|
|
1231
1496
|
throw new PretableGridUiError("row-model-observation-failed", "The row-model snapshot could not be read for a UI interaction.", cause);
|
|
1232
1497
|
}
|
|
1233
1498
|
};
|
|
1499
|
+
const interactionContext = () => observed ?? { snapshot: snapshotForInteraction(), window: null };
|
|
1234
1500
|
const navigationColumnIds = () => {
|
|
1235
1501
|
if (cachedNavigationLayout !== state.columnLayout) {
|
|
1236
1502
|
cachedNavigationLayout = state.columnLayout;
|
|
@@ -1243,7 +1509,7 @@ function createGridUiCore(options) {
|
|
|
1243
1509
|
return;
|
|
1244
1510
|
disposed = true;
|
|
1245
1511
|
activeProjectionToken = void 0;
|
|
1246
|
-
|
|
1512
|
+
observed = void 0;
|
|
1247
1513
|
releaseIndexedRowSelectionProgram(state.selection.rows);
|
|
1248
1514
|
queuedActions.length = 0;
|
|
1249
1515
|
const captured = Array.from(listeners);
|
|
@@ -1311,7 +1577,12 @@ function createGridUiCore(options) {
|
|
|
1311
1577
|
setSelection(selection) {
|
|
1312
1578
|
let next;
|
|
1313
1579
|
try {
|
|
1314
|
-
|
|
1580
|
+
const context = interactionContext();
|
|
1581
|
+
next = copySelection(selection, {
|
|
1582
|
+
replaced: state.selection.ranges,
|
|
1583
|
+
snapshot: context.snapshot,
|
|
1584
|
+
loadedWindow: context.window
|
|
1585
|
+
});
|
|
1315
1586
|
} catch (cause) {
|
|
1316
1587
|
throw new PretableGridUiError("invalid-ui-state", "The supplied selection could not be captured atomically.", cause);
|
|
1317
1588
|
}
|
|
@@ -1321,6 +1592,22 @@ function createGridUiCore(options) {
|
|
|
1321
1592
|
publish({ ...state, selection: next });
|
|
1322
1593
|
});
|
|
1323
1594
|
},
|
|
1595
|
+
setRowSelection(rows) {
|
|
1596
|
+
command(() => {
|
|
1597
|
+
let nextRows;
|
|
1598
|
+
try {
|
|
1599
|
+
nextRows = createIndexedRowSelection(rows, snapshotForInteraction());
|
|
1600
|
+
} catch (cause) {
|
|
1601
|
+
throw observationError("The supplied row selection could not be applied atomically.", cause);
|
|
1602
|
+
}
|
|
1603
|
+
if (sameIndexedRowSelectionValue(state.selection.rows, nextRows))
|
|
1604
|
+
return;
|
|
1605
|
+
publish({
|
|
1606
|
+
...state,
|
|
1607
|
+
selection: Object.freeze({ ...state.selection, rows: nextRows })
|
|
1608
|
+
});
|
|
1609
|
+
});
|
|
1610
|
+
},
|
|
1324
1611
|
toggleRowSelection(rowId) {
|
|
1325
1612
|
command(() => {
|
|
1326
1613
|
let next;
|
|
@@ -1361,6 +1648,14 @@ function createGridUiCore(options) {
|
|
|
1361
1648
|
throw observationError("Indexed row selection summary could not be observed atomically.", cause);
|
|
1362
1649
|
}
|
|
1363
1650
|
},
|
|
1651
|
+
getCellSelectionSummary() {
|
|
1652
|
+
try {
|
|
1653
|
+
const context = interactionContext();
|
|
1654
|
+
return getIndexedCellSelectionSummary(state.selection, context.snapshot, context.window);
|
|
1655
|
+
} catch (cause) {
|
|
1656
|
+
throw observationError("Indexed cell selection summary could not be observed atomically.", cause);
|
|
1657
|
+
}
|
|
1658
|
+
},
|
|
1364
1659
|
selectAllVisibleRows() {
|
|
1365
1660
|
command(() => {
|
|
1366
1661
|
let next;
|
|
@@ -1391,7 +1686,7 @@ function createGridUiCore(options) {
|
|
|
1391
1686
|
status: "editing"
|
|
1392
1687
|
});
|
|
1393
1688
|
command(() => {
|
|
1394
|
-
const snapshot =
|
|
1689
|
+
const snapshot = observed?.snapshot;
|
|
1395
1690
|
let visible = false;
|
|
1396
1691
|
try {
|
|
1397
1692
|
visible = snapshot !== void 0 && snapshot.indexOf({ kind: "data", rowId: input.rowId }) >= 0;
|
|
@@ -1535,7 +1830,8 @@ function createGridUiCore(options) {
|
|
|
1535
1830
|
return;
|
|
1536
1831
|
}
|
|
1537
1832
|
const focus = reconcileIndexedFocus(state.focus, snapshot);
|
|
1538
|
-
const
|
|
1833
|
+
const selectionWindow = options.getSelectionWindow?.() ?? null;
|
|
1834
|
+
const selection = reconcileIndexedSelection(observed === void 0 ? state.selection : projectIndexedSelection(state.selection, observed.snapshot, snapshot, options.rowModel.changesSince(observed.snapshot.revision)), snapshot, { window: selectionWindow, previous: observed });
|
|
1539
1835
|
let editing = state.editing;
|
|
1540
1836
|
if (editing !== null && snapshot.indexOf({ kind: "data", rowId: editing.rowId }) < 0) {
|
|
1541
1837
|
editing = null;
|
|
@@ -1550,7 +1846,7 @@ function createGridUiCore(options) {
|
|
|
1550
1846
|
}
|
|
1551
1847
|
if (disposed || activeProjectionToken !== token)
|
|
1552
1848
|
return;
|
|
1553
|
-
|
|
1849
|
+
observed = { snapshot, window: selectionWindow };
|
|
1554
1850
|
committed = true;
|
|
1555
1851
|
publish({
|
|
1556
1852
|
...state,
|
|
@@ -8382,4 +8678,4 @@ var numberFormats = {
|
|
|
8382
8678
|
}
|
|
8383
8679
|
};
|
|
8384
8680
|
|
|
8385
|
-
export { GROUP_COLUMN_ID, PretableDisposedModelError, PretableInvalidGroupKeyError, PretableReentrantMutationError, PretableRowIdentityChangeError, PretableRowModelError, PretableTransitionCancelledError, PretableUnsupportedRowUpdateError, createColumnHelper2 as createColumnHelper, createGrid, createLocalRowModel2 as createLocalRowModel, numberFormats };
|
|
8681
|
+
export { GROUP_COLUMN_ID, PretableDisposedModelError, PretableInvalidGroupKeyError, PretableReentrantMutationError, PretableRowIdentityChangeError, PretableRowModelError, PretableTransitionCancelledError, PretableUnsupportedRowUpdateError, createColumnHelper2 as createColumnHelper, createGrid, createLocalRowModel2 as createLocalRowModel, describeRowSelection, numberFormats };
|