@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.js CHANGED
@@ -668,7 +668,6 @@ function debounce(fn, { wait }) {
668
668
 
669
669
  // src/components/InfiniteTable/index.tsx
670
670
  var React38 = __toModule(require("react"));
671
- var import_react49 = __toModule(require("react"));
672
671
 
673
672
  // src/utils/join.ts
674
673
  var join = (...args) => args.filter((x) => !!`${x}`).join(" ");
@@ -1012,32 +1011,33 @@ var AvoidReactDiff = React7.memo(AvoidReactDiffFn);
1012
1011
 
1013
1012
  // src/components/utils/buildSubscriptionCallback.tsx
1014
1013
  function buildSubscriptionCallback(withRaf = false) {
1015
- let result = null;
1014
+ let lastCallValue = null;
1016
1015
  let fns = [];
1017
1016
  let rafId = null;
1018
1017
  const updater = (items, callback) => {
1018
+ const results = [];
1019
1019
  if (withRaf) {
1020
1020
  if (rafId != null) {
1021
1021
  cancelAnimationFrame(rafId);
1022
1022
  rafId = null;
1023
1023
  }
1024
1024
  requestAnimationFrame(() => {
1025
- result = items;
1025
+ lastCallValue = items;
1026
1026
  rafId = null;
1027
1027
  for (let i = 0, len = fns.length; i < len; i++) {
1028
- fns[i](items);
1028
+ results.push(fns[i](items));
1029
1029
  }
1030
- callback == null ? void 0 : callback();
1030
+ callback == null ? void 0 : callback(results);
1031
1031
  });
1032
1032
  } else {
1033
- result = items;
1033
+ lastCallValue = items;
1034
1034
  for (let i = 0, len = fns.length; i < len; i++) {
1035
- fns[i](items);
1035
+ results.push(fns[i](items));
1036
1036
  }
1037
- callback == null ? void 0 : callback();
1037
+ callback == null ? void 0 : callback(results);
1038
1038
  }
1039
1039
  };
1040
- updater.get = () => result;
1040
+ updater.get = () => lastCallValue;
1041
1041
  updater.onChange = (fn) => {
1042
1042
  fns.push(fn);
1043
1043
  return () => {
@@ -1048,6 +1048,7 @@ function buildSubscriptionCallback(withRaf = false) {
1048
1048
  updater(null);
1049
1049
  fns.length = 0;
1050
1050
  };
1051
+ updater.getListenersCount = () => fns.length;
1051
1052
  return updater;
1052
1053
  }
1053
1054
 
@@ -2239,13 +2240,19 @@ var DeepMap = class {
2239
2240
  this.visitDepthFirst = (fn) => {
2240
2241
  this.visitWithNext([], fn);
2241
2242
  };
2242
- this.visitWithNext = (parentKeys, fn, currentMap = this.map) => {
2243
+ this.visitWithNext = (parentKeys, fn, currentMap = this.map, depthLimit, skipSelfValue) => {
2243
2244
  if (!currentMap) {
2244
2245
  return;
2245
2246
  }
2246
2247
  let i = 0;
2247
2248
  const hasEmptyKey = currentMap.has(this.emptyKey);
2248
- let allowEmptyKey = true;
2249
+ let allowEmptyKey = skipSelfValue ? false : true;
2250
+ if (depthLimit !== void 0) {
2251
+ if (depthLimit < 0) {
2252
+ return;
2253
+ }
2254
+ depthLimit--;
2255
+ }
2249
2256
  const iterator = (_, key) => {
2250
2257
  const pair = currentMap.get(key);
2251
2258
  if (!pair) {
@@ -2257,7 +2264,7 @@ var DeepMap = class {
2257
2264
  return;
2258
2265
  }
2259
2266
  const keys = isEmptyKey ? [] : [...parentKeys, key];
2260
- const next = map2 ? () => this.visitWithNext(keys, fn, map2) : void 0;
2267
+ let next = map2 ? () => this.visitWithNext(keys, fn, map2, depthLimit !== void 0 ? depthLimit - 1 : void 0) : void 0;
2261
2268
  if (pair.hasOwnProperty("value")) {
2262
2269
  fn(pair.value, keys, i, next);
2263
2270
  i++;
@@ -2289,41 +2296,84 @@ var DeepMap = class {
2289
2296
  });
2290
2297
  }
2291
2298
  }
2292
- getValuesStartingWith(keys) {
2299
+ getValuesStartingWith(keys, excludeSelf, depthLimit) {
2293
2300
  const result = [];
2294
2301
  this.getStartingWith(keys, (_keys, value) => {
2295
2302
  result.push(value);
2296
- });
2303
+ }, excludeSelf, depthLimit);
2297
2304
  return result;
2298
2305
  }
2299
- getKeysStartingWith(keys) {
2306
+ getKeysStartingWith(keys, excludeSelf, depthLimit) {
2300
2307
  const result = [];
2301
2308
  this.getStartingWith(keys, (keys2) => {
2302
2309
  result.push(keys2);
2303
- });
2310
+ }, excludeSelf, depthLimit);
2304
2311
  return result;
2305
2312
  }
2306
- getStartingWith(keys, fn) {
2313
+ getStartingWith(keys, fn, excludeSelf, depthLimit) {
2314
+ let currentMap = this.map;
2315
+ let pair;
2316
+ let stop = false;
2317
+ if (keys.length) {
2318
+ for (let i = 0, len = keys.length; i < len; i++) {
2319
+ const key = keys[i];
2320
+ pair = currentMap.get(key);
2321
+ if (!pair || !pair.map) {
2322
+ stop = true;
2323
+ if (i === len - 1) {
2324
+ stop = true;
2325
+ break;
2326
+ } else {
2327
+ return;
2328
+ }
2329
+ }
2330
+ currentMap = pair.map;
2331
+ }
2332
+ }
2333
+ if (pair && pair.value !== void 0) {
2334
+ if (!excludeSelf) {
2335
+ fn(keys, pair.value);
2336
+ }
2337
+ }
2338
+ if (stop) {
2339
+ return;
2340
+ }
2341
+ this.visitWithNext(keys, (value, keys2, _i, next) => {
2342
+ fn(keys2, value);
2343
+ next == null ? void 0 : next();
2344
+ }, currentMap, depthLimit, excludeSelf);
2345
+ }
2346
+ getMapAt(keys) {
2307
2347
  let currentMap = this.map;
2308
2348
  let pair;
2309
2349
  if (!keys.length) {
2310
- keys = [this.emptyKey];
2350
+ return this.map;
2311
2351
  }
2312
2352
  for (let i = 0, len = keys.length; i < len; i++) {
2313
2353
  const key = keys[i];
2314
2354
  pair = currentMap.get(key);
2315
2355
  if (!pair || !pair.map) {
2316
- return;
2356
+ return void 0;
2317
2357
  }
2318
2358
  currentMap = pair.map;
2319
2359
  }
2320
- if (pair && pair.value !== void 0) {
2321
- fn(keys, pair.value);
2360
+ return currentMap;
2361
+ }
2362
+ getAllChildrenSizeFor(keys) {
2363
+ let currentMap = this.map;
2364
+ let pair;
2365
+ if (!keys.length) {
2366
+ return this.length;
2322
2367
  }
2323
- this.visitWithNext(keys, (value, keys2, _i, next) => {
2324
- fn(keys2, value);
2325
- next == null ? void 0 : next();
2326
- }, currentMap);
2368
+ for (let i = 0, len = keys.length; i < len; i++) {
2369
+ const key = keys[i];
2370
+ pair = currentMap.get(key);
2371
+ if (!pair || !pair.map) {
2372
+ return 0;
2373
+ }
2374
+ currentMap = pair.map;
2375
+ }
2376
+ return pair.length;
2327
2377
  }
2328
2378
  getDirectChildrenSizeFor(keys) {
2329
2379
  var _a;
@@ -2353,7 +2403,9 @@ var DeepMap = class {
2353
2403
  for (let i = 0, len = keys.length; i < len; i++) {
2354
2404
  const key = keys[i];
2355
2405
  const last = i === len - 1;
2356
- const pair = currentMap.get(key) || {};
2406
+ const pair = currentMap.get(key) || {
2407
+ length: 0
2408
+ };
2357
2409
  if (last) {
2358
2410
  pair.revision = this.revision++;
2359
2411
  pair.value = value;
@@ -2364,6 +2416,7 @@ var DeepMap = class {
2364
2416
  pair.map = new Map();
2365
2417
  currentMap.set(key, pair);
2366
2418
  }
2419
+ pair.length++;
2367
2420
  currentMap = pair.map;
2368
2421
  }
2369
2422
  }
@@ -2414,6 +2467,7 @@ var DeepMap = class {
2414
2467
  keys = [...keys];
2415
2468
  }
2416
2469
  const maps = [currentMap];
2470
+ const pairs = [];
2417
2471
  let result = false;
2418
2472
  for (let i = 0, len = keys.length; i < len; i++) {
2419
2473
  const key = keys[i];
@@ -2425,6 +2479,9 @@ var DeepMap = class {
2425
2479
  delete pair.value;
2426
2480
  delete pair.revision;
2427
2481
  result = true;
2482
+ pairs.forEach((pair2) => {
2483
+ pair2.length--;
2484
+ });
2428
2485
  this.length--;
2429
2486
  }
2430
2487
  if (pair.map && pair.map.size === 0) {
@@ -2440,6 +2497,7 @@ var DeepMap = class {
2440
2497
  result = false;
2441
2498
  break;
2442
2499
  }
2500
+ pairs.push(pair);
2443
2501
  currentMap = pair.map;
2444
2502
  maps.push(currentMap);
2445
2503
  }
@@ -2513,6 +2571,19 @@ var DeepMap = class {
2513
2571
  });
2514
2572
  return result;
2515
2573
  }
2574
+ valuesAt(keys) {
2575
+ const map2 = this.getMapAt(keys);
2576
+ if (!map2) {
2577
+ return [];
2578
+ }
2579
+ const result = [];
2580
+ map2.forEach((bag) => {
2581
+ if (bag.value !== void 0) {
2582
+ result.push(bag.value);
2583
+ }
2584
+ });
2585
+ return result;
2586
+ }
2516
2587
  values() {
2517
2588
  return this.sortedIterator((pair) => pair.value);
2518
2589
  }
@@ -3581,11 +3652,11 @@ var useRerender = () => {
3581
3652
  };
3582
3653
 
3583
3654
  // src/components/InfiniteTable/components/ActiveCellIndicator.css.ts
3584
- var ActiveCellIndicatorCls = { visible: "nxbq1c2 nxbq1c1 _16lm1iwf _16lm1iw3 _16lm1iw14 _16lm1iw12", hidden: "nxbq1c3 nxbq1c1 _16lm1iwf _16lm1iw3 _16lm1iw14 _16lm1iw12" };
3585
- var ActiveIndicatorWrapperCls = "_16lm1iwf _16lm1iw3 _16lm1iw14 _16lm1iw12 _16lm1iwy _16lm1iwo";
3655
+ var ActiveCellIndicatorCls = { visible: "nxbq1c2 nxbq1c1 _16lm1iwg _16lm1iw3 _16lm1iw15 _16lm1iw13", hidden: "nxbq1c3 nxbq1c1 _16lm1iwg _16lm1iw3 _16lm1iw15 _16lm1iw13" };
3656
+ var ActiveIndicatorWrapperCls = "_16lm1iwg _16lm1iw3 _16lm1iw15 _16lm1iw13 _16lm1iwz _16lm1iwp";
3586
3657
 
3587
3658
  // src/components/InfiniteTable/components/ActiveRowIndicator.css.ts
3588
- var ActiveRowIndicatorCls = { visible: "j26lrx1 j26lrx0 _16lm1iwf _16lm1iw3 _16lm1iw11 _16lm1iw12 _16lm1iw14", hidden: "j26lrx2 j26lrx0 _16lm1iwf _16lm1iw3 _16lm1iw11 _16lm1iw12 _16lm1iw14" };
3659
+ var ActiveRowIndicatorCls = { visible: "j26lrx1 j26lrx0 _16lm1iwg _16lm1iw3 _16lm1iw12 _16lm1iw13 _16lm1iw15", hidden: "j26lrx2 j26lrx0 _16lm1iwg _16lm1iw3 _16lm1iw12 _16lm1iw13 _16lm1iw15" };
3589
3660
 
3590
3661
  // src/components/InfiniteTable/components/ActiveRowIndicator.tsx
3591
3662
  var { rootClassName: rootClassName3 } = internalProps;
@@ -3862,10 +3933,10 @@ var usePrevious = (value, initialValue) => {
3862
3933
  };
3863
3934
 
3864
3935
  // src/components/hooks/useComponentState/index.tsx
3865
- var notifyChange = (props, callbackPropName, newValue) => {
3936
+ var notifyChange = (props, callbackPropName, values) => {
3866
3937
  const callbackProp = props[callbackPropName];
3867
3938
  if (typeof callbackProp === "function") {
3868
- callbackProp(newValue);
3939
+ callbackProp(...values);
3869
3940
  }
3870
3941
  };
3871
3942
  var debug3 = dbg("rerender");
@@ -3894,14 +3965,14 @@ function getReducerGeneratedActions(dispatch, getState, getProps, propsToForward
3894
3965
  }
3895
3966
  }
3896
3967
  if (notifyTheChange) {
3897
- let callbackParam = value;
3968
+ let callbackParams = [value];
3898
3969
  let callbackName = `on${toUpperFirst(stateKey)}Change`;
3899
3970
  if (mappedCallbacks && mappedCallbacks[key]) {
3900
3971
  const res = mappedCallbacks[key](value, state2);
3901
3972
  callbackName = res.callbackName || callbackName;
3902
- callbackParam = res.callbackParam;
3973
+ callbackParams = res.callbackParams;
3903
3974
  }
3904
- notifyChange(props, callbackName, callbackParam);
3975
+ notifyChange(props, callbackName, callbackParams);
3905
3976
  }
3906
3977
  const forwardFn = propsToForward[key];
3907
3978
  if (typeof forwardFn === "function") {
@@ -3966,7 +4037,8 @@ function getComponentStateRoot(config) {
3966
4037
  props,
3967
4038
  state: state2,
3968
4039
  oldState: null,
3969
- parentState
4040
+ parentState,
4041
+ getState: getComponentState
3970
4042
  });
3971
4043
  propsToStateSetRef.current = new Set([
3972
4044
  ...propsToStateSetRef.current,
@@ -4000,7 +4072,8 @@ function getComponentStateRoot(config) {
4000
4072
  props: getProps(),
4001
4073
  state: newState,
4002
4074
  oldState: previousState,
4003
- parentState: parentState2
4075
+ parentState: parentState2,
4076
+ getState: getComponentState
4004
4077
  });
4005
4078
  propsToStateSetRef.current = new Set([
4006
4079
  ...propsToStateSetRef.current,
@@ -4115,20 +4188,20 @@ var useInternalProps = () => {
4115
4188
  };
4116
4189
 
4117
4190
  // src/components/InfiniteTable/utilities.css.ts
4118
- var alignItems = { center: "_16lm1iw1e", stretch: "_16lm1iw1f" };
4119
- var cssEllipsisClassName = "_16lm1iw1p _16lm1iw1q _16lm1iw1j";
4120
- var cursor = { pointer: "_16lm1iwd", colResize: "_16lm1iwe" };
4121
- var display = { flex: "_16lm1iwt", none: "_16lm1iwu", block: "_16lm1iwv", inlineBlock: "_16lm1iww" };
4122
- var flex = { "1": "_16lm1iwg", none: "_16lm1iwh" };
4123
- var flexFlow = { column: "_16lm1iw1c", row: "_16lm1iw1d" };
4124
- var justifyContent = { center: "_16lm1iw1g", start: "_16lm1iw1h", end: "_16lm1iw1i" };
4125
- var left = { "0": "_16lm1iw14", "100%": "_16lm1iw15", auto: "_16lm1iw16" };
4126
- var overflow = { hidden: "_16lm1iw1j", auto: "_16lm1iw1k", visible: "_16lm1iw1l" };
4191
+ var alignItems = { center: "_16lm1iw1h", stretch: "_16lm1iw1i" };
4192
+ var cssEllipsisClassName = "_16lm1iw1s _16lm1iw1t _16lm1iw1m";
4193
+ var cursor = { pointer: "_16lm1iwe", colResize: "_16lm1iwf" };
4194
+ var display = { flex: "_16lm1iwu", none: "_16lm1iwv", block: "_16lm1iww", inlineBlock: "_16lm1iwx" };
4195
+ var flex = { "1": "_16lm1iwh", none: "_16lm1iwi" };
4196
+ var flexFlow = { column: "_16lm1iw1d", columnReverse: "_16lm1iw1e", row: "_16lm1iw1f", rowReverse: "_16lm1iw1g" };
4197
+ var justifyContent = { center: "_16lm1iw1j", start: "_16lm1iw1k", end: "_16lm1iw1l" };
4198
+ var left = { "0": "_16lm1iw15", "100%": "_16lm1iw16", auto: "_16lm1iw17" };
4199
+ var overflow = { hidden: "_16lm1iw1m", auto: "_16lm1iw1n", visible: "_16lm1iw1o" };
4127
4200
  var position = { relative: "_16lm1iw1", absolute: "_16lm1iw2", sticky: "_16lm1iw3", fixed: "_16lm1iw4" };
4128
- var top = { "0": "_16lm1iw12", "100%": "_16lm1iw13" };
4201
+ var top = { "0": "_16lm1iw13", "100%": "_16lm1iw14" };
4129
4202
  var transformTranslateZero = "_16lm1iwa";
4130
- var userSelect = { none: "_16lm1iwx" };
4131
- var zIndex = { "1": "_16lm1iwi", "10": "_16lm1iwj", "100": "_16lm1iwk", "1000": "_16lm1iwl", "10000": "_16lm1iwm", "100000": "_16lm1iwn", "1000000": "_16lm1iwo", "10000000": "_16lm1iwp", "1k": "_16lm1iwq", "10k": "_16lm1iwr", "100k": "_16lm1iws" };
4203
+ var userSelect = { none: "_16lm1iwy" };
4204
+ var zIndex = { "1": "_16lm1iwj", "10": "_16lm1iwk", "100": "_16lm1iwl", "1000": "_16lm1iwm", "10000": "_16lm1iwn", "100000": "_16lm1iwo", "1000000": "_16lm1iwp", "10000000": "_16lm1iwq", "1k": "_16lm1iwr", "10k": "_16lm1iws", "100k": "_16lm1iwt" };
4132
4205
 
4133
4206
  // src/components/InfiniteTable/components/InfiniteTableBody/InfiniteTableBody.tsx
4134
4207
  var InfiniteTableBody = React14.forwardRef(function InfiniteTableBody2(props, ref) {
@@ -4217,6 +4290,7 @@ var defaultFilterTypes = getFilterTypes();
4217
4290
 
4218
4291
  // src/components/InfiniteTable/hooks/useCellClassName.ts
4219
4292
  function useCellClassName(column, baseClasses, variants, extraFlags) {
4293
+ var _a;
4220
4294
  const result = [...baseClasses];
4221
4295
  const variantObject = {
4222
4296
  filtered: column.computedFiltered,
@@ -4226,7 +4300,7 @@ function useCellClassName(column, baseClasses, variants, extraFlags) {
4226
4300
  firstInCategory: column.computedFirstInCategory,
4227
4301
  lastInCategory: column.computedLastInCategory,
4228
4302
  pinned: column.computedPinned || false,
4229
- rowSelected: extraFlags.rowSelected,
4303
+ rowSelected: (_a = extraFlags.rowSelected) != null ? _a : "null",
4230
4304
  rowActive: extraFlags.rowActive,
4231
4305
  dragging: extraFlags.dragging,
4232
4306
  zebra: extraFlags.zebra
@@ -4281,14 +4355,14 @@ var useInfiniteTable = () => {
4281
4355
  // src/components/InfiniteTable/InfiniteCls.css.ts
4282
4356
  var import_createRuntimeFn = __toModule(require_vanilla_extract_recipes_createRuntimeFn_cjs());
4283
4357
  var FooterCls = "_16lm1iw1";
4284
- var InfiniteCls = "_1yeub2v0 _16lm1iw1 _16lm1iwt _16lm1iw1c _16lm1iw0";
4358
+ var InfiniteCls = "_1yeub2v0 _16lm1iw1 _16lm1iwu _16lm1iw1d _16lm1iw0";
4285
4359
  var InfiniteClsHasPinnedEnd = "_1yeub2vo";
4286
4360
  var InfiniteClsHasPinnedStart = "_1yeub2vn";
4287
4361
  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"]] });
4288
4362
  var InfiniteClsShiftingColumns = "_1yeub2vl";
4289
- var PinnedEndIndicatorBorder = "_1yeub2vr _1yeub2vp _16lm1iw2 _16lm1iw12 _16lm1iwe _16lm1iwx _16lm1iw10 _16lm1iw1n _16lm1iwf _16lm1iwp";
4363
+ var PinnedEndIndicatorBorder = "_1yeub2vr _1yeub2vp _16lm1iw2 _16lm1iw13 _16lm1iwf _16lm1iwy _16lm1iw11 _16lm1iw1q _16lm1iwg _16lm1iwq";
4290
4364
  var PinnedRowsContainerClsVariants = (0, import_createRuntimeFn.createRuntimeFn)({ defaultClassName: "", variantClassNames: { pinned: { start: "_1yeub2vi", end: "_1yeub2vj", false: "_1yeub2vk" } }, defaultVariants: {}, compoundVariants: [] });
4291
- var PinnedStartIndicatorBorder = "_1yeub2vq _1yeub2vp _16lm1iw2 _16lm1iw12 _16lm1iwe _16lm1iwx _16lm1iw10 _16lm1iw1n _16lm1iwf _16lm1iwp";
4365
+ var PinnedStartIndicatorBorder = "_1yeub2vq _1yeub2vp _16lm1iw2 _16lm1iw13 _16lm1iwf _16lm1iwy _16lm1iw11 _16lm1iw1q _16lm1iwg _16lm1iwq";
4292
4366
 
4293
4367
  // src/components/utils/getScrollbarWidth.ts
4294
4368
  var scrollbarWidth;
@@ -4866,6 +4940,9 @@ var useColumnPointerEvents = ({
4866
4940
  } = useInfiniteTable();
4867
4941
  const onPointerDown = (0, import_react16.useCallback)((e) => {
4868
4942
  var _a2;
4943
+ if (e.target.tagName === "INPUT") {
4944
+ return;
4945
+ }
4869
4946
  const {
4870
4947
  computedVisibleColumns,
4871
4948
  computedVisibleColumnsMap,
@@ -4874,6 +4951,9 @@ var useColumnPointerEvents = ({
4874
4951
  computedPinnedEndColumns
4875
4952
  } = getComputed();
4876
4953
  const dragColumn = computedVisibleColumnsMap.get(columnId);
4954
+ if (!dragColumn.computedDraggable) {
4955
+ return;
4956
+ }
4877
4957
  const target = domRef.current;
4878
4958
  const targetRect = target.getBoundingClientRect();
4879
4959
  const tableRect = rootRef.current.getBoundingClientRect();
@@ -4991,8 +5071,8 @@ function objectValuesExcept(obj, exceptList) {
4991
5071
 
4992
5072
  // src/components/InfiniteTable/components/cell.css.ts
4993
5073
  var import_createRuntimeFn2 = __toModule(require_vanilla_extract_recipes_createRuntimeFn_cjs());
4994
- var ColumnCellCls = "_1eexc2a6 _1eexc2a5 _16lm1iwt _16lm1iw1d _16lm1iw1e _16lm1iw2 _16lm1iw1o _16lm1iw1p _16lm1iwx";
4995
- 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"]] });
5074
+ var ColumnCellCls = "_1eexc2a6 _1eexc2a5 _16lm1iwu _16lm1iw1f _16lm1iw1h _16lm1iw2 _16lm1iw1r _16lm1iw1s _16lm1iwy";
5075
+ 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"]] });
4996
5076
  var SelectionCheckboxCls = "_1eexc2a7";
4997
5077
 
4998
5078
  // src/components/InfiniteTable/components/CheckBox.tsx
@@ -5000,7 +5080,7 @@ var React16 = __toModule(require("react"));
5000
5080
  var import_react17 = __toModule(require("react"));
5001
5081
 
5002
5082
  // src/components/InfiniteTable/components/CheckBox.css.ts
5003
- var CheckBoxCls = "_16lm1iwd";
5083
+ var CheckBoxCls = "_16lm1iwe";
5004
5084
 
5005
5085
  // src/components/InfiniteTable/components/CheckBox.tsx
5006
5086
  function forwardProps2() {
@@ -5015,7 +5095,7 @@ var InfiniteCheckBoxRoot = getComponentStateRoot({
5015
5095
  checked: (checked) => {
5016
5096
  return {
5017
5097
  callbackName: "onChange",
5018
- callbackParam: checked
5098
+ callbackParams: [checked]
5019
5099
  };
5020
5100
  }
5021
5101
  },
@@ -5136,7 +5216,7 @@ var defaultRenderSelectionCheckBox = (params) => {
5136
5216
  deselectCurrentRow();
5137
5217
  }
5138
5218
  },
5139
- checked: rowInfo.isGroupRow ? !rowInfo.rowSelected ? rowInfo.childrenSelectedCount > 0 ? null : false : true : rowInfo.rowSelected
5219
+ checked: rowInfo.rowSelected
5140
5220
  });
5141
5221
  };
5142
5222
  function isColumnWithField(c) {
@@ -5155,6 +5235,7 @@ function InfiniteTableColumnCellFn(props) {
5155
5235
  toggleGroupRow,
5156
5236
  rowIndex,
5157
5237
  rowHeight,
5238
+ columnsMap,
5158
5239
  domRef,
5159
5240
  hidden,
5160
5241
  showZebraRows
@@ -5230,23 +5311,24 @@ function InfiniteTableColumnCellFn(props) {
5230
5311
  }, rest);
5231
5312
  const renderParam = __spreadProps(__spreadValues({
5232
5313
  column,
5314
+ columnsMap,
5233
5315
  domRef,
5234
5316
  groupRowInfo
5235
5317
  }, rest), {
5236
5318
  selectionMode,
5237
- selectRow: imperativeApi.selectRow,
5238
- deselectRow: imperativeApi.deselectRow,
5239
- toggleRowSelection: imperativeApi.toggleRowSelection,
5319
+ selectRow: imperativeApi.selectionApi.selectRow,
5320
+ deselectRow: imperativeApi.selectionApi.deselectRow,
5321
+ toggleRowSelection: imperativeApi.selectionApi.toggleRowSelection,
5240
5322
  renderBag: {
5241
5323
  value,
5242
5324
  selectionCheckBox: null,
5243
5325
  groupIcon: null
5244
5326
  },
5245
5327
  selectCurrentRow: (0, import_react18.useCallback)(() => {
5246
- return imperativeApi.selectRow(rowInfo.id);
5328
+ return imperativeApi.selectionApi.selectRow(rowInfo.id, rowInfo.dataSourceHasGrouping ? rowInfo.groupKeys : void 0);
5247
5329
  }, [rowInfo]),
5248
5330
  deselectCurrentRow: (0, import_react18.useCallback)(() => {
5249
- return imperativeApi.deselectRow(rowInfo.id);
5331
+ return imperativeApi.selectionApi.deselectRow(rowInfo.id, rowInfo.dataSourceHasGrouping ? rowInfo.groupKeys : void 0);
5250
5332
  }, [rowInfo]),
5251
5333
  rowIndex,
5252
5334
  toggleGroupRow,
@@ -5257,7 +5339,10 @@ function InfiniteTableColumnCellFn(props) {
5257
5339
  toggleGroupRow(rowInfo.groupKeys);
5258
5340
  }, [rowInfo]),
5259
5341
  toggleCurrentGroupRowSelection: (0, import_react18.useCallback)(() => {
5260
- return imperativeApi.toggleGroupRowSelection(rowInfo.isGroupRow ? rowInfo.groupKeys : []);
5342
+ if (!rowInfo.isGroupRow) {
5343
+ return;
5344
+ }
5345
+ return imperativeApi.selectionApi.toggleGroupRowSelection(rowInfo.isGroupRow ? rowInfo.groupKeys : []);
5261
5346
  }, [rowInfo]),
5262
5347
  groupBy: computedDataSource.groupBy,
5263
5348
  pivotBy: computedDataSource.pivotBy
@@ -5274,7 +5359,7 @@ function InfiniteTableColumnCellFn(props) {
5274
5359
  })
5275
5360
  });
5276
5361
  }
5277
- if (column.renderSelectionCheckBox) {
5362
+ if (column.renderSelectionCheckBox && selectionMode == "multi-row") {
5278
5363
  renderParam.renderBag.selectionCheckBox = /* @__PURE__ */ React18.createElement(RenderCellHookComponent, {
5279
5364
  render: defaultRenderSelectionCheckBox,
5280
5365
  renderParam
@@ -5318,7 +5403,7 @@ function InfiniteTableColumnCellFn(props) {
5318
5403
  renderParam
5319
5404
  });
5320
5405
  }
5321
- return /* @__PURE__ */ React18.createElement(React18.Fragment, null, renderParam.renderBag.groupIcon, renderParam.renderBag.selectionCheckBox, renderParam.renderBag.value);
5406
+ return /* @__PURE__ */ React18.createElement(React18.Fragment, 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);
5322
5407
  }, [
5323
5408
  column,
5324
5409
  hidden,
@@ -5376,6 +5461,15 @@ function RenderCellHookComponent(props) {
5376
5461
  renderParam: props.renderParam
5377
5462
  }));
5378
5463
  }
5464
+ function RenderHeaderCellHookComponent(props) {
5465
+ const ContextProvider = InfiniteTableHeaderCellContext.Provider;
5466
+ return /* @__PURE__ */ React19.createElement(ContextProvider, {
5467
+ value: props.renderParam
5468
+ }, /* @__PURE__ */ React19.createElement(RenderHookComponent, {
5469
+ render: props.render,
5470
+ renderParam: props.renderParam
5471
+ }));
5472
+ }
5379
5473
 
5380
5474
  // src/components/InfiniteTable/components/FilterEditors.tsx
5381
5475
  var React20 = __toModule(require("react"));
@@ -5419,19 +5513,19 @@ var import_react19 = __toModule(require("react"));
5419
5513
 
5420
5514
  // src/components/InfiniteTable/components/InfiniteTableHeader/header.css.ts
5421
5515
  var import_createRuntimeFn3 = __toModule(require_vanilla_extract_recipes_createRuntimeFn_cjs());
5422
- var CellCls = "_1eexc2a5 _16lm1iwt _16lm1iw1d _16lm1iw1e _16lm1iw2 _16lm1iw1o _16lm1iw1p _16lm1iwx";
5423
- var HeaderCellContentRecipe = (0, import_createRuntimeFn3.createRuntimeFn)({ defaultClassName: "_12zfob11d _16lm1iwz _16lm1iw11 _16lm1iwt _16lm1iw1d _16lm1iw1e", variantClassNames: { filtered: { false: "_12zfob11e", true: "_12zfob11f" } }, defaultVariants: {}, compoundVariants: [] });
5424
- var HeaderCellProxy = "_12zfob1k _16lm1iw1p _16lm1iw1q _16lm1iw1j";
5425
- 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"]] });
5426
- 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"]] });
5427
- var HeaderFilterCls = "_12zfob11i _16lm1iwt _16lm1iw1d _16lm1iw1e _16lm1iw1";
5428
- var HeaderFilterEditorCls = "_16lm1iw11 _16lm1iwz";
5429
- var HeaderGroupCls = "_12zfob11h _16lm1iwt _16lm1iw1d _16lm1iw1e";
5516
+ var CellCls = "_1eexc2a5 _16lm1iwu _16lm1iw1f _16lm1iw1h _16lm1iw2 _16lm1iw1r _16lm1iw1s _16lm1iwy";
5517
+ var HeaderCellContentRecipe = (0, import_createRuntimeFn3.createRuntimeFn)({ defaultClassName: "_12zfob11e _16lm1iw10 _16lm1iw12 _16lm1iwu _16lm1iw1f _16lm1iw1h", variantClassNames: { filtered: { false: "_12zfob11f", true: "_12zfob11g" } }, defaultVariants: {}, compoundVariants: [] });
5518
+ var HeaderCellProxy = "_12zfob1k _16lm1iw1s _16lm1iw1t _16lm1iw1m";
5519
+ 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"]] });
5520
+ 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"]] });
5521
+ var HeaderFilterCls = "_12zfob11j _16lm1iwu _16lm1iw1f _16lm1iw1h _16lm1iw1";
5522
+ var HeaderFilterEditorCls = "_16lm1iw12 _16lm1iw10";
5523
+ var HeaderGroupCls = "_12zfob11i _16lm1iwu _16lm1iw1f _16lm1iw1h";
5430
5524
  var HeaderScrollbarPlaceholderCls = "_12zfob15 _16lm1iw2";
5431
5525
  var HeaderSortIconCls = "_16lm1iw1";
5432
5526
  var HeaderSortIconIndexCls = "_12zfob14";
5433
5527
  var HeaderSortIconRecipe = (0, import_createRuntimeFn3.createRuntimeFn)({ defaultClassName: "", variantClassNames: { align: { start: "_12zfob11", center: "_12zfob12", end: "_12zfob13" } }, defaultVariants: {}, compoundVariants: [] });
5434
- var HeaderWrapperCls = "_12zfob11g _16lm1iw1j _16lm1iw1 _16lm1iwt _16lm1iw1d";
5528
+ var HeaderWrapperCls = "_12zfob11h _16lm1iw1m _16lm1iw1 _16lm1iwu _16lm1iw1f";
5435
5529
 
5436
5530
  // src/components/InfiniteTable/components/icons/SortIcon.tsx
5437
5531
  var defaultLineStyle = {
@@ -5994,9 +6088,9 @@ function getColumnGroupResizer(colIndexes, config) {
5994
6088
 
5995
6089
  // src/components/InfiniteTable/components/InfiniteTableHeader/ResizeHandle/ResizeHandle.css.ts
5996
6090
  var import_createRuntimeFn4 = __toModule(require_vanilla_extract_recipes_createRuntimeFn_cjs());
5997
- var ResizeHandleCls = "zneyzh0 _16lm1iw2 _16lm1iw12 _16lm1iw19 _16lm1iw17 _16lm1iwe _16lm1iw1j";
5998
- var ResizeHandleDraggerClsRecipe = (0, import_createRuntimeFn4.createRuntimeFn)({ defaultClassName: "zneyzhb _16lm1iw2 _16lm1iw12 _16lm1iw17", variantClassNames: { constrained: { false: "zneyzhc", true: "zneyzhd" } }, defaultVariants: {}, compoundVariants: [] });
5999
- 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"]] });
6091
+ var ResizeHandleCls = "zneyzh0 _16lm1iw2 _16lm1iw13 _16lm1iw1a _16lm1iw18 _16lm1iwf _16lm1iw1m";
6092
+ var ResizeHandleDraggerClsRecipe = (0, import_createRuntimeFn4.createRuntimeFn)({ defaultClassName: "zneyzhb _16lm1iw2 _16lm1iw13 _16lm1iw18", variantClassNames: { constrained: { false: "zneyzhc", true: "zneyzhd" } }, defaultVariants: {}, compoundVariants: [] });
6093
+ 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"]] });
6000
6094
 
6001
6095
  // src/components/InfiniteTable/components/InfiniteTableHeader/ResizeHandle/index.tsx
6002
6096
  var { rootClassName: rootClassName8 } = internalProps;
@@ -6139,6 +6233,23 @@ function useColumnResizeHandle(column) {
6139
6233
  }
6140
6234
 
6141
6235
  // src/components/InfiniteTable/components/InfiniteTableHeader/InfiniteTableHeaderCell.tsx
6236
+ var defaultRenderSelectionCheckBox2 = (params) => {
6237
+ const { allRowsSelected, someRowsSelected, api } = params;
6238
+ const selected = allRowsSelected ? true : someRowsSelected ? null : false;
6239
+ return /* @__PURE__ */ React25.createElement(InfiniteCheckBox, {
6240
+ domProps: {
6241
+ className: SelectionCheckboxCls
6242
+ },
6243
+ onChange: (selected2) => {
6244
+ if (selected2) {
6245
+ api.selectionApi.selectAll();
6246
+ } else {
6247
+ api.selectionApi.deselectAll();
6248
+ }
6249
+ },
6250
+ checked: selected
6251
+ });
6252
+ };
6142
6253
  var InfiniteTableHeaderCellContext = React25.createContext(null);
6143
6254
  var { rootClassName: rootClassName9 } = internalProps;
6144
6255
  var InfiniteTableHeaderCellClassName = `${rootClassName9}HeaderCell`;
@@ -6148,6 +6259,7 @@ function InfiniteTableHeaderCell(props) {
6148
6259
  const column = props.column;
6149
6260
  const {
6150
6261
  computed: { showColumnFilters },
6262
+ imperativeApi: api,
6151
6263
  componentState: {
6152
6264
  portalDOMRef,
6153
6265
  columnHeaderHeight,
@@ -6155,8 +6267,9 @@ function InfiniteTableHeaderCell(props) {
6155
6267
  columnReorderDragColumnId
6156
6268
  }
6157
6269
  } = useInfiniteTable();
6270
+ const { allRowsSelected, someRowsSelected, selectionMode } = useDataSource();
6158
6271
  const dragging = columnReorderDragColumnId === column.id;
6159
- const { onResize, height, width, headerOptions } = props;
6272
+ const { onResize, height, width, headerOptions, columnsMap } = props;
6160
6273
  const sortInfo = column.computedSortInfo;
6161
6274
  let header = column.header;
6162
6275
  const ref = (0, import_react23.useCallback)((node) => {
@@ -6165,7 +6278,7 @@ function InfiniteTableHeaderCell(props) {
6165
6278
  (_a2 = props.domRef) == null ? void 0 : _a2.call(props, node);
6166
6279
  }, [props.domRef]);
6167
6280
  const alwaysShow = headerOptions.alwaysReserveSpaceForSortIcon;
6168
- const sortTool = column.computedSortable && (column.computedSorted || alwaysShow) ? /* @__PURE__ */ React25.createElement(SortIcon, {
6281
+ const sortIcon = column.computedSortable && (column.computedSorted || alwaysShow) ? /* @__PURE__ */ React25.createElement(SortIcon, {
6169
6282
  index: column.computedMultiSort ? column.computedSortIndex + 1 : void 0,
6170
6283
  className: `${InfiniteTableHeaderCellClassName}__sort-icon ${HeaderSortIconCls} ${HeaderSortIconRecipe({
6171
6284
  align: column.align || "start"
@@ -6176,20 +6289,58 @@ function InfiniteTableHeaderCell(props) {
6176
6289
  dragging,
6177
6290
  domRef: ref,
6178
6291
  column,
6292
+ columnsMap,
6179
6293
  columnSortInfo: sortInfo,
6180
6294
  columnFilterValue: column.computedFilterValue,
6181
- sortTool
6295
+ someRowsSelected,
6296
+ allRowsSelected,
6297
+ selectionMode,
6298
+ api,
6299
+ renderBag: {
6300
+ sortIcon,
6301
+ selectionCheckBox: null,
6302
+ header: column.header && typeof column.header !== "function" ? column.header : column.name
6303
+ }
6182
6304
  };
6183
6305
  const align = column.align || "start";
6184
6306
  const renderChildren = () => {
6307
+ if (column.renderSortIcon) {
6308
+ renderParam.renderBag.sortIcon = /* @__PURE__ */ React25.createElement(RenderHeaderCellHookComponent, {
6309
+ render: column.renderSortIcon,
6310
+ renderParam: __spreadProps(__spreadValues({}, renderParam), {
6311
+ renderBag: __spreadValues({}, renderParam.renderBag)
6312
+ })
6313
+ });
6314
+ }
6315
+ if (column.renderSelectionCheckBox && selectionMode === "multi-row") {
6316
+ renderParam.renderBag.selectionCheckBox = /* @__PURE__ */ React25.createElement(RenderHeaderCellHookComponent, {
6317
+ render: defaultRenderSelectionCheckBox2,
6318
+ renderParam
6319
+ });
6320
+ if (column.renderHeaderSelectionCheckBox && column.renderHeaderSelectionCheckBox !== true) {
6321
+ renderParam.renderBag.selectionCheckBox = /* @__PURE__ */ React25.createElement(RenderHeaderCellHookComponent, {
6322
+ render: column.renderHeaderSelectionCheckBox,
6323
+ renderParam: __spreadProps(__spreadValues({}, renderParam), {
6324
+ renderBag: __spreadValues({}, renderParam.renderBag)
6325
+ })
6326
+ });
6327
+ }
6328
+ }
6185
6329
  if (header instanceof Function) {
6186
- header = /* @__PURE__ */ React25.createElement(RenderHookComponent, {
6330
+ renderParam.renderBag.header = /* @__PURE__ */ React25.createElement(RenderHookComponent, {
6187
6331
  render: header,
6332
+ renderParam: __spreadProps(__spreadValues({}, renderParam), {
6333
+ renderBag: __spreadValues({}, renderParam.renderBag)
6334
+ })
6335
+ });
6336
+ }
6337
+ if (column.renderHeader) {
6338
+ return /* @__PURE__ */ React25.createElement(RenderHeaderCellHookComponent, {
6339
+ render: column.renderHeader,
6188
6340
  renderParam
6189
6341
  });
6190
6342
  }
6191
- header = header != null ? header : column.name;
6192
- return /* @__PURE__ */ React25.createElement(React25.Fragment, null, align === "end" ? sortTool : null, header, align !== "end" ? sortTool : null);
6343
+ return /* @__PURE__ */ React25.createElement(React25.Fragment, 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);
6193
6344
  };
6194
6345
  const domRef = (0, import_react23.useRef)(null);
6195
6346
  const {
@@ -6711,7 +6862,7 @@ function InfiniteTableHeaderFn(props) {
6711
6862
  headerOptions,
6712
6863
  width: widthWithColspan,
6713
6864
  height: heightWithRowspan,
6714
- columns: computedVisibleColumnsMap
6865
+ columnsMap: computedVisibleColumnsMap
6715
6866
  });
6716
6867
  }, [
6717
6868
  headerOptions,
@@ -6910,7 +7061,7 @@ var InfiniteTableLicenseFooter = React31.forwardRef(function InfiniteTableLicens
6910
7061
 
6911
7062
  // src/components/InfiniteTable/components/InfiniteTableRow/row.css.ts
6912
7063
  var import_createRuntimeFn5 = __toModule(require_vanilla_extract_recipes_createRuntimeFn_cjs());
6913
- var GroupRowExpanderCls = "_7pupv0b";
7064
+ var GroupRowExpanderCls = (0, import_createRuntimeFn5.createRuntimeFn)({ defaultClassName: "", variantClassNames: { align: { start: "_7pupv0b", center: "_7pupv0c", end: "_7pupv0d" } }, defaultVariants: {}, compoundVariants: [] });
6914
7065
  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: [] });
6915
7066
  var RowHoverCls = "_7pupv01";
6916
7067
 
@@ -6918,8 +7069,8 @@ var RowHoverCls = "_7pupv01";
6918
7069
  var React32 = __toModule(require("react"));
6919
7070
 
6920
7071
  // src/components/InfiniteTable/components/LoadMask.css.ts
6921
- var LoadMaskCls = { visible: "qy58ya1 qy58ya0 _16lm1iw2 _16lm1iw12 _16lm1iw14 _16lm1iw19 _16lm1iw17", hidden: "qy58ya2 qy58ya0 _16lm1iw2 _16lm1iw12 _16lm1iw14 _16lm1iw19 _16lm1iw17" };
6922
- var LoadMaskOverlayCls = "qy58ya3 _16lm1iw2 _16lm1iw12 _16lm1iw14 _16lm1iw19 _16lm1iw17";
7072
+ var LoadMaskCls = { visible: "qy58ya1 qy58ya0 _16lm1iw2 _16lm1iw13 _16lm1iw15 _16lm1iw1a _16lm1iw18", hidden: "qy58ya2 qy58ya0 _16lm1iw2 _16lm1iw13 _16lm1iw15 _16lm1iw1a _16lm1iw18" };
7073
+ var LoadMaskOverlayCls = "qy58ya3 _16lm1iw2 _16lm1iw13 _16lm1iw15 _16lm1iw1a _16lm1iw18";
6923
7074
  var LoadMaskTextCls = "qy58ya4";
6924
7075
 
6925
7076
  // src/components/InfiniteTable/components/LoadMask.tsx
@@ -6937,9 +7088,38 @@ function LoadMaskFn(props) {
6937
7088
  }
6938
7089
  var LoadMask = React32.memo(LoadMaskFn);
6939
7090
 
7091
+ // src/utils/deepClone.ts
7092
+ function cloneArray(arr) {
7093
+ return arr.map(deepClone);
7094
+ }
7095
+ function deepClone(source) {
7096
+ if (getGlobal().structuredClone) {
7097
+ return getGlobal().structuredClone(source);
7098
+ }
7099
+ if (source === null || typeof source !== "object") {
7100
+ return source;
7101
+ }
7102
+ if (Array.isArray(source)) {
7103
+ return cloneArray(source);
7104
+ }
7105
+ if (source instanceof Date) {
7106
+ return new Date(source);
7107
+ }
7108
+ if (source instanceof Set) {
7109
+ return new Set(cloneArray(Array.from(source)));
7110
+ }
7111
+ if (source instanceof Map) {
7112
+ return new Map(cloneArray(Array.from(source)));
7113
+ }
7114
+ let target = {};
7115
+ for (let key in source)
7116
+ if (source.hasOwnProperty(key)) {
7117
+ target[key] = deepClone(source[key]);
7118
+ }
7119
+ return target;
7120
+ }
7121
+
6940
7122
  // src/utils/groupAndPivot/index.ts
6941
- var GROUP_SELECTED_REDUCER_KEY = "__groupFullySelected";
6942
- var GROUP_CHILDREN_SELECTED_COUNT_KEY = "__groupChildrenSelectedCount";
6943
7123
  var LAZY_ROOT_KEY_FOR_GROUPS = "____root____";
6944
7124
  var NOT_LOADED_YET_KEY_PREFIX = "____not_loaded_yet____";
6945
7125
  function DEFAULT_TO_KEY(value) {
@@ -6956,7 +7136,7 @@ function initReducers(reducers) {
6956
7136
  }
6957
7137
  return result;
6958
7138
  }
6959
- function computeReducersFor(data, index, reducers, reducerResults) {
7139
+ function computeReducersFor(data, index, reducers, reducerResults, groupKeys) {
6960
7140
  var _a, _b;
6961
7141
  if (!reducers || !Object.keys(reducers).length) {
6962
7142
  return;
@@ -6969,7 +7149,7 @@ function computeReducersFor(data, index, reducers, reducerResults) {
6969
7149
  }
6970
7150
  const currentValue = reducerResults[key];
6971
7151
  const value = reducer.field ? data[reducer.field] : (_b = (_a = reducer.getter) == null ? void 0 : _a.call(reducer, data)) != null ? _b : null;
6972
- reducerResults[key] = reducer.reducer(currentValue, value, data, index);
7152
+ reducerResults[key] = reducer.reducer(currentValue, value, data, index, groupKeys);
6973
7153
  }
6974
7154
  }
6975
7155
  function lazyGroup(groupParams, rootData) {
@@ -6977,6 +7157,8 @@ function lazyGroup(groupParams, rootData) {
6977
7157
  reducers = {},
6978
7158
  pivot,
6979
7159
  groupBy,
7160
+ indexer,
7161
+ toPrimaryKey,
6980
7162
  mappings
6981
7163
  } = groupParams;
6982
7164
  const deepMap = new DeepMap();
@@ -7001,7 +7183,7 @@ function lazyGroup(groupParams, rootData) {
7001
7183
  const topLevelPivotColumns = pivot ? new DeepMap() : void 0;
7002
7184
  const currentPivotKeys = [];
7003
7185
  const initialReducerValue = initReducers(reducers);
7004
- const globalReducerResults = __spreadValues({}, initialReducerValue);
7186
+ const globalReducerResults = deepClone(initialReducerValue);
7005
7187
  rootData.visitDepthFirst((lazyGroupRowInfo, keys, _index, next) => {
7006
7188
  const [_rootKey, ...currentGroupKeys] = keys;
7007
7189
  const dataArray = lazyGroupRowInfo.children;
@@ -7015,6 +7197,7 @@ function lazyGroup(groupParams, rootData) {
7015
7197
  if (currentGroupKeys.length == groupBy.length && groupBy.length) {
7016
7198
  if (current) {
7017
7199
  current.items = dataArray;
7200
+ indexer.indexArray(dataArray, toPrimaryKey);
7018
7201
  }
7019
7202
  return next == null ? void 0 : next();
7020
7203
  }
@@ -7045,6 +7228,7 @@ function lazyGroup(groupParams, rootData) {
7045
7228
  childrenLoading: false,
7046
7229
  childrenAvailable: false,
7047
7230
  commonData: dataObject,
7231
+ totalChildrenCount: dataArray[i].totalChildrenCount,
7048
7232
  reducerResults: dataArray[i].aggregations || {}
7049
7233
  };
7050
7234
  deepMap.set(currentGroupKeys, deepMapGroupValue);
@@ -7079,7 +7263,7 @@ function processGroup(deepMap, currentGroupKeys, currentPivotKeys, item, itemInd
7079
7263
  } = deepMap.get(currentGroupKeys);
7080
7264
  currentGroupItems.push(item);
7081
7265
  if (reducers) {
7082
- computeReducersFor(item, itemIndex, reducers, reducerResults);
7266
+ computeReducersFor(item, itemIndex, reducers, reducerResults, currentGroupKeys);
7083
7267
  }
7084
7268
  if (pivot) {
7085
7269
  for (let pivotIndex = 0, pivotLength = pivot.length; pivotIndex < pivotLength; pivotIndex++) {
@@ -7089,19 +7273,27 @@ function processGroup(deepMap, currentGroupKeys, currentPivotKeys, item, itemInd
7089
7273
  if (!pivotDeepMap.has(currentPivotKeys)) {
7090
7274
  topLevelPivotColumns.set(currentPivotKeys, true);
7091
7275
  pivotDeepMap == null ? void 0 : pivotDeepMap.set(currentPivotKeys, {
7092
- reducerResults: __spreadValues({}, initialReducerValue),
7276
+ reducerResults: deepClone(initialReducerValue),
7093
7277
  items: []
7094
7278
  });
7095
7279
  }
7096
7280
  const { reducerResults: pivotReducerResults, items: pivotGroupItems } = pivotDeepMap.get(currentPivotKeys);
7097
7281
  pivotGroupItems.push(item);
7098
7282
  if (reducers) {
7099
- computeReducersFor(item, itemIndex, reducers, pivotReducerResults);
7283
+ computeReducersFor(item, itemIndex, reducers, pivotReducerResults, currentGroupKeys);
7100
7284
  }
7101
7285
  }
7102
7286
  currentPivotKeys.length = 0;
7103
7287
  }
7104
7288
  }
7289
+ function getGroupKeysForDataItem(data, groupBy) {
7290
+ return groupBy.reduce((groupKeys, groupBy2) => {
7291
+ const { field: groupByProperty, toKey: groupToKey } = groupBy2;
7292
+ const key = (groupToKey || DEFAULT_TO_KEY)(data[groupByProperty], data);
7293
+ groupKeys.push(key);
7294
+ return groupKeys;
7295
+ }, []);
7296
+ }
7105
7297
  function group(groupParams, data) {
7106
7298
  const {
7107
7299
  groupBy,
@@ -7115,14 +7307,14 @@ function group(groupParams, data) {
7115
7307
  const currentGroupKeys = [];
7116
7308
  const currentPivotKeys = [];
7117
7309
  const initialReducerValue = initReducers(reducers);
7118
- const globalReducerResults = __spreadValues({}, initialReducerValue);
7310
+ const globalReducerResults = deepClone(initialReducerValue);
7119
7311
  if (!groupByLength) {
7120
7312
  const deepMapGroupValue = {
7121
7313
  items: [],
7122
7314
  cache: false,
7123
7315
  childrenLoading: false,
7124
7316
  childrenAvailable: false,
7125
- reducerResults: __spreadValues({}, initialReducerValue)
7317
+ reducerResults: deepClone(initialReducerValue)
7126
7318
  };
7127
7319
  if (pivot) {
7128
7320
  deepMapGroupValue.pivotDeepMap = new DeepMap();
@@ -7141,7 +7333,7 @@ function group(groupParams, data) {
7141
7333
  cache: false,
7142
7334
  childrenLoading: false,
7143
7335
  childrenAvailable: false,
7144
- reducerResults: __spreadValues({}, initialReducerValue)
7336
+ reducerResults: deepClone(initialReducerValue)
7145
7337
  };
7146
7338
  if (pivot) {
7147
7339
  deepMapGroupValue.pivotDeepMap = new DeepMap();
@@ -7154,7 +7346,7 @@ function group(groupParams, data) {
7154
7346
  processGroup(deepMap, currentGroupKeys, currentPivotKeys, item, i, pivot, reducers, topLevelPivotColumns, initialReducerValue, defaultToKey);
7155
7347
  }
7156
7348
  if (reducers) {
7157
- computeReducersFor(item, i, reducers, globalReducerResults);
7349
+ computeReducersFor(item, i, reducers, globalReducerResults, currentGroupKeys);
7158
7350
  }
7159
7351
  currentGroupKeys.length = 0;
7160
7352
  }
@@ -7231,8 +7423,9 @@ function getEnhancedGroupData(options, deepMapValue) {
7231
7423
  groupCount: groupItems.length,
7232
7424
  groupData: groupItems,
7233
7425
  groupKeys,
7234
- rowSelected: !!reducerResults[GROUP_SELECTED_REDUCER_KEY] || false,
7235
- childrenSelectedCount: reducerResults[GROUP_CHILDREN_SELECTED_COUNT_KEY] || 0,
7426
+ rowSelected: false,
7427
+ selectedChildredCount: 0,
7428
+ deselectedChildredCount: 0,
7236
7429
  id: `${groupKeys}`,
7237
7430
  collapsed,
7238
7431
  dataSourceHasGrouping: true,
@@ -7242,6 +7435,7 @@ function getEnhancedGroupData(options, deepMapValue) {
7242
7435
  deepRowInfoArray: [],
7243
7436
  collapsedChildrenCount: 0,
7244
7437
  collapsedGroupsCount: 0,
7438
+ totalChildrenCount: options.totalChildrenCount,
7245
7439
  childrenAvailable: lazyLoad ? options.childrenAvailable : true,
7246
7440
  childrenLoading: options.childrenLoading,
7247
7441
  indexInParentGroups: options.indexInParentGroups,
@@ -7278,7 +7472,7 @@ function enhancedFlatten(param) {
7278
7472
  toPrimaryKey,
7279
7473
  groupRowsState,
7280
7474
  isRowSelected,
7281
- indexer,
7475
+ rowSelectionState,
7282
7476
  generateGroupRows,
7283
7477
  reducers = {}
7284
7478
  } = param;
@@ -7304,13 +7498,21 @@ function enhancedFlatten(param) {
7304
7498
  indexInAll: result.length,
7305
7499
  groupKeys,
7306
7500
  error: deepMapValue.error,
7501
+ totalChildrenCount: deepMapValue.totalChildrenCount,
7307
7502
  childrenLoading: deepMapValue.childrenLoading,
7308
7503
  childrenAvailable: deepMapValue.childrenAvailable,
7309
7504
  directChildrenCount: groupKeys.length === groupByStrings.length ? deepMapValue.items.length : deepMap.getDirectChildrenSizeFor(groupKeys),
7310
7505
  directChildrenLoadedCount: 0,
7311
7506
  collapsed
7312
7507
  }, deepMapValue);
7313
- indexer.add(enhancedGroupData.indexInAll, enhancedGroupData.id);
7508
+ if (isRowSelected) {
7509
+ enhancedGroupData.rowSelected = isRowSelected(enhancedGroupData);
7510
+ if (rowSelectionState) {
7511
+ const selectionCount = rowSelectionState.getSelectionCountFor(enhancedGroupData.groupKeys);
7512
+ enhancedGroupData.selectedChildredCount = selectionCount.selectedCount;
7513
+ enhancedGroupData.deselectedChildredCount = selectionCount.deselectedCount;
7514
+ }
7515
+ }
7314
7516
  const parent = parents[parents.length - 1];
7315
7517
  const parentCollapsed = (_b = parent == null ? void 0 : parent.collapsed) != null ? _b : false;
7316
7518
  let include = generateGroupRows || collapsed;
@@ -7373,7 +7575,6 @@ function enhancedFlatten(param) {
7373
7575
  if (isRowSelected) {
7374
7576
  rowInfo.rowSelected = isRowSelected(rowInfo);
7375
7577
  }
7376
- indexer.add(rowInfo.indexInAll, rowInfo.id);
7377
7578
  parents.forEach((parent2, i) => {
7378
7579
  const last = i === parents.length - 1;
7379
7580
  if (last && item) {
@@ -8172,212 +8373,540 @@ function lazyLoadRange(options, cache) {
8172
8373
  }, initialPromise);
8173
8374
  }
8174
8375
 
8175
- // src/components/DataSource/BooleanCollectionState.ts
8176
- var BooleanCollectionState = class {
8177
- constructor(state) {
8376
+ // src/components/DataSource/RowSelectionState.ts
8377
+ var RowSelectionState = class {
8378
+ constructor(state, getConfig, _forTestingOnly) {
8379
+ this.selectedRows = null;
8380
+ this.deselectedRows = null;
8381
+ this.defaultSelection = false;
8382
+ this.selectedMap = new DeepMap();
8383
+ this.deselectedMap = new DeepMap();
8384
+ this.selectionCache = new DeepMap();
8385
+ this.selectionCountCache = new DeepMap();
8386
+ this.mapSet = (name, key) => {
8387
+ if (!Array.isArray(key)) {
8388
+ key = [...this.getGroupKeysForPrimaryKey(key), key];
8389
+ }
8390
+ this.xcache();
8391
+ if (name === "selected") {
8392
+ this.selectedMap.set(key, true);
8393
+ } else {
8394
+ this.deselectedMap.set(key, true);
8395
+ }
8396
+ };
8397
+ this._selectedMapSet = (key) => {
8398
+ this.mapSet("selected", key);
8399
+ };
8400
+ this._deselectedMapSet = (key) => {
8401
+ this.mapSet("deselected", key);
8402
+ };
8178
8403
  const stateObject = state instanceof Object.getPrototypeOf(this).constructor ? state.getState() : state;
8179
- const positiveItems = this.getPositiveFromState(stateObject);
8180
- const negativeItems = this.getNegativeFromState(stateObject);
8181
- this.update({
8182
- negativeItems,
8183
- positiveItems
8184
- });
8404
+ this.getConfig = getConfig;
8405
+ if (_forTestingOnly) {
8406
+ Object.assign(this, _forTestingOnly);
8407
+ }
8408
+ this.update(stateObject);
8185
8409
  }
8186
- getInitialState() {
8187
- return this.initialState;
8410
+ getGroupKeysForPrimaryKey(pk) {
8411
+ const { indexer, groupBy } = this.getConfig();
8412
+ const data = indexer.getDataForPrimaryKey(pk);
8413
+ return data ? getGroupKeysForDataItem(data, groupBy) : [];
8188
8414
  }
8189
- destroy() {
8190
- var _a, _b;
8191
- (_a = this.positiveMap) == null ? void 0 : _a.clear();
8192
- (_b = this.negativeMap) == null ? void 0 : _b.clear();
8193
- delete this.positiveMap;
8194
- delete this.negativeMap;
8415
+ getGroupDeepMap() {
8416
+ return this.getConfig().groupDeepMap;
8195
8417
  }
8196
- update(state) {
8197
- const { positiveItems, negativeItems } = state;
8198
- this.allNegative = negativeItems === true;
8199
- this.allPositive = positiveItems === true;
8200
- if (this.allNegative && this.allPositive) {
8201
- throw `Cannot have both negativeItems and positiveItems be true!`;
8202
- }
8203
- if (negativeItems && negativeItems !== true) {
8204
- if (!this.negativeMap) {
8205
- this.negativeMap = new Map();
8206
- }
8207
- this.negativeMap.clear();
8208
- for (let k in negativeItems) {
8209
- if (negativeItems.hasOwnProperty(k)) {
8210
- this.negativeMap.set(k, true);
8211
- }
8212
- }
8213
- if (this.positiveMap) {
8214
- this.positiveMap.clear();
8215
- }
8418
+ getGroupCount(groupKeys) {
8419
+ var _a;
8420
+ if (groupKeys.length == 0) {
8421
+ return this.getConfig().totalCount;
8216
8422
  }
8217
- if (positiveItems && positiveItems !== true) {
8218
- if (!this.positiveMap) {
8219
- this.positiveMap = new Map();
8220
- }
8221
- this.positiveMap.clear();
8222
- for (let k in positiveItems) {
8223
- if (positiveItems.hasOwnProperty(k)) {
8224
- this.positiveMap.set(k, true);
8225
- }
8226
- }
8227
- if (this.negativeMap) {
8228
- this.negativeMap.clear();
8229
- }
8423
+ const groupDeepMap = this.getGroupDeepMap();
8424
+ const deepMapValue = groupDeepMap == null ? void 0 : groupDeepMap.get(groupKeys);
8425
+ if (!deepMapValue) {
8426
+ return 0;
8230
8427
  }
8428
+ return (_a = deepMapValue.totalChildrenCount) != null ? _a : deepMapValue.items.length || 0;
8231
8429
  }
8232
- isDefaultNegativeSelection() {
8233
- return this.allNegative;
8430
+ getGroupKeysDirectlyInsideGroup(groupKeys) {
8431
+ const { groupDeepMap } = this.getConfig();
8432
+ return (groupDeepMap == null ? void 0 : groupDeepMap.getKeysStartingWith(groupKeys, true, 1)) || [];
8234
8433
  }
8235
- isDefaultPositiveSelection() {
8236
- return this.allPositive;
8434
+ getGroupByLength() {
8435
+ return this.getConfig().groupBy.length;
8237
8436
  }
8238
- areAllNegative() {
8239
- return this.allNegative && (this.positiveMap ? this.positiveMap.size === 0 : true);
8437
+ static from(rowSeleStateObject, getConfig, _forTestingOnly) {
8438
+ return new RowSelectionState(rowSeleStateObject, getConfig, _forTestingOnly);
8240
8439
  }
8241
- areAllPositive() {
8242
- return this.allPositive && (this.negativeMap ? this.negativeMap.size === 0 : true);
8440
+ update(stateObject) {
8441
+ var _a, _b;
8442
+ this.selectedRows = stateObject.selectedRows || null;
8443
+ this.deselectedRows = stateObject.deselectedRows || null;
8444
+ this.selectedMap.clear();
8445
+ this.deselectedMap.clear();
8446
+ (_a = this.selectedRows) == null ? void 0 : _a.forEach(this._selectedMapSet);
8447
+ (_b = this.deselectedRows) == null ? void 0 : _b.forEach(this._deselectedMapSet);
8448
+ this.defaultSelection = stateObject.defaultSelection;
8449
+ this.xcache();
8450
+ }
8451
+ xcache() {
8452
+ this.selectionCache.clear();
8453
+ this.selectionCountCache.clear();
8243
8454
  }
8244
- makeAllNegative() {
8455
+ getState() {
8456
+ const normalize = (allKeys) => {
8457
+ const groupByLength = this.getGroupByLength();
8458
+ return allKeys.map((keys) => keys.length > groupByLength ? keys.pop() : keys);
8459
+ };
8460
+ const selectedRows = normalize(this.selectedMap.topDownKeys());
8461
+ const deselectedRows = normalize(this.deselectedMap.topDownKeys());
8462
+ return {
8463
+ defaultSelection: this.defaultSelection,
8464
+ selectedRows,
8465
+ deselectedRows
8466
+ };
8467
+ }
8468
+ deselectAll() {
8245
8469
  this.update({
8246
- negativeItems: true,
8247
- positiveItems: {}
8470
+ defaultSelection: false,
8471
+ selectedRows: [],
8472
+ deselectedRows: []
8248
8473
  });
8249
8474
  }
8250
- makeAllPositive() {
8475
+ selectAll() {
8251
8476
  this.update({
8252
- positiveItems: true,
8253
- negativeItems: {}
8477
+ defaultSelection: true,
8478
+ deselectedRows: [],
8479
+ selectedRows: []
8254
8480
  });
8255
8481
  }
8256
- isItemPositive(key) {
8257
- var _a, _b;
8258
- key = `${key}`;
8259
- if (this.allPositive === true) {
8260
- if (this.allNegative === true) {
8261
- throw 'Cannot have both positiveItems and negativeItems be "true"';
8262
- }
8263
- return !((_a = this.negativeMap) == null ? void 0 : _a.has(key));
8264
- }
8265
- return !!((_b = this.positiveMap) == null ? void 0 : _b.has(key));
8266
- }
8267
- isItemNegative(key) {
8268
- return !this.isItemPositive(key);
8482
+ isRowDefaultSelected() {
8483
+ return this.defaultSelection === true;
8269
8484
  }
8270
- setItemValue(key, shouldMakePositive) {
8271
- var _a;
8272
- key = `${key}`;
8273
- if (shouldMakePositive === this.isItemPositive(key)) {
8274
- return;
8485
+ isRowDefaultDeselected() {
8486
+ return this.defaultSelection === false;
8487
+ }
8488
+ isRowSelected(key, groupKeys) {
8489
+ groupKeys = groupKeys || this.getGroupKeysForPrimaryKey(key);
8490
+ const finalKey = [...groupKeys, key];
8491
+ const cachedResult = this.selectionCache.get(finalKey);
8492
+ if (cachedResult !== void 0) {
8493
+ return cachedResult;
8494
+ }
8495
+ const inSelected = this.selectedMap.has(finalKey);
8496
+ const inDeselected = this.deselectedMap.has(finalKey);
8497
+ if (inSelected) {
8498
+ this.selectionCache.set(finalKey, true);
8499
+ return true;
8275
8500
  }
8276
- if (shouldMakePositive) {
8277
- if (this.allNegative === true) {
8278
- if (!this.positiveMap) {
8279
- throw `No positiveMap found when trying to set item ${key} be positive`;
8280
- }
8281
- this.positiveMap.set(key, true);
8282
- } else if (this.allPositive === true) {
8283
- if (!this.negativeMap) {
8284
- throw `No negativeMap found when trying to set item ${key} be positive`;
8285
- }
8286
- this.negativeMap.delete(key);
8501
+ if (inDeselected) {
8502
+ this.selectionCache.set(finalKey, false);
8503
+ return false;
8504
+ }
8505
+ if (this.selectedMap.has(groupKeys)) {
8506
+ this.selectionCache.set(finalKey, true);
8507
+ return true;
8508
+ }
8509
+ if (this.deselectedMap.has(groupKeys)) {
8510
+ this.selectionCache.set(finalKey, false);
8511
+ return false;
8512
+ }
8513
+ groupKeys = [...groupKeys];
8514
+ while (groupKeys.length) {
8515
+ groupKeys.pop();
8516
+ const inSelected2 = this.selectedMap.has(groupKeys);
8517
+ const inDeselected2 = this.deselectedMap.has(groupKeys);
8518
+ if (inSelected2) {
8519
+ this.selectionCache.set(finalKey, true);
8520
+ return true;
8287
8521
  }
8288
- } else {
8289
- if (this.allPositive === true) {
8290
- if (!this.negativeMap) {
8291
- throw `No negativeMap found when trying to set item ${key} be negative`;
8292
- }
8293
- this.negativeMap.set(key, true);
8294
- } else if (this.allNegative === true) {
8295
- if (!this.positiveMap) {
8296
- throw `No positiveMap found when trying to set item ${key} be negative`;
8297
- }
8298
- (_a = this.positiveMap) == null ? void 0 : _a.delete(key);
8522
+ if (inDeselected2) {
8523
+ this.selectionCache.set(finalKey, false);
8524
+ return false;
8299
8525
  }
8300
8526
  }
8527
+ this.selectionCache.set(finalKey, this.defaultSelection);
8528
+ return this.defaultSelection;
8301
8529
  }
8302
- makeItemNegative(key) {
8303
- this.setItemValue(key, false);
8304
- }
8305
- makeItemPositive(key) {
8306
- this.setItemValue(key, true);
8307
- }
8308
- toggleItem(key) {
8309
- this.setItemValue(key, !this.isItemPositive(key));
8530
+ isRowDeselected(key, groupKeys) {
8531
+ return !this.isRowSelected(key, groupKeys);
8310
8532
  }
8311
- };
8312
-
8313
- // src/components/DataSource/RowSelectionState.ts
8314
- function reduceKeysToRecord(acc, key) {
8315
- acc[key] = true;
8316
- return acc;
8317
- }
8318
- var RowSelectionState = class extends BooleanCollectionState {
8319
- constructor(state) {
8320
- super(state);
8533
+ setRowSelected(key, selected, groupKeys) {
8534
+ if (selected) {
8535
+ this.setRowAsSelected(key, groupKeys);
8536
+ } else {
8537
+ this.setRowAsDeselected(key, groupKeys);
8538
+ }
8321
8539
  }
8322
- getState() {
8323
- var _a, _b, _c, _d;
8324
- return {
8325
- selectedRows: this.allPositive ? true : (_b = [...((_a = this.positiveMap) == null ? void 0 : _a.keys()) || []].reduce(reduceKeysToRecord, {})) != null ? _b : {},
8326
- deselectedRows: this.allNegative ? true : (_d = [...((_c = this.negativeMap) == null ? void 0 : _c.keys()) || []].reduce(reduceKeysToRecord, {})) != null ? _d : {}
8327
- };
8540
+ getGroupRowSelectionState(initialGroupKeys) {
8541
+ const cachedResult = this.selectionCache.get(initialGroupKeys);
8542
+ if (cachedResult !== void 0) {
8543
+ return cachedResult;
8544
+ }
8545
+ const { selectedCount, deselectedCount } = this.getSelectionCountFor(initialGroupKeys, this.getGroupRowBooleanSelectionStateFromParent(initialGroupKeys));
8546
+ const result = selectedCount && deselectedCount ? null : selectedCount ? true : false;
8547
+ this.selectionCache.set(initialGroupKeys, result);
8548
+ return result;
8328
8549
  }
8329
- getPositiveFromState(state) {
8330
- return state.selectedRows;
8550
+ getGroupRowBooleanSelectionStateFromParent(initialGroupKeys) {
8551
+ if (!initialGroupKeys.length) {
8552
+ return this.defaultSelection;
8553
+ }
8554
+ const groupKeys = [...initialGroupKeys];
8555
+ const selfDeselected = this.deselectedMap.has(groupKeys);
8556
+ const selfSelected = this.selectedMap.has(groupKeys);
8557
+ let selectionState = selfSelected && !selfDeselected ? true : selfDeselected && !selfSelected ? false : void 0;
8558
+ if (selectionState === void 0) {
8559
+ while (groupKeys.length) {
8560
+ groupKeys.pop();
8561
+ if (this.deselectedMap.has(groupKeys)) {
8562
+ selectionState = false;
8563
+ break;
8564
+ }
8565
+ if (this.selectedMap.has(groupKeys)) {
8566
+ selectionState = true;
8567
+ break;
8568
+ }
8569
+ }
8570
+ }
8571
+ if (selectionState === void 0) {
8572
+ selectionState = this.defaultSelection;
8573
+ }
8574
+ return selectionState;
8331
8575
  }
8332
- getNegativeFromState(state) {
8333
- return state.deselectedRows;
8576
+ isGroupRowPartlySelected(groupKeys) {
8577
+ return this.getGroupRowSelectionState(groupKeys) === null;
8334
8578
  }
8335
- areAllSelected() {
8336
- return this.areAllPositive();
8579
+ isGroupRowSelected(groupKeys) {
8580
+ return this.getGroupRowSelectionState(groupKeys) === true;
8337
8581
  }
8338
- areAllDeselected() {
8339
- return this.areAllNegative();
8582
+ isGroupRowDeselected(groupKeys) {
8583
+ return this.getGroupRowSelectionState(groupKeys) === false;
8340
8584
  }
8341
- deselectAll() {
8342
- this.makeAllNegative();
8585
+ selectGroupRow(groupKeys) {
8586
+ const selectedKeys = this.selectedMap.getKeysStartingWith(groupKeys, true);
8587
+ selectedKeys.forEach((groupKeys2) => {
8588
+ this.selectedMap.delete(groupKeys2);
8589
+ });
8590
+ this._selectedMapSet(groupKeys);
8591
+ const deselectedKeys = this.deselectedMap.getKeysStartingWith(groupKeys);
8592
+ deselectedKeys.forEach((groupKeys2) => {
8593
+ this.deselectedMap.delete(groupKeys2);
8594
+ });
8343
8595
  }
8344
- selectAll() {
8345
- this.makeAllPositive();
8596
+ deselectGroupRow(groupKeys) {
8597
+ const deselectedKeys = this.deselectedMap.getKeysStartingWith(groupKeys, true);
8598
+ deselectedKeys.forEach((groupKeys2) => {
8599
+ this.deselectedMap.delete(groupKeys2);
8600
+ });
8601
+ this._deselectedMapSet(groupKeys);
8602
+ const selectedKeys = this.selectedMap.getKeysStartingWith(groupKeys);
8603
+ selectedKeys.forEach((groupKeys2) => {
8604
+ this.selectedMap.delete(groupKeys2);
8605
+ });
8346
8606
  }
8347
- isRowDefaultSelected() {
8348
- return this.isDefaultPositiveSelection();
8607
+ setRowAsSelected(key, groupKeys) {
8608
+ groupKeys = groupKeys || this.getGroupKeysForPrimaryKey(key);
8609
+ const finalKey = [...groupKeys, key];
8610
+ this.deselectedMap.delete(finalKey);
8611
+ this.xcache();
8612
+ if (this.getGroupRowSelectionState(groupKeys) !== true) {
8613
+ this._selectedMapSet(finalKey);
8614
+ if (this.getGroupRowSelectionState(groupKeys) === true) {
8615
+ this.selectGroupRow(groupKeys);
8616
+ }
8617
+ }
8349
8618
  }
8350
- isRowDefaultDeselected() {
8351
- return this.isDefaultNegativeSelection();
8619
+ setRowAsDeselected(key, groupKeys) {
8620
+ groupKeys = groupKeys || this.getGroupKeysForPrimaryKey(key);
8621
+ const finalKey = [...groupKeys, key];
8622
+ this.selectedMap.delete(finalKey);
8623
+ if (this.getGroupRowSelectionState(groupKeys) !== false) {
8624
+ this._deselectedMapSet(finalKey);
8625
+ if (this.getGroupRowSelectionState(groupKeys) === false) {
8626
+ this.deselectGroupRow(groupKeys);
8627
+ }
8628
+ }
8352
8629
  }
8353
- isRowSelected(key) {
8354
- return this.isItemPositive(key);
8630
+ deselectRow(key, groupKeys) {
8631
+ this.setRowSelected(key, false, groupKeys);
8355
8632
  }
8356
- isRowDeselected(key) {
8357
- return !this.isItemPositive(key);
8633
+ selectRow(key, groupKeys) {
8634
+ this.setRowSelected(key, true, groupKeys);
8358
8635
  }
8359
- setRowSelected(key, selected) {
8360
- return this.setItemValue(key, selected);
8636
+ toggleGroupRowSelection(groupKeys) {
8637
+ const groupRowSelectionState = this.getGroupRowSelectionState(groupKeys);
8638
+ if (groupRowSelectionState === true) {
8639
+ this.deselectGroupRow(groupKeys);
8640
+ } else {
8641
+ this.selectGroupRow(groupKeys);
8642
+ }
8361
8643
  }
8362
- deselectRow(key) {
8363
- this.setRowSelected(key, false);
8644
+ toggleRowSelection(key, groupKeys) {
8645
+ if (this.isRowSelected(key, groupKeys)) {
8646
+ this.deselectRow(key, groupKeys);
8647
+ } else {
8648
+ this.selectRow(key, groupKeys);
8649
+ }
8364
8650
  }
8365
- selectRow(key) {
8366
- this.setRowSelected(key, true);
8651
+ getSelectedCount() {
8652
+ return this.getSelectionCountFor([]).selectedCount;
8367
8653
  }
8368
- toggleRowSelection(key) {
8369
- this.toggleItem(key);
8654
+ getDeselectedCount() {
8655
+ return this.getSelectionCountFor([]).deselectedCount;
8370
8656
  }
8371
- getSelectedCount(maxCount) {
8657
+ getSelectionCountFor(groupKeys = [], parentSelected) {
8372
8658
  var _a, _b;
8373
- if (this.isRowDefaultSelected()) {
8374
- const unselectedCount = this.negativeMap ? this.negativeMap.size : 0;
8375
- return maxCount ? maxCount - unselectedCount : -unselectedCount;
8376
- }
8377
- return (_b = (_a = this.positiveMap) == null ? void 0 : _a.size) != null ? _b : 0;
8659
+ const cachedResult = this.selectionCountCache.get(groupKeys);
8660
+ if (cachedResult != null) {
8661
+ return cachedResult;
8662
+ }
8663
+ if (groupKeys.length > this.getGroupByLength()) {
8664
+ const result2 = this.isRowSelected(groupKeys) ? { selectedCount: 1, deselectedCount: 0 } : {
8665
+ selectedCount: 0,
8666
+ deselectedCount: 1
8667
+ };
8668
+ this.selectionCountCache.set(groupKeys, result2);
8669
+ return result2;
8670
+ }
8671
+ parentSelected = parentSelected != null ? parentSelected : this.getGroupRowBooleanSelectionStateFromParent(groupKeys);
8672
+ let allKeys = this.getGroupKeysDirectlyInsideGroup(groupKeys);
8673
+ if (groupKeys.length === this.getGroupByLength()) {
8674
+ const selectionState = this.selectedMap.has(groupKeys) ? true : this.deselectedMap.has(groupKeys) ? false : parentSelected;
8675
+ const totalCount = this.getGroupCount(groupKeys);
8676
+ let selectedCount2 = this.selectedMap.getKeysStartingWith(groupKeys, true, 1).length;
8677
+ let deselectedCount2 = this.deselectedMap.getKeysStartingWith(groupKeys, true, 1).length;
8678
+ const notSpecifiedCount = totalCount - (selectedCount2 + deselectedCount2);
8679
+ const result2 = {
8680
+ selectedCount: selectedCount2 + (selectionState ? notSpecifiedCount : 0),
8681
+ deselectedCount: deselectedCount2 + (selectionState ? 0 : notSpecifiedCount)
8682
+ };
8683
+ this.selectionCountCache.set(groupKeys, result2);
8684
+ return result2;
8685
+ }
8686
+ let selectedCount = 0;
8687
+ let deselectedCount = 0;
8688
+ if (this.getConfig().lazyLoad && !allKeys.length) {
8689
+ const totalChildrenCount = ((_b = (_a = this.getConfig().groupDeepMap) == null ? void 0 : _a.get(groupKeys)) == null ? void 0 : _b.totalChildrenCount) || 0;
8690
+ if (parentSelected) {
8691
+ selectedCount = totalChildrenCount;
8692
+ deselectedCount = this.deselectedMap.getAllChildrenSizeFor(groupKeys);
8693
+ if (deselectedCount === totalChildrenCount) {
8694
+ selectedCount = 0;
8695
+ }
8696
+ } else {
8697
+ deselectedCount = totalChildrenCount;
8698
+ selectedCount = this.selectedMap.getAllChildrenSizeFor(groupKeys);
8699
+ if (selectedCount === totalChildrenCount) {
8700
+ deselectedCount = 0;
8701
+ }
8702
+ }
8703
+ }
8704
+ allKeys.forEach((keys) => {
8705
+ let isSelected = this.selectedMap.get(keys);
8706
+ let isDeselected = this.deselectedMap.get(keys);
8707
+ const selected = isSelected ? true : isDeselected ? false : parentSelected;
8708
+ const { selectedCount: selCount, deselectedCount: deselCount } = this.getSelectionCountFor(keys, selected);
8709
+ selectedCount += selCount;
8710
+ deselectedCount += deselCount;
8711
+ });
8712
+ const result = {
8713
+ selectedCount,
8714
+ deselectedCount
8715
+ };
8716
+ this.selectionCountCache.set(groupKeys, result);
8717
+ return result;
8378
8718
  }
8379
8719
  };
8380
8720
 
8721
+ // src/components/InfiniteTable/api/getSelectionApi.ts
8722
+ function rowSelectionStateConfigGetter(stateOrStateGetter) {
8723
+ return () => {
8724
+ const state = typeof stateOrStateGetter === "function" ? stateOrStateGetter() : stateOrStateGetter;
8725
+ return {
8726
+ lazyLoad: !!state.lazyLoad,
8727
+ groupBy: state.groupBy,
8728
+ groupDeepMap: state.groupDeepMap,
8729
+ indexer: state.indexer,
8730
+ totalCount: state.unfilteredCount
8731
+ };
8732
+ };
8733
+ }
8734
+ function getSelectionApi(param) {
8735
+ const {
8736
+ getDataSourceState,
8737
+ dataSourceActions
8738
+ } = param;
8739
+ const selectionApi = {
8740
+ get allRowsSelected() {
8741
+ return getDataSourceState().allRowsSelected;
8742
+ },
8743
+ selectAll() {
8744
+ const { rowSelection, selectionMode } = getDataSourceState();
8745
+ if (selectionMode !== "multi-row") {
8746
+ throw "Selection mode is not multi-row";
8747
+ }
8748
+ if (!(rowSelection instanceof RowSelectionState)) {
8749
+ throw "Invalid row selection";
8750
+ }
8751
+ const rowSelectionState = new RowSelectionState(rowSelection, rowSelectionStateConfigGetter(getDataSourceState));
8752
+ rowSelectionState.selectAll();
8753
+ dataSourceActions.rowSelection = rowSelectionState;
8754
+ },
8755
+ deselectAll() {
8756
+ const { rowSelection, selectionMode } = getDataSourceState();
8757
+ if (selectionMode !== "multi-row") {
8758
+ throw "Selection mode is not multi-row";
8759
+ }
8760
+ if (!(rowSelection instanceof RowSelectionState)) {
8761
+ throw "Invalid row selection";
8762
+ }
8763
+ const rowSelectionState = new RowSelectionState(rowSelection, rowSelectionStateConfigGetter(getDataSourceState));
8764
+ rowSelectionState.deselectAll();
8765
+ dataSourceActions.rowSelection = rowSelectionState;
8766
+ },
8767
+ isRowSelected(pk, groupKeys) {
8768
+ const { rowSelection, selectionMode, indexer, groupBy } = getDataSourceState();
8769
+ if (selectionMode === "single-row") {
8770
+ return rowSelection === pk;
8771
+ }
8772
+ if (selectionMode !== "multi-row") {
8773
+ throw "Selection mode is not multi-row or single-row";
8774
+ }
8775
+ if (!(rowSelection instanceof RowSelectionState)) {
8776
+ throw "Invalid row selection";
8777
+ }
8778
+ if (!groupKeys) {
8779
+ const data = indexer.getDataForPrimaryKey(pk);
8780
+ groupKeys = data ? getGroupKeysForDataItem(data, groupBy) : [];
8781
+ }
8782
+ return rowSelection.isRowSelected(pk, groupKeys);
8783
+ },
8784
+ isRowDeselected(pk, groupKeys) {
8785
+ return !this.isRowSelected(pk, groupKeys);
8786
+ },
8787
+ selectRow(pk, groupKeys) {
8788
+ const { rowSelection, selectionMode, indexer, groupBy } = getDataSourceState();
8789
+ if (selectionMode === "single-row") {
8790
+ dataSourceActions.rowSelection = pk;
8791
+ return;
8792
+ }
8793
+ if (selectionMode !== "multi-row") {
8794
+ throw "Selection mode is not multi-row or single-row";
8795
+ }
8796
+ if (!(rowSelection instanceof RowSelectionState)) {
8797
+ throw "Invalid row selection";
8798
+ }
8799
+ if (!groupKeys) {
8800
+ const data = indexer.getDataForPrimaryKey(pk);
8801
+ groupKeys = data ? getGroupKeysForDataItem(data, groupBy) : [];
8802
+ }
8803
+ const rowSelectionState = new RowSelectionState(rowSelection, rowSelectionStateConfigGetter(getDataSourceState));
8804
+ rowSelectionState.selectRow(pk, groupKeys);
8805
+ dataSourceActions.rowSelection = rowSelectionState;
8806
+ },
8807
+ deselectRow(pk, groupKeys) {
8808
+ const { selectionMode, rowSelection, indexer, groupBy } = getDataSourceState();
8809
+ if (selectionMode === "single-row") {
8810
+ dataSourceActions.rowSelection = null;
8811
+ return;
8812
+ }
8813
+ if (selectionMode !== "multi-row") {
8814
+ throw "Selection mode is not multi-row or single-row";
8815
+ }
8816
+ if (!(rowSelection instanceof RowSelectionState)) {
8817
+ throw "Invalid row selection";
8818
+ }
8819
+ if (selectionMode === "multi-row") {
8820
+ if (!groupKeys) {
8821
+ const data = indexer.getDataForPrimaryKey(pk);
8822
+ groupKeys = data ? getGroupKeysForDataItem(data, groupBy) : [];
8823
+ }
8824
+ const rowSelectionState = new RowSelectionState(rowSelection, rowSelectionStateConfigGetter(getDataSourceState));
8825
+ rowSelectionState.deselectRow(pk, groupKeys);
8826
+ dataSourceActions.rowSelection = rowSelectionState;
8827
+ }
8828
+ },
8829
+ toggleRowSelection(pk, groupKeys) {
8830
+ if (this.isRowSelected(pk, groupKeys)) {
8831
+ this.deselectRow(pk, groupKeys);
8832
+ } else {
8833
+ this.selectRow(pk, groupKeys);
8834
+ }
8835
+ },
8836
+ selectGroupRow(groupKeys) {
8837
+ const { selectionMode, rowSelection, groupBy } = getDataSourceState();
8838
+ if (selectionMode !== "multi-row") {
8839
+ throw 'Selection mode should be "multi-row"';
8840
+ }
8841
+ if (!groupBy) {
8842
+ throw "No grouping specified";
8843
+ }
8844
+ if (!(rowSelection instanceof RowSelectionState)) {
8845
+ throw "Invalid row selection";
8846
+ }
8847
+ const rowSelectionState = new RowSelectionState(rowSelection, rowSelectionStateConfigGetter(getDataSourceState));
8848
+ rowSelectionState.selectGroupRow(groupKeys);
8849
+ dataSourceActions.rowSelection = rowSelectionState;
8850
+ },
8851
+ deselectGroupRow(groupKeys) {
8852
+ const { selectionMode, rowSelection, groupBy } = getDataSourceState();
8853
+ if (selectionMode !== "multi-row") {
8854
+ throw 'Selection mode should be "multi-row"';
8855
+ }
8856
+ if (!groupBy) {
8857
+ throw "No grouping specified";
8858
+ }
8859
+ if (!(rowSelection instanceof RowSelectionState)) {
8860
+ throw "Invalid row selection";
8861
+ }
8862
+ const rowSelectionState = new RowSelectionState(rowSelection, rowSelectionStateConfigGetter(getDataSourceState));
8863
+ rowSelectionState.deselectGroupRow(groupKeys);
8864
+ dataSourceActions.rowSelection = rowSelectionState;
8865
+ },
8866
+ toggleGroupRowSelection(groupKeys) {
8867
+ const { selectionMode, rowSelection, groupBy } = getDataSourceState();
8868
+ if (selectionMode !== "multi-row") {
8869
+ throw 'Selection mode should be "multi-row"';
8870
+ }
8871
+ if (!groupBy) {
8872
+ throw "No grouping specified";
8873
+ }
8874
+ if (!(rowSelection instanceof RowSelectionState)) {
8875
+ throw "Invalid row selection";
8876
+ }
8877
+ const rowSelectionState = new RowSelectionState(rowSelection, rowSelectionStateConfigGetter(getDataSourceState));
8878
+ rowSelectionState.toggleGroupRowSelection(groupKeys);
8879
+ dataSourceActions.rowSelection = rowSelectionState;
8880
+ },
8881
+ getGroupRowSelectionState(groupKeys) {
8882
+ const { selectionMode, rowSelection, groupBy } = getDataSourceState();
8883
+ if (selectionMode !== "multi-row") {
8884
+ throw 'Selection mode should be "multi-row"';
8885
+ }
8886
+ if (!groupBy) {
8887
+ throw "No grouping specified";
8888
+ }
8889
+ if (!(rowSelection instanceof RowSelectionState)) {
8890
+ throw "Invalid row selection";
8891
+ }
8892
+ return rowSelection.getGroupRowSelectionState(groupKeys);
8893
+ },
8894
+ getSelectedPrimaryKeys: () => {
8895
+ const selected = [];
8896
+ getDataSourceState().dataArray.forEach((rowInfo) => {
8897
+ if (!rowInfo.isGroupRow && rowInfo.rowSelected) {
8898
+ selected.push(rowInfo.id);
8899
+ }
8900
+ });
8901
+ return selected;
8902
+ }
8903
+ };
8904
+ if (false) {
8905
+ globalThis.selectionApi = selectionApi;
8906
+ }
8907
+ return selectionApi;
8908
+ }
8909
+
8381
8910
  // src/components/utils/discardCallsWithEqualArg.ts
8382
8911
  var map = new WeakMap();
8383
8912
  var getCompareDefault = (a) => a;
@@ -8409,22 +8938,23 @@ function discardCallsWithEqualArg(fn, timeframe = 50, getCompareObject) {
8409
8938
  // src/components/DataSource/Indexer.ts
8410
8939
  var Indexer = class {
8411
8940
  constructor() {
8412
- this.indexToPrimaryKey = new Map();
8413
- this.primaryKeyToIndex = new Map();
8414
- }
8415
- add(index, primaryKey) {
8416
- this.indexToPrimaryKey.set(index, primaryKey);
8417
- this.primaryKeyToIndex.set(`${primaryKey}`, index);
8418
- }
8419
- clear() {
8420
- this.indexToPrimaryKey.clear();
8421
- this.primaryKeyToIndex.clear();
8422
- }
8423
- getIndexOf(primaryKey) {
8424
- return this.primaryKeyToIndex.get(`${primaryKey}`);
8425
- }
8426
- getPrimaryKeyFor(index) {
8427
- return this.indexToPrimaryKey.get(index);
8941
+ this.primaryKeyToData = new Map();
8942
+ this.add = (primaryKey, data) => {
8943
+ this.primaryKeyToData.set(`${primaryKey}`, data);
8944
+ };
8945
+ this.clear = () => {
8946
+ this.primaryKeyToData.clear();
8947
+ };
8948
+ this.getDataForPrimaryKey = (primaryKey) => {
8949
+ return this.primaryKeyToData.get(`${primaryKey}`);
8950
+ };
8951
+ this.indexArray = (arr, toPrimaryKey) => {
8952
+ arr.forEach((item) => {
8953
+ if (item != null) {
8954
+ this.add(toPrimaryKey(item), item);
8955
+ }
8956
+ });
8957
+ };
8428
8958
  }
8429
8959
  };
8430
8960
 
@@ -8485,7 +9015,7 @@ function initSetupState() {
8485
9015
  groupDeepMap: void 0,
8486
9016
  reducerResults: void 0,
8487
9017
  allRowsSelected: false,
8488
- selectedRowCount: 0,
9018
+ someRowsSelected: false,
8489
9019
  postSortDataArray: void 0,
8490
9020
  postGroupDataArray: void 0,
8491
9021
  lastSortDataArray: void 0,
@@ -8541,8 +9071,8 @@ function getLivePaginationCursorValue(livePaginationCursorProp, state) {
8541
9071
  return livePaginationCursor;
8542
9072
  }
8543
9073
  function mapPropsToState(params) {
8544
- var _a, _b, _c;
8545
- const { props, state, oldState } = params;
9074
+ var _a, _b;
9075
+ const { props, state, oldState, getState } = params;
8546
9076
  const controlledSort = isControlledValue(props.sortInfo);
8547
9077
  const controlledFilter = isControlledValue(props.filterValue);
8548
9078
  const { filterTypes } = state;
@@ -8572,32 +9102,30 @@ function mapPropsToState(params) {
8572
9102
  }
8573
9103
  }
8574
9104
  let rowSelectionState = null;
8575
- let currentRowSelection = props.rowSelection !== void 0 ? props.rowSelection : (_b = state.rowSelection) != null ? _b : props.defaultRowSelection !== void 0 ? props.defaultRowSelection : null;
9105
+ let currentRowSelection = props.rowSelection !== void 0 ? props.rowSelection : state.rowSelection === void 0 ? props.defaultRowSelection !== void 0 ? props.defaultRowSelection : null : state.rowSelection;
8576
9106
  if (selectionMode !== false) {
8577
9107
  if (selectionMode === "single-row" || selectionMode === "multi-row") {
8578
9108
  if (currentRowSelection === null) {
8579
9109
  rowSelectionState = selectionMode === "single-row" ? null : new RowSelectionState({
8580
- selectedRows: {},
8581
- deselectedRows: true
8582
- });
9110
+ selectedRows: [],
9111
+ deselectedRows: [],
9112
+ defaultSelection: false
9113
+ }, rowSelectionStateConfigGetter(getState || state));
8583
9114
  } else {
8584
- rowSelectionState = selectionMode === "single-row" ? currentRowSelection : currentRowSelection instanceof RowSelectionState ? currentRowSelection : new RowSelectionState(currentRowSelection);
9115
+ rowSelectionState = selectionMode === "single-row" ? currentRowSelection : currentRowSelection instanceof RowSelectionState ? currentRowSelection : new RowSelectionState(currentRowSelection, rowSelectionStateConfigGetter(getState || state));
8585
9116
  }
8586
9117
  }
8587
9118
  }
8588
9119
  const primaryKeyDescriptor = state.primaryKey;
8589
- const toPrimaryKey = typeof primaryKeyDescriptor === "function" ? (data, index) => primaryKeyDescriptor({ data, index }) : (data, _index) => {
8590
- const pk = data[primaryKeyDescriptor];
8591
- return pk;
8592
- };
9120
+ const toPrimaryKey = typeof primaryKeyDescriptor === "function" ? (data) => primaryKeyDescriptor(data) : (data) => data[primaryKeyDescriptor];
8593
9121
  const result = {
8594
9122
  selectionMode,
9123
+ rowSelection: rowSelectionState,
8595
9124
  toPrimaryKey,
8596
- rowSelection: rowSelectionState != null ? rowSelectionState : null,
8597
9125
  operatorsByFilterType,
8598
9126
  controlledSort,
8599
9127
  controlledFilter,
8600
- filterMode: ((_c = props.filterMode) != null ? _c : props.filterFunction != null) ? "local" : typeof props.data === "function" ? "remote" : "local",
9128
+ filterMode: ((_b = props.filterMode) != null ? _b : props.filterFunction != null) ? "local" : typeof props.data === "function" ? "remote" : "local",
8601
9129
  multiSort: Array.isArray(controlledSort ? props.sortInfo : props.defaultSortInfo),
8602
9130
  lazyLoadBatchSize: typeof props.lazyLoad === "object" ? props.lazyLoad.batchSize : void 0
8603
9131
  };
@@ -8629,20 +9157,17 @@ function getMappedCallbacks() {
8629
9157
  rowSelection: (rowSelection, state) => {
8630
9158
  if (state.selectionMode === "single-row") {
8631
9159
  return {
8632
- callbackParam: {
8633
- selectionMode: "single-row",
8634
- rowSelection
8635
- }
9160
+ callbackParams: [
9161
+ rowSelection,
9162
+ "single-row"
9163
+ ]
8636
9164
  };
8637
9165
  }
8638
9166
  return {
8639
- callbackParam: {
8640
- selectionMode: "multi-row",
8641
- get rowSelection() {
8642
- return rowSelection.getState();
8643
- },
8644
- rowSelectionState: rowSelection
8645
- }
9167
+ callbackParams: [
9168
+ rowSelection.getState(),
9169
+ "multi-row"
9170
+ ]
8646
9171
  };
8647
9172
  }
8648
9173
  };
@@ -8994,16 +9519,16 @@ function filterDataSource(params) {
8994
9519
  return dataArray;
8995
9520
  }
8996
9521
  function concludeReducer(params) {
8997
- var _a, _b, _c, _d;
9522
+ var _a, _b;
8998
9523
  const { state, previousState } = params;
8999
- const primaryKeyDescriptor = state.primaryKey;
9000
9524
  const sortInfo = state.sortInfo;
9001
9525
  let shouldSort = !!(sortInfo == null ? void 0 : sortInfo.length) && !state.controlledSort;
9002
9526
  if (state.lazyLoad || state.livePagination) {
9003
9527
  shouldSort = false;
9004
9528
  }
9005
9529
  let originalDataArrayChanged = haveDepsChanged(previousState, state, [
9006
- "originalDataArray"
9530
+ "originalDataArray",
9531
+ "originalLazyGroupDataChangeDetect"
9007
9532
  ]);
9008
9533
  const dataSourceChange = previousState && state.data !== previousState.data;
9009
9534
  let lazyLoadGroupDataChange = state.lazyLoad && previousState && (previousState.groupBy !== state.groupBy || previousState.sortInfo !== state.sortInfo);
@@ -9014,6 +9539,13 @@ function concludeReducer(params) {
9014
9539
  state.originalLazyGroupData = new DeepMap();
9015
9540
  originalDataArrayChanged = true;
9016
9541
  }
9542
+ const shouldIndex = originalDataArrayChanged;
9543
+ if (shouldIndex) {
9544
+ state.indexer.clear();
9545
+ if (!state.lazyLoad) {
9546
+ state.indexer.indexArray(state.originalDataArray, state.toPrimaryKey);
9547
+ }
9548
+ }
9017
9549
  const { filterFunction, filterValue, filterTypes, operatorsByFilterType } = state;
9018
9550
  const shouldFilter = !!filterFunction || Array.isArray(filterValue) && filterValue.length;
9019
9551
  const shouldFilterClientSide = shouldFilter && state.filterMode === "local";
@@ -9032,7 +9564,8 @@ function concludeReducer(params) {
9032
9564
  const shouldGroup = groupBy.length > 0 || !!pivotBy;
9033
9565
  const selectionDepsChanged = haveDepsChanged(previousState, state, [
9034
9566
  "rowSelection",
9035
- "isRowSelected"
9567
+ "isRowSelected",
9568
+ "originalLazyGroupDataChangeDetect"
9036
9569
  ]);
9037
9570
  const groupsDepsChanged = originalDataArrayChanged || sortDepsChanged || haveDepsChanged(previousState, state, [
9038
9571
  "generateGroupRows",
@@ -9046,13 +9579,10 @@ function concludeReducer(params) {
9046
9579
  "pivotGrandTotalColumnPosition",
9047
9580
  "showSeparatePivotColumnForSingleAggregation"
9048
9581
  ]);
9049
- const shouldGroupAgain = shouldGroup && (groupsDepsChanged || !state.lastGroupDataArray) || selectionDepsChanged && state.selectionMode === "multi-row";
9582
+ const shouldGroupAgain = shouldGroup && (groupsDepsChanged || !state.lastGroupDataArray) || selectionDepsChanged;
9050
9583
  const now = Date.now();
9051
9584
  let dataArray = state.originalDataArray;
9052
- const toPrimaryKey = typeof primaryKeyDescriptor === "function" ? (data, index) => primaryKeyDescriptor({ data, index }) : (data, _index) => {
9053
- const pk = data[primaryKeyDescriptor];
9054
- return pk;
9055
- };
9585
+ const toPrimaryKey = state.toPrimaryKey;
9056
9586
  if (!shouldFilter) {
9057
9587
  state.unfilteredCount = dataArray.length;
9058
9588
  }
@@ -9082,60 +9612,47 @@ function concludeReducer(params) {
9082
9612
  }
9083
9613
  state.postSortDataArray = dataArray;
9084
9614
  let rowInfoDataArray = state.dataArray;
9615
+ const rowSelectionState = state.rowSelection instanceof RowSelectionState ? state.rowSelection : void 0;
9616
+ rowSelectionState == null ? void 0 : rowSelectionState.xcache();
9085
9617
  let isRowSelected = state.selectionMode === "single-row" ? (rowInfo) => {
9086
9618
  return rowInfo.id === state.rowSelection;
9087
9619
  } : state.selectionMode === "multi-row" ? (rowInfo) => {
9088
- return state.rowSelection.isRowSelected(rowInfo.id);
9620
+ const rowSelection = rowSelectionState;
9621
+ return rowInfo.isGroupRow ? rowSelection.getGroupRowSelectionState(rowInfo.groupKeys) : rowSelection.isRowSelected(rowInfo.id, rowInfo.dataSourceHasGrouping ? rowInfo.groupKeys : void 0);
9089
9622
  } : void 0;
9090
- if (state.isRowSelected) {
9091
- isRowSelected = (rowInfo) => state.isRowSelected(rowInfo, state.rowSelection, state.selectionMode) || false;
9623
+ if (state.isRowSelected && state.selectionMode === "multi-row") {
9624
+ isRowSelected = (rowInfo) => state.isRowSelected(rowInfo, rowSelectionState, state.selectionMode);
9092
9625
  }
9093
9626
  if (shouldGroup) {
9094
9627
  if (shouldGroupAgain) {
9095
9628
  let aggregationReducers = state.aggregationReducers;
9096
- if (state.selectionMode === "multi-row") {
9097
- const groupSelectedReducer = {
9098
- initialValue: true,
9099
- reducer: (groupSelected, _value, data, index) => {
9100
- const rowId = toPrimaryKey(data, index);
9101
- return groupSelected && state.rowSelection.isRowSelected(rowId);
9102
- }
9103
- };
9104
- const groupChildrenSelectedCountReducer = {
9105
- initialValue: 0,
9106
- reducer: (selectedCount, _value, data, index) => {
9107
- const rowId = toPrimaryKey(data, index);
9108
- return selectedCount + state.rowSelection.isRowSelected(rowId);
9109
- }
9110
- };
9111
- aggregationReducers = __spreadProps(__spreadValues({}, aggregationReducers), {
9112
- [GROUP_SELECTED_REDUCER_KEY]: groupSelectedReducer,
9113
- [GROUP_CHILDREN_SELECTED_COUNT_KEY]: groupChildrenSelectedCountReducer
9114
- });
9115
- }
9116
9629
  const groupResult = state.lazyLoad ? lazyGroup({
9117
9630
  groupBy,
9118
9631
  pivot: pivotBy,
9119
9632
  mappings: state.pivotMappings,
9120
- reducers: aggregationReducers
9633
+ reducers: aggregationReducers,
9634
+ indexer: state.indexer,
9635
+ toPrimaryKey
9121
9636
  }, state.originalLazyGroupData) : group({
9122
9637
  groupBy,
9123
9638
  pivot: pivotBy,
9124
9639
  reducers: aggregationReducers
9125
9640
  }, dataArray);
9126
- state.indexer.clear();
9641
+ state.groupDeepMap = groupResult.deepMap;
9642
+ if (rowSelectionState) {
9643
+ rowSelectionState.getConfig = rowSelectionStateConfigGetter(state);
9644
+ }
9127
9645
  const flattenResult = enhancedFlatten({
9128
9646
  groupResult,
9129
9647
  lazyLoad: !!state.lazyLoad,
9130
9648
  reducers: aggregationReducers,
9131
9649
  toPrimaryKey,
9132
9650
  isRowSelected,
9133
- indexer: state.indexer,
9651
+ rowSelectionState,
9134
9652
  groupRowsState: state.groupRowsState,
9135
9653
  generateGroupRows: state.generateGroupRows
9136
9654
  });
9137
9655
  rowInfoDataArray = flattenResult.data;
9138
- state.groupDeepMap = groupResult.deepMap;
9139
9656
  state.reducerResults = groupResult.reducerResults;
9140
9657
  const pivotGroupsAndCols = pivotBy ? getPivotColumnsAndColumnGroups({
9141
9658
  deepMap: groupResult.topLevelPivotColumns,
@@ -9157,10 +9674,8 @@ function concludeReducer(params) {
9157
9674
  state.pivotColumns = void 0;
9158
9675
  const arrayDifferentAfterSortStep = previousState.postSortDataArray != state.postSortDataArray;
9159
9676
  if (arrayDifferentAfterSortStep || groupsDepsChanged || selectionDepsChanged) {
9160
- state.indexer.clear();
9161
9677
  rowInfoDataArray = dataArray.map((data, index) => {
9162
- const rowInfo = toRowInfo(data, data ? toPrimaryKey(data, index) : index, index, isRowSelected);
9163
- state.indexer.add(index, rowInfo.id);
9678
+ const rowInfo = toRowInfo(data, data ? toPrimaryKey(data) : index, index, isRowSelected);
9164
9679
  return rowInfo;
9165
9680
  });
9166
9681
  }
@@ -9172,13 +9687,27 @@ function concludeReducer(params) {
9172
9687
  state.dataArray = rowInfoDataArray;
9173
9688
  state.reducedAt = now;
9174
9689
  if (state.selectionMode === "multi-row") {
9175
- if (shouldGroup) {
9176
- state.allRowsSelected = ((_c = state.reducerResults) == null ? void 0 : _c[GROUP_SELECTED_REDUCER_KEY]) || false;
9177
- state.selectedRowCount = ((_d = state.reducerResults) == null ? void 0 : _d[GROUP_CHILDREN_SELECTED_COUNT_KEY]) || 0;
9690
+ if (shouldGroup && state.lazyLoad) {
9691
+ let allRowsSelected = true;
9692
+ let someRowsSelected = false;
9693
+ state.dataArray.forEach((rowInfo) => {
9694
+ if (rowInfo.isGroupRow && rowInfo.groupKeys.length === 1) {
9695
+ const { rowSelected } = rowInfo;
9696
+ if (rowSelected !== true) {
9697
+ allRowsSelected = false;
9698
+ }
9699
+ if (rowSelected === true || rowSelected === null) {
9700
+ someRowsSelected = true;
9701
+ }
9702
+ }
9703
+ });
9704
+ state.allRowsSelected = allRowsSelected;
9705
+ state.someRowsSelected = someRowsSelected;
9178
9706
  } else {
9179
- const dataArrayCount = state.dataArray.length;
9180
- state.selectedRowCount = state.rowSelection.getSelectedCount(dataArrayCount);
9181
- state.allRowsSelected = dataArrayCount === state.selectedRowCount;
9707
+ const dataArrayCount = state.filteredCount;
9708
+ const selectedRowCount = state.rowSelection.getSelectedCount();
9709
+ state.allRowsSelected = dataArrayCount === selectedRowCount;
9710
+ state.someRowsSelected = selectedRowCount > 0;
9182
9711
  }
9183
9712
  }
9184
9713
  if (false) {
@@ -9222,6 +9751,7 @@ function DataSourceCmp({ children }) {
9222
9751
  };
9223
9752
  if (false) {
9224
9753
  globalThis.getDataSourceState = getState;
9754
+ globalThis.dataSourceActions = componentActions;
9225
9755
  }
9226
9756
  useLoadData();
9227
9757
  return /* @__PURE__ */ React33.createElement(DataSourceContext.Provider, {
@@ -9236,114 +9766,42 @@ function DataSource(props) {
9236
9766
  }));
9237
9767
  }
9238
9768
 
9239
- // src/components/InfiniteTable/getImperativeApi.ts
9240
- function getImperativeApi(getComputed, getState, getDataSourceState, componentActions, dataSourceActions) {
9241
- function setGroupRowSelection(groupKeys, selected) {
9242
- const {
9243
- selectionMode,
9244
- rowSelection: currentRowSelection,
9245
- groupDeepMap,
9246
- toPrimaryKey
9247
- } = getDataSourceState();
9248
- if (selectionMode === "multi-row" && groupDeepMap) {
9249
- const rowSelectionState = new RowSelectionState(currentRowSelection);
9250
- const groupResult = groupDeepMap.get(groupKeys);
9251
- if (groupResult == null ? void 0 : groupResult.items) {
9252
- groupResult.items.forEach((data) => {
9253
- const id = toPrimaryKey(data);
9254
- if (selected) {
9255
- rowSelectionState.selectRow(id);
9256
- } else {
9257
- rowSelectionState.deselectRow(id);
9258
- }
9259
- });
9260
- dataSourceActions.rowSelection = rowSelectionState;
9261
- return true;
9262
- }
9263
- }
9264
- return false;
9265
- }
9769
+ // src/components/InfiniteTable/api/getImperativeApi.ts
9770
+ function getImperativeApi(param) {
9771
+ const {
9772
+ getComputed,
9773
+ getState,
9774
+ getDataSourceState,
9775
+ componentActions,
9776
+ dataSourceActions
9777
+ } = param;
9778
+ const selectionApi = getSelectionApi({
9779
+ dataSourceActions,
9780
+ getDataSourceState
9781
+ });
9266
9782
  const imperativeApi = {
9267
- get allRowsSelected() {
9268
- return getDataSourceState().allRowsSelected;
9269
- },
9270
- getSelectedRowCount() {
9271
- const { selectionMode, selectedRowCount } = getDataSourceState();
9272
- if (selectionMode != "multi-row") {
9273
- throw `Cannot get the selected row count unless "selectionMode" is "multi-row"!`;
9274
- }
9275
- return selectedRowCount;
9276
- },
9277
- getSelectedRows() {
9278
- const { rowSelection, indexer, dataArray } = getDataSourceState();
9279
- if (!rowSelection || !(rowSelection instanceof RowSelectionState)) {
9280
- return [];
9281
- }
9282
- if (rowSelection.isRowDefaultDeselected()) {
9283
- const { selectedRows } = rowSelection.getState();
9284
- return Object.keys(selectedRows).reduce((res, id) => {
9285
- const index = indexer.getIndexOf(id);
9286
- if (index == null) {
9287
- return res;
9288
- }
9289
- const rowInfo = dataArray[index];
9290
- if (!rowInfo || !rowInfo.data) {
9291
- return res;
9292
- }
9293
- res.push(rowInfo.data);
9294
- return res;
9295
- }, []);
9296
- } else {
9297
- return dataArray.filter((rowInfo) => {
9298
- return !rowInfo.isGroupRow && rowSelection.isRowSelected(rowInfo.id);
9299
- }).map((rowInfo) => rowInfo.data);
9300
- }
9301
- return [];
9783
+ get selectionApi() {
9784
+ return selectionApi;
9302
9785
  },
9303
9786
  setColumnOrder: (columnOrder) => {
9304
9787
  componentActions.columnOrder = columnOrder;
9305
9788
  },
9306
- selectRow: (pk) => {
9307
- const { selectionMode, rowSelection: currentRowSelection } = getDataSourceState();
9308
- if (selectionMode === "multi-row") {
9309
- const rowSelectionState = new RowSelectionState(currentRowSelection);
9310
- rowSelectionState.selectRow(pk);
9311
- dataSourceActions.rowSelection = rowSelectionState;
9789
+ collapseGroupRow(groupKeys) {
9790
+ const state = getDataSourceState();
9791
+ if (state.groupRowsState.isGroupRowExpanded(groupKeys)) {
9792
+ this.toggleGroupRow(groupKeys);
9312
9793
  return true;
9313
- } else if (selectionMode === "single-row") {
9314
- dataSourceActions.rowSelection = pk;
9315
- return false;
9316
9794
  }
9317
9795
  return false;
9318
9796
  },
9319
- deselectRow: (pk) => {
9320
- const { selectionMode, rowSelection: currentRowSelection } = getDataSourceState();
9321
- if (selectionMode === "multi-row") {
9322
- const rowSelectionState = new RowSelectionState(currentRowSelection);
9323
- rowSelectionState.deselectRow(pk);
9324
- dataSourceActions.rowSelection = rowSelectionState;
9325
- return true;
9326
- } else if (selectionMode === "single-row") {
9327
- dataSourceActions.rowSelection = null;
9797
+ expandGroupRow(groupKeys) {
9798
+ const state = getDataSourceState();
9799
+ if (state.groupRowsState.isGroupRowCollapsed(groupKeys)) {
9800
+ this.toggleGroupRow(groupKeys);
9328
9801
  return true;
9329
9802
  }
9330
9803
  return false;
9331
9804
  },
9332
- isRowSelected: (pk) => {
9333
- const { selectionMode, rowSelection } = getDataSourceState();
9334
- if (selectionMode === "multi-row") {
9335
- return rowSelection.isRowSelected(pk);
9336
- } else if (selectionMode === "single-row") {
9337
- return rowSelection === pk;
9338
- }
9339
- return false;
9340
- },
9341
- selectGroupRow: (groupKeys) => {
9342
- return setGroupRowSelection(groupKeys, true);
9343
- },
9344
- deselectGroupRow: (groupKeys) => {
9345
- return setGroupRowSelection(groupKeys, false);
9346
- },
9347
9805
  toggleGroupRow(groupKeys) {
9348
9806
  const state = getDataSourceState();
9349
9807
  const newState = new GroupRowsState(state.groupRowsState);
@@ -9371,64 +9829,6 @@ function getImperativeApi(getComputed, getState, getDataSourceState, componentAc
9371
9829
  }
9372
9830
  }
9373
9831
  },
9374
- isGroupRowSelected: (groupKeys) => {
9375
- const { selectionMode } = getDataSourceState();
9376
- if (selectionMode === "multi-row") {
9377
- const primaryKey = `${groupKeys}`;
9378
- const index = getDataSourceState().indexer.getIndexOf(primaryKey);
9379
- if (index != null) {
9380
- const rowInfo = getDataSourceState().dataArray[index];
9381
- return rowInfo.rowSelected;
9382
- }
9383
- }
9384
- return false;
9385
- },
9386
- toggleGroupRowSelection(groupKeys) {
9387
- const { selectionMode } = getDataSourceState();
9388
- if (selectionMode === "multi-row") {
9389
- if (this.isGroupRowSelected(groupKeys)) {
9390
- this.deselectGroupRow(groupKeys);
9391
- } else {
9392
- this.selectGroupRow(groupKeys);
9393
- }
9394
- return true;
9395
- }
9396
- return false;
9397
- },
9398
- toggleRowSelection: (pk) => {
9399
- const { selectionMode, rowSelection: currentRowSelection } = getDataSourceState();
9400
- if (selectionMode === "multi-row") {
9401
- const rowSelectionState = new RowSelectionState(currentRowSelection);
9402
- rowSelectionState.toggleRowSelection(pk);
9403
- dataSourceActions.rowSelection = rowSelectionState;
9404
- return true;
9405
- } else if (selectionMode === "single-row") {
9406
- const rowSelection = currentRowSelection === pk ? null : pk;
9407
- dataSourceActions.rowSelection = rowSelection;
9408
- return true;
9409
- }
9410
- return false;
9411
- },
9412
- selectAllRows: () => {
9413
- const { selectionMode, rowSelection: currentRowSelection } = getDataSourceState();
9414
- if (selectionMode === "multi-row") {
9415
- const rowSelectionState = new RowSelectionState(currentRowSelection);
9416
- rowSelectionState.selectAll();
9417
- dataSourceActions.rowSelection = rowSelectionState;
9418
- return true;
9419
- }
9420
- return false;
9421
- },
9422
- deselectAllRows: () => {
9423
- const { selectionMode, rowSelection: currentRowSelection } = getDataSourceState();
9424
- if (selectionMode === "multi-row") {
9425
- const rowSelectionState = new RowSelectionState(currentRowSelection);
9426
- rowSelectionState.deselectAll();
9427
- dataSourceActions.rowSelection = rowSelectionState;
9428
- return true;
9429
- }
9430
- return false;
9431
- },
9432
9832
  setColumnVisibility: (columnVisibility) => {
9433
9833
  componentActions.columnVisibility = columnVisibility;
9434
9834
  },
@@ -9697,6 +10097,7 @@ function useCellRendering(param) {
9697
10097
  computedPinnedStartColumns,
9698
10098
  computedPinnedEndColumns,
9699
10099
  computedVisibleColumns,
10100
+ computedVisibleColumnsMap,
9700
10101
  rowspan,
9701
10102
  toggleGroupRow,
9702
10103
  columnSize
@@ -9800,6 +10201,7 @@ function useCellRendering(param) {
9800
10201
  domRef,
9801
10202
  width,
9802
10203
  column,
10204
+ columnsMap: computedVisibleColumnsMap,
9803
10205
  rowStyle,
9804
10206
  rowClassName
9805
10207
  };
@@ -9808,6 +10210,7 @@ function useCellRendering(param) {
9808
10210
  rowHeight,
9809
10211
  getData,
9810
10212
  computedVisibleColumns,
10213
+ computedVisibleColumnsMap,
9811
10214
  groupRenderStrategy,
9812
10215
  toggleGroupRow,
9813
10216
  showZebraRows,
@@ -9823,47 +10226,117 @@ function useCellRendering(param) {
9823
10226
  // src/components/InfiniteTable/hooks/useComputed.ts
9824
10227
  var import_react43 = __toModule(require("react"));
9825
10228
 
9826
- // src/components/InfiniteTable/hooks/useColumnGroups.ts
9827
- var import_react33 = __toModule(require("react"));
9828
-
9829
- // src/components/hooks/useInterceptedMap.ts
9830
- var import_react32 = __toModule(require("react"));
9831
- function interceptMap(map2, fns) {
9832
- const { set, delete: deleteKey, clear } = map2;
9833
- if (fns.set) {
9834
- map2.set = (key, value) => {
9835
- set.call(map2, key, value);
9836
- fns.set(key, value);
9837
- return map2;
9838
- };
10229
+ // src/components/InfiniteTable/utils/MultiRowSelector.ts
10230
+ function ensureMinMax(start, end) {
10231
+ return start < end ? [start, end] : [end, start];
10232
+ }
10233
+ var MultiRowSelector = class {
10234
+ constructor(options) {
10235
+ this.multiSelectStartIndex = 0;
10236
+ this.getIdForIndex = options.getIdForIndex;
9839
10237
  }
9840
- if (fns.delete) {
9841
- map2.delete = (key) => {
9842
- const removed = deleteKey.call(map2, key);
9843
- fns.delete(key);
9844
- return removed;
9845
- };
10238
+ set rowSelectionState(rowSelectionState) {
10239
+ this._rowSelectionState = rowSelectionState;
9846
10240
  }
9847
- if (fns.clear || fns.beforeClear) {
9848
- map2.clear = () => {
9849
- if (fns.beforeClear) {
9850
- fns.beforeClear(map2);
9851
- }
9852
- const result = clear.call(map2);
9853
- if (fns.clear) {
9854
- fns.clear();
9855
- }
9856
- return result;
9857
- };
10241
+ get rowSelectionState() {
10242
+ return this._rowSelectionState;
9858
10243
  }
9859
- return () => {
9860
- if (set) {
9861
- map2.set = set;
9862
- }
9863
- if (deleteKey) {
9864
- map2.delete = deleteKey;
10244
+ selectRange(startIndex, endIndex) {
10245
+ const [start, end] = ensureMinMax(startIndex, endIndex);
10246
+ const rowSelectionState = this.rowSelectionState;
10247
+ for (let i = start; i <= end; i++) {
10248
+ const id = this.getIdForIndex(i);
10249
+ rowSelectionState.selectRow(id);
9865
10250
  }
9866
- if (clear) {
10251
+ }
10252
+ deselectRange(startIndex, endIndex) {
10253
+ const [start, end] = ensureMinMax(startIndex, endIndex);
10254
+ const rowSelectionState = this.rowSelectionState;
10255
+ for (let i = start; i <= end; i++) {
10256
+ const id = this.getIdForIndex(i);
10257
+ rowSelectionState.deselectRow(id);
10258
+ }
10259
+ }
10260
+ resetClick(index) {
10261
+ this.rowSelectionState.deselectAll();
10262
+ const id = this.getIdForIndex(index);
10263
+ this.rowSelectionState.selectRow(id);
10264
+ this.multiSelectStartIndex = index;
10265
+ this.multiSelectEndIndex = void 0;
10266
+ }
10267
+ singleAddClick(index) {
10268
+ const id = this.getIdForIndex(index);
10269
+ if (this.rowSelectionState.isRowSelected(id)) {
10270
+ this.rowSelectionState.deselectRow(id);
10271
+ if (this.rowSelectionState.isRowSelected(this.getIdForIndex(index + 1))) {
10272
+ this.multiSelectStartIndex = index + 1;
10273
+ } else {
10274
+ }
10275
+ } else {
10276
+ this.rowSelectionState.selectRow(id);
10277
+ this.multiSelectStartIndex = index;
10278
+ let multiSelectEndIndex = void 0;
10279
+ for (let i = index - 1; i >= 0; i--) {
10280
+ const id2 = this.getIdForIndex(i);
10281
+ if (this.rowSelectionState.isRowSelected(id2)) {
10282
+ multiSelectEndIndex = i;
10283
+ } else {
10284
+ break;
10285
+ }
10286
+ }
10287
+ this.multiSelectEndIndex = multiSelectEndIndex;
10288
+ }
10289
+ }
10290
+ multiSelectClick(index) {
10291
+ if (this.multiSelectEndIndex != null) {
10292
+ this.deselectRange(this.multiSelectStartIndex, this.multiSelectEndIndex);
10293
+ }
10294
+ this.selectRange(this.multiSelectStartIndex, index);
10295
+ this.multiSelectEndIndex = index;
10296
+ }
10297
+ };
10298
+
10299
+ // src/components/InfiniteTable/hooks/useColumnGroups.ts
10300
+ var import_react33 = __toModule(require("react"));
10301
+
10302
+ // src/components/hooks/useInterceptedMap.ts
10303
+ var import_react32 = __toModule(require("react"));
10304
+ function interceptMap(map2, fns) {
10305
+ const { set, delete: deleteKey, clear } = map2;
10306
+ if (fns.set) {
10307
+ map2.set = (key, value) => {
10308
+ set.call(map2, key, value);
10309
+ fns.set(key, value);
10310
+ return map2;
10311
+ };
10312
+ }
10313
+ if (fns.delete) {
10314
+ map2.delete = (key) => {
10315
+ const removed = deleteKey.call(map2, key);
10316
+ fns.delete(key);
10317
+ return removed;
10318
+ };
10319
+ }
10320
+ if (fns.clear || fns.beforeClear) {
10321
+ map2.clear = () => {
10322
+ if (fns.beforeClear) {
10323
+ fns.beforeClear(map2);
10324
+ }
10325
+ const result = clear.call(map2);
10326
+ if (fns.clear) {
10327
+ fns.clear();
10328
+ }
10329
+ return result;
10330
+ };
10331
+ }
10332
+ return () => {
10333
+ if (set) {
10334
+ map2.set = set;
10335
+ }
10336
+ if (deleteKey) {
10337
+ map2.delete = deleteKey;
10338
+ }
10339
+ if (clear) {
9867
10340
  map2.clear = clear;
9868
10341
  }
9869
10342
  };
@@ -10009,13 +10482,13 @@ var import_react36 = __toModule(require("react"));
10009
10482
 
10010
10483
  // src/components/InfiniteTable/components/icons/ExpanderIcon.css.ts
10011
10484
  var import_createRuntimeFn6 = __toModule(require_vanilla_extract_recipes_createRuntimeFn_cjs());
10012
- var ExpanderIconCls = "_16lm1iw6 _16lm1iwh _16lm1iwd";
10013
- var ExpanderIconClsVariants = (0, import_createRuntimeFn6.createRuntimeFn)({ defaultClassName: "", variantClassNames: { expanded: { true: "_16lm1iwc", false: "_198z9782" } }, defaultVariants: {}, compoundVariants: [] });
10485
+ var ExpanderIconCls = "_16lm1iw6 _16lm1iwi _16lm1iwe";
10486
+ 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"]] });
10014
10487
 
10015
10488
  // src/components/InfiniteTable/components/icons/ExpanderIcon.tsx
10016
10489
  function ExpanderIcon(props) {
10017
10490
  var _a;
10018
- const { size = 24 } = props;
10491
+ const { size = 24, direction = "start" } = props;
10019
10492
  const [expanded, setExpanded] = (0, import_react36.useState)((_a = props.expanded) != null ? _a : props.defaultExpanded);
10020
10493
  const onClick = () => {
10021
10494
  var _a2;
@@ -10038,8 +10511,9 @@ function ExpanderIcon(props) {
10038
10511
  style: props.style,
10039
10512
  onClick,
10040
10513
  className: join(props.className, ExpanderIconCls, ExpanderIconClsVariants({
10514
+ direction: direction || "start",
10041
10515
  expanded
10042
- }), "InfiniteIcon", "InfiniteIcon-expander", `InfiniteIcon-expander--${expanded ? "expanded" : "collapsed"}`)
10516
+ }), "InfiniteIcon", "InfiniteIcon-expander", `InfiniteIcon-expander--${expanded ? "expanded" : "collapsed"}`, `InfiniteIcon-expander--${direction === "end" ? "end" : "start"}`)
10043
10517
  }, /* @__PURE__ */ React35.createElement("path", {
10044
10518
  d: "M8.59 16.59L13.17 12 8.59 7.41 10 6l6 6-6 6-1.41-1.41z"
10045
10519
  }));
@@ -10049,7 +10523,7 @@ function ExpanderIcon(props) {
10049
10523
  var React36 = __toModule(require("react"));
10050
10524
 
10051
10525
  // src/components/InfiniteTable/components/icons/LoadingIcon.css.ts
10052
- var LoadingIconCls = "_16lm1iw8 _16lm1iwh _16lm1iwd";
10526
+ var LoadingIconCls = "_16lm1iw8 _16lm1iwi _16lm1iwe";
10053
10527
 
10054
10528
  // src/components/InfiniteTable/components/icons/LoadingIcon.tsx
10055
10529
  var LoadingIcon = (props) => {
@@ -10095,7 +10569,7 @@ function getGroupColumnRender({
10095
10569
  groupRenderStrategy
10096
10570
  }) {
10097
10571
  return (renderOptions) => {
10098
- const { rowInfo, renderBag } = renderOptions;
10572
+ const { rowInfo, renderBag, column } = renderOptions;
10099
10573
  let { value: valueToRender, groupIcon, selectionCheckBox } = renderBag;
10100
10574
  const groupRowInfo = rowInfo;
10101
10575
  if (groupRenderStrategy === "multi-column") {
@@ -10105,7 +10579,7 @@ function getGroupColumnRender({
10105
10579
  } else if (groupRenderStrategy === "single-column" && !groupRowInfo.isGroupRow) {
10106
10580
  }
10107
10581
  return /* @__PURE__ */ React37.createElement("div", {
10108
- className: join(display.flex, alignItems.center, groupRenderStrategy === "single-column" || groupRenderStrategy === "multi-column" && !rowInfo.isGroupRow && selectionCheckBox ? GroupRowExpanderCls : null)
10582
+ 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)
10109
10583
  }, groupIcon, selectionCheckBox, /* @__PURE__ */ React37.createElement("div", {
10110
10584
  className: cssEllipsisClassName
10111
10585
  }, valueToRender != null ? valueToRender : null));
@@ -10119,7 +10593,7 @@ function getGroupColumnRenderGroupIcon({
10119
10593
  }) {
10120
10594
  return (renderOptions) => {
10121
10595
  var _a, _b, _c;
10122
- const { rowInfo, value, groupBy, pivotBy } = renderOptions;
10596
+ const { rowInfo, value, groupBy, pivotBy, column } = renderOptions;
10123
10597
  const groupRowInfo = groupRenderStrategy !== "inline" ? rowInfo : rowInfo.isGroupRow && ((_a = rowInfo.parents) == null ? void 0 : _a[groupIndexForColumn]) || rowInfo;
10124
10598
  if (!groupRowInfo) {
10125
10599
  return null;
@@ -10151,6 +10625,7 @@ function getGroupColumnRenderGroupIcon({
10151
10625
  } else if (showExpanderIcon) {
10152
10626
  const defaultIcon = /* @__PURE__ */ React37.createElement(ExpanderIcon, {
10153
10627
  expanded: !collapsed,
10628
+ direction: column.align === "end" ? "end" : "start",
10154
10629
  onChange: () => {
10155
10630
  toggleGroupRow(groupKeys);
10156
10631
  }
@@ -11030,7 +11505,10 @@ var getComputedVisibleColumns = ({
11030
11505
  computedVisibleColumns,
11031
11506
  computedVisibleColumnsMap,
11032
11507
  computedPinnedEndWidth,
11033
- computedPinnedStartWidth
11508
+ computedPinnedStartWidth,
11509
+ renderSelectionCheckBox: computedVisibleColumns.reduce((bool, c) => {
11510
+ return bool || !!c.renderSelectionCheckBox;
11511
+ }, false)
11034
11512
  };
11035
11513
  return result;
11036
11514
  };
@@ -11091,7 +11569,8 @@ var useComputedVisibleColumns = ({
11091
11569
  computedUnpinnedOffset,
11092
11570
  computedPinnedEndOffset,
11093
11571
  computedPinnedEndWidth,
11094
- computedPinnedStartWidth
11572
+ computedPinnedStartWidth,
11573
+ renderSelectionCheckBox
11095
11574
  } = (0, import_react41.useMemo)(() => {
11096
11575
  return getComputedVisibleColumns({
11097
11576
  columns,
@@ -11142,6 +11621,7 @@ var useComputedVisibleColumns = ({
11142
11621
  columnsRenderId
11143
11622
  ]);
11144
11623
  const result = {
11624
+ renderSelectionCheckBox,
11145
11625
  columns,
11146
11626
  computedPinnedEndWidth,
11147
11627
  computedPinnedStartWidth,
@@ -11249,7 +11729,8 @@ function useComputed() {
11249
11729
  computedPinnedEndOffset,
11250
11730
  computedRemainingSpace,
11251
11731
  computedPinnedStartWidth,
11252
- computedPinnedEndWidth
11732
+ computedPinnedEndWidth,
11733
+ renderSelectionCheckBox
11253
11734
  } = useComputedVisibleColumns({
11254
11735
  columns,
11255
11736
  columnCssEllipsis: componentState.columnCssEllipsis,
@@ -11280,12 +11761,20 @@ function useComputed() {
11280
11761
  const scrollbars = useScrollbars(brain);
11281
11762
  const computedPinnedStartOverflow = computedPinnedStartWidth ? computedPinnedStartColumnsWidth > computedPinnedStartWidth : false;
11282
11763
  const computedPinnedEndOverflow = computedPinnedEndWidth ? computedPinnedEndColumnsWidth > computedPinnedEndWidth : false;
11764
+ const [multiRowSelector] = (0, import_react43.useState)(() => {
11765
+ const multiRowSelector2 = new MultiRowSelector({
11766
+ getIdForIndex: (index) => getDataSourceState().dataArray[index].id
11767
+ });
11768
+ return multiRowSelector2;
11769
+ });
11283
11770
  return {
11771
+ multiRowSelector,
11284
11772
  showColumnFilters: !!dataSourceState.filterValue,
11285
11773
  scrollbars,
11286
11774
  columnSize,
11287
11775
  rowspan,
11288
11776
  toggleGroupRow,
11777
+ renderSelectionCheckBox,
11289
11778
  computedPinnedStartOverflow,
11290
11779
  computedPinnedEndOverflow,
11291
11780
  computedPinnedStartWidth,
@@ -11468,7 +11957,7 @@ var useLicense = (licenseKey = "") => {
11468
11957
  const valid = (0, import_react44.useMemo)(() => {
11469
11958
  let valid2 = isValidLicense(licenseKey, {
11470
11959
  publishedAt: 1624970570587,
11471
- version: "0.4.1"
11960
+ version: "0.4.2"
11472
11961
  });
11473
11962
  if (!licenseKey && !valid2 && isInsidePlayground) {
11474
11963
  return true;
@@ -11478,149 +11967,19 @@ var useLicense = (licenseKey = "") => {
11478
11967
  return valid;
11479
11968
  };
11480
11969
 
11481
- // src/components/InfiniteTable/hooks/useRowSelection.ts
11482
- var import_react45 = __toModule(require("react"));
11483
-
11484
- // src/components/InfiniteTable/utils/MultiRowSelector.ts
11485
- function ensureMinMax(start, end) {
11486
- return start < end ? [start, end] : [end, start];
11487
- }
11488
- var MultiRowSelector = class {
11489
- constructor(options) {
11490
- this.multiSelectStartIndex = 0;
11491
- this.getIdForIndex = options.getIdForIndex;
11492
- }
11493
- set rowSelectionState(rowSelectionState) {
11494
- this._rowSelectionState = rowSelectionState;
11495
- }
11496
- get rowSelectionState() {
11497
- return this._rowSelectionState;
11498
- }
11499
- selectRange(startIndex, endIndex) {
11500
- const [start, end] = ensureMinMax(startIndex, endIndex);
11501
- const rowSelectionState = this.rowSelectionState;
11502
- for (let i = start; i <= end; i++) {
11503
- const id = this.getIdForIndex(i);
11504
- rowSelectionState.selectRow(id);
11505
- }
11506
- }
11507
- deselectRange(startIndex, endIndex) {
11508
- const [start, end] = ensureMinMax(startIndex, endIndex);
11509
- const rowSelectionState = this.rowSelectionState;
11510
- for (let i = start; i <= end; i++) {
11511
- const id = this.getIdForIndex(i);
11512
- rowSelectionState.deselectRow(id);
11513
- }
11514
- }
11515
- resetClick(index) {
11516
- this.rowSelectionState.deselectAll();
11517
- const id = this.getIdForIndex(index);
11518
- this.rowSelectionState.selectRow(id);
11519
- this.multiSelectStartIndex = index;
11520
- this.multiSelectEndIndex = void 0;
11521
- }
11522
- singleAddClick(index) {
11523
- const id = this.getIdForIndex(index);
11524
- if (this.rowSelectionState.isRowSelected(id)) {
11525
- this.rowSelectionState.deselectRow(id);
11526
- if (this.rowSelectionState.isRowSelected(this.getIdForIndex(index + 1))) {
11527
- this.multiSelectStartIndex = index + 1;
11528
- } else {
11529
- }
11530
- } else {
11531
- this.rowSelectionState.selectRow(id);
11532
- this.multiSelectStartIndex = index;
11533
- let multiSelectEndIndex = void 0;
11534
- for (let i = index - 1; i >= 0; i--) {
11535
- const id2 = this.getIdForIndex(i);
11536
- if (this.rowSelectionState.isRowSelected(id2)) {
11537
- multiSelectEndIndex = i;
11538
- } else {
11539
- break;
11540
- }
11541
- }
11542
- this.multiSelectEndIndex = multiSelectEndIndex;
11543
- }
11544
- }
11545
- multiSelectClick(index) {
11546
- if (this.multiSelectEndIndex != null) {
11547
- this.deselectRange(this.multiSelectStartIndex, this.multiSelectEndIndex);
11548
- }
11549
- this.selectRange(this.multiSelectStartIndex, index);
11550
- this.multiSelectEndIndex = index;
11551
- }
11552
- };
11553
-
11554
- // src/components/InfiniteTable/hooks/useRowSelection.ts
11555
- function useRowSelection() {
11556
- const { getState } = useInfiniteTable();
11557
- const [multiRowSelector] = (0, import_react45.useState)(() => {
11558
- const multiRowSelector2 = new MultiRowSelector({
11559
- getIdForIndex: (index) => getDataSourceState().dataArray[index].id
11560
- });
11561
- return multiRowSelector2;
11562
- });
11563
- const { getState: getDataSourceState, componentActions } = useDataSourceContextValue();
11564
- (0, import_react45.useEffect)(() => {
11565
- const removeOnClick = getState().cellClick.onChange((args) => {
11566
- if (args == null) {
11567
- return;
11568
- }
11569
- const { rowIndex, event } = args;
11570
- let {
11571
- rowSelection: rowSelectionState,
11572
- selectionMode,
11573
- groupBy
11574
- } = getDataSourceState();
11575
- if (groupBy.length) {
11576
- return;
11577
- }
11578
- if (selectionMode === "multi-row") {
11579
- rowSelectionState = new RowSelectionState(rowSelectionState);
11580
- multiRowSelector.rowSelectionState = rowSelectionState;
11581
- if (rowSelectionState && typeof rowSelectionState === "object") {
11582
- if (event.shiftKey) {
11583
- multiRowSelector.multiSelectClick(rowIndex);
11584
- } else if (event.metaKey || event.ctrlKey) {
11585
- multiRowSelector.singleAddClick(rowIndex);
11586
- } else {
11587
- multiRowSelector.resetClick(rowIndex);
11588
- }
11589
- componentActions.rowSelection = rowSelectionState;
11590
- }
11591
- } else if (selectionMode === "single-row") {
11592
- }
11593
- });
11594
- const removeOnKeyDown = getState().keyDown.onChange((event) => {
11595
- let { rowSelection: rowSelectionState, selectionMode } = getDataSourceState();
11596
- if (selectionMode === "multi-row") {
11597
- if ((event == null ? void 0 : event.key) === "a" && (event.ctrlKey || event.metaKey)) {
11598
- rowSelectionState = new RowSelectionState(rowSelectionState);
11599
- rowSelectionState.selectAll();
11600
- componentActions.rowSelection = rowSelectionState;
11601
- }
11602
- }
11603
- });
11604
- return () => {
11605
- removeOnClick();
11606
- removeOnKeyDown();
11607
- };
11608
- }, [multiRowSelector]);
11609
- }
11610
-
11611
11970
  // src/components/InfiniteTable/hooks/useScrollToActiveCell.ts
11612
- var import_react46 = __toModule(require("react"));
11971
+ var import_react45 = __toModule(require("react"));
11613
11972
  var RETRIES = 10;
11614
11973
  function useScrollToActiveCell(activeCellIndex, dataCount, imperativeApi) {
11615
- const didScrollRef = (0, import_react46.useRef)(false);
11616
- const rafId = (0, import_react46.useRef)(null);
11617
- (0, import_react46.useEffect)(() => {
11974
+ const didScrollRef = (0, import_react45.useRef)(false);
11975
+ const rafId = (0, import_react45.useRef)(null);
11976
+ (0, import_react45.useEffect)(() => {
11618
11977
  if (activeCellIndex != null) {
11619
11978
  didScrollRef.current = false;
11620
11979
  cancelRaf(rafId.current);
11621
11980
  }
11622
11981
  }, [activeCellIndex]);
11623
- (0, import_react46.useEffect)(() => {
11982
+ (0, import_react45.useEffect)(() => {
11624
11983
  if (activeCellIndex != null && !didScrollRef.current) {
11625
11984
  let tryScroll = function(times = 0) {
11626
11985
  times++;
@@ -11643,18 +12002,18 @@ function useScrollToActiveCell(activeCellIndex, dataCount, imperativeApi) {
11643
12002
  }
11644
12003
 
11645
12004
  // src/components/InfiniteTable/hooks/useScrollToActiveRow.ts
11646
- var import_react47 = __toModule(require("react"));
12005
+ var import_react46 = __toModule(require("react"));
11647
12006
  var RETRIES2 = 10;
11648
12007
  function useScrollToActiveRow(activeRowIndex, dataCount, imperativeApi) {
11649
- const didScrollRef = (0, import_react47.useRef)(false);
11650
- const rafId = (0, import_react47.useRef)(null);
11651
- (0, import_react47.useEffect)(() => {
12008
+ const didScrollRef = (0, import_react46.useRef)(false);
12009
+ const rafId = (0, import_react46.useRef)(null);
12010
+ (0, import_react46.useEffect)(() => {
11652
12011
  if (activeRowIndex != null) {
11653
12012
  didScrollRef.current = false;
11654
12013
  cancelAnimationFrame(rafId.current);
11655
12014
  }
11656
12015
  }, [activeRowIndex]);
11657
- (0, import_react47.useEffect)(() => {
12016
+ (0, import_react46.useEffect)(() => {
11658
12017
  if (activeRowIndex != null && !didScrollRef.current) {
11659
12018
  let tryScroll = function(times = 0) {
11660
12019
  times++;
@@ -11675,225 +12034,34 @@ function useScrollToActiveRow(activeRowIndex, dataCount, imperativeApi) {
11675
12034
  }, [activeRowIndex, dataCount]);
11676
12035
  }
11677
12036
 
11678
- // src/components/utils/clamp.ts
11679
- function clamp(value, min, max) {
11680
- return Math.min(Math.max(value, min), max);
11681
- }
12037
+ // src/components/InfiniteTable/state/getInitialState.ts
12038
+ var import_react47 = __toModule(require("react"));
11682
12039
 
11683
- // src/components/InfiniteTable/keyboardNavigationAndSelection.ts
11684
- function handleRowNavigation(options) {
11685
- const { key, getState, getDataSourceState, actions } = options;
11686
- const arrLength = getDataSourceState().dataArray.length;
11687
- const state = getState();
11688
- const { brain } = state;
11689
- let { activeRowIndex } = state;
11690
- if (activeRowIndex == null) {
11691
- return false;
11692
- }
11693
- const {
11694
- start: [startRow],
11695
- end: [endRow]
11696
- } = brain.getRenderRange();
11697
- const renderRowCount = endRow - startRow - 1;
11698
- const min = 0;
11699
- const max = arrLength - 1;
11700
- const KeyToFunction = {
11701
- ArrowDown: () => {
11702
- activeRowIndex = clamp(activeRowIndex + 1, min, max);
11703
- },
11704
- ArrowUp: () => {
11705
- activeRowIndex = clamp(activeRowIndex - 1, min, max);
11706
- },
11707
- PageDown: () => {
11708
- activeRowIndex = Math.min(activeRowIndex + renderRowCount, arrLength - 1);
11709
- },
11710
- PageUp: () => {
11711
- activeRowIndex = Math.max(activeRowIndex - renderRowCount, min);
11712
- },
11713
- End: () => {
11714
- activeRowIndex = max;
11715
- },
11716
- Home: () => {
11717
- activeRowIndex = min;
11718
- }
11719
- };
11720
- const Fn = KeyToFunction[key];
11721
- if (!Fn) {
11722
- return false;
11723
- }
11724
- Fn();
11725
- actions.activeRowIndex = activeRowIndex;
11726
- return true;
11727
- }
11728
- function handleCellNavigation(options) {
11729
- const { key, shiftKey, getState, getComputed, getDataSourceState, actions } = options;
11730
- const state = getState();
11731
- const { activeCellIndex, brain } = state;
11732
- if (!activeCellIndex) {
11733
- return false;
11734
- }
11735
- let [rowIndex, colIndex] = activeCellIndex;
11736
- const {
11737
- start: [startRow, startCol],
11738
- end: [endRow, endCol]
11739
- } = brain.getRenderRange();
11740
- const renderRowCount = endRow - startRow - 1;
11741
- const renderColCount = endCol - startCol - 1;
11742
- const maxRow = getDataSourceState().dataArray.length - 1;
11743
- const maxCol = getComputed().computedVisibleColumns.length - 1;
11744
- const minRow = 0;
11745
- const minCol = 0;
11746
- rowIndex = clamp(rowIndex, 0, maxRow);
11747
- colIndex = clamp(colIndex, 0, maxCol);
11748
- actions.activeCellIndex = [rowIndex, colIndex];
11749
- const KeyToFunction = {
11750
- ArrowDown: () => {
11751
- rowIndex = clamp(rowIndex + 1, minRow, maxRow);
11752
- },
11753
- ArrowUp: () => {
11754
- rowIndex = clamp(rowIndex - 1, minRow, maxRow);
11755
- },
11756
- ArrowLeft: () => {
11757
- colIndex = clamp(colIndex - 1, minCol, maxCol);
11758
- },
11759
- ArrowRight: () => {
11760
- colIndex = clamp(colIndex + 1, minCol, maxCol);
11761
- },
11762
- PageDown: () => {
11763
- if (!shiftKey) {
11764
- rowIndex = Math.min(rowIndex + renderRowCount, maxRow);
11765
- } else {
11766
- colIndex = Math.min(colIndex + renderColCount, maxCol);
11767
- }
11768
- },
11769
- PageUp: () => {
11770
- if (!shiftKey) {
11771
- rowIndex = Math.max(rowIndex - renderRowCount, minRow);
11772
- } else {
11773
- colIndex = Math.max(colIndex - renderColCount, minCol);
11774
- }
11775
- },
11776
- End: () => {
11777
- if (!shiftKey) {
11778
- rowIndex = maxRow;
11779
- } else {
11780
- colIndex = maxCol;
11781
- }
11782
- },
11783
- Home: () => {
11784
- if (!shiftKey) {
11785
- rowIndex = minRow;
11786
- } else {
11787
- colIndex = minCol;
11788
- }
11789
- }
11790
- };
11791
- const Fn = KeyToFunction[key];
11792
- if (!Fn) {
11793
- return false;
11794
- }
11795
- Fn();
11796
- actions.activeCellIndex = [rowIndex, colIndex];
11797
- return true;
11798
- }
11799
- var validKeys = {
11800
- ArrowUp: true,
11801
- ArrowDown: true,
11802
- ArrowLeft: true,
11803
- ArrowRight: true,
11804
- PageUp: true,
11805
- PageDown: true,
11806
- Home: true,
11807
- End: true,
11808
- Enter: true,
11809
- " ": true
11810
- };
11811
- function handleKeyboardNavigation(options) {
11812
- const { getState, getDataSourceState, imperativeApi } = options;
11813
- const state = getState();
11814
- const dataSourceState = getDataSourceState();
11815
- const { activeRowIndex, activeCellIndex, keyboardNavigation } = state;
11816
- if (!validKeys[options.key]) {
11817
- return false;
11818
- }
11819
- if (options.key === "Enter") {
11820
- if (keyboardNavigation === "row" && activeRowIndex != null) {
11821
- const rowInfo = dataSourceState.dataArray[activeRowIndex];
11822
- if (rowInfo && rowInfo.isGroupRow) {
11823
- imperativeApi.toggleGroupRow(rowInfo.groupKeys);
11824
- return true;
11825
- }
11826
- }
11827
- if (keyboardNavigation === "cell" && activeCellIndex != null) {
11828
- const rowInfo = dataSourceState.dataArray[activeCellIndex[0]];
11829
- if (rowInfo && rowInfo.isGroupRow) {
11830
- imperativeApi.toggleGroupRow(rowInfo.groupKeys);
11831
- return true;
11832
- }
11833
- }
11834
- return false;
11835
- }
11836
- if (options.key === " ") {
11837
- if (keyboardNavigation === "row" && activeRowIndex != null) {
11838
- const rowInfo = dataSourceState.dataArray[activeRowIndex];
11839
- if (rowInfo) {
11840
- if (rowInfo.isGroupRow) {
11841
- imperativeApi.toggleGroupRowSelection(rowInfo.groupKeys);
11842
- } else {
11843
- imperativeApi.toggleRowSelection(rowInfo.id);
11844
- }
11845
- return true;
11846
- }
11847
- }
11848
- if (keyboardNavigation === "cell" && activeCellIndex != null) {
11849
- const rowInfo = dataSourceState.dataArray[activeCellIndex[0]];
11850
- if (rowInfo) {
11851
- if (rowInfo.isGroupRow) {
11852
- imperativeApi.toggleGroupRowSelection(rowInfo.groupKeys);
11853
- } else {
11854
- imperativeApi.toggleRowSelection(rowInfo.id);
11855
- }
11856
- return true;
11857
- }
11858
- }
11859
- }
11860
- if (activeRowIndex != null && keyboardNavigation === "row") {
11861
- return handleRowNavigation(options);
11862
- }
11863
- if (activeCellIndex != null && keyboardNavigation === "cell") {
11864
- return handleCellNavigation(options);
11865
- }
11866
- return false;
11867
- }
11868
-
11869
- // src/components/InfiniteTable/state/getInitialState.ts
11870
- var import_react48 = __toModule(require("react"));
11871
-
11872
- // src/components/VirtualBrain/ScrollListener.ts
11873
- var initialScrollPosition = {
11874
- scrollLeft: 0,
11875
- scrollTop: 0
11876
- };
11877
- var ScrollListener = class {
11878
- constructor() {
11879
- this.scrollPosition = initialScrollPosition;
11880
- this.onScrollFns = [];
11881
- this.getScrollPosition = () => {
11882
- return this.scrollPosition;
11883
- };
11884
- this.onScroll = (fn) => {
11885
- this.onScrollFns.push(fn);
11886
- return () => {
11887
- this.onScrollFns = this.onScrollFns.filter((f) => f !== fn);
11888
- };
11889
- };
11890
- this.setScrollPosition = (scrollPosition) => {
11891
- this.scrollPosition = scrollPosition;
11892
- this.notifyScrollChange();
11893
- };
11894
- this.destroy = () => {
11895
- this.onScrollFns = [];
11896
- };
12040
+ // src/components/VirtualBrain/ScrollListener.ts
12041
+ var initialScrollPosition = {
12042
+ scrollLeft: 0,
12043
+ scrollTop: 0
12044
+ };
12045
+ var ScrollListener = class {
12046
+ constructor() {
12047
+ this.scrollPosition = initialScrollPosition;
12048
+ this.onScrollFns = [];
12049
+ this.getScrollPosition = () => {
12050
+ return this.scrollPosition;
12051
+ };
12052
+ this.onScroll = (fn) => {
12053
+ this.onScrollFns.push(fn);
12054
+ return () => {
12055
+ this.onScrollFns = this.onScrollFns.filter((f) => f !== fn);
12056
+ };
12057
+ };
12058
+ this.setScrollPosition = (scrollPosition) => {
12059
+ this.scrollPosition = scrollPosition;
12060
+ this.notifyScrollChange();
12061
+ };
12062
+ this.destroy = () => {
12063
+ this.onScrollFns = [];
12064
+ };
11897
12065
  }
11898
12066
  notifyScrollChange() {
11899
12067
  const { scrollPosition } = this;
@@ -11962,10 +12130,10 @@ function initSetupState2() {
11962
12130
  propsCache: new Map([]),
11963
12131
  brain,
11964
12132
  headerBrain,
11965
- domRef: (0, import_react48.createRef)(),
11966
- scrollerDOMRef: (0, import_react48.createRef)(),
11967
- portalDOMRef: (0, import_react48.createRef)(),
11968
- activeCellIndicatorDOMRef: (0, import_react48.createRef)(),
12133
+ domRef: (0, import_react47.createRef)(),
12134
+ scrollerDOMRef: (0, import_react47.createRef)(),
12135
+ portalDOMRef: (0, import_react47.createRef)(),
12136
+ activeCellIndicatorDOMRef: (0, import_react47.createRef)(),
11969
12137
  onRowHeightCSSVarChange: buildSubscriptionCallback(),
11970
12138
  onColumnHeaderHeightCSSVarChange: buildSubscriptionCallback(),
11971
12139
  cellClick: buildSubscriptionCallback(),
@@ -12037,6 +12205,7 @@ var forwardProps4 = (setupState) => {
12037
12205
  pivotTotalColumnPosition: (pivotTotalColumnPosition) => pivotTotalColumnPosition != null ? pivotTotalColumnPosition : "end",
12038
12206
  pivotGrandTotalColumnPosition: 1,
12039
12207
  licenseKey: (licenseKey) => licenseKey || "",
12208
+ keyboardSelection: (keyboardSelection) => keyboardSelection != null ? keyboardSelection : true,
12040
12209
  activeRowIndex: 1,
12041
12210
  activeCellIndex: 1,
12042
12211
  columnOrder: (columnOrder) => columnOrder != null ? columnOrder : true,
@@ -12111,6 +12280,388 @@ var mapPropsToState2 = (params) => {
12111
12280
  // src/components/InfiniteTable/utils/toCSSVarName.ts
12112
12281
  var toCSSVarName = (value) => `--infinite-${value}`;
12113
12282
 
12283
+ // src/components/InfiniteTable/eventHandlers/index.ts
12284
+ var import_react48 = __toModule(require("react"));
12285
+
12286
+ // src/components/InfiniteTable/eventHandlers/onCellClick.ts
12287
+ function onCellClick(context, event) {
12288
+ updateRowSelectionOnCellClick(context, event);
12289
+ }
12290
+ function updateRowSelectionOnCellClick(context, event) {
12291
+ const { rowIndex, getDataSourceState, getComputed, dataSourceActions } = context;
12292
+ const { multiRowSelector, renderSelectionCheckBox } = getComputed();
12293
+ const dataSourceState = getDataSourceState();
12294
+ const { selectionMode, groupBy } = dataSourceState;
12295
+ let { rowSelection: rowSelectionState } = dataSourceState;
12296
+ if (groupBy.length) {
12297
+ return false;
12298
+ }
12299
+ if (selectionMode === "multi-row") {
12300
+ if (renderSelectionCheckBox && !event.key) {
12301
+ return false;
12302
+ }
12303
+ rowSelectionState = new RowSelectionState(rowSelectionState, rowSelectionStateConfigGetter(getDataSourceState));
12304
+ multiRowSelector.rowSelectionState = rowSelectionState;
12305
+ if (rowSelectionState && typeof rowSelectionState === "object") {
12306
+ if (event.shiftKey) {
12307
+ multiRowSelector.multiSelectClick(rowIndex);
12308
+ } else if (event.metaKey || event.ctrlKey) {
12309
+ multiRowSelector.singleAddClick(rowIndex);
12310
+ } else {
12311
+ multiRowSelector.resetClick(rowIndex);
12312
+ }
12313
+ dataSourceActions.rowSelection = rowSelectionState;
12314
+ return true;
12315
+ }
12316
+ } else if (selectionMode === "single-row") {
12317
+ }
12318
+ return false;
12319
+ }
12320
+
12321
+ // src/components/utils/clamp.ts
12322
+ function clamp(value, min, max) {
12323
+ return Math.min(Math.max(value, min), max);
12324
+ }
12325
+
12326
+ // src/components/InfiniteTable/eventHandlers/keyboardNavigation.ts
12327
+ function handleRowNavigation(options) {
12328
+ const { key, getState, getDataSourceState, actions, api } = options;
12329
+ const dataArray = getDataSourceState().dataArray;
12330
+ const arrLength = dataArray.length;
12331
+ const state = getState();
12332
+ const { brain } = state;
12333
+ let { activeRowIndex } = state;
12334
+ if (activeRowIndex == null) {
12335
+ return false;
12336
+ }
12337
+ const {
12338
+ start: [startRow],
12339
+ end: [endRow]
12340
+ } = brain.getRenderRange();
12341
+ const renderRowCount = endRow - startRow - 1;
12342
+ const min = 0;
12343
+ const max = arrLength - 1;
12344
+ const KeyToFunction = {
12345
+ ArrowDown: () => {
12346
+ activeRowIndex = clamp(activeRowIndex + 1, min, max);
12347
+ },
12348
+ ArrowUp: () => {
12349
+ activeRowIndex = clamp(activeRowIndex - 1, min, max);
12350
+ },
12351
+ ArrowLeft: () => {
12352
+ const rowInfo = dataArray[activeRowIndex];
12353
+ if (rowInfo && rowInfo.isGroupRow) {
12354
+ return api.collapseGroupRow(rowInfo.groupKeys);
12355
+ }
12356
+ return false;
12357
+ },
12358
+ ArrowRight: () => {
12359
+ const rowInfo = dataArray[activeRowIndex];
12360
+ if (rowInfo && rowInfo.isGroupRow) {
12361
+ return api.expandGroupRow(rowInfo.groupKeys);
12362
+ }
12363
+ return false;
12364
+ },
12365
+ Enter: () => {
12366
+ const rowInfo = dataArray[activeRowIndex];
12367
+ if (rowInfo && rowInfo.isGroupRow) {
12368
+ return api.toggleGroupRow(rowInfo.groupKeys);
12369
+ }
12370
+ return false;
12371
+ },
12372
+ PageDown: () => {
12373
+ activeRowIndex = Math.min(activeRowIndex + renderRowCount, arrLength - 1);
12374
+ },
12375
+ PageUp: () => {
12376
+ activeRowIndex = Math.max(activeRowIndex - renderRowCount, min);
12377
+ },
12378
+ End: () => {
12379
+ activeRowIndex = max;
12380
+ },
12381
+ Home: () => {
12382
+ activeRowIndex = min;
12383
+ }
12384
+ };
12385
+ const Fn = KeyToFunction[key];
12386
+ if (!Fn) {
12387
+ return false;
12388
+ }
12389
+ Fn();
12390
+ actions.activeRowIndex = activeRowIndex;
12391
+ return true;
12392
+ }
12393
+ function handleCellNavigation(options) {
12394
+ const {
12395
+ api,
12396
+ key,
12397
+ shiftKey,
12398
+ getState,
12399
+ getComputed,
12400
+ getDataSourceState,
12401
+ actions
12402
+ } = options;
12403
+ const dataArray = getDataSourceState().dataArray;
12404
+ const state = getState();
12405
+ const { activeCellIndex, brain } = state;
12406
+ if (!activeCellIndex) {
12407
+ return false;
12408
+ }
12409
+ let [rowIndex, colIndex] = activeCellIndex;
12410
+ const {
12411
+ start: [startRow, startCol],
12412
+ end: [endRow, endCol]
12413
+ } = brain.getRenderRange();
12414
+ const renderRowCount = endRow - startRow - 1;
12415
+ const renderColCount = endCol - startCol - 1;
12416
+ const maxRow = getDataSourceState().dataArray.length - 1;
12417
+ const maxCol = getComputed().computedVisibleColumns.length - 1;
12418
+ const minRow = 0;
12419
+ const minCol = 0;
12420
+ rowIndex = clamp(rowIndex, 0, maxRow);
12421
+ colIndex = clamp(colIndex, 0, maxCol);
12422
+ actions.activeCellIndex = [rowIndex, colIndex];
12423
+ const KeyToFunction = {
12424
+ ArrowDown: () => {
12425
+ rowIndex = clamp(rowIndex + 1, minRow, maxRow);
12426
+ },
12427
+ ArrowUp: () => {
12428
+ rowIndex = clamp(rowIndex - 1, minRow, maxRow);
12429
+ },
12430
+ ArrowLeft: () => {
12431
+ colIndex = clamp(colIndex - 1, minCol, maxCol);
12432
+ },
12433
+ ArrowRight: () => {
12434
+ colIndex = clamp(colIndex + 1, minCol, maxCol);
12435
+ },
12436
+ Enter: () => {
12437
+ const rowInfo = dataArray[rowIndex];
12438
+ if (rowInfo && rowInfo.isGroupRow) {
12439
+ return api.toggleGroupRow(rowInfo.groupKeys);
12440
+ }
12441
+ return false;
12442
+ },
12443
+ PageDown: () => {
12444
+ if (!shiftKey) {
12445
+ rowIndex = Math.min(rowIndex + renderRowCount, maxRow);
12446
+ } else {
12447
+ colIndex = Math.min(colIndex + renderColCount, maxCol);
12448
+ }
12449
+ },
12450
+ PageUp: () => {
12451
+ if (!shiftKey) {
12452
+ rowIndex = Math.max(rowIndex - renderRowCount, minRow);
12453
+ } else {
12454
+ colIndex = Math.max(colIndex - renderColCount, minCol);
12455
+ }
12456
+ },
12457
+ End: () => {
12458
+ if (!shiftKey) {
12459
+ rowIndex = maxRow;
12460
+ } else {
12461
+ colIndex = maxCol;
12462
+ }
12463
+ },
12464
+ Home: () => {
12465
+ if (!shiftKey) {
12466
+ rowIndex = minRow;
12467
+ } else {
12468
+ colIndex = minCol;
12469
+ }
12470
+ }
12471
+ };
12472
+ const Fn = KeyToFunction[key];
12473
+ if (!Fn) {
12474
+ return false;
12475
+ }
12476
+ Fn();
12477
+ actions.activeCellIndex = [rowIndex, colIndex];
12478
+ return true;
12479
+ }
12480
+ var validKeys = {
12481
+ ArrowUp: true,
12482
+ ArrowDown: true,
12483
+ ArrowLeft: true,
12484
+ ArrowRight: true,
12485
+ PageUp: true,
12486
+ PageDown: true,
12487
+ Home: true,
12488
+ End: true,
12489
+ Enter: true,
12490
+ " ": true
12491
+ };
12492
+ function handleKeyboardNavigation(options) {
12493
+ const { getState } = options;
12494
+ const state = getState();
12495
+ const { activeRowIndex, activeCellIndex, keyboardNavigation } = state;
12496
+ if (!validKeys[options.key]) {
12497
+ return false;
12498
+ }
12499
+ if (activeRowIndex != null && keyboardNavigation === "row") {
12500
+ return handleRowNavigation(options);
12501
+ }
12502
+ if (activeCellIndex != null && keyboardNavigation === "cell") {
12503
+ return handleCellNavigation(options);
12504
+ }
12505
+ return false;
12506
+ }
12507
+
12508
+ // src/components/InfiniteTable/eventHandlers/keyboardSelection.ts
12509
+ var validKeys2 = {
12510
+ Enter: true,
12511
+ " ": true,
12512
+ a: true
12513
+ };
12514
+ function handleKeyboardSelection(context) {
12515
+ const {
12516
+ getState,
12517
+ getDataSourceState,
12518
+ dataSourceActions,
12519
+ api: imperativeApi,
12520
+ key,
12521
+ ctrlKey,
12522
+ metaKey
12523
+ } = context;
12524
+ if (!validKeys2[key]) {
12525
+ return false;
12526
+ }
12527
+ const state = getState();
12528
+ const dataSourceState = getDataSourceState();
12529
+ const {
12530
+ activeRowIndex,
12531
+ activeCellIndex,
12532
+ keyboardNavigation,
12533
+ keyboardSelection
12534
+ } = state;
12535
+ const { selectionMode, groupBy, rowSelection } = dataSourceState;
12536
+ if (keyboardSelection === false) {
12537
+ return false;
12538
+ }
12539
+ const rowIndex = keyboardNavigation === "row" && activeRowIndex != null ? activeRowIndex : keyboardNavigation === "cell" && activeCellIndex != null ? activeCellIndex[0] : null;
12540
+ const rowInfo = rowIndex != null ? dataSourceState.dataArray[rowIndex] : null;
12541
+ if (!rowInfo || rowIndex == null) {
12542
+ return false;
12543
+ }
12544
+ if (selectionMode === "single-row" && key === " ") {
12545
+ imperativeApi.selectionApi.toggleRowSelection(rowInfo.id);
12546
+ return true;
12547
+ }
12548
+ if (selectionMode !== "multi-row") {
12549
+ return false;
12550
+ }
12551
+ if (key === "a" && (ctrlKey || metaKey)) {
12552
+ const rowSelectionState = new RowSelectionState(rowSelection, rowSelectionStateConfigGetter(getDataSourceState));
12553
+ rowSelectionState.selectAll();
12554
+ dataSourceActions.rowSelection = rowSelectionState;
12555
+ return true;
12556
+ }
12557
+ if (key === " ") {
12558
+ if (groupBy.length) {
12559
+ if (rowInfo.isGroupRow) {
12560
+ imperativeApi.selectionApi.toggleGroupRowSelection(rowInfo.groupKeys);
12561
+ } else {
12562
+ imperativeApi.selectionApi.toggleRowSelection(rowInfo.id);
12563
+ }
12564
+ return true;
12565
+ } else {
12566
+ const event = __spreadValues({}, context);
12567
+ const { renderSelectionCheckBox } = context.getComputed();
12568
+ if (renderSelectionCheckBox) {
12569
+ event.shiftKey = false;
12570
+ event.metaKey = false;
12571
+ event.ctrlKey = true;
12572
+ }
12573
+ return updateRowSelectionOnCellClick(__spreadProps(__spreadValues({}, context), { rowIndex }), event);
12574
+ }
12575
+ }
12576
+ return false;
12577
+ }
12578
+
12579
+ // src/components/InfiniteTable/eventHandlers/onKeyDown.ts
12580
+ function onKeyDown(context, event) {
12581
+ const keyboardHandlerContext = __spreadProps(__spreadValues({}, context), {
12582
+ key: event.key,
12583
+ metaKey: event.metaKey,
12584
+ ctrlKey: event.ctrlKey,
12585
+ shiftKey: event.shiftKey
12586
+ });
12587
+ if (handleKeyboardSelection(keyboardHandlerContext)) {
12588
+ event.preventDefault();
12589
+ }
12590
+ if (handleKeyboardNavigation(keyboardHandlerContext)) {
12591
+ event.preventDefault();
12592
+ }
12593
+ }
12594
+
12595
+ // src/components/InfiniteTable/eventHandlers/index.ts
12596
+ function useEventHandlersContext() {
12597
+ const {
12598
+ getState,
12599
+ componentActions: actions,
12600
+ imperativeApi,
12601
+ getComputed
12602
+ } = useInfiniteTable();
12603
+ const { getState: getDataSourceState, componentActions: dataSourceActions } = useDataSourceContextValue();
12604
+ const context = (0, import_react48.useMemo)(() => {
12605
+ const context2 = {
12606
+ getComputed,
12607
+ api: imperativeApi,
12608
+ getState,
12609
+ actions,
12610
+ getDataSourceState,
12611
+ dataSourceActions
12612
+ };
12613
+ return context2;
12614
+ }, [getState, actions, getDataSourceState, dataSourceActions]);
12615
+ return context;
12616
+ }
12617
+ function handleDOMEvents() {
12618
+ const context = useEventHandlersContext();
12619
+ (0, import_react48.useEffect)(() => {
12620
+ const removeOnKeyDown = context.getState().keyDown.onChange((event) => {
12621
+ onKeyDown(__spreadProps(__spreadValues({}, context), {
12622
+ key: event.key,
12623
+ metaKey: event.metaKey,
12624
+ ctrlKey: event.ctrlKey,
12625
+ shiftKey: event.shiftKey,
12626
+ preventDefault: () => event.preventDefault()
12627
+ }), event);
12628
+ });
12629
+ function cellClickHandler(cellClickParam) {
12630
+ if (!cellClickParam) {
12631
+ return;
12632
+ }
12633
+ const event = cellClickParam.event;
12634
+ const virtualEvent = {
12635
+ metaKey: event.metaKey,
12636
+ ctrlKey: event.ctrlKey,
12637
+ shiftKey: event.shiftKey,
12638
+ key: "",
12639
+ preventDefault: () => event.preventDefault()
12640
+ };
12641
+ onCellClick(__spreadValues(__spreadProps(__spreadValues({}, context), {
12642
+ rowIndex: cellClickParam.rowIndex,
12643
+ colIndex: cellClickParam.colIndex
12644
+ }), virtualEvent), virtualEvent);
12645
+ }
12646
+ const removeOnCellClick = context.getState().cellClick.onChange(cellClickHandler);
12647
+ return () => {
12648
+ removeOnKeyDown();
12649
+ removeOnCellClick();
12650
+ };
12651
+ }, []);
12652
+ }
12653
+ function subscribeToDOMEvents() {
12654
+ const { getState } = useInfiniteTable();
12655
+ const onKeyDown2 = (0, import_react48.useCallback)((event) => {
12656
+ getState().keyDown(event);
12657
+ }, []);
12658
+ return { onKeyDown: onKeyDown2 };
12659
+ }
12660
+ function useDOMEventHandlers() {
12661
+ handleDOMEvents();
12662
+ return subscribeToDOMEvents();
12663
+ }
12664
+
12114
12665
  // src/components/InfiniteTable/index.tsx
12115
12666
  var InfiniteTableClassName = internalProps.rootClassName;
12116
12667
  var HOVERED_CLASS_NAMES = [RowHoverCls, "InfiniteColumnCell--hovered"];
@@ -12128,14 +12679,7 @@ var InfiniteTableRoot = getComponentStateRoot({
12128
12679
  });
12129
12680
  var InfiniteTableComponent = React38.memo(function InfiniteTableComponent2() {
12130
12681
  var _a;
12131
- const {
12132
- componentState,
12133
- getComputed,
12134
- computed,
12135
- componentActions: actions,
12136
- getState,
12137
- imperativeApi
12138
- } = useInfiniteTable();
12682
+ const { componentState, getComputed, computed, imperativeApi } = useInfiniteTable();
12139
12683
  const {
12140
12684
  componentState: { loading, dataArray },
12141
12685
  getState: getDataSourceState,
@@ -12164,7 +12708,7 @@ var InfiniteTableComponent = React38.memo(function InfiniteTableComponent2() {
12164
12708
  } = componentState;
12165
12709
  useScrollToActiveRow(activeRowIndex, dataArray.length, imperativeApi);
12166
12710
  useScrollToActiveCell(activeCellIndex, dataArray.length, imperativeApi);
12167
- useRowSelection();
12711
+ const { onKeyDown: onKeyDown2 } = useDOMEventHandlers();
12168
12712
  const { bodySize } = componentState;
12169
12713
  const { scrollbars } = computed;
12170
12714
  const { renderCell } = useCellRendering({
@@ -12192,22 +12736,8 @@ var InfiniteTableComponent = React38.memo(function InfiniteTableComponent2() {
12192
12736
  dataSourceActions.scrollStopDelayUpdatedByTable = scrollStopDelay;
12193
12737
  }, [scrollStopDelay]);
12194
12738
  useAutoSizeColumns();
12195
- const onKeyDown = (0, import_react49.useCallback)((event) => {
12196
- getState().keyDown(event);
12197
- if (handleKeyboardNavigation({
12198
- getState,
12199
- actions,
12200
- getDataSourceState,
12201
- getComputed,
12202
- imperativeApi,
12203
- key: event.key,
12204
- shiftKey: !!event.shiftKey
12205
- })) {
12206
- event.preventDefault();
12207
- }
12208
- }, []);
12209
12739
  return /* @__PURE__ */ React38.createElement("div", __spreadValues({
12210
- onKeyDown,
12740
+ onKeyDown: onKeyDown2,
12211
12741
  ref: domRef
12212
12742
  }, domProps), header ? /* @__PURE__ */ React38.createElement(TableHeaderWrapper, {
12213
12743
  bodyBrain: brain,
@@ -12254,8 +12784,14 @@ function InfiniteTableContextProvider() {
12254
12784
  globalThis.getComputed = getComputed;
12255
12785
  }
12256
12786
  const { getState: getDataSourceState, componentActions: dataSourceActions } = useDataSourceContextValue();
12257
- const [imperativeApi] = (0, import_react49.useState)(() => {
12258
- return getImperativeApi(getComputed, getState, getDataSourceState, componentActions, dataSourceActions);
12787
+ const [imperativeApi] = React38.useState(() => {
12788
+ return getImperativeApi({
12789
+ getComputed,
12790
+ getState,
12791
+ getDataSourceState,
12792
+ componentActions,
12793
+ dataSourceActions
12794
+ });
12259
12795
  });
12260
12796
  const contextValue = {
12261
12797
  componentActions,