@infinite-table/infinite-react 7.2.1 → 7.2.2

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.mjs CHANGED
@@ -233,34 +233,76 @@ var DeepMap = class _DeepMap {
233
233
  });
234
234
  }
235
235
  }
236
- getValuesStartingWith(keys, excludeSelf, depthLimit) {
236
+ getValuesStartingWith(keys, options) {
237
237
  const result = [];
238
238
  this.getStartingWith(
239
239
  keys,
240
240
  (_keys, value) => {
241
241
  result.push(value);
242
242
  },
243
- excludeSelf,
244
- depthLimit
243
+ options
245
244
  );
246
245
  return result;
247
246
  }
248
- getEntriesStartingWith(keys, excludeSelf, depthLimit) {
247
+ getEntriesStartingWith(keys, options) {
249
248
  const result = [];
250
249
  this.getStartingWith(
251
250
  keys,
252
251
  (keys2, value) => {
253
252
  result.push([keys2, value]);
254
253
  },
255
- excludeSelf,
256
- depthLimit
254
+ options
257
255
  );
258
256
  return result;
259
257
  }
260
- getUnnestedKeysStartingWith(keys, excludeSelf, depthLimit) {
258
+ getLeafNodesStartingWith(keys, withPair, options) {
259
+ const { respectOrder = false } = options || {};
261
260
  const pairs = [];
261
+ const result = [];
262
+ this.getStartingWith(
263
+ keys,
264
+ (_keys, _value, pair) => {
265
+ if (!pair.map && pair.hasOwnProperty("value")) {
266
+ if (respectOrder) {
267
+ pairs.push(pair);
268
+ } else {
269
+ result.push(withPair(pair));
270
+ }
271
+ }
272
+ },
273
+ options
274
+ );
275
+ if (respectOrder) {
276
+ return pairs.sort(SORT_ASC_REVISION).map(withPair);
277
+ }
278
+ return result;
279
+ }
280
+ getKeysForLeafNodesStartingWith(keys, options) {
281
+ return this.getLeafNodesStartingWith(keys, (pair) => pair.keys, options);
282
+ }
283
+ getKeysAndValuesForLeafNodesStartingWith(keys, options) {
284
+ return this.getLeafNodesStartingWith(
285
+ keys,
286
+ (pair) => [pair.keys, pair.value],
287
+ options
288
+ );
289
+ }
290
+ /**
291
+ * @param keys - the keys of the node to start from
292
+ * @param excludeSelf - whether to exclude the start node
293
+ * @param depthLimit - the depth limit
294
+ * @returns the keys of the first child on each branch (starting from the node with the given keys)
295
+ */
296
+ getKeysOfFirstChildOnEachBranchStartingWith(keys, options) {
297
+ const { excludeSelf, depthLimit, respectOrder = true } = options || {};
298
+ const pairs = [];
299
+ const result = [];
262
300
  const fn = (pair2) => {
263
- pairs.push(pair2);
301
+ if (respectOrder) {
302
+ pairs.push(pair2);
303
+ } else {
304
+ result.push(pair2.keys);
305
+ }
264
306
  };
265
307
  let currentMap = this.map;
266
308
  let pair;
@@ -295,7 +337,10 @@ var DeepMap = class _DeepMap {
295
337
  }
296
338
  }
297
339
  if (stop) {
298
- return pairs.sort(SORT_ASC_REVISION).map((pair2) => pair2.keys);
340
+ if (respectOrder) {
341
+ return pairs.sort(SORT_ASC_REVISION).map((pair2) => pair2.keys);
342
+ }
343
+ return result;
299
344
  }
300
345
  this.visitWithNext(
301
346
  keys,
@@ -307,21 +352,24 @@ var DeepMap = class _DeepMap {
307
352
  depthLimit,
308
353
  excludeSelf
309
354
  );
310
- return pairs.sort(SORT_ASC_REVISION).map((pair2) => pair2.keys);
355
+ if (respectOrder) {
356
+ return pairs.sort(SORT_ASC_REVISION).map((pair2) => pair2.keys);
357
+ }
358
+ return result;
311
359
  }
312
- getKeysStartingWith(keys, excludeSelf, depthLimit) {
360
+ getKeysStartingWith(keys, options) {
313
361
  const result = [];
314
362
  this.getStartingWith(
315
363
  keys,
316
364
  (keys2) => {
317
365
  result.push(keys2);
318
366
  },
319
- excludeSelf,
320
- depthLimit
367
+ options
321
368
  );
322
369
  return result;
323
370
  }
324
- getStartingWith(keys, fn, excludeSelf, depthLimit) {
371
+ getStartingWith(keys, fn, options) {
372
+ const { excludeSelf, depthLimit } = options || {};
325
373
  let currentMap = this.map;
326
374
  let pair;
327
375
  let stop = false;
@@ -343,7 +391,7 @@ var DeepMap = class _DeepMap {
343
391
  }
344
392
  if (pair && pair.value !== void 0) {
345
393
  if (!excludeSelf) {
346
- fn(keys, pair.value);
394
+ fn(keys, pair.value, { ...pair, keys });
347
395
  }
348
396
  }
349
397
  if (stop) {
@@ -351,8 +399,8 @@ var DeepMap = class _DeepMap {
351
399
  }
352
400
  this.visitWithNext(
353
401
  keys,
354
- (value, keys2, _i, next) => {
355
- fn(keys2, value);
402
+ (value, keys2, _i, next, pair2) => {
403
+ fn(keys2, value, { ...pair2, keys: keys2 });
356
404
  next?.();
357
405
  },
358
406
  false,
@@ -669,6 +717,7 @@ var DeepMap = class _DeepMap {
669
717
  // return makeIterator();
670
718
  // }
671
719
  };
720
+ globalThis.DeepMap = DeepMap;
672
721
 
673
722
  // src/utils/getGlobal.ts
674
723
  function getGlobal() {
@@ -798,7 +847,9 @@ function isChannelTargeted(channel, permissionToken) {
798
847
  const hasWildcard = new Set(tokenParts).has(CHANNEL_WILDCARD);
799
848
  const indexOfToken = tokenParts.indexOf(CHANNEL_WILDCARD);
800
849
  const storagePartsWithoutWildcard = hasWildcard ? tokenParts.slice(0, indexOfToken) : tokenParts;
801
- if (partsMap.getKeysStartingWith(storagePartsWithoutWildcard, hasWildcard).length > 0) {
850
+ if (partsMap.getKeysStartingWith(storagePartsWithoutWildcard, {
851
+ excludeSelf: hasWildcard
852
+ }).length > 0) {
802
853
  const remainingParts = tokenParts.slice(indexOfToken + 1);
803
854
  if (remainingParts.length) {
804
855
  return channel.endsWith(remainingParts.join(CHANNEL_SEPARATOR));
@@ -3323,7 +3374,10 @@ var GridCellManager = class extends Logger {
3323
3374
  return this.matrix.rawKeysAt([]).sort(ASC_SORT);
3324
3375
  }
3325
3376
  getColumnsWithCells() {
3326
- const positions = this.matrix.getUnnestedKeysStartingWith([], true);
3377
+ const positions = this.matrix.getKeysOfFirstChildOnEachBranchStartingWith(
3378
+ [],
3379
+ { excludeSelf: true }
3380
+ );
3327
3381
  const columns = new Set(positions.map((pos) => pos[1]));
3328
3382
  return [...columns.values()].sort(ASC_SORT);
3329
3383
  }
@@ -14541,7 +14595,10 @@ function toTreeDataArray(data, options) {
14541
14595
  treeMap.set(path, item);
14542
14596
  }
14543
14597
  function traverse(path, arr) {
14544
- const nextLevelKeys = treeMap.getKeysStartingWith(path, true, 1);
14598
+ const nextLevelKeys = treeMap.getKeysStartingWith(path, {
14599
+ excludeSelf: true,
14600
+ depthLimit: 1
14601
+ });
14545
14602
  for (const nextLevelKey of nextLevelKeys) {
14546
14603
  const p = [...path, nextLevelKey[nextLevelKey.length - 1]];
14547
14604
  let item = treeMap.get(p);
@@ -15023,12 +15080,18 @@ var RowSelectionState = class _RowSelectionState {
15023
15080
  }
15024
15081
  getGroupKeysDirectlyInsideGroup(groupKeys) {
15025
15082
  const { groupDeepMap } = this.getConfig();
15026
- return groupDeepMap?.getKeysStartingWith(groupKeys, true, 1) || [];
15083
+ return groupDeepMap?.getKeysStartingWith(groupKeys, {
15084
+ excludeSelf: true,
15085
+ depthLimit: 1
15086
+ }) || [];
15027
15087
  }
15028
15088
  getAllPrimaryKeysInsideGroup(groupKeys) {
15029
15089
  const { groupDeepMap } = this.getConfig();
15030
15090
  if (!groupKeys.length) {
15031
- const topLevelKeys = groupDeepMap?.getKeysStartingWith([], true, 1) || [];
15091
+ const topLevelKeys = groupDeepMap?.getKeysStartingWith([], {
15092
+ excludeSelf: true,
15093
+ depthLimit: 1
15094
+ }) || [];
15032
15095
  return topLevelKeys.map((groupKeys2) => this.getAllPrimaryKeysInsideGroup(groupKeys2)).flat();
15033
15096
  }
15034
15097
  const group2 = groupDeepMap?.get(groupKeys);
@@ -15234,7 +15297,9 @@ var RowSelectionState = class _RowSelectionState {
15234
15297
  this.xcache();
15235
15298
  return;
15236
15299
  }
15237
- const selectedKeys = this.selectedMap.getKeysStartingWith(groupKeys, true);
15300
+ const selectedKeys = this.selectedMap.getKeysStartingWith(groupKeys, {
15301
+ excludeSelf: true
15302
+ });
15238
15303
  selectedKeys.forEach((groupKeys2) => {
15239
15304
  this.selectedMap.delete(groupKeys2);
15240
15305
  });
@@ -15260,10 +15325,9 @@ var RowSelectionState = class _RowSelectionState {
15260
15325
  this.xcache();
15261
15326
  return;
15262
15327
  }
15263
- const deselectedKeys = this.deselectedMap.getKeysStartingWith(
15264
- groupKeys,
15265
- true
15266
- );
15328
+ const deselectedKeys = this.deselectedMap.getKeysStartingWith(groupKeys, {
15329
+ excludeSelf: true
15330
+ });
15267
15331
  deselectedKeys.forEach((groupKeys2) => {
15268
15332
  this.deselectedMap.delete(groupKeys2);
15269
15333
  });
@@ -15390,16 +15454,14 @@ var RowSelectionState = class _RowSelectionState {
15390
15454
  if (groupKeys.length === this.getGroupByLength()) {
15391
15455
  const selectionState = this.selectedMap.has(groupKeys) ? true : this.deselectedMap.has(groupKeys) ? false : parentSelected;
15392
15456
  const totalCount = this.getGroupCount(groupKeys);
15393
- let selectedCount2 = this.selectedMap.getKeysStartingWith(
15394
- groupKeys,
15395
- true,
15396
- 1
15397
- ).length;
15398
- let deselectedCount2 = this.deselectedMap.getKeysStartingWith(
15399
- groupKeys,
15400
- true,
15401
- 1
15402
- ).length;
15457
+ let selectedCount2 = this.selectedMap.getKeysStartingWith(groupKeys, {
15458
+ excludeSelf: true,
15459
+ depthLimit: 1
15460
+ }).length;
15461
+ let deselectedCount2 = this.deselectedMap.getKeysStartingWith(groupKeys, {
15462
+ excludeSelf: true,
15463
+ depthLimit: 1
15464
+ }).length;
15403
15465
  const notSpecifiedCount = totalCount - (selectedCount2 + deselectedCount2);
15404
15466
  const result2 = {
15405
15467
  selectedCount: selectedCount2 + (selectionState ? notSpecifiedCount : 0),
@@ -16954,6 +17016,26 @@ var TreeSelectionState = class _TreeSelectionState {
16954
17016
  getTreeDeepMap() {
16955
17017
  return this.getConfig().treeDeepMap;
16956
17018
  }
17019
+ getSelectedLeafNodePaths(rootNodePath = [], treeDeepMap) {
17020
+ treeDeepMap = treeDeepMap || this.getConfig().treeDeepMap;
17021
+ const selectedLeafPaths = [];
17022
+ treeDeepMap.getLeafNodesStartingWith(rootNodePath, (pair) => {
17023
+ if (this.isNodeSelected(pair.keys)) {
17024
+ selectedLeafPaths.push(pair.keys);
17025
+ }
17026
+ });
17027
+ return selectedLeafPaths;
17028
+ }
17029
+ getDeselectedLeafNodePaths(rootNodePath = [], treeDeepMap) {
17030
+ treeDeepMap = treeDeepMap || this.getConfig().treeDeepMap;
17031
+ const deselectedLeafPaths = [];
17032
+ treeDeepMap.getLeafNodesStartingWith(rootNodePath, (pair) => {
17033
+ if (!this.isNodeSelected(pair.keys)) {
17034
+ deselectedLeafPaths.push(pair.keys);
17035
+ }
17036
+ });
17037
+ return deselectedLeafPaths;
17038
+ }
16957
17039
  isLeafNode(nodePath) {
16958
17040
  return !this.getTreeDeepMap().has(nodePath);
16959
17041
  }
@@ -17051,7 +17133,9 @@ var TreeSelectionState = class _TreeSelectionState {
17051
17133
  const leafCount = this.getLeafNodesCount(nodePath);
17052
17134
  let currentSelectionState = this.isSelfSelected(nodePath);
17053
17135
  const { selectionMap } = this;
17054
- const childPaths = selectionMap.getUnnestedKeysStartingWith(nodePath, true).sort(shortestToLongest);
17136
+ const childPaths = selectionMap.getKeysOfFirstChildOnEachBranchStartingWith(nodePath, {
17137
+ excludeSelf: true
17138
+ }).sort(shortestToLongest);
17055
17139
  if (!childPaths.length) {
17056
17140
  if (currentSelectionState !== null) {
17057
17141
  const res2 = leafCount ? currentSelectionState : (
@@ -17240,6 +17324,52 @@ var TreeApiImpl = class {
17240
17324
  this.actions = param.actions;
17241
17325
  this.dataSourceApi = param.dataSourceApi;
17242
17326
  }
17327
+ getSelectedLeafNodePaths(config) {
17328
+ const { treePaths } = this.getState();
17329
+ const treeSelectionState = config?.treeSelectionState || this.getState().treeSelectionState;
17330
+ if (!treeSelectionState) {
17331
+ return [];
17332
+ }
17333
+ return treeSelectionState.getSelectedLeafNodePaths(
17334
+ config?.rootNodePath,
17335
+ treePaths
17336
+ );
17337
+ }
17338
+ getDeselectedLeafNodePaths(config) {
17339
+ const { treePaths } = this.getState();
17340
+ const treeSelectionState = config?.treeSelectionState || this.getState().treeSelectionState;
17341
+ if (!treeSelectionState) {
17342
+ return [];
17343
+ }
17344
+ return treeSelectionState.getDeselectedLeafNodePaths(
17345
+ config?.rootNodePath,
17346
+ treePaths
17347
+ );
17348
+ }
17349
+ getSelectedLeafRowInfos(config) {
17350
+ const { treePaths } = this.getState();
17351
+ const treeSelectionState = config?.treeSelectionState || this.getState().treeSelectionState;
17352
+ if (!treePaths || !treeSelectionState) {
17353
+ return [];
17354
+ }
17355
+ const rootNodePath = config?.rootNodePath || [];
17356
+ const selectedLeafRowInfos = [];
17357
+ treePaths.getLeafNodesStartingWith(
17358
+ rootNodePath,
17359
+ (pair) => {
17360
+ if (treeSelectionState.isNodeSelected(pair.keys)) {
17361
+ const rowInfo = this.getRowInfoByPath(
17362
+ pair.keys
17363
+ );
17364
+ if (rowInfo) {
17365
+ selectedLeafRowInfos.push(rowInfo);
17366
+ }
17367
+ }
17368
+ },
17369
+ { excludeSelf: true }
17370
+ );
17371
+ return selectedLeafRowInfos;
17372
+ }
17243
17373
  get allRowsSelected() {
17244
17374
  return this.getState().allRowsSelected;
17245
17375
  }
@@ -20546,12 +20676,16 @@ function getMappedCallbacks() {
20546
20676
  callbackParams: callbackParams2
20547
20677
  };
20548
20678
  }
20679
+ const dataSourceApi = state.__apiRef.current;
20680
+ const treeApi = dataSourceApi.treeApi;
20549
20681
  const callbackParams = [
20550
20682
  treeSelection2.getState(),
20551
20683
  {
20684
+ treeSelectionState: treeSelection2,
20552
20685
  selectionMode: "multi-row",
20553
20686
  lastUpdatedNodePath: state.lastSelectionUpdatedNodePathRef.current,
20554
- dataSourceApi: state.__apiRef.current
20687
+ dataSourceApi,
20688
+ treeApi
20555
20689
  }
20556
20690
  ];
20557
20691
  return {
@@ -25536,7 +25670,7 @@ var useLicense = (licenseKey = "") => {
25536
25670
  }
25537
25671
  let valid2 = isValidLicense(licenseKey, {
25538
25672
  publishedAt: 1624970570587,
25539
- version: "7.2.1"
25673
+ version: "7.2.2"
25540
25674
  });
25541
25675
  if (!licenseKey && !valid2 && isInsidePlayground) {
25542
25676
  return true;