@omnigrid/selection-plugin 0.1.9 → 0.1.10
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.js +21 -6
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -25,7 +25,7 @@ export class SelectionPlugin {
|
|
|
25
25
|
this.checkboxRenderer = options.checkboxRenderer ?? defaultCheckboxRenderer;
|
|
26
26
|
this.onSelectionChange = options.onSelectionChange;
|
|
27
27
|
this.selectionColumnId = options.selectionColumnId ?? CHECKBOX_COLUMN_DEFAULT_ID;
|
|
28
|
-
this.selectionColumnWidth = options.selectionColumnWidth ??
|
|
28
|
+
this.selectionColumnWidth = options.selectionColumnWidth ?? 40;
|
|
29
29
|
}
|
|
30
30
|
register(api) {
|
|
31
31
|
this.api = api;
|
|
@@ -78,9 +78,13 @@ export class SelectionPlugin {
|
|
|
78
78
|
if (!this.api)
|
|
79
79
|
return [];
|
|
80
80
|
if (this.groupSelection !== "none" && this.api.getRowHierarchy()) {
|
|
81
|
-
return this.api
|
|
81
|
+
return this.api
|
|
82
|
+
.getState()
|
|
83
|
+
.data.filter((row, index) => this.selectedRowIds.has(this.api.getRowId(row, index)));
|
|
82
84
|
}
|
|
83
|
-
return this.api
|
|
85
|
+
return this.api
|
|
86
|
+
.getProcessedData()
|
|
87
|
+
.filter((row, index) => this.selectedRowIds.has(this.api.getRowId(row, index)));
|
|
84
88
|
}
|
|
85
89
|
/**
|
|
86
90
|
* Returns selected row IDs and row data together.
|
|
@@ -122,7 +126,10 @@ export class SelectionPlugin {
|
|
|
122
126
|
const row = this.api.getProcessedData()[index];
|
|
123
127
|
if (!row || !this.isRowSelectable(row, index))
|
|
124
128
|
return;
|
|
125
|
-
if (this.mode === "single" &&
|
|
129
|
+
if (this.mode === "single" &&
|
|
130
|
+
!this.replaceSelectionOnClick &&
|
|
131
|
+
this.selectedRowIds.has(rowId) &&
|
|
132
|
+
!modifiers.shiftKey) {
|
|
126
133
|
this.selectedRowIds.delete(rowId);
|
|
127
134
|
this.anchorIndex = index;
|
|
128
135
|
this.refresh();
|
|
@@ -207,7 +214,11 @@ export class SelectionPlugin {
|
|
|
207
214
|
const allDescendants = hierarchy?.getLeafRowIds(rowId, "all");
|
|
208
215
|
const isGroup = allDescendants !== undefined;
|
|
209
216
|
if (!isGroup) {
|
|
210
|
-
const row = hierarchy
|
|
217
|
+
const row = hierarchy
|
|
218
|
+
? this.getRowByStableId(rowId)
|
|
219
|
+
: data !== undefined
|
|
220
|
+
? { data, index }
|
|
221
|
+
: undefined;
|
|
211
222
|
const selectable = row !== undefined && this.isRowSelectable(row.data, row.index);
|
|
212
223
|
return {
|
|
213
224
|
checked: this.selectedRowIds.has(rowId),
|
|
@@ -262,7 +273,10 @@ export class SelectionPlugin {
|
|
|
262
273
|
const row = processedData[index];
|
|
263
274
|
if (!row || !this.isRowSelectable(row, index))
|
|
264
275
|
return;
|
|
265
|
-
if (this.mode === "single" &&
|
|
276
|
+
if (this.mode === "single" &&
|
|
277
|
+
!this.replaceSelectionOnClick &&
|
|
278
|
+
this.selectedRowIds.has(rowId) &&
|
|
279
|
+
!modifiers.shiftKey) {
|
|
266
280
|
this.selectedRowIds.delete(rowId);
|
|
267
281
|
this.anchorIndex = index;
|
|
268
282
|
this.refresh();
|
|
@@ -314,6 +328,7 @@ export class SelectionPlugin {
|
|
|
314
328
|
maxWidth: this.selectionColumnWidth,
|
|
315
329
|
align: "center",
|
|
316
330
|
sortable: false,
|
|
331
|
+
filterable: false,
|
|
317
332
|
stopHeaderClick: true,
|
|
318
333
|
stopRowClick: true,
|
|
319
334
|
// The checkbox column must always stay pinned to the left.
|