@infinite-table/infinite-react 0.4.7 → 0.4.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/index.d.ts +8 -1
- package/index.esm.js +133 -18
- package/index.js +133 -18
- package/package.json +2 -2
package/index.d.ts
CHANGED
|
@@ -663,9 +663,11 @@ declare type RowSelectionStateObject = {
|
|
|
663
663
|
declare type RowSelectionStateConfig<T> = {
|
|
664
664
|
groupBy: DataSourceState<T>['groupBy'];
|
|
665
665
|
groupDeepMap: DataSourceState<T>['groupDeepMap'];
|
|
666
|
+
toPrimaryKey: DataSourceState<T>['toPrimaryKey'];
|
|
666
667
|
totalCount: number;
|
|
667
668
|
indexer: DataSourceState<T>['indexer'];
|
|
668
669
|
lazyLoad: boolean;
|
|
670
|
+
onlyUsePrimaryKeys: boolean;
|
|
669
671
|
};
|
|
670
672
|
declare type GetRowSelectionStateConfig<T> = () => RowSelectionStateConfig<T>;
|
|
671
673
|
declare type RowSelectionStateOverrideForTesting = {
|
|
@@ -673,6 +675,7 @@ declare type RowSelectionStateOverrideForTesting = {
|
|
|
673
675
|
getGroupByLength: RowSelectionState<any>['getGroupByLength'];
|
|
674
676
|
getGroupCount: RowSelectionState<any>['getGroupCount'];
|
|
675
677
|
getGroupKeysDirectlyInsideGroup: RowSelectionState<any>['getGroupKeysDirectlyInsideGroup'];
|
|
678
|
+
getAllPrimaryKeysInsideGroup: RowSelectionState<any>['getAllPrimaryKeysInsideGroup'];
|
|
676
679
|
};
|
|
677
680
|
declare class RowSelectionState<T = any> {
|
|
678
681
|
selectedRows: RowSelectionStateItem | null;
|
|
@@ -680,6 +683,7 @@ declare class RowSelectionState<T = any> {
|
|
|
680
683
|
defaultSelection: boolean;
|
|
681
684
|
selectedMap: DeepMap<any, true>;
|
|
682
685
|
deselectedMap: DeepMap<any, true>;
|
|
686
|
+
onlyUsePrimaryKeys: boolean;
|
|
683
687
|
selectionCache: DeepMap<any, boolean | null>;
|
|
684
688
|
selectionCountCache: DeepMap<any, {
|
|
685
689
|
selectedCount: number;
|
|
@@ -690,6 +694,7 @@ declare class RowSelectionState<T = any> {
|
|
|
690
694
|
getGroupDeepMap(): DeepMap<any, DeepMapGroupValueType<T, any>> | undefined;
|
|
691
695
|
getGroupCount(groupKeys: any[]): number;
|
|
692
696
|
getGroupKeysDirectlyInsideGroup(groupKeys: any[]): any[][];
|
|
697
|
+
getAllPrimaryKeysInsideGroup(groupKeys: any[]): any[];
|
|
693
698
|
getGroupByLength(): number;
|
|
694
699
|
static from<T>(rowSeleStateObject: RowSelectionStateObject, getConfig: GetRowSelectionStateConfig<T>, _forTestingOnly?: RowSelectionStateOverrideForTesting): RowSelectionState<T>;
|
|
695
700
|
constructor(state: RowSelectionStateObject | RowSelectionState, getConfig: GetRowSelectionStateConfig<T>, _forTestingOnly?: RowSelectionStateOverrideForTesting);
|
|
@@ -1155,6 +1160,7 @@ interface DataSourceMappedState<T> {
|
|
|
1155
1160
|
livePagination: DataSourceProps<T>['livePagination'];
|
|
1156
1161
|
isRowSelected: DataSourceProps<T>['isRowSelected'];
|
|
1157
1162
|
lazyLoad: DataSourceProps<T>['lazyLoad'];
|
|
1163
|
+
useGroupKeysForMultiRowSelection: NonUndefined<DataSourceProps<T>['useGroupKeysForMultiRowSelection']>;
|
|
1158
1164
|
onDataParamsChange: DataSourceProps<T>['onDataParamsChange'];
|
|
1159
1165
|
data: DataSourceProps<T>['data'];
|
|
1160
1166
|
sortMode: DataSourceProps<T>['sortMode'];
|
|
@@ -1267,6 +1273,7 @@ declare type DataSourceProps<T> = {
|
|
|
1267
1273
|
fields?: (keyof T)[];
|
|
1268
1274
|
data: DataSourceData<T>;
|
|
1269
1275
|
selectionMode?: DataSourcePropSelectionMode;
|
|
1276
|
+
useGroupKeysForMultiRowSelection?: boolean;
|
|
1270
1277
|
rowSelection?: DataSourcePropRowSelection_MultiRow | DataSourcePropRowSelection_SingleRow;
|
|
1271
1278
|
defaultRowSelection?: DataSourcePropRowSelection_MultiRow | DataSourcePropRowSelection_SingleRow;
|
|
1272
1279
|
cellSelection?: DataSourcePropCellSelection;
|
|
@@ -1703,7 +1710,7 @@ declare type InfiniteTableSelectionApi = {
|
|
|
1703
1710
|
deselectGroupRow(groupKeys: any[], children?: ArrayOfIds): void;
|
|
1704
1711
|
toggleGroupRowSelection(groupKeys: any[], children?: ArrayOfIds): void;
|
|
1705
1712
|
getGroupRowSelectionState(groupKeys: any[]): boolean | null;
|
|
1706
|
-
getSelectedPrimaryKeys(): (string | number)[];
|
|
1713
|
+
getSelectedPrimaryKeys(rowSelection?: RowSelectionStateObject): (string | number)[];
|
|
1707
1714
|
selectAll(): void;
|
|
1708
1715
|
deselectAll(): void;
|
|
1709
1716
|
};
|
package/index.esm.js
CHANGED
|
@@ -8894,11 +8894,16 @@ var RowSelectionState = class {
|
|
|
8894
8894
|
this.defaultSelection = false;
|
|
8895
8895
|
this.selectedMap = new DeepMap();
|
|
8896
8896
|
this.deselectedMap = new DeepMap();
|
|
8897
|
+
this.onlyUsePrimaryKeys = false;
|
|
8897
8898
|
this.selectionCache = new DeepMap();
|
|
8898
8899
|
this.selectionCountCache = new DeepMap();
|
|
8899
8900
|
this.mapSet = (name, key) => {
|
|
8900
8901
|
if (!Array.isArray(key)) {
|
|
8901
|
-
|
|
8902
|
+
if (this.onlyUsePrimaryKeys) {
|
|
8903
|
+
key = [key];
|
|
8904
|
+
} else {
|
|
8905
|
+
key = [...this.getGroupKeysForPrimaryKey(key), key];
|
|
8906
|
+
}
|
|
8902
8907
|
}
|
|
8903
8908
|
this.xcache();
|
|
8904
8909
|
if (name === "selected") {
|
|
@@ -8915,6 +8920,7 @@ var RowSelectionState = class {
|
|
|
8915
8920
|
};
|
|
8916
8921
|
const stateObject = state instanceof Object.getPrototypeOf(this).constructor ? state.getState() : state;
|
|
8917
8922
|
this.getConfig = getConfig;
|
|
8923
|
+
this.onlyUsePrimaryKeys = getConfig().onlyUsePrimaryKeys;
|
|
8918
8924
|
if (_forTestingOnly) {
|
|
8919
8925
|
Object.assign(this, _forTestingOnly);
|
|
8920
8926
|
}
|
|
@@ -8944,6 +8950,15 @@ var RowSelectionState = class {
|
|
|
8944
8950
|
const { groupDeepMap } = this.getConfig();
|
|
8945
8951
|
return (groupDeepMap == null ? void 0 : groupDeepMap.getKeysStartingWith(groupKeys, true, 1)) || [];
|
|
8946
8952
|
}
|
|
8953
|
+
getAllPrimaryKeysInsideGroup(groupKeys) {
|
|
8954
|
+
const { groupDeepMap } = this.getConfig();
|
|
8955
|
+
if (!groupKeys.length) {
|
|
8956
|
+
const topLevelKeys = (groupDeepMap == null ? void 0 : groupDeepMap.getKeysStartingWith([], true, 1)) || [];
|
|
8957
|
+
return topLevelKeys.map((groupKeys2) => this.getAllPrimaryKeysInsideGroup(groupKeys2)).flat();
|
|
8958
|
+
}
|
|
8959
|
+
const group2 = groupDeepMap == null ? void 0 : groupDeepMap.get(groupKeys);
|
|
8960
|
+
return group2 ? group2.items.map(this.getConfig().toPrimaryKey) : [];
|
|
8961
|
+
}
|
|
8947
8962
|
getGroupByLength() {
|
|
8948
8963
|
return this.getConfig().groupBy.length;
|
|
8949
8964
|
}
|
|
@@ -8968,7 +8983,12 @@ var RowSelectionState = class {
|
|
|
8968
8983
|
getState() {
|
|
8969
8984
|
const normalize = (allKeys) => {
|
|
8970
8985
|
const groupByLength = this.getGroupByLength();
|
|
8971
|
-
return allKeys.map((keys) =>
|
|
8986
|
+
return allKeys.map((keys) => {
|
|
8987
|
+
if (this.onlyUsePrimaryKeys) {
|
|
8988
|
+
return keys[0];
|
|
8989
|
+
}
|
|
8990
|
+
return keys.length > groupByLength ? keys.pop() : keys;
|
|
8991
|
+
});
|
|
8972
8992
|
};
|
|
8973
8993
|
const selectedRows = normalize(this.selectedMap.topDownKeys());
|
|
8974
8994
|
const deselectedRows = normalize(this.deselectedMap.topDownKeys());
|
|
@@ -8999,6 +9019,9 @@ var RowSelectionState = class {
|
|
|
8999
9019
|
return this.defaultSelection === false;
|
|
9000
9020
|
}
|
|
9001
9021
|
isRowSelected(key, groupKeys) {
|
|
9022
|
+
if (this.onlyUsePrimaryKeys) {
|
|
9023
|
+
return this.defaultSelection ? !this.deselectedMap.has([key]) : this.selectedMap.has([key]);
|
|
9024
|
+
}
|
|
9002
9025
|
groupKeys = groupKeys || this.getGroupKeysForPrimaryKey(key);
|
|
9003
9026
|
const finalKey = [...groupKeys, key];
|
|
9004
9027
|
const cachedResult = this.selectionCache.get(finalKey);
|
|
@@ -9055,7 +9078,7 @@ var RowSelectionState = class {
|
|
|
9055
9078
|
if (cachedResult !== void 0) {
|
|
9056
9079
|
return cachedResult;
|
|
9057
9080
|
}
|
|
9058
|
-
const { selectedCount, deselectedCount } = this.getSelectionCountFor(initialGroupKeys, this.getGroupRowBooleanSelectionStateFromParent(initialGroupKeys));
|
|
9081
|
+
const { selectedCount, deselectedCount } = this.getSelectionCountFor(initialGroupKeys, this.onlyUsePrimaryKeys ? void 0 : this.getGroupRowBooleanSelectionStateFromParent(initialGroupKeys));
|
|
9059
9082
|
const result = selectedCount && deselectedCount ? null : selectedCount ? true : false;
|
|
9060
9083
|
this.selectionCache.set(initialGroupKeys, result);
|
|
9061
9084
|
return result;
|
|
@@ -9096,28 +9119,67 @@ var RowSelectionState = class {
|
|
|
9096
9119
|
return this.getGroupRowSelectionState(groupKeys) === false;
|
|
9097
9120
|
}
|
|
9098
9121
|
selectGroupRow(groupKeys) {
|
|
9122
|
+
if (this.onlyUsePrimaryKeys) {
|
|
9123
|
+
const keys = this.getAllPrimaryKeysInsideGroup(groupKeys);
|
|
9124
|
+
keys.forEach((key) => {
|
|
9125
|
+
if (this.defaultSelection === true) {
|
|
9126
|
+
this.deselectedMap.delete([key]);
|
|
9127
|
+
} else {
|
|
9128
|
+
this._selectedMapSet(key);
|
|
9129
|
+
}
|
|
9130
|
+
});
|
|
9131
|
+
this.xcache();
|
|
9132
|
+
return;
|
|
9133
|
+
}
|
|
9099
9134
|
const selectedKeys = this.selectedMap.getKeysStartingWith(groupKeys, true);
|
|
9100
9135
|
selectedKeys.forEach((groupKeys2) => {
|
|
9101
9136
|
this.selectedMap.delete(groupKeys2);
|
|
9102
9137
|
});
|
|
9103
|
-
this.
|
|
9138
|
+
if (groupKeys.length === 1 && this.defaultSelection === true) {
|
|
9139
|
+
} else {
|
|
9140
|
+
this._selectedMapSet(groupKeys);
|
|
9141
|
+
}
|
|
9104
9142
|
const deselectedKeys = this.deselectedMap.getKeysStartingWith(groupKeys);
|
|
9105
9143
|
deselectedKeys.forEach((groupKeys2) => {
|
|
9106
9144
|
this.deselectedMap.delete(groupKeys2);
|
|
9107
9145
|
});
|
|
9108
9146
|
}
|
|
9109
9147
|
deselectGroupRow(groupKeys) {
|
|
9148
|
+
if (this.onlyUsePrimaryKeys) {
|
|
9149
|
+
const keys = this.getAllPrimaryKeysInsideGroup(groupKeys);
|
|
9150
|
+
keys.forEach((key) => {
|
|
9151
|
+
if (this.defaultSelection === false) {
|
|
9152
|
+
this.selectedMap.delete([key]);
|
|
9153
|
+
} else {
|
|
9154
|
+
this._deselectedMapSet(key);
|
|
9155
|
+
}
|
|
9156
|
+
});
|
|
9157
|
+
this.xcache();
|
|
9158
|
+
return;
|
|
9159
|
+
}
|
|
9110
9160
|
const deselectedKeys = this.deselectedMap.getKeysStartingWith(groupKeys, true);
|
|
9111
9161
|
deselectedKeys.forEach((groupKeys2) => {
|
|
9112
9162
|
this.deselectedMap.delete(groupKeys2);
|
|
9113
9163
|
});
|
|
9114
|
-
this.
|
|
9164
|
+
if (groupKeys.length === 1 && this.defaultSelection === false) {
|
|
9165
|
+
} else {
|
|
9166
|
+
this._deselectedMapSet(groupKeys);
|
|
9167
|
+
}
|
|
9115
9168
|
const selectedKeys = this.selectedMap.getKeysStartingWith(groupKeys);
|
|
9116
9169
|
selectedKeys.forEach((groupKeys2) => {
|
|
9117
9170
|
this.selectedMap.delete(groupKeys2);
|
|
9118
9171
|
});
|
|
9119
9172
|
}
|
|
9120
9173
|
setRowAsSelected(key, groupKeys) {
|
|
9174
|
+
if (this.onlyUsePrimaryKeys) {
|
|
9175
|
+
if (this.defaultSelection) {
|
|
9176
|
+
this.deselectedMap.delete([key]);
|
|
9177
|
+
} else {
|
|
9178
|
+
this._selectedMapSet(key);
|
|
9179
|
+
}
|
|
9180
|
+
this.xcache();
|
|
9181
|
+
return;
|
|
9182
|
+
}
|
|
9121
9183
|
groupKeys = groupKeys || this.getGroupKeysForPrimaryKey(key);
|
|
9122
9184
|
const finalKey = [...groupKeys, key];
|
|
9123
9185
|
this.deselectedMap.delete(finalKey);
|
|
@@ -9130,9 +9192,19 @@ var RowSelectionState = class {
|
|
|
9130
9192
|
}
|
|
9131
9193
|
}
|
|
9132
9194
|
setRowAsDeselected(key, groupKeys) {
|
|
9195
|
+
if (this.onlyUsePrimaryKeys) {
|
|
9196
|
+
if (this.defaultSelection) {
|
|
9197
|
+
this._deselectedMapSet(key);
|
|
9198
|
+
} else {
|
|
9199
|
+
this.selectedMap.delete([key]);
|
|
9200
|
+
}
|
|
9201
|
+
this.xcache();
|
|
9202
|
+
return;
|
|
9203
|
+
}
|
|
9133
9204
|
groupKeys = groupKeys || this.getGroupKeysForPrimaryKey(key);
|
|
9134
9205
|
const finalKey = [...groupKeys, key];
|
|
9135
9206
|
this.selectedMap.delete(finalKey);
|
|
9207
|
+
this.xcache();
|
|
9136
9208
|
if (this.getGroupRowSelectionState(groupKeys) !== false) {
|
|
9137
9209
|
this._deselectedMapSet(finalKey);
|
|
9138
9210
|
if (this.getGroupRowSelectionState(groupKeys) === false) {
|
|
@@ -9173,7 +9245,8 @@ var RowSelectionState = class {
|
|
|
9173
9245
|
if (cachedResult != null) {
|
|
9174
9246
|
return cachedResult;
|
|
9175
9247
|
}
|
|
9176
|
-
|
|
9248
|
+
const groupByLength = this.getGroupByLength();
|
|
9249
|
+
if (groupKeys.length > groupByLength) {
|
|
9177
9250
|
const result2 = this.isRowSelected(groupKeys) ? { selectedCount: 1, deselectedCount: 0 } : {
|
|
9178
9251
|
selectedCount: 0,
|
|
9179
9252
|
deselectedCount: 1
|
|
@@ -9181,6 +9254,32 @@ var RowSelectionState = class {
|
|
|
9181
9254
|
this.selectionCountCache.set(groupKeys, result2);
|
|
9182
9255
|
return result2;
|
|
9183
9256
|
}
|
|
9257
|
+
if (groupByLength && this.onlyUsePrimaryKeys) {
|
|
9258
|
+
const allKeys2 = this.getAllPrimaryKeysInsideGroup(groupKeys);
|
|
9259
|
+
let selectedCount2 = 0;
|
|
9260
|
+
let deselectedCount2 = 0;
|
|
9261
|
+
allKeys2.forEach((key) => {
|
|
9262
|
+
if (this.defaultSelection) {
|
|
9263
|
+
if (this.deselectedMap.has([key])) {
|
|
9264
|
+
deselectedCount2++;
|
|
9265
|
+
return;
|
|
9266
|
+
}
|
|
9267
|
+
selectedCount2++;
|
|
9268
|
+
} else {
|
|
9269
|
+
if (this.selectedMap.has([key])) {
|
|
9270
|
+
selectedCount2++;
|
|
9271
|
+
return;
|
|
9272
|
+
}
|
|
9273
|
+
deselectedCount2++;
|
|
9274
|
+
}
|
|
9275
|
+
});
|
|
9276
|
+
const result2 = {
|
|
9277
|
+
selectedCount: selectedCount2,
|
|
9278
|
+
deselectedCount: deselectedCount2
|
|
9279
|
+
};
|
|
9280
|
+
this.selectionCountCache.set(groupKeys, result2);
|
|
9281
|
+
return result2;
|
|
9282
|
+
}
|
|
9184
9283
|
parentSelected = parentSelected != null ? parentSelected : this.getGroupRowBooleanSelectionStateFromParent(groupKeys);
|
|
9185
9284
|
let allKeys = this.getGroupKeysDirectlyInsideGroup(groupKeys);
|
|
9186
9285
|
if (groupKeys.length === this.getGroupByLength()) {
|
|
@@ -9237,6 +9336,8 @@ function rowSelectionStateConfigGetter(stateOrStateGetter) {
|
|
|
9237
9336
|
const state = typeof stateOrStateGetter === "function" ? stateOrStateGetter() : stateOrStateGetter;
|
|
9238
9337
|
return {
|
|
9239
9338
|
lazyLoad: !!state.lazyLoad,
|
|
9339
|
+
toPrimaryKey: state.toPrimaryKey,
|
|
9340
|
+
onlyUsePrimaryKeys: !state.useGroupKeysForMultiRowSelection,
|
|
9240
9341
|
groupBy: state.groupBy,
|
|
9241
9342
|
groupDeepMap: state.groupDeepMap,
|
|
9242
9343
|
indexer: state.indexer,
|
|
@@ -9391,24 +9492,32 @@ function getSelectionApi(param) {
|
|
|
9391
9492
|
rowSelectionState.toggleGroupRowSelection(groupKeys);
|
|
9392
9493
|
dataSourceActions.rowSelection = rowSelectionState;
|
|
9393
9494
|
},
|
|
9394
|
-
getGroupRowSelectionState(groupKeys) {
|
|
9395
|
-
const
|
|
9495
|
+
getGroupRowSelectionState(groupKeys, rowSelection) {
|
|
9496
|
+
const state = getDataSourceState();
|
|
9497
|
+
const { selectionMode, groupBy } = state;
|
|
9498
|
+
const rowSelectionState = rowSelection ? new RowSelectionState(rowSelection, rowSelectionStateConfigGetter(state)) : state.rowSelection;
|
|
9396
9499
|
if (selectionMode !== "multi-row") {
|
|
9397
9500
|
throw 'Selection mode should be "multi-row"';
|
|
9398
9501
|
}
|
|
9399
9502
|
if (!groupBy) {
|
|
9400
9503
|
throw "No grouping specified";
|
|
9401
9504
|
}
|
|
9402
|
-
if (!(
|
|
9505
|
+
if (!(rowSelectionState instanceof RowSelectionState)) {
|
|
9403
9506
|
throw "Invalid row selection";
|
|
9404
9507
|
}
|
|
9405
|
-
return
|
|
9508
|
+
return rowSelectionState.getGroupRowSelectionState(groupKeys);
|
|
9406
9509
|
},
|
|
9407
|
-
getSelectedPrimaryKeys: () => {
|
|
9510
|
+
getSelectedPrimaryKeys: (rowSelection) => {
|
|
9511
|
+
const state = getDataSourceState();
|
|
9512
|
+
const rowSelectionState = rowSelection ? new RowSelectionState(rowSelection, rowSelectionStateConfigGetter(state)) : state.rowSelection;
|
|
9408
9513
|
const selected = [];
|
|
9409
|
-
|
|
9410
|
-
|
|
9411
|
-
|
|
9514
|
+
if (state.lazyLoad) {
|
|
9515
|
+
console.error(`getSelectedPrimaryKeys should not be called for lazy-loaded datasources as it wont return reliable results`);
|
|
9516
|
+
}
|
|
9517
|
+
state.originalDataArray.forEach((data) => {
|
|
9518
|
+
const id = state.toPrimaryKey(data);
|
|
9519
|
+
if (rowSelectionState.isRowSelected(id)) {
|
|
9520
|
+
selected.push(id);
|
|
9412
9521
|
}
|
|
9413
9522
|
});
|
|
9414
9523
|
return selected;
|
|
@@ -9550,6 +9659,7 @@ var forwardProps3 = (setupState) => {
|
|
|
9550
9659
|
livePagination: 1,
|
|
9551
9660
|
filterFunction: 1,
|
|
9552
9661
|
filterValue: 1,
|
|
9662
|
+
useGroupKeysForMultiRowSelection: (useGroupKeysForMultiRowSelection) => useGroupKeysForMultiRowSelection != null ? useGroupKeysForMultiRowSelection : false,
|
|
9553
9663
|
filterDelay: (filterDelay) => filterDelay != null ? filterDelay : 200,
|
|
9554
9664
|
filterTypes: (filterTypes) => {
|
|
9555
9665
|
return __spreadValues(__spreadValues({}, defaultFilterTypes), filterTypes);
|
|
@@ -10638,7 +10748,8 @@ function useCellRendering(param) {
|
|
|
10638
10748
|
rowClassName,
|
|
10639
10749
|
onScrollToTop,
|
|
10640
10750
|
onScrollToBottom,
|
|
10641
|
-
scrollToBottomOffset
|
|
10751
|
+
scrollToBottomOffset,
|
|
10752
|
+
ready
|
|
10642
10753
|
} = componentState;
|
|
10643
10754
|
const repaintId = dataSourceState.updatedAt;
|
|
10644
10755
|
useYourBrain({
|
|
@@ -10679,12 +10790,16 @@ function useCellRendering(param) {
|
|
|
10679
10790
|
if (!bodySize.height) {
|
|
10680
10791
|
return;
|
|
10681
10792
|
}
|
|
10682
|
-
const { onReady } = getState();
|
|
10683
10793
|
componentActions.ready = true;
|
|
10794
|
+
}, [!!bodySize.height]);
|
|
10795
|
+
useEffect19(() => {
|
|
10796
|
+
if (!ready) {
|
|
10797
|
+
}
|
|
10798
|
+
const { onReady } = getState();
|
|
10684
10799
|
if (onReady) {
|
|
10685
10800
|
onReady(imperativeApi);
|
|
10686
10801
|
}
|
|
10687
|
-
}, [
|
|
10802
|
+
}, [ready]);
|
|
10688
10803
|
const [, rerender] = useRerender();
|
|
10689
10804
|
useEffect19(() => {
|
|
10690
10805
|
rerender();
|
|
@@ -12376,7 +12491,7 @@ var useLicense = (licenseKey = "") => {
|
|
|
12376
12491
|
const valid = useMemo11(() => {
|
|
12377
12492
|
let valid2 = isValidLicense(licenseKey, {
|
|
12378
12493
|
publishedAt: 1624970570587,
|
|
12379
|
-
version: "0.4.
|
|
12494
|
+
version: "0.4.10"
|
|
12380
12495
|
});
|
|
12381
12496
|
if (!licenseKey && !valid2 && isInsidePlayground) {
|
|
12382
12497
|
return true;
|
package/index.js
CHANGED
|
@@ -8801,11 +8801,16 @@ var RowSelectionState = class {
|
|
|
8801
8801
|
this.defaultSelection = false;
|
|
8802
8802
|
this.selectedMap = new DeepMap();
|
|
8803
8803
|
this.deselectedMap = new DeepMap();
|
|
8804
|
+
this.onlyUsePrimaryKeys = false;
|
|
8804
8805
|
this.selectionCache = new DeepMap();
|
|
8805
8806
|
this.selectionCountCache = new DeepMap();
|
|
8806
8807
|
this.mapSet = (name, key) => {
|
|
8807
8808
|
if (!Array.isArray(key)) {
|
|
8808
|
-
|
|
8809
|
+
if (this.onlyUsePrimaryKeys) {
|
|
8810
|
+
key = [key];
|
|
8811
|
+
} else {
|
|
8812
|
+
key = [...this.getGroupKeysForPrimaryKey(key), key];
|
|
8813
|
+
}
|
|
8809
8814
|
}
|
|
8810
8815
|
this.xcache();
|
|
8811
8816
|
if (name === "selected") {
|
|
@@ -8822,6 +8827,7 @@ var RowSelectionState = class {
|
|
|
8822
8827
|
};
|
|
8823
8828
|
const stateObject = state instanceof Object.getPrototypeOf(this).constructor ? state.getState() : state;
|
|
8824
8829
|
this.getConfig = getConfig;
|
|
8830
|
+
this.onlyUsePrimaryKeys = getConfig().onlyUsePrimaryKeys;
|
|
8825
8831
|
if (_forTestingOnly) {
|
|
8826
8832
|
Object.assign(this, _forTestingOnly);
|
|
8827
8833
|
}
|
|
@@ -8851,6 +8857,15 @@ var RowSelectionState = class {
|
|
|
8851
8857
|
const { groupDeepMap } = this.getConfig();
|
|
8852
8858
|
return (groupDeepMap == null ? void 0 : groupDeepMap.getKeysStartingWith(groupKeys, true, 1)) || [];
|
|
8853
8859
|
}
|
|
8860
|
+
getAllPrimaryKeysInsideGroup(groupKeys) {
|
|
8861
|
+
const { groupDeepMap } = this.getConfig();
|
|
8862
|
+
if (!groupKeys.length) {
|
|
8863
|
+
const topLevelKeys = (groupDeepMap == null ? void 0 : groupDeepMap.getKeysStartingWith([], true, 1)) || [];
|
|
8864
|
+
return topLevelKeys.map((groupKeys2) => this.getAllPrimaryKeysInsideGroup(groupKeys2)).flat();
|
|
8865
|
+
}
|
|
8866
|
+
const group2 = groupDeepMap == null ? void 0 : groupDeepMap.get(groupKeys);
|
|
8867
|
+
return group2 ? group2.items.map(this.getConfig().toPrimaryKey) : [];
|
|
8868
|
+
}
|
|
8854
8869
|
getGroupByLength() {
|
|
8855
8870
|
return this.getConfig().groupBy.length;
|
|
8856
8871
|
}
|
|
@@ -8875,7 +8890,12 @@ var RowSelectionState = class {
|
|
|
8875
8890
|
getState() {
|
|
8876
8891
|
const normalize = (allKeys) => {
|
|
8877
8892
|
const groupByLength = this.getGroupByLength();
|
|
8878
|
-
return allKeys.map((keys) =>
|
|
8893
|
+
return allKeys.map((keys) => {
|
|
8894
|
+
if (this.onlyUsePrimaryKeys) {
|
|
8895
|
+
return keys[0];
|
|
8896
|
+
}
|
|
8897
|
+
return keys.length > groupByLength ? keys.pop() : keys;
|
|
8898
|
+
});
|
|
8879
8899
|
};
|
|
8880
8900
|
const selectedRows = normalize(this.selectedMap.topDownKeys());
|
|
8881
8901
|
const deselectedRows = normalize(this.deselectedMap.topDownKeys());
|
|
@@ -8906,6 +8926,9 @@ var RowSelectionState = class {
|
|
|
8906
8926
|
return this.defaultSelection === false;
|
|
8907
8927
|
}
|
|
8908
8928
|
isRowSelected(key, groupKeys) {
|
|
8929
|
+
if (this.onlyUsePrimaryKeys) {
|
|
8930
|
+
return this.defaultSelection ? !this.deselectedMap.has([key]) : this.selectedMap.has([key]);
|
|
8931
|
+
}
|
|
8909
8932
|
groupKeys = groupKeys || this.getGroupKeysForPrimaryKey(key);
|
|
8910
8933
|
const finalKey = [...groupKeys, key];
|
|
8911
8934
|
const cachedResult = this.selectionCache.get(finalKey);
|
|
@@ -8962,7 +8985,7 @@ var RowSelectionState = class {
|
|
|
8962
8985
|
if (cachedResult !== void 0) {
|
|
8963
8986
|
return cachedResult;
|
|
8964
8987
|
}
|
|
8965
|
-
const { selectedCount, deselectedCount } = this.getSelectionCountFor(initialGroupKeys, this.getGroupRowBooleanSelectionStateFromParent(initialGroupKeys));
|
|
8988
|
+
const { selectedCount, deselectedCount } = this.getSelectionCountFor(initialGroupKeys, this.onlyUsePrimaryKeys ? void 0 : this.getGroupRowBooleanSelectionStateFromParent(initialGroupKeys));
|
|
8966
8989
|
const result = selectedCount && deselectedCount ? null : selectedCount ? true : false;
|
|
8967
8990
|
this.selectionCache.set(initialGroupKeys, result);
|
|
8968
8991
|
return result;
|
|
@@ -9003,28 +9026,67 @@ var RowSelectionState = class {
|
|
|
9003
9026
|
return this.getGroupRowSelectionState(groupKeys) === false;
|
|
9004
9027
|
}
|
|
9005
9028
|
selectGroupRow(groupKeys) {
|
|
9029
|
+
if (this.onlyUsePrimaryKeys) {
|
|
9030
|
+
const keys = this.getAllPrimaryKeysInsideGroup(groupKeys);
|
|
9031
|
+
keys.forEach((key) => {
|
|
9032
|
+
if (this.defaultSelection === true) {
|
|
9033
|
+
this.deselectedMap.delete([key]);
|
|
9034
|
+
} else {
|
|
9035
|
+
this._selectedMapSet(key);
|
|
9036
|
+
}
|
|
9037
|
+
});
|
|
9038
|
+
this.xcache();
|
|
9039
|
+
return;
|
|
9040
|
+
}
|
|
9006
9041
|
const selectedKeys = this.selectedMap.getKeysStartingWith(groupKeys, true);
|
|
9007
9042
|
selectedKeys.forEach((groupKeys2) => {
|
|
9008
9043
|
this.selectedMap.delete(groupKeys2);
|
|
9009
9044
|
});
|
|
9010
|
-
this.
|
|
9045
|
+
if (groupKeys.length === 1 && this.defaultSelection === true) {
|
|
9046
|
+
} else {
|
|
9047
|
+
this._selectedMapSet(groupKeys);
|
|
9048
|
+
}
|
|
9011
9049
|
const deselectedKeys = this.deselectedMap.getKeysStartingWith(groupKeys);
|
|
9012
9050
|
deselectedKeys.forEach((groupKeys2) => {
|
|
9013
9051
|
this.deselectedMap.delete(groupKeys2);
|
|
9014
9052
|
});
|
|
9015
9053
|
}
|
|
9016
9054
|
deselectGroupRow(groupKeys) {
|
|
9055
|
+
if (this.onlyUsePrimaryKeys) {
|
|
9056
|
+
const keys = this.getAllPrimaryKeysInsideGroup(groupKeys);
|
|
9057
|
+
keys.forEach((key) => {
|
|
9058
|
+
if (this.defaultSelection === false) {
|
|
9059
|
+
this.selectedMap.delete([key]);
|
|
9060
|
+
} else {
|
|
9061
|
+
this._deselectedMapSet(key);
|
|
9062
|
+
}
|
|
9063
|
+
});
|
|
9064
|
+
this.xcache();
|
|
9065
|
+
return;
|
|
9066
|
+
}
|
|
9017
9067
|
const deselectedKeys = this.deselectedMap.getKeysStartingWith(groupKeys, true);
|
|
9018
9068
|
deselectedKeys.forEach((groupKeys2) => {
|
|
9019
9069
|
this.deselectedMap.delete(groupKeys2);
|
|
9020
9070
|
});
|
|
9021
|
-
this.
|
|
9071
|
+
if (groupKeys.length === 1 && this.defaultSelection === false) {
|
|
9072
|
+
} else {
|
|
9073
|
+
this._deselectedMapSet(groupKeys);
|
|
9074
|
+
}
|
|
9022
9075
|
const selectedKeys = this.selectedMap.getKeysStartingWith(groupKeys);
|
|
9023
9076
|
selectedKeys.forEach((groupKeys2) => {
|
|
9024
9077
|
this.selectedMap.delete(groupKeys2);
|
|
9025
9078
|
});
|
|
9026
9079
|
}
|
|
9027
9080
|
setRowAsSelected(key, groupKeys) {
|
|
9081
|
+
if (this.onlyUsePrimaryKeys) {
|
|
9082
|
+
if (this.defaultSelection) {
|
|
9083
|
+
this.deselectedMap.delete([key]);
|
|
9084
|
+
} else {
|
|
9085
|
+
this._selectedMapSet(key);
|
|
9086
|
+
}
|
|
9087
|
+
this.xcache();
|
|
9088
|
+
return;
|
|
9089
|
+
}
|
|
9028
9090
|
groupKeys = groupKeys || this.getGroupKeysForPrimaryKey(key);
|
|
9029
9091
|
const finalKey = [...groupKeys, key];
|
|
9030
9092
|
this.deselectedMap.delete(finalKey);
|
|
@@ -9037,9 +9099,19 @@ var RowSelectionState = class {
|
|
|
9037
9099
|
}
|
|
9038
9100
|
}
|
|
9039
9101
|
setRowAsDeselected(key, groupKeys) {
|
|
9102
|
+
if (this.onlyUsePrimaryKeys) {
|
|
9103
|
+
if (this.defaultSelection) {
|
|
9104
|
+
this._deselectedMapSet(key);
|
|
9105
|
+
} else {
|
|
9106
|
+
this.selectedMap.delete([key]);
|
|
9107
|
+
}
|
|
9108
|
+
this.xcache();
|
|
9109
|
+
return;
|
|
9110
|
+
}
|
|
9040
9111
|
groupKeys = groupKeys || this.getGroupKeysForPrimaryKey(key);
|
|
9041
9112
|
const finalKey = [...groupKeys, key];
|
|
9042
9113
|
this.selectedMap.delete(finalKey);
|
|
9114
|
+
this.xcache();
|
|
9043
9115
|
if (this.getGroupRowSelectionState(groupKeys) !== false) {
|
|
9044
9116
|
this._deselectedMapSet(finalKey);
|
|
9045
9117
|
if (this.getGroupRowSelectionState(groupKeys) === false) {
|
|
@@ -9080,7 +9152,8 @@ var RowSelectionState = class {
|
|
|
9080
9152
|
if (cachedResult != null) {
|
|
9081
9153
|
return cachedResult;
|
|
9082
9154
|
}
|
|
9083
|
-
|
|
9155
|
+
const groupByLength = this.getGroupByLength();
|
|
9156
|
+
if (groupKeys.length > groupByLength) {
|
|
9084
9157
|
const result2 = this.isRowSelected(groupKeys) ? { selectedCount: 1, deselectedCount: 0 } : {
|
|
9085
9158
|
selectedCount: 0,
|
|
9086
9159
|
deselectedCount: 1
|
|
@@ -9088,6 +9161,32 @@ var RowSelectionState = class {
|
|
|
9088
9161
|
this.selectionCountCache.set(groupKeys, result2);
|
|
9089
9162
|
return result2;
|
|
9090
9163
|
}
|
|
9164
|
+
if (groupByLength && this.onlyUsePrimaryKeys) {
|
|
9165
|
+
const allKeys2 = this.getAllPrimaryKeysInsideGroup(groupKeys);
|
|
9166
|
+
let selectedCount2 = 0;
|
|
9167
|
+
let deselectedCount2 = 0;
|
|
9168
|
+
allKeys2.forEach((key) => {
|
|
9169
|
+
if (this.defaultSelection) {
|
|
9170
|
+
if (this.deselectedMap.has([key])) {
|
|
9171
|
+
deselectedCount2++;
|
|
9172
|
+
return;
|
|
9173
|
+
}
|
|
9174
|
+
selectedCount2++;
|
|
9175
|
+
} else {
|
|
9176
|
+
if (this.selectedMap.has([key])) {
|
|
9177
|
+
selectedCount2++;
|
|
9178
|
+
return;
|
|
9179
|
+
}
|
|
9180
|
+
deselectedCount2++;
|
|
9181
|
+
}
|
|
9182
|
+
});
|
|
9183
|
+
const result2 = {
|
|
9184
|
+
selectedCount: selectedCount2,
|
|
9185
|
+
deselectedCount: deselectedCount2
|
|
9186
|
+
};
|
|
9187
|
+
this.selectionCountCache.set(groupKeys, result2);
|
|
9188
|
+
return result2;
|
|
9189
|
+
}
|
|
9091
9190
|
parentSelected = parentSelected != null ? parentSelected : this.getGroupRowBooleanSelectionStateFromParent(groupKeys);
|
|
9092
9191
|
let allKeys = this.getGroupKeysDirectlyInsideGroup(groupKeys);
|
|
9093
9192
|
if (groupKeys.length === this.getGroupByLength()) {
|
|
@@ -9144,6 +9243,8 @@ function rowSelectionStateConfigGetter(stateOrStateGetter) {
|
|
|
9144
9243
|
const state = typeof stateOrStateGetter === "function" ? stateOrStateGetter() : stateOrStateGetter;
|
|
9145
9244
|
return {
|
|
9146
9245
|
lazyLoad: !!state.lazyLoad,
|
|
9246
|
+
toPrimaryKey: state.toPrimaryKey,
|
|
9247
|
+
onlyUsePrimaryKeys: !state.useGroupKeysForMultiRowSelection,
|
|
9147
9248
|
groupBy: state.groupBy,
|
|
9148
9249
|
groupDeepMap: state.groupDeepMap,
|
|
9149
9250
|
indexer: state.indexer,
|
|
@@ -9298,24 +9399,32 @@ function getSelectionApi(param) {
|
|
|
9298
9399
|
rowSelectionState.toggleGroupRowSelection(groupKeys);
|
|
9299
9400
|
dataSourceActions.rowSelection = rowSelectionState;
|
|
9300
9401
|
},
|
|
9301
|
-
getGroupRowSelectionState(groupKeys) {
|
|
9302
|
-
const
|
|
9402
|
+
getGroupRowSelectionState(groupKeys, rowSelection) {
|
|
9403
|
+
const state = getDataSourceState();
|
|
9404
|
+
const { selectionMode, groupBy } = state;
|
|
9405
|
+
const rowSelectionState = rowSelection ? new RowSelectionState(rowSelection, rowSelectionStateConfigGetter(state)) : state.rowSelection;
|
|
9303
9406
|
if (selectionMode !== "multi-row") {
|
|
9304
9407
|
throw 'Selection mode should be "multi-row"';
|
|
9305
9408
|
}
|
|
9306
9409
|
if (!groupBy) {
|
|
9307
9410
|
throw "No grouping specified";
|
|
9308
9411
|
}
|
|
9309
|
-
if (!(
|
|
9412
|
+
if (!(rowSelectionState instanceof RowSelectionState)) {
|
|
9310
9413
|
throw "Invalid row selection";
|
|
9311
9414
|
}
|
|
9312
|
-
return
|
|
9415
|
+
return rowSelectionState.getGroupRowSelectionState(groupKeys);
|
|
9313
9416
|
},
|
|
9314
|
-
getSelectedPrimaryKeys: () => {
|
|
9417
|
+
getSelectedPrimaryKeys: (rowSelection) => {
|
|
9418
|
+
const state = getDataSourceState();
|
|
9419
|
+
const rowSelectionState = rowSelection ? new RowSelectionState(rowSelection, rowSelectionStateConfigGetter(state)) : state.rowSelection;
|
|
9315
9420
|
const selected = [];
|
|
9316
|
-
|
|
9317
|
-
|
|
9318
|
-
|
|
9421
|
+
if (state.lazyLoad) {
|
|
9422
|
+
console.error(`getSelectedPrimaryKeys should not be called for lazy-loaded datasources as it wont return reliable results`);
|
|
9423
|
+
}
|
|
9424
|
+
state.originalDataArray.forEach((data) => {
|
|
9425
|
+
const id = state.toPrimaryKey(data);
|
|
9426
|
+
if (rowSelectionState.isRowSelected(id)) {
|
|
9427
|
+
selected.push(id);
|
|
9319
9428
|
}
|
|
9320
9429
|
});
|
|
9321
9430
|
return selected;
|
|
@@ -9457,6 +9566,7 @@ var forwardProps3 = (setupState) => {
|
|
|
9457
9566
|
livePagination: 1,
|
|
9458
9567
|
filterFunction: 1,
|
|
9459
9568
|
filterValue: 1,
|
|
9569
|
+
useGroupKeysForMultiRowSelection: (useGroupKeysForMultiRowSelection) => useGroupKeysForMultiRowSelection != null ? useGroupKeysForMultiRowSelection : false,
|
|
9460
9570
|
filterDelay: (filterDelay) => filterDelay != null ? filterDelay : 200,
|
|
9461
9571
|
filterTypes: (filterTypes) => {
|
|
9462
9572
|
return __spreadValues(__spreadValues({}, defaultFilterTypes), filterTypes);
|
|
@@ -10539,7 +10649,8 @@ function useCellRendering(param) {
|
|
|
10539
10649
|
rowClassName,
|
|
10540
10650
|
onScrollToTop,
|
|
10541
10651
|
onScrollToBottom,
|
|
10542
|
-
scrollToBottomOffset
|
|
10652
|
+
scrollToBottomOffset,
|
|
10653
|
+
ready
|
|
10543
10654
|
} = componentState;
|
|
10544
10655
|
const repaintId = dataSourceState.updatedAt;
|
|
10545
10656
|
useYourBrain({
|
|
@@ -10580,12 +10691,16 @@ function useCellRendering(param) {
|
|
|
10580
10691
|
if (!bodySize.height) {
|
|
10581
10692
|
return;
|
|
10582
10693
|
}
|
|
10583
|
-
const { onReady } = getState();
|
|
10584
10694
|
componentActions.ready = true;
|
|
10695
|
+
}, [!!bodySize.height]);
|
|
10696
|
+
(0, import_react32.useEffect)(() => {
|
|
10697
|
+
if (!ready) {
|
|
10698
|
+
}
|
|
10699
|
+
const { onReady } = getState();
|
|
10585
10700
|
if (onReady) {
|
|
10586
10701
|
onReady(imperativeApi);
|
|
10587
10702
|
}
|
|
10588
|
-
}, [
|
|
10703
|
+
}, [ready]);
|
|
10589
10704
|
const [, rerender] = useRerender();
|
|
10590
10705
|
(0, import_react32.useEffect)(() => {
|
|
10591
10706
|
rerender();
|
|
@@ -12277,7 +12392,7 @@ var useLicense = (licenseKey = "") => {
|
|
|
12277
12392
|
const valid = (0, import_react44.useMemo)(() => {
|
|
12278
12393
|
let valid2 = isValidLicense(licenseKey, {
|
|
12279
12394
|
publishedAt: 1624970570587,
|
|
12280
|
-
version: "0.4.
|
|
12395
|
+
version: "0.4.10"
|
|
12281
12396
|
});
|
|
12282
12397
|
if (!licenseKey && !valid2 && isInsidePlayground) {
|
|
12283
12398
|
return true;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@infinite-table/infinite-react",
|
|
3
3
|
"description": "Infinite Table for React",
|
|
4
|
-
"version": "0.4.
|
|
4
|
+
"version": "0.4.10",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "index.esm.js",
|
|
7
7
|
"typings": "index.d.ts",
|
|
@@ -14,5 +14,5 @@
|
|
|
14
14
|
},
|
|
15
15
|
"license": "Commercial & Open Source",
|
|
16
16
|
"//": "will be updated at build time",
|
|
17
|
-
"publishedAt":
|
|
17
|
+
"publishedAt": 1661331797164
|
|
18
18
|
}
|