@infinite-table/infinite-react 0.2.3 → 0.2.4
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 +11 -6
- package/index.esm.js +40 -24
- package/index.js +40 -24
- package/package.json +2 -2
package/index.d.ts
CHANGED
|
@@ -348,8 +348,7 @@ declare module "components/DataSource/types" {
|
|
|
348
348
|
export interface DataSourceMappedState<T> {
|
|
349
349
|
aggregationReducers?: DataSourceProps<T>['aggregationReducers'];
|
|
350
350
|
livePagination: DataSourceProps<T>['livePagination'];
|
|
351
|
-
|
|
352
|
-
lazyLoadBatchSize: DataSourceProps<T>['lazyLoadBatchSize'];
|
|
351
|
+
lazyLoad: DataSourceProps<T>['lazyLoad'];
|
|
353
352
|
onDataParamsChange: DataSourceProps<T>['onDataParamsChange'];
|
|
354
353
|
data: DataSourceProps<T>['data'];
|
|
355
354
|
primaryKey: DataSourceProps<T>['primaryKey'];
|
|
@@ -418,8 +417,9 @@ declare module "components/DataSource/types" {
|
|
|
418
417
|
primaryKey: keyof T;
|
|
419
418
|
fields?: (keyof T)[];
|
|
420
419
|
data: DataSourceData<T>;
|
|
421
|
-
|
|
422
|
-
|
|
420
|
+
lazyLoad?: boolean | {
|
|
421
|
+
batchSize?: number;
|
|
422
|
+
};
|
|
423
423
|
loading?: boolean;
|
|
424
424
|
defaultLoading?: boolean;
|
|
425
425
|
onLoadingChange?: (loading: boolean) => void;
|
|
@@ -457,6 +457,7 @@ declare module "components/DataSource/types" {
|
|
|
457
457
|
multiSort: boolean;
|
|
458
458
|
controlledSort: boolean;
|
|
459
459
|
livePaginationCursor?: DataSourceLivePaginationCursorValue;
|
|
460
|
+
lazyLoadBatchSize?: number;
|
|
460
461
|
}
|
|
461
462
|
export type DataSourceComponentActions<T> = ComponentStateActions<DataSourceState<T>>;
|
|
462
463
|
export interface DataSourceContextValue<T> {
|
|
@@ -533,10 +534,13 @@ declare module "components/DataSource/state/getInitialState" {
|
|
|
533
534
|
sortInfo: 1 | ((value: import("components/DataSource").DataSourceSortInfo<T> | undefined) => import("components/DataSource").DataSourceSingleSortInfo<T>[] | null);
|
|
534
535
|
groupBy: 1 | ((value: import("components/DataSource").DataSourcePropGroupBy<T> | undefined) => import("components/DataSource").DataSourcePropGroupBy<T>);
|
|
535
536
|
pivotBy: 1 | ((value: import("components/DataSource").DataSourcePropPivotBy<T> | undefined) => import("components/DataSource").DataSourcePropPivotBy<T> | undefined);
|
|
536
|
-
lazyLoadBatchSize: 1 | ((value: number | undefined) => number | undefined);
|
|
537
537
|
aggregationReducers: 1 | ((value: import("components/DataSource").DataSourcePropAggregationReducers<T> | undefined) => import("components/DataSource").DataSourcePropAggregationReducers<T> | undefined);
|
|
538
538
|
livePagination: 1 | ((value: boolean | undefined) => boolean | undefined);
|
|
539
|
-
|
|
539
|
+
lazyLoad: 1 | ((value: boolean | {
|
|
540
|
+
batchSize?: number | undefined;
|
|
541
|
+
} | undefined) => boolean | {
|
|
542
|
+
batchSize?: number | undefined;
|
|
543
|
+
} | undefined);
|
|
540
544
|
onDataParamsChange: 1 | ((value: ((dataParamsChange: DataSourceDataParams<T>) => void) | undefined) => ((dataParamsChange: DataSourceDataParams<T>) => void) | undefined);
|
|
541
545
|
primaryKey: 1 | ((value: keyof T) => keyof T);
|
|
542
546
|
groupRowsState: 1 | ((value: GroupRowsState<any> | undefined) => GroupRowsState<any>);
|
|
@@ -550,6 +554,7 @@ declare module "components/DataSource/state/getInitialState" {
|
|
|
550
554
|
export function onPropChange<T>(params: {
|
|
551
555
|
name: keyof T;
|
|
552
556
|
newValue: any;
|
|
557
|
+
oldValue: any;
|
|
553
558
|
}, props: DataSourceProps<T>, actions: DataSourceComponentActions<T>): void;
|
|
554
559
|
export function getInterceptActions<T>(): ComponentInterceptedActions<DataSourceState<T>>;
|
|
555
560
|
}
|
package/index.esm.js
CHANGED
|
@@ -3025,7 +3025,7 @@ function buildDataSourceDataParams(componentState, overrides) {
|
|
|
3025
3025
|
dataSourceParams.livePaginationCursor = componentState.livePaginationCursor;
|
|
3026
3026
|
dataSourceParams.cursorId = componentState.cursorId;
|
|
3027
3027
|
}
|
|
3028
|
-
if (componentState.
|
|
3028
|
+
if (componentState.lazyLoad) {
|
|
3029
3029
|
if (componentState.lazyLoadBatchSize != null && componentState.lazyLoadBatchSize > 0) {
|
|
3030
3030
|
dataSourceParams.lazyLoadBatchSize = componentState.lazyLoadBatchSize;
|
|
3031
3031
|
dataSourceParams.lazyLoadStartIndex = 0;
|
|
@@ -3050,9 +3050,9 @@ function buildDataSourceDataParams(componentState, overrides) {
|
|
|
3050
3050
|
}
|
|
3051
3051
|
function loadData(data, componentState, actions, overrides) {
|
|
3052
3052
|
const dataParams = buildDataSourceDataParams(componentState, overrides);
|
|
3053
|
-
if (componentState.
|
|
3053
|
+
if (componentState.lazyLoad) {
|
|
3054
3054
|
const lazyGroupData = componentState.originalLazyGroupData;
|
|
3055
|
-
const key = [LAZY_ROOT_KEY_FOR_GROUPS, ...dataParams.groupKeys];
|
|
3055
|
+
const key = [LAZY_ROOT_KEY_FOR_GROUPS, ...dataParams.groupKeys || []];
|
|
3056
3056
|
const existingGroupRowInfo = lazyGroupData.get(key);
|
|
3057
3057
|
if (existingGroupRowInfo && existingGroupRowInfo.cache) {
|
|
3058
3058
|
const items = existingGroupRowInfo.items;
|
|
@@ -3073,7 +3073,7 @@ function loadData(data, componentState, actions, overrides) {
|
|
|
3073
3073
|
data = data(dataParams);
|
|
3074
3074
|
}
|
|
3075
3075
|
const dataIsPromise = typeof data === "object" && typeof data.then === "function";
|
|
3076
|
-
if (dataIsPromise && !componentState.
|
|
3076
|
+
if (dataIsPromise && !componentState.lazyLoad) {
|
|
3077
3077
|
actions.loading = true;
|
|
3078
3078
|
}
|
|
3079
3079
|
return Promise.resolve(data).then((dataParam) => {
|
|
@@ -3089,9 +3089,9 @@ function loadData(data, componentState, actions, overrides) {
|
|
|
3089
3089
|
if (remoteData.mappings) {
|
|
3090
3090
|
actions.pivotMappings = remoteData.mappings;
|
|
3091
3091
|
}
|
|
3092
|
-
if (componentState.
|
|
3092
|
+
if (componentState.lazyLoad) {
|
|
3093
3093
|
const lazyGroupData = componentState.originalLazyGroupData;
|
|
3094
|
-
const key = [LAZY_ROOT_KEY_FOR_GROUPS, ...dataParams.groupKeys];
|
|
3094
|
+
const key = [LAZY_ROOT_KEY_FOR_GROUPS, ...dataParams.groupKeys || []];
|
|
3095
3095
|
const newGroupRowInfo = {
|
|
3096
3096
|
cache: !!remoteData.cache,
|
|
3097
3097
|
totalCount: (_a = remoteData.totalCount) != null ? _a : dataArray.length,
|
|
@@ -3121,6 +3121,10 @@ function loadData(data, componentState, actions, overrides) {
|
|
|
3121
3121
|
}
|
|
3122
3122
|
skipAssign = true;
|
|
3123
3123
|
actions.originalLazyGroupDataChangeDetect = getChangeDetect();
|
|
3124
|
+
if (!dataParams.groupKeys || !dataParams.groupKeys.length) {
|
|
3125
|
+
const topLevelItems = lazyGroupData.get([LAZY_ROOT_KEY_FOR_GROUPS]);
|
|
3126
|
+
actions.originalDataArray = [...topLevelItems.items];
|
|
3127
|
+
}
|
|
3124
3128
|
}
|
|
3125
3129
|
} else {
|
|
3126
3130
|
dataArray = dataParam;
|
|
@@ -3128,7 +3132,7 @@ function loadData(data, componentState, actions, overrides) {
|
|
|
3128
3132
|
if (!skipAssign) {
|
|
3129
3133
|
actions.originalDataArray = dataArray;
|
|
3130
3134
|
}
|
|
3131
|
-
if (dataIsPromise && !componentState.
|
|
3135
|
+
if (dataIsPromise && !componentState.lazyLoad) {
|
|
3132
3136
|
actions.loading = false;
|
|
3133
3137
|
}
|
|
3134
3138
|
});
|
|
@@ -3286,27 +3290,27 @@ function lazyLoadRange(options, cache) {
|
|
|
3286
3290
|
const cacheKeys = theGroupKeys.length ? theGroupKeys : rootGroupKeys;
|
|
3287
3291
|
const indexInGroup = rowInfo.indexInGroup;
|
|
3288
3292
|
if (!rowLoaded) {
|
|
3289
|
-
let
|
|
3293
|
+
let cachedFnCalls = perGroupFnCalls.get(cacheKeys);
|
|
3290
3294
|
const batchStartIndexInGroup = Math.floor(indexInGroup / lazyLoadBatchSize) * lazyLoadBatchSize;
|
|
3291
3295
|
const offset = rowInfo.indexInGroup - batchStartIndexInGroup;
|
|
3292
3296
|
const absoluteIndexOfBatchStart = dataArray[rowInfo.indexInAll - offset].indexInAll;
|
|
3293
3297
|
const batchStartRowLoaded = isRowLoaded(absoluteIndexOfBatchStart);
|
|
3294
3298
|
const batchStartRowId = dataArray[absoluteIndexOfBatchStart].id;
|
|
3295
|
-
if (batchStartRowLoaded || (
|
|
3299
|
+
if (batchStartRowLoaded || (cachedFnCalls == null ? void 0 : cachedFnCalls[batchStartRowId])) {
|
|
3296
3300
|
continue;
|
|
3297
3301
|
}
|
|
3298
|
-
const shouldSetFnCalls = !
|
|
3299
|
-
|
|
3302
|
+
const shouldSetFnCalls = !cachedFnCalls;
|
|
3303
|
+
cachedFnCalls = cachedFnCalls || {};
|
|
3300
3304
|
const currentFnCall = {
|
|
3301
3305
|
lazyLoadStartIndex: batchStartIndexInGroup,
|
|
3302
3306
|
lazyLoadBatchSize,
|
|
3303
3307
|
groupKeys: theGroupKeys
|
|
3304
3308
|
};
|
|
3305
|
-
if (!
|
|
3306
|
-
|
|
3309
|
+
if (!cachedFnCalls[batchStartRowId]) {
|
|
3310
|
+
cachedFnCalls[batchStartRowId] = currentFnCall;
|
|
3307
3311
|
}
|
|
3308
3312
|
if (shouldSetFnCalls) {
|
|
3309
|
-
perGroupFnCalls.set(cacheKeys,
|
|
3313
|
+
perGroupFnCalls.set(cacheKeys, cachedFnCalls);
|
|
3310
3314
|
}
|
|
3311
3315
|
}
|
|
3312
3316
|
}
|
|
@@ -3563,12 +3567,11 @@ function getCompareObjectForDataParams(dataParams) {
|
|
|
3563
3567
|
var forwardProps3 = (setupState) => {
|
|
3564
3568
|
return {
|
|
3565
3569
|
onDataParamsChange: (fn) => fn ? discardCallsWithEqualArg(fn, 100, getCompareObjectForDataParams) : void 0,
|
|
3566
|
-
|
|
3570
|
+
lazyLoad: (lazyLoad) => !!lazyLoad,
|
|
3567
3571
|
data: 1,
|
|
3568
3572
|
pivotBy: 1,
|
|
3569
3573
|
primaryKey: 1,
|
|
3570
3574
|
livePagination: 1,
|
|
3571
|
-
lazyLoadBatchSize: (lazyLoadBatchSize) => lazyLoadBatchSize != null ? lazyLoadBatchSize : -1,
|
|
3572
3575
|
aggregationReducers: 1,
|
|
3573
3576
|
collapseGroupRowsOnDataFunctionChange: (collapseGroupRowsOnDataFunctionChange) => collapseGroupRowsOnDataFunctionChange != null ? collapseGroupRowsOnDataFunctionChange : true,
|
|
3574
3577
|
loading: (loading) => loading != null ? loading : false,
|
|
@@ -3595,7 +3598,8 @@ function mapPropsToState2(params) {
|
|
|
3595
3598
|
const controlledSort = isControlledValue(props.sortInfo);
|
|
3596
3599
|
const result = {
|
|
3597
3600
|
controlledSort,
|
|
3598
|
-
multiSort: Array.isArray(controlledSort ? props.sortInfo : props.defaultSortInfo)
|
|
3601
|
+
multiSort: Array.isArray(controlledSort ? props.sortInfo : props.defaultSortInfo),
|
|
3602
|
+
lazyLoadBatchSize: typeof props.lazyLoad === "object" ? props.lazyLoad.batchSize : void 0
|
|
3599
3603
|
};
|
|
3600
3604
|
if (props.livePagination) {
|
|
3601
3605
|
const dataArrayChanged = !oldState || oldState.originalDataArray !== state.originalDataArray;
|
|
@@ -3608,7 +3612,7 @@ var debugFullLazyLoad = dbg("DataSource:fullLazyLoad");
|
|
|
3608
3612
|
function onPropChange(params, props, actions) {
|
|
3609
3613
|
const { name, newValue } = params;
|
|
3610
3614
|
if (name === "data" && typeof newValue === "function" && !props.groupRowsState) {
|
|
3611
|
-
if (props.
|
|
3615
|
+
if (props.lazyLoad) {
|
|
3612
3616
|
debugFullLazyLoad(`"data" function prop has changed`);
|
|
3613
3617
|
}
|
|
3614
3618
|
if (props.collapseGroupRowsOnDataFunctionChange !== false) {
|
|
@@ -3875,17 +3879,29 @@ function concludeReducer(params) {
|
|
|
3875
3879
|
var _a;
|
|
3876
3880
|
const { state, previousState } = params;
|
|
3877
3881
|
const sortInfo = state.sortInfo;
|
|
3878
|
-
|
|
3879
|
-
|
|
3882
|
+
let shouldSort = !!(sortInfo == null ? void 0 : sortInfo.length) && !state.controlledSort;
|
|
3883
|
+
if (state.lazyLoad || state.livePagination) {
|
|
3884
|
+
shouldSort = false;
|
|
3885
|
+
}
|
|
3886
|
+
let originalDataArrayChanged = haveDepsChanged(previousState, state, [
|
|
3880
3887
|
"originalDataArray"
|
|
3881
3888
|
]);
|
|
3889
|
+
const dataSourceChange = previousState && state.data !== previousState.data;
|
|
3890
|
+
let lazyLoadGroupDataChange = state.lazyLoad && previousState && (previousState.groupBy !== state.groupBy || previousState.sortInfo !== state.sortInfo);
|
|
3891
|
+
if (dataSourceChange) {
|
|
3892
|
+
lazyLoadGroupDataChange = true;
|
|
3893
|
+
}
|
|
3894
|
+
if (lazyLoadGroupDataChange) {
|
|
3895
|
+
state.originalLazyGroupData = new DeepMap();
|
|
3896
|
+
originalDataArrayChanged = true;
|
|
3897
|
+
}
|
|
3882
3898
|
const sortInfoChanged = haveDepsChanged(previousState, state, ["sortInfo"]);
|
|
3883
3899
|
const sortDepsChanged = originalDataArrayChanged || sortInfoChanged;
|
|
3884
3900
|
const shouldSortAgain = shouldSort && (sortDepsChanged || !state.lastSortDataArray);
|
|
3885
3901
|
const groupBy = state.groupBy;
|
|
3886
3902
|
const pivotBy = state.pivotBy;
|
|
3887
3903
|
const shouldGroup = groupBy.length || pivotBy;
|
|
3888
|
-
const groupsDepsChanged = haveDepsChanged(previousState, state, [
|
|
3904
|
+
const groupsDepsChanged = originalDataArrayChanged || haveDepsChanged(previousState, state, [
|
|
3889
3905
|
"generateGroupRows",
|
|
3890
3906
|
"originalDataArray",
|
|
3891
3907
|
"originalLazyGroupData",
|
|
@@ -3918,7 +3934,7 @@ function concludeReducer(params) {
|
|
|
3918
3934
|
};
|
|
3919
3935
|
if (shouldGroup) {
|
|
3920
3936
|
if (shouldGroupAgain) {
|
|
3921
|
-
const groupResult = state.
|
|
3937
|
+
const groupResult = state.lazyLoad ? lazyGroup({
|
|
3922
3938
|
groupBy,
|
|
3923
3939
|
pivot: pivotBy,
|
|
3924
3940
|
mappings: state.pivotMappings,
|
|
@@ -4027,7 +4043,7 @@ function useToggleGroupRow() {
|
|
|
4027
4043
|
const newState = new GroupRowsState(state.groupRowsState);
|
|
4028
4044
|
newState.toggleGroupRow(groupKeys);
|
|
4029
4045
|
dataSourceActions.groupRowsState = newState;
|
|
4030
|
-
if (state.
|
|
4046
|
+
if (state.lazyLoad && newState.isGroupRowExpanded(groupKeys)) {
|
|
4031
4047
|
loadData(state.data, state, dataSourceActions, {
|
|
4032
4048
|
groupKeys
|
|
4033
4049
|
});
|
|
@@ -7723,7 +7739,7 @@ var useLicense = (licenseKey = "") => {
|
|
|
7723
7739
|
const valid = useMemo12(() => {
|
|
7724
7740
|
let valid2 = isValidLicense(licenseKey, {
|
|
7725
7741
|
publishedAt: 1624970570587,
|
|
7726
|
-
version: "0.2.
|
|
7742
|
+
version: "0.2.4"
|
|
7727
7743
|
});
|
|
7728
7744
|
if (!licenseKey && !valid2 && isInsideSandbox) {
|
|
7729
7745
|
return true;
|
package/index.js
CHANGED
|
@@ -3011,7 +3011,7 @@ function buildDataSourceDataParams(componentState, overrides) {
|
|
|
3011
3011
|
dataSourceParams.livePaginationCursor = componentState.livePaginationCursor;
|
|
3012
3012
|
dataSourceParams.cursorId = componentState.cursorId;
|
|
3013
3013
|
}
|
|
3014
|
-
if (componentState.
|
|
3014
|
+
if (componentState.lazyLoad) {
|
|
3015
3015
|
if (componentState.lazyLoadBatchSize != null && componentState.lazyLoadBatchSize > 0) {
|
|
3016
3016
|
dataSourceParams.lazyLoadBatchSize = componentState.lazyLoadBatchSize;
|
|
3017
3017
|
dataSourceParams.lazyLoadStartIndex = 0;
|
|
@@ -3036,9 +3036,9 @@ function buildDataSourceDataParams(componentState, overrides) {
|
|
|
3036
3036
|
}
|
|
3037
3037
|
function loadData(data, componentState, actions, overrides) {
|
|
3038
3038
|
const dataParams = buildDataSourceDataParams(componentState, overrides);
|
|
3039
|
-
if (componentState.
|
|
3039
|
+
if (componentState.lazyLoad) {
|
|
3040
3040
|
const lazyGroupData = componentState.originalLazyGroupData;
|
|
3041
|
-
const key = [LAZY_ROOT_KEY_FOR_GROUPS, ...dataParams.groupKeys];
|
|
3041
|
+
const key = [LAZY_ROOT_KEY_FOR_GROUPS, ...dataParams.groupKeys || []];
|
|
3042
3042
|
const existingGroupRowInfo = lazyGroupData.get(key);
|
|
3043
3043
|
if (existingGroupRowInfo && existingGroupRowInfo.cache) {
|
|
3044
3044
|
const items = existingGroupRowInfo.items;
|
|
@@ -3059,7 +3059,7 @@ function loadData(data, componentState, actions, overrides) {
|
|
|
3059
3059
|
data = data(dataParams);
|
|
3060
3060
|
}
|
|
3061
3061
|
const dataIsPromise = typeof data === "object" && typeof data.then === "function";
|
|
3062
|
-
if (dataIsPromise && !componentState.
|
|
3062
|
+
if (dataIsPromise && !componentState.lazyLoad) {
|
|
3063
3063
|
actions.loading = true;
|
|
3064
3064
|
}
|
|
3065
3065
|
return Promise.resolve(data).then((dataParam) => {
|
|
@@ -3075,9 +3075,9 @@ function loadData(data, componentState, actions, overrides) {
|
|
|
3075
3075
|
if (remoteData.mappings) {
|
|
3076
3076
|
actions.pivotMappings = remoteData.mappings;
|
|
3077
3077
|
}
|
|
3078
|
-
if (componentState.
|
|
3078
|
+
if (componentState.lazyLoad) {
|
|
3079
3079
|
const lazyGroupData = componentState.originalLazyGroupData;
|
|
3080
|
-
const key = [LAZY_ROOT_KEY_FOR_GROUPS, ...dataParams.groupKeys];
|
|
3080
|
+
const key = [LAZY_ROOT_KEY_FOR_GROUPS, ...dataParams.groupKeys || []];
|
|
3081
3081
|
const newGroupRowInfo = {
|
|
3082
3082
|
cache: !!remoteData.cache,
|
|
3083
3083
|
totalCount: (_a = remoteData.totalCount) != null ? _a : dataArray.length,
|
|
@@ -3107,6 +3107,10 @@ function loadData(data, componentState, actions, overrides) {
|
|
|
3107
3107
|
}
|
|
3108
3108
|
skipAssign = true;
|
|
3109
3109
|
actions.originalLazyGroupDataChangeDetect = getChangeDetect();
|
|
3110
|
+
if (!dataParams.groupKeys || !dataParams.groupKeys.length) {
|
|
3111
|
+
const topLevelItems = lazyGroupData.get([LAZY_ROOT_KEY_FOR_GROUPS]);
|
|
3112
|
+
actions.originalDataArray = [...topLevelItems.items];
|
|
3113
|
+
}
|
|
3110
3114
|
}
|
|
3111
3115
|
} else {
|
|
3112
3116
|
dataArray = dataParam;
|
|
@@ -3114,7 +3118,7 @@ function loadData(data, componentState, actions, overrides) {
|
|
|
3114
3118
|
if (!skipAssign) {
|
|
3115
3119
|
actions.originalDataArray = dataArray;
|
|
3116
3120
|
}
|
|
3117
|
-
if (dataIsPromise && !componentState.
|
|
3121
|
+
if (dataIsPromise && !componentState.lazyLoad) {
|
|
3118
3122
|
actions.loading = false;
|
|
3119
3123
|
}
|
|
3120
3124
|
});
|
|
@@ -3272,27 +3276,27 @@ function lazyLoadRange(options, cache) {
|
|
|
3272
3276
|
const cacheKeys = theGroupKeys.length ? theGroupKeys : rootGroupKeys;
|
|
3273
3277
|
const indexInGroup = rowInfo.indexInGroup;
|
|
3274
3278
|
if (!rowLoaded) {
|
|
3275
|
-
let
|
|
3279
|
+
let cachedFnCalls = perGroupFnCalls.get(cacheKeys);
|
|
3276
3280
|
const batchStartIndexInGroup = Math.floor(indexInGroup / lazyLoadBatchSize) * lazyLoadBatchSize;
|
|
3277
3281
|
const offset = rowInfo.indexInGroup - batchStartIndexInGroup;
|
|
3278
3282
|
const absoluteIndexOfBatchStart = dataArray[rowInfo.indexInAll - offset].indexInAll;
|
|
3279
3283
|
const batchStartRowLoaded = isRowLoaded(absoluteIndexOfBatchStart);
|
|
3280
3284
|
const batchStartRowId = dataArray[absoluteIndexOfBatchStart].id;
|
|
3281
|
-
if (batchStartRowLoaded || (
|
|
3285
|
+
if (batchStartRowLoaded || (cachedFnCalls == null ? void 0 : cachedFnCalls[batchStartRowId])) {
|
|
3282
3286
|
continue;
|
|
3283
3287
|
}
|
|
3284
|
-
const shouldSetFnCalls = !
|
|
3285
|
-
|
|
3288
|
+
const shouldSetFnCalls = !cachedFnCalls;
|
|
3289
|
+
cachedFnCalls = cachedFnCalls || {};
|
|
3286
3290
|
const currentFnCall = {
|
|
3287
3291
|
lazyLoadStartIndex: batchStartIndexInGroup,
|
|
3288
3292
|
lazyLoadBatchSize,
|
|
3289
3293
|
groupKeys: theGroupKeys
|
|
3290
3294
|
};
|
|
3291
|
-
if (!
|
|
3292
|
-
|
|
3295
|
+
if (!cachedFnCalls[batchStartRowId]) {
|
|
3296
|
+
cachedFnCalls[batchStartRowId] = currentFnCall;
|
|
3293
3297
|
}
|
|
3294
3298
|
if (shouldSetFnCalls) {
|
|
3295
|
-
perGroupFnCalls.set(cacheKeys,
|
|
3299
|
+
perGroupFnCalls.set(cacheKeys, cachedFnCalls);
|
|
3296
3300
|
}
|
|
3297
3301
|
}
|
|
3298
3302
|
}
|
|
@@ -3549,12 +3553,11 @@ function getCompareObjectForDataParams(dataParams) {
|
|
|
3549
3553
|
var forwardProps3 = (setupState) => {
|
|
3550
3554
|
return {
|
|
3551
3555
|
onDataParamsChange: (fn) => fn ? discardCallsWithEqualArg(fn, 100, getCompareObjectForDataParams) : void 0,
|
|
3552
|
-
|
|
3556
|
+
lazyLoad: (lazyLoad) => !!lazyLoad,
|
|
3553
3557
|
data: 1,
|
|
3554
3558
|
pivotBy: 1,
|
|
3555
3559
|
primaryKey: 1,
|
|
3556
3560
|
livePagination: 1,
|
|
3557
|
-
lazyLoadBatchSize: (lazyLoadBatchSize) => lazyLoadBatchSize != null ? lazyLoadBatchSize : -1,
|
|
3558
3561
|
aggregationReducers: 1,
|
|
3559
3562
|
collapseGroupRowsOnDataFunctionChange: (collapseGroupRowsOnDataFunctionChange) => collapseGroupRowsOnDataFunctionChange != null ? collapseGroupRowsOnDataFunctionChange : true,
|
|
3560
3563
|
loading: (loading) => loading != null ? loading : false,
|
|
@@ -3581,7 +3584,8 @@ function mapPropsToState2(params) {
|
|
|
3581
3584
|
const controlledSort = isControlledValue(props.sortInfo);
|
|
3582
3585
|
const result = {
|
|
3583
3586
|
controlledSort,
|
|
3584
|
-
multiSort: Array.isArray(controlledSort ? props.sortInfo : props.defaultSortInfo)
|
|
3587
|
+
multiSort: Array.isArray(controlledSort ? props.sortInfo : props.defaultSortInfo),
|
|
3588
|
+
lazyLoadBatchSize: typeof props.lazyLoad === "object" ? props.lazyLoad.batchSize : void 0
|
|
3585
3589
|
};
|
|
3586
3590
|
if (props.livePagination) {
|
|
3587
3591
|
const dataArrayChanged = !oldState || oldState.originalDataArray !== state.originalDataArray;
|
|
@@ -3594,7 +3598,7 @@ var debugFullLazyLoad = dbg("DataSource:fullLazyLoad");
|
|
|
3594
3598
|
function onPropChange(params, props, actions) {
|
|
3595
3599
|
const { name, newValue } = params;
|
|
3596
3600
|
if (name === "data" && typeof newValue === "function" && !props.groupRowsState) {
|
|
3597
|
-
if (props.
|
|
3601
|
+
if (props.lazyLoad) {
|
|
3598
3602
|
debugFullLazyLoad(`"data" function prop has changed`);
|
|
3599
3603
|
}
|
|
3600
3604
|
if (props.collapseGroupRowsOnDataFunctionChange !== false) {
|
|
@@ -3861,17 +3865,29 @@ function concludeReducer(params) {
|
|
|
3861
3865
|
var _a;
|
|
3862
3866
|
const { state, previousState } = params;
|
|
3863
3867
|
const sortInfo = state.sortInfo;
|
|
3864
|
-
|
|
3865
|
-
|
|
3868
|
+
let shouldSort = !!(sortInfo == null ? void 0 : sortInfo.length) && !state.controlledSort;
|
|
3869
|
+
if (state.lazyLoad || state.livePagination) {
|
|
3870
|
+
shouldSort = false;
|
|
3871
|
+
}
|
|
3872
|
+
let originalDataArrayChanged = haveDepsChanged(previousState, state, [
|
|
3866
3873
|
"originalDataArray"
|
|
3867
3874
|
]);
|
|
3875
|
+
const dataSourceChange = previousState && state.data !== previousState.data;
|
|
3876
|
+
let lazyLoadGroupDataChange = state.lazyLoad && previousState && (previousState.groupBy !== state.groupBy || previousState.sortInfo !== state.sortInfo);
|
|
3877
|
+
if (dataSourceChange) {
|
|
3878
|
+
lazyLoadGroupDataChange = true;
|
|
3879
|
+
}
|
|
3880
|
+
if (lazyLoadGroupDataChange) {
|
|
3881
|
+
state.originalLazyGroupData = new DeepMap();
|
|
3882
|
+
originalDataArrayChanged = true;
|
|
3883
|
+
}
|
|
3868
3884
|
const sortInfoChanged = haveDepsChanged(previousState, state, ["sortInfo"]);
|
|
3869
3885
|
const sortDepsChanged = originalDataArrayChanged || sortInfoChanged;
|
|
3870
3886
|
const shouldSortAgain = shouldSort && (sortDepsChanged || !state.lastSortDataArray);
|
|
3871
3887
|
const groupBy = state.groupBy;
|
|
3872
3888
|
const pivotBy = state.pivotBy;
|
|
3873
3889
|
const shouldGroup = groupBy.length || pivotBy;
|
|
3874
|
-
const groupsDepsChanged = haveDepsChanged(previousState, state, [
|
|
3890
|
+
const groupsDepsChanged = originalDataArrayChanged || haveDepsChanged(previousState, state, [
|
|
3875
3891
|
"generateGroupRows",
|
|
3876
3892
|
"originalDataArray",
|
|
3877
3893
|
"originalLazyGroupData",
|
|
@@ -3904,7 +3920,7 @@ function concludeReducer(params) {
|
|
|
3904
3920
|
};
|
|
3905
3921
|
if (shouldGroup) {
|
|
3906
3922
|
if (shouldGroupAgain) {
|
|
3907
|
-
const groupResult = state.
|
|
3923
|
+
const groupResult = state.lazyLoad ? lazyGroup({
|
|
3908
3924
|
groupBy,
|
|
3909
3925
|
pivot: pivotBy,
|
|
3910
3926
|
mappings: state.pivotMappings,
|
|
@@ -4013,7 +4029,7 @@ function useToggleGroupRow() {
|
|
|
4013
4029
|
const newState = new GroupRowsState(state.groupRowsState);
|
|
4014
4030
|
newState.toggleGroupRow(groupKeys);
|
|
4015
4031
|
dataSourceActions.groupRowsState = newState;
|
|
4016
|
-
if (state.
|
|
4032
|
+
if (state.lazyLoad && newState.isGroupRowExpanded(groupKeys)) {
|
|
4017
4033
|
loadData(state.data, state, dataSourceActions, {
|
|
4018
4034
|
groupKeys
|
|
4019
4035
|
});
|
|
@@ -7630,7 +7646,7 @@ var useLicense = (licenseKey = "") => {
|
|
|
7630
7646
|
const valid = (0, import_react43.useMemo)(() => {
|
|
7631
7647
|
let valid2 = isValidLicense(licenseKey, {
|
|
7632
7648
|
publishedAt: 1624970570587,
|
|
7633
|
-
version: "0.2.
|
|
7649
|
+
version: "0.2.4"
|
|
7634
7650
|
});
|
|
7635
7651
|
if (!licenseKey && !valid2 && isInsideSandbox) {
|
|
7636
7652
|
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.4",
|
|
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": 1644430025786
|
|
18
18
|
}
|