@infinite-table/infinite-react 5.0.0-canary.0 → 5.0.0-canary.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.dev.js CHANGED
@@ -1410,7 +1410,7 @@ function stripVar(cssVariableWithVarString) {
1410
1410
  }
1411
1411
 
1412
1412
  // src/components/InfiniteTable/internalVars.css.ts
1413
- var InternalVars = { currentColumnTransformX: "var(--currentColumnTransformX__16hkbkc0)", y: "var(--y__16hkbkc1)", activeCellRowOffset: "var(--activeCellRowOffset__16hkbkc2)", activeCellRowHeight: "var(--activeCellRowHeight__16hkbkc3)", activeCellOffsetX: "var(--activeCellOffsetX__16hkbkc4)", activeCellOffsetY: "var(--activeCellOffsetY__16hkbkc5)", scrollTopForActiveRow: "var(--scrollTopForActiveRow__16hkbkc6)", activeCellColWidth: "var(--activeCellColWidth__16hkbkc7)", activeCellColOffset: "var(--activeCellColOffset__16hkbkc8)", columnReorderEffectDurationAtIndex: "var(--columnReorderEffectDurationAtIndex__16hkbkc9)", columnWidthAtIndex: "var(--columnWidthAtIndex__16hkbkca)", columnOffsetAtIndex: "var(--columnOffsetAtIndex__16hkbkcb)", columnOffsetAtIndexWhileReordering: "var(--columnOffsetAtIndexWhileReordering__16hkbkcc)", columnZIndexAtIndex: "var(--columnZIndexAtIndex__16hkbkcd)", pinnedStartWidth: "var(--pinnedStartWidth__16hkbkce)", pinnedEndWidth: "var(--pinnedEndWidth__16hkbkcf)", pinnedEndOffset: "var(--pinnedEndOffset__16hkbkcg)", computedVisibleColumnsCount: "var(--computedVisibleColumnsCount__16hkbkch)", baseZIndexForCells: "var(--baseZIndexForCells__16hkbkci)", bodyWidth: "var(--bodyWidth__16hkbkcj)", bodyHeight: "var(--bodyHeight__16hkbkck)", scrollbarWidthHorizontal: "var(--scrollbarWidthHorizontal__16hkbkcl)", scrollbarWidthVertical: "var(--scrollbarWidthVertical__16hkbkcm)", scrollLeft: "var(--scrollLeft__16hkbkcn)", scrollTop: "var(--scrollTop__16hkbkco)" };
1413
+ var InternalVars = { currentColumnTransformX: "var(--currentColumnTransformX__16hkbkc0)", y: "var(--y__16hkbkc1)", activeCellRowOffset: "var(--activeCellRowOffset__16hkbkc2)", activeCellRowOffsetX: "var(--activeCellRowOffsetX__16hkbkc3)", activeCellRowHeight: "var(--activeCellRowHeight__16hkbkc4)", activeCellOffsetX: "var(--activeCellOffsetX__16hkbkc5)", activeCellOffsetY: "var(--activeCellOffsetY__16hkbkc6)", scrollTopForActiveRow: "var(--scrollTopForActiveRow__16hkbkc7)", scrollLeftForActiveRowWhenHorizontalLayout: "var(--scrollLeftForActiveRowWhenHorizontalLayout__16hkbkc8)", activeCellColWidth: "var(--activeCellColWidth__16hkbkc9)", activeCellColOffset: "var(--activeCellColOffset__16hkbkca)", columnReorderEffectDurationAtIndex: "var(--columnReorderEffectDurationAtIndex__16hkbkcb)", columnWidthAtIndex: "var(--columnWidthAtIndex__16hkbkcc)", columnOffsetAtIndex: "var(--columnOffsetAtIndex__16hkbkcd)", columnOffsetAtIndexWhileReordering: "var(--columnOffsetAtIndexWhileReordering__16hkbkce)", columnZIndexAtIndex: "var(--columnZIndexAtIndex__16hkbkcf)", pinnedStartWidth: "var(--pinnedStartWidth__16hkbkcg)", pinnedEndWidth: "var(--pinnedEndWidth__16hkbkch)", pinnedEndOffset: "var(--pinnedEndOffset__16hkbkci)", computedVisibleColumnsCount: "var(--computedVisibleColumnsCount__16hkbkcj)", baseZIndexForCells: "var(--baseZIndexForCells__16hkbkck)", bodyWidth: "var(--bodyWidth__16hkbkcl)", bodyHeight: "var(--bodyHeight__16hkbkcm)", scrollbarWidthHorizontal: "var(--scrollbarWidthHorizontal__16hkbkcn)", scrollbarWidthVertical: "var(--scrollbarWidthVertical__16hkbkco)", scrollLeft: "var(--scrollLeft__16hkbkcp)", scrollTop: "var(--scrollTop__16hkbkcq)" };
1414
1414
 
1415
1415
  // src/utils/selectParent.ts
1416
1416
  function selectParent(el, selector2) {
@@ -3122,11 +3122,13 @@ var ReactHeadlessTableRenderer = class extends Logger {
3122
3122
  return { start: startRow, end: endRow };
3123
3123
  };
3124
3124
  this.getScrollPositionForScrollRowIntoView = (rowIndex, config = { offset: 0 }) => {
3125
+ var _a;
3125
3126
  if (this.destroyed) {
3126
3127
  return null;
3127
3128
  }
3128
3129
  const { brain } = this;
3129
3130
  const scrollPosition = brain.getScrollPosition();
3131
+ let scrollLeft2 = scrollPosition.scrollLeft;
3130
3132
  let { scrollAdjustPosition, offset = 0 } = config;
3131
3133
  if (this.isRowFullyVisible(rowIndex) && !scrollAdjustPosition) {
3132
3134
  return scrollPosition;
@@ -3156,9 +3158,22 @@ var ReactHeadlessTableRenderer = class extends Logger {
3156
3158
  offset += rowHeight;
3157
3159
  scrollTop2 += rowOffset - bottom + offset + fixedEndRowsHeight;
3158
3160
  }
3159
- return __spreadProps(__spreadValues({}, scrollPosition), {
3161
+ if (this.brain.isHorizontalLayoutBrain) {
3162
+ const colIndex = (_a = config.colIndex) != null ? _a : Math.ceil(this.brain.getInitialCols() / 2);
3163
+ const colScrollPosition = this.getScrollPositionForScrollColumnIntoView(
3164
+ colIndex,
3165
+ __spreadProps(__spreadValues({}, config), {
3166
+ horizontalLayoutPageIndex: this.brain.getPageIndexForRow(rowIndex)
3167
+ })
3168
+ );
3169
+ if (colScrollPosition) {
3170
+ scrollLeft2 = colScrollPosition.scrollLeft;
3171
+ }
3172
+ }
3173
+ return {
3174
+ scrollLeft: scrollLeft2,
3160
3175
  scrollTop: scrollTop2
3161
- });
3176
+ };
3162
3177
  };
3163
3178
  this.getScrollPositionForScrollColumnIntoView = (colIndex, config = { offset: 0 }) => {
3164
3179
  if (this.destroyed) {
@@ -4269,9 +4284,9 @@ var HorizontalLayoutTableRenderer = class extends ReactHeadlessTableRenderer {
4269
4284
  element.style.setProperty(currentTransformY, currentTransformYValue);
4270
4285
  }
4271
4286
  const xOffset = `calc(var(${columnOffsetX}) + ${pageOffset})`;
4272
- const transformX = `var(${columnOffsetXWhileReordering}, ${xOffset})`;
4287
+ const transformX2 = `var(${columnOffsetXWhileReordering}, ${xOffset})`;
4273
4288
  const transformY = `var(${currentTransformY})`;
4274
- const transformValue = `translate3d(${transformX}, ${transformY}, 0px)`;
4289
+ const transformValue = `translate3d(${transformX2}, ${transformY}, 0px)`;
4275
4290
  if (element.__transformValue !== transformValue) {
4276
4291
  element.__transformValue = transformValue;
4277
4292
  element.style.transform = transformValue;
@@ -4395,46 +4410,169 @@ var useRerender = () => {
4395
4410
  var ActiveCellIndicatorCls = { visible: "ActiveCellIndicator_ActiveCellIndicatorCls_visible__nxbq1c2 ActiveCellIndicator_ActiveCellIndicator__nxbq1c1 utilities_pointerEvents_none__16lm1iwl utilities_position_absolute__16lm1iw2", hidden: "ActiveCellIndicator_ActiveCellIndicatorCls_hidden__nxbq1c3 ActiveCellIndicator_ActiveCellIndicator__nxbq1c1 utilities_pointerEvents_none__16lm1iwl utilities_position_absolute__16lm1iw2" };
4396
4411
  var ActiveIndicatorWrapperCls = "ActiveCellIndicator_ActiveIndicatorWrapperCls__nxbq1c0 utilities_pointerEvents_none__16lm1iwl utilities_position_sticky__16lm1iw4 utilities_left_0__16lm1iw1e utilities_top_0__16lm1iw1c utilities_height_0__16lm1iw18 utilities_zIndex_1000000__16lm1iwu";
4397
4412
 
4413
+ // ../node_modules/@vanilla-extract/recipes/dist/createRuntimeFn-62c9670f.esm.js
4414
+ function toPrimitive(t, r) {
4415
+ if ("object" != typeof t || !t)
4416
+ return t;
4417
+ var e = t[Symbol.toPrimitive];
4418
+ if (void 0 !== e) {
4419
+ var i = e.call(t, r || "default");
4420
+ if ("object" != typeof i)
4421
+ return i;
4422
+ throw new TypeError("@@toPrimitive must return a primitive value.");
4423
+ }
4424
+ return ("string" === r ? String : Number)(t);
4425
+ }
4426
+ function toPropertyKey(t) {
4427
+ var i = toPrimitive(t, "string");
4428
+ return "symbol" == typeof i ? i : String(i);
4429
+ }
4430
+ function _defineProperty(obj, key, value) {
4431
+ key = toPropertyKey(key);
4432
+ if (key in obj) {
4433
+ Object.defineProperty(obj, key, {
4434
+ value,
4435
+ enumerable: true,
4436
+ configurable: true,
4437
+ writable: true
4438
+ });
4439
+ } else {
4440
+ obj[key] = value;
4441
+ }
4442
+ return obj;
4443
+ }
4444
+ function ownKeys(e, r) {
4445
+ var t = Object.keys(e);
4446
+ if (Object.getOwnPropertySymbols) {
4447
+ var o = Object.getOwnPropertySymbols(e);
4448
+ r && (o = o.filter(function(r2) {
4449
+ return Object.getOwnPropertyDescriptor(e, r2).enumerable;
4450
+ })), t.push.apply(t, o);
4451
+ }
4452
+ return t;
4453
+ }
4454
+ function _objectSpread2(e) {
4455
+ for (var r = 1; r < arguments.length; r++) {
4456
+ var t = null != arguments[r] ? arguments[r] : {};
4457
+ r % 2 ? ownKeys(Object(t), true).forEach(function(r2) {
4458
+ _defineProperty(e, r2, t[r2]);
4459
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r2) {
4460
+ Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
4461
+ });
4462
+ }
4463
+ return e;
4464
+ }
4465
+ function mapValues(input, fn) {
4466
+ var result = {};
4467
+ for (var _key in input) {
4468
+ result[_key] = fn(input[_key], _key);
4469
+ }
4470
+ return result;
4471
+ }
4472
+ var shouldApplyCompound = (compoundCheck, selections, defaultVariants) => {
4473
+ for (var key of Object.keys(compoundCheck)) {
4474
+ var _selections$key;
4475
+ if (compoundCheck[key] !== ((_selections$key = selections[key]) !== null && _selections$key !== void 0 ? _selections$key : defaultVariants[key])) {
4476
+ return false;
4477
+ }
4478
+ }
4479
+ return true;
4480
+ };
4481
+ var createRuntimeFn = (config) => {
4482
+ var runtimeFn = (options) => {
4483
+ var className = config.defaultClassName;
4484
+ var selections = _objectSpread2(_objectSpread2({}, config.defaultVariants), options);
4485
+ for (var variantName in selections) {
4486
+ var _selections$variantNa;
4487
+ var variantSelection = (_selections$variantNa = selections[variantName]) !== null && _selections$variantNa !== void 0 ? _selections$variantNa : config.defaultVariants[variantName];
4488
+ if (variantSelection != null) {
4489
+ var selection = variantSelection;
4490
+ if (typeof selection === "boolean") {
4491
+ selection = selection === true ? "true" : "false";
4492
+ }
4493
+ var selectionClassName = (
4494
+ // @ts-expect-error
4495
+ config.variantClassNames[variantName][selection]
4496
+ );
4497
+ if (selectionClassName) {
4498
+ className += " " + selectionClassName;
4499
+ }
4500
+ }
4501
+ }
4502
+ for (var [compoundCheck, compoundClassName] of config.compoundVariants) {
4503
+ if (shouldApplyCompound(compoundCheck, selections, config.defaultVariants)) {
4504
+ className += " " + compoundClassName;
4505
+ }
4506
+ }
4507
+ return className;
4508
+ };
4509
+ runtimeFn.variants = () => Object.keys(config.variantClassNames);
4510
+ runtimeFn.classNames = {
4511
+ get base() {
4512
+ return config.defaultClassName.split(" ")[0];
4513
+ },
4514
+ get variants() {
4515
+ return mapValues(config.variantClassNames, (classNames) => mapValues(classNames, (className) => className.split(" ")[0]));
4516
+ }
4517
+ };
4518
+ return runtimeFn;
4519
+ };
4520
+
4398
4521
  // src/components/InfiniteTable/components/ActiveRowIndicator.css.ts
4399
- var ActiveRowIndicatorCls = { visible: "ActiveRowIndicator_ActiveRowIndicatorCls_visible__j26lrx1 ActiveRowIndicator_ActiveRowIndicator__j26lrx0 utilities_pointerEvents_none__16lm1iwl utilities_position_absolute__16lm1iw2 utilities_top_0__16lm1iw1c utilities_left_0__16lm1iw1e", hidden: "ActiveRowIndicator_ActiveRowIndicatorCls_hidden__j26lrx2 ActiveRowIndicator_ActiveRowIndicator__j26lrx0 utilities_pointerEvents_none__16lm1iwl utilities_position_absolute__16lm1iw2 utilities_top_0__16lm1iw1c utilities_left_0__16lm1iw1e" };
4522
+ var ActiveRowIndicatorRecipe = createRuntimeFn({ defaultClassName: "ActiveRowIndicator_ActiveRowIndicator__j26lrx0 utilities_pointerEvents_none__16lm1iwl utilities_position_absolute__16lm1iw2 utilities_top_0__16lm1iw1c utilities_left_0__16lm1iw1e", variantClassNames: { active: { true: "ActiveRowIndicator_ActiveRowIndicatorRecipe_active_true__j26lrx2", false: "ActiveRowIndicator_ActiveRowIndicatorRecipe_active_false__j26lrx3" } }, defaultVariants: {}, compoundVariants: [] });
4400
4523
 
4401
4524
  // src/components/InfiniteTable/components/ActiveRowIndicator.tsx
4402
4525
  var { rootClassName: rootClassName3 } = internalProps;
4403
4526
  var baseCls = `${rootClassName3}-ActiveRowIndicator`;
4527
+ var transformX = `calc(${InternalVars.activeCellRowOffsetX} + var(${stripVar(
4528
+ InternalVars.scrollLeftForActiveRowWhenHorizontalLayout
4529
+ )}, 0px))`;
4404
4530
  var ActiveStyle = {
4405
4531
  [stripVar(InternalVars.activeCellOffsetY)]: InternalVars.activeCellRowOffset,
4406
- transform: `translate3d(0px, calc( ${InternalVars.activeCellOffsetY} + var(${stripVar(InternalVars.scrollTopForActiveRow)}, 0px)), 0px)`,
4532
+ transform: `translate3d(${transformX}, calc( ${InternalVars.activeCellOffsetY} + var(${stripVar(InternalVars.scrollTopForActiveRow)}, 0px)), 0px)`,
4407
4533
  height: InternalVars.activeCellRowHeight,
4408
4534
  maxWidth: ThemeVars.runtime.totalVisibleColumnsWidthVar
4409
4535
  };
4410
4536
  var ActiveRowIndicatorFn = (props) => {
4411
4537
  const { brain } = props;
4412
4538
  const domRef = (0, import_react8.useRef)(null);
4413
- const active = props.activeRowIndex != null && brain.getRowCount() > props.activeRowIndex;
4539
+ const active = props.activeRowIndex != null && brain.getInitialRows() > props.activeRowIndex;
4414
4540
  const [_rerenderId, rerender] = useRerender();
4415
4541
  (0, import_react8.useLayoutEffect)(() => {
4416
4542
  if (props.activeRowIndex == null) {
4417
4543
  return;
4418
4544
  }
4419
- const rowIndex = props.activeRowIndex;
4545
+ let activeCellRowOffsetX = "0px";
4546
+ let rowIndex = props.activeRowIndex;
4547
+ if (brain.isHorizontalLayoutBrain && brain.rowsPerPage) {
4548
+ const pageIndex = brain.getPageIndexForRow(rowIndex);
4549
+ if (pageIndex > 0) {
4550
+ activeCellRowOffsetX = `calc(${ThemeVars.runtime.totalVisibleColumnsWidthVar} * ${pageIndex})`;
4551
+ }
4552
+ rowIndex = rowIndex % brain.rowsPerPage;
4553
+ }
4420
4554
  const activeCellRowHeight = brain.getRowHeight(rowIndex);
4421
4555
  const activeCellRowOffset = brain.getItemOffsetFor(rowIndex, "vertical");
4422
4556
  const node = domRef.current;
4423
4557
  const vars = {
4424
4558
  activeCellRowHeight: `${activeCellRowHeight}px`,
4425
- activeCellRowOffset: `${activeCellRowOffset}px`
4559
+ activeCellRowOffset: `${activeCellRowOffset}px`,
4560
+ activeCellRowOffsetX
4426
4561
  };
4427
4562
  setInfiniteVarsOnNode(vars, node);
4428
- }, [props.activeRowIndex]);
4563
+ }, [props.activeRowIndex, brain]);
4429
4564
  (0, import_react8.useEffect)(() => {
4430
- const removeOnScroll = brain.onScroll((scrollPosition) => {
4565
+ const updateVars = (scrollPosition) => {
4431
4566
  setInfiniteVarsOnNode(
4432
4567
  {
4433
- scrollTopForActiveRow: `${-scrollPosition.scrollTop}px`
4568
+ scrollTopForActiveRow: `${-scrollPosition.scrollTop}px`,
4569
+ scrollLeftForActiveRowWhenHorizontalLayout: `${-scrollPosition.scrollLeft}px`
4434
4570
  },
4435
4571
  domRef.current
4436
4572
  );
4437
- });
4573
+ };
4574
+ updateVars(brain.getScrollPosition());
4575
+ const removeOnScroll = brain.onScroll(updateVars);
4438
4576
  const removeOnRenderCountChange = brain.onRenderCountChange(rerender);
4439
4577
  return () => {
4440
4578
  removeOnRenderCountChange();
@@ -4448,7 +4586,9 @@ var ActiveRowIndicatorFn = (props) => {
4448
4586
  {
4449
4587
  ref: domRef,
4450
4588
  "data-name": "active-row-indicator",
4451
- className: `${baseCls} ${active ? ActiveRowIndicatorCls.visible : ActiveRowIndicatorCls.hidden}`,
4589
+ className: `${baseCls} ${ActiveRowIndicatorRecipe({
4590
+ active
4591
+ })}`,
4452
4592
  style: active ? ActiveStyle : void 0
4453
4593
  }
4454
4594
  ))
@@ -4490,7 +4630,7 @@ var ActiveCellIndicatorFn = (props) => {
4490
4630
  const active = props.activeCellIndex != null && brain.getInitialRows() > props.activeCellIndex[0];
4491
4631
  (0, import_react9.useLayoutEffect)(() => {
4492
4632
  reposition(brain, props.activeCellIndex, props.rowHeight, domRef);
4493
- }, [props.activeCellIndex, props.rowHeight]);
4633
+ }, [props.activeCellIndex, props.rowHeight, brain]);
4494
4634
  (0, import_react9.useEffect)(() => {
4495
4635
  const removeOnRenderCountChange = brain.onRenderCountChange(() => {
4496
4636
  rerender();
@@ -5254,114 +5394,6 @@ var useInfiniteTableState = () => {
5254
5394
  var React26 = __toESM(require("react"));
5255
5395
  var import_react18 = require("react");
5256
5396
 
5257
- // ../node_modules/@vanilla-extract/recipes/dist/createRuntimeFn-62c9670f.esm.js
5258
- function toPrimitive(t, r) {
5259
- if ("object" != typeof t || !t)
5260
- return t;
5261
- var e = t[Symbol.toPrimitive];
5262
- if (void 0 !== e) {
5263
- var i = e.call(t, r || "default");
5264
- if ("object" != typeof i)
5265
- return i;
5266
- throw new TypeError("@@toPrimitive must return a primitive value.");
5267
- }
5268
- return ("string" === r ? String : Number)(t);
5269
- }
5270
- function toPropertyKey(t) {
5271
- var i = toPrimitive(t, "string");
5272
- return "symbol" == typeof i ? i : String(i);
5273
- }
5274
- function _defineProperty(obj, key, value) {
5275
- key = toPropertyKey(key);
5276
- if (key in obj) {
5277
- Object.defineProperty(obj, key, {
5278
- value,
5279
- enumerable: true,
5280
- configurable: true,
5281
- writable: true
5282
- });
5283
- } else {
5284
- obj[key] = value;
5285
- }
5286
- return obj;
5287
- }
5288
- function ownKeys(e, r) {
5289
- var t = Object.keys(e);
5290
- if (Object.getOwnPropertySymbols) {
5291
- var o = Object.getOwnPropertySymbols(e);
5292
- r && (o = o.filter(function(r2) {
5293
- return Object.getOwnPropertyDescriptor(e, r2).enumerable;
5294
- })), t.push.apply(t, o);
5295
- }
5296
- return t;
5297
- }
5298
- function _objectSpread2(e) {
5299
- for (var r = 1; r < arguments.length; r++) {
5300
- var t = null != arguments[r] ? arguments[r] : {};
5301
- r % 2 ? ownKeys(Object(t), true).forEach(function(r2) {
5302
- _defineProperty(e, r2, t[r2]);
5303
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r2) {
5304
- Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
5305
- });
5306
- }
5307
- return e;
5308
- }
5309
- function mapValues(input, fn) {
5310
- var result = {};
5311
- for (var _key in input) {
5312
- result[_key] = fn(input[_key], _key);
5313
- }
5314
- return result;
5315
- }
5316
- var shouldApplyCompound = (compoundCheck, selections, defaultVariants) => {
5317
- for (var key of Object.keys(compoundCheck)) {
5318
- var _selections$key;
5319
- if (compoundCheck[key] !== ((_selections$key = selections[key]) !== null && _selections$key !== void 0 ? _selections$key : defaultVariants[key])) {
5320
- return false;
5321
- }
5322
- }
5323
- return true;
5324
- };
5325
- var createRuntimeFn = (config) => {
5326
- var runtimeFn = (options) => {
5327
- var className = config.defaultClassName;
5328
- var selections = _objectSpread2(_objectSpread2({}, config.defaultVariants), options);
5329
- for (var variantName in selections) {
5330
- var _selections$variantNa;
5331
- var variantSelection = (_selections$variantNa = selections[variantName]) !== null && _selections$variantNa !== void 0 ? _selections$variantNa : config.defaultVariants[variantName];
5332
- if (variantSelection != null) {
5333
- var selection = variantSelection;
5334
- if (typeof selection === "boolean") {
5335
- selection = selection === true ? "true" : "false";
5336
- }
5337
- var selectionClassName = (
5338
- // @ts-expect-error
5339
- config.variantClassNames[variantName][selection]
5340
- );
5341
- if (selectionClassName) {
5342
- className += " " + selectionClassName;
5343
- }
5344
- }
5345
- }
5346
- for (var [compoundCheck, compoundClassName] of config.compoundVariants) {
5347
- if (shouldApplyCompound(compoundCheck, selections, config.defaultVariants)) {
5348
- className += " " + compoundClassName;
5349
- }
5350
- }
5351
- return className;
5352
- };
5353
- runtimeFn.variants = () => Object.keys(config.variantClassNames);
5354
- runtimeFn.classNames = {
5355
- get base() {
5356
- return config.defaultClassName.split(" ")[0];
5357
- },
5358
- get variants() {
5359
- return mapValues(config.variantClassNames, (classNames) => mapValues(classNames, (className) => className.split(" ")[0]));
5360
- }
5361
- };
5362
- return runtimeFn;
5363
- };
5364
-
5365
5397
  // src/components/InfiniteTable/components/InfiniteTableHeader/header.css.ts
5366
5398
  var CellCls = "cell_CellCls__1eexc2a5 utilities_display_flex__16lm1iwz utilities_flexFlow_row__16lm1iw1o utilities_alignItems_center__16lm1iw1q utilities_position_absolute__16lm1iw2 utilities_willChange_transform__16lm1iw22 utilities_whiteSpace_nowrap__16lm1iw23 utilities_userSelect_none__16lm1iw17";
5367
5399
  var HeaderCellContentRecipe = createRuntimeFn({ defaultClassName: "header_HeaderCellContentRecipe__12zfob122 utilities_height_100%__16lm1iw19 utilities_width_100%__16lm1iw1b utilities_display_flex__16lm1iwz utilities_flexFlow_row__16lm1iw1o utilities_alignItems_center__16lm1iw1q utilities_justifyContent_start__16lm1iw1v", variantClassNames: { filtered: { false: "header_HeaderCellContentRecipe_filtered_false__12zfob123", true: "header_HeaderCellContentRecipe_filtered_true__12zfob124" }, verticalAlign: { start: "header_HeaderCellContentRecipe_verticalAlign_start__12zfob125", end: "header_HeaderCellContentRecipe_verticalAlign_end__12zfob126", center: "header_HeaderCellContentRecipe_verticalAlign_center__12zfob127" }, align: { start: "header_HeaderCellContentRecipe_align_start__12zfob128", end: "header_HeaderCellContentRecipe_align_end__12zfob129", center: "header_HeaderCellContentRecipe_align_center__12zfob12a" } }, defaultVariants: {}, compoundVariants: [] });
@@ -8795,6 +8827,7 @@ function InfiniteTableColumnCellFn(props) {
8795
8827
  if (inEdit) {
8796
8828
  return null;
8797
8829
  }
8830
+ renderParamRef.current = renderParam;
8798
8831
  if (renderFunctions.renderGroupIcon) {
8799
8832
  renderParam.renderBag.groupIcon = /* @__PURE__ */ React36.createElement(
8800
8833
  RenderCellHookComponent,
@@ -9008,6 +9041,7 @@ function InfiniteTableColumnCellFn(props) {
9008
9041
  bottom: bottomSelectionBorder
9009
9042
  } : null;
9010
9043
  const afterChildren = editor;
9044
+ const theChildren = renderChildren();
9011
9045
  const cellProps = {
9012
9046
  domRef,
9013
9047
  cellType: "body",
@@ -9046,7 +9080,7 @@ function InfiniteTableColumnCellFn(props) {
9046
9080
  colClassName,
9047
9081
  rowComputedClassName
9048
9082
  ),
9049
- renderChildren
9083
+ renderChildren: (0, import_react25.useCallback)(() => theChildren, [renderChildren])
9050
9084
  };
9051
9085
  const ContextProvider = InfiniteTableColumnCellContext.Provider;
9052
9086
  return (
@@ -10838,7 +10872,7 @@ function lazyGroup(groupParams, rootData) {
10838
10872
  rootData.visitDepthFirst(
10839
10873
  (lazyGroupRowInfo, keys, _index, next) => {
10840
10874
  const [_rootKey, ...currentGroupKeys] = keys;
10841
- const dataArray = lazyGroupRowInfo.children;
10875
+ let dataArray = lazyGroupRowInfo.children;
10842
10876
  const current = deepMap.get(currentGroupKeys);
10843
10877
  if (current) {
10844
10878
  current.cache = lazyGroupRowInfo.cache;
@@ -10861,10 +10895,11 @@ function lazyGroup(groupParams, rootData) {
10861
10895
  );
10862
10896
  }
10863
10897
  }
10864
- indexer.indexArray(dataArray, {
10898
+ const res = indexer.indexArray(dataArray, {
10865
10899
  toPrimaryKey,
10866
10900
  cache
10867
10901
  });
10902
+ dataArray = res;
10868
10903
  }
10869
10904
  return next == null ? void 0 : next();
10870
10905
  }
@@ -12857,11 +12892,15 @@ var Indexer = class {
12857
12892
  };
12858
12893
  this.indexArray = (arr, options) => {
12859
12894
  const { cache, toPrimaryKey } = options;
12895
+ if (cache && cache.shouldResetDataSource()) {
12896
+ this.clear();
12897
+ arr = [];
12898
+ }
12860
12899
  if (cache && !cache.isEmpty()) {
12861
12900
  arr = arr.concat();
12862
12901
  }
12863
12902
  if (!arr.length && cache) {
12864
- const cacheInfo = [...cache.getMutations().values()].flatMap((x) => x);
12903
+ const cacheInfo = cache.getMutationsArray();
12865
12904
  if (cacheInfo && cacheInfo.length) {
12866
12905
  for (let cacheIndex = 0, cacheLength = cacheInfo.length; cacheIndex < cacheLength; cacheIndex++) {
12867
12906
  const info = cacheInfo[cacheIndex];
@@ -13174,6 +13213,7 @@ function getPivotColumnsAndColumnGroups({
13174
13213
  }
13175
13214
 
13176
13215
  // src/components/DataSource/DataSourceCache.ts
13216
+ var CLEAR_SYMBOL = Symbol("CLEAR");
13177
13217
  var DataSourceCache = class {
13178
13218
  constructor() {
13179
13219
  this.affectedFields = /* @__PURE__ */ new Set();
@@ -13227,6 +13267,21 @@ var DataSourceCache = class {
13227
13267
  });
13228
13268
  this.primaryKeyToData.set(primaryKey, value);
13229
13269
  };
13270
+ this.resetDataSource = (metadata) => {
13271
+ this.clear();
13272
+ this.allFieldsAffected = true;
13273
+ const pk = CLEAR_SYMBOL;
13274
+ const value = this.primaryKeyToData.get(pk) || [];
13275
+ value.push({
13276
+ type: "clear-all",
13277
+ primaryKey: void 0,
13278
+ metadata
13279
+ });
13280
+ this.primaryKeyToData.set(pk, value);
13281
+ };
13282
+ this.shouldResetDataSource = () => {
13283
+ return this.primaryKeyToData.has(CLEAR_SYMBOL);
13284
+ };
13230
13285
  this.clear = () => {
13231
13286
  this.allFieldsAffected = false;
13232
13287
  this.affectedFields.clear();
@@ -13242,9 +13297,15 @@ var DataSourceCache = class {
13242
13297
  const data = this.primaryKeyToData.get(primaryKey);
13243
13298
  return data;
13244
13299
  };
13300
+ this.getMutationsCount = () => {
13301
+ return this.primaryKeyToData.size;
13302
+ };
13245
13303
  this.getMutations = () => {
13246
13304
  return new Map(this.primaryKeyToData);
13247
13305
  };
13306
+ this.getMutationsArray = () => {
13307
+ return Array.from(this.primaryKeyToData.values()).flat();
13308
+ };
13248
13309
  }
13249
13310
  static clone(cache, { light = false } = {}) {
13250
13311
  const clone = new DataSourceCache();
@@ -13506,6 +13567,32 @@ var DataSourceApiImpl = class {
13506
13567
  const { indexer } = this.getState();
13507
13568
  return (_a = indexer.getDataForPrimaryKey(id)) != null ? _a : null;
13508
13569
  };
13570
+ /**
13571
+ * Replaces all data in the DataSource with the provided data.
13572
+ * @param data - The new data to replace the existing data with.
13573
+ * @param options - Additional options for the operation.
13574
+ * @param options.flush - If true, the mutations will be flushed immediately.
13575
+ * @param options.metadata - Additional metadata for the operation.
13576
+ * @returns A promise that resolves when the operation is complete.
13577
+ */
13578
+ this.replaceAllData = (data, options) => {
13579
+ this.batchOperation({
13580
+ type: "replace-all",
13581
+ array: data,
13582
+ metadata: options == null ? void 0 : options.metadata
13583
+ });
13584
+ return this.addDataArray(data, options);
13585
+ };
13586
+ /**
13587
+ * Clears all data in the DataSource.
13588
+ * @param options - Additional options for the operation.
13589
+ * @param options.flush - If true, the mutations will be flushed immediately.
13590
+ * @param options.metadata - Additional metadata for the operation.
13591
+ * @returns A promise that resolves when the operation is complete.
13592
+ */
13593
+ this.clearAllData = (options) => {
13594
+ return this.replaceAllData([], options);
13595
+ };
13509
13596
  this.updateData = (data, options) => {
13510
13597
  return this.updateDataArray([data], options);
13511
13598
  };
@@ -13701,12 +13788,12 @@ var DataSourceApiImpl = class {
13701
13788
  }, delay);
13702
13789
  }
13703
13790
  }
13791
+ if (operation.type === "replace-all") {
13792
+ this.pendingOperations.length = 0;
13793
+ }
13704
13794
  this.pendingOperations.push(operation);
13705
13795
  return this.pendingPromise;
13706
13796
  }
13707
- batchOperations(operations) {
13708
- this.pendingOperations.push(...operations);
13709
- }
13710
13797
  commitOperations(operations) {
13711
13798
  if (!operations.length) {
13712
13799
  return;
@@ -13746,14 +13833,21 @@ var DataSourceApiImpl = class {
13746
13833
  position2 = "after";
13747
13834
  });
13748
13835
  break;
13836
+ case "replace-all":
13837
+ cache.resetDataSource(operation.metadata);
13838
+ break;
13749
13839
  }
13750
13840
  });
13751
13841
  this.actions.cache = cache;
13752
13842
  }
13843
+ flush() {
13844
+ return this.commit();
13845
+ }
13753
13846
  commit() {
13754
13847
  this.commitOperations(this.pendingOperations);
13755
13848
  this.pendingOperations.length = 0;
13756
- if (this.pendingPromise && this.resolvePendingPromise) {
13849
+ const pendingPromise = this.pendingPromise;
13850
+ if (pendingPromise && this.resolvePendingPromise) {
13757
13851
  const resolve = this.resolvePendingPromise;
13758
13852
  requestAnimationFrame(() => {
13759
13853
  resolve(true);
@@ -13761,6 +13855,7 @@ var DataSourceApiImpl = class {
13761
13855
  this.pendingPromise = null;
13762
13856
  this.resolvePendingPromise = null;
13763
13857
  }
13858
+ return pendingPromise || Promise.resolve(true);
13764
13859
  }
13765
13860
  };
13766
13861
  function getCacheAffectedParts(state) {
@@ -17021,22 +17116,35 @@ var InfiniteTableApiImpl = class {
17021
17116
  state.scrollerDOMRef.current.scrollTop = Math.max(scrollTop2, 0);
17022
17117
  }
17023
17118
  scrollRowIntoView(rowIndex, config = { offset: 0 }) {
17119
+ var _a;
17024
17120
  const state = this.getState();
17121
+ const computed = this.getComputed();
17122
+ const currentScrollPosition = state.brain.getScrollPosition();
17123
+ let columnId = config.columnId;
17124
+ let colIndex = void 0;
17125
+ if (!columnId && state.brain.isHorizontalLayoutBrain && computed.computedVisibleColumns.length > 0) {
17126
+ columnId = computed.computedVisibleColumns[Math.ceil(computed.computedVisibleColumns.length / 2)].id;
17127
+ colIndex = (_a = computed.computedVisibleColumnsMap.get(columnId)) == null ? void 0 : _a.computedVisibleIndex;
17128
+ }
17025
17129
  const scrollPosition = state.renderer.getScrollPositionForScrollRowIntoView(
17026
17130
  rowIndex,
17027
- config
17131
+ __spreadProps(__spreadValues({}, config), { colIndex })
17028
17132
  );
17029
17133
  if (!scrollPosition) {
17030
17134
  return false;
17031
17135
  }
17032
- const currentScrollPosition = state.brain.getScrollPosition();
17033
17136
  const scrollTopMax = state.brain.scrollTopMax;
17034
- if (scrollPosition.scrollTop > scrollTopMax + (config.offset || 0)) {
17137
+ const scrollLeftChanged = scrollPosition.scrollLeft !== currentScrollPosition.scrollLeft;
17138
+ const scrollTopValid = scrollPosition.scrollTop <= scrollTopMax + (config.offset || 0);
17139
+ if (!scrollTopValid && !scrollLeftChanged) {
17035
17140
  return false;
17036
17141
  }
17037
- if (scrollPosition.scrollTop !== currentScrollPosition.scrollTop) {
17142
+ if (scrollTopValid && scrollPosition.scrollTop !== currentScrollPosition.scrollTop) {
17038
17143
  state.scrollerDOMRef.current.scrollTop = scrollPosition.scrollTop;
17039
17144
  }
17145
+ if (scrollLeftChanged) {
17146
+ state.scrollerDOMRef.current.scrollLeft = scrollPosition.scrollLeft;
17147
+ }
17040
17148
  return true;
17041
17149
  }
17042
17150
  scrollColumnIntoView(columnId, config = { offset: 0 }) {
@@ -19720,7 +19828,7 @@ var useLicense = (licenseKey = "") => {
19720
19828
  }
19721
19829
  let valid2 = isValidLicense(licenseKey, {
19722
19830
  publishedAt: 1624970570587,
19723
- version: "5.0.0-canary.0"
19831
+ version: "5.0.0-canary.2"
19724
19832
  });
19725
19833
  if (!licenseKey && !valid2 && isInsidePlayground) {
19726
19834
  return true;
@@ -19981,6 +20089,15 @@ function handleRowNavigation(options, event) {
19981
20089
  },
19982
20090
  ArrowLeft: () => {
19983
20091
  const rowInfo = dataArray[activeRowIndex];
20092
+ if (brain.isHorizontalLayoutBrain) {
20093
+ const rowsPerPage = brain.rowsPerPage;
20094
+ if (activeRowIndex - rowsPerPage >= min) {
20095
+ activeRowIndex = activeRowIndex - rowsPerPage;
20096
+ } else {
20097
+ KeyToFunction.ArrowUp();
20098
+ }
20099
+ return;
20100
+ }
19984
20101
  if (rowInfo && rowInfo.isGroupRow) {
19985
20102
  return api.collapseGroupRow(rowInfo.groupKeys);
19986
20103
  }
@@ -19991,6 +20108,15 @@ function handleRowNavigation(options, event) {
19991
20108
  },
19992
20109
  ArrowRight: () => {
19993
20110
  const rowInfo = dataArray[activeRowIndex];
20111
+ if (brain.isHorizontalLayoutBrain) {
20112
+ const rowsPerPage = brain.rowsPerPage;
20113
+ if (activeRowIndex + rowsPerPage <= max) {
20114
+ activeRowIndex = activeRowIndex + rowsPerPage;
20115
+ } else {
20116
+ KeyToFunction.ArrowDown();
20117
+ }
20118
+ return;
20119
+ }
19994
20120
  if (rowInfo && rowInfo.isGroupRow) {
19995
20121
  return api.expandGroupRow(rowInfo.groupKeys);
19996
20122
  }