@gridkitjs/core 0.0.0-dev-20261112200523 → 0.0.0-dev-20261118081957
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/{chunk-AHDALZCY.js → chunk-DHSWUNSZ.js} +128 -111
- package/dist/chunk-DHSWUNSZ.js.map +1 -0
- package/dist/{filterEditor-9hncygVf.d.ts → filterEditor-C2nZkvgC.d.ts} +61 -16
- package/dist/index.d.ts +2 -2
- package/dist/index.js +73 -22
- package/dist/index.js.map +1 -1
- package/dist/renderer.d.ts +2 -2
- package/dist/renderer.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-AHDALZCY.js.map +0 -1
|
@@ -259,10 +259,16 @@ function partitionByValue(rows, column, direction) {
|
|
|
259
259
|
});
|
|
260
260
|
return groups;
|
|
261
261
|
}
|
|
262
|
+
function withGroupPosition(rows, depth) {
|
|
263
|
+
return rows.map((row, index) => ({
|
|
264
|
+
...row,
|
|
265
|
+
groupPosition: { level: depth, position: index + 1, setSize: rows.length }
|
|
266
|
+
}));
|
|
267
|
+
}
|
|
262
268
|
function buildLevel(rows, levels, parentPath, expansion, byId, out) {
|
|
263
269
|
const level = levels[0];
|
|
264
270
|
if (level === void 0) {
|
|
265
|
-
out.push(...rows);
|
|
271
|
+
out.push(...withGroupPosition(rows, parentPath.length));
|
|
266
272
|
return;
|
|
267
273
|
}
|
|
268
274
|
const column = byId.get(level.columnId);
|
|
@@ -272,7 +278,7 @@ function buildLevel(rows, levels, parentPath, expansion, byId, out) {
|
|
|
272
278
|
}
|
|
273
279
|
const rest = levels.slice(1);
|
|
274
280
|
const groups = partitionByValue(rows, column, level.direction ?? "asc");
|
|
275
|
-
for (const group of groups) {
|
|
281
|
+
for (const [index, group] of groups.entries()) {
|
|
276
282
|
const path = [...parentPath, group.value];
|
|
277
283
|
const groupId = groupRowId(path);
|
|
278
284
|
const expanded = isGroupExpanded(expansion, groupId);
|
|
@@ -285,6 +291,8 @@ function buildLevel(rows, levels, parentPath, expansion, byId, out) {
|
|
|
285
291
|
path,
|
|
286
292
|
expanded,
|
|
287
293
|
count: group.rows.length,
|
|
294
|
+
position: index + 1,
|
|
295
|
+
setSize: groups.length,
|
|
288
296
|
// Both set by `groupRows` once it has the whole flattened array.
|
|
289
297
|
rowIndex: -1,
|
|
290
298
|
datasetIndex: -1,
|
|
@@ -783,6 +791,108 @@ function resolveCell(rowsById, columns, cell) {
|
|
|
783
791
|
};
|
|
784
792
|
}
|
|
785
793
|
|
|
794
|
+
// src/util/selection.ts
|
|
795
|
+
var NO_CHANGE = { added: [], removed: [] };
|
|
796
|
+
function sameSelection(a, b) {
|
|
797
|
+
return a.length === b.length && a.every((id, index) => id === b[index]);
|
|
798
|
+
}
|
|
799
|
+
function toggleSelection(selection, id, mode) {
|
|
800
|
+
if (mode === false) {
|
|
801
|
+
return selection;
|
|
802
|
+
}
|
|
803
|
+
if (selection.includes(id)) {
|
|
804
|
+
return selection.filter((selectedId) => selectedId !== id);
|
|
805
|
+
}
|
|
806
|
+
return mode === "single" ? [id] : [...selection, id];
|
|
807
|
+
}
|
|
808
|
+
function selectOnly(selection, id, mode) {
|
|
809
|
+
if (mode === false) {
|
|
810
|
+
return selection;
|
|
811
|
+
}
|
|
812
|
+
return selection.length === 1 && selection[0] === id ? selection : [id];
|
|
813
|
+
}
|
|
814
|
+
function selectRange(selection, orderedIds, anchorId, focusId, mode) {
|
|
815
|
+
if (mode !== "multiple") {
|
|
816
|
+
return selectOnly(selection, focusId, mode);
|
|
817
|
+
}
|
|
818
|
+
const anchor = orderedIds.indexOf(anchorId);
|
|
819
|
+
const focus = orderedIds.indexOf(focusId);
|
|
820
|
+
if (anchor === -1 || focus === -1) {
|
|
821
|
+
return selection;
|
|
822
|
+
}
|
|
823
|
+
const next = orderedIds.slice(
|
|
824
|
+
Math.min(anchor, focus),
|
|
825
|
+
Math.max(anchor, focus) + 1
|
|
826
|
+
);
|
|
827
|
+
return sameSelection(selection, next) ? selection : next;
|
|
828
|
+
}
|
|
829
|
+
function selectAll(selection, orderedIds, mode) {
|
|
830
|
+
if (mode !== "multiple") {
|
|
831
|
+
return selection;
|
|
832
|
+
}
|
|
833
|
+
return sameSelection(selection, orderedIds) ? selection : orderedIds;
|
|
834
|
+
}
|
|
835
|
+
function clearSelection(selection) {
|
|
836
|
+
return selection.length === 0 ? selection : [];
|
|
837
|
+
}
|
|
838
|
+
function diffSelection(previous, next) {
|
|
839
|
+
if (previous === next) {
|
|
840
|
+
return NO_CHANGE;
|
|
841
|
+
}
|
|
842
|
+
const before = new Set(previous);
|
|
843
|
+
const after = new Set(next);
|
|
844
|
+
return {
|
|
845
|
+
added: next.filter((id) => !before.has(id)),
|
|
846
|
+
removed: previous.filter((id) => !after.has(id))
|
|
847
|
+
};
|
|
848
|
+
}
|
|
849
|
+
var NO_CELL_SELECTED = { kind: "none" };
|
|
850
|
+
function isSameCell(a, b) {
|
|
851
|
+
if (a.kind === "none" || b.kind === "none") {
|
|
852
|
+
return a.kind === b.kind;
|
|
853
|
+
}
|
|
854
|
+
return a.rowId === b.rowId && a.columnId === b.columnId;
|
|
855
|
+
}
|
|
856
|
+
function holdsCell(selection, cell) {
|
|
857
|
+
return selection.kind === "cell" && selection.rowId === cell.rowId && selection.columnId === cell.columnId;
|
|
858
|
+
}
|
|
859
|
+
function selectCell(selection, cell, mode) {
|
|
860
|
+
if (mode === false || holdsCell(selection, cell)) {
|
|
861
|
+
return selection;
|
|
862
|
+
}
|
|
863
|
+
return { kind: "cell", rowId: cell.rowId, columnId: cell.columnId };
|
|
864
|
+
}
|
|
865
|
+
function toggleCellSelection(selection, cell, mode) {
|
|
866
|
+
if (mode === false) {
|
|
867
|
+
return selection;
|
|
868
|
+
}
|
|
869
|
+
return holdsCell(selection, cell) ? NO_CELL_SELECTED : { kind: "cell", rowId: cell.rowId, columnId: cell.columnId };
|
|
870
|
+
}
|
|
871
|
+
function clearCellSelection(selection) {
|
|
872
|
+
return selection.kind === "none" ? selection : NO_CELL_SELECTED;
|
|
873
|
+
}
|
|
874
|
+
function intentOf(event, options) {
|
|
875
|
+
if (event.shiftKey) {
|
|
876
|
+
return "range";
|
|
877
|
+
}
|
|
878
|
+
if (event.ctrlKey || event.metaKey) {
|
|
879
|
+
return "toggle";
|
|
880
|
+
}
|
|
881
|
+
return options?.toggleOnClick === true ? "toggle" : "replace";
|
|
882
|
+
}
|
|
883
|
+
function applySelectionIntent(selection, orderedIds, anchorId, id, intent, mode) {
|
|
884
|
+
switch (intent) {
|
|
885
|
+
case "toggle":
|
|
886
|
+
return toggleSelection(selection, id, mode);
|
|
887
|
+
// A range with no anchor yet spans from the id to itself, which is the
|
|
888
|
+
// plain click a first Shift-click may as well be.
|
|
889
|
+
case "range":
|
|
890
|
+
return selectRange(selection, orderedIds, anchorId ?? id, id, mode);
|
|
891
|
+
default:
|
|
892
|
+
return selectOnly(selection, id, mode);
|
|
893
|
+
}
|
|
894
|
+
}
|
|
895
|
+
|
|
786
896
|
// src/util/sizing.ts
|
|
787
897
|
var DEFAULT_COLUMN_SIZES = {
|
|
788
898
|
width: 150,
|
|
@@ -1118,101 +1228,6 @@ function setColumnVisibility(columns, visibility, columnIds, visible) {
|
|
|
1118
1228
|
};
|
|
1119
1229
|
}
|
|
1120
1230
|
|
|
1121
|
-
// src/util/selection.ts
|
|
1122
|
-
var NO_CHANGE = { added: [], removed: [] };
|
|
1123
|
-
function sameSelection(a, b) {
|
|
1124
|
-
return a.length === b.length && a.every((id, index) => id === b[index]);
|
|
1125
|
-
}
|
|
1126
|
-
function toggleSelection(selection, id, mode) {
|
|
1127
|
-
if (mode === false) {
|
|
1128
|
-
return selection;
|
|
1129
|
-
}
|
|
1130
|
-
if (selection.includes(id)) {
|
|
1131
|
-
return selection.filter((selectedId) => selectedId !== id);
|
|
1132
|
-
}
|
|
1133
|
-
return mode === "single" ? [id] : [...selection, id];
|
|
1134
|
-
}
|
|
1135
|
-
function selectOnly(selection, id, mode) {
|
|
1136
|
-
if (mode === false) {
|
|
1137
|
-
return selection;
|
|
1138
|
-
}
|
|
1139
|
-
return selection.length === 1 && selection[0] === id ? selection : [id];
|
|
1140
|
-
}
|
|
1141
|
-
function selectRange(selection, orderedIds, anchorId, focusId, mode) {
|
|
1142
|
-
if (mode !== "multiple") {
|
|
1143
|
-
return selectOnly(selection, focusId, mode);
|
|
1144
|
-
}
|
|
1145
|
-
const anchor = orderedIds.indexOf(anchorId);
|
|
1146
|
-
const focus = orderedIds.indexOf(focusId);
|
|
1147
|
-
if (anchor === -1 || focus === -1) {
|
|
1148
|
-
return selection;
|
|
1149
|
-
}
|
|
1150
|
-
const next = orderedIds.slice(
|
|
1151
|
-
Math.min(anchor, focus),
|
|
1152
|
-
Math.max(anchor, focus) + 1
|
|
1153
|
-
);
|
|
1154
|
-
return sameSelection(selection, next) ? selection : next;
|
|
1155
|
-
}
|
|
1156
|
-
function selectAll(selection, orderedIds, mode) {
|
|
1157
|
-
if (mode !== "multiple") {
|
|
1158
|
-
return selection;
|
|
1159
|
-
}
|
|
1160
|
-
return sameSelection(selection, orderedIds) ? selection : orderedIds;
|
|
1161
|
-
}
|
|
1162
|
-
function clearSelection(selection) {
|
|
1163
|
-
return selection.length === 0 ? selection : [];
|
|
1164
|
-
}
|
|
1165
|
-
function diffSelection(previous, next) {
|
|
1166
|
-
if (previous === next) {
|
|
1167
|
-
return NO_CHANGE;
|
|
1168
|
-
}
|
|
1169
|
-
const before = new Set(previous);
|
|
1170
|
-
const after = new Set(next);
|
|
1171
|
-
return {
|
|
1172
|
-
added: next.filter((id) => !before.has(id)),
|
|
1173
|
-
removed: previous.filter((id) => !after.has(id))
|
|
1174
|
-
};
|
|
1175
|
-
}
|
|
1176
|
-
function isSameCell(a, b) {
|
|
1177
|
-
if (a === null || b === null) {
|
|
1178
|
-
return a === b;
|
|
1179
|
-
}
|
|
1180
|
-
return a.rowId === b.rowId && a.columnId === b.columnId;
|
|
1181
|
-
}
|
|
1182
|
-
function selectCell(selection, cell, mode) {
|
|
1183
|
-
if (mode === false || isSameCell(selection, cell)) {
|
|
1184
|
-
return selection;
|
|
1185
|
-
}
|
|
1186
|
-
return cell;
|
|
1187
|
-
}
|
|
1188
|
-
function toggleCellSelection(selection, cell, mode) {
|
|
1189
|
-
if (mode === false) {
|
|
1190
|
-
return selection;
|
|
1191
|
-
}
|
|
1192
|
-
return isSameCell(selection, cell) ? null : cell;
|
|
1193
|
-
}
|
|
1194
|
-
function intentOf(event, options) {
|
|
1195
|
-
if (event.shiftKey) {
|
|
1196
|
-
return "range";
|
|
1197
|
-
}
|
|
1198
|
-
if (event.ctrlKey || event.metaKey) {
|
|
1199
|
-
return "toggle";
|
|
1200
|
-
}
|
|
1201
|
-
return options?.toggleOnClick === true ? "toggle" : "replace";
|
|
1202
|
-
}
|
|
1203
|
-
function applySelectionIntent(selection, orderedIds, anchorId, id, intent, mode) {
|
|
1204
|
-
switch (intent) {
|
|
1205
|
-
case "toggle":
|
|
1206
|
-
return toggleSelection(selection, id, mode);
|
|
1207
|
-
// A range with no anchor yet spans from the id to itself, which is the
|
|
1208
|
-
// plain click a first Shift-click may as well be.
|
|
1209
|
-
case "range":
|
|
1210
|
-
return selectRange(selection, orderedIds, anchorId ?? id, id, mode);
|
|
1211
|
-
default:
|
|
1212
|
-
return selectOnly(selection, id, mode);
|
|
1213
|
-
}
|
|
1214
|
-
}
|
|
1215
|
-
|
|
1216
1231
|
// src/util/format.ts
|
|
1217
1232
|
var DATE_FIELDS = {
|
|
1218
1233
|
year: "numeric",
|
|
@@ -1663,7 +1678,7 @@ function selectionCopy(source) {
|
|
|
1663
1678
|
return { kind: "columns", columnIds };
|
|
1664
1679
|
}
|
|
1665
1680
|
const cell = state.cellSelection;
|
|
1666
|
-
if (cell
|
|
1681
|
+
if (cell.kind === "cell" && hasRow(source, cell.rowId) && hasColumn(source, cell.columnId)) {
|
|
1667
1682
|
return { kind: "cell", rowId: cell.rowId, columnId: cell.columnId };
|
|
1668
1683
|
}
|
|
1669
1684
|
return null;
|
|
@@ -2887,7 +2902,7 @@ function builtInCommands() {
|
|
|
2887
2902
|
id: "selection.clear",
|
|
2888
2903
|
label: ({ messages }) => messages.clearSelection,
|
|
2889
2904
|
isVisible: (context) => isOn(context, ["grid", "cell", "header"]) && isAnythingSelectable(context.options.selectable),
|
|
2890
|
-
isEnabled: ({ state }) => state.rowSelection.length > 0 || state.columnSelection.length > 0 || state.cellSelection !==
|
|
2905
|
+
isEnabled: ({ state }) => state.rowSelection.length > 0 || state.columnSelection.length > 0 || state.cellSelection.kind !== "none",
|
|
2891
2906
|
execute: ({ actions }) => {
|
|
2892
2907
|
actions.clearSelection();
|
|
2893
2908
|
}
|
|
@@ -3329,6 +3344,19 @@ export {
|
|
|
3329
3344
|
resolveColumns,
|
|
3330
3345
|
resolveCell,
|
|
3331
3346
|
reportError,
|
|
3347
|
+
toggleSelection,
|
|
3348
|
+
selectOnly,
|
|
3349
|
+
selectRange,
|
|
3350
|
+
selectAll,
|
|
3351
|
+
clearSelection,
|
|
3352
|
+
diffSelection,
|
|
3353
|
+
NO_CELL_SELECTED,
|
|
3354
|
+
isSameCell,
|
|
3355
|
+
selectCell,
|
|
3356
|
+
toggleCellSelection,
|
|
3357
|
+
clearCellSelection,
|
|
3358
|
+
intentOf,
|
|
3359
|
+
applySelectionIntent,
|
|
3332
3360
|
DEFAULT_COLUMN_SIZES,
|
|
3333
3361
|
KEYBOARD_STEP,
|
|
3334
3362
|
resolveColumnConstraints,
|
|
@@ -3345,17 +3373,6 @@ export {
|
|
|
3345
3373
|
isColumnVisible,
|
|
3346
3374
|
applyColumnVisibility,
|
|
3347
3375
|
setColumnVisibility,
|
|
3348
|
-
toggleSelection,
|
|
3349
|
-
selectOnly,
|
|
3350
|
-
selectRange,
|
|
3351
|
-
selectAll,
|
|
3352
|
-
clearSelection,
|
|
3353
|
-
diffSelection,
|
|
3354
|
-
isSameCell,
|
|
3355
|
-
selectCell,
|
|
3356
|
-
toggleCellSelection,
|
|
3357
|
-
intentOf,
|
|
3358
|
-
applySelectionIntent,
|
|
3359
3376
|
formatCellValue,
|
|
3360
3377
|
formatAggregateValue,
|
|
3361
3378
|
formatGroupValue,
|
|
@@ -3409,4 +3426,4 @@ export {
|
|
|
3409
3426
|
clampFocus,
|
|
3410
3427
|
nextFocusForKey
|
|
3411
3428
|
};
|
|
3412
|
-
//# sourceMappingURL=chunk-
|
|
3429
|
+
//# sourceMappingURL=chunk-DHSWUNSZ.js.map
|