@infinite-table/infinite-react 7.2.0 → 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
  }
@@ -5990,7 +6044,6 @@ var cursor = { pointer: "_16lm1iwk", "default": "_16lm1iwl", colResize: "_16lm1i
5990
6044
  var display = { flex: "_16lm1iw1p", contents: "_16lm1iw1q", none: "_16lm1iw1r", block: "_16lm1iw1s", grid: "_16lm1iw1t", inlineBlock: "_16lm1iw1u", inlineFlex: "_16lm1iw1v", inlineGrid: "_16lm1iw1w" };
5991
6045
  var flex = { "1": "_16lm1iw1c", none: "_16lm1iw1d" };
5992
6046
  var flexFlow = { column: "_16lm1iw2f", columnReverse: "_16lm1iw2g", row: "_16lm1iw2h", rowReverse: "_16lm1iw2i" };
5993
- var gap = { "0": "_16lm1iw2o", "1": "_16lm1iw2p", "2": "_16lm1iw2q", "3": "_16lm1iw2r", "4": "_16lm1iw2s", "5": "_16lm1iw2t", "6": "_16lm1iw2u", "7": "_16lm1iw2v", "8": "_16lm1iw2w", "9": "_16lm1iw2x", "10": "_16lm1iw2y", none: "_16lm1iw2z" };
5994
6047
  var height = { "0": "_16lm1iw1y", "100%": "_16lm1iw1z", "50%": "_16lm1iw20" };
5995
6048
  var justifyContent = { center: "_16lm1iw30", spaceBetween: "_16lm1iw31", spaceAround: "_16lm1iw32", start: "_16lm1iw33", end: "_16lm1iw34" };
5996
6049
  var left = { "0": "_16lm1iw26", "100%": "_16lm1iw27", "50%": "_16lm1iw28", auto: "_16lm1iw29" };
@@ -12180,7 +12233,7 @@ var DragList = (props) => {
12180
12233
  [DRAG_LIST_ATTRIBUTE]: props.dragListId
12181
12234
  };
12182
12235
  const children = typeof props.children === "function" ? props.children(domProps, contextValue) : props.children;
12183
- return /* @__PURE__ */ React44.createElement(DragListContext, { value: contextValue }, children);
12236
+ return /* @__PURE__ */ React44.createElement(DragListContext.Provider, { value: contextValue }, children);
12184
12237
  };
12185
12238
  var DRAG_LIST_ATTRIBUTE = "data-drag-list-id";
12186
12239
  var DRAG_ITEM_ATTRIBUTE = "data-drag-item-id";
@@ -14542,7 +14595,10 @@ function toTreeDataArray(data, options) {
14542
14595
  treeMap.set(path, item);
14543
14596
  }
14544
14597
  function traverse(path, arr) {
14545
- const nextLevelKeys = treeMap.getKeysStartingWith(path, true, 1);
14598
+ const nextLevelKeys = treeMap.getKeysStartingWith(path, {
14599
+ excludeSelf: true,
14600
+ depthLimit: 1
14601
+ });
14546
14602
  for (const nextLevelKey of nextLevelKeys) {
14547
14603
  const p = [...path, nextLevelKey[nextLevelKey.length - 1]];
14548
14604
  let item = treeMap.get(p);
@@ -15024,12 +15080,18 @@ var RowSelectionState = class _RowSelectionState {
15024
15080
  }
15025
15081
  getGroupKeysDirectlyInsideGroup(groupKeys) {
15026
15082
  const { groupDeepMap } = this.getConfig();
15027
- return groupDeepMap?.getKeysStartingWith(groupKeys, true, 1) || [];
15083
+ return groupDeepMap?.getKeysStartingWith(groupKeys, {
15084
+ excludeSelf: true,
15085
+ depthLimit: 1
15086
+ }) || [];
15028
15087
  }
15029
15088
  getAllPrimaryKeysInsideGroup(groupKeys) {
15030
15089
  const { groupDeepMap } = this.getConfig();
15031
15090
  if (!groupKeys.length) {
15032
- const topLevelKeys = groupDeepMap?.getKeysStartingWith([], true, 1) || [];
15091
+ const topLevelKeys = groupDeepMap?.getKeysStartingWith([], {
15092
+ excludeSelf: true,
15093
+ depthLimit: 1
15094
+ }) || [];
15033
15095
  return topLevelKeys.map((groupKeys2) => this.getAllPrimaryKeysInsideGroup(groupKeys2)).flat();
15034
15096
  }
15035
15097
  const group2 = groupDeepMap?.get(groupKeys);
@@ -15235,7 +15297,9 @@ var RowSelectionState = class _RowSelectionState {
15235
15297
  this.xcache();
15236
15298
  return;
15237
15299
  }
15238
- const selectedKeys = this.selectedMap.getKeysStartingWith(groupKeys, true);
15300
+ const selectedKeys = this.selectedMap.getKeysStartingWith(groupKeys, {
15301
+ excludeSelf: true
15302
+ });
15239
15303
  selectedKeys.forEach((groupKeys2) => {
15240
15304
  this.selectedMap.delete(groupKeys2);
15241
15305
  });
@@ -15261,10 +15325,9 @@ var RowSelectionState = class _RowSelectionState {
15261
15325
  this.xcache();
15262
15326
  return;
15263
15327
  }
15264
- const deselectedKeys = this.deselectedMap.getKeysStartingWith(
15265
- groupKeys,
15266
- true
15267
- );
15328
+ const deselectedKeys = this.deselectedMap.getKeysStartingWith(groupKeys, {
15329
+ excludeSelf: true
15330
+ });
15268
15331
  deselectedKeys.forEach((groupKeys2) => {
15269
15332
  this.deselectedMap.delete(groupKeys2);
15270
15333
  });
@@ -15391,16 +15454,14 @@ var RowSelectionState = class _RowSelectionState {
15391
15454
  if (groupKeys.length === this.getGroupByLength()) {
15392
15455
  const selectionState = this.selectedMap.has(groupKeys) ? true : this.deselectedMap.has(groupKeys) ? false : parentSelected;
15393
15456
  const totalCount = this.getGroupCount(groupKeys);
15394
- let selectedCount2 = this.selectedMap.getKeysStartingWith(
15395
- groupKeys,
15396
- true,
15397
- 1
15398
- ).length;
15399
- let deselectedCount2 = this.deselectedMap.getKeysStartingWith(
15400
- groupKeys,
15401
- true,
15402
- 1
15403
- ).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;
15404
15465
  const notSpecifiedCount = totalCount - (selectedCount2 + deselectedCount2);
15405
15466
  const result2 = {
15406
15467
  selectedCount: selectedCount2 + (selectionState ? notSpecifiedCount : 0),
@@ -16955,6 +17016,26 @@ var TreeSelectionState = class _TreeSelectionState {
16955
17016
  getTreeDeepMap() {
16956
17017
  return this.getConfig().treeDeepMap;
16957
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
+ }
16958
17039
  isLeafNode(nodePath) {
16959
17040
  return !this.getTreeDeepMap().has(nodePath);
16960
17041
  }
@@ -17052,7 +17133,9 @@ var TreeSelectionState = class _TreeSelectionState {
17052
17133
  const leafCount = this.getLeafNodesCount(nodePath);
17053
17134
  let currentSelectionState = this.isSelfSelected(nodePath);
17054
17135
  const { selectionMap } = this;
17055
- const childPaths = selectionMap.getUnnestedKeysStartingWith(nodePath, true).sort(shortestToLongest);
17136
+ const childPaths = selectionMap.getKeysOfFirstChildOnEachBranchStartingWith(nodePath, {
17137
+ excludeSelf: true
17138
+ }).sort(shortestToLongest);
17056
17139
  if (!childPaths.length) {
17057
17140
  if (currentSelectionState !== null) {
17058
17141
  const res2 = leafCount ? currentSelectionState : (
@@ -17241,6 +17324,52 @@ var TreeApiImpl = class {
17241
17324
  this.actions = param.actions;
17242
17325
  this.dataSourceApi = param.dataSourceApi;
17243
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
+ }
17244
17373
  get allRowsSelected() {
17245
17374
  return this.getState().allRowsSelected;
17246
17375
  }
@@ -20547,12 +20676,16 @@ function getMappedCallbacks() {
20547
20676
  callbackParams: callbackParams2
20548
20677
  };
20549
20678
  }
20679
+ const dataSourceApi = state.__apiRef.current;
20680
+ const treeApi = dataSourceApi.treeApi;
20550
20681
  const callbackParams = [
20551
20682
  treeSelection2.getState(),
20552
20683
  {
20684
+ treeSelectionState: treeSelection2,
20553
20685
  selectionMode: "multi-row",
20554
20686
  lastUpdatedNodePath: state.lastSelectionUpdatedNodePathRef.current,
20555
- dataSourceApi: state.__apiRef.current
20687
+ dataSourceApi,
20688
+ treeApi
20556
20689
  }
20557
20690
  ];
20558
20691
  return {
@@ -25537,7 +25670,7 @@ var useLicense = (licenseKey = "") => {
25537
25670
  }
25538
25671
  let valid2 = isValidLicense(licenseKey, {
25539
25672
  publishedAt: 1624970570587,
25540
- version: "7.2.0"
25673
+ version: "7.2.2"
25541
25674
  });
25542
25675
  if (!licenseKey && !valid2 && isInsidePlayground) {
25543
25676
  return true;
@@ -29368,7 +29501,7 @@ import { useCallback as useCallback31 } from "react";
29368
29501
 
29369
29502
  // src/components/InfiniteTable/components/GroupingToolbar/index.css.ts
29370
29503
  var GroupingToolbarItemClearCls = "hs68h8j _16lm1iwk _16lm1iwx _16lm1iw2n";
29371
- var GroupingToolbarItemRecipe = createRuntimeFn({ defaultClassName: "hs68h8e _16lm1iw12 _16lm1iw1x _16lm1iw2j _16lm1iw1p _16lm1iw31", variantClassNames: { active: { true: "hs68h8f _16lm1iwn _16lm1iw1h", false: "_16lm1iwo" }, draggingInProgress: { true: "hs68h8h", false: "hs68h8i" } }, defaultVariants: {}, compoundVariants: [] });
29504
+ var GroupingToolbarItemRecipe = createRuntimeFn({ defaultClassName: "hs68h8e _16lm1iw12 _16lm1iw1x _16lm1iw2j _16lm1iw1p", variantClassNames: { active: { true: "hs68h8f _16lm1iwn _16lm1iw1h", false: "_16lm1iwo" }, draggingInProgress: { true: "hs68h8h", false: "hs68h8i" } }, defaultVariants: {}, compoundVariants: [] });
29372
29505
  var GroupingToolbarPlaceholderCls = "hs68h81";
29373
29506
  var GroupingToolbarRecipe = createRuntimeFn({ defaultClassName: "hs68h80 _16lm1iw1p", variantClassNames: { orientation: { horizontal: "_16lm1iw2h _16lm1iw2j", vertical: "_16lm1iw2f" }, draggingInProgress: { true: "_16lm1iw1h", false: "hs68h86" }, dropRejected: { true: "hs68h87", false: "hs68h88" }, active: { true: "hs68h89", false: "hs68h8a" } }, defaultVariants: {}, compoundVariants: [[{ dropRejected: true, active: true }, "hs68h8b"], [{ dropRejected: false, active: true }, "hs68h8c"], [{ active: false, dropRejected: false }, "hs68h8d"]] });
29374
29507
 
@@ -29388,7 +29521,7 @@ function GroupingToolbarItemDefault(props) {
29388
29521
  props.onClear?.();
29389
29522
  }
29390
29523
  };
29391
- return /* @__PURE__ */ React74.createElement("div", { ...props.domProps }, props.label, /* @__PURE__ */ React74.createElement(
29524
+ return /* @__PURE__ */ React74.createElement("div", { ...props.domProps }, props.label, /* @__PURE__ */ React74.createElement("div", { className: flex[1] }), /* @__PURE__ */ React74.createElement(
29392
29525
  "div",
29393
29526
  {
29394
29527
  tabIndex: 0,
@@ -29448,7 +29581,7 @@ function GroupingToolbarItem(props) {
29448
29581
  direction: column.computedSortedAsc ? 1 : column.computedSortedDesc ? -1 : 0
29449
29582
  }
29450
29583
  ) : null;
29451
- const header = /* @__PURE__ */ React75.createElement("div", { className: join(display.flex, flexFlow.row, gap[2], alignItems.end) }, columnHeader, sortIcon);
29584
+ const header = /* @__PURE__ */ React75.createElement(React75.Fragment, null, columnHeader, sortIcon);
29452
29585
  const active = dragItemId === id && dragSourceListId === GROUPING_TOOLBAR_DRAG_LIST_ID;
29453
29586
  const className = join(
29454
29587
  GroupingToolbarItemRecipe({
@@ -29514,9 +29647,8 @@ function GroupingToolbar(props) {
29514
29647
  }
29515
29648
  },
29516
29649
  onClear: () => {
29517
- dataSourceApi.setGroupBy(
29518
- groupBy.filter((g) => g !== group2)
29519
- );
29650
+ const newGroupBy = groupBy.filter((g) => g !== group2).filter(Boolean);
29651
+ dataSourceApi.setGroupBy(newGroupBy);
29520
29652
  }
29521
29653
  }
29522
29654
  );