@infinite-table/infinite-react 9.2.0 → 9.3.0

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 CHANGED
@@ -2450,7 +2450,14 @@ type RowSelectionStateConfig<T> = {
2450
2450
  groupBy: DataSourceState<T>['groupBy'];
2451
2451
  groupDeepMap: DataSourceState<T>['groupDeepMap'];
2452
2452
  toPrimaryKey: DataSourceState<T>['toPrimaryKey'];
2453
+ /**
2454
+ * The count of all the rows - for lazy load, after the (remote) filter
2455
+ */
2453
2456
  totalCount: number;
2457
+ /**
2458
+ * Lazy load: the count of all the rows without the filter, when the server sends it
2459
+ */
2460
+ lazyUnfilteredCount?: number;
2454
2461
  indexer: DataSourceState<T>['indexer'];
2455
2462
  lazyLoad: boolean;
2456
2463
  onlyUsePrimaryKeys: boolean;
@@ -2500,6 +2507,17 @@ declare class RowSelectionState<T = any> {
2500
2507
  * so the rows of the group that are filtered out keep their selection
2501
2508
  */
2502
2509
  private setVisibleRowsSelection;
2510
+ /**
2511
+ * Lazy load, when the selection also acts on rows that are filtered out:
2512
+ * the count of all the rows inside the group without the filter, if the server sent it
2513
+ */
2514
+ private getLazyUnfilteredCount;
2515
+ /**
2516
+ * Lazy load, when the selection also acts on rows that are filtered out:
2517
+ * the count of the rows inside the group (not at the last level) that are not inside
2518
+ * its loaded groups - so the rows of the groups hidden by the filter or not loaded yet
2519
+ */
2520
+ getLazyHiddenRowsCount(groupKeys: any[]): number;
2503
2521
  getGroupCount(groupKeys: any[]): number;
2504
2522
  getGroupKeysDirectlyInsideGroup(groupKeys: any[]): any[][];
2505
2523
  getAllPrimaryKeysInsideGroup(groupKeys: any[]): any[];
@@ -3055,7 +3073,7 @@ interface DataSourceDataParams<T> {
3055
3073
  lazyLoadStartIndex?: number;
3056
3074
  groupKeys?: any[];
3057
3075
  /**
3058
- * Only passed with `lazyLoad`: the rows a stored multi row selection covers.
3076
+ * Only passed with `lazyLoad` and `selectionMode: 'multi-row'`: the rows a stored multi row selection covers.
3059
3077
  * For `'visible'`, a selected group or `defaultSelection: true` covers only the rows that pass `filterValue`.
3060
3078
  */
3061
3079
  multiRowSelectionTarget?: DataSourcePropMultiRowSelectionTarget;
@@ -3079,7 +3097,19 @@ type DataSourceRemoteData<T> = {
3079
3097
  cache?: boolean;
3080
3098
  error?: string;
3081
3099
  totalCount?: number;
3100
+ /**
3101
+ * The count of rows (or groups, for a group level) without the filter
3102
+ */
3082
3103
  totalCountUnfiltered?: number;
3104
+ /**
3105
+ * For a group level: the leaf rows under it (at any depth), after the filter
3106
+ */
3107
+ totalChildrenCount?: number;
3108
+ /**
3109
+ * For a group level: the leaf rows under it (at any depth), without the filter.
3110
+ * With `multiRowSelectionTarget: 'all'`, the selection checkboxes also count the rows that the filter hides.
3111
+ */
3112
+ totalChildrenCountUnfiltered?: number;
3083
3113
  livePaginationCursor?: DataSourceLivePaginationCursorValue;
3084
3114
  };
3085
3115
  type DataSourceDataFn<T> = (dataInfo: DataSourceDataParams<T>) => T[] | Promise<T[] | DataSourceRemoteData<T>>;
@@ -3170,6 +3200,11 @@ type LazyGroupDataItem<DataType> = {
3170
3200
  aggregations?: Record<string, any>;
3171
3201
  dataset?: DataSourceRemoteData<DataType>;
3172
3202
  totalChildrenCount?: number;
3203
+ /**
3204
+ * The leaf rows under the group (at any depth), without the filter.
3205
+ * With `multiRowSelectionTarget: 'all'`, the selection checkboxes also count the rows that the filter hides.
3206
+ */
3207
+ totalChildrenCountUnfiltered?: number;
3173
3208
  pivot?: {
3174
3209
  values: Record<string, any>;
3175
3210
  totals?: Record<string, any>;
@@ -3184,7 +3219,8 @@ type LazyRowInfoGroup<DataType> = {
3184
3219
  childrenAvailable: boolean;
3185
3220
  cache: boolean;
3186
3221
  totalCount: number;
3187
- totalCountUnfiltered: number;
3222
+ totalCountUnfiltered?: number;
3223
+ totalChildrenCountUnfiltered?: number;
3188
3224
  error?: string;
3189
3225
  };
3190
3226
  type LazyGroupDataDeepMap<DataType, KeyType = string> = DeepMap<KeyType, LazyRowInfoGroup<DataType>>;
@@ -7050,6 +7086,7 @@ type DeepMapGroupValueType<DataType, KeyType> = {
7050
7086
  childrenLoading: boolean;
7051
7087
  childrenAvailable: boolean;
7052
7088
  totalChildrenCount?: number;
7089
+ totalChildrenCountUnfiltered?: number;
7053
7090
  cache: boolean;
7054
7091
  error?: string;
7055
7092
  isTree: false;
package/index.dev.js CHANGED
@@ -15185,6 +15185,7 @@ function lazyGroup(groupParams, rootData) {
15185
15185
  childrenAvailable: false,
15186
15186
  commonData: dataObject,
15187
15187
  totalChildrenCount: dataArray[i].totalChildrenCount,
15188
+ totalChildrenCountUnfiltered: dataArray[i].totalChildrenCountUnfiltered,
15188
15189
  reducerResults: dataArray[i].aggregations || {},
15189
15190
  isTree: false,
15190
15191
  isGroupBy: true
@@ -16882,9 +16883,40 @@ var RowSelectionState = class _RowSelectionState {
16882
16883
  });
16883
16884
  this.xcache();
16884
16885
  }
16886
+ /**
16887
+ * Lazy load, when the selection also acts on rows that are filtered out:
16888
+ * the count of all the rows inside the group without the filter, if the server sent it
16889
+ */
16890
+ getLazyUnfilteredCount(groupKeys) {
16891
+ const config = this.getConfig();
16892
+ if (!config.lazyLoad || config.multiRowSelectionTarget === "visible") {
16893
+ return void 0;
16894
+ }
16895
+ if (!groupKeys.length) {
16896
+ return config.lazyUnfilteredCount;
16897
+ }
16898
+ return config.groupDeepMap?.get(groupKeys)?.totalChildrenCountUnfiltered;
16899
+ }
16900
+ /**
16901
+ * Lazy load, when the selection also acts on rows that are filtered out:
16902
+ * the count of the rows inside the group (not at the last level) that are not inside
16903
+ * its loaded groups - so the rows of the groups hidden by the filter or not loaded yet
16904
+ */
16905
+ getLazyHiddenRowsCount(groupKeys) {
16906
+ const unfilteredCount = groupKeys.length < this.getGroupByLength() ? this.getLazyUnfilteredCount(groupKeys) : void 0;
16907
+ if (unfilteredCount === void 0) {
16908
+ return 0;
16909
+ }
16910
+ const { groupDeepMap } = this.getConfig();
16911
+ let childrenCount = 0;
16912
+ this.getGroupKeysDirectlyInsideGroup(groupKeys).forEach((keys) => {
16913
+ childrenCount += this.getLazyUnfilteredCount(keys) ?? (groupDeepMap?.get(keys)?.totalChildrenCount || 0);
16914
+ });
16915
+ return Math.max(unfilteredCount - childrenCount, 0);
16916
+ }
16885
16917
  getGroupCount(groupKeys) {
16886
16918
  if (groupKeys.length == 0) {
16887
- return this.getConfig().totalCount;
16919
+ return this.getLazyUnfilteredCount([]) ?? this.getConfig().totalCount;
16888
16920
  }
16889
16921
  if (this.targetsFilteredOutRows()) {
16890
16922
  return getUnfilteredGroups(this.getConfig()).get(groupKeys)?.count ?? 0;
@@ -16894,7 +16926,7 @@ var RowSelectionState = class _RowSelectionState {
16894
16926
  if (!deepMapValue) {
16895
16927
  return 0;
16896
16928
  }
16897
- return deepMapValue.totalChildrenCount ?? (deepMapValue.items.length || 0);
16929
+ return this.getLazyUnfilteredCount(groupKeys) ?? deepMapValue.totalChildrenCount ?? (deepMapValue.items.length || 0);
16898
16930
  }
16899
16931
  getGroupKeysDirectlyInsideGroup(groupKeys) {
16900
16932
  const config = this.getConfig();
@@ -17343,8 +17375,9 @@ var RowSelectionState = class _RowSelectionState {
17343
17375
  }
17344
17376
  let selectedCount = 0;
17345
17377
  let deselectedCount = 0;
17346
- if (this.getConfig().lazyLoad && !allKeys.length) {
17347
- const totalChildrenCount = this.getConfig().groupDeepMap?.get(groupKeys)?.totalChildrenCount || 0;
17378
+ const { lazyLoad, groupDeepMap } = this.getConfig();
17379
+ if (lazyLoad && !allKeys.length) {
17380
+ const totalChildrenCount = this.getLazyUnfilteredCount(groupKeys) ?? (groupDeepMap?.get(groupKeys)?.totalChildrenCount || 0);
17348
17381
  if (parentSelected) {
17349
17382
  selectedCount = totalChildrenCount;
17350
17383
  deselectedCount = this.deselectedMap.getAllChildrenSizeFor(groupKeys);
@@ -17367,6 +17400,12 @@ var RowSelectionState = class _RowSelectionState {
17367
17400
  selectedCount += selCount;
17368
17401
  deselectedCount += deselCount;
17369
17402
  });
17403
+ const hiddenCount = allKeys.length ? this.getLazyHiddenRowsCount(groupKeys) : 0;
17404
+ if (parentSelected) {
17405
+ selectedCount += hiddenCount;
17406
+ } else {
17407
+ deselectedCount += hiddenCount;
17408
+ }
17370
17409
  const result = {
17371
17410
  selectedCount,
17372
17411
  deselectedCount
@@ -17387,14 +17426,17 @@ function rowSelectionStateConfigGetter(stateOrStateGetter) {
17387
17426
  return () => {
17388
17427
  const state = typeof stateOrStateGetter === "function" ? stateOrStateGetter() : stateOrStateGetter;
17389
17428
  const { originalDataArray, postFilterDataArray } = state;
17429
+ const lazyLoad = !!state.lazyLoad;
17430
+ const lazyRoot = lazyLoad ? state.originalLazyGroupData.get([LAZY_ROOT_KEY_FOR_GROUPS]) : void 0;
17390
17431
  return {
17391
- lazyLoad: !!state.lazyLoad,
17432
+ lazyLoad,
17392
17433
  toPrimaryKey: state.toPrimaryKey,
17393
17434
  onlyUsePrimaryKeys: !state.useGroupKeysForMultiRowSelection,
17394
17435
  groupBy: state.groupBy,
17395
17436
  groupDeepMap: state.groupDeepMap,
17396
17437
  indexer: state.indexer,
17397
- totalCount: state.unfilteredCount,
17438
+ totalCount: lazyLoad ? originalDataArray?.length ?? 0 : state.unfilteredCount,
17439
+ lazyUnfilteredCount: state.groupBy.length ? lazyRoot?.totalChildrenCountUnfiltered : lazyRoot?.totalCountUnfiltered,
17398
17440
  multiRowSelectionTarget: state.multiRowSelectionTarget,
17399
17441
  someRowsFilteredOut: !state.lazyLoad && !!originalDataArray && !!postFilterDataArray && postFilterDataArray.length < originalDataArray.length,
17400
17442
  originalDataArray,
@@ -22310,6 +22352,14 @@ function concludeReducer(params) {
22310
22352
  }
22311
22353
  }
22312
22354
  });
22355
+ const { rowSelection } = state;
22356
+ if (rowSelection instanceof RowSelectionState && rowSelection.getLazyHiddenRowsCount([])) {
22357
+ if (rowSelection.defaultSelection) {
22358
+ someRowsSelected = true;
22359
+ } else {
22360
+ allRowsSelected = false;
22361
+ }
22362
+ }
22313
22363
  state.allRowsSelected = allRowsSelected;
22314
22364
  state.someRowsSelected = someRowsSelected;
22315
22365
  if (debugId) {
@@ -22428,7 +22478,9 @@ function buildDataSourceDataParams(componentState, overrides, masterContext) {
22428
22478
  dataSourceParams.lazyLoadStartIndex = 0;
22429
22479
  }
22430
22480
  dataSourceParams.groupKeys = [];
22431
- dataSourceParams.multiRowSelectionTarget = componentState.multiRowSelectionTarget;
22481
+ if (componentState.selectionMode === "multi-row") {
22482
+ dataSourceParams.multiRowSelectionTarget = componentState.multiRowSelectionTarget;
22483
+ }
22432
22484
  }
22433
22485
  if (overrides) {
22434
22486
  Object.assign(dataSourceParams, overrides);
@@ -22505,8 +22557,7 @@ function loadData(data, componentState, actions, overrides, masterContext) {
22505
22557
  childrenLoading: true,
22506
22558
  childrenAvailable: false,
22507
22559
  cache: CACHE_DEFAULT,
22508
- totalCount: 0,
22509
- totalCountUnfiltered: 0
22560
+ totalCount: 0
22510
22561
  });
22511
22562
  }
22512
22563
  actions.originalLazyGroupDataChangeDetect = getChangeDetect();
@@ -22545,7 +22596,9 @@ function loadData(data, componentState, actions, overrides, masterContext) {
22545
22596
  childrenLoading: false,
22546
22597
  childrenAvailable: true,
22547
22598
  totalCount: remoteData2.totalCount ?? dataArray2.length,
22548
- totalCountUnfiltered: remoteData2.totalCount ?? dataArray2.length,
22599
+ // set even when missing, so a previous response's values are not kept
22600
+ totalCountUnfiltered: remoteData2.totalCountUnfiltered,
22601
+ totalChildrenCountUnfiltered: remoteData2.totalChildrenCountUnfiltered,
22549
22602
  children: dataArray2,
22550
22603
  error: remoteData2.error
22551
22604
  };
@@ -28105,7 +28158,7 @@ var useLicense = (licenseKey = "") => {
28105
28158
  }
28106
28159
  let valid2 = isValidLicense(licenseKey, {
28107
28160
  publishedAt: 1624970570587,
28108
- version: "9.2.0"
28161
+ version: "9.3.0"
28109
28162
  });
28110
28163
  if (!licenseKey && !valid2 && isInsidePlayground) {
28111
28164
  return true;
package/index.dev.mjs CHANGED
@@ -15119,6 +15119,7 @@ function lazyGroup(groupParams, rootData) {
15119
15119
  childrenAvailable: false,
15120
15120
  commonData: dataObject,
15121
15121
  totalChildrenCount: dataArray[i].totalChildrenCount,
15122
+ totalChildrenCountUnfiltered: dataArray[i].totalChildrenCountUnfiltered,
15122
15123
  reducerResults: dataArray[i].aggregations || {},
15123
15124
  isTree: false,
15124
15125
  isGroupBy: true
@@ -16816,9 +16817,40 @@ var RowSelectionState = class _RowSelectionState {
16816
16817
  });
16817
16818
  this.xcache();
16818
16819
  }
16820
+ /**
16821
+ * Lazy load, when the selection also acts on rows that are filtered out:
16822
+ * the count of all the rows inside the group without the filter, if the server sent it
16823
+ */
16824
+ getLazyUnfilteredCount(groupKeys) {
16825
+ const config = this.getConfig();
16826
+ if (!config.lazyLoad || config.multiRowSelectionTarget === "visible") {
16827
+ return void 0;
16828
+ }
16829
+ if (!groupKeys.length) {
16830
+ return config.lazyUnfilteredCount;
16831
+ }
16832
+ return config.groupDeepMap?.get(groupKeys)?.totalChildrenCountUnfiltered;
16833
+ }
16834
+ /**
16835
+ * Lazy load, when the selection also acts on rows that are filtered out:
16836
+ * the count of the rows inside the group (not at the last level) that are not inside
16837
+ * its loaded groups - so the rows of the groups hidden by the filter or not loaded yet
16838
+ */
16839
+ getLazyHiddenRowsCount(groupKeys) {
16840
+ const unfilteredCount = groupKeys.length < this.getGroupByLength() ? this.getLazyUnfilteredCount(groupKeys) : void 0;
16841
+ if (unfilteredCount === void 0) {
16842
+ return 0;
16843
+ }
16844
+ const { groupDeepMap } = this.getConfig();
16845
+ let childrenCount = 0;
16846
+ this.getGroupKeysDirectlyInsideGroup(groupKeys).forEach((keys) => {
16847
+ childrenCount += this.getLazyUnfilteredCount(keys) ?? (groupDeepMap?.get(keys)?.totalChildrenCount || 0);
16848
+ });
16849
+ return Math.max(unfilteredCount - childrenCount, 0);
16850
+ }
16819
16851
  getGroupCount(groupKeys) {
16820
16852
  if (groupKeys.length == 0) {
16821
- return this.getConfig().totalCount;
16853
+ return this.getLazyUnfilteredCount([]) ?? this.getConfig().totalCount;
16822
16854
  }
16823
16855
  if (this.targetsFilteredOutRows()) {
16824
16856
  return getUnfilteredGroups(this.getConfig()).get(groupKeys)?.count ?? 0;
@@ -16828,7 +16860,7 @@ var RowSelectionState = class _RowSelectionState {
16828
16860
  if (!deepMapValue) {
16829
16861
  return 0;
16830
16862
  }
16831
- return deepMapValue.totalChildrenCount ?? (deepMapValue.items.length || 0);
16863
+ return this.getLazyUnfilteredCount(groupKeys) ?? deepMapValue.totalChildrenCount ?? (deepMapValue.items.length || 0);
16832
16864
  }
16833
16865
  getGroupKeysDirectlyInsideGroup(groupKeys) {
16834
16866
  const config = this.getConfig();
@@ -17277,8 +17309,9 @@ var RowSelectionState = class _RowSelectionState {
17277
17309
  }
17278
17310
  let selectedCount = 0;
17279
17311
  let deselectedCount = 0;
17280
- if (this.getConfig().lazyLoad && !allKeys.length) {
17281
- const totalChildrenCount = this.getConfig().groupDeepMap?.get(groupKeys)?.totalChildrenCount || 0;
17312
+ const { lazyLoad, groupDeepMap } = this.getConfig();
17313
+ if (lazyLoad && !allKeys.length) {
17314
+ const totalChildrenCount = this.getLazyUnfilteredCount(groupKeys) ?? (groupDeepMap?.get(groupKeys)?.totalChildrenCount || 0);
17282
17315
  if (parentSelected) {
17283
17316
  selectedCount = totalChildrenCount;
17284
17317
  deselectedCount = this.deselectedMap.getAllChildrenSizeFor(groupKeys);
@@ -17301,6 +17334,12 @@ var RowSelectionState = class _RowSelectionState {
17301
17334
  selectedCount += selCount;
17302
17335
  deselectedCount += deselCount;
17303
17336
  });
17337
+ const hiddenCount = allKeys.length ? this.getLazyHiddenRowsCount(groupKeys) : 0;
17338
+ if (parentSelected) {
17339
+ selectedCount += hiddenCount;
17340
+ } else {
17341
+ deselectedCount += hiddenCount;
17342
+ }
17304
17343
  const result = {
17305
17344
  selectedCount,
17306
17345
  deselectedCount
@@ -17321,14 +17360,17 @@ function rowSelectionStateConfigGetter(stateOrStateGetter) {
17321
17360
  return () => {
17322
17361
  const state = typeof stateOrStateGetter === "function" ? stateOrStateGetter() : stateOrStateGetter;
17323
17362
  const { originalDataArray, postFilterDataArray } = state;
17363
+ const lazyLoad = !!state.lazyLoad;
17364
+ const lazyRoot = lazyLoad ? state.originalLazyGroupData.get([LAZY_ROOT_KEY_FOR_GROUPS]) : void 0;
17324
17365
  return {
17325
- lazyLoad: !!state.lazyLoad,
17366
+ lazyLoad,
17326
17367
  toPrimaryKey: state.toPrimaryKey,
17327
17368
  onlyUsePrimaryKeys: !state.useGroupKeysForMultiRowSelection,
17328
17369
  groupBy: state.groupBy,
17329
17370
  groupDeepMap: state.groupDeepMap,
17330
17371
  indexer: state.indexer,
17331
- totalCount: state.unfilteredCount,
17372
+ totalCount: lazyLoad ? originalDataArray?.length ?? 0 : state.unfilteredCount,
17373
+ lazyUnfilteredCount: state.groupBy.length ? lazyRoot?.totalChildrenCountUnfiltered : lazyRoot?.totalCountUnfiltered,
17332
17374
  multiRowSelectionTarget: state.multiRowSelectionTarget,
17333
17375
  someRowsFilteredOut: !state.lazyLoad && !!originalDataArray && !!postFilterDataArray && postFilterDataArray.length < originalDataArray.length,
17334
17376
  originalDataArray,
@@ -22244,6 +22286,14 @@ function concludeReducer(params) {
22244
22286
  }
22245
22287
  }
22246
22288
  });
22289
+ const { rowSelection } = state;
22290
+ if (rowSelection instanceof RowSelectionState && rowSelection.getLazyHiddenRowsCount([])) {
22291
+ if (rowSelection.defaultSelection) {
22292
+ someRowsSelected = true;
22293
+ } else {
22294
+ allRowsSelected = false;
22295
+ }
22296
+ }
22247
22297
  state.allRowsSelected = allRowsSelected;
22248
22298
  state.someRowsSelected = someRowsSelected;
22249
22299
  if (debugId) {
@@ -22362,7 +22412,9 @@ function buildDataSourceDataParams(componentState, overrides, masterContext) {
22362
22412
  dataSourceParams.lazyLoadStartIndex = 0;
22363
22413
  }
22364
22414
  dataSourceParams.groupKeys = [];
22365
- dataSourceParams.multiRowSelectionTarget = componentState.multiRowSelectionTarget;
22415
+ if (componentState.selectionMode === "multi-row") {
22416
+ dataSourceParams.multiRowSelectionTarget = componentState.multiRowSelectionTarget;
22417
+ }
22366
22418
  }
22367
22419
  if (overrides) {
22368
22420
  Object.assign(dataSourceParams, overrides);
@@ -22439,8 +22491,7 @@ function loadData(data, componentState, actions, overrides, masterContext) {
22439
22491
  childrenLoading: true,
22440
22492
  childrenAvailable: false,
22441
22493
  cache: CACHE_DEFAULT,
22442
- totalCount: 0,
22443
- totalCountUnfiltered: 0
22494
+ totalCount: 0
22444
22495
  });
22445
22496
  }
22446
22497
  actions.originalLazyGroupDataChangeDetect = getChangeDetect();
@@ -22479,7 +22530,9 @@ function loadData(data, componentState, actions, overrides, masterContext) {
22479
22530
  childrenLoading: false,
22480
22531
  childrenAvailable: true,
22481
22532
  totalCount: remoteData2.totalCount ?? dataArray2.length,
22482
- totalCountUnfiltered: remoteData2.totalCount ?? dataArray2.length,
22533
+ // set even when missing, so a previous response's values are not kept
22534
+ totalCountUnfiltered: remoteData2.totalCountUnfiltered,
22535
+ totalChildrenCountUnfiltered: remoteData2.totalChildrenCountUnfiltered,
22483
22536
  children: dataArray2,
22484
22537
  error: remoteData2.error
22485
22538
  };
@@ -28044,7 +28097,7 @@ var useLicense = (licenseKey = "") => {
28044
28097
  }
28045
28098
  let valid2 = isValidLicense(licenseKey, {
28046
28099
  publishedAt: 1624970570587,
28047
- version: "9.2.0"
28100
+ version: "9.3.0"
28048
28101
  });
28049
28102
  if (!licenseKey && !valid2 && isInsidePlayground) {
28050
28103
  return true;