@infinite-table/infinite-react 9.1.2 → 9.1.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.dev.js CHANGED
@@ -22434,6 +22434,23 @@ function computeFilterValueForRemote(filterValue, {
22434
22434
  }
22435
22435
  );
22436
22436
  }
22437
+ function createRemoteFilterValueMemo() {
22438
+ let prev;
22439
+ return (filterValue, filterTypes, filterMode) => {
22440
+ if (prev && prev.filterValue === filterValue && prev.filterTypes === filterTypes && prev.filterMode === filterMode) {
22441
+ return prev.result;
22442
+ }
22443
+ let result = computeFilterValueForRemote(filterValue, {
22444
+ filterTypes,
22445
+ filterMode
22446
+ });
22447
+ if (prev && prev.filterValue === filterValue && JSON.stringify(prev.result) === JSON.stringify(result)) {
22448
+ result = prev.result;
22449
+ }
22450
+ prev = { filterValue, filterTypes, filterMode, result };
22451
+ return result;
22452
+ };
22453
+ }
22437
22454
  var getRafPromise = () => new Promise((resolve) => {
22438
22455
  raf(resolve);
22439
22456
  });
@@ -22446,6 +22463,10 @@ function getDetailReady(masterContext, getDataSourceState) {
22446
22463
  isDetailReady
22447
22464
  };
22448
22465
  }
22466
+ function isFirstLazyBatchRequested(componentState) {
22467
+ const { lazyLoad, lazyLoadBatchSize, lazyLoadCacheOfLoadedBatches } = componentState;
22468
+ return !!lazyLoad && !!lazyLoadBatchSize && lazyLoadBatchSize > 0 && lazyLoadCacheOfLoadedBatches.has([0]);
22469
+ }
22449
22470
  function lazyLoadRange(options, cache) {
22450
22471
  const {
22451
22472
  startIndex,
@@ -25042,12 +25063,15 @@ function useLoadData(options) {
25042
25063
  }
25043
25064
  }
25044
25065
  }, [scrollbars.vertical]);
25045
- const computedFilterValue = (0, import_react41.useMemo)(() => {
25046
- return computeFilterValueForRemote(filterValue, {
25047
- filterTypes,
25048
- filterMode
25049
- });
25050
- }, [filterValue, filterMode, filterTypes]);
25066
+ const getRemoteFilterValue = (0, import_react41.useMemo)(
25067
+ () => createRemoteFilterValueMemo(),
25068
+ []
25069
+ );
25070
+ const computedFilterValue = getRemoteFilterValue(
25071
+ filterValue,
25072
+ filterTypes,
25073
+ filterMode
25074
+ );
25051
25075
  const depsObject = {
25052
25076
  // #sortMode_vs_shouldReloadData.sortInfo
25053
25077
  sortInfo: shouldReloadData.sortInfo ? sortInfo : null,
@@ -25058,14 +25082,19 @@ function useLoadData(options) {
25058
25082
  cursorId: livePagination ? stateCursorId : null
25059
25083
  };
25060
25084
  const initialRef = (0, import_react41.useRef)(true);
25061
- useLazyLoadRange(options, {
25062
- sortInfo,
25063
- groupBy,
25064
- pivotBy,
25065
- filterValue,
25066
- refetchKey,
25067
- cursorId: livePagination ? stateCursorId : null
25068
- });
25085
+ const lazyRangeReloadedRef = (0, import_react41.useRef)(false);
25086
+ useLazyLoadRange(
25087
+ options,
25088
+ {
25089
+ sortInfo,
25090
+ groupBy,
25091
+ pivotBy,
25092
+ filterValue,
25093
+ refetchKey,
25094
+ cursorId: livePagination ? stateCursorId : null
25095
+ },
25096
+ lazyRangeReloadedRef
25097
+ );
25069
25098
  const getMasterContext = useGetMasterDetailContext();
25070
25099
  const dataChangeTimestampsRef = (0, import_react41.useRef)([]);
25071
25100
  useEffectWithChanges(
@@ -25129,6 +25158,9 @@ function useLoadData(options) {
25129
25158
  }
25130
25159
  const componentState = getDataSourceState();
25131
25160
  if (typeof componentState.data === "function") {
25161
+ if (lazyRangeReloadedRef.current && !appendWhenLivePagination && isFirstLazyBatchRequested(componentState)) {
25162
+ return;
25163
+ }
25132
25164
  let marker;
25133
25165
  if (componentState.debugId) {
25134
25166
  marker = getMarker(
@@ -25150,6 +25182,9 @@ function useLoadData(options) {
25150
25182
  },
25151
25183
  { ...depsObject, data }
25152
25184
  );
25185
+ (0, import_react41.useEffect)(() => {
25186
+ lazyRangeReloadedRef.current = false;
25187
+ });
25153
25188
  useEffectWithChanges(() => {
25154
25189
  const componentState = getDataSourceState();
25155
25190
  if (initialRef.current) {
@@ -25163,7 +25198,7 @@ function useLoadData(options) {
25163
25198
  }
25164
25199
  }, depsObject);
25165
25200
  }
25166
- function useLazyLoadRange(options, dependencies) {
25201
+ function useLazyLoadRange(options, dependencies, reloadedRef) {
25167
25202
  const { getDataSourceState, dataSourceActions, dataSourceState } = options;
25168
25203
  (0, import_react41.useEffect)(() => {
25169
25204
  dataSourceActions.lazyLoadCacheOfLoadedBatches = new DeepMap();
@@ -25219,6 +25254,7 @@ function useLazyLoadRange(options, dependencies) {
25219
25254
  loadRange(notifyRenderRangeChange.get(), {
25220
25255
  dismissLoadedRows: true
25221
25256
  });
25257
+ reloadedRef.current = true;
25222
25258
  } else {
25223
25259
  if (changes.originalLazyGroupDataChangeDetect || changes.groupRowsState) {
25224
25260
  loadRange(notifyRenderRangeChange.get());
@@ -27857,7 +27893,7 @@ var useLicense = (licenseKey = "") => {
27857
27893
  }
27858
27894
  let valid2 = isValidLicense(licenseKey, {
27859
27895
  publishedAt: 1624970570587,
27860
- version: "9.1.2"
27896
+ version: "9.1.3"
27861
27897
  });
27862
27898
  if (!licenseKey && !valid2 && isInsidePlayground) {
27863
27899
  return true;
package/index.dev.mjs CHANGED
@@ -22368,6 +22368,23 @@ function computeFilterValueForRemote(filterValue, {
22368
22368
  }
22369
22369
  );
22370
22370
  }
22371
+ function createRemoteFilterValueMemo() {
22372
+ let prev;
22373
+ return (filterValue, filterTypes, filterMode) => {
22374
+ if (prev && prev.filterValue === filterValue && prev.filterTypes === filterTypes && prev.filterMode === filterMode) {
22375
+ return prev.result;
22376
+ }
22377
+ let result = computeFilterValueForRemote(filterValue, {
22378
+ filterTypes,
22379
+ filterMode
22380
+ });
22381
+ if (prev && prev.filterValue === filterValue && JSON.stringify(prev.result) === JSON.stringify(result)) {
22382
+ result = prev.result;
22383
+ }
22384
+ prev = { filterValue, filterTypes, filterMode, result };
22385
+ return result;
22386
+ };
22387
+ }
22371
22388
  var getRafPromise = () => new Promise((resolve) => {
22372
22389
  raf(resolve);
22373
22390
  });
@@ -22380,6 +22397,10 @@ function getDetailReady(masterContext, getDataSourceState) {
22380
22397
  isDetailReady
22381
22398
  };
22382
22399
  }
22400
+ function isFirstLazyBatchRequested(componentState) {
22401
+ const { lazyLoad, lazyLoadBatchSize, lazyLoadCacheOfLoadedBatches } = componentState;
22402
+ return !!lazyLoad && !!lazyLoadBatchSize && lazyLoadBatchSize > 0 && lazyLoadCacheOfLoadedBatches.has([0]);
22403
+ }
22383
22404
  function lazyLoadRange(options, cache) {
22384
22405
  const {
22385
22406
  startIndex,
@@ -24981,12 +25002,15 @@ function useLoadData(options) {
24981
25002
  }
24982
25003
  }
24983
25004
  }, [scrollbars.vertical]);
24984
- const computedFilterValue = useMemo11(() => {
24985
- return computeFilterValueForRemote(filterValue, {
24986
- filterTypes,
24987
- filterMode
24988
- });
24989
- }, [filterValue, filterMode, filterTypes]);
25005
+ const getRemoteFilterValue = useMemo11(
25006
+ () => createRemoteFilterValueMemo(),
25007
+ []
25008
+ );
25009
+ const computedFilterValue = getRemoteFilterValue(
25010
+ filterValue,
25011
+ filterTypes,
25012
+ filterMode
25013
+ );
24990
25014
  const depsObject = {
24991
25015
  // #sortMode_vs_shouldReloadData.sortInfo
24992
25016
  sortInfo: shouldReloadData.sortInfo ? sortInfo : null,
@@ -24997,14 +25021,19 @@ function useLoadData(options) {
24997
25021
  cursorId: livePagination ? stateCursorId : null
24998
25022
  };
24999
25023
  const initialRef = useRef25(true);
25000
- useLazyLoadRange(options, {
25001
- sortInfo,
25002
- groupBy,
25003
- pivotBy,
25004
- filterValue,
25005
- refetchKey,
25006
- cursorId: livePagination ? stateCursorId : null
25007
- });
25024
+ const lazyRangeReloadedRef = useRef25(false);
25025
+ useLazyLoadRange(
25026
+ options,
25027
+ {
25028
+ sortInfo,
25029
+ groupBy,
25030
+ pivotBy,
25031
+ filterValue,
25032
+ refetchKey,
25033
+ cursorId: livePagination ? stateCursorId : null
25034
+ },
25035
+ lazyRangeReloadedRef
25036
+ );
25008
25037
  const getMasterContext = useGetMasterDetailContext();
25009
25038
  const dataChangeTimestampsRef = useRef25([]);
25010
25039
  useEffectWithChanges(
@@ -25068,6 +25097,9 @@ function useLoadData(options) {
25068
25097
  }
25069
25098
  const componentState = getDataSourceState();
25070
25099
  if (typeof componentState.data === "function") {
25100
+ if (lazyRangeReloadedRef.current && !appendWhenLivePagination && isFirstLazyBatchRequested(componentState)) {
25101
+ return;
25102
+ }
25071
25103
  let marker;
25072
25104
  if (componentState.debugId) {
25073
25105
  marker = getMarker(
@@ -25089,6 +25121,9 @@ function useLoadData(options) {
25089
25121
  },
25090
25122
  { ...depsObject, data }
25091
25123
  );
25124
+ useEffect21(() => {
25125
+ lazyRangeReloadedRef.current = false;
25126
+ });
25092
25127
  useEffectWithChanges(() => {
25093
25128
  const componentState = getDataSourceState();
25094
25129
  if (initialRef.current) {
@@ -25102,7 +25137,7 @@ function useLoadData(options) {
25102
25137
  }
25103
25138
  }, depsObject);
25104
25139
  }
25105
- function useLazyLoadRange(options, dependencies) {
25140
+ function useLazyLoadRange(options, dependencies, reloadedRef) {
25106
25141
  const { getDataSourceState, dataSourceActions, dataSourceState } = options;
25107
25142
  useEffect21(() => {
25108
25143
  dataSourceActions.lazyLoadCacheOfLoadedBatches = new DeepMap();
@@ -25158,6 +25193,7 @@ function useLazyLoadRange(options, dependencies) {
25158
25193
  loadRange(notifyRenderRangeChange.get(), {
25159
25194
  dismissLoadedRows: true
25160
25195
  });
25196
+ reloadedRef.current = true;
25161
25197
  } else {
25162
25198
  if (changes.originalLazyGroupDataChangeDetect || changes.groupRowsState) {
25163
25199
  loadRange(notifyRenderRangeChange.get());
@@ -27796,7 +27832,7 @@ var useLicense = (licenseKey = "") => {
27796
27832
  }
27797
27833
  let valid2 = isValidLicense(licenseKey, {
27798
27834
  publishedAt: 1624970570587,
27799
- version: "9.1.2"
27835
+ version: "9.1.3"
27800
27836
  });
27801
27837
  if (!licenseKey && !valid2 && isInsidePlayground) {
27802
27838
  return true;