@infinite-table/infinite-react 0.0.1-canary.9 → 0.0.2-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.js CHANGED
@@ -577,7 +577,10 @@ __export(exports, {
577
577
  InfiniteTableClassName: () => InfiniteTableClassName,
578
578
  InfiniteTableComponent: () => InfiniteTableComponent,
579
579
  flatten: () => flatten,
580
+ getComponentStateRoot: () => getComponentStateRoot,
580
581
  group: () => group,
582
+ interceptMap: () => interceptMap,
583
+ useComponentState: () => useComponentState,
581
584
  useDataSource: () => useDataSource
582
585
  });
583
586
 
@@ -643,6 +646,41 @@ function isControlled(propName, props) {
643
646
  return controlled;
644
647
  }
645
648
 
649
+ // src/components/VirtualBrain/ScrollListener.ts
650
+ var initialScrollPosition = {
651
+ scrollLeft: 0,
652
+ scrollTop: 0
653
+ };
654
+ var ScrollListener = class {
655
+ constructor() {
656
+ this.scrollPosition = initialScrollPosition;
657
+ this.onScrollFns = [];
658
+ this.getScrollPosition = () => {
659
+ return this.scrollPosition;
660
+ };
661
+ this.onScroll = (fn) => {
662
+ this.onScrollFns.push(fn);
663
+ return () => {
664
+ this.onScrollFns = this.onScrollFns.filter((f) => f !== fn);
665
+ };
666
+ };
667
+ this.setScrollPosition = (scrollPosition) => {
668
+ this.scrollPosition = scrollPosition;
669
+ this.notifyScrollChange();
670
+ };
671
+ this.destroy = () => {
672
+ this.onScrollFns = [];
673
+ };
674
+ }
675
+ notifyScrollChange() {
676
+ const { scrollPosition } = this;
677
+ const fns = this.onScrollFns;
678
+ for (let i = 0, len = fns.length; i < len; i++) {
679
+ fns[i](scrollPosition);
680
+ }
681
+ }
682
+ };
683
+
646
684
  // src/components/InfiniteTable/state/computeColumnGroupsDepths.ts
647
685
  function computeColumnGroupsDepths(columnGroups) {
648
686
  const map = new Map();
@@ -677,7 +715,7 @@ function getInitialState(params) {
677
715
  const generatedColumns = new Map();
678
716
  const pivotColumns = props.pivotColumns;
679
717
  return {
680
- rowHeight: typeof props.rowHeight === "number" ? props.rowHeight : 0,
718
+ rowHeightComputed: typeof props.rowHeight === "number" ? props.rowHeight : 0,
681
719
  headerHeight: typeof props.headerHeight === "number" ? props.headerHeight : 0,
682
720
  domRef: (0, import_react2.createRef)(),
683
721
  bodyDOMRef: (0, import_react2.createRef)(),
@@ -700,6 +738,8 @@ function getInitialState(params) {
700
738
  generatedColumns,
701
739
  columnOrder: (_c = isControlled("columnOrder", props) ? props.columnOrder : props.defaultColumnOrder) != null ? _c : true,
702
740
  computedColumnGroups,
741
+ pinnedStartScrollListener: new ScrollListener(),
742
+ pinnedEndScrollListener: new ScrollListener(),
703
743
  columnGroups,
704
744
  collapsedColumnGroups,
705
745
  columnGroupsDepthsMap,
@@ -731,6 +771,8 @@ function deriveReadOnlyState(params) {
731
771
  rowStyle: props.rowStyle,
732
772
  rowProps: props.rowProps,
733
773
  rowClassName: props.rowClassName,
774
+ pinnedStartMaxWidth: props.pinnedStartMaxWidth,
775
+ pinnedEndMaxWidth: props.pinnedEndMaxWidth,
734
776
  groupRenderStrategy: (_e = props.groupRenderStrategy) != null ? _e : "multi-column",
735
777
  pivotTotalColumnPosition,
736
778
  columnMinWidth: (_f = props.columnMinWidth) != null ? _f : 30,
@@ -1009,6 +1051,9 @@ var adjustColumnOrderForPinning = (columnOrder, columnPinning) => {
1009
1051
  };
1010
1052
 
1011
1053
  // src/components/InfiniteTable/utils/getComputedVisibleColumns.ts
1054
+ var IS_GROUP_COLUMN_ID = (columnId) => {
1055
+ return columnId.startsWith("group-by");
1056
+ };
1012
1057
  var isColumnVisible = (columnVisibility, _columnVisibilityAssumeVisible, colId) => {
1013
1058
  return !columnVisibility.has(colId) || columnVisibility.get(colId) !== false;
1014
1059
  };
@@ -1024,6 +1069,8 @@ var getComputedVisibleColumns = ({
1024
1069
  columnMinWidth,
1025
1070
  columnMaxWidth,
1026
1071
  columnDefaultWidth,
1072
+ pinnedStartMaxWidth,
1073
+ pinnedEndMaxWidth,
1027
1074
  sortable,
1028
1075
  sortInfo,
1029
1076
  setSortInfo,
@@ -1041,12 +1088,12 @@ var getComputedVisibleColumns = ({
1041
1088
  let col = columns.get(columnId);
1042
1089
  if (!col) {
1043
1090
  col = generatedColumns.get(columnId);
1044
- if (!col) {
1091
+ if (!col && !IS_GROUP_COLUMN_ID(columnId)) {
1045
1092
  throw `Column with id "${columnId}" specified in columnOrder array cannot be found in the columns map.`;
1046
1093
  }
1047
1094
  }
1048
1095
  return col;
1049
- });
1096
+ }).filter(Boolean);
1050
1097
  const sortedMap = (sortInfo != null ? sortInfo : []).reduce((acc, info, index) => {
1051
1098
  if (info.id) {
1052
1099
  acc[info.id] = { sortInfo: info, index };
@@ -1205,6 +1252,8 @@ var getComputedVisibleColumns = ({
1205
1252
  }
1206
1253
  prevPinned = computedPinned;
1207
1254
  });
1255
+ const computedPinnedStartWidth = pinnedStartMaxWidth != null ? Math.min(pinnedStartMaxWidth, computedPinnedStartColumnsWidth) : computedPinnedStartColumnsWidth;
1256
+ const computedPinnedEndWidth = pinnedEndMaxWidth != null ? Math.min(pinnedEndMaxWidth, computedPinnedEndColumnsWidth) : computedPinnedEndColumnsWidth;
1208
1257
  const result = {
1209
1258
  computedRemainingSpace: bodySize.width - (totalPinnedStartWidth + totalPinnedEndWidth + totalUnpinnedWidth),
1210
1259
  computedPinnedStartColumnsWidth,
@@ -1217,7 +1266,9 @@ var getComputedVisibleColumns = ({
1217
1266
  computedPinnedEndOffset: computedPinnedStartColumnsWidth + computedUnpinnedColumnsWidth,
1218
1267
  computedUnpinnedColumns,
1219
1268
  computedVisibleColumns,
1220
- computedVisibleColumnsMap
1269
+ computedVisibleColumnsMap,
1270
+ computedPinnedEndWidth,
1271
+ computedPinnedStartWidth
1221
1272
  };
1222
1273
  return result;
1223
1274
  };
@@ -1323,6 +1374,8 @@ var useComputedVisibleColumns = ({
1323
1374
  setSortInfo,
1324
1375
  columnOrder,
1325
1376
  columnPinning,
1377
+ pinnedEndMaxWidth,
1378
+ pinnedStartMaxWidth,
1326
1379
  columnVisibility,
1327
1380
  columnVisibilityAssumeVisible
1328
1381
  }) => {
@@ -1341,7 +1394,9 @@ var useComputedVisibleColumns = ({
1341
1394
  computedPinnedEndColumnsWidth,
1342
1395
  computedUnpinnedColumnsWidth,
1343
1396
  computedUnpinnedOffset,
1344
- computedPinnedEndOffset
1397
+ computedPinnedEndOffset,
1398
+ computedPinnedEndWidth,
1399
+ computedPinnedStartWidth
1345
1400
  } = (0, import_react8.useMemo)(() => {
1346
1401
  return getComputedVisibleColumns({
1347
1402
  columns,
@@ -1354,6 +1409,8 @@ var useComputedVisibleColumns = ({
1354
1409
  sortInfo,
1355
1410
  setSortInfo,
1356
1411
  multiSort,
1412
+ pinnedEndMaxWidth,
1413
+ pinnedStartMaxWidth,
1357
1414
  draggableColumns,
1358
1415
  columnOrder,
1359
1416
  columnPinning,
@@ -1374,6 +1431,8 @@ var useComputedVisibleColumns = ({
1374
1431
  columnOrder,
1375
1432
  columnVisibility,
1376
1433
  columnVisibilityAssumeVisible,
1434
+ pinnedEndMaxWidth,
1435
+ pinnedStartMaxWidth,
1377
1436
  columnPinning,
1378
1437
  columnsRenderId,
1379
1438
  visibilityRenderId,
@@ -1381,6 +1440,8 @@ var useComputedVisibleColumns = ({
1381
1440
  ]);
1382
1441
  const result = {
1383
1442
  columns,
1443
+ computedPinnedEndWidth,
1444
+ computedPinnedStartWidth,
1384
1445
  computedRemainingSpace,
1385
1446
  computedUnpinnedOffset,
1386
1447
  computedPinnedEndOffset,
@@ -3128,7 +3189,7 @@ function useComputed() {
3128
3189
  (0, import_react18.useState)(() => {
3129
3190
  componentState.onRowHeightChange.onChange((rowHeight) => {
3130
3191
  if (rowHeight) {
3131
- componentActions.rowHeight = rowHeight;
3192
+ componentActions.rowHeightComputed = rowHeight;
3132
3193
  }
3133
3194
  });
3134
3195
  componentState.onHeaderHeightChange.onChange((headerHeight) => {
@@ -3157,13 +3218,17 @@ function useComputed() {
3157
3218
  computedUnpinnedColumnsWidth,
3158
3219
  computedUnpinnedOffset,
3159
3220
  computedPinnedEndOffset,
3160
- computedRemainingSpace
3221
+ computedRemainingSpace,
3222
+ computedPinnedStartWidth,
3223
+ computedPinnedEndWidth
3161
3224
  } = useComputedVisibleColumns({
3162
3225
  columns: componentState.computedPivotColumns || componentState.columns,
3163
3226
  generatedColumns: componentState.generatedColumns,
3164
3227
  columnMinWidth: componentState.columnMinWidth,
3165
3228
  columnMaxWidth: componentState.columnMaxWidth,
3166
3229
  columnDefaultWidth: componentState.columnDefaultWidth,
3230
+ pinnedStartMaxWidth: componentState.pinnedStartMaxWidth,
3231
+ pinnedEndMaxWidth: componentState.pinnedEndMaxWidth,
3167
3232
  bodySize,
3168
3233
  sortable: componentState.sortable,
3169
3234
  draggableColumns: componentState.draggableColumns,
@@ -3198,7 +3263,13 @@ function useComputed() {
3198
3263
  if (colWidthSum > scrollLeft) {
3199
3264
  columnRenderStartIndex--;
3200
3265
  }
3266
+ const computedPinnedStartOverflow = computedPinnedStartWidth ? computedPinnedStartColumnsWidth > computedPinnedStartWidth : false;
3267
+ const computedPinnedEndOverflow = computedPinnedEndWidth ? computedPinnedEndColumnsWidth > computedPinnedEndWidth : false;
3201
3268
  return {
3269
+ computedPinnedStartOverflow,
3270
+ computedPinnedEndOverflow,
3271
+ computedPinnedStartWidth,
3272
+ computedPinnedEndWidth,
3202
3273
  computedVisibleColumns,
3203
3274
  computedColumnOrder,
3204
3275
  computedRemainingSpace,
@@ -3268,8 +3339,8 @@ function getScrollbarWidth() {
3268
3339
  // src/components/InfiniteTable/components/ScrollbarPlaceholder.tsx
3269
3340
  var React11 = __toModule(require("react"));
3270
3341
  function HorizontalScrollbarPlaceholderFn(props) {
3271
- const height = getScrollbarWidth();
3272
- if (!height) {
3342
+ const scrollbarWidth2 = getScrollbarWidth();
3343
+ if (!scrollbarWidth2) {
3273
3344
  return null;
3274
3345
  }
3275
3346
  return /* @__PURE__ */ React11.createElement("div", {
@@ -3278,15 +3349,14 @@ function HorizontalScrollbarPlaceholderFn(props) {
3278
3349
  position: "absolute",
3279
3350
  overflow: "visible",
3280
3351
  overflowX: "scroll",
3281
- height,
3282
3352
  bottom: 0
3283
3353
  }, props.style)
3284
3354
  });
3285
3355
  }
3286
3356
  var HorizontalScrollbarPlaceholder = React11.memo(HorizontalScrollbarPlaceholderFn);
3287
3357
  function VerticalScrollbarPlaceholderFn(props) {
3288
- const width = getScrollbarWidth();
3289
- if (!width) {
3358
+ const scrollbarWidth2 = getScrollbarWidth();
3359
+ if (!scrollbarWidth2) {
3290
3360
  return null;
3291
3361
  }
3292
3362
  return /* @__PURE__ */ React11.createElement("div", {
@@ -3295,7 +3365,6 @@ function VerticalScrollbarPlaceholderFn(props) {
3295
3365
  position: "absolute",
3296
3366
  overflow: "visible",
3297
3367
  overflowY: "scroll",
3298
- width,
3299
3368
  bottom: 0
3300
3369
  }, props.style)
3301
3370
  });
@@ -4277,7 +4346,23 @@ var UPDATE_SCROLL = (node, scrollPosition) => {
4277
4346
  node.style.transform = `translate3d(${-scrollPosition.scrollLeft}px, 0px, 0px)`;
4278
4347
  };
4279
4348
  function InfiniteTableHeaderUnvirtualizedFn(props) {
4280
- const _a = props, { columns, scrollable, brain, totalWidth } = _a, domProps = __objRest(_a, ["columns", "scrollable", "brain", "totalWidth"]);
4349
+ const _a = props, {
4350
+ columns,
4351
+ scrollable,
4352
+ classNameModifiers,
4353
+ brain,
4354
+ scrollListener,
4355
+ totalWidth,
4356
+ availableWidth
4357
+ } = _a, domProps = __objRest(_a, [
4358
+ "columns",
4359
+ "scrollable",
4360
+ "classNameModifiers",
4361
+ "brain",
4362
+ "scrollListener",
4363
+ "totalWidth",
4364
+ "availableWidth"
4365
+ ]);
4281
4366
  const {
4282
4367
  componentState: {
4283
4368
  computedColumnGroups,
@@ -4318,23 +4403,27 @@ function InfiniteTableHeaderUnvirtualizedFn(props) {
4318
4403
  });
4319
4404
  const style = __spreadValues({}, domProps == null ? void 0 : domProps.style);
4320
4405
  if (totalWidth != null) {
4321
- style.width = totalWidth;
4406
+ style.width = availableWidth;
4322
4407
  }
4323
4408
  (0, import_react26.useEffect)(() => {
4324
- if (!brain || !scrollable) {
4409
+ const scroller = brain || scrollListener;
4410
+ if (!scroller || !scrollable) {
4325
4411
  return;
4326
4412
  }
4327
4413
  const onScroll = (scrollPosition) => {
4328
4414
  UPDATE_SCROLL(domRef.current, scrollPosition);
4329
4415
  };
4330
- const removeOnScroll = brain.onScroll(onScroll);
4416
+ const removeOnScroll = scroller.onScroll(onScroll);
4331
4417
  return removeOnScroll;
4332
- }, [brain]);
4418
+ }, [brain, scrollListener]);
4333
4419
  return /* @__PURE__ */ React21.createElement("div", __spreadProps(__spreadValues({}, domProps), {
4334
- ref: domRef,
4335
- className: join(ICSS.flexFlow.row, ICSS.display.flex, TableHeaderClassName2, `${TableHeaderClassName2}--unvirtualized`, domProps.className),
4420
+ className: join(TableHeaderClassName2, `${TableHeaderClassName2}--unvirtualized`, domProps.className, ...(classNameModifiers || []).filter(Boolean).map((modifier) => `${TableHeaderClassName2}--${modifier}`)),
4336
4421
  style
4337
- }), children);
4422
+ }), /* @__PURE__ */ React21.createElement("div", {
4423
+ style: { width: totalWidth },
4424
+ className: join(ICSS.flexFlow.row, ICSS.display.flex),
4425
+ ref: domRef
4426
+ }, children));
4338
4427
  }
4339
4428
  var InfiniteTableHeaderUnvirtualized = React21.memo(InfiniteTableHeaderUnvirtualizedFn);
4340
4429
 
@@ -4347,11 +4436,21 @@ function TableHeaderWrapper(props) {
4347
4436
  computedPinnedStartColumns,
4348
4437
  computedPinnedEndColumns,
4349
4438
  computedPinnedStartColumnsWidth,
4439
+ computedPinnedStartWidth,
4440
+ computedPinnedEndWidth,
4350
4441
  computedPinnedEndColumnsWidth,
4351
- computedUnpinnedColumnsWidth
4442
+ computedUnpinnedColumnsWidth,
4443
+ computedPinnedStartOverflow,
4444
+ computedPinnedEndOverflow
4352
4445
  } = tableContextValue.computed;
4353
4446
  const {
4354
- componentState: { virtualizeHeader, headerHeight, columnGroupsMaxDepth }
4447
+ componentState: {
4448
+ virtualizeHeader,
4449
+ headerHeight,
4450
+ columnGroupsMaxDepth,
4451
+ pinnedStartScrollListener,
4452
+ pinnedEndScrollListener
4453
+ }
4355
4454
  } = tableContextValue;
4356
4455
  const hasPinnedStart = computedPinnedStartColumns.length > 0;
4357
4456
  const hasPinnedEnd = computedPinnedEndColumns.length > 0;
@@ -4362,15 +4461,17 @@ function TableHeaderWrapper(props) {
4362
4461
  brain,
4363
4462
  style: {
4364
4463
  position: "absolute",
4365
- left: computedPinnedStartColumnsWidth,
4464
+ left: computedPinnedStartWidth,
4366
4465
  width: computedUnpinnedColumnsWidth,
4367
4466
  height: columnGroupsMaxDepth || headerHeight
4368
4467
  },
4468
+ availableWidth: computedUnpinnedColumnsWidth,
4369
4469
  totalWidth: computedUnpinnedColumnsWidth
4370
4470
  }) : /* @__PURE__ */ React22.createElement(InfiniteTableHeaderUnvirtualized, {
4371
4471
  brain,
4372
4472
  scrollable: true,
4373
4473
  columns: computedUnpinnedColumns,
4474
+ availableWidth: computedUnpinnedColumnsWidth,
4374
4475
  totalWidth: computedUnpinnedColumnsWidth
4375
4476
  });
4376
4477
  return /* @__PURE__ */ React22.createElement("div", {
@@ -4383,18 +4484,34 @@ function TableHeaderWrapper(props) {
4383
4484
  style: {
4384
4485
  left: 0,
4385
4486
  position: "absolute",
4386
- width: computedPinnedStartColumnsWidth
4487
+ width: computedPinnedStartWidth
4387
4488
  },
4489
+ availableWidth: computedPinnedStartWidth,
4490
+ totalWidth: computedPinnedStartColumnsWidth,
4388
4491
  columns: computedPinnedStartColumns,
4389
- totalWidth: computedPinnedStartColumnsWidth
4492
+ scrollable: computedPinnedStartOverflow,
4493
+ classNameModifiers: [
4494
+ "pinned",
4495
+ "pinned-start",
4496
+ computedPinnedStartOverflow ? "overflow" : ""
4497
+ ],
4498
+ scrollListener: computedPinnedStartOverflow ? pinnedStartScrollListener : void 0
4390
4499
  }) : null, header, hasPinnedEnd ? /* @__PURE__ */ React22.createElement(InfiniteTableHeaderUnvirtualized, {
4391
4500
  style: {
4392
4501
  right: scrollbars.vertical ? getScrollbarWidth() : 0,
4393
4502
  position: "absolute",
4394
- width: computedPinnedEndColumnsWidth
4503
+ width: computedPinnedEndWidth
4395
4504
  },
4396
4505
  columns: computedPinnedEndColumns,
4397
- totalWidth: computedPinnedEndColumnsWidth
4506
+ availableWidth: computedPinnedEndWidth,
4507
+ totalWidth: computedPinnedEndColumnsWidth,
4508
+ scrollable: computedPinnedEndOverflow,
4509
+ classNameModifiers: [
4510
+ "pinned",
4511
+ "pinned-end",
4512
+ computedPinnedEndOverflow ? "overflow" : ""
4513
+ ],
4514
+ scrollListener: computedPinnedEndOverflow ? pinnedEndScrollListener : void 0
4398
4515
  }) : null, scrollbars.vertical ? /* @__PURE__ */ React22.createElement(VerticalScrollbarPlaceholder, {
4399
4516
  style: {
4400
4517
  height: "100%",
@@ -4444,13 +4561,6 @@ var getScrollableClassName = (scrollable) => {
4444
4561
 
4445
4562
  // src/components/VirtualScrollContainer/index.tsx
4446
4563
  var rootClassName6 = "IT-VirtualScrollContainer";
4447
- var defaultClasName = [
4448
- ICSS.position.fixed,
4449
- ICSS.height["100%"],
4450
- ICSS.width["100%"],
4451
- ICSS.left[0],
4452
- ICSS.top[0]
4453
- ].join(" ");
4454
4564
  var VirtualScrollContainer = React23.forwardRef(function VirtualScrollContainer2(props, ref) {
4455
4565
  const {
4456
4566
  children,
@@ -4467,7 +4577,6 @@ var VirtualScrollContainer = React23.forwardRef(function VirtualScrollContainer2
4467
4577
  className: [
4468
4578
  className,
4469
4579
  rootClassName6,
4470
- defaultClasName,
4471
4580
  getScrollableClassName(scrollable)
4472
4581
  ].join(" ")
4473
4582
  }, children);
@@ -4513,7 +4622,6 @@ var UPDATE_SCROLL2 = (node, scrollPosition) => {
4513
4622
  var CLASSES = join(ICSS.height["0"], ICSS.width["0"], ICSS.willChange.transform);
4514
4623
  var debug4 = dbg("VirtuaList");
4515
4624
  var rootClassName7 = "IList";
4516
- var defaultClasses = [ICSS.position.relative, ICSS.transform.translate3D000];
4517
4625
  var VirtualList = (props) => {
4518
4626
  const _a = props, {
4519
4627
  scrollable,
@@ -4577,7 +4685,7 @@ var VirtualList = (props) => {
4577
4685
  const width = mainAxis === "horizontal" ? totalSize : itemCrossAxisSize != null ? itemCrossAxisSize : 0;
4578
4686
  const height = mainAxis === "vertical" ? totalSize : itemCrossAxisSize != null ? itemCrossAxisSize : 0;
4579
4687
  const domProps = __spreadProps(__spreadValues({}, restDOMProps), {
4580
- className: join(props.className, rootClassName7, `${rootClassName7}--${mainAxis}`, ...defaultClasses)
4688
+ className: join(props.className, rootClassName7, `${rootClassName7}--${mainAxis}`, ICSS.transform.translate3D000)
4581
4689
  });
4582
4690
  if (false) {
4583
4691
  domProps["data-cmp-name"] = `VirtualList`;
@@ -4587,7 +4695,8 @@ var VirtualList = (props) => {
4587
4695
  onContainerScroll
4588
4696
  }, /* @__PURE__ */ React25.createElement("div", {
4589
4697
  ref: domRef,
4590
- className: CLASSES
4698
+ className: CLASSES,
4699
+ "data-name": "scroll-transform-target"
4591
4700
  }, /* @__PURE__ */ React25.createElement(RawList, {
4592
4701
  brain: virtualBrain,
4593
4702
  renderItem,
@@ -4861,8 +4970,8 @@ function useUnpinnedRendering(params) {
4861
4970
  verticalVirtualBrain,
4862
4971
  horizontalVirtualBrain,
4863
4972
  computedUnpinnedColumnsWidth,
4864
- computedPinnedStartColumnsWidth,
4865
- computedPinnedEndColumnsWidth,
4973
+ computedPinnedStartWidth,
4974
+ computedPinnedEndWidth,
4866
4975
  computedUnpinnedColumns,
4867
4976
  getState
4868
4977
  } = params;
@@ -4917,8 +5026,8 @@ function useUnpinnedRendering(params) {
4917
5026
  height: bodySize.height,
4918
5027
  top: 0,
4919
5028
  position: "absolute",
4920
- left: computedPinnedStartColumnsWidth,
4921
- right: computedPinnedEndColumnsWidth
5029
+ left: computedPinnedStartWidth,
5030
+ right: computedPinnedEndWidth
4922
5031
  },
4923
5032
  count: getData().length,
4924
5033
  rowHeight,
@@ -5017,7 +5126,7 @@ function useOnMount(domRef, props) {
5017
5126
 
5018
5127
  // src/components/VirtualList/RowListWithExternalScrolling.tsx
5019
5128
  var rootClassName10 = "IList";
5020
- var defaultClasses2 = [
5129
+ var defaultClasses = [
5021
5130
  ICSS.willChange.transform,
5022
5131
  ICSS.position.relative,
5023
5132
  ICSS.transform.translate3D000
@@ -5051,8 +5160,6 @@ var RowListWithExternalScrolling = (props) => {
5051
5160
  const { renderStartIndex, renderEndIndex } = brain.getRenderRange();
5052
5161
  node.dataset.renderStartIndex = renderStartIndex;
5053
5162
  node.dataset.renderEndIndex = renderEndIndex;
5054
- node.dataset.scrollLeft = scrollPosition.scrollLeft;
5055
- node.dataset.scrollTop = scrollPosition.scrollTop;
5056
5163
  }
5057
5164
  if (updateScroll) {
5058
5165
  updateScroll(node, scrollPosition);
@@ -5069,7 +5176,7 @@ var RowListWithExternalScrolling = (props) => {
5069
5176
  const domProps = {
5070
5177
  ref: domRef,
5071
5178
  style,
5072
- className: join(className, rootClassName10, `${rootClassName10}--vertical`, ...defaultClasses2)
5179
+ className: join(className, rootClassName10, `${rootClassName10}--vertical`, ...defaultClasses)
5073
5180
  };
5074
5181
  if (false) {
5075
5182
  domProps["data-cmp-name"] = "RowListWithExternalScrolling";
@@ -5082,9 +5189,74 @@ var RowListWithExternalScrolling = (props) => {
5082
5189
  };
5083
5190
 
5084
5191
  // src/components/InfiniteTable/hooks/usePinnedRendering.tsx
5085
- var UPDATE_SCROLL3 = (node, scrollPosition) => {
5086
- node.style.transform = `translate3d(0px, ${-scrollPosition.scrollTop}px, 0px)`;
5192
+ var UPDATE_SCROLL3 = (node, brainScrollPosition, horizontalPinnedScrollPosition) => {
5193
+ node.style.transform = `translate3d(${horizontalPinnedScrollPosition ? -horizontalPinnedScrollPosition.scrollLeft : 0}px, ${-brainScrollPosition.scrollTop}px, 0px)`;
5087
5194
  };
5195
+ var PinnedRowsContainerClassName = `ITablePinnedRows`;
5196
+ function PinnedRowsContainer(props) {
5197
+ const {
5198
+ maxWidth,
5199
+ pinning,
5200
+ rowWidth,
5201
+ height,
5202
+ pinnedScrollListener,
5203
+ hasOverflow,
5204
+ brain,
5205
+ renderRow
5206
+ } = props;
5207
+ const style = React32.useMemo(() => {
5208
+ const result = pinning === "end" ? {
5209
+ width: rowWidth,
5210
+ height,
5211
+ right: 0
5212
+ } : {};
5213
+ if (!hasOverflow && pinning === "end") {
5214
+ result.position = "absolute";
5215
+ }
5216
+ if (hasOverflow) {
5217
+ result.height = getScrollbarWidth();
5218
+ result.width = getScrollbarWidth();
5219
+ }
5220
+ return result;
5221
+ }, [height, rowWidth, pinning, hasOverflow]);
5222
+ const updateScroll = (0, import_react36.useCallback)((node, scrollPosition) => {
5223
+ UPDATE_SCROLL3(node, scrollPosition, hasOverflow ? pinnedScrollListener.getScrollPosition() : void 0);
5224
+ }, [hasOverflow, pinnedScrollListener]);
5225
+ const rowListProps = {
5226
+ style,
5227
+ brain,
5228
+ renderRow,
5229
+ updateScroll,
5230
+ className: join(`${PinnedRowsContainerClassName}`, `${PinnedRowsContainerClassName}--pinned-${pinning}`, `${PinnedRowsContainerClassName}--overflow`)
5231
+ };
5232
+ if (hasOverflow) {
5233
+ return /* @__PURE__ */ React32.createElement(VirtualScrollContainer, {
5234
+ scrollable: {
5235
+ horizontal: true,
5236
+ vertical: false
5237
+ },
5238
+ style: {
5239
+ width: maxWidth,
5240
+ height,
5241
+ position: "absolute",
5242
+ [pinning === "start" ? "left" : "right"]: 0,
5243
+ [pinning === "start" ? "right" : "left"]: "unset"
5244
+ },
5245
+ onContainerScroll: pinnedScrollListener == null ? void 0 : pinnedScrollListener.setScrollPosition,
5246
+ className: join(`${PinnedRowsContainerClassName}Container`, `${PinnedRowsContainerClassName}Container--pinned-${pinning}`)
5247
+ }, /* @__PURE__ */ React32.createElement(RowListWithExternalScrolling, __spreadProps(__spreadValues({}, rowListProps), {
5248
+ onMount: (node) => {
5249
+ pinnedScrollListener == null ? void 0 : pinnedScrollListener.onScroll((scrollPosition) => {
5250
+ updateScroll(node, brain.getScrollPosition(), scrollPosition);
5251
+ });
5252
+ }
5253
+ })), /* @__PURE__ */ React32.createElement(SpacePlaceholder, {
5254
+ width: rowWidth,
5255
+ height: 1
5256
+ }));
5257
+ }
5258
+ return /* @__PURE__ */ React32.createElement(RowListWithExternalScrolling, __spreadValues({}, rowListProps));
5259
+ }
5088
5260
  function useRenderPinnedRow(params) {
5089
5261
  const { getData, getState, columnsWidth, columns } = params;
5090
5262
  const renderPinnedRow = (0, import_react36.useCallback)((rowInfo) => {
@@ -5104,7 +5276,7 @@ function useRenderPinnedRow(params) {
5104
5276
  }, [columnsWidth, columns]);
5105
5277
  return renderPinnedRow;
5106
5278
  }
5107
- function usePinnedEndRendering(params) {
5279
+ function usePinnedRenderingForSide(side, params) {
5108
5280
  const {
5109
5281
  getState,
5110
5282
  getData,
@@ -5112,7 +5284,15 @@ function usePinnedEndRendering(params) {
5112
5284
  bodySize,
5113
5285
  computedPinnedEndColumns,
5114
5286
  computedPinnedEndColumnsWidth,
5287
+ computedPinnedStartColumns,
5288
+ computedPinnedStartColumnsWidth,
5115
5289
  verticalVirtualBrain,
5290
+ computedPinnedEndWidth,
5291
+ computedPinnedEndOverflow,
5292
+ computedPinnedStartWidth,
5293
+ computedPinnedStartOverflow,
5294
+ pinnedStartScrollListener,
5295
+ pinnedEndScrollListener,
5116
5296
  repaintId,
5117
5297
  toggleGroupRow,
5118
5298
  scrollbars: {
@@ -5120,31 +5300,54 @@ function usePinnedEndRendering(params) {
5120
5300
  horizontal: hasHorizontalScrollbar
5121
5301
  }
5122
5302
  } = params;
5123
- const renderRowPinnedEnd = useRenderPinnedRow({
5303
+ const count = getData().length;
5304
+ const rowWidth = side === "start" ? computedPinnedStartColumnsWidth : computedPinnedEndColumnsWidth;
5305
+ const columns = side === "start" ? computedPinnedStartColumns : computedPinnedEndColumns;
5306
+ const columnsWidth = side === "start" ? computedPinnedStartColumnsWidth : computedPinnedEndColumnsWidth;
5307
+ const maxWidth = side === "start" ? computedPinnedStartWidth : computedPinnedEndWidth;
5308
+ const hasOverflow = side === "start" ? computedPinnedStartOverflow : computedPinnedEndOverflow;
5309
+ const pinnedScrollListener = side === "start" ? pinnedStartScrollListener : pinnedEndScrollListener;
5310
+ const renderRowPinned = useRenderPinnedRow({
5124
5311
  getData,
5125
5312
  getState,
5126
5313
  toggleGroupRow,
5127
- columns: computedPinnedEndColumns,
5128
- columnsWidth: computedPinnedEndColumnsWidth
5314
+ columns,
5315
+ columnsWidth
5129
5316
  });
5130
- const pinnedEndList = computedPinnedEndColumns.length && rowHeight !== 0 ? /* @__PURE__ */ React32.createElement(RowListWithExternalScrolling, {
5131
- repaintId: `${repaintId}-pin-end-${rowHeight}`,
5317
+ const pinnedList = columns.length && rowHeight !== 0 ? /* @__PURE__ */ React32.createElement(PinnedRowsContainer, {
5318
+ pinning: side,
5319
+ pinnedScrollListener,
5320
+ hasOverflow,
5321
+ rowHeight,
5322
+ rowWidth,
5323
+ maxWidth,
5324
+ height: bodySize.height,
5325
+ count,
5326
+ repaintId: `${repaintId}-pin-${side}-${rowHeight}`,
5132
5327
  brain: verticalVirtualBrain,
5133
- renderRow: renderRowPinnedEnd,
5134
- style: {
5135
- position: "absolute",
5136
- height: bodySize.height,
5137
- width: computedPinnedEndColumnsWidth,
5138
- right: 0
5139
- },
5140
- updateScroll: UPDATE_SCROLL3
5328
+ renderRow: renderRowPinned
5141
5329
  }) : null;
5142
- const pinnedEndScrollbarPlaceholder = pinnedEndList && hasHorizontalScrollbar ? /* @__PURE__ */ React32.createElement(HorizontalScrollbarPlaceholder, {
5143
- style: {
5144
- width: computedPinnedEndColumnsWidth,
5330
+ const pinnedScrollbarPlaceholder = pinnedList && hasHorizontalScrollbar && !hasOverflow ? /* @__PURE__ */ React32.createElement(HorizontalScrollbarPlaceholder, {
5331
+ style: side === "end" ? {
5332
+ width: columnsWidth,
5145
5333
  right: hasVerticalScrollbar ? getScrollbarWidth() : 0
5334
+ } : {
5335
+ width: columnsWidth,
5336
+ left: 0
5146
5337
  }
5147
5338
  }) : null;
5339
+ return {
5340
+ renderRowPinned,
5341
+ pinnedList,
5342
+ pinnedScrollbarPlaceholder
5343
+ };
5344
+ }
5345
+ function usePinnedEndRendering(params) {
5346
+ const {
5347
+ renderRowPinned: renderRowPinnedEnd,
5348
+ pinnedList: pinnedEndList,
5349
+ pinnedScrollbarPlaceholder: pinnedEndScrollbarPlaceholder
5350
+ } = usePinnedRenderingForSide("end", params);
5148
5351
  return {
5149
5352
  renderRowPinnedEnd,
5150
5353
  pinnedEndList,
@@ -5153,40 +5356,16 @@ function usePinnedEndRendering(params) {
5153
5356
  }
5154
5357
  function usePinnedStartRendering(params) {
5155
5358
  const {
5156
- getData,
5157
- getState,
5158
- rowHeight,
5159
- computedPinnedStartColumns,
5160
- computedPinnedStartColumnsWidth,
5161
- verticalVirtualBrain,
5162
- toggleGroupRow,
5163
- repaintId,
5164
- scrollbars: { horizontal: hasHorizontalScrollbar }
5165
- } = params;
5166
- const renderRowPinnedStart = useRenderPinnedRow({
5167
- getData,
5168
- getState,
5169
- toggleGroupRow,
5170
- columns: computedPinnedStartColumns,
5171
- columnsWidth: computedPinnedStartColumnsWidth
5172
- });
5173
- const pinnedStartList = computedPinnedStartColumns.length && rowHeight !== 0 ? /* @__PURE__ */ React32.createElement(RowListWithExternalScrolling, {
5174
- repaintId: `${repaintId}-pin-start-${rowHeight}`,
5175
- brain: verticalVirtualBrain,
5176
- renderRow: renderRowPinnedStart,
5177
- updateScroll: UPDATE_SCROLL3
5178
- }) : null;
5179
- const pinnedStartScrollbarPlaceholder = pinnedStartList && hasHorizontalScrollbar ? /* @__PURE__ */ React32.createElement(HorizontalScrollbarPlaceholder, {
5180
- style: {
5181
- width: computedPinnedStartColumnsWidth,
5182
- left: 0
5183
- }
5184
- }) : null;
5185
- return {
5359
+ renderRowPinned: renderRowPinnedStart,
5360
+ pinnedList: pinnedStartList,
5361
+ pinnedScrollbarPlaceholder: pinnedStartScrollbarPlaceholder
5362
+ } = usePinnedRenderingForSide("start", params);
5363
+ const result = {
5186
5364
  renderRowPinnedStart,
5187
5365
  pinnedStartList,
5188
5366
  pinnedStartScrollbarPlaceholder
5189
5367
  };
5368
+ return result;
5190
5369
  }
5191
5370
 
5192
5371
  // src/components/InfiniteTable/hooks/useYourBrain.ts
@@ -5194,7 +5373,7 @@ var import_react38 = __toModule(require("react"));
5194
5373
 
5195
5374
  // src/components/VirtualBrain/index.ts
5196
5375
  var import_binary_search2 = __toModule(require_binary_search());
5197
- var initialScrollPosition = {
5376
+ var initialScrollPosition2 = {
5198
5377
  scrollLeft: 0,
5199
5378
  scrollTop: 0
5200
5379
  };
@@ -5203,7 +5382,7 @@ var SORT_ASC = (a, b) => a - b;
5203
5382
  var VirtualBrain = class extends Logger {
5204
5383
  constructor(options) {
5205
5384
  super(`VirtualBrain:${options.mainAxis}`);
5206
- this.scrollPosition = initialScrollPosition;
5385
+ this.scrollPosition = initialScrollPosition2;
5207
5386
  this.scrollPositionOnMainAxis = 0;
5208
5387
  this.totalSize = 0;
5209
5388
  this.onScrollFns = [];
@@ -5557,8 +5736,8 @@ function useYourBrain(param) {
5557
5736
  const {
5558
5737
  dataArray,
5559
5738
  computedUnpinnedColumns,
5560
- computedPinnedStartColumnsWidth,
5561
- computedPinnedEndColumnsWidth,
5739
+ computedPinnedStartWidth,
5740
+ computedPinnedEndWidth,
5562
5741
  rowHeight,
5563
5742
  bodySize
5564
5743
  } = param;
@@ -5591,13 +5770,9 @@ function useYourBrain(param) {
5591
5770
  (0, import_react38.useEffect)(() => {
5592
5771
  horizontalVirtualBrain.setAvailableSize({
5593
5772
  height: 0,
5594
- width: Math.max(bodySize.width - computedPinnedStartColumnsWidth - computedPinnedEndColumnsWidth, 0)
5773
+ width: Math.max(bodySize.width - computedPinnedStartWidth - computedPinnedEndWidth, 0)
5595
5774
  });
5596
- }, [
5597
- bodySize.width,
5598
- computedPinnedStartColumnsWidth,
5599
- computedPinnedEndColumnsWidth
5600
- ]);
5775
+ }, [bodySize.width, computedPinnedStartWidth, computedPinnedEndWidth]);
5601
5776
  return { horizontalVirtualBrain, verticalVirtualBrain };
5602
5777
  }
5603
5778
 
@@ -5634,13 +5809,23 @@ function useListRendering(param) {
5634
5809
  computedPinnedEndColumns,
5635
5810
  computedPinnedStartColumnsWidth,
5636
5811
  computedPinnedEndColumnsWidth,
5812
+ computedPinnedStartWidth,
5813
+ computedPinnedEndWidth,
5637
5814
  computedUnpinnedColumns,
5638
- computedUnpinnedColumnsWidth
5815
+ computedUnpinnedColumnsWidth,
5816
+ computedPinnedStartOverflow,
5817
+ computedPinnedEndOverflow
5639
5818
  } = computed;
5640
- const { componentState: dataSourceState } = useDataSourceContextValue();
5819
+ const { componentState: dataSourceState, getState: getDataSourceState } = useDataSourceContextValue();
5641
5820
  const { dataArray } = dataSourceState;
5642
5821
  const getData = useLatest(dataArray);
5643
- const { rowHeight } = componentState;
5822
+ const {
5823
+ rowHeightComputed: rowHeight,
5824
+ pinnedStartMaxWidth,
5825
+ pinnedEndMaxWidth,
5826
+ pinnedStartScrollListener,
5827
+ pinnedEndScrollListener
5828
+ } = componentState;
5644
5829
  const prevDataSourceTimestamp = usePrevious(dataSourceState.updatedAt);
5645
5830
  const repaintIdRef = (0, import_react39.useRef)(0);
5646
5831
  if (!shallowEqualObjects(prevComputed, computed) || prevDataSourceTimestamp !== dataSourceState.updatedAt) {
@@ -5648,9 +5833,9 @@ function useListRendering(param) {
5648
5833
  }
5649
5834
  const repaintId = repaintIdRef.current;
5650
5835
  const { horizontalVirtualBrain, verticalVirtualBrain } = useYourBrain({
5836
+ computedPinnedStartWidth: computed.computedPinnedStartWidth,
5837
+ computedPinnedEndWidth: computed.computedPinnedEndWidth,
5651
5838
  computedUnpinnedColumns: computed.computedUnpinnedColumns,
5652
- computedPinnedStartColumnsWidth: computed.computedPinnedStartColumnsWidth,
5653
- computedPinnedEndColumnsWidth: computed.computedPinnedEndColumnsWidth,
5654
5839
  rowHeight,
5655
5840
  dataArray,
5656
5841
  bodySize
@@ -5675,7 +5860,9 @@ function useListRendering(param) {
5675
5860
  setColumnVisibility: (columnVisibility) => {
5676
5861
  componentActions.columnVisibility = columnVisibility;
5677
5862
  },
5678
- setColumnAggregations: (columnAggregations) => componentActions.columnAggregations = columnAggregations
5863
+ setColumnAggregations: (columnAggregations) => componentActions.columnAggregations = columnAggregations,
5864
+ getState,
5865
+ getDataSourceState
5679
5866
  };
5680
5867
  onReady(imperativeApi);
5681
5868
  }
@@ -5685,7 +5872,7 @@ function useListRendering(param) {
5685
5872
  horizontalVirtualBrain,
5686
5873
  domRef
5687
5874
  });
5688
- const { getState: getDataSourceState, componentActions: dataSourceActions } = useDataSourceContextValue();
5875
+ const { componentActions: dataSourceActions } = useDataSourceContextValue();
5689
5876
  const toggleGroupRow = (0, import_react39.useCallback)((groupKeys) => {
5690
5877
  const newState = new GroupRowsState(getDataSourceState().groupRowsState);
5691
5878
  newState.toggleGroupRow(groupKeys);
@@ -5696,14 +5883,22 @@ function useListRendering(param) {
5696
5883
  scrollbars,
5697
5884
  computedPinnedStartColumns,
5698
5885
  computedPinnedEndColumns,
5886
+ computedPinnedStartWidth,
5887
+ computedPinnedEndWidth,
5888
+ computedPinnedStartOverflow,
5889
+ computedPinnedEndOverflow,
5699
5890
  computedPinnedStartColumnsWidth,
5700
5891
  computedPinnedEndColumnsWidth,
5701
5892
  getData,
5702
5893
  getState,
5703
5894
  toggleGroupRow,
5895
+ pinnedStartMaxWidth,
5896
+ pinnedEndMaxWidth,
5704
5897
  repaintId,
5705
5898
  rowHeight,
5706
- verticalVirtualBrain
5899
+ verticalVirtualBrain,
5900
+ pinnedStartScrollListener,
5901
+ pinnedEndScrollListener
5707
5902
  };
5708
5903
  const centerRenderingParams = __spreadProps(__spreadValues({}, pinnedRenderingParams), {
5709
5904
  columnShifts,
@@ -5964,7 +6159,7 @@ var useLicense = (licenseKey) => {
5964
6159
  const valid = (0, import_react41.useMemo)(() => {
5965
6160
  return isValidLicense(licenseKey, {
5966
6161
  publishedAt: 1624970570587,
5967
- version: "0.0.1-canary.9"
6162
+ version: "0.0.2-canary.2"
5968
6163
  });
5969
6164
  }, [licenseKey]);
5970
6165
  return valid;
@@ -6050,7 +6245,6 @@ var InfiniteTableComponent = React35.memo(function InfiniteTableComponent2() {
6050
6245
  headerHeightCSSVar
6051
6246
  } = componentState;
6052
6247
  const { columnShifts, bodySize } = componentState;
6053
- const className = join(InfiniteTableClassName, columnShifts ? `${InfiniteTableClassName}--shifting` : "", domProps == null ? void 0 : domProps.className);
6054
6248
  const {
6055
6249
  pinnedStartList,
6056
6250
  pinnedEndList,
@@ -6070,6 +6264,7 @@ var InfiniteTableComponent = React35.memo(function InfiniteTableComponent2() {
6070
6264
  computed
6071
6265
  });
6072
6266
  const licenseValid = useLicense(licenseKey);
6267
+ const className = join(InfiniteTableClassName, columnShifts ? `${InfiniteTableClassName}--shifting` : "", domProps == null ? void 0 : domProps.className, pinnedStartList ? `${InfiniteTableClassName}--has-pinned-start` : null, pinnedEndList ? `${InfiniteTableClassName}--has-pinned-end` : null, computed.computedPinnedStartOverflow ? `${InfiniteTableClassName}--has-pinned-start-overflow` : null, computed.computedPinnedEndOverflow ? `${InfiniteTableClassName}--has-pinned-end-overflow` : null);
6073
6268
  return /* @__PURE__ */ React35.createElement("div", __spreadProps(__spreadValues({
6074
6269
  ref: domRef
6075
6270
  }, domProps), {
@@ -6105,7 +6300,10 @@ function InfiniteTableContextProvider() {
6105
6300
  const computed = useComputed();
6106
6301
  const getComputed = useLatest(computed);
6107
6302
  const getState = useLatest(componentState);
6108
- globalThis.getState = getState;
6303
+ if (false) {
6304
+ globalThis.getState = getState;
6305
+ globalThis.getComputed = getComputed;
6306
+ }
6109
6307
  const contextValue = {
6110
6308
  componentActions,
6111
6309
  componentState,