@infinite-table/infinite-react 0.0.1-canary.9 → 0.0.1

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
@@ -643,6 +643,41 @@ function isControlled(propName, props) {
643
643
  return controlled;
644
644
  }
645
645
 
646
+ // src/components/VirtualBrain/ScrollListener.ts
647
+ var initialScrollPosition = {
648
+ scrollLeft: 0,
649
+ scrollTop: 0
650
+ };
651
+ var ScrollListener = class {
652
+ constructor() {
653
+ this.scrollPosition = initialScrollPosition;
654
+ this.onScrollFns = [];
655
+ this.getScrollPosition = () => {
656
+ return this.scrollPosition;
657
+ };
658
+ this.onScroll = (fn) => {
659
+ this.onScrollFns.push(fn);
660
+ return () => {
661
+ this.onScrollFns = this.onScrollFns.filter((f) => f !== fn);
662
+ };
663
+ };
664
+ this.setScrollPosition = (scrollPosition) => {
665
+ this.scrollPosition = scrollPosition;
666
+ this.notifyScrollChange();
667
+ };
668
+ this.destroy = () => {
669
+ this.onScrollFns = [];
670
+ };
671
+ }
672
+ notifyScrollChange() {
673
+ const { scrollPosition } = this;
674
+ const fns = this.onScrollFns;
675
+ for (let i = 0, len = fns.length; i < len; i++) {
676
+ fns[i](scrollPosition);
677
+ }
678
+ }
679
+ };
680
+
646
681
  // src/components/InfiniteTable/state/computeColumnGroupsDepths.ts
647
682
  function computeColumnGroupsDepths(columnGroups) {
648
683
  const map = new Map();
@@ -677,7 +712,7 @@ function getInitialState(params) {
677
712
  const generatedColumns = new Map();
678
713
  const pivotColumns = props.pivotColumns;
679
714
  return {
680
- rowHeight: typeof props.rowHeight === "number" ? props.rowHeight : 0,
715
+ rowHeightComputed: typeof props.rowHeight === "number" ? props.rowHeight : 0,
681
716
  headerHeight: typeof props.headerHeight === "number" ? props.headerHeight : 0,
682
717
  domRef: (0, import_react2.createRef)(),
683
718
  bodyDOMRef: (0, import_react2.createRef)(),
@@ -700,6 +735,8 @@ function getInitialState(params) {
700
735
  generatedColumns,
701
736
  columnOrder: (_c = isControlled("columnOrder", props) ? props.columnOrder : props.defaultColumnOrder) != null ? _c : true,
702
737
  computedColumnGroups,
738
+ pinnedStartScrollListener: new ScrollListener(),
739
+ pinnedEndScrollListener: new ScrollListener(),
703
740
  columnGroups,
704
741
  collapsedColumnGroups,
705
742
  columnGroupsDepthsMap,
@@ -731,6 +768,8 @@ function deriveReadOnlyState(params) {
731
768
  rowStyle: props.rowStyle,
732
769
  rowProps: props.rowProps,
733
770
  rowClassName: props.rowClassName,
771
+ pinnedStartMaxWidth: props.pinnedStartMaxWidth,
772
+ pinnedEndMaxWidth: props.pinnedEndMaxWidth,
734
773
  groupRenderStrategy: (_e = props.groupRenderStrategy) != null ? _e : "multi-column",
735
774
  pivotTotalColumnPosition,
736
775
  columnMinWidth: (_f = props.columnMinWidth) != null ? _f : 30,
@@ -1024,6 +1063,8 @@ var getComputedVisibleColumns = ({
1024
1063
  columnMinWidth,
1025
1064
  columnMaxWidth,
1026
1065
  columnDefaultWidth,
1066
+ pinnedStartMaxWidth,
1067
+ pinnedEndMaxWidth,
1027
1068
  sortable,
1028
1069
  sortInfo,
1029
1070
  setSortInfo,
@@ -1205,6 +1246,8 @@ var getComputedVisibleColumns = ({
1205
1246
  }
1206
1247
  prevPinned = computedPinned;
1207
1248
  });
1249
+ const computedPinnedStartWidth = pinnedStartMaxWidth != null ? Math.min(pinnedStartMaxWidth, computedPinnedStartColumnsWidth) : computedPinnedStartColumnsWidth;
1250
+ const computedPinnedEndWidth = pinnedEndMaxWidth != null ? Math.min(pinnedEndMaxWidth, computedPinnedEndColumnsWidth) : computedPinnedEndColumnsWidth;
1208
1251
  const result = {
1209
1252
  computedRemainingSpace: bodySize.width - (totalPinnedStartWidth + totalPinnedEndWidth + totalUnpinnedWidth),
1210
1253
  computedPinnedStartColumnsWidth,
@@ -1217,7 +1260,9 @@ var getComputedVisibleColumns = ({
1217
1260
  computedPinnedEndOffset: computedPinnedStartColumnsWidth + computedUnpinnedColumnsWidth,
1218
1261
  computedUnpinnedColumns,
1219
1262
  computedVisibleColumns,
1220
- computedVisibleColumnsMap
1263
+ computedVisibleColumnsMap,
1264
+ computedPinnedEndWidth,
1265
+ computedPinnedStartWidth
1221
1266
  };
1222
1267
  return result;
1223
1268
  };
@@ -1323,6 +1368,8 @@ var useComputedVisibleColumns = ({
1323
1368
  setSortInfo,
1324
1369
  columnOrder,
1325
1370
  columnPinning,
1371
+ pinnedEndMaxWidth,
1372
+ pinnedStartMaxWidth,
1326
1373
  columnVisibility,
1327
1374
  columnVisibilityAssumeVisible
1328
1375
  }) => {
@@ -1341,7 +1388,9 @@ var useComputedVisibleColumns = ({
1341
1388
  computedPinnedEndColumnsWidth,
1342
1389
  computedUnpinnedColumnsWidth,
1343
1390
  computedUnpinnedOffset,
1344
- computedPinnedEndOffset
1391
+ computedPinnedEndOffset,
1392
+ computedPinnedEndWidth,
1393
+ computedPinnedStartWidth
1345
1394
  } = (0, import_react8.useMemo)(() => {
1346
1395
  return getComputedVisibleColumns({
1347
1396
  columns,
@@ -1354,6 +1403,8 @@ var useComputedVisibleColumns = ({
1354
1403
  sortInfo,
1355
1404
  setSortInfo,
1356
1405
  multiSort,
1406
+ pinnedEndMaxWidth,
1407
+ pinnedStartMaxWidth,
1357
1408
  draggableColumns,
1358
1409
  columnOrder,
1359
1410
  columnPinning,
@@ -1374,6 +1425,8 @@ var useComputedVisibleColumns = ({
1374
1425
  columnOrder,
1375
1426
  columnVisibility,
1376
1427
  columnVisibilityAssumeVisible,
1428
+ pinnedEndMaxWidth,
1429
+ pinnedStartMaxWidth,
1377
1430
  columnPinning,
1378
1431
  columnsRenderId,
1379
1432
  visibilityRenderId,
@@ -1381,6 +1434,8 @@ var useComputedVisibleColumns = ({
1381
1434
  ]);
1382
1435
  const result = {
1383
1436
  columns,
1437
+ computedPinnedEndWidth,
1438
+ computedPinnedStartWidth,
1384
1439
  computedRemainingSpace,
1385
1440
  computedUnpinnedOffset,
1386
1441
  computedPinnedEndOffset,
@@ -3128,7 +3183,7 @@ function useComputed() {
3128
3183
  (0, import_react18.useState)(() => {
3129
3184
  componentState.onRowHeightChange.onChange((rowHeight) => {
3130
3185
  if (rowHeight) {
3131
- componentActions.rowHeight = rowHeight;
3186
+ componentActions.rowHeightComputed = rowHeight;
3132
3187
  }
3133
3188
  });
3134
3189
  componentState.onHeaderHeightChange.onChange((headerHeight) => {
@@ -3157,13 +3212,17 @@ function useComputed() {
3157
3212
  computedUnpinnedColumnsWidth,
3158
3213
  computedUnpinnedOffset,
3159
3214
  computedPinnedEndOffset,
3160
- computedRemainingSpace
3215
+ computedRemainingSpace,
3216
+ computedPinnedStartWidth,
3217
+ computedPinnedEndWidth
3161
3218
  } = useComputedVisibleColumns({
3162
3219
  columns: componentState.computedPivotColumns || componentState.columns,
3163
3220
  generatedColumns: componentState.generatedColumns,
3164
3221
  columnMinWidth: componentState.columnMinWidth,
3165
3222
  columnMaxWidth: componentState.columnMaxWidth,
3166
3223
  columnDefaultWidth: componentState.columnDefaultWidth,
3224
+ pinnedStartMaxWidth: componentState.pinnedStartMaxWidth,
3225
+ pinnedEndMaxWidth: componentState.pinnedEndMaxWidth,
3167
3226
  bodySize,
3168
3227
  sortable: componentState.sortable,
3169
3228
  draggableColumns: componentState.draggableColumns,
@@ -3198,7 +3257,13 @@ function useComputed() {
3198
3257
  if (colWidthSum > scrollLeft) {
3199
3258
  columnRenderStartIndex--;
3200
3259
  }
3260
+ const computedPinnedStartOverflow = computedPinnedStartWidth ? computedPinnedStartColumnsWidth > computedPinnedStartWidth : false;
3261
+ const computedPinnedEndOverflow = computedPinnedEndWidth ? computedPinnedEndColumnsWidth > computedPinnedEndWidth : false;
3201
3262
  return {
3263
+ computedPinnedStartOverflow,
3264
+ computedPinnedEndOverflow,
3265
+ computedPinnedStartWidth,
3266
+ computedPinnedEndWidth,
3202
3267
  computedVisibleColumns,
3203
3268
  computedColumnOrder,
3204
3269
  computedRemainingSpace,
@@ -3268,8 +3333,8 @@ function getScrollbarWidth() {
3268
3333
  // src/components/InfiniteTable/components/ScrollbarPlaceholder.tsx
3269
3334
  var React11 = __toModule(require("react"));
3270
3335
  function HorizontalScrollbarPlaceholderFn(props) {
3271
- const height = getScrollbarWidth();
3272
- if (!height) {
3336
+ const scrollbarWidth2 = getScrollbarWidth();
3337
+ if (!scrollbarWidth2) {
3273
3338
  return null;
3274
3339
  }
3275
3340
  return /* @__PURE__ */ React11.createElement("div", {
@@ -3278,15 +3343,14 @@ function HorizontalScrollbarPlaceholderFn(props) {
3278
3343
  position: "absolute",
3279
3344
  overflow: "visible",
3280
3345
  overflowX: "scroll",
3281
- height,
3282
3346
  bottom: 0
3283
3347
  }, props.style)
3284
3348
  });
3285
3349
  }
3286
3350
  var HorizontalScrollbarPlaceholder = React11.memo(HorizontalScrollbarPlaceholderFn);
3287
3351
  function VerticalScrollbarPlaceholderFn(props) {
3288
- const width = getScrollbarWidth();
3289
- if (!width) {
3352
+ const scrollbarWidth2 = getScrollbarWidth();
3353
+ if (!scrollbarWidth2) {
3290
3354
  return null;
3291
3355
  }
3292
3356
  return /* @__PURE__ */ React11.createElement("div", {
@@ -3295,7 +3359,6 @@ function VerticalScrollbarPlaceholderFn(props) {
3295
3359
  position: "absolute",
3296
3360
  overflow: "visible",
3297
3361
  overflowY: "scroll",
3298
- width,
3299
3362
  bottom: 0
3300
3363
  }, props.style)
3301
3364
  });
@@ -4277,7 +4340,23 @@ var UPDATE_SCROLL = (node, scrollPosition) => {
4277
4340
  node.style.transform = `translate3d(${-scrollPosition.scrollLeft}px, 0px, 0px)`;
4278
4341
  };
4279
4342
  function InfiniteTableHeaderUnvirtualizedFn(props) {
4280
- const _a = props, { columns, scrollable, brain, totalWidth } = _a, domProps = __objRest(_a, ["columns", "scrollable", "brain", "totalWidth"]);
4343
+ const _a = props, {
4344
+ columns,
4345
+ scrollable,
4346
+ classNameModifiers,
4347
+ brain,
4348
+ scrollListener,
4349
+ totalWidth,
4350
+ availableWidth
4351
+ } = _a, domProps = __objRest(_a, [
4352
+ "columns",
4353
+ "scrollable",
4354
+ "classNameModifiers",
4355
+ "brain",
4356
+ "scrollListener",
4357
+ "totalWidth",
4358
+ "availableWidth"
4359
+ ]);
4281
4360
  const {
4282
4361
  componentState: {
4283
4362
  computedColumnGroups,
@@ -4318,23 +4397,27 @@ function InfiniteTableHeaderUnvirtualizedFn(props) {
4318
4397
  });
4319
4398
  const style = __spreadValues({}, domProps == null ? void 0 : domProps.style);
4320
4399
  if (totalWidth != null) {
4321
- style.width = totalWidth;
4400
+ style.width = availableWidth;
4322
4401
  }
4323
4402
  (0, import_react26.useEffect)(() => {
4324
- if (!brain || !scrollable) {
4403
+ const scroller = brain || scrollListener;
4404
+ if (!scroller || !scrollable) {
4325
4405
  return;
4326
4406
  }
4327
4407
  const onScroll = (scrollPosition) => {
4328
4408
  UPDATE_SCROLL(domRef.current, scrollPosition);
4329
4409
  };
4330
- const removeOnScroll = brain.onScroll(onScroll);
4410
+ const removeOnScroll = scroller.onScroll(onScroll);
4331
4411
  return removeOnScroll;
4332
- }, [brain]);
4412
+ }, [brain, scrollListener]);
4333
4413
  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),
4414
+ className: join(TableHeaderClassName2, `${TableHeaderClassName2}--unvirtualized`, domProps.className, ...(classNameModifiers || []).filter(Boolean).map((modifier) => `${TableHeaderClassName2}--${modifier}`)),
4336
4415
  style
4337
- }), children);
4416
+ }), /* @__PURE__ */ React21.createElement("div", {
4417
+ style: { width: totalWidth },
4418
+ className: join(ICSS.flexFlow.row, ICSS.display.flex),
4419
+ ref: domRef
4420
+ }, children));
4338
4421
  }
4339
4422
  var InfiniteTableHeaderUnvirtualized = React21.memo(InfiniteTableHeaderUnvirtualizedFn);
4340
4423
 
@@ -4347,11 +4430,21 @@ function TableHeaderWrapper(props) {
4347
4430
  computedPinnedStartColumns,
4348
4431
  computedPinnedEndColumns,
4349
4432
  computedPinnedStartColumnsWidth,
4433
+ computedPinnedStartWidth,
4434
+ computedPinnedEndWidth,
4350
4435
  computedPinnedEndColumnsWidth,
4351
- computedUnpinnedColumnsWidth
4436
+ computedUnpinnedColumnsWidth,
4437
+ computedPinnedStartOverflow,
4438
+ computedPinnedEndOverflow
4352
4439
  } = tableContextValue.computed;
4353
4440
  const {
4354
- componentState: { virtualizeHeader, headerHeight, columnGroupsMaxDepth }
4441
+ componentState: {
4442
+ virtualizeHeader,
4443
+ headerHeight,
4444
+ columnGroupsMaxDepth,
4445
+ pinnedStartScrollListener,
4446
+ pinnedEndScrollListener
4447
+ }
4355
4448
  } = tableContextValue;
4356
4449
  const hasPinnedStart = computedPinnedStartColumns.length > 0;
4357
4450
  const hasPinnedEnd = computedPinnedEndColumns.length > 0;
@@ -4362,15 +4455,17 @@ function TableHeaderWrapper(props) {
4362
4455
  brain,
4363
4456
  style: {
4364
4457
  position: "absolute",
4365
- left: computedPinnedStartColumnsWidth,
4458
+ left: computedPinnedStartWidth,
4366
4459
  width: computedUnpinnedColumnsWidth,
4367
4460
  height: columnGroupsMaxDepth || headerHeight
4368
4461
  },
4462
+ availableWidth: computedUnpinnedColumnsWidth,
4369
4463
  totalWidth: computedUnpinnedColumnsWidth
4370
4464
  }) : /* @__PURE__ */ React22.createElement(InfiniteTableHeaderUnvirtualized, {
4371
4465
  brain,
4372
4466
  scrollable: true,
4373
4467
  columns: computedUnpinnedColumns,
4468
+ availableWidth: computedUnpinnedColumnsWidth,
4374
4469
  totalWidth: computedUnpinnedColumnsWidth
4375
4470
  });
4376
4471
  return /* @__PURE__ */ React22.createElement("div", {
@@ -4383,18 +4478,34 @@ function TableHeaderWrapper(props) {
4383
4478
  style: {
4384
4479
  left: 0,
4385
4480
  position: "absolute",
4386
- width: computedPinnedStartColumnsWidth
4481
+ width: computedPinnedStartWidth
4387
4482
  },
4483
+ availableWidth: computedPinnedStartWidth,
4484
+ totalWidth: computedPinnedStartColumnsWidth,
4388
4485
  columns: computedPinnedStartColumns,
4389
- totalWidth: computedPinnedStartColumnsWidth
4486
+ scrollable: computedPinnedStartOverflow,
4487
+ classNameModifiers: [
4488
+ "pinned",
4489
+ "pinned-start",
4490
+ computedPinnedStartOverflow ? "overflow" : ""
4491
+ ],
4492
+ scrollListener: computedPinnedStartOverflow ? pinnedStartScrollListener : void 0
4390
4493
  }) : null, header, hasPinnedEnd ? /* @__PURE__ */ React22.createElement(InfiniteTableHeaderUnvirtualized, {
4391
4494
  style: {
4392
4495
  right: scrollbars.vertical ? getScrollbarWidth() : 0,
4393
4496
  position: "absolute",
4394
- width: computedPinnedEndColumnsWidth
4497
+ width: computedPinnedEndWidth
4395
4498
  },
4396
4499
  columns: computedPinnedEndColumns,
4397
- totalWidth: computedPinnedEndColumnsWidth
4500
+ availableWidth: computedPinnedEndWidth,
4501
+ totalWidth: computedPinnedEndColumnsWidth,
4502
+ scrollable: computedPinnedEndOverflow,
4503
+ classNameModifiers: [
4504
+ "pinned",
4505
+ "pinned-end",
4506
+ computedPinnedEndOverflow ? "overflow" : ""
4507
+ ],
4508
+ scrollListener: computedPinnedEndOverflow ? pinnedEndScrollListener : void 0
4398
4509
  }) : null, scrollbars.vertical ? /* @__PURE__ */ React22.createElement(VerticalScrollbarPlaceholder, {
4399
4510
  style: {
4400
4511
  height: "100%",
@@ -4444,13 +4555,6 @@ var getScrollableClassName = (scrollable) => {
4444
4555
 
4445
4556
  // src/components/VirtualScrollContainer/index.tsx
4446
4557
  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
4558
  var VirtualScrollContainer = React23.forwardRef(function VirtualScrollContainer2(props, ref) {
4455
4559
  const {
4456
4560
  children,
@@ -4467,7 +4571,6 @@ var VirtualScrollContainer = React23.forwardRef(function VirtualScrollContainer2
4467
4571
  className: [
4468
4572
  className,
4469
4573
  rootClassName6,
4470
- defaultClasName,
4471
4574
  getScrollableClassName(scrollable)
4472
4575
  ].join(" ")
4473
4576
  }, children);
@@ -4513,7 +4616,6 @@ var UPDATE_SCROLL2 = (node, scrollPosition) => {
4513
4616
  var CLASSES = join(ICSS.height["0"], ICSS.width["0"], ICSS.willChange.transform);
4514
4617
  var debug4 = dbg("VirtuaList");
4515
4618
  var rootClassName7 = "IList";
4516
- var defaultClasses = [ICSS.position.relative, ICSS.transform.translate3D000];
4517
4619
  var VirtualList = (props) => {
4518
4620
  const _a = props, {
4519
4621
  scrollable,
@@ -4577,7 +4679,7 @@ var VirtualList = (props) => {
4577
4679
  const width = mainAxis === "horizontal" ? totalSize : itemCrossAxisSize != null ? itemCrossAxisSize : 0;
4578
4680
  const height = mainAxis === "vertical" ? totalSize : itemCrossAxisSize != null ? itemCrossAxisSize : 0;
4579
4681
  const domProps = __spreadProps(__spreadValues({}, restDOMProps), {
4580
- className: join(props.className, rootClassName7, `${rootClassName7}--${mainAxis}`, ...defaultClasses)
4682
+ className: join(props.className, rootClassName7, `${rootClassName7}--${mainAxis}`, ICSS.transform.translate3D000)
4581
4683
  });
4582
4684
  if (false) {
4583
4685
  domProps["data-cmp-name"] = `VirtualList`;
@@ -4587,7 +4689,8 @@ var VirtualList = (props) => {
4587
4689
  onContainerScroll
4588
4690
  }, /* @__PURE__ */ React25.createElement("div", {
4589
4691
  ref: domRef,
4590
- className: CLASSES
4692
+ className: CLASSES,
4693
+ "data-name": "scroll-transform-target"
4591
4694
  }, /* @__PURE__ */ React25.createElement(RawList, {
4592
4695
  brain: virtualBrain,
4593
4696
  renderItem,
@@ -4861,8 +4964,8 @@ function useUnpinnedRendering(params) {
4861
4964
  verticalVirtualBrain,
4862
4965
  horizontalVirtualBrain,
4863
4966
  computedUnpinnedColumnsWidth,
4864
- computedPinnedStartColumnsWidth,
4865
- computedPinnedEndColumnsWidth,
4967
+ computedPinnedStartWidth,
4968
+ computedPinnedEndWidth,
4866
4969
  computedUnpinnedColumns,
4867
4970
  getState
4868
4971
  } = params;
@@ -4917,8 +5020,8 @@ function useUnpinnedRendering(params) {
4917
5020
  height: bodySize.height,
4918
5021
  top: 0,
4919
5022
  position: "absolute",
4920
- left: computedPinnedStartColumnsWidth,
4921
- right: computedPinnedEndColumnsWidth
5023
+ left: computedPinnedStartWidth,
5024
+ right: computedPinnedEndWidth
4922
5025
  },
4923
5026
  count: getData().length,
4924
5027
  rowHeight,
@@ -5017,7 +5120,7 @@ function useOnMount(domRef, props) {
5017
5120
 
5018
5121
  // src/components/VirtualList/RowListWithExternalScrolling.tsx
5019
5122
  var rootClassName10 = "IList";
5020
- var defaultClasses2 = [
5123
+ var defaultClasses = [
5021
5124
  ICSS.willChange.transform,
5022
5125
  ICSS.position.relative,
5023
5126
  ICSS.transform.translate3D000
@@ -5051,8 +5154,6 @@ var RowListWithExternalScrolling = (props) => {
5051
5154
  const { renderStartIndex, renderEndIndex } = brain.getRenderRange();
5052
5155
  node.dataset.renderStartIndex = renderStartIndex;
5053
5156
  node.dataset.renderEndIndex = renderEndIndex;
5054
- node.dataset.scrollLeft = scrollPosition.scrollLeft;
5055
- node.dataset.scrollTop = scrollPosition.scrollTop;
5056
5157
  }
5057
5158
  if (updateScroll) {
5058
5159
  updateScroll(node, scrollPosition);
@@ -5069,7 +5170,7 @@ var RowListWithExternalScrolling = (props) => {
5069
5170
  const domProps = {
5070
5171
  ref: domRef,
5071
5172
  style,
5072
- className: join(className, rootClassName10, `${rootClassName10}--vertical`, ...defaultClasses2)
5173
+ className: join(className, rootClassName10, `${rootClassName10}--vertical`, ...defaultClasses)
5073
5174
  };
5074
5175
  if (false) {
5075
5176
  domProps["data-cmp-name"] = "RowListWithExternalScrolling";
@@ -5082,9 +5183,74 @@ var RowListWithExternalScrolling = (props) => {
5082
5183
  };
5083
5184
 
5084
5185
  // src/components/InfiniteTable/hooks/usePinnedRendering.tsx
5085
- var UPDATE_SCROLL3 = (node, scrollPosition) => {
5086
- node.style.transform = `translate3d(0px, ${-scrollPosition.scrollTop}px, 0px)`;
5186
+ var UPDATE_SCROLL3 = (node, brainScrollPosition, horizontalPinnedScrollPosition) => {
5187
+ node.style.transform = `translate3d(${horizontalPinnedScrollPosition ? -horizontalPinnedScrollPosition.scrollLeft : 0}px, ${-brainScrollPosition.scrollTop}px, 0px)`;
5087
5188
  };
5189
+ var PinnedRowsContainerClassName = `ITablePinnedRows`;
5190
+ function PinnedRowsContainer(props) {
5191
+ const {
5192
+ maxWidth,
5193
+ pinning,
5194
+ rowWidth,
5195
+ height,
5196
+ pinnedScrollListener,
5197
+ hasOverflow,
5198
+ brain,
5199
+ renderRow
5200
+ } = props;
5201
+ const style = React32.useMemo(() => {
5202
+ const result = pinning === "end" ? {
5203
+ width: rowWidth,
5204
+ height,
5205
+ right: 0
5206
+ } : {};
5207
+ if (!hasOverflow && pinning === "end") {
5208
+ result.position = "absolute";
5209
+ }
5210
+ if (hasOverflow) {
5211
+ result.height = getScrollbarWidth();
5212
+ result.width = getScrollbarWidth();
5213
+ }
5214
+ return result;
5215
+ }, [height, rowWidth, pinning, hasOverflow]);
5216
+ const updateScroll = (0, import_react36.useCallback)((node, scrollPosition) => {
5217
+ UPDATE_SCROLL3(node, scrollPosition, hasOverflow ? pinnedScrollListener.getScrollPosition() : void 0);
5218
+ }, [hasOverflow, pinnedScrollListener]);
5219
+ const rowListProps = {
5220
+ style,
5221
+ brain,
5222
+ renderRow,
5223
+ updateScroll,
5224
+ className: join(`${PinnedRowsContainerClassName}`, `${PinnedRowsContainerClassName}--pinned-${pinning}`, `${PinnedRowsContainerClassName}--overflow`)
5225
+ };
5226
+ if (hasOverflow) {
5227
+ return /* @__PURE__ */ React32.createElement(VirtualScrollContainer, {
5228
+ scrollable: {
5229
+ horizontal: true,
5230
+ vertical: false
5231
+ },
5232
+ style: {
5233
+ width: maxWidth,
5234
+ height,
5235
+ position: "absolute",
5236
+ [pinning === "start" ? "left" : "right"]: 0,
5237
+ [pinning === "start" ? "right" : "left"]: "unset"
5238
+ },
5239
+ onContainerScroll: pinnedScrollListener == null ? void 0 : pinnedScrollListener.setScrollPosition,
5240
+ className: join(`${PinnedRowsContainerClassName}Container`, `${PinnedRowsContainerClassName}Container--pinned-${pinning}`)
5241
+ }, /* @__PURE__ */ React32.createElement(RowListWithExternalScrolling, __spreadProps(__spreadValues({}, rowListProps), {
5242
+ onMount: (node) => {
5243
+ pinnedScrollListener == null ? void 0 : pinnedScrollListener.onScroll((scrollPosition) => {
5244
+ updateScroll(node, brain.getScrollPosition(), scrollPosition);
5245
+ });
5246
+ }
5247
+ })), /* @__PURE__ */ React32.createElement(SpacePlaceholder, {
5248
+ width: rowWidth,
5249
+ height: 1
5250
+ }));
5251
+ }
5252
+ return /* @__PURE__ */ React32.createElement(RowListWithExternalScrolling, __spreadValues({}, rowListProps));
5253
+ }
5088
5254
  function useRenderPinnedRow(params) {
5089
5255
  const { getData, getState, columnsWidth, columns } = params;
5090
5256
  const renderPinnedRow = (0, import_react36.useCallback)((rowInfo) => {
@@ -5104,7 +5270,7 @@ function useRenderPinnedRow(params) {
5104
5270
  }, [columnsWidth, columns]);
5105
5271
  return renderPinnedRow;
5106
5272
  }
5107
- function usePinnedEndRendering(params) {
5273
+ function usePinnedRenderingForSide(side, params) {
5108
5274
  const {
5109
5275
  getState,
5110
5276
  getData,
@@ -5112,7 +5278,15 @@ function usePinnedEndRendering(params) {
5112
5278
  bodySize,
5113
5279
  computedPinnedEndColumns,
5114
5280
  computedPinnedEndColumnsWidth,
5281
+ computedPinnedStartColumns,
5282
+ computedPinnedStartColumnsWidth,
5115
5283
  verticalVirtualBrain,
5284
+ computedPinnedEndWidth,
5285
+ computedPinnedEndOverflow,
5286
+ computedPinnedStartWidth,
5287
+ computedPinnedStartOverflow,
5288
+ pinnedStartScrollListener,
5289
+ pinnedEndScrollListener,
5116
5290
  repaintId,
5117
5291
  toggleGroupRow,
5118
5292
  scrollbars: {
@@ -5120,31 +5294,54 @@ function usePinnedEndRendering(params) {
5120
5294
  horizontal: hasHorizontalScrollbar
5121
5295
  }
5122
5296
  } = params;
5123
- const renderRowPinnedEnd = useRenderPinnedRow({
5297
+ const count = getData().length;
5298
+ const rowWidth = side === "start" ? computedPinnedStartColumnsWidth : computedPinnedEndColumnsWidth;
5299
+ const columns = side === "start" ? computedPinnedStartColumns : computedPinnedEndColumns;
5300
+ const columnsWidth = side === "start" ? computedPinnedStartColumnsWidth : computedPinnedEndColumnsWidth;
5301
+ const maxWidth = side === "start" ? computedPinnedStartWidth : computedPinnedEndWidth;
5302
+ const hasOverflow = side === "start" ? computedPinnedStartOverflow : computedPinnedEndOverflow;
5303
+ const pinnedScrollListener = side === "start" ? pinnedStartScrollListener : pinnedEndScrollListener;
5304
+ const renderRowPinned = useRenderPinnedRow({
5124
5305
  getData,
5125
5306
  getState,
5126
5307
  toggleGroupRow,
5127
- columns: computedPinnedEndColumns,
5128
- columnsWidth: computedPinnedEndColumnsWidth
5308
+ columns,
5309
+ columnsWidth
5129
5310
  });
5130
- const pinnedEndList = computedPinnedEndColumns.length && rowHeight !== 0 ? /* @__PURE__ */ React32.createElement(RowListWithExternalScrolling, {
5131
- repaintId: `${repaintId}-pin-end-${rowHeight}`,
5311
+ const pinnedList = columns.length && rowHeight !== 0 ? /* @__PURE__ */ React32.createElement(PinnedRowsContainer, {
5312
+ pinning: side,
5313
+ pinnedScrollListener,
5314
+ hasOverflow,
5315
+ rowHeight,
5316
+ rowWidth,
5317
+ maxWidth,
5318
+ height: bodySize.height,
5319
+ count,
5320
+ repaintId: `${repaintId}-pin-${side}-${rowHeight}`,
5132
5321
  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
5322
+ renderRow: renderRowPinned
5141
5323
  }) : null;
5142
- const pinnedEndScrollbarPlaceholder = pinnedEndList && hasHorizontalScrollbar ? /* @__PURE__ */ React32.createElement(HorizontalScrollbarPlaceholder, {
5143
- style: {
5144
- width: computedPinnedEndColumnsWidth,
5324
+ const pinnedScrollbarPlaceholder = pinnedList && hasHorizontalScrollbar && !hasOverflow ? /* @__PURE__ */ React32.createElement(HorizontalScrollbarPlaceholder, {
5325
+ style: side === "end" ? {
5326
+ width: columnsWidth,
5145
5327
  right: hasVerticalScrollbar ? getScrollbarWidth() : 0
5328
+ } : {
5329
+ width: columnsWidth,
5330
+ left: 0
5146
5331
  }
5147
5332
  }) : null;
5333
+ return {
5334
+ renderRowPinned,
5335
+ pinnedList,
5336
+ pinnedScrollbarPlaceholder
5337
+ };
5338
+ }
5339
+ function usePinnedEndRendering(params) {
5340
+ const {
5341
+ renderRowPinned: renderRowPinnedEnd,
5342
+ pinnedList: pinnedEndList,
5343
+ pinnedScrollbarPlaceholder: pinnedEndScrollbarPlaceholder
5344
+ } = usePinnedRenderingForSide("end", params);
5148
5345
  return {
5149
5346
  renderRowPinnedEnd,
5150
5347
  pinnedEndList,
@@ -5153,40 +5350,16 @@ function usePinnedEndRendering(params) {
5153
5350
  }
5154
5351
  function usePinnedStartRendering(params) {
5155
5352
  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 {
5353
+ renderRowPinned: renderRowPinnedStart,
5354
+ pinnedList: pinnedStartList,
5355
+ pinnedScrollbarPlaceholder: pinnedStartScrollbarPlaceholder
5356
+ } = usePinnedRenderingForSide("start", params);
5357
+ const result = {
5186
5358
  renderRowPinnedStart,
5187
5359
  pinnedStartList,
5188
5360
  pinnedStartScrollbarPlaceholder
5189
5361
  };
5362
+ return result;
5190
5363
  }
5191
5364
 
5192
5365
  // src/components/InfiniteTable/hooks/useYourBrain.ts
@@ -5194,7 +5367,7 @@ var import_react38 = __toModule(require("react"));
5194
5367
 
5195
5368
  // src/components/VirtualBrain/index.ts
5196
5369
  var import_binary_search2 = __toModule(require_binary_search());
5197
- var initialScrollPosition = {
5370
+ var initialScrollPosition2 = {
5198
5371
  scrollLeft: 0,
5199
5372
  scrollTop: 0
5200
5373
  };
@@ -5203,7 +5376,7 @@ var SORT_ASC = (a, b) => a - b;
5203
5376
  var VirtualBrain = class extends Logger {
5204
5377
  constructor(options) {
5205
5378
  super(`VirtualBrain:${options.mainAxis}`);
5206
- this.scrollPosition = initialScrollPosition;
5379
+ this.scrollPosition = initialScrollPosition2;
5207
5380
  this.scrollPositionOnMainAxis = 0;
5208
5381
  this.totalSize = 0;
5209
5382
  this.onScrollFns = [];
@@ -5557,8 +5730,8 @@ function useYourBrain(param) {
5557
5730
  const {
5558
5731
  dataArray,
5559
5732
  computedUnpinnedColumns,
5560
- computedPinnedStartColumnsWidth,
5561
- computedPinnedEndColumnsWidth,
5733
+ computedPinnedStartWidth,
5734
+ computedPinnedEndWidth,
5562
5735
  rowHeight,
5563
5736
  bodySize
5564
5737
  } = param;
@@ -5591,13 +5764,9 @@ function useYourBrain(param) {
5591
5764
  (0, import_react38.useEffect)(() => {
5592
5765
  horizontalVirtualBrain.setAvailableSize({
5593
5766
  height: 0,
5594
- width: Math.max(bodySize.width - computedPinnedStartColumnsWidth - computedPinnedEndColumnsWidth, 0)
5767
+ width: Math.max(bodySize.width - computedPinnedStartWidth - computedPinnedEndWidth, 0)
5595
5768
  });
5596
- }, [
5597
- bodySize.width,
5598
- computedPinnedStartColumnsWidth,
5599
- computedPinnedEndColumnsWidth
5600
- ]);
5769
+ }, [bodySize.width, computedPinnedStartWidth, computedPinnedEndWidth]);
5601
5770
  return { horizontalVirtualBrain, verticalVirtualBrain };
5602
5771
  }
5603
5772
 
@@ -5634,13 +5803,23 @@ function useListRendering(param) {
5634
5803
  computedPinnedEndColumns,
5635
5804
  computedPinnedStartColumnsWidth,
5636
5805
  computedPinnedEndColumnsWidth,
5806
+ computedPinnedStartWidth,
5807
+ computedPinnedEndWidth,
5637
5808
  computedUnpinnedColumns,
5638
- computedUnpinnedColumnsWidth
5809
+ computedUnpinnedColumnsWidth,
5810
+ computedPinnedStartOverflow,
5811
+ computedPinnedEndOverflow
5639
5812
  } = computed;
5640
- const { componentState: dataSourceState } = useDataSourceContextValue();
5813
+ const { componentState: dataSourceState, getState: getDataSourceState } = useDataSourceContextValue();
5641
5814
  const { dataArray } = dataSourceState;
5642
5815
  const getData = useLatest(dataArray);
5643
- const { rowHeight } = componentState;
5816
+ const {
5817
+ rowHeightComputed: rowHeight,
5818
+ pinnedStartMaxWidth,
5819
+ pinnedEndMaxWidth,
5820
+ pinnedStartScrollListener,
5821
+ pinnedEndScrollListener
5822
+ } = componentState;
5644
5823
  const prevDataSourceTimestamp = usePrevious(dataSourceState.updatedAt);
5645
5824
  const repaintIdRef = (0, import_react39.useRef)(0);
5646
5825
  if (!shallowEqualObjects(prevComputed, computed) || prevDataSourceTimestamp !== dataSourceState.updatedAt) {
@@ -5648,9 +5827,9 @@ function useListRendering(param) {
5648
5827
  }
5649
5828
  const repaintId = repaintIdRef.current;
5650
5829
  const { horizontalVirtualBrain, verticalVirtualBrain } = useYourBrain({
5830
+ computedPinnedStartWidth: computed.computedPinnedStartWidth,
5831
+ computedPinnedEndWidth: computed.computedPinnedEndWidth,
5651
5832
  computedUnpinnedColumns: computed.computedUnpinnedColumns,
5652
- computedPinnedStartColumnsWidth: computed.computedPinnedStartColumnsWidth,
5653
- computedPinnedEndColumnsWidth: computed.computedPinnedEndColumnsWidth,
5654
5833
  rowHeight,
5655
5834
  dataArray,
5656
5835
  bodySize
@@ -5675,7 +5854,9 @@ function useListRendering(param) {
5675
5854
  setColumnVisibility: (columnVisibility) => {
5676
5855
  componentActions.columnVisibility = columnVisibility;
5677
5856
  },
5678
- setColumnAggregations: (columnAggregations) => componentActions.columnAggregations = columnAggregations
5857
+ setColumnAggregations: (columnAggregations) => componentActions.columnAggregations = columnAggregations,
5858
+ getState,
5859
+ getDataSourceState
5679
5860
  };
5680
5861
  onReady(imperativeApi);
5681
5862
  }
@@ -5685,7 +5866,7 @@ function useListRendering(param) {
5685
5866
  horizontalVirtualBrain,
5686
5867
  domRef
5687
5868
  });
5688
- const { getState: getDataSourceState, componentActions: dataSourceActions } = useDataSourceContextValue();
5869
+ const { componentActions: dataSourceActions } = useDataSourceContextValue();
5689
5870
  const toggleGroupRow = (0, import_react39.useCallback)((groupKeys) => {
5690
5871
  const newState = new GroupRowsState(getDataSourceState().groupRowsState);
5691
5872
  newState.toggleGroupRow(groupKeys);
@@ -5696,14 +5877,22 @@ function useListRendering(param) {
5696
5877
  scrollbars,
5697
5878
  computedPinnedStartColumns,
5698
5879
  computedPinnedEndColumns,
5880
+ computedPinnedStartWidth,
5881
+ computedPinnedEndWidth,
5882
+ computedPinnedStartOverflow,
5883
+ computedPinnedEndOverflow,
5699
5884
  computedPinnedStartColumnsWidth,
5700
5885
  computedPinnedEndColumnsWidth,
5701
5886
  getData,
5702
5887
  getState,
5703
5888
  toggleGroupRow,
5889
+ pinnedStartMaxWidth,
5890
+ pinnedEndMaxWidth,
5704
5891
  repaintId,
5705
5892
  rowHeight,
5706
- verticalVirtualBrain
5893
+ verticalVirtualBrain,
5894
+ pinnedStartScrollListener,
5895
+ pinnedEndScrollListener
5707
5896
  };
5708
5897
  const centerRenderingParams = __spreadProps(__spreadValues({}, pinnedRenderingParams), {
5709
5898
  columnShifts,
@@ -5964,7 +6153,7 @@ var useLicense = (licenseKey) => {
5964
6153
  const valid = (0, import_react41.useMemo)(() => {
5965
6154
  return isValidLicense(licenseKey, {
5966
6155
  publishedAt: 1624970570587,
5967
- version: "0.0.1-canary.9"
6156
+ version: "0.0.1"
5968
6157
  });
5969
6158
  }, [licenseKey]);
5970
6159
  return valid;
@@ -6050,7 +6239,6 @@ var InfiniteTableComponent = React35.memo(function InfiniteTableComponent2() {
6050
6239
  headerHeightCSSVar
6051
6240
  } = componentState;
6052
6241
  const { columnShifts, bodySize } = componentState;
6053
- const className = join(InfiniteTableClassName, columnShifts ? `${InfiniteTableClassName}--shifting` : "", domProps == null ? void 0 : domProps.className);
6054
6242
  const {
6055
6243
  pinnedStartList,
6056
6244
  pinnedEndList,
@@ -6070,6 +6258,7 @@ var InfiniteTableComponent = React35.memo(function InfiniteTableComponent2() {
6070
6258
  computed
6071
6259
  });
6072
6260
  const licenseValid = useLicense(licenseKey);
6261
+ 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
6262
  return /* @__PURE__ */ React35.createElement("div", __spreadProps(__spreadValues({
6074
6263
  ref: domRef
6075
6264
  }, domProps), {
@@ -6105,7 +6294,10 @@ function InfiniteTableContextProvider() {
6105
6294
  const computed = useComputed();
6106
6295
  const getComputed = useLatest(computed);
6107
6296
  const getState = useLatest(componentState);
6108
- globalThis.getState = getState;
6297
+ if (false) {
6298
+ globalThis.getState = getState;
6299
+ globalThis.getComputed = getComputed;
6300
+ }
6109
6301
  const contextValue = {
6110
6302
  componentActions,
6111
6303
  componentState,