@infinite-table/infinite-react 0.2.11 → 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 +239 -217
- package/index.esm.js +146 -86
- package/index.js +146 -86
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -629,6 +629,7 @@ __export(exports, {
|
|
|
629
629
|
InfiniteTable: () => InfiniteTable,
|
|
630
630
|
InfiniteTableClassName: () => InfiniteTableClassName,
|
|
631
631
|
InfiniteTableComponent: () => InfiniteTableComponent,
|
|
632
|
+
debounce: () => debounce,
|
|
632
633
|
flatten: () => flatten,
|
|
633
634
|
getComponentStateRoot: () => getComponentStateRoot,
|
|
634
635
|
group: () => group,
|
|
@@ -639,6 +640,20 @@ __export(exports, {
|
|
|
639
640
|
useEffectWithChanges: () => useEffectWithChanges
|
|
640
641
|
});
|
|
641
642
|
|
|
643
|
+
// src/components/utils/debounce.ts
|
|
644
|
+
function debounce(fn, { wait }) {
|
|
645
|
+
let timeout = null;
|
|
646
|
+
return function(...args) {
|
|
647
|
+
const context = this;
|
|
648
|
+
if (timeout !== null) {
|
|
649
|
+
clearTimeout(timeout);
|
|
650
|
+
}
|
|
651
|
+
timeout = setTimeout(() => {
|
|
652
|
+
fn.apply(context, args);
|
|
653
|
+
}, wait);
|
|
654
|
+
};
|
|
655
|
+
}
|
|
656
|
+
|
|
642
657
|
// src/components/InfiniteTable/index.tsx
|
|
643
658
|
var React34 = __toModule(require("react"));
|
|
644
659
|
|
|
@@ -1469,7 +1484,7 @@ var useInfiniteTable = () => {
|
|
|
1469
1484
|
// src/components/InfiniteTable/hooks/useComputedVisibleColumns.ts
|
|
1470
1485
|
var import_react8 = __toModule(require("react"));
|
|
1471
1486
|
|
|
1472
|
-
// src/components/flexbox/index.
|
|
1487
|
+
// src/components/flexbox/index.ts
|
|
1473
1488
|
var computeFlex = (params) => {
|
|
1474
1489
|
const {
|
|
1475
1490
|
availableSize,
|
|
@@ -1740,7 +1755,6 @@ var getComputedVisibleColumns = ({
|
|
|
1740
1755
|
}
|
|
1741
1756
|
return acc;
|
|
1742
1757
|
}, {});
|
|
1743
|
-
console.log(columnSizing, "columnSizing");
|
|
1744
1758
|
const flexResult = computeFlex({
|
|
1745
1759
|
availableSize: Math.max(bodySize.width - (viewportReservedWidth != null ? viewportReservedWidth : 0) - getScrollbarWidth(), 0),
|
|
1746
1760
|
maxSize: columnMaxWidth,
|
|
@@ -2109,6 +2123,7 @@ var useComputedVisibleColumns = ({
|
|
|
2109
2123
|
pinnedEndMaxWidth,
|
|
2110
2124
|
pinnedStartMaxWidth,
|
|
2111
2125
|
columnSizing,
|
|
2126
|
+
columnTypes,
|
|
2112
2127
|
columnPinning,
|
|
2113
2128
|
columnsRenderId,
|
|
2114
2129
|
pinningRenderId
|
|
@@ -2139,7 +2154,7 @@ var sortAscending = (a, b) => a - b;
|
|
|
2139
2154
|
// src/components/InfiniteTable/hooks/useComputed.ts
|
|
2140
2155
|
var import_react18 = __toModule(require("react"));
|
|
2141
2156
|
|
|
2142
|
-
// src/components/hooks/useComponentState.tsx
|
|
2157
|
+
// src/components/hooks/useComponentState/index.tsx
|
|
2143
2158
|
var React2 = __toModule(require("react"));
|
|
2144
2159
|
var import_react11 = __toModule(require("react"));
|
|
2145
2160
|
|
|
@@ -2201,7 +2216,7 @@ var usePrevious = (value, initialValue) => {
|
|
|
2201
2216
|
return ref.current;
|
|
2202
2217
|
};
|
|
2203
2218
|
|
|
2204
|
-
// src/components/hooks/useComponentState.tsx
|
|
2219
|
+
// src/components/hooks/useComponentState/index.tsx
|
|
2205
2220
|
var notifyChange = (props, propName, newValue) => {
|
|
2206
2221
|
const upperPropName = toUpperFirst(propName);
|
|
2207
2222
|
const callbackPropName = `on${upperPropName}Change`;
|
|
@@ -2819,6 +2834,7 @@ var DeepMap = class {
|
|
|
2819
2834
|
this.map = new Map();
|
|
2820
2835
|
this.length = 0;
|
|
2821
2836
|
this.revision = 0;
|
|
2837
|
+
this.emptyKey = Symbol("emptyKey");
|
|
2822
2838
|
this.visit = (fn) => {
|
|
2823
2839
|
this.map.forEach((_, k) => this.visitKey(k, this.map, [], fn));
|
|
2824
2840
|
};
|
|
@@ -2830,13 +2846,19 @@ var DeepMap = class {
|
|
|
2830
2846
|
return;
|
|
2831
2847
|
}
|
|
2832
2848
|
let i = 0;
|
|
2833
|
-
currentMap.
|
|
2849
|
+
const hasEmptyKey = currentMap.has(this.emptyKey);
|
|
2850
|
+
let allowEmptyKey = true;
|
|
2851
|
+
const iterator = (_, key) => {
|
|
2834
2852
|
const pair = currentMap.get(key);
|
|
2835
2853
|
if (!pair) {
|
|
2836
2854
|
return;
|
|
2837
2855
|
}
|
|
2838
2856
|
const { map: map2 } = pair;
|
|
2839
|
-
const
|
|
2857
|
+
const isEmptyKey = key === this.emptyKey;
|
|
2858
|
+
if (isEmptyKey && !allowEmptyKey) {
|
|
2859
|
+
return;
|
|
2860
|
+
}
|
|
2861
|
+
const keys = isEmptyKey ? [] : [...parentKeys, key];
|
|
2840
2862
|
const next = map2 ? () => this.visitWithNext(keys, fn, map2) : void 0;
|
|
2841
2863
|
if (pair.hasOwnProperty("value")) {
|
|
2842
2864
|
fn(pair.value, keys, i, next);
|
|
@@ -2844,7 +2866,13 @@ var DeepMap = class {
|
|
|
2844
2866
|
} else {
|
|
2845
2867
|
next == null ? void 0 : next();
|
|
2846
2868
|
}
|
|
2847
|
-
}
|
|
2869
|
+
};
|
|
2870
|
+
if (hasEmptyKey) {
|
|
2871
|
+
iterator(void 0, this.emptyKey);
|
|
2872
|
+
allowEmptyKey = false;
|
|
2873
|
+
i = 0;
|
|
2874
|
+
}
|
|
2875
|
+
currentMap.forEach(iterator);
|
|
2848
2876
|
};
|
|
2849
2877
|
if (initial) {
|
|
2850
2878
|
initial.forEach((entry) => {
|
|
@@ -2863,7 +2891,7 @@ var DeepMap = class {
|
|
|
2863
2891
|
set(keys, value) {
|
|
2864
2892
|
let currentMap = this.map;
|
|
2865
2893
|
if (!keys.length) {
|
|
2866
|
-
|
|
2894
|
+
keys = [this.emptyKey];
|
|
2867
2895
|
}
|
|
2868
2896
|
for (let i = 0, len = keys.length; i < len; i++) {
|
|
2869
2897
|
const key = keys[i];
|
|
@@ -2889,7 +2917,7 @@ var DeepMap = class {
|
|
|
2889
2917
|
var _a;
|
|
2890
2918
|
let currentMap = this.map;
|
|
2891
2919
|
if (!keys.length) {
|
|
2892
|
-
|
|
2920
|
+
keys = [this.emptyKey];
|
|
2893
2921
|
}
|
|
2894
2922
|
for (let i = 0, len = keys.length; i < len; i++) {
|
|
2895
2923
|
const key = keys[i];
|
|
@@ -2924,10 +2952,11 @@ var DeepMap = class {
|
|
|
2924
2952
|
this.revision = 0;
|
|
2925
2953
|
}
|
|
2926
2954
|
delete(keys) {
|
|
2927
|
-
keys = [...keys];
|
|
2928
2955
|
let currentMap = this.map;
|
|
2929
2956
|
if (!keys.length) {
|
|
2930
|
-
|
|
2957
|
+
keys = [this.emptyKey];
|
|
2958
|
+
} else {
|
|
2959
|
+
keys = [...keys];
|
|
2931
2960
|
}
|
|
2932
2961
|
let maps = [currentMap];
|
|
2933
2962
|
let result = false;
|
|
@@ -2980,7 +3009,7 @@ var DeepMap = class {
|
|
|
2980
3009
|
has(keys) {
|
|
2981
3010
|
let currentMap = this.map;
|
|
2982
3011
|
if (!keys.length) {
|
|
2983
|
-
|
|
3012
|
+
keys = [this.emptyKey];
|
|
2984
3013
|
}
|
|
2985
3014
|
for (let i = 0, len = keys.length; i < len; i++) {
|
|
2986
3015
|
const key = keys[i];
|
|
@@ -3004,7 +3033,7 @@ var DeepMap = class {
|
|
|
3004
3033
|
return;
|
|
3005
3034
|
}
|
|
3006
3035
|
const { map: map2 } = pair;
|
|
3007
|
-
const keys = [...parentKeys, key];
|
|
3036
|
+
const keys = key === this.emptyKey ? [] : [...parentKeys, key];
|
|
3008
3037
|
const next = once(() => {
|
|
3009
3038
|
if (map2) {
|
|
3010
3039
|
map2.forEach((_, k) => {
|
|
@@ -3020,7 +3049,12 @@ var DeepMap = class {
|
|
|
3020
3049
|
getArray(fn) {
|
|
3021
3050
|
const result = [];
|
|
3022
3051
|
this.visit((pair, keys) => {
|
|
3023
|
-
|
|
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
|
+
}
|
|
3024
3058
|
});
|
|
3025
3059
|
return result;
|
|
3026
3060
|
}
|
|
@@ -3106,7 +3140,7 @@ function lazyGroup(groupParams, rootData) {
|
|
|
3106
3140
|
} = groupParams;
|
|
3107
3141
|
const deepMap = new DeepMap();
|
|
3108
3142
|
function traverseValues(pivotDeepMap, container, pivot2, pivotIndex = 0, currentPivotKeys2 = []) {
|
|
3109
|
-
const last = pivotIndex === pivot2.length - 1;
|
|
3143
|
+
const last = !pivot2.length || pivotIndex === pivot2.length - 1;
|
|
3110
3144
|
const values = container[(mappings == null ? void 0 : mappings.values) || "values"] || {};
|
|
3111
3145
|
for (var k in values)
|
|
3112
3146
|
if (values.hasOwnProperty(k)) {
|
|
@@ -3130,7 +3164,7 @@ function lazyGroup(groupParams, rootData) {
|
|
|
3130
3164
|
rootData.visitDepthFirst((lazyGroupRowInfo, keys, _index, next) => {
|
|
3131
3165
|
const [_rootKey, ...currentGroupKeys] = keys;
|
|
3132
3166
|
const dataArray = lazyGroupRowInfo.items;
|
|
3133
|
-
if (currentGroupKeys.length == groupBy.length) {
|
|
3167
|
+
if (currentGroupKeys.length == groupBy.length && groupBy.length) {
|
|
3134
3168
|
const deepMapGroupValue = deepMap.get(currentGroupKeys);
|
|
3135
3169
|
if (deepMapGroupValue) {
|
|
3136
3170
|
deepMapGroupValue.items = dataArray;
|
|
@@ -3152,9 +3186,11 @@ function lazyGroup(groupParams, rootData) {
|
|
|
3152
3186
|
const dataObject = dataArray[i].data;
|
|
3153
3187
|
const dataKeys = dataArray[i].keys;
|
|
3154
3188
|
let item = dataObject;
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
|
|
3189
|
+
if (dataKeys.length) {
|
|
3190
|
+
const { field: groupByProperty } = groupBy[dataKeys.length - 1];
|
|
3191
|
+
const key = item[groupByProperty];
|
|
3192
|
+
currentGroupKeys.push(key);
|
|
3193
|
+
}
|
|
3158
3194
|
const deepMapGroupValue = {
|
|
3159
3195
|
items: [],
|
|
3160
3196
|
commonData: dataObject,
|
|
@@ -3166,7 +3202,9 @@ function lazyGroup(groupParams, rootData) {
|
|
|
3166
3202
|
const pivotContainer = dataArray[i].pivot;
|
|
3167
3203
|
traverseValues(pivotDeepMap, pivotContainer, pivot, 0, currentPivotKeys);
|
|
3168
3204
|
}
|
|
3169
|
-
|
|
3205
|
+
if (dataKeys.length) {
|
|
3206
|
+
currentGroupKeys.pop();
|
|
3207
|
+
}
|
|
3170
3208
|
}
|
|
3171
3209
|
next == null ? void 0 : next();
|
|
3172
3210
|
});
|
|
@@ -3182,6 +3220,37 @@ function lazyGroup(groupParams, rootData) {
|
|
|
3182
3220
|
}
|
|
3183
3221
|
return result;
|
|
3184
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
|
+
}
|
|
3185
3254
|
function group(groupParams, data) {
|
|
3186
3255
|
const {
|
|
3187
3256
|
groupBy,
|
|
@@ -3196,6 +3265,16 @@ function group(groupParams, data) {
|
|
|
3196
3265
|
let currentPivotKeys = [];
|
|
3197
3266
|
const initialReducerValue = initReducers(reducers);
|
|
3198
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
|
+
}
|
|
3199
3278
|
for (let i = 0, len = data.length; i < len; i++) {
|
|
3200
3279
|
let item = data[i];
|
|
3201
3280
|
for (let groupByIndex = 0; groupByIndex < groupByLength; groupByIndex++) {
|
|
@@ -3212,38 +3291,10 @@ function group(groupParams, data) {
|
|
|
3212
3291
|
}
|
|
3213
3292
|
deepMap.set(currentGroupKeys, deepMapGroupValue);
|
|
3214
3293
|
}
|
|
3215
|
-
|
|
3216
|
-
|
|
3217
|
-
|
|
3218
|
-
|
|
3219
|
-
} = deepMap.get(currentGroupKeys);
|
|
3220
|
-
currentGroupItems.push(item);
|
|
3221
|
-
if (reducers) {
|
|
3222
|
-
computeReducersFor(item, reducers, reducerResults);
|
|
3223
|
-
}
|
|
3224
|
-
if (pivot) {
|
|
3225
|
-
for (let pivotIndex = 0, pivotLength = pivot.length; pivotIndex < pivotLength; pivotIndex++) {
|
|
3226
|
-
const { field: pivotField, toKey: pivotToKey } = pivot[pivotIndex];
|
|
3227
|
-
const pivotKey = (pivotToKey || defaultToKey)(item[pivotField], item);
|
|
3228
|
-
currentPivotKeys.push(pivotKey);
|
|
3229
|
-
if (!pivotDeepMap.has(currentPivotKeys)) {
|
|
3230
|
-
topLevelPivotColumns.set(currentPivotKeys, true);
|
|
3231
|
-
pivotDeepMap == null ? void 0 : pivotDeepMap.set(currentPivotKeys, {
|
|
3232
|
-
reducerResults: __spreadValues({}, initialReducerValue),
|
|
3233
|
-
items: []
|
|
3234
|
-
});
|
|
3235
|
-
}
|
|
3236
|
-
const {
|
|
3237
|
-
reducerResults: pivotReducerResults,
|
|
3238
|
-
items: pivotGroupItems
|
|
3239
|
-
} = pivotDeepMap.get(currentPivotKeys);
|
|
3240
|
-
pivotGroupItems.push(item);
|
|
3241
|
-
if (reducers) {
|
|
3242
|
-
computeReducersFor(item, reducers, pivotReducerResults);
|
|
3243
|
-
}
|
|
3244
|
-
}
|
|
3245
|
-
currentPivotKeys.length = 0;
|
|
3246
|
-
}
|
|
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);
|
|
3247
3298
|
}
|
|
3248
3299
|
if (reducers) {
|
|
3249
3300
|
computeReducersFor(item, reducers, globalReducerResults);
|
|
@@ -3462,20 +3513,6 @@ function useEffectWithChanges(fn, deps) {
|
|
|
3462
3513
|
}, useEffectDeps);
|
|
3463
3514
|
}
|
|
3464
3515
|
|
|
3465
|
-
// src/components/utils/debounce.ts
|
|
3466
|
-
function debounce(fn, { wait }) {
|
|
3467
|
-
let timeout = null;
|
|
3468
|
-
return function(...args) {
|
|
3469
|
-
const context = this;
|
|
3470
|
-
if (timeout !== null) {
|
|
3471
|
-
clearTimeout(timeout);
|
|
3472
|
-
}
|
|
3473
|
-
timeout = setTimeout(() => {
|
|
3474
|
-
fn.apply(context, args);
|
|
3475
|
-
}, wait);
|
|
3476
|
-
};
|
|
3477
|
-
}
|
|
3478
|
-
|
|
3479
3516
|
// src/components/DataSource/privateHooks/useLoadData.ts
|
|
3480
3517
|
var getRafPromise = () => new Promise((resolve) => {
|
|
3481
3518
|
requestAnimationFrame(resolve);
|
|
@@ -3501,7 +3538,7 @@ function buildDataSourceDataParams(componentState, overrides) {
|
|
|
3501
3538
|
};
|
|
3502
3539
|
if (componentState.livePagination !== void 0) {
|
|
3503
3540
|
dataSourceParams.livePaginationCursor = componentState.livePaginationCursor;
|
|
3504
|
-
dataSourceParams.
|
|
3541
|
+
dataSourceParams.__cursorId = componentState.cursorId;
|
|
3505
3542
|
}
|
|
3506
3543
|
if (componentState.lazyLoad) {
|
|
3507
3544
|
if (componentState.lazyLoadBatchSize != null && componentState.lazyLoadBatchSize > 0) {
|
|
@@ -3532,7 +3569,7 @@ function loadData(data, componentState, actions, overrides) {
|
|
|
3532
3569
|
const lazyGroupData = componentState.originalLazyGroupData;
|
|
3533
3570
|
const key = [LAZY_ROOT_KEY_FOR_GROUPS, ...dataParams.groupKeys || []];
|
|
3534
3571
|
const existingGroupRowInfo = lazyGroupData.get(key);
|
|
3535
|
-
if (existingGroupRowInfo && existingGroupRowInfo.cache) {
|
|
3572
|
+
if (existingGroupRowInfo && existingGroupRowInfo.cache && key.length > 1) {
|
|
3536
3573
|
const items = existingGroupRowInfo.items;
|
|
3537
3574
|
const len = items.length;
|
|
3538
3575
|
let allLoaded = true;
|
|
@@ -3598,10 +3635,14 @@ function loadData(data, componentState, actions, overrides) {
|
|
|
3598
3635
|
lazyGroupData.set(key, newGroupRowInfo);
|
|
3599
3636
|
}
|
|
3600
3637
|
skipAssign = true;
|
|
3601
|
-
|
|
3638
|
+
let skipTriggerChangeAsAlreadyOriginalArrayWasUpdated = false;
|
|
3602
3639
|
if (!dataParams.groupKeys || !dataParams.groupKeys.length) {
|
|
3603
3640
|
const topLevelItems = lazyGroupData.get([LAZY_ROOT_KEY_FOR_GROUPS]);
|
|
3604
3641
|
actions.originalDataArray = [...topLevelItems.items];
|
|
3642
|
+
skipTriggerChangeAsAlreadyOriginalArrayWasUpdated = true;
|
|
3643
|
+
}
|
|
3644
|
+
if (!skipTriggerChangeAsAlreadyOriginalArrayWasUpdated) {
|
|
3645
|
+
actions.originalLazyGroupDataChangeDetect = getChangeDetect();
|
|
3605
3646
|
}
|
|
3606
3647
|
}
|
|
3607
3648
|
} else {
|
|
@@ -3687,7 +3728,8 @@ function useLoadData() {
|
|
|
3687
3728
|
const componentState2 = getComponentState();
|
|
3688
3729
|
if (initialRef.current) {
|
|
3689
3730
|
initialRef.current = false;
|
|
3690
|
-
|
|
3731
|
+
const dataParams = buildDataSourceDataParams(componentState2);
|
|
3732
|
+
actions.dataParams = dataParams;
|
|
3691
3733
|
}
|
|
3692
3734
|
}, depsObject);
|
|
3693
3735
|
}
|
|
@@ -3700,7 +3742,6 @@ function useLazyLoadRange() {
|
|
|
3700
3742
|
const loadingCache = (0, import_react15.useMemo)(() => {
|
|
3701
3743
|
return new Map();
|
|
3702
3744
|
}, [componentState.data]);
|
|
3703
|
-
globalThis.loadingCache = loadingCache;
|
|
3704
3745
|
const {
|
|
3705
3746
|
lazyLoadBatchSize,
|
|
3706
3747
|
notifyRenderRangeChange,
|
|
@@ -3708,13 +3749,13 @@ function useLazyLoadRange() {
|
|
|
3708
3749
|
scrollStopDelayUpdatedByTable
|
|
3709
3750
|
} = componentState;
|
|
3710
3751
|
const latestRenderRangeRef = (0, import_react15.useRef)(null);
|
|
3711
|
-
const loadRange = (
|
|
3752
|
+
const loadRange = (renderRange, cache = loadingCache) => {
|
|
3712
3753
|
const componentState2 = getComponentState();
|
|
3713
|
-
|
|
3714
|
-
if (!
|
|
3754
|
+
renderRange = renderRange || latestRenderRangeRef.current;
|
|
3755
|
+
if (!renderRange) {
|
|
3715
3756
|
return;
|
|
3716
3757
|
}
|
|
3717
|
-
const { renderStartIndex: startIndex, renderEndIndex: endIndex } =
|
|
3758
|
+
const { renderStartIndex: startIndex, renderEndIndex: endIndex } = renderRange;
|
|
3718
3759
|
if (!lazyLoadBatchSize || lazyLoadBatchSize <= 0) {
|
|
3719
3760
|
return;
|
|
3720
3761
|
}
|
|
@@ -3729,9 +3770,9 @@ function useLazyLoadRange() {
|
|
|
3729
3770
|
const debouncedLoadRange = (0, import_react15.useMemo)(() => debounce(loadRange, { wait: scrollStopDelayUpdatedByTable }), [scrollStopDelayUpdatedByTable]);
|
|
3730
3771
|
(0, import_react15.useEffect)(() => {
|
|
3731
3772
|
if (lazyLoadBatchSize && lazyLoadBatchSize > 0) {
|
|
3732
|
-
return notifyRenderRangeChange.onChange((
|
|
3733
|
-
latestRenderRangeRef.current =
|
|
3734
|
-
loadRange(
|
|
3773
|
+
return notifyRenderRangeChange.onChange((renderRange) => {
|
|
3774
|
+
latestRenderRangeRef.current = renderRange;
|
|
3775
|
+
loadRange(renderRange, loadingCache);
|
|
3735
3776
|
});
|
|
3736
3777
|
}
|
|
3737
3778
|
return;
|
|
@@ -4142,7 +4183,7 @@ function getInterceptActions() {
|
|
|
4142
4183
|
},
|
|
4143
4184
|
cursorId: (cursorId, { actions, state }) => {
|
|
4144
4185
|
const dataParams = buildDataSourceDataParams(state, {
|
|
4145
|
-
cursorId
|
|
4186
|
+
__cursorId: cursorId
|
|
4146
4187
|
});
|
|
4147
4188
|
actions.dataParams = dataParams;
|
|
4148
4189
|
},
|
|
@@ -4167,7 +4208,7 @@ function getInterceptActions() {
|
|
|
4167
4208
|
|
|
4168
4209
|
// src/utils/groupAndPivot/getPivotColumnsAndColumnGroups.ts
|
|
4169
4210
|
function prepareColumn(column) {
|
|
4170
|
-
const { pivotByAtIndex: pivotByForColumn } = column;
|
|
4211
|
+
const { pivotByAtIndex: pivotByForColumn, pivotAggregator } = column;
|
|
4171
4212
|
if (pivotByForColumn == null ? void 0 : pivotByForColumn.column) {
|
|
4172
4213
|
if (typeof pivotByForColumn.column === "function") {
|
|
4173
4214
|
Object.assign(column, pivotByForColumn.column({ column }));
|
|
@@ -4175,6 +4216,13 @@ function prepareColumn(column) {
|
|
|
4175
4216
|
Object.assign(column, pivotByForColumn.column);
|
|
4176
4217
|
}
|
|
4177
4218
|
}
|
|
4219
|
+
if (pivotAggregator == null ? void 0 : pivotAggregator.pivotColumn) {
|
|
4220
|
+
if (typeof pivotAggregator.pivotColumn === "function") {
|
|
4221
|
+
Object.assign(column, pivotAggregator.pivotColumn({ column }));
|
|
4222
|
+
} else {
|
|
4223
|
+
Object.assign(column, pivotAggregator.pivotColumn);
|
|
4224
|
+
}
|
|
4225
|
+
}
|
|
4178
4226
|
return column;
|
|
4179
4227
|
}
|
|
4180
4228
|
function prepareColumnGroup(columnGroup) {
|
|
@@ -4305,7 +4353,7 @@ function getPivotColumnsAndColumnGroups({
|
|
|
4305
4353
|
next == null ? void 0 : next();
|
|
4306
4354
|
}
|
|
4307
4355
|
});
|
|
4308
|
-
if (
|
|
4356
|
+
if (!pivotLength) {
|
|
4309
4357
|
aggregationReducers.forEach((reducer, index) => {
|
|
4310
4358
|
columns.set(`total:${reducer.id}`, prepareColumn({
|
|
4311
4359
|
header: `${reducer.name || reducer.id} total`,
|
|
@@ -4837,7 +4885,7 @@ function getColumnsWhenGrouping(params) {
|
|
|
4837
4885
|
}, toggleGroupRow, groupColumn);
|
|
4838
4886
|
computedColumns.set(generatedGroupColumn.id || `group-by-${groupByForColumn.field}`, generatedGroupColumn);
|
|
4839
4887
|
});
|
|
4840
|
-
} else if (groupRenderStrategy === "single-column") {
|
|
4888
|
+
} else if (groupRenderStrategy === "single-column" && groupBy.length) {
|
|
4841
4889
|
const singleGroupColumn = getSingleGroupColumn({
|
|
4842
4890
|
groupCount: groupBy.length,
|
|
4843
4891
|
groupBy,
|
|
@@ -4847,7 +4895,14 @@ function getColumnsWhenGrouping(params) {
|
|
|
4847
4895
|
computedColumns.set(singleGroupColumn.id || "group-by", singleGroupColumn);
|
|
4848
4896
|
}
|
|
4849
4897
|
if (pivotColumns) {
|
|
4898
|
+
const columnsByField = {};
|
|
4899
|
+
columns.forEach((col) => {
|
|
4900
|
+
if (col.field) {
|
|
4901
|
+
columnsByField[col.field] = col;
|
|
4902
|
+
}
|
|
4903
|
+
});
|
|
4850
4904
|
pivotColumns.forEach((col, key) => {
|
|
4905
|
+
var _a, _b;
|
|
4851
4906
|
if (col.pivotTotalColumn && pivotTotalColumnPosition === false) {
|
|
4852
4907
|
return;
|
|
4853
4908
|
}
|
|
@@ -4863,6 +4918,10 @@ function getColumnsWhenGrouping(params) {
|
|
|
4863
4918
|
column = __spreadValues(__spreadValues({}, column), pivotColumn);
|
|
4864
4919
|
}
|
|
4865
4920
|
}
|
|
4921
|
+
if (column.inheritFromColumn !== false) {
|
|
4922
|
+
const colToInheritFrom = typeof column.inheritFromColumn === "string" ? columns.get(column.inheritFromColumn) : ((_a = column.pivotAggregator) == null ? void 0 : _a.field) ? columnsByField[(_b = column.pivotAggregator) == null ? void 0 : _b.field] : void 0;
|
|
4923
|
+
column = __spreadValues(__spreadValues({}, colToInheritFrom), column);
|
|
4924
|
+
}
|
|
4866
4925
|
if (!column.render && column.renderValue) {
|
|
4867
4926
|
column.render = (renderOptions) => {
|
|
4868
4927
|
return column.renderValue(renderOptions);
|
|
@@ -7227,8 +7286,8 @@ function PinnedRowsContainer(props) {
|
|
|
7227
7286
|
}
|
|
7228
7287
|
function useRenderPinnedRow(params) {
|
|
7229
7288
|
const { getData, getState, columnsWidth, columns, rowSpan, verticalBrain } = params;
|
|
7289
|
+
const dataArray = getData();
|
|
7230
7290
|
const renderPinnedRow = (0, import_react37.useCallback)((rowParams) => {
|
|
7231
|
-
const dataArray = getData();
|
|
7232
7291
|
const rowInfo = dataArray[rowParams.rowIndex];
|
|
7233
7292
|
const { showZebraRows, showHoverRows } = getState();
|
|
7234
7293
|
const rowProps = __spreadValues({
|
|
@@ -7245,7 +7304,7 @@ function useRenderPinnedRow(params) {
|
|
|
7245
7304
|
columns
|
|
7246
7305
|
}, rowParams);
|
|
7247
7306
|
return /* @__PURE__ */ React30.createElement(TableRowUnvirtualized, __spreadValues({}, rowProps));
|
|
7248
|
-
}, [columnsWidth, columns, verticalBrain]);
|
|
7307
|
+
}, [columnsWidth, columns, verticalBrain, dataArray]);
|
|
7249
7308
|
return renderPinnedRow;
|
|
7250
7309
|
}
|
|
7251
7310
|
function usePinnedRenderingForSide(side, params) {
|
|
@@ -7283,6 +7342,7 @@ function usePinnedRenderingForSide(side, params) {
|
|
|
7283
7342
|
const renderRowPinned = useRenderPinnedRow({
|
|
7284
7343
|
getData,
|
|
7285
7344
|
getState,
|
|
7345
|
+
repaintId,
|
|
7286
7346
|
toggleGroupRow,
|
|
7287
7347
|
rowSpan,
|
|
7288
7348
|
verticalBrain: verticalVirtualBrain,
|
|
@@ -7428,7 +7488,7 @@ function useListRendering(param) {
|
|
|
7428
7488
|
} = componentState;
|
|
7429
7489
|
const prevDataSourceTimestamp = usePrevious(dataSourceState.updatedAt);
|
|
7430
7490
|
const repaintIdRef = (0, import_react40.useRef)(0);
|
|
7431
|
-
if (!shallowEqualObjects(prevComputed, computed)
|
|
7491
|
+
if (prevDataSourceTimestamp !== dataSourceState.updatedAt || !shallowEqualObjects(prevComputed, computed)) {
|
|
7432
7492
|
repaintIdRef.current++;
|
|
7433
7493
|
}
|
|
7434
7494
|
const repaintId = repaintIdRef.current;
|
|
@@ -7768,7 +7828,7 @@ var useLicense = (licenseKey = "") => {
|
|
|
7768
7828
|
const valid = (0, import_react42.useMemo)(() => {
|
|
7769
7829
|
let valid2 = isValidLicense(licenseKey, {
|
|
7770
7830
|
publishedAt: 1624970570587,
|
|
7771
|
-
version: "0.2.
|
|
7831
|
+
version: "0.2.14"
|
|
7772
7832
|
});
|
|
7773
7833
|
if (!licenseKey && !valid2 && isInsidePlayground) {
|
|
7774
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
|
}
|