@geotab/zenith 3.16.0-beta.2 → 3.16.0-beta.3
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/README.md +15 -12
- package/dist/absolute/absolute.js +1 -1
- package/dist/chart/plugins/linePlugin/getInterpolatedValue.d.ts +2 -2
- package/dist/chart/plugins/linePlugin/getInterpolatedValue.js +3 -2
- package/dist/chart/plugins/linePlugin/linePlugin.js +2 -1
- package/dist/chart/utils/getFormattedLabel.js +5 -1
- package/dist/checkbox/checkbox.d.ts +2 -1
- package/dist/checkbox/checkbox.js +2 -2
- package/dist/checkboxListWithAction/checkboxListWithAction.js +1 -0
- package/dist/commonHelpers/hooks/useTrapFocus.d.ts +0 -9
- package/dist/commonHelpers/hooks/useTrapFocus.js +14 -66
- package/dist/dataGrid/columns/checkboxColumn/checkboxCell.d.ts +2 -1
- package/dist/dataGrid/columns/checkboxColumn/checkboxCell.js +1 -1
- package/dist/dataGrid/columns/checkboxColumn/checkboxColumnWrapper.d.ts +4 -2
- package/dist/dataGrid/columns/checkboxColumn/checkboxColumnWrapper.js +10 -1
- package/dist/dataGrid/row/row.js +3 -2
- package/dist/dataGrid/withSelectableRows/withSelectableRows.js +73 -12
- package/dist/index.css +1 -1
- package/dist/table/selectable/interfaces.d.ts +9 -13
- package/dist/table/selectable/useDragSelection.d.ts +10 -0
- package/dist/table/selectable/useDragSelection.js +139 -0
- package/dist/table/selectable/useSelectableRows.d.ts +2 -2
- package/dist/table/selectable/useSelectableRows.js +59 -49
- package/dist/table/selectable/utils/calculateSelectionState.js +0 -35
- package/dist/table/selectable/utils/getDragSelectionRows.d.ts +15 -0
- package/dist/table/selectable/utils/getDragSelectionRows.js +28 -0
- package/dist/table/selectable/utils/getRangeIds.d.ts +2 -0
- package/dist/table/selectable/utils/getRangeIds.js +21 -0
- package/dist/table/selectable/utils/isRowChecked.js +1 -12
- package/dist/table/table.js +1 -1
- package/esm/absolute/absolute.js +1 -1
- package/esm/chart/plugins/linePlugin/getInterpolatedValue.d.ts +2 -2
- package/esm/chart/plugins/linePlugin/getInterpolatedValue.js +3 -2
- package/esm/chart/plugins/linePlugin/linePlugin.js +2 -1
- package/esm/chart/utils/getFormattedLabel.js +5 -1
- package/esm/checkbox/checkbox.d.ts +2 -1
- package/esm/checkbox/checkbox.js +2 -2
- package/esm/checkboxListWithAction/checkboxListWithAction.js +1 -0
- package/esm/commonHelpers/hooks/useTrapFocus.d.ts +0 -9
- package/esm/commonHelpers/hooks/useTrapFocus.js +15 -67
- package/esm/dataGrid/columns/checkboxColumn/checkboxCell.d.ts +2 -1
- package/esm/dataGrid/columns/checkboxColumn/checkboxCell.js +1 -1
- package/esm/dataGrid/columns/checkboxColumn/checkboxColumnWrapper.d.ts +4 -2
- package/esm/dataGrid/columns/checkboxColumn/checkboxColumnWrapper.js +10 -1
- package/esm/dataGrid/row/row.js +3 -2
- package/esm/dataGrid/withSelectableRows/withSelectableRows.js +73 -12
- package/esm/table/selectable/interfaces.d.ts +9 -13
- package/esm/table/selectable/useDragSelection.d.ts +10 -0
- package/esm/table/selectable/useDragSelection.js +135 -0
- package/esm/table/selectable/useSelectableRows.d.ts +2 -2
- package/esm/table/selectable/useSelectableRows.js +59 -49
- package/esm/table/selectable/utils/calculateSelectionState.js +0 -35
- package/esm/table/selectable/utils/getDragSelectionRows.d.ts +15 -0
- package/esm/table/selectable/utils/getDragSelectionRows.js +24 -0
- package/esm/table/selectable/utils/getRangeIds.d.ts +2 -0
- package/esm/table/selectable/utils/getRangeIds.js +17 -0
- package/esm/table/selectable/utils/isRowChecked.js +1 -12
- package/esm/table/table.js +1 -1
- package/package.json +1 -1
|
@@ -10,6 +10,8 @@ import { useLanguage } from "../../utils/localization/useLanguage";
|
|
|
10
10
|
import { checkRow } from "./utils/checkRow";
|
|
11
11
|
import { isRowChecked } from "./utils/isRowChecked";
|
|
12
12
|
import { getCurrentPageSelection } from "./utils/getCurrentPageSelection";
|
|
13
|
+
import { useDragSelection } from "./useDragSelection";
|
|
14
|
+
import { getDragSelectionRows } from "./utils/getDragSelectionRows";
|
|
13
15
|
injectString("cs", "Select all", "Vybrat v\u0161e");
|
|
14
16
|
injectString("da-DK", "Select all", "V\xE6lg alle");
|
|
15
17
|
injectString("de", "Select all", "Alle ausw\xE4hlen");
|
|
@@ -83,7 +85,7 @@ export const getEmptySelection = () => ({
|
|
|
83
85
|
export const SelectableWrapperName = "Selectable";
|
|
84
86
|
// Infinite scroll has no pages, so the header checkbox always means "select all" (never current page).
|
|
85
87
|
const resolveCheckboxEmitsCurrentPage = (isInfinite, checkboxSelectsCurrentPage, turnOffSelectAll) => isInfinite ? false : checkboxSelectsCurrentPage !== null && checkboxSelectsCurrentPage !== void 0 ? checkboxSelectsCurrentPage : turnOffSelectAll;
|
|
86
|
-
export const useSelectableRows = (columns, entities, isMobile, selectMode, setSelectMode, selectable, isInfinite = false) => {
|
|
88
|
+
export const useSelectableRows = (columns, entities, isMobile, selectMode, setSelectMode, selectable, isInfinite = false, gridRef, expandedRows) => {
|
|
87
89
|
var _a;
|
|
88
90
|
const {
|
|
89
91
|
translate
|
|
@@ -133,30 +135,19 @@ export const useSelectableRows = (columns, entities, isMobile, selectMode, setSe
|
|
|
133
135
|
}
|
|
134
136
|
}, [checkboxDisabled, checkboxVisible, entities, selectable, setSelectMode, selectable === null || selectable === void 0 ? void 0 : selectable.strategy]);
|
|
135
137
|
const getNewSelection = useCallback((id, checked) => {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
// exclusion set - it must never be rebuilt from `entities` (the current page),
|
|
141
|
-
// otherwise every other page's rows would silently fall out of the selection.
|
|
142
|
-
const excluded = new Set(selections);
|
|
143
|
-
checkRow(excluded, selectable, entities, id, !checked);
|
|
144
|
-
return excluded;
|
|
138
|
+
if (state === SelectionState.All) {
|
|
139
|
+
const newSelection = getCurrentPageSelection(entities, selectable);
|
|
140
|
+
checkRow(newSelection, selectable, entities, id, false);
|
|
141
|
+
return newSelection;
|
|
145
142
|
}
|
|
146
143
|
checkRow(selections, selectable, entities, id, checked);
|
|
147
144
|
return selections;
|
|
148
|
-
}, [entities, selectable, selections]);
|
|
145
|
+
}, [state, entities, selectable, selections]);
|
|
149
146
|
const onSelectListener = useCallback((id, checked) => {
|
|
150
147
|
var _a;
|
|
151
|
-
const wasAllSelected = ((_a = selectable === null || selectable === void 0 ? void 0 : selectable.selection) === null || _a === void 0 ? void 0 : _a.all) || false;
|
|
152
148
|
const newSelection = getNewSelection(id, checked);
|
|
153
|
-
const newState = calculateSelectionState(entities, newSelection,
|
|
154
|
-
|
|
155
|
-
// and only record the exclusion - it must not collapse to the current page's ids.
|
|
156
|
-
const newValue = wasAllSelected ? {
|
|
157
|
-
selected: [...newSelection],
|
|
158
|
-
all: true
|
|
159
|
-
} : {
|
|
149
|
+
const newState = calculateSelectionState(entities, newSelection, ((_a = selectable === null || selectable === void 0 ? void 0 : selectable.selection) === null || _a === void 0 ? void 0 : _a.all) || false, checkboxVisible, checkboxDisabled, selectable === null || selectable === void 0 ? void 0 : selectable.strategy);
|
|
150
|
+
const newValue = {
|
|
160
151
|
selected: [...newSelection],
|
|
161
152
|
all: newState === SelectionState.All
|
|
162
153
|
};
|
|
@@ -164,8 +155,49 @@ export const useSelectableRows = (columns, entities, isMobile, selectMode, setSe
|
|
|
164
155
|
selectable === null || selectable === void 0 ? void 0 : selectable.onSelect(newValue);
|
|
165
156
|
setSelectMode(newValue.all || newValue.selected.length > 0);
|
|
166
157
|
}, [checkboxDisabled, checkboxVisible, entities, selectable, setSelectMode, setState, getNewSelection]);
|
|
158
|
+
const onBatchSelect = useCallback((rangeIds, select, base) => {
|
|
159
|
+
var _a;
|
|
160
|
+
const result = new Set(base);
|
|
161
|
+
const limit = selectable === null || selectable === void 0 ? void 0 : selectable.selectionLimit;
|
|
162
|
+
for (const id of rangeIds) {
|
|
163
|
+
if (select && limit !== undefined && result.size >= limit) {
|
|
164
|
+
break;
|
|
165
|
+
}
|
|
166
|
+
checkRow(result, selectable, entities, id, select);
|
|
167
|
+
}
|
|
168
|
+
const newState = calculateSelectionState(entities, result, ((_a = selectable === null || selectable === void 0 ? void 0 : selectable.selection) === null || _a === void 0 ? void 0 : _a.all) || false, checkboxVisible, checkboxDisabled, selectable === null || selectable === void 0 ? void 0 : selectable.strategy);
|
|
169
|
+
const newValue = {
|
|
170
|
+
selected: [...result],
|
|
171
|
+
all: newState === SelectionState.All
|
|
172
|
+
};
|
|
173
|
+
setState(newState);
|
|
174
|
+
selectable === null || selectable === void 0 ? void 0 : selectable.onSelect(newValue);
|
|
175
|
+
setSelectMode(newValue.all || newValue.selected.length > 0);
|
|
176
|
+
}, [entities, selectable, checkboxVisible, checkboxDisabled, setSelectMode]);
|
|
177
|
+
// Deliberately independent of the current selection, so the drag anchor survives the
|
|
178
|
+
// selection changes a drag itself produces.
|
|
179
|
+
const {
|
|
180
|
+
rows: dragRows,
|
|
181
|
+
entityById
|
|
182
|
+
} = useMemo(() => getDragSelectionRows(entities, expandedRows), [entities, expandedRows]);
|
|
183
|
+
const isSelectable = useCallback(row => {
|
|
184
|
+
const entity = entityById.get(row.id);
|
|
185
|
+
return !!entity && checkboxVisible(entity, row.isNested) && !checkboxDisabled(entity, row.isNested);
|
|
186
|
+
}, [entityById, checkboxVisible, checkboxDisabled]);
|
|
187
|
+
const getBaseSelection = useCallback(() => state === SelectionState.All ? getCurrentPageSelection(entities, selectable) : new Set(selections), [state, entities, selectable, selections]);
|
|
188
|
+
const {
|
|
189
|
+
onCheckboxMouseDown,
|
|
190
|
+
suppressNextChangeRef
|
|
191
|
+
} = useDragSelection(dragRows, gridRef, onBatchSelect, getBaseSelection, isSelectable, !!selectable);
|
|
192
|
+
const onCheckboxChange = useCallback((id, checked) => {
|
|
193
|
+
if (suppressNextChangeRef.current) {
|
|
194
|
+
suppressNextChangeRef.current = false;
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
onSelectListener(id, checked);
|
|
198
|
+
}, [onSelectListener, suppressNextChangeRef]);
|
|
167
199
|
const onChangeSelectionState = useCallback(newState => {
|
|
168
|
-
var _a, _b
|
|
200
|
+
var _a, _b;
|
|
169
201
|
if (newState === SelectionState.All) {
|
|
170
202
|
(selectable === null || selectable === void 0 ? void 0 : selectable.onSelect) && selectable.onSelect({
|
|
171
203
|
selected: [],
|
|
@@ -184,11 +216,7 @@ export const useSelectableRows = (columns, entities, isMobile, selectMode, setSe
|
|
|
184
216
|
}
|
|
185
217
|
const newSelections = getCurrentPageSelection(entities, selectable);
|
|
186
218
|
setState(newState);
|
|
187
|
-
|
|
188
|
-
// included ids when `all` is false, excluded ids when `all` is true. Switching to an
|
|
189
|
-
// explicit "select current page" here always leaves `all: false`, so a previous
|
|
190
|
-
// exclusion list must not be reinterpreted as an inclusion list.
|
|
191
|
-
const previousSelections = ((_a = selectable === null || selectable === void 0 ? void 0 : selectable.selection) === null || _a === void 0 ? void 0 : _a.all) ? [] : (_c = (_b = selectable === null || selectable === void 0 ? void 0 : selectable.selection) === null || _b === void 0 ? void 0 : _b.selected) !== null && _c !== void 0 ? _c : [];
|
|
219
|
+
const previousSelections = (_b = (_a = selectable === null || selectable === void 0 ? void 0 : selectable.selection) === null || _a === void 0 ? void 0 : _a.selected) !== null && _b !== void 0 ? _b : [];
|
|
192
220
|
const mergedSelections = new Set([...previousSelections, ...newSelections]);
|
|
193
221
|
const newValue = {
|
|
194
222
|
selected: [...mergedSelections],
|
|
@@ -207,12 +235,7 @@ export const useSelectableRows = (columns, entities, isMobile, selectMode, setSe
|
|
|
207
235
|
}
|
|
208
236
|
return translate("Deselect all");
|
|
209
237
|
}, [selectable, selectableState, state, translate]);
|
|
210
|
-
const isEntityChecked = useCallback(
|
|
211
|
-
// MYG-142234: while `selection.all` is true, `selections` holds excluded ids, and every
|
|
212
|
-
// row must be evaluated through the SelectionState.All (exclusion-aware) branch of
|
|
213
|
-
// isRowChecked - not the per-page `state`, which can be Partial/None for a page that
|
|
214
|
-
// contains some of those exclusions.
|
|
215
|
-
(entity, isNested) => isRowChecked(selections, isAllSelected ? SelectionState.All : state, selectable === null || selectable === void 0 ? void 0 : selectable.strategy, entity, isNested), [selections, isAllSelected, state, selectable === null || selectable === void 0 ? void 0 : selectable.strategy]);
|
|
238
|
+
const isEntityChecked = useCallback((entity, isNested) => isRowChecked(selections, state, selectable === null || selectable === void 0 ? void 0 : selectable.strategy, entity, isNested), [selections, state, selectable === null || selectable === void 0 ? void 0 : selectable.strategy]);
|
|
216
239
|
const hasSelectable = !!selectable;
|
|
217
240
|
const selectableCheckboxSelectsCurrentPage = selectable === null || selectable === void 0 ? void 0 : selectable.checkboxSelectsCurrentPage;
|
|
218
241
|
const selectableTurnOffSelectAll = selectable === null || selectable === void 0 ? void 0 : selectable.turnOffSelectAll;
|
|
@@ -250,7 +273,8 @@ export const useSelectableRows = (columns, entities, isMobile, selectMode, setSe
|
|
|
250
273
|
indeterminate: checked.indeterminate,
|
|
251
274
|
disabled: isDisable,
|
|
252
275
|
label: checkboxTitle(entity),
|
|
253
|
-
onChange:
|
|
276
|
+
onChange: onCheckboxChange,
|
|
277
|
+
onMouseDown: isDisable ? undefined : onCheckboxMouseDown,
|
|
254
278
|
children: _jsx(CheckboxCell.Content, {
|
|
255
279
|
children: value
|
|
256
280
|
})
|
|
@@ -264,30 +288,16 @@ export const useSelectableRows = (columns, entities, isMobile, selectMode, setSe
|
|
|
264
288
|
checked: state === SelectionState.CurrentPage || state === SelectionState.All,
|
|
265
289
|
indeterminate: state === SelectionState.Partial,
|
|
266
290
|
onChange: newValue => {
|
|
267
|
-
var _a, _b
|
|
291
|
+
var _a, _b;
|
|
268
292
|
if (newValue) {
|
|
269
293
|
const newState = checkboxEmitsCurrentPage ? SelectionState.CurrentPage : SelectionState.All;
|
|
270
294
|
setState(newState);
|
|
271
295
|
onChangeSelectionState(newState);
|
|
272
|
-
} else if ((_a = selectable.selection) === null || _a === void 0 ? void 0 : _a.all) {
|
|
273
|
-
// MYG-142234: in exclusion mode, `selected` holds excluded ids. Unchecking
|
|
274
|
-
// the header must add the current page's ids to that exclusion set and
|
|
275
|
-
// keep `all: true` - it must never be treated as an inclusion list, or
|
|
276
|
-
// every other page's selection would be silently wiped out.
|
|
277
|
-
const currentPageIds = getCurrentPageSelection(entities, selectable);
|
|
278
|
-
const newExcluded = new Set([...selectable.selection.selected, ...currentPageIds]);
|
|
279
|
-
const newState = calculateSelectionState(entities, newExcluded, true, checkboxVisible, checkboxDisabled, selectable.strategy);
|
|
280
|
-
setState(newState);
|
|
281
|
-
selectable.onSelect({
|
|
282
|
-
selected: [...newExcluded],
|
|
283
|
-
all: true
|
|
284
|
-
});
|
|
285
|
-
setSelectMode(true);
|
|
286
296
|
} else {
|
|
287
297
|
// Intentionally different from onSelect(None) ("Deselect all" menu item, which clears everything).
|
|
288
298
|
// Unchecking the header checkbox only removes the current page from the selection, preserving other pages.
|
|
289
299
|
const currentPageIds = getCurrentPageSelection(entities, selectable);
|
|
290
|
-
const remaining = ((
|
|
300
|
+
const remaining = ((_b = (_a = selectable.selection) === null || _a === void 0 ? void 0 : _a.selected) !== null && _b !== void 0 ? _b : []).filter(id => !currentPageIds.has(id));
|
|
291
301
|
const newState = remaining.length > 0 ? SelectionState.Partial : SelectionState.None;
|
|
292
302
|
setState(newState);
|
|
293
303
|
selectable.onSelect({
|
|
@@ -310,7 +320,7 @@ export const useSelectableRows = (columns, entities, isMobile, selectMode, setSe
|
|
|
310
320
|
return cell;
|
|
311
321
|
}
|
|
312
322
|
};
|
|
313
|
-
}, [checkboxDisabled, checkboxTitle, checkboxVisible, headerTitle, onChangeSelectionState,
|
|
323
|
+
}, [checkboxDisabled, checkboxTitle, checkboxVisible, headerTitle, onChangeSelectionState, onCheckboxChange, onCheckboxMouseDown, hasSelectable, checkboxEmitsCurrentPage, checkboxInHeaderValue, selectableHeader, selectableTurnOffSelectAll, isInfinite, selectable, selectableState, state, isMobile, checkboxPlaceholder, isEntityChecked, entities, setSelectMode]);
|
|
314
324
|
const selectableFeedWrapper = useCallback((primaryData, secondaryData, entity, isNested) => {
|
|
315
325
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
316
326
|
if (!entity) {
|
|
@@ -3,41 +3,6 @@ export const calculateSelectionState = (entities, selections, all, checkboxVisib
|
|
|
3
3
|
if (selections.size === 0) {
|
|
4
4
|
return all ? SelectionState.All : SelectionState.None;
|
|
5
5
|
}
|
|
6
|
-
if (all) {
|
|
7
|
-
// When `all` is true, `selections` holds the ids explicitly excluded from the
|
|
8
|
-
// otherwise-fully-selected set (see ISelectionValue), rather than included ids.
|
|
9
|
-
const isExcluded = (entity) => {
|
|
10
|
-
if (strategy === "nested" && entity.children) {
|
|
11
|
-
if (entity.children.length === 0) {
|
|
12
|
-
return false;
|
|
13
|
-
}
|
|
14
|
-
return entity.children.every(child => {
|
|
15
|
-
if (!checkboxVisible(child)) {
|
|
16
|
-
return true;
|
|
17
|
-
}
|
|
18
|
-
if (checkboxDisabled(child)) {
|
|
19
|
-
return true;
|
|
20
|
-
}
|
|
21
|
-
return selections.has(child.id);
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
return selections.has(entity.id);
|
|
25
|
-
};
|
|
26
|
-
const isPartiallyExcluded = (entity) => {
|
|
27
|
-
if (strategy === "nested" && entity.children) {
|
|
28
|
-
return entity.children.some(child => selections.has(child.id));
|
|
29
|
-
}
|
|
30
|
-
return selections.has(entity.id);
|
|
31
|
-
};
|
|
32
|
-
const relevantEntities = entities.filter(entity => checkboxVisible(entity) && !checkboxDisabled(entity));
|
|
33
|
-
if (relevantEntities.length === 0) {
|
|
34
|
-
return SelectionState.All;
|
|
35
|
-
}
|
|
36
|
-
if (relevantEntities.every(entity => !isPartiallyExcluded(entity))) {
|
|
37
|
-
return SelectionState.All;
|
|
38
|
-
}
|
|
39
|
-
return relevantEntities.every(entity => isExcluded(entity)) ? SelectionState.None : SelectionState.Partial;
|
|
40
|
-
}
|
|
41
6
|
return entities.every(entity => {
|
|
42
7
|
if (!checkboxVisible(entity)) {
|
|
43
8
|
return true;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { IEntityWithId } from "../../../commonHelpers/entity";
|
|
2
|
+
import { IRowEntity } from "../../../dataGrid/row/row";
|
|
3
|
+
import { IDragSelectionRow } from "../interfaces";
|
|
4
|
+
export interface IDragSelection<T> {
|
|
5
|
+
/** The rows in render order. */
|
|
6
|
+
rows: IDragSelectionRow[];
|
|
7
|
+
/** Every entity a row can point at, parents and children alike. */
|
|
8
|
+
entityById: Map<string, T>;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Flattens the entities into the rows the grid actually renders: each entity followed by its
|
|
12
|
+
* children while it is expanded. Drag and shift-click ranges walk this list, so they cross
|
|
13
|
+
* nesting levels the way the user sees them on screen.
|
|
14
|
+
*/
|
|
15
|
+
export declare const getDragSelectionRows: <T extends IRowEntity<N>, N extends IEntityWithId>(entities: T[], expandedRows?: string[]) => IDragSelection<T | N>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Flattens the entities into the rows the grid actually renders: each entity followed by its
|
|
3
|
+
* children while it is expanded. Drag and shift-click ranges walk this list, so they cross
|
|
4
|
+
* nesting levels the way the user sees them on screen.
|
|
5
|
+
*/
|
|
6
|
+
export const getDragSelectionRows = (entities, expandedRows) => {
|
|
7
|
+
const expanded = new Set(expandedRows);
|
|
8
|
+
const rows = [];
|
|
9
|
+
const entityById = new Map();
|
|
10
|
+
entities.forEach(entity => {
|
|
11
|
+
rows.push({ id: entity.id, isNested: false });
|
|
12
|
+
entityById.set(entity.id, entity);
|
|
13
|
+
// Children are always indexed — a collapsed row's children still need to resolve for
|
|
14
|
+
// the selection predicates — but only an expanded row contributes them to the range.
|
|
15
|
+
const isExpanded = expanded.has(entity.id);
|
|
16
|
+
(entity.children || []).forEach(child => {
|
|
17
|
+
entityById.set(child.id, child);
|
|
18
|
+
if (isExpanded) {
|
|
19
|
+
rows.push({ id: child.id, isNested: true });
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
return { rows, entityById };
|
|
24
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export const getRangeIds = (rows, fromId, toId, isSelectable) => {
|
|
2
|
+
const fromIdx = rows.findIndex(row => row.id === fromId);
|
|
3
|
+
const toIdx = rows.findIndex(row => row.id === toId);
|
|
4
|
+
if (fromIdx === -1 || toIdx === -1) {
|
|
5
|
+
return [];
|
|
6
|
+
}
|
|
7
|
+
const start = Math.min(fromIdx, toIdx);
|
|
8
|
+
const end = Math.max(fromIdx, toIdx);
|
|
9
|
+
const ids = [];
|
|
10
|
+
for (let i = start; i <= end; i++) {
|
|
11
|
+
const row = rows[i];
|
|
12
|
+
if (isSelectable(row)) {
|
|
13
|
+
ids.push(row.id);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return ids;
|
|
17
|
+
};
|
|
@@ -1,18 +1,7 @@
|
|
|
1
1
|
import { SelectionState } from "../interfaces";
|
|
2
2
|
export const isRowChecked = (selections, state, strategy, entity, isNested) => {
|
|
3
3
|
if (state === SelectionState.All) {
|
|
4
|
-
|
|
5
|
-
// explicitly excluded from that selection (see ISelectionValue), not included ids.
|
|
6
|
-
if (isNested) {
|
|
7
|
-
return { indeterminate: false, checked: !selections.has(entity.id) };
|
|
8
|
-
}
|
|
9
|
-
const mainEntity = entity;
|
|
10
|
-
if (strategy === "nested" && mainEntity.children && mainEntity.children.length > 0) {
|
|
11
|
-
const allChildrenChecked = mainEntity.children.every(child => !selections.has(child.id));
|
|
12
|
-
const someChildrenChecked = mainEntity.children.some(child => !selections.has(child.id));
|
|
13
|
-
return { indeterminate: someChildrenChecked && !allChildrenChecked, checked: allChildrenChecked };
|
|
14
|
-
}
|
|
15
|
-
return { indeterminate: false, checked: !selections.has(entity.id) };
|
|
4
|
+
return { indeterminate: false, checked: true };
|
|
16
5
|
}
|
|
17
6
|
if (isNested) {
|
|
18
7
|
return { indeterminate: false, checked: selections.has(entity.id) };
|
package/esm/table/table.js
CHANGED
|
@@ -238,7 +238,7 @@ const TableInner = ({
|
|
|
238
238
|
const {
|
|
239
239
|
selectableColumns,
|
|
240
240
|
selectableFeedWrapper
|
|
241
|
-
} = useSelectableRows(nestedColumns, entities, isMobile, selectMode, setMobileSelectMode, isLoading ? undefined : selectable, isInfinite);
|
|
241
|
+
} = useSelectableRows(nestedColumns, entities, isMobile, selectMode, setMobileSelectMode, isLoading ? undefined : selectable, isInfinite, gridRef, expanded);
|
|
242
242
|
const {
|
|
243
243
|
sortableColumns,
|
|
244
244
|
feedSortControl
|