@infinite-table/infinite-react 0.4.1 → 0.4.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.
Files changed (6) hide show
  1. package/index.css +81 -64
  2. package/index.d.ts +290 -185
  3. package/index.esm.css +81 -64
  4. package/index.esm.js +1472 -935
  5. package/index.js +1478 -942
  6. package/package.json +2 -2
package/index.esm.js CHANGED
@@ -638,9 +638,9 @@ import {
638
638
  StrictMode,
639
639
  createElement as createElement35,
640
640
  memo as memo13,
641
- useEffect as useEffect30
641
+ useEffect as useEffect30,
642
+ useState as useState15
642
643
  } from "react";
643
- import { useCallback as useCallback18, useState as useState16 } from "react";
644
644
 
645
645
  // src/utils/join.ts
646
646
  var join = (...args) => args.filter((x) => !!`${x}`).join(" ");
@@ -1018,32 +1018,33 @@ var AvoidReactDiff = memo2(AvoidReactDiffFn);
1018
1018
 
1019
1019
  // src/components/utils/buildSubscriptionCallback.tsx
1020
1020
  function buildSubscriptionCallback(withRaf = false) {
1021
- let result = null;
1021
+ let lastCallValue = null;
1022
1022
  let fns = [];
1023
1023
  let rafId = null;
1024
1024
  const updater = (items, callback) => {
1025
+ const results = [];
1025
1026
  if (withRaf) {
1026
1027
  if (rafId != null) {
1027
1028
  cancelAnimationFrame(rafId);
1028
1029
  rafId = null;
1029
1030
  }
1030
1031
  requestAnimationFrame(() => {
1031
- result = items;
1032
+ lastCallValue = items;
1032
1033
  rafId = null;
1033
1034
  for (let i = 0, len = fns.length; i < len; i++) {
1034
- fns[i](items);
1035
+ results.push(fns[i](items));
1035
1036
  }
1036
- callback == null ? void 0 : callback();
1037
+ callback == null ? void 0 : callback(results);
1037
1038
  });
1038
1039
  } else {
1039
- result = items;
1040
+ lastCallValue = items;
1040
1041
  for (let i = 0, len = fns.length; i < len; i++) {
1041
- fns[i](items);
1042
+ results.push(fns[i](items));
1042
1043
  }
1043
- callback == null ? void 0 : callback();
1044
+ callback == null ? void 0 : callback(results);
1044
1045
  }
1045
1046
  };
1046
- updater.get = () => result;
1047
+ updater.get = () => lastCallValue;
1047
1048
  updater.onChange = (fn) => {
1048
1049
  fns.push(fn);
1049
1050
  return () => {
@@ -1054,6 +1055,7 @@ function buildSubscriptionCallback(withRaf = false) {
1054
1055
  updater(null);
1055
1056
  fns.length = 0;
1056
1057
  };
1058
+ updater.getListenersCount = () => fns.length;
1057
1059
  return updater;
1058
1060
  }
1059
1061
 
@@ -2247,13 +2249,19 @@ var DeepMap = class {
2247
2249
  this.visitDepthFirst = (fn) => {
2248
2250
  this.visitWithNext([], fn);
2249
2251
  };
2250
- this.visitWithNext = (parentKeys, fn, currentMap = this.map) => {
2252
+ this.visitWithNext = (parentKeys, fn, currentMap = this.map, depthLimit, skipSelfValue) => {
2251
2253
  if (!currentMap) {
2252
2254
  return;
2253
2255
  }
2254
2256
  let i = 0;
2255
2257
  const hasEmptyKey = currentMap.has(this.emptyKey);
2256
- let allowEmptyKey = true;
2258
+ let allowEmptyKey = skipSelfValue ? false : true;
2259
+ if (depthLimit !== void 0) {
2260
+ if (depthLimit < 0) {
2261
+ return;
2262
+ }
2263
+ depthLimit--;
2264
+ }
2257
2265
  const iterator = (_, key) => {
2258
2266
  const pair = currentMap.get(key);
2259
2267
  if (!pair) {
@@ -2265,7 +2273,7 @@ var DeepMap = class {
2265
2273
  return;
2266
2274
  }
2267
2275
  const keys = isEmptyKey ? [] : [...parentKeys, key];
2268
- const next = map2 ? () => this.visitWithNext(keys, fn, map2) : void 0;
2276
+ let next = map2 ? () => this.visitWithNext(keys, fn, map2, depthLimit !== void 0 ? depthLimit - 1 : void 0) : void 0;
2269
2277
  if (pair.hasOwnProperty("value")) {
2270
2278
  fn(pair.value, keys, i, next);
2271
2279
  i++;
@@ -2297,41 +2305,84 @@ var DeepMap = class {
2297
2305
  });
2298
2306
  }
2299
2307
  }
2300
- getValuesStartingWith(keys) {
2308
+ getValuesStartingWith(keys, excludeSelf, depthLimit) {
2301
2309
  const result = [];
2302
2310
  this.getStartingWith(keys, (_keys, value) => {
2303
2311
  result.push(value);
2304
- });
2312
+ }, excludeSelf, depthLimit);
2305
2313
  return result;
2306
2314
  }
2307
- getKeysStartingWith(keys) {
2315
+ getKeysStartingWith(keys, excludeSelf, depthLimit) {
2308
2316
  const result = [];
2309
2317
  this.getStartingWith(keys, (keys2) => {
2310
2318
  result.push(keys2);
2311
- });
2319
+ }, excludeSelf, depthLimit);
2312
2320
  return result;
2313
2321
  }
2314
- getStartingWith(keys, fn) {
2322
+ getStartingWith(keys, fn, excludeSelf, depthLimit) {
2323
+ let currentMap = this.map;
2324
+ let pair;
2325
+ let stop = false;
2326
+ if (keys.length) {
2327
+ for (let i = 0, len = keys.length; i < len; i++) {
2328
+ const key = keys[i];
2329
+ pair = currentMap.get(key);
2330
+ if (!pair || !pair.map) {
2331
+ stop = true;
2332
+ if (i === len - 1) {
2333
+ stop = true;
2334
+ break;
2335
+ } else {
2336
+ return;
2337
+ }
2338
+ }
2339
+ currentMap = pair.map;
2340
+ }
2341
+ }
2342
+ if (pair && pair.value !== void 0) {
2343
+ if (!excludeSelf) {
2344
+ fn(keys, pair.value);
2345
+ }
2346
+ }
2347
+ if (stop) {
2348
+ return;
2349
+ }
2350
+ this.visitWithNext(keys, (value, keys2, _i, next) => {
2351
+ fn(keys2, value);
2352
+ next == null ? void 0 : next();
2353
+ }, currentMap, depthLimit, excludeSelf);
2354
+ }
2355
+ getMapAt(keys) {
2315
2356
  let currentMap = this.map;
2316
2357
  let pair;
2317
2358
  if (!keys.length) {
2318
- keys = [this.emptyKey];
2359
+ return this.map;
2319
2360
  }
2320
2361
  for (let i = 0, len = keys.length; i < len; i++) {
2321
2362
  const key = keys[i];
2322
2363
  pair = currentMap.get(key);
2323
2364
  if (!pair || !pair.map) {
2324
- return;
2365
+ return void 0;
2325
2366
  }
2326
2367
  currentMap = pair.map;
2327
2368
  }
2328
- if (pair && pair.value !== void 0) {
2329
- fn(keys, pair.value);
2369
+ return currentMap;
2370
+ }
2371
+ getAllChildrenSizeFor(keys) {
2372
+ let currentMap = this.map;
2373
+ let pair;
2374
+ if (!keys.length) {
2375
+ return this.length;
2330
2376
  }
2331
- this.visitWithNext(keys, (value, keys2, _i, next) => {
2332
- fn(keys2, value);
2333
- next == null ? void 0 : next();
2334
- }, currentMap);
2377
+ for (let i = 0, len = keys.length; i < len; i++) {
2378
+ const key = keys[i];
2379
+ pair = currentMap.get(key);
2380
+ if (!pair || !pair.map) {
2381
+ return 0;
2382
+ }
2383
+ currentMap = pair.map;
2384
+ }
2385
+ return pair.length;
2335
2386
  }
2336
2387
  getDirectChildrenSizeFor(keys) {
2337
2388
  var _a;
@@ -2361,7 +2412,9 @@ var DeepMap = class {
2361
2412
  for (let i = 0, len = keys.length; i < len; i++) {
2362
2413
  const key = keys[i];
2363
2414
  const last = i === len - 1;
2364
- const pair = currentMap.get(key) || {};
2415
+ const pair = currentMap.get(key) || {
2416
+ length: 0
2417
+ };
2365
2418
  if (last) {
2366
2419
  pair.revision = this.revision++;
2367
2420
  pair.value = value;
@@ -2372,6 +2425,7 @@ var DeepMap = class {
2372
2425
  pair.map = new Map();
2373
2426
  currentMap.set(key, pair);
2374
2427
  }
2428
+ pair.length++;
2375
2429
  currentMap = pair.map;
2376
2430
  }
2377
2431
  }
@@ -2422,6 +2476,7 @@ var DeepMap = class {
2422
2476
  keys = [...keys];
2423
2477
  }
2424
2478
  const maps = [currentMap];
2479
+ const pairs = [];
2425
2480
  let result = false;
2426
2481
  for (let i = 0, len = keys.length; i < len; i++) {
2427
2482
  const key = keys[i];
@@ -2433,6 +2488,9 @@ var DeepMap = class {
2433
2488
  delete pair.value;
2434
2489
  delete pair.revision;
2435
2490
  result = true;
2491
+ pairs.forEach((pair2) => {
2492
+ pair2.length--;
2493
+ });
2436
2494
  this.length--;
2437
2495
  }
2438
2496
  if (pair.map && pair.map.size === 0) {
@@ -2448,6 +2506,7 @@ var DeepMap = class {
2448
2506
  result = false;
2449
2507
  break;
2450
2508
  }
2509
+ pairs.push(pair);
2451
2510
  currentMap = pair.map;
2452
2511
  maps.push(currentMap);
2453
2512
  }
@@ -2521,6 +2580,19 @@ var DeepMap = class {
2521
2580
  });
2522
2581
  return result;
2523
2582
  }
2583
+ valuesAt(keys) {
2584
+ const map2 = this.getMapAt(keys);
2585
+ if (!map2) {
2586
+ return [];
2587
+ }
2588
+ const result = [];
2589
+ map2.forEach((bag) => {
2590
+ if (bag.value !== void 0) {
2591
+ result.push(bag.value);
2592
+ }
2593
+ });
2594
+ return result;
2595
+ }
2524
2596
  values() {
2525
2597
  return this.sortedIterator((pair) => pair.value);
2526
2598
  }
@@ -3592,11 +3664,11 @@ var useRerender = () => {
3592
3664
  };
3593
3665
 
3594
3666
  // src/components/InfiniteTable/components/ActiveCellIndicator.css.ts
3595
- var ActiveCellIndicatorCls = { visible: "nxbq1c2 nxbq1c1 _16lm1iwf _16lm1iw3 _16lm1iw14 _16lm1iw12", hidden: "nxbq1c3 nxbq1c1 _16lm1iwf _16lm1iw3 _16lm1iw14 _16lm1iw12" };
3596
- var ActiveIndicatorWrapperCls = "_16lm1iwf _16lm1iw3 _16lm1iw14 _16lm1iw12 _16lm1iwy _16lm1iwo";
3667
+ var ActiveCellIndicatorCls = { visible: "nxbq1c2 nxbq1c1 _16lm1iwg _16lm1iw3 _16lm1iw15 _16lm1iw13", hidden: "nxbq1c3 nxbq1c1 _16lm1iwg _16lm1iw3 _16lm1iw15 _16lm1iw13" };
3668
+ var ActiveIndicatorWrapperCls = "_16lm1iwg _16lm1iw3 _16lm1iw15 _16lm1iw13 _16lm1iwz _16lm1iwp";
3597
3669
 
3598
3670
  // src/components/InfiniteTable/components/ActiveRowIndicator.css.ts
3599
- var ActiveRowIndicatorCls = { visible: "j26lrx1 j26lrx0 _16lm1iwf _16lm1iw3 _16lm1iw11 _16lm1iw12 _16lm1iw14", hidden: "j26lrx2 j26lrx0 _16lm1iwf _16lm1iw3 _16lm1iw11 _16lm1iw12 _16lm1iw14" };
3671
+ var ActiveRowIndicatorCls = { visible: "j26lrx1 j26lrx0 _16lm1iwg _16lm1iw3 _16lm1iw12 _16lm1iw13 _16lm1iw15", hidden: "j26lrx2 j26lrx0 _16lm1iwg _16lm1iw3 _16lm1iw12 _16lm1iw13 _16lm1iw15" };
3600
3672
 
3601
3673
  // src/components/InfiniteTable/components/ActiveRowIndicator.tsx
3602
3674
  var { rootClassName: rootClassName3 } = internalProps;
@@ -3887,10 +3959,10 @@ var usePrevious = (value, initialValue) => {
3887
3959
  };
3888
3960
 
3889
3961
  // src/components/hooks/useComponentState/index.tsx
3890
- var notifyChange = (props, callbackPropName, newValue) => {
3962
+ var notifyChange = (props, callbackPropName, values) => {
3891
3963
  const callbackProp = props[callbackPropName];
3892
3964
  if (typeof callbackProp === "function") {
3893
- callbackProp(newValue);
3965
+ callbackProp(...values);
3894
3966
  }
3895
3967
  };
3896
3968
  var debug3 = dbg("rerender");
@@ -3919,14 +3991,14 @@ function getReducerGeneratedActions(dispatch, getState, getProps, propsToForward
3919
3991
  }
3920
3992
  }
3921
3993
  if (notifyTheChange) {
3922
- let callbackParam = value;
3994
+ let callbackParams = [value];
3923
3995
  let callbackName = `on${toUpperFirst(stateKey)}Change`;
3924
3996
  if (mappedCallbacks && mappedCallbacks[key]) {
3925
3997
  const res = mappedCallbacks[key](value, state2);
3926
3998
  callbackName = res.callbackName || callbackName;
3927
- callbackParam = res.callbackParam;
3999
+ callbackParams = res.callbackParams;
3928
4000
  }
3929
- notifyChange(props, callbackName, callbackParam);
4001
+ notifyChange(props, callbackName, callbackParams);
3930
4002
  }
3931
4003
  const forwardFn = propsToForward[key];
3932
4004
  if (typeof forwardFn === "function") {
@@ -3991,7 +4063,8 @@ function getComponentStateRoot(config) {
3991
4063
  props,
3992
4064
  state: state2,
3993
4065
  oldState: null,
3994
- parentState
4066
+ parentState,
4067
+ getState: getComponentState
3995
4068
  });
3996
4069
  propsToStateSetRef.current = new Set([
3997
4070
  ...propsToStateSetRef.current,
@@ -4025,7 +4098,8 @@ function getComponentStateRoot(config) {
4025
4098
  props: getProps(),
4026
4099
  state: newState,
4027
4100
  oldState: previousState,
4028
- parentState: parentState2
4101
+ parentState: parentState2,
4102
+ getState: getComponentState
4029
4103
  });
4030
4104
  propsToStateSetRef.current = new Set([
4031
4105
  ...propsToStateSetRef.current,
@@ -4143,20 +4217,20 @@ var useInternalProps = () => {
4143
4217
  };
4144
4218
 
4145
4219
  // src/components/InfiniteTable/utilities.css.ts
4146
- var alignItems = { center: "_16lm1iw1e", stretch: "_16lm1iw1f" };
4147
- var cssEllipsisClassName = "_16lm1iw1p _16lm1iw1q _16lm1iw1j";
4148
- var cursor = { pointer: "_16lm1iwd", colResize: "_16lm1iwe" };
4149
- var display = { flex: "_16lm1iwt", none: "_16lm1iwu", block: "_16lm1iwv", inlineBlock: "_16lm1iww" };
4150
- var flex = { "1": "_16lm1iwg", none: "_16lm1iwh" };
4151
- var flexFlow = { column: "_16lm1iw1c", row: "_16lm1iw1d" };
4152
- var justifyContent = { center: "_16lm1iw1g", start: "_16lm1iw1h", end: "_16lm1iw1i" };
4153
- var left = { "0": "_16lm1iw14", "100%": "_16lm1iw15", auto: "_16lm1iw16" };
4154
- var overflow = { hidden: "_16lm1iw1j", auto: "_16lm1iw1k", visible: "_16lm1iw1l" };
4220
+ var alignItems = { center: "_16lm1iw1h", stretch: "_16lm1iw1i" };
4221
+ var cssEllipsisClassName = "_16lm1iw1s _16lm1iw1t _16lm1iw1m";
4222
+ var cursor = { pointer: "_16lm1iwe", colResize: "_16lm1iwf" };
4223
+ var display = { flex: "_16lm1iwu", none: "_16lm1iwv", block: "_16lm1iww", inlineBlock: "_16lm1iwx" };
4224
+ var flex = { "1": "_16lm1iwh", none: "_16lm1iwi" };
4225
+ var flexFlow = { column: "_16lm1iw1d", columnReverse: "_16lm1iw1e", row: "_16lm1iw1f", rowReverse: "_16lm1iw1g" };
4226
+ var justifyContent = { center: "_16lm1iw1j", start: "_16lm1iw1k", end: "_16lm1iw1l" };
4227
+ var left = { "0": "_16lm1iw15", "100%": "_16lm1iw16", auto: "_16lm1iw17" };
4228
+ var overflow = { hidden: "_16lm1iw1m", auto: "_16lm1iw1n", visible: "_16lm1iw1o" };
4155
4229
  var position = { relative: "_16lm1iw1", absolute: "_16lm1iw2", sticky: "_16lm1iw3", fixed: "_16lm1iw4" };
4156
- var top = { "0": "_16lm1iw12", "100%": "_16lm1iw13" };
4230
+ var top = { "0": "_16lm1iw13", "100%": "_16lm1iw14" };
4157
4231
  var transformTranslateZero = "_16lm1iwa";
4158
- var userSelect = { none: "_16lm1iwx" };
4159
- var zIndex = { "1": "_16lm1iwi", "10": "_16lm1iwj", "100": "_16lm1iwk", "1000": "_16lm1iwl", "10000": "_16lm1iwm", "100000": "_16lm1iwn", "1000000": "_16lm1iwo", "10000000": "_16lm1iwp", "1k": "_16lm1iwq", "10k": "_16lm1iwr", "100k": "_16lm1iws" };
4232
+ var userSelect = { none: "_16lm1iwy" };
4233
+ var zIndex = { "1": "_16lm1iwj", "10": "_16lm1iwk", "100": "_16lm1iwl", "1000": "_16lm1iwm", "10000": "_16lm1iwn", "100000": "_16lm1iwo", "1000000": "_16lm1iwp", "10000000": "_16lm1iwq", "1k": "_16lm1iwr", "10k": "_16lm1iws", "100k": "_16lm1iwt" };
4160
4234
 
4161
4235
  // src/components/InfiniteTable/components/InfiniteTableBody/InfiniteTableBody.tsx
4162
4236
  var InfiniteTableBody = forwardRef2(function InfiniteTableBody2(props, ref) {
@@ -4253,6 +4327,7 @@ var defaultFilterTypes = getFilterTypes();
4253
4327
 
4254
4328
  // src/components/InfiniteTable/hooks/useCellClassName.ts
4255
4329
  function useCellClassName(column, baseClasses, variants, extraFlags) {
4330
+ var _a;
4256
4331
  const result = [...baseClasses];
4257
4332
  const variantObject = {
4258
4333
  filtered: column.computedFiltered,
@@ -4262,7 +4337,7 @@ function useCellClassName(column, baseClasses, variants, extraFlags) {
4262
4337
  firstInCategory: column.computedFirstInCategory,
4263
4338
  lastInCategory: column.computedLastInCategory,
4264
4339
  pinned: column.computedPinned || false,
4265
- rowSelected: extraFlags.rowSelected,
4340
+ rowSelected: (_a = extraFlags.rowSelected) != null ? _a : "null",
4266
4341
  rowActive: extraFlags.rowActive,
4267
4342
  dragging: extraFlags.dragging,
4268
4343
  zebra: extraFlags.zebra
@@ -4317,14 +4392,14 @@ var useInfiniteTable = () => {
4317
4392
  // src/components/InfiniteTable/InfiniteCls.css.ts
4318
4393
  var import_createRuntimeFn = __toModule(require_vanilla_extract_recipes_createRuntimeFn_cjs());
4319
4394
  var FooterCls = "_16lm1iw1";
4320
- var InfiniteCls = "_1yeub2v0 _16lm1iw1 _16lm1iwt _16lm1iw1c _16lm1iw0";
4395
+ var InfiniteCls = "_1yeub2v0 _16lm1iw1 _16lm1iwu _16lm1iw1d _16lm1iw0";
4321
4396
  var InfiniteClsHasPinnedEnd = "_1yeub2vo";
4322
4397
  var InfiniteClsHasPinnedStart = "_1yeub2vn";
4323
4398
  var InfiniteClsRecipe = (0, import_createRuntimeFn.createRuntimeFn)({ defaultClassName: "", variantClassNames: { focused: { true: "_1yeub2v2", false: "_1yeub2v3" }, focusedWithin: { true: "_1yeub2v4", false: "_1yeub2v5" }, hasPinnedStart: { true: "_1yeub2v6", false: "_1yeub2v7" }, hasPinnedEnd: { true: "_1yeub2v8", false: "_1yeub2v9" }, hasPinnedStartOverflow: { true: "_1yeub2va", false: "_1yeub2vb" }, hasPinnedEndOverflow: { true: "_1yeub2vc", false: "_1yeub2vd" } }, defaultVariants: {}, compoundVariants: [[{ focused: false, focusedWithin: false }, "_1yeub2ve"]] });
4324
4399
  var InfiniteClsShiftingColumns = "_1yeub2vl";
4325
- var PinnedEndIndicatorBorder = "_1yeub2vr _1yeub2vp _16lm1iw2 _16lm1iw12 _16lm1iwe _16lm1iwx _16lm1iw10 _16lm1iw1n _16lm1iwf _16lm1iwp";
4400
+ var PinnedEndIndicatorBorder = "_1yeub2vr _1yeub2vp _16lm1iw2 _16lm1iw13 _16lm1iwf _16lm1iwy _16lm1iw11 _16lm1iw1q _16lm1iwg _16lm1iwq";
4326
4401
  var PinnedRowsContainerClsVariants = (0, import_createRuntimeFn.createRuntimeFn)({ defaultClassName: "", variantClassNames: { pinned: { start: "_1yeub2vi", end: "_1yeub2vj", false: "_1yeub2vk" } }, defaultVariants: {}, compoundVariants: [] });
4327
- var PinnedStartIndicatorBorder = "_1yeub2vq _1yeub2vp _16lm1iw2 _16lm1iw12 _16lm1iwe _16lm1iwx _16lm1iw10 _16lm1iw1n _16lm1iwf _16lm1iwp";
4402
+ var PinnedStartIndicatorBorder = "_1yeub2vq _1yeub2vp _16lm1iw2 _16lm1iw13 _16lm1iwf _16lm1iwy _16lm1iw11 _16lm1iw1q _16lm1iwg _16lm1iwq";
4328
4403
 
4329
4404
  // src/components/utils/getScrollbarWidth.ts
4330
4405
  var scrollbarWidth;
@@ -4902,6 +4977,9 @@ var useColumnPointerEvents = ({
4902
4977
  } = useInfiniteTable();
4903
4978
  const onPointerDown = useCallback6((e) => {
4904
4979
  var _a2;
4980
+ if (e.target.tagName === "INPUT") {
4981
+ return;
4982
+ }
4905
4983
  const {
4906
4984
  computedVisibleColumns,
4907
4985
  computedVisibleColumnsMap,
@@ -4910,6 +4988,9 @@ var useColumnPointerEvents = ({
4910
4988
  computedPinnedEndColumns
4911
4989
  } = getComputed();
4912
4990
  const dragColumn = computedVisibleColumnsMap.get(columnId);
4991
+ if (!dragColumn.computedDraggable) {
4992
+ return;
4993
+ }
4913
4994
  const target = domRef.current;
4914
4995
  const targetRect = target.getBoundingClientRect();
4915
4996
  const tableRect = rootRef.current.getBoundingClientRect();
@@ -5034,8 +5115,8 @@ function objectValuesExcept(obj, exceptList) {
5034
5115
 
5035
5116
  // src/components/InfiniteTable/components/cell.css.ts
5036
5117
  var import_createRuntimeFn2 = __toModule(require_vanilla_extract_recipes_createRuntimeFn_cjs());
5037
- var ColumnCellCls = "_1eexc2a6 _1eexc2a5 _16lm1iwt _16lm1iw1d _16lm1iw1e _16lm1iw2 _16lm1iw1o _16lm1iw1p _16lm1iwx";
5038
- var ColumnCellRecipe = (0, import_createRuntimeFn2.createRuntimeFn)({ defaultClassName: "_1eexc2a8", variantClassNames: { dragging: { false: "_1eexc2a9", true: "_1eexc2aa" }, rowActive: { false: "_1eexc2ab", true: "_1eexc2ac" }, zebra: { false: "_1eexc2ad", even: "_1eexc2ae", odd: "_1eexc2af" }, rowSelected: { true: "_1eexc2ag", false: "_1eexc2ah" }, first: { true: "_1eexc2ai", false: "_1eexc2aj" }, last: { true: "_1eexc2ak", false: "_1eexc2al" }, groupByField: { true: "_1eexc2am", false: "_1eexc2an" }, firstInCategory: { true: "_1eexc2ao", false: "_1eexc2ap" }, lastInCategory: { true: "_1eexc2aq", false: "_1eexc2ar" }, pinned: { start: "_1eexc2as", end: "_1eexc2at", false: "_1eexc2au" }, filtered: { true: "_1eexc2av", false: "_1eexc2aw" } }, defaultVariants: {}, compoundVariants: [[{ pinned: "start", lastInCategory: true }, "_1eexc2ax"], [{ pinned: "start", firstInCategory: true }, "_1eexc2ay"], [{ pinned: "end", firstInCategory: true }, "_1eexc2az"], [{ pinned: "end", lastInCategory: true }, "_1eexc2a10"]] });
5118
+ var ColumnCellCls = "_1eexc2a6 _1eexc2a5 _16lm1iwu _16lm1iw1f _16lm1iw1h _16lm1iw2 _16lm1iw1r _16lm1iw1s _16lm1iwy";
5119
+ var ColumnCellRecipe = (0, import_createRuntimeFn2.createRuntimeFn)({ defaultClassName: "_1eexc2a8", variantClassNames: { dragging: { false: "_1eexc2a9", true: "_1eexc2aa" }, rowActive: { false: "_1eexc2ab", true: "_1eexc2ac" }, zebra: { false: "_1eexc2ad", even: "_1eexc2ae", odd: "_1eexc2af" }, rowSelected: { true: "_1eexc2ag", false: "_1eexc2ah", null: "_1eexc2ai" }, first: { true: "_1eexc2aj", false: "_1eexc2ak" }, last: { true: "_1eexc2al", false: "_1eexc2am" }, groupByField: { true: "_1eexc2an", false: "_1eexc2ao" }, firstInCategory: { true: "_1eexc2ap", false: "_1eexc2aq" }, lastInCategory: { true: "_1eexc2ar", false: "_1eexc2as" }, pinned: { start: "_1eexc2at", end: "_1eexc2au", false: "_1eexc2av" }, filtered: { true: "_1eexc2aw", false: "_1eexc2ax" } }, defaultVariants: {}, compoundVariants: [[{ pinned: "start", lastInCategory: true }, "_1eexc2ay"], [{ pinned: "start", firstInCategory: true }, "_1eexc2az"], [{ pinned: "end", firstInCategory: true }, "_1eexc2a10"], [{ pinned: "end", lastInCategory: true }, "_1eexc2a11"]] });
5039
5120
  var SelectionCheckboxCls = "_1eexc2a7";
5040
5121
 
5041
5122
  // src/components/InfiniteTable/components/CheckBox.tsx
@@ -5045,7 +5126,7 @@ import {
5045
5126
  import { useEffect as useEffect9, useRef as useRef11 } from "react";
5046
5127
 
5047
5128
  // src/components/InfiniteTable/components/CheckBox.css.ts
5048
- var CheckBoxCls = "_16lm1iwd";
5129
+ var CheckBoxCls = "_16lm1iwe";
5049
5130
 
5050
5131
  // src/components/InfiniteTable/components/CheckBox.tsx
5051
5132
  function forwardProps2() {
@@ -5060,7 +5141,7 @@ var InfiniteCheckBoxRoot = getComponentStateRoot({
5060
5141
  checked: (checked) => {
5061
5142
  return {
5062
5143
  callbackName: "onChange",
5063
- callbackParam: checked
5144
+ callbackParams: [checked]
5064
5145
  };
5065
5146
  }
5066
5147
  },
@@ -5185,7 +5266,7 @@ var defaultRenderSelectionCheckBox = (params) => {
5185
5266
  deselectCurrentRow();
5186
5267
  }
5187
5268
  },
5188
- checked: rowInfo.isGroupRow ? !rowInfo.rowSelected ? rowInfo.childrenSelectedCount > 0 ? null : false : true : rowInfo.rowSelected
5269
+ checked: rowInfo.rowSelected
5189
5270
  });
5190
5271
  };
5191
5272
  function isColumnWithField(c) {
@@ -5204,6 +5285,7 @@ function InfiniteTableColumnCellFn(props) {
5204
5285
  toggleGroupRow,
5205
5286
  rowIndex,
5206
5287
  rowHeight,
5288
+ columnsMap,
5207
5289
  domRef,
5208
5290
  hidden,
5209
5291
  showZebraRows
@@ -5279,23 +5361,24 @@ function InfiniteTableColumnCellFn(props) {
5279
5361
  }, rest);
5280
5362
  const renderParam = __spreadProps(__spreadValues({
5281
5363
  column,
5364
+ columnsMap,
5282
5365
  domRef,
5283
5366
  groupRowInfo
5284
5367
  }, rest), {
5285
5368
  selectionMode,
5286
- selectRow: imperativeApi.selectRow,
5287
- deselectRow: imperativeApi.deselectRow,
5288
- toggleRowSelection: imperativeApi.toggleRowSelection,
5369
+ selectRow: imperativeApi.selectionApi.selectRow,
5370
+ deselectRow: imperativeApi.selectionApi.deselectRow,
5371
+ toggleRowSelection: imperativeApi.selectionApi.toggleRowSelection,
5289
5372
  renderBag: {
5290
5373
  value,
5291
5374
  selectionCheckBox: null,
5292
5375
  groupIcon: null
5293
5376
  },
5294
5377
  selectCurrentRow: useCallback7(() => {
5295
- return imperativeApi.selectRow(rowInfo.id);
5378
+ return imperativeApi.selectionApi.selectRow(rowInfo.id, rowInfo.dataSourceHasGrouping ? rowInfo.groupKeys : void 0);
5296
5379
  }, [rowInfo]),
5297
5380
  deselectCurrentRow: useCallback7(() => {
5298
- return imperativeApi.deselectRow(rowInfo.id);
5381
+ return imperativeApi.selectionApi.deselectRow(rowInfo.id, rowInfo.dataSourceHasGrouping ? rowInfo.groupKeys : void 0);
5299
5382
  }, [rowInfo]),
5300
5383
  rowIndex,
5301
5384
  toggleGroupRow,
@@ -5306,7 +5389,10 @@ function InfiniteTableColumnCellFn(props) {
5306
5389
  toggleGroupRow(rowInfo.groupKeys);
5307
5390
  }, [rowInfo]),
5308
5391
  toggleCurrentGroupRowSelection: useCallback7(() => {
5309
- return imperativeApi.toggleGroupRowSelection(rowInfo.isGroupRow ? rowInfo.groupKeys : []);
5392
+ if (!rowInfo.isGroupRow) {
5393
+ return;
5394
+ }
5395
+ return imperativeApi.selectionApi.toggleGroupRowSelection(rowInfo.isGroupRow ? rowInfo.groupKeys : []);
5310
5396
  }, [rowInfo]),
5311
5397
  groupBy: computedDataSource.groupBy,
5312
5398
  pivotBy: computedDataSource.pivotBy
@@ -5323,7 +5409,7 @@ function InfiniteTableColumnCellFn(props) {
5323
5409
  })
5324
5410
  });
5325
5411
  }
5326
- if (column.renderSelectionCheckBox) {
5412
+ if (column.renderSelectionCheckBox && selectionMode == "multi-row") {
5327
5413
  renderParam.renderBag.selectionCheckBox = /* @__PURE__ */ createElement15(RenderCellHookComponent, {
5328
5414
  render: defaultRenderSelectionCheckBox,
5329
5415
  renderParam
@@ -5367,7 +5453,7 @@ function InfiniteTableColumnCellFn(props) {
5367
5453
  renderParam
5368
5454
  });
5369
5455
  }
5370
- return /* @__PURE__ */ createElement15(Fragment2, null, renderParam.renderBag.groupIcon, renderParam.renderBag.selectionCheckBox, renderParam.renderBag.value);
5456
+ return /* @__PURE__ */ createElement15(Fragment2, null, column.align !== "end" ? renderParam.renderBag.groupIcon : null, column.align !== "end" ? renderParam.renderBag.selectionCheckBox : null, renderParam.renderBag.value, column.align === "end" ? renderParam.renderBag.selectionCheckBox : null, column.align === "end" ? renderParam.renderBag.groupIcon : null);
5371
5457
  }, [
5372
5458
  column,
5373
5459
  hidden,
@@ -5425,6 +5511,15 @@ function RenderCellHookComponent(props) {
5425
5511
  renderParam: props.renderParam
5426
5512
  }));
5427
5513
  }
5514
+ function RenderHeaderCellHookComponent(props) {
5515
+ const ContextProvider = InfiniteTableHeaderCellContext.Provider;
5516
+ return /* @__PURE__ */ createElement16(ContextProvider, {
5517
+ value: props.renderParam
5518
+ }, /* @__PURE__ */ createElement16(RenderHookComponent, {
5519
+ render: props.render,
5520
+ renderParam: props.renderParam
5521
+ }));
5522
+ }
5428
5523
 
5429
5524
  // src/components/InfiniteTable/components/FilterEditors.tsx
5430
5525
  import {
@@ -5472,19 +5567,19 @@ import { useEffect as useEffect10, useState as useState6 } from "react";
5472
5567
 
5473
5568
  // src/components/InfiniteTable/components/InfiniteTableHeader/header.css.ts
5474
5569
  var import_createRuntimeFn3 = __toModule(require_vanilla_extract_recipes_createRuntimeFn_cjs());
5475
- var CellCls = "_1eexc2a5 _16lm1iwt _16lm1iw1d _16lm1iw1e _16lm1iw2 _16lm1iw1o _16lm1iw1p _16lm1iwx";
5476
- var HeaderCellContentRecipe = (0, import_createRuntimeFn3.createRuntimeFn)({ defaultClassName: "_12zfob11d _16lm1iwz _16lm1iw11 _16lm1iwt _16lm1iw1d _16lm1iw1e", variantClassNames: { filtered: { false: "_12zfob11e", true: "_12zfob11f" } }, defaultVariants: {}, compoundVariants: [] });
5477
- var HeaderCellProxy = "_12zfob1k _16lm1iw1p _16lm1iw1q _16lm1iw1j";
5478
- var HeaderCellRecipe = (0, import_createRuntimeFn3.createRuntimeFn)({ defaultClassName: "_12zfob1l _16lm1iwv", variantClassNames: { rowActive: { false: "_12zfob1m", true: "_12zfob1n" }, rowSelected: { false: "_12zfob1o", true: "_12zfob1p" }, zebra: { false: "_12zfob1q", even: "_12zfob1r", odd: "_12zfob1s" }, dragging: { true: "_12zfob1t", false: "_12zfob1u" }, first: { true: "_12zfob1v", false: "_12zfob1w" }, last: { true: "_12zfob1x", false: "_12zfob1y" }, groupByField: { true: "_12zfob1z", false: "_12zfob110" }, firstInCategory: { true: "_12zfob111", false: "_12zfob112" }, lastInCategory: { true: "_12zfob113", false: "_12zfob114" }, pinned: { start: "_12zfob115", end: "_12zfob116", false: "_12zfob117" }, filtered: { true: "_12zfob118", false: "_12zfob119" } }, defaultVariants: {}, compoundVariants: [[{ pinned: "start", lastInCategory: true }, "_12zfob11a"], [{ pinned: "end", firstInCategory: true }, "_12zfob11b"], [{ pinned: false, lastInCategory: true }, "_12zfob11c"]] });
5479
- var HeaderClsRecipe = (0, import_createRuntimeFn3.createRuntimeFn)({ defaultClassName: "_12zfob16 _16lm1iwv _16lm1iw2", variantClassNames: { pinned: { start: "_12zfob17", end: "_12zfob18", false: "_12zfob19" }, firstInCategory: { true: "_12zfob1a", false: "_12zfob1b" }, lastInCategory: { true: "_12zfob1c", false: "_12zfob1d" }, overflow: { true: "_12zfob1e", false: "_12zfob1f" } }, defaultVariants: {}, compoundVariants: [[{ overflow: true, pinned: "start" }, "_12zfob1g"], [{ pinned: "start", firstInCategory: true }, "_12zfob1h"], [{ overflow: true, pinned: "end" }, "_12zfob1i"], [{ pinned: "end", lastInCategory: true }, "_12zfob1j"]] });
5480
- var HeaderFilterCls = "_12zfob11i _16lm1iwt _16lm1iw1d _16lm1iw1e _16lm1iw1";
5481
- var HeaderFilterEditorCls = "_16lm1iw11 _16lm1iwz";
5482
- var HeaderGroupCls = "_12zfob11h _16lm1iwt _16lm1iw1d _16lm1iw1e";
5570
+ var CellCls = "_1eexc2a5 _16lm1iwu _16lm1iw1f _16lm1iw1h _16lm1iw2 _16lm1iw1r _16lm1iw1s _16lm1iwy";
5571
+ var HeaderCellContentRecipe = (0, import_createRuntimeFn3.createRuntimeFn)({ defaultClassName: "_12zfob11e _16lm1iw10 _16lm1iw12 _16lm1iwu _16lm1iw1f _16lm1iw1h", variantClassNames: { filtered: { false: "_12zfob11f", true: "_12zfob11g" } }, defaultVariants: {}, compoundVariants: [] });
5572
+ var HeaderCellProxy = "_12zfob1k _16lm1iw1s _16lm1iw1t _16lm1iw1m";
5573
+ var HeaderCellRecipe = (0, import_createRuntimeFn3.createRuntimeFn)({ defaultClassName: "_12zfob1l _16lm1iww", variantClassNames: { rowActive: { false: "_12zfob1m", true: "_12zfob1n" }, rowSelected: { false: "_12zfob1o", true: "_12zfob1p", null: "_12zfob1q" }, zebra: { false: "_12zfob1r", even: "_12zfob1s", odd: "_12zfob1t" }, dragging: { true: "_12zfob1u", false: "_12zfob1v" }, first: { true: "_12zfob1w", false: "_12zfob1x" }, last: { true: "_12zfob1y", false: "_12zfob1z" }, groupByField: { true: "_12zfob110", false: "_12zfob111" }, firstInCategory: { true: "_12zfob112", false: "_12zfob113" }, lastInCategory: { true: "_12zfob114", false: "_12zfob115" }, pinned: { start: "_12zfob116", end: "_12zfob117", false: "_12zfob118" }, filtered: { true: "_12zfob119", false: "_12zfob11a" } }, defaultVariants: {}, compoundVariants: [[{ pinned: "start", lastInCategory: true }, "_12zfob11b"], [{ pinned: "end", firstInCategory: true }, "_12zfob11c"], [{ pinned: false, lastInCategory: true }, "_12zfob11d"]] });
5574
+ var HeaderClsRecipe = (0, import_createRuntimeFn3.createRuntimeFn)({ defaultClassName: "_12zfob16 _16lm1iww _16lm1iw2", variantClassNames: { pinned: { start: "_12zfob17", end: "_12zfob18", false: "_12zfob19" }, firstInCategory: { true: "_12zfob1a", false: "_12zfob1b" }, lastInCategory: { true: "_12zfob1c", false: "_12zfob1d" }, overflow: { true: "_12zfob1e", false: "_12zfob1f" } }, defaultVariants: {}, compoundVariants: [[{ overflow: true, pinned: "start" }, "_12zfob1g"], [{ pinned: "start", firstInCategory: true }, "_12zfob1h"], [{ overflow: true, pinned: "end" }, "_12zfob1i"], [{ pinned: "end", lastInCategory: true }, "_12zfob1j"]] });
5575
+ var HeaderFilterCls = "_12zfob11j _16lm1iwu _16lm1iw1f _16lm1iw1h _16lm1iw1";
5576
+ var HeaderFilterEditorCls = "_16lm1iw12 _16lm1iw10";
5577
+ var HeaderGroupCls = "_12zfob11i _16lm1iwu _16lm1iw1f _16lm1iw1h";
5483
5578
  var HeaderScrollbarPlaceholderCls = "_12zfob15 _16lm1iw2";
5484
5579
  var HeaderSortIconCls = "_16lm1iw1";
5485
5580
  var HeaderSortIconIndexCls = "_12zfob14";
5486
5581
  var HeaderSortIconRecipe = (0, import_createRuntimeFn3.createRuntimeFn)({ defaultClassName: "", variantClassNames: { align: { start: "_12zfob11", center: "_12zfob12", end: "_12zfob13" } }, defaultVariants: {}, compoundVariants: [] });
5487
- var HeaderWrapperCls = "_12zfob11g _16lm1iw1j _16lm1iw1 _16lm1iwt _16lm1iw1d";
5582
+ var HeaderWrapperCls = "_12zfob11h _16lm1iw1m _16lm1iw1 _16lm1iwu _16lm1iw1f";
5488
5583
 
5489
5584
  // src/components/InfiniteTable/components/icons/SortIcon.tsx
5490
5585
  var defaultLineStyle = {
@@ -6054,9 +6149,9 @@ function getColumnGroupResizer(colIndexes, config) {
6054
6149
 
6055
6150
  // src/components/InfiniteTable/components/InfiniteTableHeader/ResizeHandle/ResizeHandle.css.ts
6056
6151
  var import_createRuntimeFn4 = __toModule(require_vanilla_extract_recipes_createRuntimeFn_cjs());
6057
- var ResizeHandleCls = "zneyzh0 _16lm1iw2 _16lm1iw12 _16lm1iw19 _16lm1iw17 _16lm1iwe _16lm1iw1j";
6058
- var ResizeHandleDraggerClsRecipe = (0, import_createRuntimeFn4.createRuntimeFn)({ defaultClassName: "zneyzhb _16lm1iw2 _16lm1iw12 _16lm1iw17", variantClassNames: { constrained: { false: "zneyzhc", true: "zneyzhd" } }, defaultVariants: {}, compoundVariants: [] });
6059
- var ResizeHandleRecipeCls = (0, import_createRuntimeFn4.createRuntimeFn)({ defaultClassName: "", variantClassNames: { computedPinned: { start: "zneyzh1", end: "zneyzh2 _16lm1iw14 _16lm1iw1b", false: "zneyzh3" }, computedFirstInCategory: { true: "zneyzh4", false: "zneyzh5" }, computedLastInCategory: { true: "zneyzh6", false: "zneyzh7" } }, defaultVariants: {}, compoundVariants: [[{ computedPinned: "end", computedLastInCategory: false, computedFirstInCategory: true }, "zneyzh8"], [{ computedPinned: false, computedFirstInCategory: false, computedLastInCategory: true }, "zneyzh9"], [{ computedPinned: "start", computedFirstInCategory: false, computedLastInCategory: true }, "zneyzha"]] });
6152
+ var ResizeHandleCls = "zneyzh0 _16lm1iw2 _16lm1iw13 _16lm1iw1a _16lm1iw18 _16lm1iwf _16lm1iw1m";
6153
+ var ResizeHandleDraggerClsRecipe = (0, import_createRuntimeFn4.createRuntimeFn)({ defaultClassName: "zneyzhb _16lm1iw2 _16lm1iw13 _16lm1iw18", variantClassNames: { constrained: { false: "zneyzhc", true: "zneyzhd" } }, defaultVariants: {}, compoundVariants: [] });
6154
+ var ResizeHandleRecipeCls = (0, import_createRuntimeFn4.createRuntimeFn)({ defaultClassName: "", variantClassNames: { computedPinned: { start: "zneyzh1", end: "zneyzh2 _16lm1iw15 _16lm1iw1c", false: "zneyzh3" }, computedFirstInCategory: { true: "zneyzh4", false: "zneyzh5" }, computedLastInCategory: { true: "zneyzh6", false: "zneyzh7" } }, defaultVariants: {}, compoundVariants: [[{ computedPinned: "end", computedLastInCategory: false, computedFirstInCategory: true }, "zneyzh8"], [{ computedPinned: false, computedFirstInCategory: false, computedLastInCategory: true }, "zneyzh9"], [{ computedPinned: "start", computedFirstInCategory: false, computedLastInCategory: true }, "zneyzha"]] });
6060
6155
 
6061
6156
  // src/components/InfiniteTable/components/InfiniteTableHeader/ResizeHandle/index.tsx
6062
6157
  var { rootClassName: rootClassName8 } = internalProps;
@@ -6199,6 +6294,23 @@ function useColumnResizeHandle(column) {
6199
6294
  }
6200
6295
 
6201
6296
  // src/components/InfiniteTable/components/InfiniteTableHeader/InfiniteTableHeaderCell.tsx
6297
+ var defaultRenderSelectionCheckBox2 = (params) => {
6298
+ const { allRowsSelected, someRowsSelected, api } = params;
6299
+ const selected = allRowsSelected ? true : someRowsSelected ? null : false;
6300
+ return /* @__PURE__ */ createElement22(InfiniteCheckBox, {
6301
+ domProps: {
6302
+ className: SelectionCheckboxCls
6303
+ },
6304
+ onChange: (selected2) => {
6305
+ if (selected2) {
6306
+ api.selectionApi.selectAll();
6307
+ } else {
6308
+ api.selectionApi.deselectAll();
6309
+ }
6310
+ },
6311
+ checked: selected
6312
+ });
6313
+ };
6202
6314
  var InfiniteTableHeaderCellContext = createContext5(null);
6203
6315
  var { rootClassName: rootClassName9 } = internalProps;
6204
6316
  var InfiniteTableHeaderCellClassName = `${rootClassName9}HeaderCell`;
@@ -6208,6 +6320,7 @@ function InfiniteTableHeaderCell(props) {
6208
6320
  const column = props.column;
6209
6321
  const {
6210
6322
  computed: { showColumnFilters },
6323
+ imperativeApi: api,
6211
6324
  componentState: {
6212
6325
  portalDOMRef,
6213
6326
  columnHeaderHeight,
@@ -6215,8 +6328,9 @@ function InfiniteTableHeaderCell(props) {
6215
6328
  columnReorderDragColumnId
6216
6329
  }
6217
6330
  } = useInfiniteTable();
6331
+ const { allRowsSelected, someRowsSelected, selectionMode } = useDataSource();
6218
6332
  const dragging = columnReorderDragColumnId === column.id;
6219
- const { onResize, height, width, headerOptions } = props;
6333
+ const { onResize, height, width, headerOptions, columnsMap } = props;
6220
6334
  const sortInfo = column.computedSortInfo;
6221
6335
  let header = column.header;
6222
6336
  const ref = useCallback9((node) => {
@@ -6225,7 +6339,7 @@ function InfiniteTableHeaderCell(props) {
6225
6339
  (_a2 = props.domRef) == null ? void 0 : _a2.call(props, node);
6226
6340
  }, [props.domRef]);
6227
6341
  const alwaysShow = headerOptions.alwaysReserveSpaceForSortIcon;
6228
- const sortTool = column.computedSortable && (column.computedSorted || alwaysShow) ? /* @__PURE__ */ createElement22(SortIcon, {
6342
+ const sortIcon = column.computedSortable && (column.computedSorted || alwaysShow) ? /* @__PURE__ */ createElement22(SortIcon, {
6229
6343
  index: column.computedMultiSort ? column.computedSortIndex + 1 : void 0,
6230
6344
  className: `${InfiniteTableHeaderCellClassName}__sort-icon ${HeaderSortIconCls} ${HeaderSortIconRecipe({
6231
6345
  align: column.align || "start"
@@ -6236,20 +6350,58 @@ function InfiniteTableHeaderCell(props) {
6236
6350
  dragging,
6237
6351
  domRef: ref,
6238
6352
  column,
6353
+ columnsMap,
6239
6354
  columnSortInfo: sortInfo,
6240
6355
  columnFilterValue: column.computedFilterValue,
6241
- sortTool
6356
+ someRowsSelected,
6357
+ allRowsSelected,
6358
+ selectionMode,
6359
+ api,
6360
+ renderBag: {
6361
+ sortIcon,
6362
+ selectionCheckBox: null,
6363
+ header: column.header && typeof column.header !== "function" ? column.header : column.name
6364
+ }
6242
6365
  };
6243
6366
  const align = column.align || "start";
6244
6367
  const renderChildren = () => {
6368
+ if (column.renderSortIcon) {
6369
+ renderParam.renderBag.sortIcon = /* @__PURE__ */ createElement22(RenderHeaderCellHookComponent, {
6370
+ render: column.renderSortIcon,
6371
+ renderParam: __spreadProps(__spreadValues({}, renderParam), {
6372
+ renderBag: __spreadValues({}, renderParam.renderBag)
6373
+ })
6374
+ });
6375
+ }
6376
+ if (column.renderSelectionCheckBox && selectionMode === "multi-row") {
6377
+ renderParam.renderBag.selectionCheckBox = /* @__PURE__ */ createElement22(RenderHeaderCellHookComponent, {
6378
+ render: defaultRenderSelectionCheckBox2,
6379
+ renderParam
6380
+ });
6381
+ if (column.renderHeaderSelectionCheckBox && column.renderHeaderSelectionCheckBox !== true) {
6382
+ renderParam.renderBag.selectionCheckBox = /* @__PURE__ */ createElement22(RenderHeaderCellHookComponent, {
6383
+ render: column.renderHeaderSelectionCheckBox,
6384
+ renderParam: __spreadProps(__spreadValues({}, renderParam), {
6385
+ renderBag: __spreadValues({}, renderParam.renderBag)
6386
+ })
6387
+ });
6388
+ }
6389
+ }
6245
6390
  if (header instanceof Function) {
6246
- header = /* @__PURE__ */ createElement22(RenderHookComponent, {
6391
+ renderParam.renderBag.header = /* @__PURE__ */ createElement22(RenderHookComponent, {
6247
6392
  render: header,
6393
+ renderParam: __spreadProps(__spreadValues({}, renderParam), {
6394
+ renderBag: __spreadValues({}, renderParam.renderBag)
6395
+ })
6396
+ });
6397
+ }
6398
+ if (column.renderHeader) {
6399
+ return /* @__PURE__ */ createElement22(RenderHeaderCellHookComponent, {
6400
+ render: column.renderHeader,
6248
6401
  renderParam
6249
6402
  });
6250
6403
  }
6251
- header = header != null ? header : column.name;
6252
- return /* @__PURE__ */ createElement22(Fragment3, null, align === "end" ? sortTool : null, header, align !== "end" ? sortTool : null);
6404
+ return /* @__PURE__ */ createElement22(Fragment3, null, align !== "end" ? renderParam.renderBag.selectionCheckBox : null, align === "end" ? renderParam.renderBag.sortIcon : null, renderParam.renderBag.header, align !== "end" ? renderParam.renderBag.sortIcon : null, align === "end" ? renderParam.renderBag.selectionCheckBox : null);
6253
6405
  };
6254
6406
  const domRef = useRef13(null);
6255
6407
  const {
@@ -6785,7 +6937,7 @@ function InfiniteTableHeaderFn(props) {
6785
6937
  headerOptions,
6786
6938
  width: widthWithColspan,
6787
6939
  height: heightWithRowspan,
6788
- columns: computedVisibleColumnsMap
6940
+ columnsMap: computedVisibleColumnsMap
6789
6941
  });
6790
6942
  }, [
6791
6943
  headerOptions,
@@ -6989,7 +7141,7 @@ var InfiniteTableLicenseFooter = forwardRef4(function InfiniteTableLicenseFooter
6989
7141
 
6990
7142
  // src/components/InfiniteTable/components/InfiniteTableRow/row.css.ts
6991
7143
  var import_createRuntimeFn5 = __toModule(require_vanilla_extract_recipes_createRuntimeFn_cjs());
6992
- var GroupRowExpanderCls = "_7pupv0b";
7144
+ var GroupRowExpanderCls = (0, import_createRuntimeFn5.createRuntimeFn)({ defaultClassName: "", variantClassNames: { align: { start: "_7pupv0b", center: "_7pupv0c", end: "_7pupv0d" } }, defaultVariants: {}, compoundVariants: [] });
6993
7145
  var RowClsRecipe = (0, import_createRuntimeFn5.createRuntimeFn)({ defaultClassName: "_7pupv00", variantClassNames: { zebra: { false: "_7pupv02", even: "_7pupv03", odd: "_7pupv04" }, groupRow: { true: "_7pupv05", false: "_7pupv06" }, inlineGroupRow: { true: "_7pupv07", false: "_7pupv08" }, showHoverRows: { true: "_7pupv09", false: "_7pupv0a" } }, defaultVariants: {}, compoundVariants: [] });
6994
7146
  var RowHoverCls = "_7pupv01";
6995
7147
 
@@ -7000,8 +7152,8 @@ import {
7000
7152
  } from "react";
7001
7153
 
7002
7154
  // src/components/InfiniteTable/components/LoadMask.css.ts
7003
- var LoadMaskCls = { visible: "qy58ya1 qy58ya0 _16lm1iw2 _16lm1iw12 _16lm1iw14 _16lm1iw19 _16lm1iw17", hidden: "qy58ya2 qy58ya0 _16lm1iw2 _16lm1iw12 _16lm1iw14 _16lm1iw19 _16lm1iw17" };
7004
- var LoadMaskOverlayCls = "qy58ya3 _16lm1iw2 _16lm1iw12 _16lm1iw14 _16lm1iw19 _16lm1iw17";
7155
+ var LoadMaskCls = { visible: "qy58ya1 qy58ya0 _16lm1iw2 _16lm1iw13 _16lm1iw15 _16lm1iw1a _16lm1iw18", hidden: "qy58ya2 qy58ya0 _16lm1iw2 _16lm1iw13 _16lm1iw15 _16lm1iw1a _16lm1iw18" };
7156
+ var LoadMaskOverlayCls = "qy58ya3 _16lm1iw2 _16lm1iw13 _16lm1iw15 _16lm1iw1a _16lm1iw18";
7005
7157
  var LoadMaskTextCls = "qy58ya4";
7006
7158
 
7007
7159
  // src/components/InfiniteTable/components/LoadMask.tsx
@@ -7019,9 +7171,38 @@ function LoadMaskFn(props) {
7019
7171
  }
7020
7172
  var LoadMask = memo12(LoadMaskFn);
7021
7173
 
7174
+ // src/utils/deepClone.ts
7175
+ function cloneArray(arr) {
7176
+ return arr.map(deepClone);
7177
+ }
7178
+ function deepClone(source) {
7179
+ if (getGlobal().structuredClone) {
7180
+ return getGlobal().structuredClone(source);
7181
+ }
7182
+ if (source === null || typeof source !== "object") {
7183
+ return source;
7184
+ }
7185
+ if (Array.isArray(source)) {
7186
+ return cloneArray(source);
7187
+ }
7188
+ if (source instanceof Date) {
7189
+ return new Date(source);
7190
+ }
7191
+ if (source instanceof Set) {
7192
+ return new Set(cloneArray(Array.from(source)));
7193
+ }
7194
+ if (source instanceof Map) {
7195
+ return new Map(cloneArray(Array.from(source)));
7196
+ }
7197
+ let target = {};
7198
+ for (let key in source)
7199
+ if (source.hasOwnProperty(key)) {
7200
+ target[key] = deepClone(source[key]);
7201
+ }
7202
+ return target;
7203
+ }
7204
+
7022
7205
  // src/utils/groupAndPivot/index.ts
7023
- var GROUP_SELECTED_REDUCER_KEY = "__groupFullySelected";
7024
- var GROUP_CHILDREN_SELECTED_COUNT_KEY = "__groupChildrenSelectedCount";
7025
7206
  var LAZY_ROOT_KEY_FOR_GROUPS = "____root____";
7026
7207
  var NOT_LOADED_YET_KEY_PREFIX = "____not_loaded_yet____";
7027
7208
  function DEFAULT_TO_KEY(value) {
@@ -7038,7 +7219,7 @@ function initReducers(reducers) {
7038
7219
  }
7039
7220
  return result;
7040
7221
  }
7041
- function computeReducersFor(data, index, reducers, reducerResults) {
7222
+ function computeReducersFor(data, index, reducers, reducerResults, groupKeys) {
7042
7223
  var _a, _b;
7043
7224
  if (!reducers || !Object.keys(reducers).length) {
7044
7225
  return;
@@ -7051,7 +7232,7 @@ function computeReducersFor(data, index, reducers, reducerResults) {
7051
7232
  }
7052
7233
  const currentValue = reducerResults[key];
7053
7234
  const value = reducer.field ? data[reducer.field] : (_b = (_a = reducer.getter) == null ? void 0 : _a.call(reducer, data)) != null ? _b : null;
7054
- reducerResults[key] = reducer.reducer(currentValue, value, data, index);
7235
+ reducerResults[key] = reducer.reducer(currentValue, value, data, index, groupKeys);
7055
7236
  }
7056
7237
  }
7057
7238
  function lazyGroup(groupParams, rootData) {
@@ -7059,6 +7240,8 @@ function lazyGroup(groupParams, rootData) {
7059
7240
  reducers = {},
7060
7241
  pivot,
7061
7242
  groupBy,
7243
+ indexer,
7244
+ toPrimaryKey,
7062
7245
  mappings
7063
7246
  } = groupParams;
7064
7247
  const deepMap = new DeepMap();
@@ -7083,7 +7266,7 @@ function lazyGroup(groupParams, rootData) {
7083
7266
  const topLevelPivotColumns = pivot ? new DeepMap() : void 0;
7084
7267
  const currentPivotKeys = [];
7085
7268
  const initialReducerValue = initReducers(reducers);
7086
- const globalReducerResults = __spreadValues({}, initialReducerValue);
7269
+ const globalReducerResults = deepClone(initialReducerValue);
7087
7270
  rootData.visitDepthFirst((lazyGroupRowInfo, keys, _index, next) => {
7088
7271
  const [_rootKey, ...currentGroupKeys] = keys;
7089
7272
  const dataArray = lazyGroupRowInfo.children;
@@ -7097,6 +7280,7 @@ function lazyGroup(groupParams, rootData) {
7097
7280
  if (currentGroupKeys.length == groupBy.length && groupBy.length) {
7098
7281
  if (current) {
7099
7282
  current.items = dataArray;
7283
+ indexer.indexArray(dataArray, toPrimaryKey);
7100
7284
  }
7101
7285
  return next == null ? void 0 : next();
7102
7286
  }
@@ -7127,6 +7311,7 @@ function lazyGroup(groupParams, rootData) {
7127
7311
  childrenLoading: false,
7128
7312
  childrenAvailable: false,
7129
7313
  commonData: dataObject,
7314
+ totalChildrenCount: dataArray[i].totalChildrenCount,
7130
7315
  reducerResults: dataArray[i].aggregations || {}
7131
7316
  };
7132
7317
  deepMap.set(currentGroupKeys, deepMapGroupValue);
@@ -7161,7 +7346,7 @@ function processGroup(deepMap, currentGroupKeys, currentPivotKeys, item, itemInd
7161
7346
  } = deepMap.get(currentGroupKeys);
7162
7347
  currentGroupItems.push(item);
7163
7348
  if (reducers) {
7164
- computeReducersFor(item, itemIndex, reducers, reducerResults);
7349
+ computeReducersFor(item, itemIndex, reducers, reducerResults, currentGroupKeys);
7165
7350
  }
7166
7351
  if (pivot) {
7167
7352
  for (let pivotIndex = 0, pivotLength = pivot.length; pivotIndex < pivotLength; pivotIndex++) {
@@ -7171,19 +7356,27 @@ function processGroup(deepMap, currentGroupKeys, currentPivotKeys, item, itemInd
7171
7356
  if (!pivotDeepMap.has(currentPivotKeys)) {
7172
7357
  topLevelPivotColumns.set(currentPivotKeys, true);
7173
7358
  pivotDeepMap == null ? void 0 : pivotDeepMap.set(currentPivotKeys, {
7174
- reducerResults: __spreadValues({}, initialReducerValue),
7359
+ reducerResults: deepClone(initialReducerValue),
7175
7360
  items: []
7176
7361
  });
7177
7362
  }
7178
7363
  const { reducerResults: pivotReducerResults, items: pivotGroupItems } = pivotDeepMap.get(currentPivotKeys);
7179
7364
  pivotGroupItems.push(item);
7180
7365
  if (reducers) {
7181
- computeReducersFor(item, itemIndex, reducers, pivotReducerResults);
7366
+ computeReducersFor(item, itemIndex, reducers, pivotReducerResults, currentGroupKeys);
7182
7367
  }
7183
7368
  }
7184
7369
  currentPivotKeys.length = 0;
7185
7370
  }
7186
7371
  }
7372
+ function getGroupKeysForDataItem(data, groupBy) {
7373
+ return groupBy.reduce((groupKeys, groupBy2) => {
7374
+ const { field: groupByProperty, toKey: groupToKey } = groupBy2;
7375
+ const key = (groupToKey || DEFAULT_TO_KEY)(data[groupByProperty], data);
7376
+ groupKeys.push(key);
7377
+ return groupKeys;
7378
+ }, []);
7379
+ }
7187
7380
  function group(groupParams, data) {
7188
7381
  const {
7189
7382
  groupBy,
@@ -7197,14 +7390,14 @@ function group(groupParams, data) {
7197
7390
  const currentGroupKeys = [];
7198
7391
  const currentPivotKeys = [];
7199
7392
  const initialReducerValue = initReducers(reducers);
7200
- const globalReducerResults = __spreadValues({}, initialReducerValue);
7393
+ const globalReducerResults = deepClone(initialReducerValue);
7201
7394
  if (!groupByLength) {
7202
7395
  const deepMapGroupValue = {
7203
7396
  items: [],
7204
7397
  cache: false,
7205
7398
  childrenLoading: false,
7206
7399
  childrenAvailable: false,
7207
- reducerResults: __spreadValues({}, initialReducerValue)
7400
+ reducerResults: deepClone(initialReducerValue)
7208
7401
  };
7209
7402
  if (pivot) {
7210
7403
  deepMapGroupValue.pivotDeepMap = new DeepMap();
@@ -7223,7 +7416,7 @@ function group(groupParams, data) {
7223
7416
  cache: false,
7224
7417
  childrenLoading: false,
7225
7418
  childrenAvailable: false,
7226
- reducerResults: __spreadValues({}, initialReducerValue)
7419
+ reducerResults: deepClone(initialReducerValue)
7227
7420
  };
7228
7421
  if (pivot) {
7229
7422
  deepMapGroupValue.pivotDeepMap = new DeepMap();
@@ -7236,7 +7429,7 @@ function group(groupParams, data) {
7236
7429
  processGroup(deepMap, currentGroupKeys, currentPivotKeys, item, i, pivot, reducers, topLevelPivotColumns, initialReducerValue, defaultToKey);
7237
7430
  }
7238
7431
  if (reducers) {
7239
- computeReducersFor(item, i, reducers, globalReducerResults);
7432
+ computeReducersFor(item, i, reducers, globalReducerResults, currentGroupKeys);
7240
7433
  }
7241
7434
  currentGroupKeys.length = 0;
7242
7435
  }
@@ -7313,8 +7506,9 @@ function getEnhancedGroupData(options, deepMapValue) {
7313
7506
  groupCount: groupItems.length,
7314
7507
  groupData: groupItems,
7315
7508
  groupKeys,
7316
- rowSelected: !!reducerResults[GROUP_SELECTED_REDUCER_KEY] || false,
7317
- childrenSelectedCount: reducerResults[GROUP_CHILDREN_SELECTED_COUNT_KEY] || 0,
7509
+ rowSelected: false,
7510
+ selectedChildredCount: 0,
7511
+ deselectedChildredCount: 0,
7318
7512
  id: `${groupKeys}`,
7319
7513
  collapsed,
7320
7514
  dataSourceHasGrouping: true,
@@ -7324,6 +7518,7 @@ function getEnhancedGroupData(options, deepMapValue) {
7324
7518
  deepRowInfoArray: [],
7325
7519
  collapsedChildrenCount: 0,
7326
7520
  collapsedGroupsCount: 0,
7521
+ totalChildrenCount: options.totalChildrenCount,
7327
7522
  childrenAvailable: lazyLoad ? options.childrenAvailable : true,
7328
7523
  childrenLoading: options.childrenLoading,
7329
7524
  indexInParentGroups: options.indexInParentGroups,
@@ -7360,7 +7555,7 @@ function enhancedFlatten(param) {
7360
7555
  toPrimaryKey,
7361
7556
  groupRowsState,
7362
7557
  isRowSelected,
7363
- indexer,
7558
+ rowSelectionState,
7364
7559
  generateGroupRows,
7365
7560
  reducers = {}
7366
7561
  } = param;
@@ -7386,13 +7581,21 @@ function enhancedFlatten(param) {
7386
7581
  indexInAll: result.length,
7387
7582
  groupKeys,
7388
7583
  error: deepMapValue.error,
7584
+ totalChildrenCount: deepMapValue.totalChildrenCount,
7389
7585
  childrenLoading: deepMapValue.childrenLoading,
7390
7586
  childrenAvailable: deepMapValue.childrenAvailable,
7391
7587
  directChildrenCount: groupKeys.length === groupByStrings.length ? deepMapValue.items.length : deepMap.getDirectChildrenSizeFor(groupKeys),
7392
7588
  directChildrenLoadedCount: 0,
7393
7589
  collapsed
7394
7590
  }, deepMapValue);
7395
- indexer.add(enhancedGroupData.indexInAll, enhancedGroupData.id);
7591
+ if (isRowSelected) {
7592
+ enhancedGroupData.rowSelected = isRowSelected(enhancedGroupData);
7593
+ if (rowSelectionState) {
7594
+ const selectionCount = rowSelectionState.getSelectionCountFor(enhancedGroupData.groupKeys);
7595
+ enhancedGroupData.selectedChildredCount = selectionCount.selectedCount;
7596
+ enhancedGroupData.deselectedChildredCount = selectionCount.deselectedCount;
7597
+ }
7598
+ }
7396
7599
  const parent = parents[parents.length - 1];
7397
7600
  const parentCollapsed = (_b = parent == null ? void 0 : parent.collapsed) != null ? _b : false;
7398
7601
  let include = generateGroupRows || collapsed;
@@ -7455,7 +7658,6 @@ function enhancedFlatten(param) {
7455
7658
  if (isRowSelected) {
7456
7659
  rowInfo.rowSelected = isRowSelected(rowInfo);
7457
7660
  }
7458
- indexer.add(rowInfo.indexInAll, rowInfo.id);
7459
7661
  parents.forEach((parent2, i) => {
7460
7662
  const last = i === parents.length - 1;
7461
7663
  if (last && item) {
@@ -8257,212 +8459,540 @@ function lazyLoadRange(options, cache) {
8257
8459
  }, initialPromise);
8258
8460
  }
8259
8461
 
8260
- // src/components/DataSource/BooleanCollectionState.ts
8261
- var BooleanCollectionState = class {
8262
- constructor(state) {
8462
+ // src/components/DataSource/RowSelectionState.ts
8463
+ var RowSelectionState = class {
8464
+ constructor(state, getConfig, _forTestingOnly) {
8465
+ this.selectedRows = null;
8466
+ this.deselectedRows = null;
8467
+ this.defaultSelection = false;
8468
+ this.selectedMap = new DeepMap();
8469
+ this.deselectedMap = new DeepMap();
8470
+ this.selectionCache = new DeepMap();
8471
+ this.selectionCountCache = new DeepMap();
8472
+ this.mapSet = (name, key) => {
8473
+ if (!Array.isArray(key)) {
8474
+ key = [...this.getGroupKeysForPrimaryKey(key), key];
8475
+ }
8476
+ this.xcache();
8477
+ if (name === "selected") {
8478
+ this.selectedMap.set(key, true);
8479
+ } else {
8480
+ this.deselectedMap.set(key, true);
8481
+ }
8482
+ };
8483
+ this._selectedMapSet = (key) => {
8484
+ this.mapSet("selected", key);
8485
+ };
8486
+ this._deselectedMapSet = (key) => {
8487
+ this.mapSet("deselected", key);
8488
+ };
8263
8489
  const stateObject = state instanceof Object.getPrototypeOf(this).constructor ? state.getState() : state;
8264
- const positiveItems = this.getPositiveFromState(stateObject);
8265
- const negativeItems = this.getNegativeFromState(stateObject);
8266
- this.update({
8267
- negativeItems,
8268
- positiveItems
8269
- });
8490
+ this.getConfig = getConfig;
8491
+ if (_forTestingOnly) {
8492
+ Object.assign(this, _forTestingOnly);
8493
+ }
8494
+ this.update(stateObject);
8270
8495
  }
8271
- getInitialState() {
8272
- return this.initialState;
8496
+ getGroupKeysForPrimaryKey(pk) {
8497
+ const { indexer, groupBy } = this.getConfig();
8498
+ const data = indexer.getDataForPrimaryKey(pk);
8499
+ return data ? getGroupKeysForDataItem(data, groupBy) : [];
8273
8500
  }
8274
- destroy() {
8275
- var _a, _b;
8276
- (_a = this.positiveMap) == null ? void 0 : _a.clear();
8277
- (_b = this.negativeMap) == null ? void 0 : _b.clear();
8278
- delete this.positiveMap;
8279
- delete this.negativeMap;
8501
+ getGroupDeepMap() {
8502
+ return this.getConfig().groupDeepMap;
8280
8503
  }
8281
- update(state) {
8282
- const { positiveItems, negativeItems } = state;
8283
- this.allNegative = negativeItems === true;
8284
- this.allPositive = positiveItems === true;
8285
- if (this.allNegative && this.allPositive) {
8286
- throw `Cannot have both negativeItems and positiveItems be true!`;
8287
- }
8288
- if (negativeItems && negativeItems !== true) {
8289
- if (!this.negativeMap) {
8290
- this.negativeMap = new Map();
8291
- }
8292
- this.negativeMap.clear();
8293
- for (let k in negativeItems) {
8294
- if (negativeItems.hasOwnProperty(k)) {
8295
- this.negativeMap.set(k, true);
8296
- }
8297
- }
8298
- if (this.positiveMap) {
8299
- this.positiveMap.clear();
8300
- }
8504
+ getGroupCount(groupKeys) {
8505
+ var _a;
8506
+ if (groupKeys.length == 0) {
8507
+ return this.getConfig().totalCount;
8301
8508
  }
8302
- if (positiveItems && positiveItems !== true) {
8303
- if (!this.positiveMap) {
8304
- this.positiveMap = new Map();
8305
- }
8306
- this.positiveMap.clear();
8307
- for (let k in positiveItems) {
8308
- if (positiveItems.hasOwnProperty(k)) {
8309
- this.positiveMap.set(k, true);
8310
- }
8311
- }
8312
- if (this.negativeMap) {
8313
- this.negativeMap.clear();
8314
- }
8509
+ const groupDeepMap = this.getGroupDeepMap();
8510
+ const deepMapValue = groupDeepMap == null ? void 0 : groupDeepMap.get(groupKeys);
8511
+ if (!deepMapValue) {
8512
+ return 0;
8315
8513
  }
8514
+ return (_a = deepMapValue.totalChildrenCount) != null ? _a : deepMapValue.items.length || 0;
8316
8515
  }
8317
- isDefaultNegativeSelection() {
8318
- return this.allNegative;
8516
+ getGroupKeysDirectlyInsideGroup(groupKeys) {
8517
+ const { groupDeepMap } = this.getConfig();
8518
+ return (groupDeepMap == null ? void 0 : groupDeepMap.getKeysStartingWith(groupKeys, true, 1)) || [];
8319
8519
  }
8320
- isDefaultPositiveSelection() {
8321
- return this.allPositive;
8520
+ getGroupByLength() {
8521
+ return this.getConfig().groupBy.length;
8322
8522
  }
8323
- areAllNegative() {
8324
- return this.allNegative && (this.positiveMap ? this.positiveMap.size === 0 : true);
8523
+ static from(rowSeleStateObject, getConfig, _forTestingOnly) {
8524
+ return new RowSelectionState(rowSeleStateObject, getConfig, _forTestingOnly);
8325
8525
  }
8326
- areAllPositive() {
8327
- return this.allPositive && (this.negativeMap ? this.negativeMap.size === 0 : true);
8526
+ update(stateObject) {
8527
+ var _a, _b;
8528
+ this.selectedRows = stateObject.selectedRows || null;
8529
+ this.deselectedRows = stateObject.deselectedRows || null;
8530
+ this.selectedMap.clear();
8531
+ this.deselectedMap.clear();
8532
+ (_a = this.selectedRows) == null ? void 0 : _a.forEach(this._selectedMapSet);
8533
+ (_b = this.deselectedRows) == null ? void 0 : _b.forEach(this._deselectedMapSet);
8534
+ this.defaultSelection = stateObject.defaultSelection;
8535
+ this.xcache();
8536
+ }
8537
+ xcache() {
8538
+ this.selectionCache.clear();
8539
+ this.selectionCountCache.clear();
8328
8540
  }
8329
- makeAllNegative() {
8541
+ getState() {
8542
+ const normalize = (allKeys) => {
8543
+ const groupByLength = this.getGroupByLength();
8544
+ return allKeys.map((keys) => keys.length > groupByLength ? keys.pop() : keys);
8545
+ };
8546
+ const selectedRows = normalize(this.selectedMap.topDownKeys());
8547
+ const deselectedRows = normalize(this.deselectedMap.topDownKeys());
8548
+ return {
8549
+ defaultSelection: this.defaultSelection,
8550
+ selectedRows,
8551
+ deselectedRows
8552
+ };
8553
+ }
8554
+ deselectAll() {
8330
8555
  this.update({
8331
- negativeItems: true,
8332
- positiveItems: {}
8556
+ defaultSelection: false,
8557
+ selectedRows: [],
8558
+ deselectedRows: []
8333
8559
  });
8334
8560
  }
8335
- makeAllPositive() {
8561
+ selectAll() {
8336
8562
  this.update({
8337
- positiveItems: true,
8338
- negativeItems: {}
8563
+ defaultSelection: true,
8564
+ deselectedRows: [],
8565
+ selectedRows: []
8339
8566
  });
8340
8567
  }
8341
- isItemPositive(key) {
8342
- var _a, _b;
8343
- key = `${key}`;
8344
- if (this.allPositive === true) {
8345
- if (this.allNegative === true) {
8346
- throw 'Cannot have both positiveItems and negativeItems be "true"';
8347
- }
8348
- return !((_a = this.negativeMap) == null ? void 0 : _a.has(key));
8349
- }
8350
- return !!((_b = this.positiveMap) == null ? void 0 : _b.has(key));
8351
- }
8352
- isItemNegative(key) {
8353
- return !this.isItemPositive(key);
8568
+ isRowDefaultSelected() {
8569
+ return this.defaultSelection === true;
8354
8570
  }
8355
- setItemValue(key, shouldMakePositive) {
8356
- var _a;
8357
- key = `${key}`;
8358
- if (shouldMakePositive === this.isItemPositive(key)) {
8359
- return;
8571
+ isRowDefaultDeselected() {
8572
+ return this.defaultSelection === false;
8573
+ }
8574
+ isRowSelected(key, groupKeys) {
8575
+ groupKeys = groupKeys || this.getGroupKeysForPrimaryKey(key);
8576
+ const finalKey = [...groupKeys, key];
8577
+ const cachedResult = this.selectionCache.get(finalKey);
8578
+ if (cachedResult !== void 0) {
8579
+ return cachedResult;
8580
+ }
8581
+ const inSelected = this.selectedMap.has(finalKey);
8582
+ const inDeselected = this.deselectedMap.has(finalKey);
8583
+ if (inSelected) {
8584
+ this.selectionCache.set(finalKey, true);
8585
+ return true;
8360
8586
  }
8361
- if (shouldMakePositive) {
8362
- if (this.allNegative === true) {
8363
- if (!this.positiveMap) {
8364
- throw `No positiveMap found when trying to set item ${key} be positive`;
8365
- }
8366
- this.positiveMap.set(key, true);
8367
- } else if (this.allPositive === true) {
8368
- if (!this.negativeMap) {
8369
- throw `No negativeMap found when trying to set item ${key} be positive`;
8370
- }
8371
- this.negativeMap.delete(key);
8587
+ if (inDeselected) {
8588
+ this.selectionCache.set(finalKey, false);
8589
+ return false;
8590
+ }
8591
+ if (this.selectedMap.has(groupKeys)) {
8592
+ this.selectionCache.set(finalKey, true);
8593
+ return true;
8594
+ }
8595
+ if (this.deselectedMap.has(groupKeys)) {
8596
+ this.selectionCache.set(finalKey, false);
8597
+ return false;
8598
+ }
8599
+ groupKeys = [...groupKeys];
8600
+ while (groupKeys.length) {
8601
+ groupKeys.pop();
8602
+ const inSelected2 = this.selectedMap.has(groupKeys);
8603
+ const inDeselected2 = this.deselectedMap.has(groupKeys);
8604
+ if (inSelected2) {
8605
+ this.selectionCache.set(finalKey, true);
8606
+ return true;
8372
8607
  }
8373
- } else {
8374
- if (this.allPositive === true) {
8375
- if (!this.negativeMap) {
8376
- throw `No negativeMap found when trying to set item ${key} be negative`;
8377
- }
8378
- this.negativeMap.set(key, true);
8379
- } else if (this.allNegative === true) {
8380
- if (!this.positiveMap) {
8381
- throw `No positiveMap found when trying to set item ${key} be negative`;
8382
- }
8383
- (_a = this.positiveMap) == null ? void 0 : _a.delete(key);
8608
+ if (inDeselected2) {
8609
+ this.selectionCache.set(finalKey, false);
8610
+ return false;
8384
8611
  }
8385
8612
  }
8613
+ this.selectionCache.set(finalKey, this.defaultSelection);
8614
+ return this.defaultSelection;
8386
8615
  }
8387
- makeItemNegative(key) {
8388
- this.setItemValue(key, false);
8389
- }
8390
- makeItemPositive(key) {
8391
- this.setItemValue(key, true);
8392
- }
8393
- toggleItem(key) {
8394
- this.setItemValue(key, !this.isItemPositive(key));
8616
+ isRowDeselected(key, groupKeys) {
8617
+ return !this.isRowSelected(key, groupKeys);
8395
8618
  }
8396
- };
8397
-
8398
- // src/components/DataSource/RowSelectionState.ts
8399
- function reduceKeysToRecord(acc, key) {
8400
- acc[key] = true;
8401
- return acc;
8402
- }
8403
- var RowSelectionState = class extends BooleanCollectionState {
8404
- constructor(state) {
8405
- super(state);
8619
+ setRowSelected(key, selected, groupKeys) {
8620
+ if (selected) {
8621
+ this.setRowAsSelected(key, groupKeys);
8622
+ } else {
8623
+ this.setRowAsDeselected(key, groupKeys);
8624
+ }
8406
8625
  }
8407
- getState() {
8408
- var _a, _b, _c, _d;
8409
- return {
8410
- selectedRows: this.allPositive ? true : (_b = [...((_a = this.positiveMap) == null ? void 0 : _a.keys()) || []].reduce(reduceKeysToRecord, {})) != null ? _b : {},
8411
- deselectedRows: this.allNegative ? true : (_d = [...((_c = this.negativeMap) == null ? void 0 : _c.keys()) || []].reduce(reduceKeysToRecord, {})) != null ? _d : {}
8412
- };
8626
+ getGroupRowSelectionState(initialGroupKeys) {
8627
+ const cachedResult = this.selectionCache.get(initialGroupKeys);
8628
+ if (cachedResult !== void 0) {
8629
+ return cachedResult;
8630
+ }
8631
+ const { selectedCount, deselectedCount } = this.getSelectionCountFor(initialGroupKeys, this.getGroupRowBooleanSelectionStateFromParent(initialGroupKeys));
8632
+ const result = selectedCount && deselectedCount ? null : selectedCount ? true : false;
8633
+ this.selectionCache.set(initialGroupKeys, result);
8634
+ return result;
8413
8635
  }
8414
- getPositiveFromState(state) {
8415
- return state.selectedRows;
8636
+ getGroupRowBooleanSelectionStateFromParent(initialGroupKeys) {
8637
+ if (!initialGroupKeys.length) {
8638
+ return this.defaultSelection;
8639
+ }
8640
+ const groupKeys = [...initialGroupKeys];
8641
+ const selfDeselected = this.deselectedMap.has(groupKeys);
8642
+ const selfSelected = this.selectedMap.has(groupKeys);
8643
+ let selectionState = selfSelected && !selfDeselected ? true : selfDeselected && !selfSelected ? false : void 0;
8644
+ if (selectionState === void 0) {
8645
+ while (groupKeys.length) {
8646
+ groupKeys.pop();
8647
+ if (this.deselectedMap.has(groupKeys)) {
8648
+ selectionState = false;
8649
+ break;
8650
+ }
8651
+ if (this.selectedMap.has(groupKeys)) {
8652
+ selectionState = true;
8653
+ break;
8654
+ }
8655
+ }
8656
+ }
8657
+ if (selectionState === void 0) {
8658
+ selectionState = this.defaultSelection;
8659
+ }
8660
+ return selectionState;
8416
8661
  }
8417
- getNegativeFromState(state) {
8418
- return state.deselectedRows;
8662
+ isGroupRowPartlySelected(groupKeys) {
8663
+ return this.getGroupRowSelectionState(groupKeys) === null;
8419
8664
  }
8420
- areAllSelected() {
8421
- return this.areAllPositive();
8665
+ isGroupRowSelected(groupKeys) {
8666
+ return this.getGroupRowSelectionState(groupKeys) === true;
8422
8667
  }
8423
- areAllDeselected() {
8424
- return this.areAllNegative();
8668
+ isGroupRowDeselected(groupKeys) {
8669
+ return this.getGroupRowSelectionState(groupKeys) === false;
8425
8670
  }
8426
- deselectAll() {
8427
- this.makeAllNegative();
8671
+ selectGroupRow(groupKeys) {
8672
+ const selectedKeys = this.selectedMap.getKeysStartingWith(groupKeys, true);
8673
+ selectedKeys.forEach((groupKeys2) => {
8674
+ this.selectedMap.delete(groupKeys2);
8675
+ });
8676
+ this._selectedMapSet(groupKeys);
8677
+ const deselectedKeys = this.deselectedMap.getKeysStartingWith(groupKeys);
8678
+ deselectedKeys.forEach((groupKeys2) => {
8679
+ this.deselectedMap.delete(groupKeys2);
8680
+ });
8428
8681
  }
8429
- selectAll() {
8430
- this.makeAllPositive();
8682
+ deselectGroupRow(groupKeys) {
8683
+ const deselectedKeys = this.deselectedMap.getKeysStartingWith(groupKeys, true);
8684
+ deselectedKeys.forEach((groupKeys2) => {
8685
+ this.deselectedMap.delete(groupKeys2);
8686
+ });
8687
+ this._deselectedMapSet(groupKeys);
8688
+ const selectedKeys = this.selectedMap.getKeysStartingWith(groupKeys);
8689
+ selectedKeys.forEach((groupKeys2) => {
8690
+ this.selectedMap.delete(groupKeys2);
8691
+ });
8431
8692
  }
8432
- isRowDefaultSelected() {
8433
- return this.isDefaultPositiveSelection();
8693
+ setRowAsSelected(key, groupKeys) {
8694
+ groupKeys = groupKeys || this.getGroupKeysForPrimaryKey(key);
8695
+ const finalKey = [...groupKeys, key];
8696
+ this.deselectedMap.delete(finalKey);
8697
+ this.xcache();
8698
+ if (this.getGroupRowSelectionState(groupKeys) !== true) {
8699
+ this._selectedMapSet(finalKey);
8700
+ if (this.getGroupRowSelectionState(groupKeys) === true) {
8701
+ this.selectGroupRow(groupKeys);
8702
+ }
8703
+ }
8434
8704
  }
8435
- isRowDefaultDeselected() {
8436
- return this.isDefaultNegativeSelection();
8705
+ setRowAsDeselected(key, groupKeys) {
8706
+ groupKeys = groupKeys || this.getGroupKeysForPrimaryKey(key);
8707
+ const finalKey = [...groupKeys, key];
8708
+ this.selectedMap.delete(finalKey);
8709
+ if (this.getGroupRowSelectionState(groupKeys) !== false) {
8710
+ this._deselectedMapSet(finalKey);
8711
+ if (this.getGroupRowSelectionState(groupKeys) === false) {
8712
+ this.deselectGroupRow(groupKeys);
8713
+ }
8714
+ }
8437
8715
  }
8438
- isRowSelected(key) {
8439
- return this.isItemPositive(key);
8716
+ deselectRow(key, groupKeys) {
8717
+ this.setRowSelected(key, false, groupKeys);
8440
8718
  }
8441
- isRowDeselected(key) {
8442
- return !this.isItemPositive(key);
8719
+ selectRow(key, groupKeys) {
8720
+ this.setRowSelected(key, true, groupKeys);
8443
8721
  }
8444
- setRowSelected(key, selected) {
8445
- return this.setItemValue(key, selected);
8722
+ toggleGroupRowSelection(groupKeys) {
8723
+ const groupRowSelectionState = this.getGroupRowSelectionState(groupKeys);
8724
+ if (groupRowSelectionState === true) {
8725
+ this.deselectGroupRow(groupKeys);
8726
+ } else {
8727
+ this.selectGroupRow(groupKeys);
8728
+ }
8446
8729
  }
8447
- deselectRow(key) {
8448
- this.setRowSelected(key, false);
8730
+ toggleRowSelection(key, groupKeys) {
8731
+ if (this.isRowSelected(key, groupKeys)) {
8732
+ this.deselectRow(key, groupKeys);
8733
+ } else {
8734
+ this.selectRow(key, groupKeys);
8735
+ }
8449
8736
  }
8450
- selectRow(key) {
8451
- this.setRowSelected(key, true);
8737
+ getSelectedCount() {
8738
+ return this.getSelectionCountFor([]).selectedCount;
8452
8739
  }
8453
- toggleRowSelection(key) {
8454
- this.toggleItem(key);
8740
+ getDeselectedCount() {
8741
+ return this.getSelectionCountFor([]).deselectedCount;
8455
8742
  }
8456
- getSelectedCount(maxCount) {
8743
+ getSelectionCountFor(groupKeys = [], parentSelected) {
8457
8744
  var _a, _b;
8458
- if (this.isRowDefaultSelected()) {
8459
- const unselectedCount = this.negativeMap ? this.negativeMap.size : 0;
8460
- return maxCount ? maxCount - unselectedCount : -unselectedCount;
8461
- }
8462
- return (_b = (_a = this.positiveMap) == null ? void 0 : _a.size) != null ? _b : 0;
8745
+ const cachedResult = this.selectionCountCache.get(groupKeys);
8746
+ if (cachedResult != null) {
8747
+ return cachedResult;
8748
+ }
8749
+ if (groupKeys.length > this.getGroupByLength()) {
8750
+ const result2 = this.isRowSelected(groupKeys) ? { selectedCount: 1, deselectedCount: 0 } : {
8751
+ selectedCount: 0,
8752
+ deselectedCount: 1
8753
+ };
8754
+ this.selectionCountCache.set(groupKeys, result2);
8755
+ return result2;
8756
+ }
8757
+ parentSelected = parentSelected != null ? parentSelected : this.getGroupRowBooleanSelectionStateFromParent(groupKeys);
8758
+ let allKeys = this.getGroupKeysDirectlyInsideGroup(groupKeys);
8759
+ if (groupKeys.length === this.getGroupByLength()) {
8760
+ const selectionState = this.selectedMap.has(groupKeys) ? true : this.deselectedMap.has(groupKeys) ? false : parentSelected;
8761
+ const totalCount = this.getGroupCount(groupKeys);
8762
+ let selectedCount2 = this.selectedMap.getKeysStartingWith(groupKeys, true, 1).length;
8763
+ let deselectedCount2 = this.deselectedMap.getKeysStartingWith(groupKeys, true, 1).length;
8764
+ const notSpecifiedCount = totalCount - (selectedCount2 + deselectedCount2);
8765
+ const result2 = {
8766
+ selectedCount: selectedCount2 + (selectionState ? notSpecifiedCount : 0),
8767
+ deselectedCount: deselectedCount2 + (selectionState ? 0 : notSpecifiedCount)
8768
+ };
8769
+ this.selectionCountCache.set(groupKeys, result2);
8770
+ return result2;
8771
+ }
8772
+ let selectedCount = 0;
8773
+ let deselectedCount = 0;
8774
+ if (this.getConfig().lazyLoad && !allKeys.length) {
8775
+ const totalChildrenCount = ((_b = (_a = this.getConfig().groupDeepMap) == null ? void 0 : _a.get(groupKeys)) == null ? void 0 : _b.totalChildrenCount) || 0;
8776
+ if (parentSelected) {
8777
+ selectedCount = totalChildrenCount;
8778
+ deselectedCount = this.deselectedMap.getAllChildrenSizeFor(groupKeys);
8779
+ if (deselectedCount === totalChildrenCount) {
8780
+ selectedCount = 0;
8781
+ }
8782
+ } else {
8783
+ deselectedCount = totalChildrenCount;
8784
+ selectedCount = this.selectedMap.getAllChildrenSizeFor(groupKeys);
8785
+ if (selectedCount === totalChildrenCount) {
8786
+ deselectedCount = 0;
8787
+ }
8788
+ }
8789
+ }
8790
+ allKeys.forEach((keys) => {
8791
+ let isSelected = this.selectedMap.get(keys);
8792
+ let isDeselected = this.deselectedMap.get(keys);
8793
+ const selected = isSelected ? true : isDeselected ? false : parentSelected;
8794
+ const { selectedCount: selCount, deselectedCount: deselCount } = this.getSelectionCountFor(keys, selected);
8795
+ selectedCount += selCount;
8796
+ deselectedCount += deselCount;
8797
+ });
8798
+ const result = {
8799
+ selectedCount,
8800
+ deselectedCount
8801
+ };
8802
+ this.selectionCountCache.set(groupKeys, result);
8803
+ return result;
8463
8804
  }
8464
8805
  };
8465
8806
 
8807
+ // src/components/InfiniteTable/api/getSelectionApi.ts
8808
+ function rowSelectionStateConfigGetter(stateOrStateGetter) {
8809
+ return () => {
8810
+ const state = typeof stateOrStateGetter === "function" ? stateOrStateGetter() : stateOrStateGetter;
8811
+ return {
8812
+ lazyLoad: !!state.lazyLoad,
8813
+ groupBy: state.groupBy,
8814
+ groupDeepMap: state.groupDeepMap,
8815
+ indexer: state.indexer,
8816
+ totalCount: state.unfilteredCount
8817
+ };
8818
+ };
8819
+ }
8820
+ function getSelectionApi(param) {
8821
+ const {
8822
+ getDataSourceState,
8823
+ dataSourceActions
8824
+ } = param;
8825
+ const selectionApi = {
8826
+ get allRowsSelected() {
8827
+ return getDataSourceState().allRowsSelected;
8828
+ },
8829
+ selectAll() {
8830
+ const { rowSelection, selectionMode } = getDataSourceState();
8831
+ if (selectionMode !== "multi-row") {
8832
+ throw "Selection mode is not multi-row";
8833
+ }
8834
+ if (!(rowSelection instanceof RowSelectionState)) {
8835
+ throw "Invalid row selection";
8836
+ }
8837
+ const rowSelectionState = new RowSelectionState(rowSelection, rowSelectionStateConfigGetter(getDataSourceState));
8838
+ rowSelectionState.selectAll();
8839
+ dataSourceActions.rowSelection = rowSelectionState;
8840
+ },
8841
+ deselectAll() {
8842
+ const { rowSelection, selectionMode } = getDataSourceState();
8843
+ if (selectionMode !== "multi-row") {
8844
+ throw "Selection mode is not multi-row";
8845
+ }
8846
+ if (!(rowSelection instanceof RowSelectionState)) {
8847
+ throw "Invalid row selection";
8848
+ }
8849
+ const rowSelectionState = new RowSelectionState(rowSelection, rowSelectionStateConfigGetter(getDataSourceState));
8850
+ rowSelectionState.deselectAll();
8851
+ dataSourceActions.rowSelection = rowSelectionState;
8852
+ },
8853
+ isRowSelected(pk, groupKeys) {
8854
+ const { rowSelection, selectionMode, indexer, groupBy } = getDataSourceState();
8855
+ if (selectionMode === "single-row") {
8856
+ return rowSelection === pk;
8857
+ }
8858
+ if (selectionMode !== "multi-row") {
8859
+ throw "Selection mode is not multi-row or single-row";
8860
+ }
8861
+ if (!(rowSelection instanceof RowSelectionState)) {
8862
+ throw "Invalid row selection";
8863
+ }
8864
+ if (!groupKeys) {
8865
+ const data = indexer.getDataForPrimaryKey(pk);
8866
+ groupKeys = data ? getGroupKeysForDataItem(data, groupBy) : [];
8867
+ }
8868
+ return rowSelection.isRowSelected(pk, groupKeys);
8869
+ },
8870
+ isRowDeselected(pk, groupKeys) {
8871
+ return !this.isRowSelected(pk, groupKeys);
8872
+ },
8873
+ selectRow(pk, groupKeys) {
8874
+ const { rowSelection, selectionMode, indexer, groupBy } = getDataSourceState();
8875
+ if (selectionMode === "single-row") {
8876
+ dataSourceActions.rowSelection = pk;
8877
+ return;
8878
+ }
8879
+ if (selectionMode !== "multi-row") {
8880
+ throw "Selection mode is not multi-row or single-row";
8881
+ }
8882
+ if (!(rowSelection instanceof RowSelectionState)) {
8883
+ throw "Invalid row selection";
8884
+ }
8885
+ if (!groupKeys) {
8886
+ const data = indexer.getDataForPrimaryKey(pk);
8887
+ groupKeys = data ? getGroupKeysForDataItem(data, groupBy) : [];
8888
+ }
8889
+ const rowSelectionState = new RowSelectionState(rowSelection, rowSelectionStateConfigGetter(getDataSourceState));
8890
+ rowSelectionState.selectRow(pk, groupKeys);
8891
+ dataSourceActions.rowSelection = rowSelectionState;
8892
+ },
8893
+ deselectRow(pk, groupKeys) {
8894
+ const { selectionMode, rowSelection, indexer, groupBy } = getDataSourceState();
8895
+ if (selectionMode === "single-row") {
8896
+ dataSourceActions.rowSelection = null;
8897
+ return;
8898
+ }
8899
+ if (selectionMode !== "multi-row") {
8900
+ throw "Selection mode is not multi-row or single-row";
8901
+ }
8902
+ if (!(rowSelection instanceof RowSelectionState)) {
8903
+ throw "Invalid row selection";
8904
+ }
8905
+ if (selectionMode === "multi-row") {
8906
+ if (!groupKeys) {
8907
+ const data = indexer.getDataForPrimaryKey(pk);
8908
+ groupKeys = data ? getGroupKeysForDataItem(data, groupBy) : [];
8909
+ }
8910
+ const rowSelectionState = new RowSelectionState(rowSelection, rowSelectionStateConfigGetter(getDataSourceState));
8911
+ rowSelectionState.deselectRow(pk, groupKeys);
8912
+ dataSourceActions.rowSelection = rowSelectionState;
8913
+ }
8914
+ },
8915
+ toggleRowSelection(pk, groupKeys) {
8916
+ if (this.isRowSelected(pk, groupKeys)) {
8917
+ this.deselectRow(pk, groupKeys);
8918
+ } else {
8919
+ this.selectRow(pk, groupKeys);
8920
+ }
8921
+ },
8922
+ selectGroupRow(groupKeys) {
8923
+ const { selectionMode, rowSelection, groupBy } = getDataSourceState();
8924
+ if (selectionMode !== "multi-row") {
8925
+ throw 'Selection mode should be "multi-row"';
8926
+ }
8927
+ if (!groupBy) {
8928
+ throw "No grouping specified";
8929
+ }
8930
+ if (!(rowSelection instanceof RowSelectionState)) {
8931
+ throw "Invalid row selection";
8932
+ }
8933
+ const rowSelectionState = new RowSelectionState(rowSelection, rowSelectionStateConfigGetter(getDataSourceState));
8934
+ rowSelectionState.selectGroupRow(groupKeys);
8935
+ dataSourceActions.rowSelection = rowSelectionState;
8936
+ },
8937
+ deselectGroupRow(groupKeys) {
8938
+ const { selectionMode, rowSelection, groupBy } = getDataSourceState();
8939
+ if (selectionMode !== "multi-row") {
8940
+ throw 'Selection mode should be "multi-row"';
8941
+ }
8942
+ if (!groupBy) {
8943
+ throw "No grouping specified";
8944
+ }
8945
+ if (!(rowSelection instanceof RowSelectionState)) {
8946
+ throw "Invalid row selection";
8947
+ }
8948
+ const rowSelectionState = new RowSelectionState(rowSelection, rowSelectionStateConfigGetter(getDataSourceState));
8949
+ rowSelectionState.deselectGroupRow(groupKeys);
8950
+ dataSourceActions.rowSelection = rowSelectionState;
8951
+ },
8952
+ toggleGroupRowSelection(groupKeys) {
8953
+ const { selectionMode, rowSelection, groupBy } = getDataSourceState();
8954
+ if (selectionMode !== "multi-row") {
8955
+ throw 'Selection mode should be "multi-row"';
8956
+ }
8957
+ if (!groupBy) {
8958
+ throw "No grouping specified";
8959
+ }
8960
+ if (!(rowSelection instanceof RowSelectionState)) {
8961
+ throw "Invalid row selection";
8962
+ }
8963
+ const rowSelectionState = new RowSelectionState(rowSelection, rowSelectionStateConfigGetter(getDataSourceState));
8964
+ rowSelectionState.toggleGroupRowSelection(groupKeys);
8965
+ dataSourceActions.rowSelection = rowSelectionState;
8966
+ },
8967
+ getGroupRowSelectionState(groupKeys) {
8968
+ const { selectionMode, rowSelection, groupBy } = getDataSourceState();
8969
+ if (selectionMode !== "multi-row") {
8970
+ throw 'Selection mode should be "multi-row"';
8971
+ }
8972
+ if (!groupBy) {
8973
+ throw "No grouping specified";
8974
+ }
8975
+ if (!(rowSelection instanceof RowSelectionState)) {
8976
+ throw "Invalid row selection";
8977
+ }
8978
+ return rowSelection.getGroupRowSelectionState(groupKeys);
8979
+ },
8980
+ getSelectedPrimaryKeys: () => {
8981
+ const selected = [];
8982
+ getDataSourceState().dataArray.forEach((rowInfo) => {
8983
+ if (!rowInfo.isGroupRow && rowInfo.rowSelected) {
8984
+ selected.push(rowInfo.id);
8985
+ }
8986
+ });
8987
+ return selected;
8988
+ }
8989
+ };
8990
+ if (false) {
8991
+ globalThis.selectionApi = selectionApi;
8992
+ }
8993
+ return selectionApi;
8994
+ }
8995
+
8466
8996
  // src/components/utils/discardCallsWithEqualArg.ts
8467
8997
  var map = new WeakMap();
8468
8998
  var getCompareDefault = (a) => a;
@@ -8494,22 +9024,23 @@ function discardCallsWithEqualArg(fn, timeframe = 50, getCompareObject) {
8494
9024
  // src/components/DataSource/Indexer.ts
8495
9025
  var Indexer = class {
8496
9026
  constructor() {
8497
- this.indexToPrimaryKey = new Map();
8498
- this.primaryKeyToIndex = new Map();
8499
- }
8500
- add(index, primaryKey) {
8501
- this.indexToPrimaryKey.set(index, primaryKey);
8502
- this.primaryKeyToIndex.set(`${primaryKey}`, index);
8503
- }
8504
- clear() {
8505
- this.indexToPrimaryKey.clear();
8506
- this.primaryKeyToIndex.clear();
8507
- }
8508
- getIndexOf(primaryKey) {
8509
- return this.primaryKeyToIndex.get(`${primaryKey}`);
8510
- }
8511
- getPrimaryKeyFor(index) {
8512
- return this.indexToPrimaryKey.get(index);
9027
+ this.primaryKeyToData = new Map();
9028
+ this.add = (primaryKey, data) => {
9029
+ this.primaryKeyToData.set(`${primaryKey}`, data);
9030
+ };
9031
+ this.clear = () => {
9032
+ this.primaryKeyToData.clear();
9033
+ };
9034
+ this.getDataForPrimaryKey = (primaryKey) => {
9035
+ return this.primaryKeyToData.get(`${primaryKey}`);
9036
+ };
9037
+ this.indexArray = (arr, toPrimaryKey) => {
9038
+ arr.forEach((item) => {
9039
+ if (item != null) {
9040
+ this.add(toPrimaryKey(item), item);
9041
+ }
9042
+ });
9043
+ };
8513
9044
  }
8514
9045
  };
8515
9046
 
@@ -8570,7 +9101,7 @@ function initSetupState() {
8570
9101
  groupDeepMap: void 0,
8571
9102
  reducerResults: void 0,
8572
9103
  allRowsSelected: false,
8573
- selectedRowCount: 0,
9104
+ someRowsSelected: false,
8574
9105
  postSortDataArray: void 0,
8575
9106
  postGroupDataArray: void 0,
8576
9107
  lastSortDataArray: void 0,
@@ -8626,8 +9157,8 @@ function getLivePaginationCursorValue(livePaginationCursorProp, state) {
8626
9157
  return livePaginationCursor;
8627
9158
  }
8628
9159
  function mapPropsToState(params) {
8629
- var _a, _b, _c;
8630
- const { props, state, oldState } = params;
9160
+ var _a, _b;
9161
+ const { props, state, oldState, getState } = params;
8631
9162
  const controlledSort = isControlledValue(props.sortInfo);
8632
9163
  const controlledFilter = isControlledValue(props.filterValue);
8633
9164
  const { filterTypes } = state;
@@ -8657,32 +9188,30 @@ function mapPropsToState(params) {
8657
9188
  }
8658
9189
  }
8659
9190
  let rowSelectionState = null;
8660
- let currentRowSelection = props.rowSelection !== void 0 ? props.rowSelection : (_b = state.rowSelection) != null ? _b : props.defaultRowSelection !== void 0 ? props.defaultRowSelection : null;
9191
+ let currentRowSelection = props.rowSelection !== void 0 ? props.rowSelection : state.rowSelection === void 0 ? props.defaultRowSelection !== void 0 ? props.defaultRowSelection : null : state.rowSelection;
8661
9192
  if (selectionMode !== false) {
8662
9193
  if (selectionMode === "single-row" || selectionMode === "multi-row") {
8663
9194
  if (currentRowSelection === null) {
8664
9195
  rowSelectionState = selectionMode === "single-row" ? null : new RowSelectionState({
8665
- selectedRows: {},
8666
- deselectedRows: true
8667
- });
9196
+ selectedRows: [],
9197
+ deselectedRows: [],
9198
+ defaultSelection: false
9199
+ }, rowSelectionStateConfigGetter(getState || state));
8668
9200
  } else {
8669
- rowSelectionState = selectionMode === "single-row" ? currentRowSelection : currentRowSelection instanceof RowSelectionState ? currentRowSelection : new RowSelectionState(currentRowSelection);
9201
+ rowSelectionState = selectionMode === "single-row" ? currentRowSelection : currentRowSelection instanceof RowSelectionState ? currentRowSelection : new RowSelectionState(currentRowSelection, rowSelectionStateConfigGetter(getState || state));
8670
9202
  }
8671
9203
  }
8672
9204
  }
8673
9205
  const primaryKeyDescriptor = state.primaryKey;
8674
- const toPrimaryKey = typeof primaryKeyDescriptor === "function" ? (data, index) => primaryKeyDescriptor({ data, index }) : (data, _index) => {
8675
- const pk = data[primaryKeyDescriptor];
8676
- return pk;
8677
- };
9206
+ const toPrimaryKey = typeof primaryKeyDescriptor === "function" ? (data) => primaryKeyDescriptor(data) : (data) => data[primaryKeyDescriptor];
8678
9207
  const result = {
8679
9208
  selectionMode,
9209
+ rowSelection: rowSelectionState,
8680
9210
  toPrimaryKey,
8681
- rowSelection: rowSelectionState != null ? rowSelectionState : null,
8682
9211
  operatorsByFilterType,
8683
9212
  controlledSort,
8684
9213
  controlledFilter,
8685
- filterMode: ((_c = props.filterMode) != null ? _c : props.filterFunction != null) ? "local" : typeof props.data === "function" ? "remote" : "local",
9214
+ filterMode: ((_b = props.filterMode) != null ? _b : props.filterFunction != null) ? "local" : typeof props.data === "function" ? "remote" : "local",
8686
9215
  multiSort: Array.isArray(controlledSort ? props.sortInfo : props.defaultSortInfo),
8687
9216
  lazyLoadBatchSize: typeof props.lazyLoad === "object" ? props.lazyLoad.batchSize : void 0
8688
9217
  };
@@ -8714,20 +9243,17 @@ function getMappedCallbacks() {
8714
9243
  rowSelection: (rowSelection, state) => {
8715
9244
  if (state.selectionMode === "single-row") {
8716
9245
  return {
8717
- callbackParam: {
8718
- selectionMode: "single-row",
8719
- rowSelection
8720
- }
9246
+ callbackParams: [
9247
+ rowSelection,
9248
+ "single-row"
9249
+ ]
8721
9250
  };
8722
9251
  }
8723
9252
  return {
8724
- callbackParam: {
8725
- selectionMode: "multi-row",
8726
- get rowSelection() {
8727
- return rowSelection.getState();
8728
- },
8729
- rowSelectionState: rowSelection
8730
- }
9253
+ callbackParams: [
9254
+ rowSelection.getState(),
9255
+ "multi-row"
9256
+ ]
8731
9257
  };
8732
9258
  }
8733
9259
  };
@@ -9079,16 +9605,16 @@ function filterDataSource(params) {
9079
9605
  return dataArray;
9080
9606
  }
9081
9607
  function concludeReducer(params) {
9082
- var _a, _b, _c, _d;
9608
+ var _a, _b;
9083
9609
  const { state, previousState } = params;
9084
- const primaryKeyDescriptor = state.primaryKey;
9085
9610
  const sortInfo = state.sortInfo;
9086
9611
  let shouldSort = !!(sortInfo == null ? void 0 : sortInfo.length) && !state.controlledSort;
9087
9612
  if (state.lazyLoad || state.livePagination) {
9088
9613
  shouldSort = false;
9089
9614
  }
9090
9615
  let originalDataArrayChanged = haveDepsChanged(previousState, state, [
9091
- "originalDataArray"
9616
+ "originalDataArray",
9617
+ "originalLazyGroupDataChangeDetect"
9092
9618
  ]);
9093
9619
  const dataSourceChange = previousState && state.data !== previousState.data;
9094
9620
  let lazyLoadGroupDataChange = state.lazyLoad && previousState && (previousState.groupBy !== state.groupBy || previousState.sortInfo !== state.sortInfo);
@@ -9099,6 +9625,13 @@ function concludeReducer(params) {
9099
9625
  state.originalLazyGroupData = new DeepMap();
9100
9626
  originalDataArrayChanged = true;
9101
9627
  }
9628
+ const shouldIndex = originalDataArrayChanged;
9629
+ if (shouldIndex) {
9630
+ state.indexer.clear();
9631
+ if (!state.lazyLoad) {
9632
+ state.indexer.indexArray(state.originalDataArray, state.toPrimaryKey);
9633
+ }
9634
+ }
9102
9635
  const { filterFunction, filterValue, filterTypes, operatorsByFilterType } = state;
9103
9636
  const shouldFilter = !!filterFunction || Array.isArray(filterValue) && filterValue.length;
9104
9637
  const shouldFilterClientSide = shouldFilter && state.filterMode === "local";
@@ -9117,7 +9650,8 @@ function concludeReducer(params) {
9117
9650
  const shouldGroup = groupBy.length > 0 || !!pivotBy;
9118
9651
  const selectionDepsChanged = haveDepsChanged(previousState, state, [
9119
9652
  "rowSelection",
9120
- "isRowSelected"
9653
+ "isRowSelected",
9654
+ "originalLazyGroupDataChangeDetect"
9121
9655
  ]);
9122
9656
  const groupsDepsChanged = originalDataArrayChanged || sortDepsChanged || haveDepsChanged(previousState, state, [
9123
9657
  "generateGroupRows",
@@ -9131,13 +9665,10 @@ function concludeReducer(params) {
9131
9665
  "pivotGrandTotalColumnPosition",
9132
9666
  "showSeparatePivotColumnForSingleAggregation"
9133
9667
  ]);
9134
- const shouldGroupAgain = shouldGroup && (groupsDepsChanged || !state.lastGroupDataArray) || selectionDepsChanged && state.selectionMode === "multi-row";
9668
+ const shouldGroupAgain = shouldGroup && (groupsDepsChanged || !state.lastGroupDataArray) || selectionDepsChanged;
9135
9669
  const now = Date.now();
9136
9670
  let dataArray = state.originalDataArray;
9137
- const toPrimaryKey = typeof primaryKeyDescriptor === "function" ? (data, index) => primaryKeyDescriptor({ data, index }) : (data, _index) => {
9138
- const pk = data[primaryKeyDescriptor];
9139
- return pk;
9140
- };
9671
+ const toPrimaryKey = state.toPrimaryKey;
9141
9672
  if (!shouldFilter) {
9142
9673
  state.unfilteredCount = dataArray.length;
9143
9674
  }
@@ -9167,60 +9698,47 @@ function concludeReducer(params) {
9167
9698
  }
9168
9699
  state.postSortDataArray = dataArray;
9169
9700
  let rowInfoDataArray = state.dataArray;
9701
+ const rowSelectionState = state.rowSelection instanceof RowSelectionState ? state.rowSelection : void 0;
9702
+ rowSelectionState == null ? void 0 : rowSelectionState.xcache();
9170
9703
  let isRowSelected = state.selectionMode === "single-row" ? (rowInfo) => {
9171
9704
  return rowInfo.id === state.rowSelection;
9172
9705
  } : state.selectionMode === "multi-row" ? (rowInfo) => {
9173
- return state.rowSelection.isRowSelected(rowInfo.id);
9706
+ const rowSelection = rowSelectionState;
9707
+ return rowInfo.isGroupRow ? rowSelection.getGroupRowSelectionState(rowInfo.groupKeys) : rowSelection.isRowSelected(rowInfo.id, rowInfo.dataSourceHasGrouping ? rowInfo.groupKeys : void 0);
9174
9708
  } : void 0;
9175
- if (state.isRowSelected) {
9176
- isRowSelected = (rowInfo) => state.isRowSelected(rowInfo, state.rowSelection, state.selectionMode) || false;
9709
+ if (state.isRowSelected && state.selectionMode === "multi-row") {
9710
+ isRowSelected = (rowInfo) => state.isRowSelected(rowInfo, rowSelectionState, state.selectionMode);
9177
9711
  }
9178
9712
  if (shouldGroup) {
9179
9713
  if (shouldGroupAgain) {
9180
9714
  let aggregationReducers = state.aggregationReducers;
9181
- if (state.selectionMode === "multi-row") {
9182
- const groupSelectedReducer = {
9183
- initialValue: true,
9184
- reducer: (groupSelected, _value, data, index) => {
9185
- const rowId = toPrimaryKey(data, index);
9186
- return groupSelected && state.rowSelection.isRowSelected(rowId);
9187
- }
9188
- };
9189
- const groupChildrenSelectedCountReducer = {
9190
- initialValue: 0,
9191
- reducer: (selectedCount, _value, data, index) => {
9192
- const rowId = toPrimaryKey(data, index);
9193
- return selectedCount + state.rowSelection.isRowSelected(rowId);
9194
- }
9195
- };
9196
- aggregationReducers = __spreadProps(__spreadValues({}, aggregationReducers), {
9197
- [GROUP_SELECTED_REDUCER_KEY]: groupSelectedReducer,
9198
- [GROUP_CHILDREN_SELECTED_COUNT_KEY]: groupChildrenSelectedCountReducer
9199
- });
9200
- }
9201
9715
  const groupResult = state.lazyLoad ? lazyGroup({
9202
9716
  groupBy,
9203
9717
  pivot: pivotBy,
9204
9718
  mappings: state.pivotMappings,
9205
- reducers: aggregationReducers
9719
+ reducers: aggregationReducers,
9720
+ indexer: state.indexer,
9721
+ toPrimaryKey
9206
9722
  }, state.originalLazyGroupData) : group({
9207
9723
  groupBy,
9208
9724
  pivot: pivotBy,
9209
9725
  reducers: aggregationReducers
9210
9726
  }, dataArray);
9211
- state.indexer.clear();
9727
+ state.groupDeepMap = groupResult.deepMap;
9728
+ if (rowSelectionState) {
9729
+ rowSelectionState.getConfig = rowSelectionStateConfigGetter(state);
9730
+ }
9212
9731
  const flattenResult = enhancedFlatten({
9213
9732
  groupResult,
9214
9733
  lazyLoad: !!state.lazyLoad,
9215
9734
  reducers: aggregationReducers,
9216
9735
  toPrimaryKey,
9217
9736
  isRowSelected,
9218
- indexer: state.indexer,
9737
+ rowSelectionState,
9219
9738
  groupRowsState: state.groupRowsState,
9220
9739
  generateGroupRows: state.generateGroupRows
9221
9740
  });
9222
9741
  rowInfoDataArray = flattenResult.data;
9223
- state.groupDeepMap = groupResult.deepMap;
9224
9742
  state.reducerResults = groupResult.reducerResults;
9225
9743
  const pivotGroupsAndCols = pivotBy ? getPivotColumnsAndColumnGroups({
9226
9744
  deepMap: groupResult.topLevelPivotColumns,
@@ -9242,10 +9760,8 @@ function concludeReducer(params) {
9242
9760
  state.pivotColumns = void 0;
9243
9761
  const arrayDifferentAfterSortStep = previousState.postSortDataArray != state.postSortDataArray;
9244
9762
  if (arrayDifferentAfterSortStep || groupsDepsChanged || selectionDepsChanged) {
9245
- state.indexer.clear();
9246
9763
  rowInfoDataArray = dataArray.map((data, index) => {
9247
- const rowInfo = toRowInfo(data, data ? toPrimaryKey(data, index) : index, index, isRowSelected);
9248
- state.indexer.add(index, rowInfo.id);
9764
+ const rowInfo = toRowInfo(data, data ? toPrimaryKey(data) : index, index, isRowSelected);
9249
9765
  return rowInfo;
9250
9766
  });
9251
9767
  }
@@ -9257,13 +9773,27 @@ function concludeReducer(params) {
9257
9773
  state.dataArray = rowInfoDataArray;
9258
9774
  state.reducedAt = now;
9259
9775
  if (state.selectionMode === "multi-row") {
9260
- if (shouldGroup) {
9261
- state.allRowsSelected = ((_c = state.reducerResults) == null ? void 0 : _c[GROUP_SELECTED_REDUCER_KEY]) || false;
9262
- state.selectedRowCount = ((_d = state.reducerResults) == null ? void 0 : _d[GROUP_CHILDREN_SELECTED_COUNT_KEY]) || 0;
9776
+ if (shouldGroup && state.lazyLoad) {
9777
+ let allRowsSelected = true;
9778
+ let someRowsSelected = false;
9779
+ state.dataArray.forEach((rowInfo) => {
9780
+ if (rowInfo.isGroupRow && rowInfo.groupKeys.length === 1) {
9781
+ const { rowSelected } = rowInfo;
9782
+ if (rowSelected !== true) {
9783
+ allRowsSelected = false;
9784
+ }
9785
+ if (rowSelected === true || rowSelected === null) {
9786
+ someRowsSelected = true;
9787
+ }
9788
+ }
9789
+ });
9790
+ state.allRowsSelected = allRowsSelected;
9791
+ state.someRowsSelected = someRowsSelected;
9263
9792
  } else {
9264
- const dataArrayCount = state.dataArray.length;
9265
- state.selectedRowCount = state.rowSelection.getSelectedCount(dataArrayCount);
9266
- state.allRowsSelected = dataArrayCount === state.selectedRowCount;
9793
+ const dataArrayCount = state.filteredCount;
9794
+ const selectedRowCount = state.rowSelection.getSelectedCount();
9795
+ state.allRowsSelected = dataArrayCount === selectedRowCount;
9796
+ state.someRowsSelected = selectedRowCount > 0;
9267
9797
  }
9268
9798
  }
9269
9799
  if (false) {
@@ -9307,6 +9837,7 @@ function DataSourceCmp({ children }) {
9307
9837
  };
9308
9838
  if (false) {
9309
9839
  globalThis.getDataSourceState = getState;
9840
+ globalThis.dataSourceActions = componentActions;
9310
9841
  }
9311
9842
  useLoadData();
9312
9843
  return /* @__PURE__ */ createElement30(DataSourceContext.Provider, {
@@ -9321,114 +9852,42 @@ function DataSource(props) {
9321
9852
  }));
9322
9853
  }
9323
9854
 
9324
- // src/components/InfiniteTable/getImperativeApi.ts
9325
- function getImperativeApi(getComputed, getState, getDataSourceState, componentActions, dataSourceActions) {
9326
- function setGroupRowSelection(groupKeys, selected) {
9327
- const {
9328
- selectionMode,
9329
- rowSelection: currentRowSelection,
9330
- groupDeepMap,
9331
- toPrimaryKey
9332
- } = getDataSourceState();
9333
- if (selectionMode === "multi-row" && groupDeepMap) {
9334
- const rowSelectionState = new RowSelectionState(currentRowSelection);
9335
- const groupResult = groupDeepMap.get(groupKeys);
9336
- if (groupResult == null ? void 0 : groupResult.items) {
9337
- groupResult.items.forEach((data) => {
9338
- const id = toPrimaryKey(data);
9339
- if (selected) {
9340
- rowSelectionState.selectRow(id);
9341
- } else {
9342
- rowSelectionState.deselectRow(id);
9343
- }
9344
- });
9345
- dataSourceActions.rowSelection = rowSelectionState;
9346
- return true;
9347
- }
9348
- }
9349
- return false;
9350
- }
9855
+ // src/components/InfiniteTable/api/getImperativeApi.ts
9856
+ function getImperativeApi(param) {
9857
+ const {
9858
+ getComputed,
9859
+ getState,
9860
+ getDataSourceState,
9861
+ componentActions,
9862
+ dataSourceActions
9863
+ } = param;
9864
+ const selectionApi = getSelectionApi({
9865
+ dataSourceActions,
9866
+ getDataSourceState
9867
+ });
9351
9868
  const imperativeApi = {
9352
- get allRowsSelected() {
9353
- return getDataSourceState().allRowsSelected;
9354
- },
9355
- getSelectedRowCount() {
9356
- const { selectionMode, selectedRowCount } = getDataSourceState();
9357
- if (selectionMode != "multi-row") {
9358
- throw `Cannot get the selected row count unless "selectionMode" is "multi-row"!`;
9359
- }
9360
- return selectedRowCount;
9361
- },
9362
- getSelectedRows() {
9363
- const { rowSelection, indexer, dataArray } = getDataSourceState();
9364
- if (!rowSelection || !(rowSelection instanceof RowSelectionState)) {
9365
- return [];
9366
- }
9367
- if (rowSelection.isRowDefaultDeselected()) {
9368
- const { selectedRows } = rowSelection.getState();
9369
- return Object.keys(selectedRows).reduce((res, id) => {
9370
- const index = indexer.getIndexOf(id);
9371
- if (index == null) {
9372
- return res;
9373
- }
9374
- const rowInfo = dataArray[index];
9375
- if (!rowInfo || !rowInfo.data) {
9376
- return res;
9377
- }
9378
- res.push(rowInfo.data);
9379
- return res;
9380
- }, []);
9381
- } else {
9382
- return dataArray.filter((rowInfo) => {
9383
- return !rowInfo.isGroupRow && rowSelection.isRowSelected(rowInfo.id);
9384
- }).map((rowInfo) => rowInfo.data);
9385
- }
9386
- return [];
9869
+ get selectionApi() {
9870
+ return selectionApi;
9387
9871
  },
9388
9872
  setColumnOrder: (columnOrder) => {
9389
9873
  componentActions.columnOrder = columnOrder;
9390
9874
  },
9391
- selectRow: (pk) => {
9392
- const { selectionMode, rowSelection: currentRowSelection } = getDataSourceState();
9393
- if (selectionMode === "multi-row") {
9394
- const rowSelectionState = new RowSelectionState(currentRowSelection);
9395
- rowSelectionState.selectRow(pk);
9396
- dataSourceActions.rowSelection = rowSelectionState;
9875
+ collapseGroupRow(groupKeys) {
9876
+ const state = getDataSourceState();
9877
+ if (state.groupRowsState.isGroupRowExpanded(groupKeys)) {
9878
+ this.toggleGroupRow(groupKeys);
9397
9879
  return true;
9398
- } else if (selectionMode === "single-row") {
9399
- dataSourceActions.rowSelection = pk;
9400
- return false;
9401
9880
  }
9402
9881
  return false;
9403
9882
  },
9404
- deselectRow: (pk) => {
9405
- const { selectionMode, rowSelection: currentRowSelection } = getDataSourceState();
9406
- if (selectionMode === "multi-row") {
9407
- const rowSelectionState = new RowSelectionState(currentRowSelection);
9408
- rowSelectionState.deselectRow(pk);
9409
- dataSourceActions.rowSelection = rowSelectionState;
9410
- return true;
9411
- } else if (selectionMode === "single-row") {
9412
- dataSourceActions.rowSelection = null;
9883
+ expandGroupRow(groupKeys) {
9884
+ const state = getDataSourceState();
9885
+ if (state.groupRowsState.isGroupRowCollapsed(groupKeys)) {
9886
+ this.toggleGroupRow(groupKeys);
9413
9887
  return true;
9414
9888
  }
9415
9889
  return false;
9416
9890
  },
9417
- isRowSelected: (pk) => {
9418
- const { selectionMode, rowSelection } = getDataSourceState();
9419
- if (selectionMode === "multi-row") {
9420
- return rowSelection.isRowSelected(pk);
9421
- } else if (selectionMode === "single-row") {
9422
- return rowSelection === pk;
9423
- }
9424
- return false;
9425
- },
9426
- selectGroupRow: (groupKeys) => {
9427
- return setGroupRowSelection(groupKeys, true);
9428
- },
9429
- deselectGroupRow: (groupKeys) => {
9430
- return setGroupRowSelection(groupKeys, false);
9431
- },
9432
9891
  toggleGroupRow(groupKeys) {
9433
9892
  const state = getDataSourceState();
9434
9893
  const newState = new GroupRowsState(state.groupRowsState);
@@ -9456,64 +9915,6 @@ function getImperativeApi(getComputed, getState, getDataSourceState, componentAc
9456
9915
  }
9457
9916
  }
9458
9917
  },
9459
- isGroupRowSelected: (groupKeys) => {
9460
- const { selectionMode } = getDataSourceState();
9461
- if (selectionMode === "multi-row") {
9462
- const primaryKey = `${groupKeys}`;
9463
- const index = getDataSourceState().indexer.getIndexOf(primaryKey);
9464
- if (index != null) {
9465
- const rowInfo = getDataSourceState().dataArray[index];
9466
- return rowInfo.rowSelected;
9467
- }
9468
- }
9469
- return false;
9470
- },
9471
- toggleGroupRowSelection(groupKeys) {
9472
- const { selectionMode } = getDataSourceState();
9473
- if (selectionMode === "multi-row") {
9474
- if (this.isGroupRowSelected(groupKeys)) {
9475
- this.deselectGroupRow(groupKeys);
9476
- } else {
9477
- this.selectGroupRow(groupKeys);
9478
- }
9479
- return true;
9480
- }
9481
- return false;
9482
- },
9483
- toggleRowSelection: (pk) => {
9484
- const { selectionMode, rowSelection: currentRowSelection } = getDataSourceState();
9485
- if (selectionMode === "multi-row") {
9486
- const rowSelectionState = new RowSelectionState(currentRowSelection);
9487
- rowSelectionState.toggleRowSelection(pk);
9488
- dataSourceActions.rowSelection = rowSelectionState;
9489
- return true;
9490
- } else if (selectionMode === "single-row") {
9491
- const rowSelection = currentRowSelection === pk ? null : pk;
9492
- dataSourceActions.rowSelection = rowSelection;
9493
- return true;
9494
- }
9495
- return false;
9496
- },
9497
- selectAllRows: () => {
9498
- const { selectionMode, rowSelection: currentRowSelection } = getDataSourceState();
9499
- if (selectionMode === "multi-row") {
9500
- const rowSelectionState = new RowSelectionState(currentRowSelection);
9501
- rowSelectionState.selectAll();
9502
- dataSourceActions.rowSelection = rowSelectionState;
9503
- return true;
9504
- }
9505
- return false;
9506
- },
9507
- deselectAllRows: () => {
9508
- const { selectionMode, rowSelection: currentRowSelection } = getDataSourceState();
9509
- if (selectionMode === "multi-row") {
9510
- const rowSelectionState = new RowSelectionState(currentRowSelection);
9511
- rowSelectionState.deselectAll();
9512
- dataSourceActions.rowSelection = rowSelectionState;
9513
- return true;
9514
- }
9515
- return false;
9516
- },
9517
9918
  setColumnVisibility: (columnVisibility) => {
9518
9919
  componentActions.columnVisibility = columnVisibility;
9519
9920
  },
@@ -9788,6 +10189,7 @@ function useCellRendering(param) {
9788
10189
  computedPinnedStartColumns,
9789
10190
  computedPinnedEndColumns,
9790
10191
  computedVisibleColumns,
10192
+ computedVisibleColumnsMap,
9791
10193
  rowspan,
9792
10194
  toggleGroupRow,
9793
10195
  columnSize
@@ -9891,6 +10293,7 @@ function useCellRendering(param) {
9891
10293
  domRef,
9892
10294
  width,
9893
10295
  column,
10296
+ columnsMap: computedVisibleColumnsMap,
9894
10297
  rowStyle,
9895
10298
  rowClassName
9896
10299
  };
@@ -9899,6 +10302,7 @@ function useCellRendering(param) {
9899
10302
  rowHeight,
9900
10303
  getData,
9901
10304
  computedVisibleColumns,
10305
+ computedVisibleColumnsMap,
9902
10306
  groupRenderStrategy,
9903
10307
  toggleGroupRow,
9904
10308
  showZebraRows,
@@ -9914,47 +10318,117 @@ function useCellRendering(param) {
9914
10318
  // src/components/InfiniteTable/hooks/useComputed.ts
9915
10319
  import { useCallback as useCallback17, useEffect as useEffect26, useState as useState14 } from "react";
9916
10320
 
9917
- // src/components/InfiniteTable/hooks/useColumnGroups.ts
9918
- import { useEffect as useEffect20 } from "react";
9919
-
9920
- // src/components/hooks/useInterceptedMap.ts
9921
- import { useEffect as useEffect19 } from "react";
9922
- function interceptMap(map2, fns) {
9923
- const { set, delete: deleteKey, clear } = map2;
9924
- if (fns.set) {
9925
- map2.set = (key, value) => {
9926
- set.call(map2, key, value);
9927
- fns.set(key, value);
9928
- return map2;
9929
- };
10321
+ // src/components/InfiniteTable/utils/MultiRowSelector.ts
10322
+ function ensureMinMax(start, end) {
10323
+ return start < end ? [start, end] : [end, start];
10324
+ }
10325
+ var MultiRowSelector = class {
10326
+ constructor(options) {
10327
+ this.multiSelectStartIndex = 0;
10328
+ this.getIdForIndex = options.getIdForIndex;
9930
10329
  }
9931
- if (fns.delete) {
9932
- map2.delete = (key) => {
9933
- const removed = deleteKey.call(map2, key);
9934
- fns.delete(key);
9935
- return removed;
9936
- };
10330
+ set rowSelectionState(rowSelectionState) {
10331
+ this._rowSelectionState = rowSelectionState;
9937
10332
  }
9938
- if (fns.clear || fns.beforeClear) {
9939
- map2.clear = () => {
9940
- if (fns.beforeClear) {
9941
- fns.beforeClear(map2);
9942
- }
9943
- const result = clear.call(map2);
9944
- if (fns.clear) {
9945
- fns.clear();
9946
- }
9947
- return result;
9948
- };
10333
+ get rowSelectionState() {
10334
+ return this._rowSelectionState;
9949
10335
  }
9950
- return () => {
9951
- if (set) {
9952
- map2.set = set;
9953
- }
9954
- if (deleteKey) {
9955
- map2.delete = deleteKey;
10336
+ selectRange(startIndex, endIndex) {
10337
+ const [start, end] = ensureMinMax(startIndex, endIndex);
10338
+ const rowSelectionState = this.rowSelectionState;
10339
+ for (let i = start; i <= end; i++) {
10340
+ const id = this.getIdForIndex(i);
10341
+ rowSelectionState.selectRow(id);
9956
10342
  }
9957
- if (clear) {
10343
+ }
10344
+ deselectRange(startIndex, endIndex) {
10345
+ const [start, end] = ensureMinMax(startIndex, endIndex);
10346
+ const rowSelectionState = this.rowSelectionState;
10347
+ for (let i = start; i <= end; i++) {
10348
+ const id = this.getIdForIndex(i);
10349
+ rowSelectionState.deselectRow(id);
10350
+ }
10351
+ }
10352
+ resetClick(index) {
10353
+ this.rowSelectionState.deselectAll();
10354
+ const id = this.getIdForIndex(index);
10355
+ this.rowSelectionState.selectRow(id);
10356
+ this.multiSelectStartIndex = index;
10357
+ this.multiSelectEndIndex = void 0;
10358
+ }
10359
+ singleAddClick(index) {
10360
+ const id = this.getIdForIndex(index);
10361
+ if (this.rowSelectionState.isRowSelected(id)) {
10362
+ this.rowSelectionState.deselectRow(id);
10363
+ if (this.rowSelectionState.isRowSelected(this.getIdForIndex(index + 1))) {
10364
+ this.multiSelectStartIndex = index + 1;
10365
+ } else {
10366
+ }
10367
+ } else {
10368
+ this.rowSelectionState.selectRow(id);
10369
+ this.multiSelectStartIndex = index;
10370
+ let multiSelectEndIndex = void 0;
10371
+ for (let i = index - 1; i >= 0; i--) {
10372
+ const id2 = this.getIdForIndex(i);
10373
+ if (this.rowSelectionState.isRowSelected(id2)) {
10374
+ multiSelectEndIndex = i;
10375
+ } else {
10376
+ break;
10377
+ }
10378
+ }
10379
+ this.multiSelectEndIndex = multiSelectEndIndex;
10380
+ }
10381
+ }
10382
+ multiSelectClick(index) {
10383
+ if (this.multiSelectEndIndex != null) {
10384
+ this.deselectRange(this.multiSelectStartIndex, this.multiSelectEndIndex);
10385
+ }
10386
+ this.selectRange(this.multiSelectStartIndex, index);
10387
+ this.multiSelectEndIndex = index;
10388
+ }
10389
+ };
10390
+
10391
+ // src/components/InfiniteTable/hooks/useColumnGroups.ts
10392
+ import { useEffect as useEffect20 } from "react";
10393
+
10394
+ // src/components/hooks/useInterceptedMap.ts
10395
+ import { useEffect as useEffect19 } from "react";
10396
+ function interceptMap(map2, fns) {
10397
+ const { set, delete: deleteKey, clear } = map2;
10398
+ if (fns.set) {
10399
+ map2.set = (key, value) => {
10400
+ set.call(map2, key, value);
10401
+ fns.set(key, value);
10402
+ return map2;
10403
+ };
10404
+ }
10405
+ if (fns.delete) {
10406
+ map2.delete = (key) => {
10407
+ const removed = deleteKey.call(map2, key);
10408
+ fns.delete(key);
10409
+ return removed;
10410
+ };
10411
+ }
10412
+ if (fns.clear || fns.beforeClear) {
10413
+ map2.clear = () => {
10414
+ if (fns.beforeClear) {
10415
+ fns.beforeClear(map2);
10416
+ }
10417
+ const result = clear.call(map2);
10418
+ if (fns.clear) {
10419
+ fns.clear();
10420
+ }
10421
+ return result;
10422
+ };
10423
+ }
10424
+ return () => {
10425
+ if (set) {
10426
+ map2.set = set;
10427
+ }
10428
+ if (deleteKey) {
10429
+ map2.delete = deleteKey;
10430
+ }
10431
+ if (clear) {
9958
10432
  map2.clear = clear;
9959
10433
  }
9960
10434
  };
@@ -10105,13 +10579,13 @@ import { useState as useState12 } from "react";
10105
10579
 
10106
10580
  // src/components/InfiniteTable/components/icons/ExpanderIcon.css.ts
10107
10581
  var import_createRuntimeFn6 = __toModule(require_vanilla_extract_recipes_createRuntimeFn_cjs());
10108
- var ExpanderIconCls = "_16lm1iw6 _16lm1iwh _16lm1iwd";
10109
- var ExpanderIconClsVariants = (0, import_createRuntimeFn6.createRuntimeFn)({ defaultClassName: "", variantClassNames: { expanded: { true: "_16lm1iwc", false: "_198z9782" } }, defaultVariants: {}, compoundVariants: [] });
10582
+ var ExpanderIconCls = "_16lm1iw6 _16lm1iwi _16lm1iwe";
10583
+ var ExpanderIconClsVariants = (0, import_createRuntimeFn6.createRuntimeFn)({ defaultClassName: "", variantClassNames: { expanded: { true: "_16lm1iwc", false: "_198z9782" }, direction: { end: "_198z9783", start: "_198z9784" } }, defaultVariants: {}, compoundVariants: [[{ expanded: false, direction: "end" }, "_16lm1iwd"]] });
10110
10584
 
10111
10585
  // src/components/InfiniteTable/components/icons/ExpanderIcon.tsx
10112
10586
  function ExpanderIcon(props) {
10113
10587
  var _a;
10114
- const { size = 24 } = props;
10588
+ const { size = 24, direction = "start" } = props;
10115
10589
  const [expanded, setExpanded] = useState12((_a = props.expanded) != null ? _a : props.defaultExpanded);
10116
10590
  const onClick = () => {
10117
10591
  var _a2;
@@ -10134,8 +10608,9 @@ function ExpanderIcon(props) {
10134
10608
  style: props.style,
10135
10609
  onClick,
10136
10610
  className: join(props.className, ExpanderIconCls, ExpanderIconClsVariants({
10611
+ direction: direction || "start",
10137
10612
  expanded
10138
- }), "InfiniteIcon", "InfiniteIcon-expander", `InfiniteIcon-expander--${expanded ? "expanded" : "collapsed"}`)
10613
+ }), "InfiniteIcon", "InfiniteIcon-expander", `InfiniteIcon-expander--${expanded ? "expanded" : "collapsed"}`, `InfiniteIcon-expander--${direction === "end" ? "end" : "start"}`)
10139
10614
  }, /* @__PURE__ */ createElement32("path", {
10140
10615
  d: "M8.59 16.59L13.17 12 8.59 7.41 10 6l6 6-6 6-1.41-1.41z"
10141
10616
  }));
@@ -10147,7 +10622,7 @@ import {
10147
10622
  } from "react";
10148
10623
 
10149
10624
  // src/components/InfiniteTable/components/icons/LoadingIcon.css.ts
10150
- var LoadingIconCls = "_16lm1iw8 _16lm1iwh _16lm1iwd";
10625
+ var LoadingIconCls = "_16lm1iw8 _16lm1iwi _16lm1iwe";
10151
10626
 
10152
10627
  // src/components/InfiniteTable/components/icons/LoadingIcon.tsx
10153
10628
  var LoadingIcon = (props) => {
@@ -10193,7 +10668,7 @@ function getGroupColumnRender({
10193
10668
  groupRenderStrategy
10194
10669
  }) {
10195
10670
  return (renderOptions) => {
10196
- const { rowInfo, renderBag } = renderOptions;
10671
+ const { rowInfo, renderBag, column } = renderOptions;
10197
10672
  let { value: valueToRender, groupIcon, selectionCheckBox } = renderBag;
10198
10673
  const groupRowInfo = rowInfo;
10199
10674
  if (groupRenderStrategy === "multi-column") {
@@ -10203,7 +10678,7 @@ function getGroupColumnRender({
10203
10678
  } else if (groupRenderStrategy === "single-column" && !groupRowInfo.isGroupRow) {
10204
10679
  }
10205
10680
  return /* @__PURE__ */ createElement34("div", {
10206
- className: join(display.flex, alignItems.center, groupRenderStrategy === "single-column" || groupRenderStrategy === "multi-column" && !rowInfo.isGroupRow && selectionCheckBox ? GroupRowExpanderCls : null)
10681
+ className: join(display.flex, column.align === "end" ? flexFlow.rowReverse : flexFlow.row, alignItems.center, groupRenderStrategy === "single-column" || groupRenderStrategy === "multi-column" && !rowInfo.isGroupRow && selectionCheckBox ? GroupRowExpanderCls({ align: column.align || "start" }) : null)
10207
10682
  }, groupIcon, selectionCheckBox, /* @__PURE__ */ createElement34("div", {
10208
10683
  className: cssEllipsisClassName
10209
10684
  }, valueToRender != null ? valueToRender : null));
@@ -10217,7 +10692,7 @@ function getGroupColumnRenderGroupIcon({
10217
10692
  }) {
10218
10693
  return (renderOptions) => {
10219
10694
  var _a, _b, _c;
10220
- const { rowInfo, value, groupBy, pivotBy } = renderOptions;
10695
+ const { rowInfo, value, groupBy, pivotBy, column } = renderOptions;
10221
10696
  const groupRowInfo = groupRenderStrategy !== "inline" ? rowInfo : rowInfo.isGroupRow && ((_a = rowInfo.parents) == null ? void 0 : _a[groupIndexForColumn]) || rowInfo;
10222
10697
  if (!groupRowInfo) {
10223
10698
  return null;
@@ -10249,6 +10724,7 @@ function getGroupColumnRenderGroupIcon({
10249
10724
  } else if (showExpanderIcon) {
10250
10725
  const defaultIcon = /* @__PURE__ */ createElement34(ExpanderIcon, {
10251
10726
  expanded: !collapsed,
10727
+ direction: column.align === "end" ? "end" : "start",
10252
10728
  onChange: () => {
10253
10729
  toggleGroupRow(groupKeys);
10254
10730
  }
@@ -11128,7 +11604,10 @@ var getComputedVisibleColumns = ({
11128
11604
  computedVisibleColumns,
11129
11605
  computedVisibleColumnsMap,
11130
11606
  computedPinnedEndWidth,
11131
- computedPinnedStartWidth
11607
+ computedPinnedStartWidth,
11608
+ renderSelectionCheckBox: computedVisibleColumns.reduce((bool, c) => {
11609
+ return bool || !!c.renderSelectionCheckBox;
11610
+ }, false)
11132
11611
  };
11133
11612
  return result;
11134
11613
  };
@@ -11189,7 +11668,8 @@ var useComputedVisibleColumns = ({
11189
11668
  computedUnpinnedOffset,
11190
11669
  computedPinnedEndOffset,
11191
11670
  computedPinnedEndWidth,
11192
- computedPinnedStartWidth
11671
+ computedPinnedStartWidth,
11672
+ renderSelectionCheckBox
11193
11673
  } = useMemo10(() => {
11194
11674
  return getComputedVisibleColumns({
11195
11675
  columns,
@@ -11240,6 +11720,7 @@ var useComputedVisibleColumns = ({
11240
11720
  columnsRenderId
11241
11721
  ]);
11242
11722
  const result = {
11723
+ renderSelectionCheckBox,
11243
11724
  columns,
11244
11725
  computedPinnedEndWidth,
11245
11726
  computedPinnedStartWidth,
@@ -11347,7 +11828,8 @@ function useComputed() {
11347
11828
  computedPinnedEndOffset,
11348
11829
  computedRemainingSpace,
11349
11830
  computedPinnedStartWidth,
11350
- computedPinnedEndWidth
11831
+ computedPinnedEndWidth,
11832
+ renderSelectionCheckBox
11351
11833
  } = useComputedVisibleColumns({
11352
11834
  columns,
11353
11835
  columnCssEllipsis: componentState.columnCssEllipsis,
@@ -11378,12 +11860,20 @@ function useComputed() {
11378
11860
  const scrollbars = useScrollbars(brain);
11379
11861
  const computedPinnedStartOverflow = computedPinnedStartWidth ? computedPinnedStartColumnsWidth > computedPinnedStartWidth : false;
11380
11862
  const computedPinnedEndOverflow = computedPinnedEndWidth ? computedPinnedEndColumnsWidth > computedPinnedEndWidth : false;
11863
+ const [multiRowSelector] = useState14(() => {
11864
+ const multiRowSelector2 = new MultiRowSelector({
11865
+ getIdForIndex: (index) => getDataSourceState().dataArray[index].id
11866
+ });
11867
+ return multiRowSelector2;
11868
+ });
11381
11869
  return {
11870
+ multiRowSelector,
11382
11871
  showColumnFilters: !!dataSourceState.filterValue,
11383
11872
  scrollbars,
11384
11873
  columnSize,
11385
11874
  rowspan,
11386
11875
  toggleGroupRow,
11876
+ renderSelectionCheckBox,
11387
11877
  computedPinnedStartOverflow,
11388
11878
  computedPinnedEndOverflow,
11389
11879
  computedPinnedStartWidth,
@@ -11566,7 +12056,7 @@ var useLicense = (licenseKey = "") => {
11566
12056
  const valid = useMemo11(() => {
11567
12057
  let valid2 = isValidLicense(licenseKey, {
11568
12058
  publishedAt: 1624970570587,
11569
- version: "0.4.1"
12059
+ version: "0.4.2"
11570
12060
  });
11571
12061
  if (!licenseKey && !valid2 && isInsidePlayground) {
11572
12062
  return true;
@@ -11576,149 +12066,19 @@ var useLicense = (licenseKey = "") => {
11576
12066
  return valid;
11577
12067
  };
11578
12068
 
11579
- // src/components/InfiniteTable/hooks/useRowSelection.ts
11580
- import { useEffect as useEffect27, useState as useState15 } from "react";
11581
-
11582
- // src/components/InfiniteTable/utils/MultiRowSelector.ts
11583
- function ensureMinMax(start, end) {
11584
- return start < end ? [start, end] : [end, start];
11585
- }
11586
- var MultiRowSelector = class {
11587
- constructor(options) {
11588
- this.multiSelectStartIndex = 0;
11589
- this.getIdForIndex = options.getIdForIndex;
11590
- }
11591
- set rowSelectionState(rowSelectionState) {
11592
- this._rowSelectionState = rowSelectionState;
11593
- }
11594
- get rowSelectionState() {
11595
- return this._rowSelectionState;
11596
- }
11597
- selectRange(startIndex, endIndex) {
11598
- const [start, end] = ensureMinMax(startIndex, endIndex);
11599
- const rowSelectionState = this.rowSelectionState;
11600
- for (let i = start; i <= end; i++) {
11601
- const id = this.getIdForIndex(i);
11602
- rowSelectionState.selectRow(id);
11603
- }
11604
- }
11605
- deselectRange(startIndex, endIndex) {
11606
- const [start, end] = ensureMinMax(startIndex, endIndex);
11607
- const rowSelectionState = this.rowSelectionState;
11608
- for (let i = start; i <= end; i++) {
11609
- const id = this.getIdForIndex(i);
11610
- rowSelectionState.deselectRow(id);
11611
- }
11612
- }
11613
- resetClick(index) {
11614
- this.rowSelectionState.deselectAll();
11615
- const id = this.getIdForIndex(index);
11616
- this.rowSelectionState.selectRow(id);
11617
- this.multiSelectStartIndex = index;
11618
- this.multiSelectEndIndex = void 0;
11619
- }
11620
- singleAddClick(index) {
11621
- const id = this.getIdForIndex(index);
11622
- if (this.rowSelectionState.isRowSelected(id)) {
11623
- this.rowSelectionState.deselectRow(id);
11624
- if (this.rowSelectionState.isRowSelected(this.getIdForIndex(index + 1))) {
11625
- this.multiSelectStartIndex = index + 1;
11626
- } else {
11627
- }
11628
- } else {
11629
- this.rowSelectionState.selectRow(id);
11630
- this.multiSelectStartIndex = index;
11631
- let multiSelectEndIndex = void 0;
11632
- for (let i = index - 1; i >= 0; i--) {
11633
- const id2 = this.getIdForIndex(i);
11634
- if (this.rowSelectionState.isRowSelected(id2)) {
11635
- multiSelectEndIndex = i;
11636
- } else {
11637
- break;
11638
- }
11639
- }
11640
- this.multiSelectEndIndex = multiSelectEndIndex;
11641
- }
11642
- }
11643
- multiSelectClick(index) {
11644
- if (this.multiSelectEndIndex != null) {
11645
- this.deselectRange(this.multiSelectStartIndex, this.multiSelectEndIndex);
11646
- }
11647
- this.selectRange(this.multiSelectStartIndex, index);
11648
- this.multiSelectEndIndex = index;
11649
- }
11650
- };
11651
-
11652
- // src/components/InfiniteTable/hooks/useRowSelection.ts
11653
- function useRowSelection() {
11654
- const { getState } = useInfiniteTable();
11655
- const [multiRowSelector] = useState15(() => {
11656
- const multiRowSelector2 = new MultiRowSelector({
11657
- getIdForIndex: (index) => getDataSourceState().dataArray[index].id
11658
- });
11659
- return multiRowSelector2;
11660
- });
11661
- const { getState: getDataSourceState, componentActions } = useDataSourceContextValue();
11662
- useEffect27(() => {
11663
- const removeOnClick = getState().cellClick.onChange((args) => {
11664
- if (args == null) {
11665
- return;
11666
- }
11667
- const { rowIndex, event } = args;
11668
- let {
11669
- rowSelection: rowSelectionState,
11670
- selectionMode,
11671
- groupBy
11672
- } = getDataSourceState();
11673
- if (groupBy.length) {
11674
- return;
11675
- }
11676
- if (selectionMode === "multi-row") {
11677
- rowSelectionState = new RowSelectionState(rowSelectionState);
11678
- multiRowSelector.rowSelectionState = rowSelectionState;
11679
- if (rowSelectionState && typeof rowSelectionState === "object") {
11680
- if (event.shiftKey) {
11681
- multiRowSelector.multiSelectClick(rowIndex);
11682
- } else if (event.metaKey || event.ctrlKey) {
11683
- multiRowSelector.singleAddClick(rowIndex);
11684
- } else {
11685
- multiRowSelector.resetClick(rowIndex);
11686
- }
11687
- componentActions.rowSelection = rowSelectionState;
11688
- }
11689
- } else if (selectionMode === "single-row") {
11690
- }
11691
- });
11692
- const removeOnKeyDown = getState().keyDown.onChange((event) => {
11693
- let { rowSelection: rowSelectionState, selectionMode } = getDataSourceState();
11694
- if (selectionMode === "multi-row") {
11695
- if ((event == null ? void 0 : event.key) === "a" && (event.ctrlKey || event.metaKey)) {
11696
- rowSelectionState = new RowSelectionState(rowSelectionState);
11697
- rowSelectionState.selectAll();
11698
- componentActions.rowSelection = rowSelectionState;
11699
- }
11700
- }
11701
- });
11702
- return () => {
11703
- removeOnClick();
11704
- removeOnKeyDown();
11705
- };
11706
- }, [multiRowSelector]);
11707
- }
11708
-
11709
12069
  // src/components/InfiniteTable/hooks/useScrollToActiveCell.ts
11710
- import { useRef as useRef22, useEffect as useEffect28 } from "react";
12070
+ import { useRef as useRef22, useEffect as useEffect27 } from "react";
11711
12071
  var RETRIES = 10;
11712
12072
  function useScrollToActiveCell(activeCellIndex, dataCount, imperativeApi) {
11713
12073
  const didScrollRef = useRef22(false);
11714
12074
  const rafId = useRef22(null);
11715
- useEffect28(() => {
12075
+ useEffect27(() => {
11716
12076
  if (activeCellIndex != null) {
11717
12077
  didScrollRef.current = false;
11718
12078
  cancelRaf(rafId.current);
11719
12079
  }
11720
12080
  }, [activeCellIndex]);
11721
- useEffect28(() => {
12081
+ useEffect27(() => {
11722
12082
  if (activeCellIndex != null && !didScrollRef.current) {
11723
12083
  let tryScroll = function(times = 0) {
11724
12084
  times++;
@@ -11741,18 +12101,18 @@ function useScrollToActiveCell(activeCellIndex, dataCount, imperativeApi) {
11741
12101
  }
11742
12102
 
11743
12103
  // src/components/InfiniteTable/hooks/useScrollToActiveRow.ts
11744
- import { useRef as useRef23, useEffect as useEffect29 } from "react";
12104
+ import { useRef as useRef23, useEffect as useEffect28 } from "react";
11745
12105
  var RETRIES2 = 10;
11746
12106
  function useScrollToActiveRow(activeRowIndex, dataCount, imperativeApi) {
11747
12107
  const didScrollRef = useRef23(false);
11748
12108
  const rafId = useRef23(null);
11749
- useEffect29(() => {
12109
+ useEffect28(() => {
11750
12110
  if (activeRowIndex != null) {
11751
12111
  didScrollRef.current = false;
11752
12112
  cancelAnimationFrame(rafId.current);
11753
12113
  }
11754
12114
  }, [activeRowIndex]);
11755
- useEffect29(() => {
12115
+ useEffect28(() => {
11756
12116
  if (activeRowIndex != null && !didScrollRef.current) {
11757
12117
  let tryScroll = function(times = 0) {
11758
12118
  times++;
@@ -11773,225 +12133,34 @@ function useScrollToActiveRow(activeRowIndex, dataCount, imperativeApi) {
11773
12133
  }, [activeRowIndex, dataCount]);
11774
12134
  }
11775
12135
 
11776
- // src/components/utils/clamp.ts
11777
- function clamp(value, min, max) {
11778
- return Math.min(Math.max(value, min), max);
11779
- }
12136
+ // src/components/InfiniteTable/state/getInitialState.ts
12137
+ import { createRef } from "react";
11780
12138
 
11781
- // src/components/InfiniteTable/keyboardNavigationAndSelection.ts
11782
- function handleRowNavigation(options) {
11783
- const { key, getState, getDataSourceState, actions } = options;
11784
- const arrLength = getDataSourceState().dataArray.length;
11785
- const state = getState();
11786
- const { brain } = state;
11787
- let { activeRowIndex } = state;
11788
- if (activeRowIndex == null) {
11789
- return false;
11790
- }
11791
- const {
11792
- start: [startRow],
11793
- end: [endRow]
11794
- } = brain.getRenderRange();
11795
- const renderRowCount = endRow - startRow - 1;
11796
- const min = 0;
11797
- const max = arrLength - 1;
11798
- const KeyToFunction = {
11799
- ArrowDown: () => {
11800
- activeRowIndex = clamp(activeRowIndex + 1, min, max);
11801
- },
11802
- ArrowUp: () => {
11803
- activeRowIndex = clamp(activeRowIndex - 1, min, max);
11804
- },
11805
- PageDown: () => {
11806
- activeRowIndex = Math.min(activeRowIndex + renderRowCount, arrLength - 1);
11807
- },
11808
- PageUp: () => {
11809
- activeRowIndex = Math.max(activeRowIndex - renderRowCount, min);
11810
- },
11811
- End: () => {
11812
- activeRowIndex = max;
11813
- },
11814
- Home: () => {
11815
- activeRowIndex = min;
11816
- }
11817
- };
11818
- const Fn = KeyToFunction[key];
11819
- if (!Fn) {
11820
- return false;
11821
- }
11822
- Fn();
11823
- actions.activeRowIndex = activeRowIndex;
11824
- return true;
11825
- }
11826
- function handleCellNavigation(options) {
11827
- const { key, shiftKey, getState, getComputed, getDataSourceState, actions } = options;
11828
- const state = getState();
11829
- const { activeCellIndex, brain } = state;
11830
- if (!activeCellIndex) {
11831
- return false;
11832
- }
11833
- let [rowIndex, colIndex] = activeCellIndex;
11834
- const {
11835
- start: [startRow, startCol],
11836
- end: [endRow, endCol]
11837
- } = brain.getRenderRange();
11838
- const renderRowCount = endRow - startRow - 1;
11839
- const renderColCount = endCol - startCol - 1;
11840
- const maxRow = getDataSourceState().dataArray.length - 1;
11841
- const maxCol = getComputed().computedVisibleColumns.length - 1;
11842
- const minRow = 0;
11843
- const minCol = 0;
11844
- rowIndex = clamp(rowIndex, 0, maxRow);
11845
- colIndex = clamp(colIndex, 0, maxCol);
11846
- actions.activeCellIndex = [rowIndex, colIndex];
11847
- const KeyToFunction = {
11848
- ArrowDown: () => {
11849
- rowIndex = clamp(rowIndex + 1, minRow, maxRow);
11850
- },
11851
- ArrowUp: () => {
11852
- rowIndex = clamp(rowIndex - 1, minRow, maxRow);
11853
- },
11854
- ArrowLeft: () => {
11855
- colIndex = clamp(colIndex - 1, minCol, maxCol);
11856
- },
11857
- ArrowRight: () => {
11858
- colIndex = clamp(colIndex + 1, minCol, maxCol);
11859
- },
11860
- PageDown: () => {
11861
- if (!shiftKey) {
11862
- rowIndex = Math.min(rowIndex + renderRowCount, maxRow);
11863
- } else {
11864
- colIndex = Math.min(colIndex + renderColCount, maxCol);
11865
- }
11866
- },
11867
- PageUp: () => {
11868
- if (!shiftKey) {
11869
- rowIndex = Math.max(rowIndex - renderRowCount, minRow);
11870
- } else {
11871
- colIndex = Math.max(colIndex - renderColCount, minCol);
11872
- }
11873
- },
11874
- End: () => {
11875
- if (!shiftKey) {
11876
- rowIndex = maxRow;
11877
- } else {
11878
- colIndex = maxCol;
11879
- }
11880
- },
11881
- Home: () => {
11882
- if (!shiftKey) {
11883
- rowIndex = minRow;
11884
- } else {
11885
- colIndex = minCol;
11886
- }
11887
- }
11888
- };
11889
- const Fn = KeyToFunction[key];
11890
- if (!Fn) {
11891
- return false;
11892
- }
11893
- Fn();
11894
- actions.activeCellIndex = [rowIndex, colIndex];
11895
- return true;
11896
- }
11897
- var validKeys = {
11898
- ArrowUp: true,
11899
- ArrowDown: true,
11900
- ArrowLeft: true,
11901
- ArrowRight: true,
11902
- PageUp: true,
11903
- PageDown: true,
11904
- Home: true,
11905
- End: true,
11906
- Enter: true,
11907
- " ": true
11908
- };
11909
- function handleKeyboardNavigation(options) {
11910
- const { getState, getDataSourceState, imperativeApi } = options;
11911
- const state = getState();
11912
- const dataSourceState = getDataSourceState();
11913
- const { activeRowIndex, activeCellIndex, keyboardNavigation } = state;
11914
- if (!validKeys[options.key]) {
11915
- return false;
11916
- }
11917
- if (options.key === "Enter") {
11918
- if (keyboardNavigation === "row" && activeRowIndex != null) {
11919
- const rowInfo = dataSourceState.dataArray[activeRowIndex];
11920
- if (rowInfo && rowInfo.isGroupRow) {
11921
- imperativeApi.toggleGroupRow(rowInfo.groupKeys);
11922
- return true;
11923
- }
11924
- }
11925
- if (keyboardNavigation === "cell" && activeCellIndex != null) {
11926
- const rowInfo = dataSourceState.dataArray[activeCellIndex[0]];
11927
- if (rowInfo && rowInfo.isGroupRow) {
11928
- imperativeApi.toggleGroupRow(rowInfo.groupKeys);
11929
- return true;
11930
- }
11931
- }
11932
- return false;
11933
- }
11934
- if (options.key === " ") {
11935
- if (keyboardNavigation === "row" && activeRowIndex != null) {
11936
- const rowInfo = dataSourceState.dataArray[activeRowIndex];
11937
- if (rowInfo) {
11938
- if (rowInfo.isGroupRow) {
11939
- imperativeApi.toggleGroupRowSelection(rowInfo.groupKeys);
11940
- } else {
11941
- imperativeApi.toggleRowSelection(rowInfo.id);
11942
- }
11943
- return true;
11944
- }
11945
- }
11946
- if (keyboardNavigation === "cell" && activeCellIndex != null) {
11947
- const rowInfo = dataSourceState.dataArray[activeCellIndex[0]];
11948
- if (rowInfo) {
11949
- if (rowInfo.isGroupRow) {
11950
- imperativeApi.toggleGroupRowSelection(rowInfo.groupKeys);
11951
- } else {
11952
- imperativeApi.toggleRowSelection(rowInfo.id);
11953
- }
11954
- return true;
11955
- }
11956
- }
11957
- }
11958
- if (activeRowIndex != null && keyboardNavigation === "row") {
11959
- return handleRowNavigation(options);
11960
- }
11961
- if (activeCellIndex != null && keyboardNavigation === "cell") {
11962
- return handleCellNavigation(options);
11963
- }
11964
- return false;
11965
- }
11966
-
11967
- // src/components/InfiniteTable/state/getInitialState.ts
11968
- import { createRef } from "react";
11969
-
11970
- // src/components/VirtualBrain/ScrollListener.ts
11971
- var initialScrollPosition = {
11972
- scrollLeft: 0,
11973
- scrollTop: 0
11974
- };
11975
- var ScrollListener = class {
11976
- constructor() {
11977
- this.scrollPosition = initialScrollPosition;
11978
- this.onScrollFns = [];
11979
- this.getScrollPosition = () => {
11980
- return this.scrollPosition;
11981
- };
11982
- this.onScroll = (fn) => {
11983
- this.onScrollFns.push(fn);
11984
- return () => {
11985
- this.onScrollFns = this.onScrollFns.filter((f) => f !== fn);
11986
- };
11987
- };
11988
- this.setScrollPosition = (scrollPosition) => {
11989
- this.scrollPosition = scrollPosition;
11990
- this.notifyScrollChange();
11991
- };
11992
- this.destroy = () => {
11993
- this.onScrollFns = [];
11994
- };
12139
+ // src/components/VirtualBrain/ScrollListener.ts
12140
+ var initialScrollPosition = {
12141
+ scrollLeft: 0,
12142
+ scrollTop: 0
12143
+ };
12144
+ var ScrollListener = class {
12145
+ constructor() {
12146
+ this.scrollPosition = initialScrollPosition;
12147
+ this.onScrollFns = [];
12148
+ this.getScrollPosition = () => {
12149
+ return this.scrollPosition;
12150
+ };
12151
+ this.onScroll = (fn) => {
12152
+ this.onScrollFns.push(fn);
12153
+ return () => {
12154
+ this.onScrollFns = this.onScrollFns.filter((f) => f !== fn);
12155
+ };
12156
+ };
12157
+ this.setScrollPosition = (scrollPosition) => {
12158
+ this.scrollPosition = scrollPosition;
12159
+ this.notifyScrollChange();
12160
+ };
12161
+ this.destroy = () => {
12162
+ this.onScrollFns = [];
12163
+ };
11995
12164
  }
11996
12165
  notifyScrollChange() {
11997
12166
  const { scrollPosition } = this;
@@ -12135,6 +12304,7 @@ var forwardProps4 = (setupState) => {
12135
12304
  pivotTotalColumnPosition: (pivotTotalColumnPosition) => pivotTotalColumnPosition != null ? pivotTotalColumnPosition : "end",
12136
12305
  pivotGrandTotalColumnPosition: 1,
12137
12306
  licenseKey: (licenseKey) => licenseKey || "",
12307
+ keyboardSelection: (keyboardSelection) => keyboardSelection != null ? keyboardSelection : true,
12138
12308
  activeRowIndex: 1,
12139
12309
  activeCellIndex: 1,
12140
12310
  columnOrder: (columnOrder) => columnOrder != null ? columnOrder : true,
@@ -12209,6 +12379,388 @@ var mapPropsToState2 = (params) => {
12209
12379
  // src/components/InfiniteTable/utils/toCSSVarName.ts
12210
12380
  var toCSSVarName = (value) => `--infinite-${value}`;
12211
12381
 
12382
+ // src/components/InfiniteTable/eventHandlers/index.ts
12383
+ import { useCallback as useCallback18, useMemo as useMemo12, useEffect as useEffect29 } from "react";
12384
+
12385
+ // src/components/InfiniteTable/eventHandlers/onCellClick.ts
12386
+ function onCellClick(context, event) {
12387
+ updateRowSelectionOnCellClick(context, event);
12388
+ }
12389
+ function updateRowSelectionOnCellClick(context, event) {
12390
+ const { rowIndex, getDataSourceState, getComputed, dataSourceActions } = context;
12391
+ const { multiRowSelector, renderSelectionCheckBox } = getComputed();
12392
+ const dataSourceState = getDataSourceState();
12393
+ const { selectionMode, groupBy } = dataSourceState;
12394
+ let { rowSelection: rowSelectionState } = dataSourceState;
12395
+ if (groupBy.length) {
12396
+ return false;
12397
+ }
12398
+ if (selectionMode === "multi-row") {
12399
+ if (renderSelectionCheckBox && !event.key) {
12400
+ return false;
12401
+ }
12402
+ rowSelectionState = new RowSelectionState(rowSelectionState, rowSelectionStateConfigGetter(getDataSourceState));
12403
+ multiRowSelector.rowSelectionState = rowSelectionState;
12404
+ if (rowSelectionState && typeof rowSelectionState === "object") {
12405
+ if (event.shiftKey) {
12406
+ multiRowSelector.multiSelectClick(rowIndex);
12407
+ } else if (event.metaKey || event.ctrlKey) {
12408
+ multiRowSelector.singleAddClick(rowIndex);
12409
+ } else {
12410
+ multiRowSelector.resetClick(rowIndex);
12411
+ }
12412
+ dataSourceActions.rowSelection = rowSelectionState;
12413
+ return true;
12414
+ }
12415
+ } else if (selectionMode === "single-row") {
12416
+ }
12417
+ return false;
12418
+ }
12419
+
12420
+ // src/components/utils/clamp.ts
12421
+ function clamp(value, min, max) {
12422
+ return Math.min(Math.max(value, min), max);
12423
+ }
12424
+
12425
+ // src/components/InfiniteTable/eventHandlers/keyboardNavigation.ts
12426
+ function handleRowNavigation(options) {
12427
+ const { key, getState, getDataSourceState, actions, api } = options;
12428
+ const dataArray = getDataSourceState().dataArray;
12429
+ const arrLength = dataArray.length;
12430
+ const state = getState();
12431
+ const { brain } = state;
12432
+ let { activeRowIndex } = state;
12433
+ if (activeRowIndex == null) {
12434
+ return false;
12435
+ }
12436
+ const {
12437
+ start: [startRow],
12438
+ end: [endRow]
12439
+ } = brain.getRenderRange();
12440
+ const renderRowCount = endRow - startRow - 1;
12441
+ const min = 0;
12442
+ const max = arrLength - 1;
12443
+ const KeyToFunction = {
12444
+ ArrowDown: () => {
12445
+ activeRowIndex = clamp(activeRowIndex + 1, min, max);
12446
+ },
12447
+ ArrowUp: () => {
12448
+ activeRowIndex = clamp(activeRowIndex - 1, min, max);
12449
+ },
12450
+ ArrowLeft: () => {
12451
+ const rowInfo = dataArray[activeRowIndex];
12452
+ if (rowInfo && rowInfo.isGroupRow) {
12453
+ return api.collapseGroupRow(rowInfo.groupKeys);
12454
+ }
12455
+ return false;
12456
+ },
12457
+ ArrowRight: () => {
12458
+ const rowInfo = dataArray[activeRowIndex];
12459
+ if (rowInfo && rowInfo.isGroupRow) {
12460
+ return api.expandGroupRow(rowInfo.groupKeys);
12461
+ }
12462
+ return false;
12463
+ },
12464
+ Enter: () => {
12465
+ const rowInfo = dataArray[activeRowIndex];
12466
+ if (rowInfo && rowInfo.isGroupRow) {
12467
+ return api.toggleGroupRow(rowInfo.groupKeys);
12468
+ }
12469
+ return false;
12470
+ },
12471
+ PageDown: () => {
12472
+ activeRowIndex = Math.min(activeRowIndex + renderRowCount, arrLength - 1);
12473
+ },
12474
+ PageUp: () => {
12475
+ activeRowIndex = Math.max(activeRowIndex - renderRowCount, min);
12476
+ },
12477
+ End: () => {
12478
+ activeRowIndex = max;
12479
+ },
12480
+ Home: () => {
12481
+ activeRowIndex = min;
12482
+ }
12483
+ };
12484
+ const Fn = KeyToFunction[key];
12485
+ if (!Fn) {
12486
+ return false;
12487
+ }
12488
+ Fn();
12489
+ actions.activeRowIndex = activeRowIndex;
12490
+ return true;
12491
+ }
12492
+ function handleCellNavigation(options) {
12493
+ const {
12494
+ api,
12495
+ key,
12496
+ shiftKey,
12497
+ getState,
12498
+ getComputed,
12499
+ getDataSourceState,
12500
+ actions
12501
+ } = options;
12502
+ const dataArray = getDataSourceState().dataArray;
12503
+ const state = getState();
12504
+ const { activeCellIndex, brain } = state;
12505
+ if (!activeCellIndex) {
12506
+ return false;
12507
+ }
12508
+ let [rowIndex, colIndex] = activeCellIndex;
12509
+ const {
12510
+ start: [startRow, startCol],
12511
+ end: [endRow, endCol]
12512
+ } = brain.getRenderRange();
12513
+ const renderRowCount = endRow - startRow - 1;
12514
+ const renderColCount = endCol - startCol - 1;
12515
+ const maxRow = getDataSourceState().dataArray.length - 1;
12516
+ const maxCol = getComputed().computedVisibleColumns.length - 1;
12517
+ const minRow = 0;
12518
+ const minCol = 0;
12519
+ rowIndex = clamp(rowIndex, 0, maxRow);
12520
+ colIndex = clamp(colIndex, 0, maxCol);
12521
+ actions.activeCellIndex = [rowIndex, colIndex];
12522
+ const KeyToFunction = {
12523
+ ArrowDown: () => {
12524
+ rowIndex = clamp(rowIndex + 1, minRow, maxRow);
12525
+ },
12526
+ ArrowUp: () => {
12527
+ rowIndex = clamp(rowIndex - 1, minRow, maxRow);
12528
+ },
12529
+ ArrowLeft: () => {
12530
+ colIndex = clamp(colIndex - 1, minCol, maxCol);
12531
+ },
12532
+ ArrowRight: () => {
12533
+ colIndex = clamp(colIndex + 1, minCol, maxCol);
12534
+ },
12535
+ Enter: () => {
12536
+ const rowInfo = dataArray[rowIndex];
12537
+ if (rowInfo && rowInfo.isGroupRow) {
12538
+ return api.toggleGroupRow(rowInfo.groupKeys);
12539
+ }
12540
+ return false;
12541
+ },
12542
+ PageDown: () => {
12543
+ if (!shiftKey) {
12544
+ rowIndex = Math.min(rowIndex + renderRowCount, maxRow);
12545
+ } else {
12546
+ colIndex = Math.min(colIndex + renderColCount, maxCol);
12547
+ }
12548
+ },
12549
+ PageUp: () => {
12550
+ if (!shiftKey) {
12551
+ rowIndex = Math.max(rowIndex - renderRowCount, minRow);
12552
+ } else {
12553
+ colIndex = Math.max(colIndex - renderColCount, minCol);
12554
+ }
12555
+ },
12556
+ End: () => {
12557
+ if (!shiftKey) {
12558
+ rowIndex = maxRow;
12559
+ } else {
12560
+ colIndex = maxCol;
12561
+ }
12562
+ },
12563
+ Home: () => {
12564
+ if (!shiftKey) {
12565
+ rowIndex = minRow;
12566
+ } else {
12567
+ colIndex = minCol;
12568
+ }
12569
+ }
12570
+ };
12571
+ const Fn = KeyToFunction[key];
12572
+ if (!Fn) {
12573
+ return false;
12574
+ }
12575
+ Fn();
12576
+ actions.activeCellIndex = [rowIndex, colIndex];
12577
+ return true;
12578
+ }
12579
+ var validKeys = {
12580
+ ArrowUp: true,
12581
+ ArrowDown: true,
12582
+ ArrowLeft: true,
12583
+ ArrowRight: true,
12584
+ PageUp: true,
12585
+ PageDown: true,
12586
+ Home: true,
12587
+ End: true,
12588
+ Enter: true,
12589
+ " ": true
12590
+ };
12591
+ function handleKeyboardNavigation(options) {
12592
+ const { getState } = options;
12593
+ const state = getState();
12594
+ const { activeRowIndex, activeCellIndex, keyboardNavigation } = state;
12595
+ if (!validKeys[options.key]) {
12596
+ return false;
12597
+ }
12598
+ if (activeRowIndex != null && keyboardNavigation === "row") {
12599
+ return handleRowNavigation(options);
12600
+ }
12601
+ if (activeCellIndex != null && keyboardNavigation === "cell") {
12602
+ return handleCellNavigation(options);
12603
+ }
12604
+ return false;
12605
+ }
12606
+
12607
+ // src/components/InfiniteTable/eventHandlers/keyboardSelection.ts
12608
+ var validKeys2 = {
12609
+ Enter: true,
12610
+ " ": true,
12611
+ a: true
12612
+ };
12613
+ function handleKeyboardSelection(context) {
12614
+ const {
12615
+ getState,
12616
+ getDataSourceState,
12617
+ dataSourceActions,
12618
+ api: imperativeApi,
12619
+ key,
12620
+ ctrlKey,
12621
+ metaKey
12622
+ } = context;
12623
+ if (!validKeys2[key]) {
12624
+ return false;
12625
+ }
12626
+ const state = getState();
12627
+ const dataSourceState = getDataSourceState();
12628
+ const {
12629
+ activeRowIndex,
12630
+ activeCellIndex,
12631
+ keyboardNavigation,
12632
+ keyboardSelection
12633
+ } = state;
12634
+ const { selectionMode, groupBy, rowSelection } = dataSourceState;
12635
+ if (keyboardSelection === false) {
12636
+ return false;
12637
+ }
12638
+ const rowIndex = keyboardNavigation === "row" && activeRowIndex != null ? activeRowIndex : keyboardNavigation === "cell" && activeCellIndex != null ? activeCellIndex[0] : null;
12639
+ const rowInfo = rowIndex != null ? dataSourceState.dataArray[rowIndex] : null;
12640
+ if (!rowInfo || rowIndex == null) {
12641
+ return false;
12642
+ }
12643
+ if (selectionMode === "single-row" && key === " ") {
12644
+ imperativeApi.selectionApi.toggleRowSelection(rowInfo.id);
12645
+ return true;
12646
+ }
12647
+ if (selectionMode !== "multi-row") {
12648
+ return false;
12649
+ }
12650
+ if (key === "a" && (ctrlKey || metaKey)) {
12651
+ const rowSelectionState = new RowSelectionState(rowSelection, rowSelectionStateConfigGetter(getDataSourceState));
12652
+ rowSelectionState.selectAll();
12653
+ dataSourceActions.rowSelection = rowSelectionState;
12654
+ return true;
12655
+ }
12656
+ if (key === " ") {
12657
+ if (groupBy.length) {
12658
+ if (rowInfo.isGroupRow) {
12659
+ imperativeApi.selectionApi.toggleGroupRowSelection(rowInfo.groupKeys);
12660
+ } else {
12661
+ imperativeApi.selectionApi.toggleRowSelection(rowInfo.id);
12662
+ }
12663
+ return true;
12664
+ } else {
12665
+ const event = __spreadValues({}, context);
12666
+ const { renderSelectionCheckBox } = context.getComputed();
12667
+ if (renderSelectionCheckBox) {
12668
+ event.shiftKey = false;
12669
+ event.metaKey = false;
12670
+ event.ctrlKey = true;
12671
+ }
12672
+ return updateRowSelectionOnCellClick(__spreadProps(__spreadValues({}, context), { rowIndex }), event);
12673
+ }
12674
+ }
12675
+ return false;
12676
+ }
12677
+
12678
+ // src/components/InfiniteTable/eventHandlers/onKeyDown.ts
12679
+ function onKeyDown(context, event) {
12680
+ const keyboardHandlerContext = __spreadProps(__spreadValues({}, context), {
12681
+ key: event.key,
12682
+ metaKey: event.metaKey,
12683
+ ctrlKey: event.ctrlKey,
12684
+ shiftKey: event.shiftKey
12685
+ });
12686
+ if (handleKeyboardSelection(keyboardHandlerContext)) {
12687
+ event.preventDefault();
12688
+ }
12689
+ if (handleKeyboardNavigation(keyboardHandlerContext)) {
12690
+ event.preventDefault();
12691
+ }
12692
+ }
12693
+
12694
+ // src/components/InfiniteTable/eventHandlers/index.ts
12695
+ function useEventHandlersContext() {
12696
+ const {
12697
+ getState,
12698
+ componentActions: actions,
12699
+ imperativeApi,
12700
+ getComputed
12701
+ } = useInfiniteTable();
12702
+ const { getState: getDataSourceState, componentActions: dataSourceActions } = useDataSourceContextValue();
12703
+ const context = useMemo12(() => {
12704
+ const context2 = {
12705
+ getComputed,
12706
+ api: imperativeApi,
12707
+ getState,
12708
+ actions,
12709
+ getDataSourceState,
12710
+ dataSourceActions
12711
+ };
12712
+ return context2;
12713
+ }, [getState, actions, getDataSourceState, dataSourceActions]);
12714
+ return context;
12715
+ }
12716
+ function handleDOMEvents() {
12717
+ const context = useEventHandlersContext();
12718
+ useEffect29(() => {
12719
+ const removeOnKeyDown = context.getState().keyDown.onChange((event) => {
12720
+ onKeyDown(__spreadProps(__spreadValues({}, context), {
12721
+ key: event.key,
12722
+ metaKey: event.metaKey,
12723
+ ctrlKey: event.ctrlKey,
12724
+ shiftKey: event.shiftKey,
12725
+ preventDefault: () => event.preventDefault()
12726
+ }), event);
12727
+ });
12728
+ function cellClickHandler(cellClickParam) {
12729
+ if (!cellClickParam) {
12730
+ return;
12731
+ }
12732
+ const event = cellClickParam.event;
12733
+ const virtualEvent = {
12734
+ metaKey: event.metaKey,
12735
+ ctrlKey: event.ctrlKey,
12736
+ shiftKey: event.shiftKey,
12737
+ key: "",
12738
+ preventDefault: () => event.preventDefault()
12739
+ };
12740
+ onCellClick(__spreadValues(__spreadProps(__spreadValues({}, context), {
12741
+ rowIndex: cellClickParam.rowIndex,
12742
+ colIndex: cellClickParam.colIndex
12743
+ }), virtualEvent), virtualEvent);
12744
+ }
12745
+ const removeOnCellClick = context.getState().cellClick.onChange(cellClickHandler);
12746
+ return () => {
12747
+ removeOnKeyDown();
12748
+ removeOnCellClick();
12749
+ };
12750
+ }, []);
12751
+ }
12752
+ function subscribeToDOMEvents() {
12753
+ const { getState } = useInfiniteTable();
12754
+ const onKeyDown2 = useCallback18((event) => {
12755
+ getState().keyDown(event);
12756
+ }, []);
12757
+ return { onKeyDown: onKeyDown2 };
12758
+ }
12759
+ function useDOMEventHandlers() {
12760
+ handleDOMEvents();
12761
+ return subscribeToDOMEvents();
12762
+ }
12763
+
12212
12764
  // src/components/InfiniteTable/index.tsx
12213
12765
  var InfiniteTableClassName = internalProps.rootClassName;
12214
12766
  var HOVERED_CLASS_NAMES = [RowHoverCls, "InfiniteColumnCell--hovered"];
@@ -12226,14 +12778,7 @@ var InfiniteTableRoot = getComponentStateRoot({
12226
12778
  });
12227
12779
  var InfiniteTableComponent = memo13(function InfiniteTableComponent2() {
12228
12780
  var _a;
12229
- const {
12230
- componentState,
12231
- getComputed,
12232
- computed,
12233
- componentActions: actions,
12234
- getState,
12235
- imperativeApi
12236
- } = useInfiniteTable();
12781
+ const { componentState, getComputed, computed, imperativeApi } = useInfiniteTable();
12237
12782
  const {
12238
12783
  componentState: { loading, dataArray },
12239
12784
  getState: getDataSourceState,
@@ -12262,7 +12807,7 @@ var InfiniteTableComponent = memo13(function InfiniteTableComponent2() {
12262
12807
  } = componentState;
12263
12808
  useScrollToActiveRow(activeRowIndex, dataArray.length, imperativeApi);
12264
12809
  useScrollToActiveCell(activeCellIndex, dataArray.length, imperativeApi);
12265
- useRowSelection();
12810
+ const { onKeyDown: onKeyDown2 } = useDOMEventHandlers();
12266
12811
  const { bodySize } = componentState;
12267
12812
  const { scrollbars } = computed;
12268
12813
  const { renderCell } = useCellRendering({
@@ -12290,22 +12835,8 @@ var InfiniteTableComponent = memo13(function InfiniteTableComponent2() {
12290
12835
  dataSourceActions.scrollStopDelayUpdatedByTable = scrollStopDelay;
12291
12836
  }, [scrollStopDelay]);
12292
12837
  useAutoSizeColumns();
12293
- const onKeyDown = useCallback18((event) => {
12294
- getState().keyDown(event);
12295
- if (handleKeyboardNavigation({
12296
- getState,
12297
- actions,
12298
- getDataSourceState,
12299
- getComputed,
12300
- imperativeApi,
12301
- key: event.key,
12302
- shiftKey: !!event.shiftKey
12303
- })) {
12304
- event.preventDefault();
12305
- }
12306
- }, []);
12307
12838
  return /* @__PURE__ */ createElement35("div", __spreadValues({
12308
- onKeyDown,
12839
+ onKeyDown: onKeyDown2,
12309
12840
  ref: domRef
12310
12841
  }, domProps), header ? /* @__PURE__ */ createElement35(TableHeaderWrapper, {
12311
12842
  bodyBrain: brain,
@@ -12352,8 +12883,14 @@ function InfiniteTableContextProvider() {
12352
12883
  globalThis.getComputed = getComputed;
12353
12884
  }
12354
12885
  const { getState: getDataSourceState, componentActions: dataSourceActions } = useDataSourceContextValue();
12355
- const [imperativeApi] = useState16(() => {
12356
- return getImperativeApi(getComputed, getState, getDataSourceState, componentActions, dataSourceActions);
12886
+ const [imperativeApi] = useState15(() => {
12887
+ return getImperativeApi({
12888
+ getComputed,
12889
+ getState,
12890
+ getDataSourceState,
12891
+ componentActions,
12892
+ dataSourceActions
12893
+ });
12357
12894
  });
12358
12895
  const contextValue = {
12359
12896
  componentActions,