@gridkitjs/core 0.0.0-dev-20261112195815 → 0.0.0-dev-20261112201151
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-NA6KXHPE.js → chunk-QGKPKQIO.js} +118 -109
- package/dist/chunk-QGKPKQIO.js.map +1 -0
- package/dist/{filterEditor-Buy3CLup.d.ts → filterEditor-B7C_n89V.d.ts} +49 -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-NA6KXHPE.js.map +0 -1
|
@@ -783,6 +783,108 @@ function resolveCell(rowsById, columns, cell) {
|
|
|
783
783
|
};
|
|
784
784
|
}
|
|
785
785
|
|
|
786
|
+
// src/util/selection.ts
|
|
787
|
+
var NO_CHANGE = { added: [], removed: [] };
|
|
788
|
+
function sameSelection(a, b) {
|
|
789
|
+
return a.length === b.length && a.every((id, index) => id === b[index]);
|
|
790
|
+
}
|
|
791
|
+
function toggleSelection(selection, id, mode) {
|
|
792
|
+
if (mode === false) {
|
|
793
|
+
return selection;
|
|
794
|
+
}
|
|
795
|
+
if (selection.includes(id)) {
|
|
796
|
+
return selection.filter((selectedId) => selectedId !== id);
|
|
797
|
+
}
|
|
798
|
+
return mode === "single" ? [id] : [...selection, id];
|
|
799
|
+
}
|
|
800
|
+
function selectOnly(selection, id, mode) {
|
|
801
|
+
if (mode === false) {
|
|
802
|
+
return selection;
|
|
803
|
+
}
|
|
804
|
+
return selection.length === 1 && selection[0] === id ? selection : [id];
|
|
805
|
+
}
|
|
806
|
+
function selectRange(selection, orderedIds, anchorId, focusId, mode) {
|
|
807
|
+
if (mode !== "multiple") {
|
|
808
|
+
return selectOnly(selection, focusId, mode);
|
|
809
|
+
}
|
|
810
|
+
const anchor = orderedIds.indexOf(anchorId);
|
|
811
|
+
const focus = orderedIds.indexOf(focusId);
|
|
812
|
+
if (anchor === -1 || focus === -1) {
|
|
813
|
+
return selection;
|
|
814
|
+
}
|
|
815
|
+
const next = orderedIds.slice(
|
|
816
|
+
Math.min(anchor, focus),
|
|
817
|
+
Math.max(anchor, focus) + 1
|
|
818
|
+
);
|
|
819
|
+
return sameSelection(selection, next) ? selection : next;
|
|
820
|
+
}
|
|
821
|
+
function selectAll(selection, orderedIds, mode) {
|
|
822
|
+
if (mode !== "multiple") {
|
|
823
|
+
return selection;
|
|
824
|
+
}
|
|
825
|
+
return sameSelection(selection, orderedIds) ? selection : orderedIds;
|
|
826
|
+
}
|
|
827
|
+
function clearSelection(selection) {
|
|
828
|
+
return selection.length === 0 ? selection : [];
|
|
829
|
+
}
|
|
830
|
+
function diffSelection(previous, next) {
|
|
831
|
+
if (previous === next) {
|
|
832
|
+
return NO_CHANGE;
|
|
833
|
+
}
|
|
834
|
+
const before = new Set(previous);
|
|
835
|
+
const after = new Set(next);
|
|
836
|
+
return {
|
|
837
|
+
added: next.filter((id) => !before.has(id)),
|
|
838
|
+
removed: previous.filter((id) => !after.has(id))
|
|
839
|
+
};
|
|
840
|
+
}
|
|
841
|
+
var NO_CELL_SELECTED = { kind: "none" };
|
|
842
|
+
function isSameCell(a, b) {
|
|
843
|
+
if (a.kind === "none" || b.kind === "none") {
|
|
844
|
+
return a.kind === b.kind;
|
|
845
|
+
}
|
|
846
|
+
return a.rowId === b.rowId && a.columnId === b.columnId;
|
|
847
|
+
}
|
|
848
|
+
function holdsCell(selection, cell) {
|
|
849
|
+
return selection.kind === "cell" && selection.rowId === cell.rowId && selection.columnId === cell.columnId;
|
|
850
|
+
}
|
|
851
|
+
function selectCell(selection, cell, mode) {
|
|
852
|
+
if (mode === false || holdsCell(selection, cell)) {
|
|
853
|
+
return selection;
|
|
854
|
+
}
|
|
855
|
+
return { kind: "cell", rowId: cell.rowId, columnId: cell.columnId };
|
|
856
|
+
}
|
|
857
|
+
function toggleCellSelection(selection, cell, mode) {
|
|
858
|
+
if (mode === false) {
|
|
859
|
+
return selection;
|
|
860
|
+
}
|
|
861
|
+
return holdsCell(selection, cell) ? NO_CELL_SELECTED : { kind: "cell", rowId: cell.rowId, columnId: cell.columnId };
|
|
862
|
+
}
|
|
863
|
+
function clearCellSelection(selection) {
|
|
864
|
+
return selection.kind === "none" ? selection : NO_CELL_SELECTED;
|
|
865
|
+
}
|
|
866
|
+
function intentOf(event, options) {
|
|
867
|
+
if (event.shiftKey) {
|
|
868
|
+
return "range";
|
|
869
|
+
}
|
|
870
|
+
if (event.ctrlKey || event.metaKey) {
|
|
871
|
+
return "toggle";
|
|
872
|
+
}
|
|
873
|
+
return options?.toggleOnClick === true ? "toggle" : "replace";
|
|
874
|
+
}
|
|
875
|
+
function applySelectionIntent(selection, orderedIds, anchorId, id, intent, mode) {
|
|
876
|
+
switch (intent) {
|
|
877
|
+
case "toggle":
|
|
878
|
+
return toggleSelection(selection, id, mode);
|
|
879
|
+
// A range with no anchor yet spans from the id to itself, which is the
|
|
880
|
+
// plain click a first Shift-click may as well be.
|
|
881
|
+
case "range":
|
|
882
|
+
return selectRange(selection, orderedIds, anchorId ?? id, id, mode);
|
|
883
|
+
default:
|
|
884
|
+
return selectOnly(selection, id, mode);
|
|
885
|
+
}
|
|
886
|
+
}
|
|
887
|
+
|
|
786
888
|
// src/util/sizing.ts
|
|
787
889
|
var DEFAULT_COLUMN_SIZES = {
|
|
788
890
|
width: 150,
|
|
@@ -1118,101 +1220,6 @@ function setColumnVisibility(columns, visibility, columnIds, visible) {
|
|
|
1118
1220
|
};
|
|
1119
1221
|
}
|
|
1120
1222
|
|
|
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
1223
|
// src/util/format.ts
|
|
1217
1224
|
var DATE_FIELDS = {
|
|
1218
1225
|
year: "numeric",
|
|
@@ -1663,7 +1670,7 @@ function selectionCopy(source) {
|
|
|
1663
1670
|
return { kind: "columns", columnIds };
|
|
1664
1671
|
}
|
|
1665
1672
|
const cell = state.cellSelection;
|
|
1666
|
-
if (cell
|
|
1673
|
+
if (cell.kind === "cell" && hasRow(source, cell.rowId) && hasColumn(source, cell.columnId)) {
|
|
1667
1674
|
return { kind: "cell", rowId: cell.rowId, columnId: cell.columnId };
|
|
1668
1675
|
}
|
|
1669
1676
|
return null;
|
|
@@ -2887,7 +2894,7 @@ function builtInCommands() {
|
|
|
2887
2894
|
id: "selection.clear",
|
|
2888
2895
|
label: ({ messages }) => messages.clearSelection,
|
|
2889
2896
|
isVisible: (context) => isOn(context, ["grid", "cell", "header"]) && isAnythingSelectable(context.options.selectable),
|
|
2890
|
-
isEnabled: ({ state }) => state.rowSelection.length > 0 || state.columnSelection.length > 0 || state.cellSelection !==
|
|
2897
|
+
isEnabled: ({ state }) => state.rowSelection.length > 0 || state.columnSelection.length > 0 || state.cellSelection.kind !== "none",
|
|
2891
2898
|
execute: ({ actions }) => {
|
|
2892
2899
|
actions.clearSelection();
|
|
2893
2900
|
}
|
|
@@ -3329,6 +3336,19 @@ export {
|
|
|
3329
3336
|
resolveColumns,
|
|
3330
3337
|
resolveCell,
|
|
3331
3338
|
reportError,
|
|
3339
|
+
toggleSelection,
|
|
3340
|
+
selectOnly,
|
|
3341
|
+
selectRange,
|
|
3342
|
+
selectAll,
|
|
3343
|
+
clearSelection,
|
|
3344
|
+
diffSelection,
|
|
3345
|
+
NO_CELL_SELECTED,
|
|
3346
|
+
isSameCell,
|
|
3347
|
+
selectCell,
|
|
3348
|
+
toggleCellSelection,
|
|
3349
|
+
clearCellSelection,
|
|
3350
|
+
intentOf,
|
|
3351
|
+
applySelectionIntent,
|
|
3332
3352
|
DEFAULT_COLUMN_SIZES,
|
|
3333
3353
|
KEYBOARD_STEP,
|
|
3334
3354
|
resolveColumnConstraints,
|
|
@@ -3345,17 +3365,6 @@ export {
|
|
|
3345
3365
|
isColumnVisible,
|
|
3346
3366
|
applyColumnVisibility,
|
|
3347
3367
|
setColumnVisibility,
|
|
3348
|
-
toggleSelection,
|
|
3349
|
-
selectOnly,
|
|
3350
|
-
selectRange,
|
|
3351
|
-
selectAll,
|
|
3352
|
-
clearSelection,
|
|
3353
|
-
diffSelection,
|
|
3354
|
-
isSameCell,
|
|
3355
|
-
selectCell,
|
|
3356
|
-
toggleCellSelection,
|
|
3357
|
-
intentOf,
|
|
3358
|
-
applySelectionIntent,
|
|
3359
3368
|
formatCellValue,
|
|
3360
3369
|
formatAggregateValue,
|
|
3361
3370
|
formatGroupValue,
|
|
@@ -3409,4 +3418,4 @@ export {
|
|
|
3409
3418
|
clampFocus,
|
|
3410
3419
|
nextFocusForKey
|
|
3411
3420
|
};
|
|
3412
|
-
//# sourceMappingURL=chunk-
|
|
3421
|
+
//# sourceMappingURL=chunk-QGKPKQIO.js.map
|