@infinite-table/infinite-react 0.2.2 → 0.2.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/index.d.ts +1 -0
- package/index.esm.js +37 -16
- package/index.js +37 -16
- package/package.json +2 -2
package/index.d.ts
CHANGED
|
@@ -865,6 +865,7 @@ declare module "utils/groupAndPivot/index" {
|
|
|
865
865
|
export type PivotValuesDeepMap<DataType, KeyType> = DeepMap<GroupKeyType<KeyType>, PivotGroupValueType<DataType, KeyType>>;
|
|
866
866
|
export type DeepMapGroupValueType<DataType, KeyType> = {
|
|
867
867
|
items: DataType[];
|
|
868
|
+
commonData?: Partial<DataType>;
|
|
868
869
|
reducerResults: Record<string, AggregationReducerResult>;
|
|
869
870
|
pivotDeepMap?: DeepMap<GroupKeyType<KeyType>, PivotGroupValueType<DataType, KeyType>>;
|
|
870
871
|
};
|
package/index.esm.js
CHANGED
|
@@ -2662,6 +2662,13 @@ function lazyGroup(groupParams, rootData) {
|
|
|
2662
2662
|
rootData.visitDepthFirst((lazyGroupRowInfo, keys, _index, next) => {
|
|
2663
2663
|
const [_rootKey, ...currentGroupKeys] = keys;
|
|
2664
2664
|
const dataArray = lazyGroupRowInfo.items;
|
|
2665
|
+
if (currentGroupKeys.length == groupBy.length) {
|
|
2666
|
+
const deepMapGroupValue = deepMap.get(currentGroupKeys);
|
|
2667
|
+
if (deepMapGroupValue) {
|
|
2668
|
+
deepMapGroupValue.items = dataArray;
|
|
2669
|
+
}
|
|
2670
|
+
return next == null ? void 0 : next();
|
|
2671
|
+
}
|
|
2665
2672
|
for (let i = 0, len = dataArray.length; i < len; i++) {
|
|
2666
2673
|
if (!dataArray[i]) {
|
|
2667
2674
|
const deepMapGroupValue2 = {
|
|
@@ -2682,6 +2689,7 @@ function lazyGroup(groupParams, rootData) {
|
|
|
2682
2689
|
currentGroupKeys.push(key);
|
|
2683
2690
|
const deepMapGroupValue = {
|
|
2684
2691
|
items: [],
|
|
2692
|
+
commonData: dataObject,
|
|
2685
2693
|
reducerResults: dataArray[i].aggregations || {}
|
|
2686
2694
|
};
|
|
2687
2695
|
deepMap.set(currentGroupKeys, deepMapGroupValue);
|
|
@@ -2817,10 +2825,15 @@ function flatten(groupResult) {
|
|
|
2817
2825
|
function getEnhancedGroupData(options, deepMapValue) {
|
|
2818
2826
|
const { groupBy, groupKeys, collapsed, parents, reducers } = options;
|
|
2819
2827
|
const groupNesting = groupKeys.length;
|
|
2820
|
-
const {
|
|
2828
|
+
const {
|
|
2829
|
+
items: groupItems,
|
|
2830
|
+
reducerResults,
|
|
2831
|
+
pivotDeepMap,
|
|
2832
|
+
commonData
|
|
2833
|
+
} = deepMapValue;
|
|
2821
2834
|
let data = null;
|
|
2822
2835
|
if (Object.keys(reducerResults).length > 0) {
|
|
2823
|
-
data = {};
|
|
2836
|
+
data = commonData || {};
|
|
2824
2837
|
for (let key in reducers)
|
|
2825
2838
|
if (reducers.hasOwnProperty(key)) {
|
|
2826
2839
|
const reducer = reducers[key];
|
|
@@ -2839,7 +2852,7 @@ function getEnhancedGroupData(options, deepMapValue) {
|
|
|
2839
2852
|
groupCount: groupItems.length,
|
|
2840
2853
|
groupData: groupItems,
|
|
2841
2854
|
groupKeys,
|
|
2842
|
-
id: groupKeys
|
|
2855
|
+
id: `${groupKeys}`,
|
|
2843
2856
|
collapsed,
|
|
2844
2857
|
parents,
|
|
2845
2858
|
collapsedChildrenCount: 0,
|
|
@@ -2916,7 +2929,7 @@ function enhancedFlatten(param) {
|
|
|
2916
2929
|
const startIndex = result.length;
|
|
2917
2930
|
result.push(...items.map((item, index) => {
|
|
2918
2931
|
return {
|
|
2919
|
-
id: toPrimaryKey(item)
|
|
2932
|
+
id: item ? toPrimaryKey(item) : `${groupKeys}-${index}`,
|
|
2920
2933
|
data: item,
|
|
2921
2934
|
isGroupRow: false,
|
|
2922
2935
|
collapsed: false,
|
|
@@ -3266,11 +3279,11 @@ function lazyLoadRange(options, cache) {
|
|
|
3266
3279
|
continue;
|
|
3267
3280
|
}
|
|
3268
3281
|
const rowLoaded = rowInfo.data != null;
|
|
3269
|
-
const
|
|
3270
|
-
if (rowInfo.groupKeys) {
|
|
3271
|
-
|
|
3282
|
+
const theGroupKeys = rowInfo.groupKeys ? [...rowInfo.groupKeys] : [];
|
|
3283
|
+
if (rowInfo.groupKeys && rowInfo.isGroupRow) {
|
|
3284
|
+
theGroupKeys.pop();
|
|
3272
3285
|
}
|
|
3273
|
-
const cacheKeys =
|
|
3286
|
+
const cacheKeys = theGroupKeys.length ? theGroupKeys : rootGroupKeys;
|
|
3274
3287
|
const indexInGroup = rowInfo.indexInGroup;
|
|
3275
3288
|
if (!rowLoaded) {
|
|
3276
3289
|
let fnCalls = perGroupFnCalls.get(cacheKeys);
|
|
@@ -3287,7 +3300,7 @@ function lazyLoadRange(options, cache) {
|
|
|
3287
3300
|
const currentFnCall = {
|
|
3288
3301
|
lazyLoadStartIndex: batchStartIndexInGroup,
|
|
3289
3302
|
lazyLoadBatchSize,
|
|
3290
|
-
groupKeys:
|
|
3303
|
+
groupKeys: theGroupKeys
|
|
3291
3304
|
};
|
|
3292
3305
|
if (!fnCalls[batchStartRowId]) {
|
|
3293
3306
|
fnCalls[batchStartRowId] = currentFnCall;
|
|
@@ -3897,7 +3910,11 @@ function concludeReducer(params) {
|
|
|
3897
3910
|
state.postSortDataArray = dataArray;
|
|
3898
3911
|
state.groupDeepMap = void 0;
|
|
3899
3912
|
const toPrimaryKey = (data) => {
|
|
3900
|
-
|
|
3913
|
+
const pk = data[state.primaryKey];
|
|
3914
|
+
if (Array.isArray(pk)) {
|
|
3915
|
+
debugger;
|
|
3916
|
+
}
|
|
3917
|
+
return pk;
|
|
3901
3918
|
};
|
|
3902
3919
|
if (shouldGroup) {
|
|
3903
3920
|
if (shouldGroupAgain) {
|
|
@@ -3939,7 +3956,7 @@ function concludeReducer(params) {
|
|
|
3939
3956
|
state.pivotColumns = void 0;
|
|
3940
3957
|
const arrayDifferentAfterSortStep = previousState.postSortDataArray != state.postSortDataArray;
|
|
3941
3958
|
if (arrayDifferentAfterSortStep) {
|
|
3942
|
-
rowInfoDataArray = dataArray.map((data, index) => toRowInfo(data, toPrimaryKey(data), index));
|
|
3959
|
+
rowInfoDataArray = dataArray.map((data, index) => toRowInfo(data, data ? toPrimaryKey(data) : index, index));
|
|
3943
3960
|
}
|
|
3944
3961
|
}
|
|
3945
3962
|
state.postGroupDataArray = rowInfoDataArray;
|
|
@@ -4049,7 +4066,7 @@ function useColumnsWhen() {
|
|
|
4049
4066
|
}, [pivotTotalColumnPosition]);
|
|
4050
4067
|
useColumnsWhenInlineGroupRenderStrategy(groupByMap);
|
|
4051
4068
|
const { toggleGroupRow } = useColumnsWhenGrouping();
|
|
4052
|
-
useHideEmptyGroupColumns(
|
|
4069
|
+
useHideEmptyGroupColumns();
|
|
4053
4070
|
return { toggleGroupRow };
|
|
4054
4071
|
}
|
|
4055
4072
|
function useColumnsWhenInlineGroupRenderStrategy(groupByMap) {
|
|
@@ -4171,9 +4188,13 @@ function useColumnsWhenGrouping() {
|
|
|
4171
4188
|
]);
|
|
4172
4189
|
return { toggleGroupRow };
|
|
4173
4190
|
}
|
|
4174
|
-
function useHideEmptyGroupColumns(
|
|
4191
|
+
function useHideEmptyGroupColumns() {
|
|
4175
4192
|
const {
|
|
4176
|
-
componentState: {
|
|
4193
|
+
componentState: {
|
|
4194
|
+
groupBy,
|
|
4195
|
+
groupRowsState,
|
|
4196
|
+
originalLazyGroupDataChangeDetect
|
|
4197
|
+
},
|
|
4177
4198
|
getState: getDataSourceState
|
|
4178
4199
|
} = useDataSourceContextValue();
|
|
4179
4200
|
const {
|
|
@@ -4226,8 +4247,8 @@ function useHideEmptyGroupColumns(groupRowsMap) {
|
|
|
4226
4247
|
getDataSourceState,
|
|
4227
4248
|
groupRenderStrategy,
|
|
4228
4249
|
generatedColumns,
|
|
4250
|
+
originalLazyGroupDataChangeDetect,
|
|
4229
4251
|
groupBy,
|
|
4230
|
-
groupRowsMap,
|
|
4231
4252
|
hideEmptyGroupColumns ? groupRowsState : null,
|
|
4232
4253
|
hideEmptyGroupColumns
|
|
4233
4254
|
]);
|
|
@@ -7702,7 +7723,7 @@ var useLicense = (licenseKey = "") => {
|
|
|
7702
7723
|
const valid = useMemo12(() => {
|
|
7703
7724
|
let valid2 = isValidLicense(licenseKey, {
|
|
7704
7725
|
publishedAt: 1624970570587,
|
|
7705
|
-
version: "0.2.
|
|
7726
|
+
version: "0.2.3"
|
|
7706
7727
|
});
|
|
7707
7728
|
if (!licenseKey && !valid2 && isInsideSandbox) {
|
|
7708
7729
|
return true;
|
package/index.js
CHANGED
|
@@ -2648,6 +2648,13 @@ function lazyGroup(groupParams, rootData) {
|
|
|
2648
2648
|
rootData.visitDepthFirst((lazyGroupRowInfo, keys, _index, next) => {
|
|
2649
2649
|
const [_rootKey, ...currentGroupKeys] = keys;
|
|
2650
2650
|
const dataArray = lazyGroupRowInfo.items;
|
|
2651
|
+
if (currentGroupKeys.length == groupBy.length) {
|
|
2652
|
+
const deepMapGroupValue = deepMap.get(currentGroupKeys);
|
|
2653
|
+
if (deepMapGroupValue) {
|
|
2654
|
+
deepMapGroupValue.items = dataArray;
|
|
2655
|
+
}
|
|
2656
|
+
return next == null ? void 0 : next();
|
|
2657
|
+
}
|
|
2651
2658
|
for (let i = 0, len = dataArray.length; i < len; i++) {
|
|
2652
2659
|
if (!dataArray[i]) {
|
|
2653
2660
|
const deepMapGroupValue2 = {
|
|
@@ -2668,6 +2675,7 @@ function lazyGroup(groupParams, rootData) {
|
|
|
2668
2675
|
currentGroupKeys.push(key);
|
|
2669
2676
|
const deepMapGroupValue = {
|
|
2670
2677
|
items: [],
|
|
2678
|
+
commonData: dataObject,
|
|
2671
2679
|
reducerResults: dataArray[i].aggregations || {}
|
|
2672
2680
|
};
|
|
2673
2681
|
deepMap.set(currentGroupKeys, deepMapGroupValue);
|
|
@@ -2803,10 +2811,15 @@ function flatten(groupResult) {
|
|
|
2803
2811
|
function getEnhancedGroupData(options, deepMapValue) {
|
|
2804
2812
|
const { groupBy, groupKeys, collapsed, parents, reducers } = options;
|
|
2805
2813
|
const groupNesting = groupKeys.length;
|
|
2806
|
-
const {
|
|
2814
|
+
const {
|
|
2815
|
+
items: groupItems,
|
|
2816
|
+
reducerResults,
|
|
2817
|
+
pivotDeepMap,
|
|
2818
|
+
commonData
|
|
2819
|
+
} = deepMapValue;
|
|
2807
2820
|
let data = null;
|
|
2808
2821
|
if (Object.keys(reducerResults).length > 0) {
|
|
2809
|
-
data = {};
|
|
2822
|
+
data = commonData || {};
|
|
2810
2823
|
for (let key in reducers)
|
|
2811
2824
|
if (reducers.hasOwnProperty(key)) {
|
|
2812
2825
|
const reducer = reducers[key];
|
|
@@ -2825,7 +2838,7 @@ function getEnhancedGroupData(options, deepMapValue) {
|
|
|
2825
2838
|
groupCount: groupItems.length,
|
|
2826
2839
|
groupData: groupItems,
|
|
2827
2840
|
groupKeys,
|
|
2828
|
-
id: groupKeys
|
|
2841
|
+
id: `${groupKeys}`,
|
|
2829
2842
|
collapsed,
|
|
2830
2843
|
parents,
|
|
2831
2844
|
collapsedChildrenCount: 0,
|
|
@@ -2902,7 +2915,7 @@ function enhancedFlatten(param) {
|
|
|
2902
2915
|
const startIndex = result.length;
|
|
2903
2916
|
result.push(...items.map((item, index) => {
|
|
2904
2917
|
return {
|
|
2905
|
-
id: toPrimaryKey(item)
|
|
2918
|
+
id: item ? toPrimaryKey(item) : `${groupKeys}-${index}`,
|
|
2906
2919
|
data: item,
|
|
2907
2920
|
isGroupRow: false,
|
|
2908
2921
|
collapsed: false,
|
|
@@ -3252,11 +3265,11 @@ function lazyLoadRange(options, cache) {
|
|
|
3252
3265
|
continue;
|
|
3253
3266
|
}
|
|
3254
3267
|
const rowLoaded = rowInfo.data != null;
|
|
3255
|
-
const
|
|
3256
|
-
if (rowInfo.groupKeys) {
|
|
3257
|
-
|
|
3268
|
+
const theGroupKeys = rowInfo.groupKeys ? [...rowInfo.groupKeys] : [];
|
|
3269
|
+
if (rowInfo.groupKeys && rowInfo.isGroupRow) {
|
|
3270
|
+
theGroupKeys.pop();
|
|
3258
3271
|
}
|
|
3259
|
-
const cacheKeys =
|
|
3272
|
+
const cacheKeys = theGroupKeys.length ? theGroupKeys : rootGroupKeys;
|
|
3260
3273
|
const indexInGroup = rowInfo.indexInGroup;
|
|
3261
3274
|
if (!rowLoaded) {
|
|
3262
3275
|
let fnCalls = perGroupFnCalls.get(cacheKeys);
|
|
@@ -3273,7 +3286,7 @@ function lazyLoadRange(options, cache) {
|
|
|
3273
3286
|
const currentFnCall = {
|
|
3274
3287
|
lazyLoadStartIndex: batchStartIndexInGroup,
|
|
3275
3288
|
lazyLoadBatchSize,
|
|
3276
|
-
groupKeys:
|
|
3289
|
+
groupKeys: theGroupKeys
|
|
3277
3290
|
};
|
|
3278
3291
|
if (!fnCalls[batchStartRowId]) {
|
|
3279
3292
|
fnCalls[batchStartRowId] = currentFnCall;
|
|
@@ -3883,7 +3896,11 @@ function concludeReducer(params) {
|
|
|
3883
3896
|
state.postSortDataArray = dataArray;
|
|
3884
3897
|
state.groupDeepMap = void 0;
|
|
3885
3898
|
const toPrimaryKey = (data) => {
|
|
3886
|
-
|
|
3899
|
+
const pk = data[state.primaryKey];
|
|
3900
|
+
if (Array.isArray(pk)) {
|
|
3901
|
+
debugger;
|
|
3902
|
+
}
|
|
3903
|
+
return pk;
|
|
3887
3904
|
};
|
|
3888
3905
|
if (shouldGroup) {
|
|
3889
3906
|
if (shouldGroupAgain) {
|
|
@@ -3925,7 +3942,7 @@ function concludeReducer(params) {
|
|
|
3925
3942
|
state.pivotColumns = void 0;
|
|
3926
3943
|
const arrayDifferentAfterSortStep = previousState.postSortDataArray != state.postSortDataArray;
|
|
3927
3944
|
if (arrayDifferentAfterSortStep) {
|
|
3928
|
-
rowInfoDataArray = dataArray.map((data, index) => toRowInfo(data, toPrimaryKey(data), index));
|
|
3945
|
+
rowInfoDataArray = dataArray.map((data, index) => toRowInfo(data, data ? toPrimaryKey(data) : index, index));
|
|
3929
3946
|
}
|
|
3930
3947
|
}
|
|
3931
3948
|
state.postGroupDataArray = rowInfoDataArray;
|
|
@@ -4035,7 +4052,7 @@ function useColumnsWhen() {
|
|
|
4035
4052
|
}, [pivotTotalColumnPosition]);
|
|
4036
4053
|
useColumnsWhenInlineGroupRenderStrategy(groupByMap);
|
|
4037
4054
|
const { toggleGroupRow } = useColumnsWhenGrouping();
|
|
4038
|
-
useHideEmptyGroupColumns(
|
|
4055
|
+
useHideEmptyGroupColumns();
|
|
4039
4056
|
return { toggleGroupRow };
|
|
4040
4057
|
}
|
|
4041
4058
|
function useColumnsWhenInlineGroupRenderStrategy(groupByMap) {
|
|
@@ -4157,9 +4174,13 @@ function useColumnsWhenGrouping() {
|
|
|
4157
4174
|
]);
|
|
4158
4175
|
return { toggleGroupRow };
|
|
4159
4176
|
}
|
|
4160
|
-
function useHideEmptyGroupColumns(
|
|
4177
|
+
function useHideEmptyGroupColumns() {
|
|
4161
4178
|
const {
|
|
4162
|
-
componentState: {
|
|
4179
|
+
componentState: {
|
|
4180
|
+
groupBy,
|
|
4181
|
+
groupRowsState,
|
|
4182
|
+
originalLazyGroupDataChangeDetect
|
|
4183
|
+
},
|
|
4163
4184
|
getState: getDataSourceState
|
|
4164
4185
|
} = useDataSourceContextValue();
|
|
4165
4186
|
const {
|
|
@@ -4212,8 +4233,8 @@ function useHideEmptyGroupColumns(groupRowsMap) {
|
|
|
4212
4233
|
getDataSourceState,
|
|
4213
4234
|
groupRenderStrategy,
|
|
4214
4235
|
generatedColumns,
|
|
4236
|
+
originalLazyGroupDataChangeDetect,
|
|
4215
4237
|
groupBy,
|
|
4216
|
-
groupRowsMap,
|
|
4217
4238
|
hideEmptyGroupColumns ? groupRowsState : null,
|
|
4218
4239
|
hideEmptyGroupColumns
|
|
4219
4240
|
]);
|
|
@@ -7609,7 +7630,7 @@ var useLicense = (licenseKey = "") => {
|
|
|
7609
7630
|
const valid = (0, import_react43.useMemo)(() => {
|
|
7610
7631
|
let valid2 = isValidLicense(licenseKey, {
|
|
7611
7632
|
publishedAt: 1624970570587,
|
|
7612
|
-
version: "0.2.
|
|
7633
|
+
version: "0.2.3"
|
|
7613
7634
|
});
|
|
7614
7635
|
if (!licenseKey && !valid2 && isInsideSandbox) {
|
|
7615
7636
|
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.2.
|
|
4
|
+
"version": "0.2.3",
|
|
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": 1644358278775
|
|
18
18
|
}
|