@infinite-table/infinite-react 0.4.8 → 0.4.9
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 +7 -0
- package/index.esm.js +121 -13
- package/index.js +121 -13
- 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
|
+
usePrimaryKeysForMultiRowSelection: NonUndefined<DataSourceProps<T>['usePrimaryKeysForMultiRowSelection']>;
|
|
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
|
+
usePrimaryKeysForMultiRowSelection?: boolean;
|
|
1270
1277
|
rowSelection?: DataSourcePropRowSelection_MultiRow | DataSourcePropRowSelection_SingleRow;
|
|
1271
1278
|
defaultRowSelection?: DataSourcePropRowSelection_MultiRow | DataSourcePropRowSelection_SingleRow;
|
|
1272
1279
|
cellSelection?: DataSourcePropCellSelection;
|
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) {
|
|
@@ -9181,6 +9253,32 @@ var RowSelectionState = class {
|
|
|
9181
9253
|
this.selectionCountCache.set(groupKeys, result2);
|
|
9182
9254
|
return result2;
|
|
9183
9255
|
}
|
|
9256
|
+
if (this.onlyUsePrimaryKeys) {
|
|
9257
|
+
const allKeys2 = this.getAllPrimaryKeysInsideGroup(groupKeys);
|
|
9258
|
+
let selectedCount2 = 0;
|
|
9259
|
+
let deselectedCount2 = 0;
|
|
9260
|
+
allKeys2.forEach((key) => {
|
|
9261
|
+
if (this.defaultSelection) {
|
|
9262
|
+
if (this.deselectedMap.has([key])) {
|
|
9263
|
+
deselectedCount2++;
|
|
9264
|
+
return;
|
|
9265
|
+
}
|
|
9266
|
+
selectedCount2++;
|
|
9267
|
+
} else {
|
|
9268
|
+
if (this.selectedMap.has([key])) {
|
|
9269
|
+
selectedCount2++;
|
|
9270
|
+
return;
|
|
9271
|
+
}
|
|
9272
|
+
deselectedCount2++;
|
|
9273
|
+
}
|
|
9274
|
+
});
|
|
9275
|
+
const result2 = {
|
|
9276
|
+
selectedCount: selectedCount2,
|
|
9277
|
+
deselectedCount: deselectedCount2
|
|
9278
|
+
};
|
|
9279
|
+
this.selectionCountCache.set(groupKeys, result2);
|
|
9280
|
+
return result2;
|
|
9281
|
+
}
|
|
9184
9282
|
parentSelected = parentSelected != null ? parentSelected : this.getGroupRowBooleanSelectionStateFromParent(groupKeys);
|
|
9185
9283
|
let allKeys = this.getGroupKeysDirectlyInsideGroup(groupKeys);
|
|
9186
9284
|
if (groupKeys.length === this.getGroupByLength()) {
|
|
@@ -9237,6 +9335,8 @@ function rowSelectionStateConfigGetter(stateOrStateGetter) {
|
|
|
9237
9335
|
const state = typeof stateOrStateGetter === "function" ? stateOrStateGetter() : stateOrStateGetter;
|
|
9238
9336
|
return {
|
|
9239
9337
|
lazyLoad: !!state.lazyLoad,
|
|
9338
|
+
toPrimaryKey: state.toPrimaryKey,
|
|
9339
|
+
onlyUsePrimaryKeys: state.usePrimaryKeysForMultiRowSelection,
|
|
9240
9340
|
groupBy: state.groupBy,
|
|
9241
9341
|
groupDeepMap: state.groupDeepMap,
|
|
9242
9342
|
indexer: state.indexer,
|
|
@@ -9391,18 +9491,20 @@ function getSelectionApi(param) {
|
|
|
9391
9491
|
rowSelectionState.toggleGroupRowSelection(groupKeys);
|
|
9392
9492
|
dataSourceActions.rowSelection = rowSelectionState;
|
|
9393
9493
|
},
|
|
9394
|
-
getGroupRowSelectionState(groupKeys) {
|
|
9395
|
-
const
|
|
9494
|
+
getGroupRowSelectionState(groupKeys, rowSelection) {
|
|
9495
|
+
const state = getDataSourceState();
|
|
9496
|
+
const { selectionMode, groupBy } = state;
|
|
9497
|
+
const rowSelectionState = rowSelection ? new RowSelectionState(rowSelection, rowSelectionStateConfigGetter(state)) : state.rowSelection;
|
|
9396
9498
|
if (selectionMode !== "multi-row") {
|
|
9397
9499
|
throw 'Selection mode should be "multi-row"';
|
|
9398
9500
|
}
|
|
9399
9501
|
if (!groupBy) {
|
|
9400
9502
|
throw "No grouping specified";
|
|
9401
9503
|
}
|
|
9402
|
-
if (!(
|
|
9504
|
+
if (!(rowSelectionState instanceof RowSelectionState)) {
|
|
9403
9505
|
throw "Invalid row selection";
|
|
9404
9506
|
}
|
|
9405
|
-
return
|
|
9507
|
+
return rowSelectionState.getGroupRowSelectionState(groupKeys);
|
|
9406
9508
|
},
|
|
9407
9509
|
getSelectedPrimaryKeys: (rowSelection) => {
|
|
9408
9510
|
const state = getDataSourceState();
|
|
@@ -9556,6 +9658,7 @@ var forwardProps3 = (setupState) => {
|
|
|
9556
9658
|
livePagination: 1,
|
|
9557
9659
|
filterFunction: 1,
|
|
9558
9660
|
filterValue: 1,
|
|
9661
|
+
usePrimaryKeysForMultiRowSelection: (usePrimaryKeysForMultiRowSelection) => usePrimaryKeysForMultiRowSelection != null ? usePrimaryKeysForMultiRowSelection : false,
|
|
9559
9662
|
filterDelay: (filterDelay) => filterDelay != null ? filterDelay : 200,
|
|
9560
9663
|
filterTypes: (filterTypes) => {
|
|
9561
9664
|
return __spreadValues(__spreadValues({}, defaultFilterTypes), filterTypes);
|
|
@@ -10644,7 +10747,8 @@ function useCellRendering(param) {
|
|
|
10644
10747
|
rowClassName,
|
|
10645
10748
|
onScrollToTop,
|
|
10646
10749
|
onScrollToBottom,
|
|
10647
|
-
scrollToBottomOffset
|
|
10750
|
+
scrollToBottomOffset,
|
|
10751
|
+
ready
|
|
10648
10752
|
} = componentState;
|
|
10649
10753
|
const repaintId = dataSourceState.updatedAt;
|
|
10650
10754
|
useYourBrain({
|
|
@@ -10685,12 +10789,16 @@ function useCellRendering(param) {
|
|
|
10685
10789
|
if (!bodySize.height) {
|
|
10686
10790
|
return;
|
|
10687
10791
|
}
|
|
10688
|
-
const { onReady } = getState();
|
|
10689
10792
|
componentActions.ready = true;
|
|
10793
|
+
}, [!!bodySize.height]);
|
|
10794
|
+
useEffect19(() => {
|
|
10795
|
+
if (!ready) {
|
|
10796
|
+
}
|
|
10797
|
+
const { onReady } = getState();
|
|
10690
10798
|
if (onReady) {
|
|
10691
10799
|
onReady(imperativeApi);
|
|
10692
10800
|
}
|
|
10693
|
-
}, [
|
|
10801
|
+
}, [ready]);
|
|
10694
10802
|
const [, rerender] = useRerender();
|
|
10695
10803
|
useEffect19(() => {
|
|
10696
10804
|
rerender();
|
|
@@ -12382,7 +12490,7 @@ var useLicense = (licenseKey = "") => {
|
|
|
12382
12490
|
const valid = useMemo11(() => {
|
|
12383
12491
|
let valid2 = isValidLicense(licenseKey, {
|
|
12384
12492
|
publishedAt: 1624970570587,
|
|
12385
|
-
version: "0.4.
|
|
12493
|
+
version: "0.4.9"
|
|
12386
12494
|
});
|
|
12387
12495
|
if (!licenseKey && !valid2 && isInsidePlayground) {
|
|
12388
12496
|
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) {
|
|
@@ -9088,6 +9160,32 @@ var RowSelectionState = class {
|
|
|
9088
9160
|
this.selectionCountCache.set(groupKeys, result2);
|
|
9089
9161
|
return result2;
|
|
9090
9162
|
}
|
|
9163
|
+
if (this.onlyUsePrimaryKeys) {
|
|
9164
|
+
const allKeys2 = this.getAllPrimaryKeysInsideGroup(groupKeys);
|
|
9165
|
+
let selectedCount2 = 0;
|
|
9166
|
+
let deselectedCount2 = 0;
|
|
9167
|
+
allKeys2.forEach((key) => {
|
|
9168
|
+
if (this.defaultSelection) {
|
|
9169
|
+
if (this.deselectedMap.has([key])) {
|
|
9170
|
+
deselectedCount2++;
|
|
9171
|
+
return;
|
|
9172
|
+
}
|
|
9173
|
+
selectedCount2++;
|
|
9174
|
+
} else {
|
|
9175
|
+
if (this.selectedMap.has([key])) {
|
|
9176
|
+
selectedCount2++;
|
|
9177
|
+
return;
|
|
9178
|
+
}
|
|
9179
|
+
deselectedCount2++;
|
|
9180
|
+
}
|
|
9181
|
+
});
|
|
9182
|
+
const result2 = {
|
|
9183
|
+
selectedCount: selectedCount2,
|
|
9184
|
+
deselectedCount: deselectedCount2
|
|
9185
|
+
};
|
|
9186
|
+
this.selectionCountCache.set(groupKeys, result2);
|
|
9187
|
+
return result2;
|
|
9188
|
+
}
|
|
9091
9189
|
parentSelected = parentSelected != null ? parentSelected : this.getGroupRowBooleanSelectionStateFromParent(groupKeys);
|
|
9092
9190
|
let allKeys = this.getGroupKeysDirectlyInsideGroup(groupKeys);
|
|
9093
9191
|
if (groupKeys.length === this.getGroupByLength()) {
|
|
@@ -9144,6 +9242,8 @@ function rowSelectionStateConfigGetter(stateOrStateGetter) {
|
|
|
9144
9242
|
const state = typeof stateOrStateGetter === "function" ? stateOrStateGetter() : stateOrStateGetter;
|
|
9145
9243
|
return {
|
|
9146
9244
|
lazyLoad: !!state.lazyLoad,
|
|
9245
|
+
toPrimaryKey: state.toPrimaryKey,
|
|
9246
|
+
onlyUsePrimaryKeys: state.usePrimaryKeysForMultiRowSelection,
|
|
9147
9247
|
groupBy: state.groupBy,
|
|
9148
9248
|
groupDeepMap: state.groupDeepMap,
|
|
9149
9249
|
indexer: state.indexer,
|
|
@@ -9298,18 +9398,20 @@ function getSelectionApi(param) {
|
|
|
9298
9398
|
rowSelectionState.toggleGroupRowSelection(groupKeys);
|
|
9299
9399
|
dataSourceActions.rowSelection = rowSelectionState;
|
|
9300
9400
|
},
|
|
9301
|
-
getGroupRowSelectionState(groupKeys) {
|
|
9302
|
-
const
|
|
9401
|
+
getGroupRowSelectionState(groupKeys, rowSelection) {
|
|
9402
|
+
const state = getDataSourceState();
|
|
9403
|
+
const { selectionMode, groupBy } = state;
|
|
9404
|
+
const rowSelectionState = rowSelection ? new RowSelectionState(rowSelection, rowSelectionStateConfigGetter(state)) : state.rowSelection;
|
|
9303
9405
|
if (selectionMode !== "multi-row") {
|
|
9304
9406
|
throw 'Selection mode should be "multi-row"';
|
|
9305
9407
|
}
|
|
9306
9408
|
if (!groupBy) {
|
|
9307
9409
|
throw "No grouping specified";
|
|
9308
9410
|
}
|
|
9309
|
-
if (!(
|
|
9411
|
+
if (!(rowSelectionState instanceof RowSelectionState)) {
|
|
9310
9412
|
throw "Invalid row selection";
|
|
9311
9413
|
}
|
|
9312
|
-
return
|
|
9414
|
+
return rowSelectionState.getGroupRowSelectionState(groupKeys);
|
|
9313
9415
|
},
|
|
9314
9416
|
getSelectedPrimaryKeys: (rowSelection) => {
|
|
9315
9417
|
const state = getDataSourceState();
|
|
@@ -9463,6 +9565,7 @@ var forwardProps3 = (setupState) => {
|
|
|
9463
9565
|
livePagination: 1,
|
|
9464
9566
|
filterFunction: 1,
|
|
9465
9567
|
filterValue: 1,
|
|
9568
|
+
usePrimaryKeysForMultiRowSelection: (usePrimaryKeysForMultiRowSelection) => usePrimaryKeysForMultiRowSelection != null ? usePrimaryKeysForMultiRowSelection : false,
|
|
9466
9569
|
filterDelay: (filterDelay) => filterDelay != null ? filterDelay : 200,
|
|
9467
9570
|
filterTypes: (filterTypes) => {
|
|
9468
9571
|
return __spreadValues(__spreadValues({}, defaultFilterTypes), filterTypes);
|
|
@@ -10545,7 +10648,8 @@ function useCellRendering(param) {
|
|
|
10545
10648
|
rowClassName,
|
|
10546
10649
|
onScrollToTop,
|
|
10547
10650
|
onScrollToBottom,
|
|
10548
|
-
scrollToBottomOffset
|
|
10651
|
+
scrollToBottomOffset,
|
|
10652
|
+
ready
|
|
10549
10653
|
} = componentState;
|
|
10550
10654
|
const repaintId = dataSourceState.updatedAt;
|
|
10551
10655
|
useYourBrain({
|
|
@@ -10586,12 +10690,16 @@ function useCellRendering(param) {
|
|
|
10586
10690
|
if (!bodySize.height) {
|
|
10587
10691
|
return;
|
|
10588
10692
|
}
|
|
10589
|
-
const { onReady } = getState();
|
|
10590
10693
|
componentActions.ready = true;
|
|
10694
|
+
}, [!!bodySize.height]);
|
|
10695
|
+
(0, import_react32.useEffect)(() => {
|
|
10696
|
+
if (!ready) {
|
|
10697
|
+
}
|
|
10698
|
+
const { onReady } = getState();
|
|
10591
10699
|
if (onReady) {
|
|
10592
10700
|
onReady(imperativeApi);
|
|
10593
10701
|
}
|
|
10594
|
-
}, [
|
|
10702
|
+
}, [ready]);
|
|
10595
10703
|
const [, rerender] = useRerender();
|
|
10596
10704
|
(0, import_react32.useEffect)(() => {
|
|
10597
10705
|
rerender();
|
|
@@ -12283,7 +12391,7 @@ var useLicense = (licenseKey = "") => {
|
|
|
12283
12391
|
const valid = (0, import_react44.useMemo)(() => {
|
|
12284
12392
|
let valid2 = isValidLicense(licenseKey, {
|
|
12285
12393
|
publishedAt: 1624970570587,
|
|
12286
|
-
version: "0.4.
|
|
12394
|
+
version: "0.4.9"
|
|
12287
12395
|
});
|
|
12288
12396
|
if (!licenseKey && !valid2 && isInsidePlayground) {
|
|
12289
12397
|
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.9",
|
|
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": 1661328172572
|
|
18
18
|
}
|