@infinite-table/infinite-react 0.2.13 → 0.2.14
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 +2 -1
- package/index.esm.js +93 -57
- package/index.js +93 -57
- package/package.json +2 -2
package/index.d.ts
CHANGED
|
@@ -47,6 +47,7 @@ declare class DeepMap<KeyType, ValueType> {
|
|
|
47
47
|
private map;
|
|
48
48
|
private length;
|
|
49
49
|
private revision;
|
|
50
|
+
private emptyKey;
|
|
50
51
|
static clone<KeyType, ValueType>(map: DeepMap<KeyType, ValueType>): DeepMap<KeyType, ValueType>;
|
|
51
52
|
constructor(initial?: [KeyType[], ValueType][]);
|
|
52
53
|
set(keys: KeyType[] & {
|
|
@@ -390,7 +391,7 @@ interface DataSourceDataParams<T> {
|
|
|
390
391
|
groupKeys?: any[];
|
|
391
392
|
aggregationReducers?: DataSourcePropAggregationReducers<T>;
|
|
392
393
|
livePaginationCursor?: DataSourceLivePaginationCursorValue;
|
|
393
|
-
|
|
394
|
+
__cursorId?: DataSourceSetupState<T>['cursorId'];
|
|
394
395
|
changes?: DataSourceDataParamsChanges<T>;
|
|
395
396
|
}
|
|
396
397
|
declare type DataSourceDataParamsChanges<T> = Partial<Record<keyof Omit<DataSourceDataParams<T>, 'originalDataArray' | 'changes'>, true>>;
|
package/index.esm.js
CHANGED
|
@@ -1474,7 +1474,7 @@ var useInfiniteTable = () => {
|
|
|
1474
1474
|
// src/components/InfiniteTable/hooks/useComputedVisibleColumns.ts
|
|
1475
1475
|
import { useMemo as useMemo2 } from "react";
|
|
1476
1476
|
|
|
1477
|
-
// src/components/flexbox/index.
|
|
1477
|
+
// src/components/flexbox/index.ts
|
|
1478
1478
|
var computeFlex = (params) => {
|
|
1479
1479
|
const {
|
|
1480
1480
|
availableSize,
|
|
@@ -2847,6 +2847,7 @@ var DeepMap = class {
|
|
|
2847
2847
|
this.map = new Map();
|
|
2848
2848
|
this.length = 0;
|
|
2849
2849
|
this.revision = 0;
|
|
2850
|
+
this.emptyKey = Symbol("emptyKey");
|
|
2850
2851
|
this.visit = (fn) => {
|
|
2851
2852
|
this.map.forEach((_, k) => this.visitKey(k, this.map, [], fn));
|
|
2852
2853
|
};
|
|
@@ -2858,13 +2859,19 @@ var DeepMap = class {
|
|
|
2858
2859
|
return;
|
|
2859
2860
|
}
|
|
2860
2861
|
let i = 0;
|
|
2861
|
-
currentMap.
|
|
2862
|
+
const hasEmptyKey = currentMap.has(this.emptyKey);
|
|
2863
|
+
let allowEmptyKey = true;
|
|
2864
|
+
const iterator = (_, key) => {
|
|
2862
2865
|
const pair = currentMap.get(key);
|
|
2863
2866
|
if (!pair) {
|
|
2864
2867
|
return;
|
|
2865
2868
|
}
|
|
2866
2869
|
const { map: map2 } = pair;
|
|
2867
|
-
const
|
|
2870
|
+
const isEmptyKey = key === this.emptyKey;
|
|
2871
|
+
if (isEmptyKey && !allowEmptyKey) {
|
|
2872
|
+
return;
|
|
2873
|
+
}
|
|
2874
|
+
const keys = isEmptyKey ? [] : [...parentKeys, key];
|
|
2868
2875
|
const next = map2 ? () => this.visitWithNext(keys, fn, map2) : void 0;
|
|
2869
2876
|
if (pair.hasOwnProperty("value")) {
|
|
2870
2877
|
fn(pair.value, keys, i, next);
|
|
@@ -2872,7 +2879,13 @@ var DeepMap = class {
|
|
|
2872
2879
|
} else {
|
|
2873
2880
|
next == null ? void 0 : next();
|
|
2874
2881
|
}
|
|
2875
|
-
}
|
|
2882
|
+
};
|
|
2883
|
+
if (hasEmptyKey) {
|
|
2884
|
+
iterator(void 0, this.emptyKey);
|
|
2885
|
+
allowEmptyKey = false;
|
|
2886
|
+
i = 0;
|
|
2887
|
+
}
|
|
2888
|
+
currentMap.forEach(iterator);
|
|
2876
2889
|
};
|
|
2877
2890
|
if (initial) {
|
|
2878
2891
|
initial.forEach((entry) => {
|
|
@@ -2891,7 +2904,7 @@ var DeepMap = class {
|
|
|
2891
2904
|
set(keys, value) {
|
|
2892
2905
|
let currentMap = this.map;
|
|
2893
2906
|
if (!keys.length) {
|
|
2894
|
-
|
|
2907
|
+
keys = [this.emptyKey];
|
|
2895
2908
|
}
|
|
2896
2909
|
for (let i = 0, len = keys.length; i < len; i++) {
|
|
2897
2910
|
const key = keys[i];
|
|
@@ -2917,7 +2930,7 @@ var DeepMap = class {
|
|
|
2917
2930
|
var _a;
|
|
2918
2931
|
let currentMap = this.map;
|
|
2919
2932
|
if (!keys.length) {
|
|
2920
|
-
|
|
2933
|
+
keys = [this.emptyKey];
|
|
2921
2934
|
}
|
|
2922
2935
|
for (let i = 0, len = keys.length; i < len; i++) {
|
|
2923
2936
|
const key = keys[i];
|
|
@@ -2952,10 +2965,11 @@ var DeepMap = class {
|
|
|
2952
2965
|
this.revision = 0;
|
|
2953
2966
|
}
|
|
2954
2967
|
delete(keys) {
|
|
2955
|
-
keys = [...keys];
|
|
2956
2968
|
let currentMap = this.map;
|
|
2957
2969
|
if (!keys.length) {
|
|
2958
|
-
|
|
2970
|
+
keys = [this.emptyKey];
|
|
2971
|
+
} else {
|
|
2972
|
+
keys = [...keys];
|
|
2959
2973
|
}
|
|
2960
2974
|
let maps = [currentMap];
|
|
2961
2975
|
let result = false;
|
|
@@ -3008,7 +3022,7 @@ var DeepMap = class {
|
|
|
3008
3022
|
has(keys) {
|
|
3009
3023
|
let currentMap = this.map;
|
|
3010
3024
|
if (!keys.length) {
|
|
3011
|
-
|
|
3025
|
+
keys = [this.emptyKey];
|
|
3012
3026
|
}
|
|
3013
3027
|
for (let i = 0, len = keys.length; i < len; i++) {
|
|
3014
3028
|
const key = keys[i];
|
|
@@ -3032,7 +3046,7 @@ var DeepMap = class {
|
|
|
3032
3046
|
return;
|
|
3033
3047
|
}
|
|
3034
3048
|
const { map: map2 } = pair;
|
|
3035
|
-
const keys = [...parentKeys, key];
|
|
3049
|
+
const keys = key === this.emptyKey ? [] : [...parentKeys, key];
|
|
3036
3050
|
const next = once(() => {
|
|
3037
3051
|
if (map2) {
|
|
3038
3052
|
map2.forEach((_, k) => {
|
|
@@ -3048,7 +3062,12 @@ var DeepMap = class {
|
|
|
3048
3062
|
getArray(fn) {
|
|
3049
3063
|
const result = [];
|
|
3050
3064
|
this.visit((pair, keys) => {
|
|
3051
|
-
|
|
3065
|
+
const res = fn(__spreadProps(__spreadValues({}, pair), { keys }));
|
|
3066
|
+
if (keys.length === 0) {
|
|
3067
|
+
result.splice(0, 0, res);
|
|
3068
|
+
} else {
|
|
3069
|
+
result.push(res);
|
|
3070
|
+
}
|
|
3052
3071
|
});
|
|
3053
3072
|
return result;
|
|
3054
3073
|
}
|
|
@@ -3134,7 +3153,7 @@ function lazyGroup(groupParams, rootData) {
|
|
|
3134
3153
|
} = groupParams;
|
|
3135
3154
|
const deepMap = new DeepMap();
|
|
3136
3155
|
function traverseValues(pivotDeepMap, container, pivot2, pivotIndex = 0, currentPivotKeys2 = []) {
|
|
3137
|
-
const last = pivotIndex === pivot2.length - 1;
|
|
3156
|
+
const last = !pivot2.length || pivotIndex === pivot2.length - 1;
|
|
3138
3157
|
const values = container[(mappings == null ? void 0 : mappings.values) || "values"] || {};
|
|
3139
3158
|
for (var k in values)
|
|
3140
3159
|
if (values.hasOwnProperty(k)) {
|
|
@@ -3158,7 +3177,7 @@ function lazyGroup(groupParams, rootData) {
|
|
|
3158
3177
|
rootData.visitDepthFirst((lazyGroupRowInfo, keys, _index, next) => {
|
|
3159
3178
|
const [_rootKey, ...currentGroupKeys] = keys;
|
|
3160
3179
|
const dataArray = lazyGroupRowInfo.items;
|
|
3161
|
-
if (currentGroupKeys.length == groupBy.length) {
|
|
3180
|
+
if (currentGroupKeys.length == groupBy.length && groupBy.length) {
|
|
3162
3181
|
const deepMapGroupValue = deepMap.get(currentGroupKeys);
|
|
3163
3182
|
if (deepMapGroupValue) {
|
|
3164
3183
|
deepMapGroupValue.items = dataArray;
|
|
@@ -3180,9 +3199,11 @@ function lazyGroup(groupParams, rootData) {
|
|
|
3180
3199
|
const dataObject = dataArray[i].data;
|
|
3181
3200
|
const dataKeys = dataArray[i].keys;
|
|
3182
3201
|
let item = dataObject;
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
|
|
3202
|
+
if (dataKeys.length) {
|
|
3203
|
+
const { field: groupByProperty } = groupBy[dataKeys.length - 1];
|
|
3204
|
+
const key = item[groupByProperty];
|
|
3205
|
+
currentGroupKeys.push(key);
|
|
3206
|
+
}
|
|
3186
3207
|
const deepMapGroupValue = {
|
|
3187
3208
|
items: [],
|
|
3188
3209
|
commonData: dataObject,
|
|
@@ -3194,7 +3215,9 @@ function lazyGroup(groupParams, rootData) {
|
|
|
3194
3215
|
const pivotContainer = dataArray[i].pivot;
|
|
3195
3216
|
traverseValues(pivotDeepMap, pivotContainer, pivot, 0, currentPivotKeys);
|
|
3196
3217
|
}
|
|
3197
|
-
|
|
3218
|
+
if (dataKeys.length) {
|
|
3219
|
+
currentGroupKeys.pop();
|
|
3220
|
+
}
|
|
3198
3221
|
}
|
|
3199
3222
|
next == null ? void 0 : next();
|
|
3200
3223
|
});
|
|
@@ -3210,6 +3233,37 @@ function lazyGroup(groupParams, rootData) {
|
|
|
3210
3233
|
}
|
|
3211
3234
|
return result;
|
|
3212
3235
|
}
|
|
3236
|
+
function processGroup(deepMap, currentGroupKeys, currentPivotKeys, item, pivot, reducers, topLevelPivotColumns, initialReducerValue, defaultToKey = DEFAULT_TO_KEY) {
|
|
3237
|
+
const {
|
|
3238
|
+
items: currentGroupItems,
|
|
3239
|
+
reducerResults,
|
|
3240
|
+
pivotDeepMap
|
|
3241
|
+
} = deepMap.get(currentGroupKeys);
|
|
3242
|
+
currentGroupItems.push(item);
|
|
3243
|
+
if (reducers) {
|
|
3244
|
+
computeReducersFor(item, reducers, reducerResults);
|
|
3245
|
+
}
|
|
3246
|
+
if (pivot) {
|
|
3247
|
+
for (let pivotIndex = 0, pivotLength = pivot.length; pivotIndex < pivotLength; pivotIndex++) {
|
|
3248
|
+
const { field: pivotField, toKey: pivotToKey } = pivot[pivotIndex];
|
|
3249
|
+
const pivotKey = (pivotToKey || defaultToKey)(item[pivotField], item);
|
|
3250
|
+
currentPivotKeys.push(pivotKey);
|
|
3251
|
+
if (!pivotDeepMap.has(currentPivotKeys)) {
|
|
3252
|
+
topLevelPivotColumns.set(currentPivotKeys, true);
|
|
3253
|
+
pivotDeepMap == null ? void 0 : pivotDeepMap.set(currentPivotKeys, {
|
|
3254
|
+
reducerResults: __spreadValues({}, initialReducerValue),
|
|
3255
|
+
items: []
|
|
3256
|
+
});
|
|
3257
|
+
}
|
|
3258
|
+
const { reducerResults: pivotReducerResults, items: pivotGroupItems } = pivotDeepMap.get(currentPivotKeys);
|
|
3259
|
+
pivotGroupItems.push(item);
|
|
3260
|
+
if (reducers) {
|
|
3261
|
+
computeReducersFor(item, reducers, pivotReducerResults);
|
|
3262
|
+
}
|
|
3263
|
+
}
|
|
3264
|
+
currentPivotKeys.length = 0;
|
|
3265
|
+
}
|
|
3266
|
+
}
|
|
3213
3267
|
function group(groupParams, data) {
|
|
3214
3268
|
const {
|
|
3215
3269
|
groupBy,
|
|
@@ -3224,6 +3278,16 @@ function group(groupParams, data) {
|
|
|
3224
3278
|
let currentPivotKeys = [];
|
|
3225
3279
|
const initialReducerValue = initReducers(reducers);
|
|
3226
3280
|
const globalReducerResults = __spreadValues({}, initialReducerValue);
|
|
3281
|
+
if (!groupByLength) {
|
|
3282
|
+
const deepMapGroupValue = {
|
|
3283
|
+
items: [],
|
|
3284
|
+
reducerResults: __spreadValues({}, initialReducerValue)
|
|
3285
|
+
};
|
|
3286
|
+
if (pivot) {
|
|
3287
|
+
deepMapGroupValue.pivotDeepMap = new DeepMap();
|
|
3288
|
+
}
|
|
3289
|
+
deepMap.set(currentGroupKeys, deepMapGroupValue);
|
|
3290
|
+
}
|
|
3227
3291
|
for (let i = 0, len = data.length; i < len; i++) {
|
|
3228
3292
|
let item = data[i];
|
|
3229
3293
|
for (let groupByIndex = 0; groupByIndex < groupByLength; groupByIndex++) {
|
|
@@ -3240,38 +3304,10 @@ function group(groupParams, data) {
|
|
|
3240
3304
|
}
|
|
3241
3305
|
deepMap.set(currentGroupKeys, deepMapGroupValue);
|
|
3242
3306
|
}
|
|
3243
|
-
|
|
3244
|
-
|
|
3245
|
-
|
|
3246
|
-
|
|
3247
|
-
} = deepMap.get(currentGroupKeys);
|
|
3248
|
-
currentGroupItems.push(item);
|
|
3249
|
-
if (reducers) {
|
|
3250
|
-
computeReducersFor(item, reducers, reducerResults);
|
|
3251
|
-
}
|
|
3252
|
-
if (pivot) {
|
|
3253
|
-
for (let pivotIndex = 0, pivotLength = pivot.length; pivotIndex < pivotLength; pivotIndex++) {
|
|
3254
|
-
const { field: pivotField, toKey: pivotToKey } = pivot[pivotIndex];
|
|
3255
|
-
const pivotKey = (pivotToKey || defaultToKey)(item[pivotField], item);
|
|
3256
|
-
currentPivotKeys.push(pivotKey);
|
|
3257
|
-
if (!pivotDeepMap.has(currentPivotKeys)) {
|
|
3258
|
-
topLevelPivotColumns.set(currentPivotKeys, true);
|
|
3259
|
-
pivotDeepMap == null ? void 0 : pivotDeepMap.set(currentPivotKeys, {
|
|
3260
|
-
reducerResults: __spreadValues({}, initialReducerValue),
|
|
3261
|
-
items: []
|
|
3262
|
-
});
|
|
3263
|
-
}
|
|
3264
|
-
const {
|
|
3265
|
-
reducerResults: pivotReducerResults,
|
|
3266
|
-
items: pivotGroupItems
|
|
3267
|
-
} = pivotDeepMap.get(currentPivotKeys);
|
|
3268
|
-
pivotGroupItems.push(item);
|
|
3269
|
-
if (reducers) {
|
|
3270
|
-
computeReducersFor(item, reducers, pivotReducerResults);
|
|
3271
|
-
}
|
|
3272
|
-
}
|
|
3273
|
-
currentPivotKeys.length = 0;
|
|
3274
|
-
}
|
|
3307
|
+
processGroup(deepMap, currentGroupKeys, currentPivotKeys, item, pivot, reducers, topLevelPivotColumns, initialReducerValue, defaultToKey);
|
|
3308
|
+
}
|
|
3309
|
+
if (!groupByLength) {
|
|
3310
|
+
processGroup(deepMap, currentGroupKeys, currentPivotKeys, item, pivot, reducers, topLevelPivotColumns, initialReducerValue, defaultToKey);
|
|
3275
3311
|
}
|
|
3276
3312
|
if (reducers) {
|
|
3277
3313
|
computeReducersFor(item, reducers, globalReducerResults);
|
|
@@ -3515,7 +3551,7 @@ function buildDataSourceDataParams(componentState, overrides) {
|
|
|
3515
3551
|
};
|
|
3516
3552
|
if (componentState.livePagination !== void 0) {
|
|
3517
3553
|
dataSourceParams.livePaginationCursor = componentState.livePaginationCursor;
|
|
3518
|
-
dataSourceParams.
|
|
3554
|
+
dataSourceParams.__cursorId = componentState.cursorId;
|
|
3519
3555
|
}
|
|
3520
3556
|
if (componentState.lazyLoad) {
|
|
3521
3557
|
if (componentState.lazyLoadBatchSize != null && componentState.lazyLoadBatchSize > 0) {
|
|
@@ -3546,7 +3582,7 @@ function loadData(data, componentState, actions, overrides) {
|
|
|
3546
3582
|
const lazyGroupData = componentState.originalLazyGroupData;
|
|
3547
3583
|
const key = [LAZY_ROOT_KEY_FOR_GROUPS, ...dataParams.groupKeys || []];
|
|
3548
3584
|
const existingGroupRowInfo = lazyGroupData.get(key);
|
|
3549
|
-
if (existingGroupRowInfo && existingGroupRowInfo.cache) {
|
|
3585
|
+
if (existingGroupRowInfo && existingGroupRowInfo.cache && key.length > 1) {
|
|
3550
3586
|
const items = existingGroupRowInfo.items;
|
|
3551
3587
|
const len = items.length;
|
|
3552
3588
|
let allLoaded = true;
|
|
@@ -3705,7 +3741,8 @@ function useLoadData() {
|
|
|
3705
3741
|
const componentState2 = getComponentState();
|
|
3706
3742
|
if (initialRef.current) {
|
|
3707
3743
|
initialRef.current = false;
|
|
3708
|
-
|
|
3744
|
+
const dataParams = buildDataSourceDataParams(componentState2);
|
|
3745
|
+
actions.dataParams = dataParams;
|
|
3709
3746
|
}
|
|
3710
3747
|
}, depsObject);
|
|
3711
3748
|
}
|
|
@@ -3718,7 +3755,6 @@ function useLazyLoadRange() {
|
|
|
3718
3755
|
const loadingCache = useMemo4(() => {
|
|
3719
3756
|
return new Map();
|
|
3720
3757
|
}, [componentState.data]);
|
|
3721
|
-
globalThis.loadingCache = loadingCache;
|
|
3722
3758
|
const {
|
|
3723
3759
|
lazyLoadBatchSize,
|
|
3724
3760
|
notifyRenderRangeChange,
|
|
@@ -4160,7 +4196,7 @@ function getInterceptActions() {
|
|
|
4160
4196
|
},
|
|
4161
4197
|
cursorId: (cursorId, { actions, state }) => {
|
|
4162
4198
|
const dataParams = buildDataSourceDataParams(state, {
|
|
4163
|
-
cursorId
|
|
4199
|
+
__cursorId: cursorId
|
|
4164
4200
|
});
|
|
4165
4201
|
actions.dataParams = dataParams;
|
|
4166
4202
|
},
|
|
@@ -4330,7 +4366,7 @@ function getPivotColumnsAndColumnGroups({
|
|
|
4330
4366
|
next == null ? void 0 : next();
|
|
4331
4367
|
}
|
|
4332
4368
|
});
|
|
4333
|
-
if (
|
|
4369
|
+
if (!pivotLength) {
|
|
4334
4370
|
aggregationReducers.forEach((reducer, index) => {
|
|
4335
4371
|
columns.set(`total:${reducer.id}`, prepareColumn({
|
|
4336
4372
|
header: `${reducer.name || reducer.id} total`,
|
|
@@ -4862,7 +4898,7 @@ function getColumnsWhenGrouping(params) {
|
|
|
4862
4898
|
}, toggleGroupRow, groupColumn);
|
|
4863
4899
|
computedColumns.set(generatedGroupColumn.id || `group-by-${groupByForColumn.field}`, generatedGroupColumn);
|
|
4864
4900
|
});
|
|
4865
|
-
} else if (groupRenderStrategy === "single-column") {
|
|
4901
|
+
} else if (groupRenderStrategy === "single-column" && groupBy.length) {
|
|
4866
4902
|
const singleGroupColumn = getSingleGroupColumn({
|
|
4867
4903
|
groupCount: groupBy.length,
|
|
4868
4904
|
groupBy,
|
|
@@ -7884,7 +7920,7 @@ var useLicense = (licenseKey = "") => {
|
|
|
7884
7920
|
const valid = useMemo12(() => {
|
|
7885
7921
|
let valid2 = isValidLicense(licenseKey, {
|
|
7886
7922
|
publishedAt: 1624970570587,
|
|
7887
|
-
version: "0.2.
|
|
7923
|
+
version: "0.2.14"
|
|
7888
7924
|
});
|
|
7889
7925
|
if (!licenseKey && !valid2 && isInsidePlayground) {
|
|
7890
7926
|
return true;
|
package/index.js
CHANGED
|
@@ -1484,7 +1484,7 @@ var useInfiniteTable = () => {
|
|
|
1484
1484
|
// src/components/InfiniteTable/hooks/useComputedVisibleColumns.ts
|
|
1485
1485
|
var import_react8 = __toModule(require("react"));
|
|
1486
1486
|
|
|
1487
|
-
// src/components/flexbox/index.
|
|
1487
|
+
// src/components/flexbox/index.ts
|
|
1488
1488
|
var computeFlex = (params) => {
|
|
1489
1489
|
const {
|
|
1490
1490
|
availableSize,
|
|
@@ -2834,6 +2834,7 @@ var DeepMap = class {
|
|
|
2834
2834
|
this.map = new Map();
|
|
2835
2835
|
this.length = 0;
|
|
2836
2836
|
this.revision = 0;
|
|
2837
|
+
this.emptyKey = Symbol("emptyKey");
|
|
2837
2838
|
this.visit = (fn) => {
|
|
2838
2839
|
this.map.forEach((_, k) => this.visitKey(k, this.map, [], fn));
|
|
2839
2840
|
};
|
|
@@ -2845,13 +2846,19 @@ var DeepMap = class {
|
|
|
2845
2846
|
return;
|
|
2846
2847
|
}
|
|
2847
2848
|
let i = 0;
|
|
2848
|
-
currentMap.
|
|
2849
|
+
const hasEmptyKey = currentMap.has(this.emptyKey);
|
|
2850
|
+
let allowEmptyKey = true;
|
|
2851
|
+
const iterator = (_, key) => {
|
|
2849
2852
|
const pair = currentMap.get(key);
|
|
2850
2853
|
if (!pair) {
|
|
2851
2854
|
return;
|
|
2852
2855
|
}
|
|
2853
2856
|
const { map: map2 } = pair;
|
|
2854
|
-
const
|
|
2857
|
+
const isEmptyKey = key === this.emptyKey;
|
|
2858
|
+
if (isEmptyKey && !allowEmptyKey) {
|
|
2859
|
+
return;
|
|
2860
|
+
}
|
|
2861
|
+
const keys = isEmptyKey ? [] : [...parentKeys, key];
|
|
2855
2862
|
const next = map2 ? () => this.visitWithNext(keys, fn, map2) : void 0;
|
|
2856
2863
|
if (pair.hasOwnProperty("value")) {
|
|
2857
2864
|
fn(pair.value, keys, i, next);
|
|
@@ -2859,7 +2866,13 @@ var DeepMap = class {
|
|
|
2859
2866
|
} else {
|
|
2860
2867
|
next == null ? void 0 : next();
|
|
2861
2868
|
}
|
|
2862
|
-
}
|
|
2869
|
+
};
|
|
2870
|
+
if (hasEmptyKey) {
|
|
2871
|
+
iterator(void 0, this.emptyKey);
|
|
2872
|
+
allowEmptyKey = false;
|
|
2873
|
+
i = 0;
|
|
2874
|
+
}
|
|
2875
|
+
currentMap.forEach(iterator);
|
|
2863
2876
|
};
|
|
2864
2877
|
if (initial) {
|
|
2865
2878
|
initial.forEach((entry) => {
|
|
@@ -2878,7 +2891,7 @@ var DeepMap = class {
|
|
|
2878
2891
|
set(keys, value) {
|
|
2879
2892
|
let currentMap = this.map;
|
|
2880
2893
|
if (!keys.length) {
|
|
2881
|
-
|
|
2894
|
+
keys = [this.emptyKey];
|
|
2882
2895
|
}
|
|
2883
2896
|
for (let i = 0, len = keys.length; i < len; i++) {
|
|
2884
2897
|
const key = keys[i];
|
|
@@ -2904,7 +2917,7 @@ var DeepMap = class {
|
|
|
2904
2917
|
var _a;
|
|
2905
2918
|
let currentMap = this.map;
|
|
2906
2919
|
if (!keys.length) {
|
|
2907
|
-
|
|
2920
|
+
keys = [this.emptyKey];
|
|
2908
2921
|
}
|
|
2909
2922
|
for (let i = 0, len = keys.length; i < len; i++) {
|
|
2910
2923
|
const key = keys[i];
|
|
@@ -2939,10 +2952,11 @@ var DeepMap = class {
|
|
|
2939
2952
|
this.revision = 0;
|
|
2940
2953
|
}
|
|
2941
2954
|
delete(keys) {
|
|
2942
|
-
keys = [...keys];
|
|
2943
2955
|
let currentMap = this.map;
|
|
2944
2956
|
if (!keys.length) {
|
|
2945
|
-
|
|
2957
|
+
keys = [this.emptyKey];
|
|
2958
|
+
} else {
|
|
2959
|
+
keys = [...keys];
|
|
2946
2960
|
}
|
|
2947
2961
|
let maps = [currentMap];
|
|
2948
2962
|
let result = false;
|
|
@@ -2995,7 +3009,7 @@ var DeepMap = class {
|
|
|
2995
3009
|
has(keys) {
|
|
2996
3010
|
let currentMap = this.map;
|
|
2997
3011
|
if (!keys.length) {
|
|
2998
|
-
|
|
3012
|
+
keys = [this.emptyKey];
|
|
2999
3013
|
}
|
|
3000
3014
|
for (let i = 0, len = keys.length; i < len; i++) {
|
|
3001
3015
|
const key = keys[i];
|
|
@@ -3019,7 +3033,7 @@ var DeepMap = class {
|
|
|
3019
3033
|
return;
|
|
3020
3034
|
}
|
|
3021
3035
|
const { map: map2 } = pair;
|
|
3022
|
-
const keys = [...parentKeys, key];
|
|
3036
|
+
const keys = key === this.emptyKey ? [] : [...parentKeys, key];
|
|
3023
3037
|
const next = once(() => {
|
|
3024
3038
|
if (map2) {
|
|
3025
3039
|
map2.forEach((_, k) => {
|
|
@@ -3035,7 +3049,12 @@ var DeepMap = class {
|
|
|
3035
3049
|
getArray(fn) {
|
|
3036
3050
|
const result = [];
|
|
3037
3051
|
this.visit((pair, keys) => {
|
|
3038
|
-
|
|
3052
|
+
const res = fn(__spreadProps(__spreadValues({}, pair), { keys }));
|
|
3053
|
+
if (keys.length === 0) {
|
|
3054
|
+
result.splice(0, 0, res);
|
|
3055
|
+
} else {
|
|
3056
|
+
result.push(res);
|
|
3057
|
+
}
|
|
3039
3058
|
});
|
|
3040
3059
|
return result;
|
|
3041
3060
|
}
|
|
@@ -3121,7 +3140,7 @@ function lazyGroup(groupParams, rootData) {
|
|
|
3121
3140
|
} = groupParams;
|
|
3122
3141
|
const deepMap = new DeepMap();
|
|
3123
3142
|
function traverseValues(pivotDeepMap, container, pivot2, pivotIndex = 0, currentPivotKeys2 = []) {
|
|
3124
|
-
const last = pivotIndex === pivot2.length - 1;
|
|
3143
|
+
const last = !pivot2.length || pivotIndex === pivot2.length - 1;
|
|
3125
3144
|
const values = container[(mappings == null ? void 0 : mappings.values) || "values"] || {};
|
|
3126
3145
|
for (var k in values)
|
|
3127
3146
|
if (values.hasOwnProperty(k)) {
|
|
@@ -3145,7 +3164,7 @@ function lazyGroup(groupParams, rootData) {
|
|
|
3145
3164
|
rootData.visitDepthFirst((lazyGroupRowInfo, keys, _index, next) => {
|
|
3146
3165
|
const [_rootKey, ...currentGroupKeys] = keys;
|
|
3147
3166
|
const dataArray = lazyGroupRowInfo.items;
|
|
3148
|
-
if (currentGroupKeys.length == groupBy.length) {
|
|
3167
|
+
if (currentGroupKeys.length == groupBy.length && groupBy.length) {
|
|
3149
3168
|
const deepMapGroupValue = deepMap.get(currentGroupKeys);
|
|
3150
3169
|
if (deepMapGroupValue) {
|
|
3151
3170
|
deepMapGroupValue.items = dataArray;
|
|
@@ -3167,9 +3186,11 @@ function lazyGroup(groupParams, rootData) {
|
|
|
3167
3186
|
const dataObject = dataArray[i].data;
|
|
3168
3187
|
const dataKeys = dataArray[i].keys;
|
|
3169
3188
|
let item = dataObject;
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
|
|
3189
|
+
if (dataKeys.length) {
|
|
3190
|
+
const { field: groupByProperty } = groupBy[dataKeys.length - 1];
|
|
3191
|
+
const key = item[groupByProperty];
|
|
3192
|
+
currentGroupKeys.push(key);
|
|
3193
|
+
}
|
|
3173
3194
|
const deepMapGroupValue = {
|
|
3174
3195
|
items: [],
|
|
3175
3196
|
commonData: dataObject,
|
|
@@ -3181,7 +3202,9 @@ function lazyGroup(groupParams, rootData) {
|
|
|
3181
3202
|
const pivotContainer = dataArray[i].pivot;
|
|
3182
3203
|
traverseValues(pivotDeepMap, pivotContainer, pivot, 0, currentPivotKeys);
|
|
3183
3204
|
}
|
|
3184
|
-
|
|
3205
|
+
if (dataKeys.length) {
|
|
3206
|
+
currentGroupKeys.pop();
|
|
3207
|
+
}
|
|
3185
3208
|
}
|
|
3186
3209
|
next == null ? void 0 : next();
|
|
3187
3210
|
});
|
|
@@ -3197,6 +3220,37 @@ function lazyGroup(groupParams, rootData) {
|
|
|
3197
3220
|
}
|
|
3198
3221
|
return result;
|
|
3199
3222
|
}
|
|
3223
|
+
function processGroup(deepMap, currentGroupKeys, currentPivotKeys, item, pivot, reducers, topLevelPivotColumns, initialReducerValue, defaultToKey = DEFAULT_TO_KEY) {
|
|
3224
|
+
const {
|
|
3225
|
+
items: currentGroupItems,
|
|
3226
|
+
reducerResults,
|
|
3227
|
+
pivotDeepMap
|
|
3228
|
+
} = deepMap.get(currentGroupKeys);
|
|
3229
|
+
currentGroupItems.push(item);
|
|
3230
|
+
if (reducers) {
|
|
3231
|
+
computeReducersFor(item, reducers, reducerResults);
|
|
3232
|
+
}
|
|
3233
|
+
if (pivot) {
|
|
3234
|
+
for (let pivotIndex = 0, pivotLength = pivot.length; pivotIndex < pivotLength; pivotIndex++) {
|
|
3235
|
+
const { field: pivotField, toKey: pivotToKey } = pivot[pivotIndex];
|
|
3236
|
+
const pivotKey = (pivotToKey || defaultToKey)(item[pivotField], item);
|
|
3237
|
+
currentPivotKeys.push(pivotKey);
|
|
3238
|
+
if (!pivotDeepMap.has(currentPivotKeys)) {
|
|
3239
|
+
topLevelPivotColumns.set(currentPivotKeys, true);
|
|
3240
|
+
pivotDeepMap == null ? void 0 : pivotDeepMap.set(currentPivotKeys, {
|
|
3241
|
+
reducerResults: __spreadValues({}, initialReducerValue),
|
|
3242
|
+
items: []
|
|
3243
|
+
});
|
|
3244
|
+
}
|
|
3245
|
+
const { reducerResults: pivotReducerResults, items: pivotGroupItems } = pivotDeepMap.get(currentPivotKeys);
|
|
3246
|
+
pivotGroupItems.push(item);
|
|
3247
|
+
if (reducers) {
|
|
3248
|
+
computeReducersFor(item, reducers, pivotReducerResults);
|
|
3249
|
+
}
|
|
3250
|
+
}
|
|
3251
|
+
currentPivotKeys.length = 0;
|
|
3252
|
+
}
|
|
3253
|
+
}
|
|
3200
3254
|
function group(groupParams, data) {
|
|
3201
3255
|
const {
|
|
3202
3256
|
groupBy,
|
|
@@ -3211,6 +3265,16 @@ function group(groupParams, data) {
|
|
|
3211
3265
|
let currentPivotKeys = [];
|
|
3212
3266
|
const initialReducerValue = initReducers(reducers);
|
|
3213
3267
|
const globalReducerResults = __spreadValues({}, initialReducerValue);
|
|
3268
|
+
if (!groupByLength) {
|
|
3269
|
+
const deepMapGroupValue = {
|
|
3270
|
+
items: [],
|
|
3271
|
+
reducerResults: __spreadValues({}, initialReducerValue)
|
|
3272
|
+
};
|
|
3273
|
+
if (pivot) {
|
|
3274
|
+
deepMapGroupValue.pivotDeepMap = new DeepMap();
|
|
3275
|
+
}
|
|
3276
|
+
deepMap.set(currentGroupKeys, deepMapGroupValue);
|
|
3277
|
+
}
|
|
3214
3278
|
for (let i = 0, len = data.length; i < len; i++) {
|
|
3215
3279
|
let item = data[i];
|
|
3216
3280
|
for (let groupByIndex = 0; groupByIndex < groupByLength; groupByIndex++) {
|
|
@@ -3227,38 +3291,10 @@ function group(groupParams, data) {
|
|
|
3227
3291
|
}
|
|
3228
3292
|
deepMap.set(currentGroupKeys, deepMapGroupValue);
|
|
3229
3293
|
}
|
|
3230
|
-
|
|
3231
|
-
|
|
3232
|
-
|
|
3233
|
-
|
|
3234
|
-
} = deepMap.get(currentGroupKeys);
|
|
3235
|
-
currentGroupItems.push(item);
|
|
3236
|
-
if (reducers) {
|
|
3237
|
-
computeReducersFor(item, reducers, reducerResults);
|
|
3238
|
-
}
|
|
3239
|
-
if (pivot) {
|
|
3240
|
-
for (let pivotIndex = 0, pivotLength = pivot.length; pivotIndex < pivotLength; pivotIndex++) {
|
|
3241
|
-
const { field: pivotField, toKey: pivotToKey } = pivot[pivotIndex];
|
|
3242
|
-
const pivotKey = (pivotToKey || defaultToKey)(item[pivotField], item);
|
|
3243
|
-
currentPivotKeys.push(pivotKey);
|
|
3244
|
-
if (!pivotDeepMap.has(currentPivotKeys)) {
|
|
3245
|
-
topLevelPivotColumns.set(currentPivotKeys, true);
|
|
3246
|
-
pivotDeepMap == null ? void 0 : pivotDeepMap.set(currentPivotKeys, {
|
|
3247
|
-
reducerResults: __spreadValues({}, initialReducerValue),
|
|
3248
|
-
items: []
|
|
3249
|
-
});
|
|
3250
|
-
}
|
|
3251
|
-
const {
|
|
3252
|
-
reducerResults: pivotReducerResults,
|
|
3253
|
-
items: pivotGroupItems
|
|
3254
|
-
} = pivotDeepMap.get(currentPivotKeys);
|
|
3255
|
-
pivotGroupItems.push(item);
|
|
3256
|
-
if (reducers) {
|
|
3257
|
-
computeReducersFor(item, reducers, pivotReducerResults);
|
|
3258
|
-
}
|
|
3259
|
-
}
|
|
3260
|
-
currentPivotKeys.length = 0;
|
|
3261
|
-
}
|
|
3294
|
+
processGroup(deepMap, currentGroupKeys, currentPivotKeys, item, pivot, reducers, topLevelPivotColumns, initialReducerValue, defaultToKey);
|
|
3295
|
+
}
|
|
3296
|
+
if (!groupByLength) {
|
|
3297
|
+
processGroup(deepMap, currentGroupKeys, currentPivotKeys, item, pivot, reducers, topLevelPivotColumns, initialReducerValue, defaultToKey);
|
|
3262
3298
|
}
|
|
3263
3299
|
if (reducers) {
|
|
3264
3300
|
computeReducersFor(item, reducers, globalReducerResults);
|
|
@@ -3502,7 +3538,7 @@ function buildDataSourceDataParams(componentState, overrides) {
|
|
|
3502
3538
|
};
|
|
3503
3539
|
if (componentState.livePagination !== void 0) {
|
|
3504
3540
|
dataSourceParams.livePaginationCursor = componentState.livePaginationCursor;
|
|
3505
|
-
dataSourceParams.
|
|
3541
|
+
dataSourceParams.__cursorId = componentState.cursorId;
|
|
3506
3542
|
}
|
|
3507
3543
|
if (componentState.lazyLoad) {
|
|
3508
3544
|
if (componentState.lazyLoadBatchSize != null && componentState.lazyLoadBatchSize > 0) {
|
|
@@ -3533,7 +3569,7 @@ function loadData(data, componentState, actions, overrides) {
|
|
|
3533
3569
|
const lazyGroupData = componentState.originalLazyGroupData;
|
|
3534
3570
|
const key = [LAZY_ROOT_KEY_FOR_GROUPS, ...dataParams.groupKeys || []];
|
|
3535
3571
|
const existingGroupRowInfo = lazyGroupData.get(key);
|
|
3536
|
-
if (existingGroupRowInfo && existingGroupRowInfo.cache) {
|
|
3572
|
+
if (existingGroupRowInfo && existingGroupRowInfo.cache && key.length > 1) {
|
|
3537
3573
|
const items = existingGroupRowInfo.items;
|
|
3538
3574
|
const len = items.length;
|
|
3539
3575
|
let allLoaded = true;
|
|
@@ -3692,7 +3728,8 @@ function useLoadData() {
|
|
|
3692
3728
|
const componentState2 = getComponentState();
|
|
3693
3729
|
if (initialRef.current) {
|
|
3694
3730
|
initialRef.current = false;
|
|
3695
|
-
|
|
3731
|
+
const dataParams = buildDataSourceDataParams(componentState2);
|
|
3732
|
+
actions.dataParams = dataParams;
|
|
3696
3733
|
}
|
|
3697
3734
|
}, depsObject);
|
|
3698
3735
|
}
|
|
@@ -3705,7 +3742,6 @@ function useLazyLoadRange() {
|
|
|
3705
3742
|
const loadingCache = (0, import_react15.useMemo)(() => {
|
|
3706
3743
|
return new Map();
|
|
3707
3744
|
}, [componentState.data]);
|
|
3708
|
-
globalThis.loadingCache = loadingCache;
|
|
3709
3745
|
const {
|
|
3710
3746
|
lazyLoadBatchSize,
|
|
3711
3747
|
notifyRenderRangeChange,
|
|
@@ -4147,7 +4183,7 @@ function getInterceptActions() {
|
|
|
4147
4183
|
},
|
|
4148
4184
|
cursorId: (cursorId, { actions, state }) => {
|
|
4149
4185
|
const dataParams = buildDataSourceDataParams(state, {
|
|
4150
|
-
cursorId
|
|
4186
|
+
__cursorId: cursorId
|
|
4151
4187
|
});
|
|
4152
4188
|
actions.dataParams = dataParams;
|
|
4153
4189
|
},
|
|
@@ -4317,7 +4353,7 @@ function getPivotColumnsAndColumnGroups({
|
|
|
4317
4353
|
next == null ? void 0 : next();
|
|
4318
4354
|
}
|
|
4319
4355
|
});
|
|
4320
|
-
if (
|
|
4356
|
+
if (!pivotLength) {
|
|
4321
4357
|
aggregationReducers.forEach((reducer, index) => {
|
|
4322
4358
|
columns.set(`total:${reducer.id}`, prepareColumn({
|
|
4323
4359
|
header: `${reducer.name || reducer.id} total`,
|
|
@@ -4849,7 +4885,7 @@ function getColumnsWhenGrouping(params) {
|
|
|
4849
4885
|
}, toggleGroupRow, groupColumn);
|
|
4850
4886
|
computedColumns.set(generatedGroupColumn.id || `group-by-${groupByForColumn.field}`, generatedGroupColumn);
|
|
4851
4887
|
});
|
|
4852
|
-
} else if (groupRenderStrategy === "single-column") {
|
|
4888
|
+
} else if (groupRenderStrategy === "single-column" && groupBy.length) {
|
|
4853
4889
|
const singleGroupColumn = getSingleGroupColumn({
|
|
4854
4890
|
groupCount: groupBy.length,
|
|
4855
4891
|
groupBy,
|
|
@@ -7792,7 +7828,7 @@ var useLicense = (licenseKey = "") => {
|
|
|
7792
7828
|
const valid = (0, import_react42.useMemo)(() => {
|
|
7793
7829
|
let valid2 = isValidLicense(licenseKey, {
|
|
7794
7830
|
publishedAt: 1624970570587,
|
|
7795
|
-
version: "0.2.
|
|
7831
|
+
version: "0.2.14"
|
|
7796
7832
|
});
|
|
7797
7833
|
if (!licenseKey && !valid2 && isInsidePlayground) {
|
|
7798
7834
|
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.14",
|
|
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": 1647350101044
|
|
18
18
|
}
|