@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.esm.js CHANGED
@@ -630,6 +630,41 @@ function isControlled(propName, props) {
630
630
  return controlled;
631
631
  }
632
632
 
633
+ // src/components/VirtualBrain/ScrollListener.ts
634
+ var initialScrollPosition = {
635
+ scrollLeft: 0,
636
+ scrollTop: 0
637
+ };
638
+ var ScrollListener = class {
639
+ constructor() {
640
+ this.scrollPosition = initialScrollPosition;
641
+ this.onScrollFns = [];
642
+ this.getScrollPosition = () => {
643
+ return this.scrollPosition;
644
+ };
645
+ this.onScroll = (fn) => {
646
+ this.onScrollFns.push(fn);
647
+ return () => {
648
+ this.onScrollFns = this.onScrollFns.filter((f) => f !== fn);
649
+ };
650
+ };
651
+ this.setScrollPosition = (scrollPosition) => {
652
+ this.scrollPosition = scrollPosition;
653
+ this.notifyScrollChange();
654
+ };
655
+ this.destroy = () => {
656
+ this.onScrollFns = [];
657
+ };
658
+ }
659
+ notifyScrollChange() {
660
+ const { scrollPosition } = this;
661
+ const fns = this.onScrollFns;
662
+ for (let i = 0, len = fns.length; i < len; i++) {
663
+ fns[i](scrollPosition);
664
+ }
665
+ }
666
+ };
667
+
633
668
  // src/components/InfiniteTable/state/computeColumnGroupsDepths.ts
634
669
  function computeColumnGroupsDepths(columnGroups) {
635
670
  const map = new Map();
@@ -664,7 +699,7 @@ function getInitialState(params) {
664
699
  const generatedColumns = new Map();
665
700
  const pivotColumns = props.pivotColumns;
666
701
  return {
667
- rowHeight: typeof props.rowHeight === "number" ? props.rowHeight : 0,
702
+ rowHeightComputed: typeof props.rowHeight === "number" ? props.rowHeight : 0,
668
703
  headerHeight: typeof props.headerHeight === "number" ? props.headerHeight : 0,
669
704
  domRef: createRef(),
670
705
  bodyDOMRef: createRef(),
@@ -687,6 +722,8 @@ function getInitialState(params) {
687
722
  generatedColumns,
688
723
  columnOrder: (_c = isControlled("columnOrder", props) ? props.columnOrder : props.defaultColumnOrder) != null ? _c : true,
689
724
  computedColumnGroups,
725
+ pinnedStartScrollListener: new ScrollListener(),
726
+ pinnedEndScrollListener: new ScrollListener(),
690
727
  columnGroups,
691
728
  collapsedColumnGroups,
692
729
  columnGroupsDepthsMap,
@@ -718,6 +755,8 @@ function deriveReadOnlyState(params) {
718
755
  rowStyle: props.rowStyle,
719
756
  rowProps: props.rowProps,
720
757
  rowClassName: props.rowClassName,
758
+ pinnedStartMaxWidth: props.pinnedStartMaxWidth,
759
+ pinnedEndMaxWidth: props.pinnedEndMaxWidth,
721
760
  groupRenderStrategy: (_e = props.groupRenderStrategy) != null ? _e : "multi-column",
722
761
  pivotTotalColumnPosition,
723
762
  columnMinWidth: (_f = props.columnMinWidth) != null ? _f : 30,
@@ -1004,6 +1043,9 @@ var adjustColumnOrderForPinning = (columnOrder, columnPinning) => {
1004
1043
  };
1005
1044
 
1006
1045
  // src/components/InfiniteTable/utils/getComputedVisibleColumns.ts
1046
+ var IS_GROUP_COLUMN_ID = (columnId) => {
1047
+ return columnId.startsWith("group-by");
1048
+ };
1007
1049
  var isColumnVisible = (columnVisibility, _columnVisibilityAssumeVisible, colId) => {
1008
1050
  return !columnVisibility.has(colId) || columnVisibility.get(colId) !== false;
1009
1051
  };
@@ -1019,6 +1061,8 @@ var getComputedVisibleColumns = ({
1019
1061
  columnMinWidth,
1020
1062
  columnMaxWidth,
1021
1063
  columnDefaultWidth,
1064
+ pinnedStartMaxWidth,
1065
+ pinnedEndMaxWidth,
1022
1066
  sortable,
1023
1067
  sortInfo,
1024
1068
  setSortInfo,
@@ -1036,12 +1080,12 @@ var getComputedVisibleColumns = ({
1036
1080
  let col = columns.get(columnId);
1037
1081
  if (!col) {
1038
1082
  col = generatedColumns.get(columnId);
1039
- if (!col) {
1083
+ if (!col && !IS_GROUP_COLUMN_ID(columnId)) {
1040
1084
  throw `Column with id "${columnId}" specified in columnOrder array cannot be found in the columns map.`;
1041
1085
  }
1042
1086
  }
1043
1087
  return col;
1044
- });
1088
+ }).filter(Boolean);
1045
1089
  const sortedMap = (sortInfo != null ? sortInfo : []).reduce((acc, info, index) => {
1046
1090
  if (info.id) {
1047
1091
  acc[info.id] = { sortInfo: info, index };
@@ -1200,6 +1244,8 @@ var getComputedVisibleColumns = ({
1200
1244
  }
1201
1245
  prevPinned = computedPinned;
1202
1246
  });
1247
+ const computedPinnedStartWidth = pinnedStartMaxWidth != null ? Math.min(pinnedStartMaxWidth, computedPinnedStartColumnsWidth) : computedPinnedStartColumnsWidth;
1248
+ const computedPinnedEndWidth = pinnedEndMaxWidth != null ? Math.min(pinnedEndMaxWidth, computedPinnedEndColumnsWidth) : computedPinnedEndColumnsWidth;
1203
1249
  const result = {
1204
1250
  computedRemainingSpace: bodySize.width - (totalPinnedStartWidth + totalPinnedEndWidth + totalUnpinnedWidth),
1205
1251
  computedPinnedStartColumnsWidth,
@@ -1212,7 +1258,9 @@ var getComputedVisibleColumns = ({
1212
1258
  computedPinnedEndOffset: computedPinnedStartColumnsWidth + computedUnpinnedColumnsWidth,
1213
1259
  computedUnpinnedColumns,
1214
1260
  computedVisibleColumns,
1215
- computedVisibleColumnsMap
1261
+ computedVisibleColumnsMap,
1262
+ computedPinnedEndWidth,
1263
+ computedPinnedStartWidth
1216
1264
  };
1217
1265
  return result;
1218
1266
  };
@@ -1318,6 +1366,8 @@ var useComputedVisibleColumns = ({
1318
1366
  setSortInfo,
1319
1367
  columnOrder,
1320
1368
  columnPinning,
1369
+ pinnedEndMaxWidth,
1370
+ pinnedStartMaxWidth,
1321
1371
  columnVisibility,
1322
1372
  columnVisibilityAssumeVisible
1323
1373
  }) => {
@@ -1336,7 +1386,9 @@ var useComputedVisibleColumns = ({
1336
1386
  computedPinnedEndColumnsWidth,
1337
1387
  computedUnpinnedColumnsWidth,
1338
1388
  computedUnpinnedOffset,
1339
- computedPinnedEndOffset
1389
+ computedPinnedEndOffset,
1390
+ computedPinnedEndWidth,
1391
+ computedPinnedStartWidth
1340
1392
  } = useMemo2(() => {
1341
1393
  return getComputedVisibleColumns({
1342
1394
  columns,
@@ -1349,6 +1401,8 @@ var useComputedVisibleColumns = ({
1349
1401
  sortInfo,
1350
1402
  setSortInfo,
1351
1403
  multiSort,
1404
+ pinnedEndMaxWidth,
1405
+ pinnedStartMaxWidth,
1352
1406
  draggableColumns,
1353
1407
  columnOrder,
1354
1408
  columnPinning,
@@ -1369,6 +1423,8 @@ var useComputedVisibleColumns = ({
1369
1423
  columnOrder,
1370
1424
  columnVisibility,
1371
1425
  columnVisibilityAssumeVisible,
1426
+ pinnedEndMaxWidth,
1427
+ pinnedStartMaxWidth,
1372
1428
  columnPinning,
1373
1429
  columnsRenderId,
1374
1430
  visibilityRenderId,
@@ -1376,6 +1432,8 @@ var useComputedVisibleColumns = ({
1376
1432
  ]);
1377
1433
  const result = {
1378
1434
  columns,
1435
+ computedPinnedEndWidth,
1436
+ computedPinnedStartWidth,
1379
1437
  computedRemainingSpace,
1380
1438
  computedUnpinnedOffset,
1381
1439
  computedPinnedEndOffset,
@@ -3143,7 +3201,7 @@ function useComputed() {
3143
3201
  useState4(() => {
3144
3202
  componentState.onRowHeightChange.onChange((rowHeight) => {
3145
3203
  if (rowHeight) {
3146
- componentActions.rowHeight = rowHeight;
3204
+ componentActions.rowHeightComputed = rowHeight;
3147
3205
  }
3148
3206
  });
3149
3207
  componentState.onHeaderHeightChange.onChange((headerHeight) => {
@@ -3172,13 +3230,17 @@ function useComputed() {
3172
3230
  computedUnpinnedColumnsWidth,
3173
3231
  computedUnpinnedOffset,
3174
3232
  computedPinnedEndOffset,
3175
- computedRemainingSpace
3233
+ computedRemainingSpace,
3234
+ computedPinnedStartWidth,
3235
+ computedPinnedEndWidth
3176
3236
  } = useComputedVisibleColumns({
3177
3237
  columns: componentState.computedPivotColumns || componentState.columns,
3178
3238
  generatedColumns: componentState.generatedColumns,
3179
3239
  columnMinWidth: componentState.columnMinWidth,
3180
3240
  columnMaxWidth: componentState.columnMaxWidth,
3181
3241
  columnDefaultWidth: componentState.columnDefaultWidth,
3242
+ pinnedStartMaxWidth: componentState.pinnedStartMaxWidth,
3243
+ pinnedEndMaxWidth: componentState.pinnedEndMaxWidth,
3182
3244
  bodySize,
3183
3245
  sortable: componentState.sortable,
3184
3246
  draggableColumns: componentState.draggableColumns,
@@ -3213,7 +3275,13 @@ function useComputed() {
3213
3275
  if (colWidthSum > scrollLeft) {
3214
3276
  columnRenderStartIndex--;
3215
3277
  }
3278
+ const computedPinnedStartOverflow = computedPinnedStartWidth ? computedPinnedStartColumnsWidth > computedPinnedStartWidth : false;
3279
+ const computedPinnedEndOverflow = computedPinnedEndWidth ? computedPinnedEndColumnsWidth > computedPinnedEndWidth : false;
3216
3280
  return {
3281
+ computedPinnedStartOverflow,
3282
+ computedPinnedEndOverflow,
3283
+ computedPinnedStartWidth,
3284
+ computedPinnedEndWidth,
3217
3285
  computedVisibleColumns,
3218
3286
  computedColumnOrder,
3219
3287
  computedRemainingSpace,
@@ -3291,8 +3359,8 @@ import {
3291
3359
  memo as memo2
3292
3360
  } from "react";
3293
3361
  function HorizontalScrollbarPlaceholderFn(props) {
3294
- const height = getScrollbarWidth();
3295
- if (!height) {
3362
+ const scrollbarWidth2 = getScrollbarWidth();
3363
+ if (!scrollbarWidth2) {
3296
3364
  return null;
3297
3365
  }
3298
3366
  return /* @__PURE__ */ createElement8("div", {
@@ -3301,15 +3369,14 @@ function HorizontalScrollbarPlaceholderFn(props) {
3301
3369
  position: "absolute",
3302
3370
  overflow: "visible",
3303
3371
  overflowX: "scroll",
3304
- height,
3305
3372
  bottom: 0
3306
3373
  }, props.style)
3307
3374
  });
3308
3375
  }
3309
3376
  var HorizontalScrollbarPlaceholder = memo2(HorizontalScrollbarPlaceholderFn);
3310
3377
  function VerticalScrollbarPlaceholderFn(props) {
3311
- const width = getScrollbarWidth();
3312
- if (!width) {
3378
+ const scrollbarWidth2 = getScrollbarWidth();
3379
+ if (!scrollbarWidth2) {
3313
3380
  return null;
3314
3381
  }
3315
3382
  return /* @__PURE__ */ createElement8("div", {
@@ -3318,7 +3385,6 @@ function VerticalScrollbarPlaceholderFn(props) {
3318
3385
  position: "absolute",
3319
3386
  overflow: "visible",
3320
3387
  overflowY: "scroll",
3321
- width,
3322
3388
  bottom: 0
3323
3389
  }, props.style)
3324
3390
  });
@@ -4334,7 +4400,23 @@ var UPDATE_SCROLL = (node, scrollPosition) => {
4334
4400
  node.style.transform = `translate3d(${-scrollPosition.scrollLeft}px, 0px, 0px)`;
4335
4401
  };
4336
4402
  function InfiniteTableHeaderUnvirtualizedFn(props) {
4337
- const _a = props, { columns, scrollable, brain, totalWidth } = _a, domProps = __objRest(_a, ["columns", "scrollable", "brain", "totalWidth"]);
4403
+ const _a = props, {
4404
+ columns,
4405
+ scrollable,
4406
+ classNameModifiers,
4407
+ brain,
4408
+ scrollListener,
4409
+ totalWidth,
4410
+ availableWidth
4411
+ } = _a, domProps = __objRest(_a, [
4412
+ "columns",
4413
+ "scrollable",
4414
+ "classNameModifiers",
4415
+ "brain",
4416
+ "scrollListener",
4417
+ "totalWidth",
4418
+ "availableWidth"
4419
+ ]);
4338
4420
  const {
4339
4421
  componentState: {
4340
4422
  computedColumnGroups,
@@ -4375,23 +4457,27 @@ function InfiniteTableHeaderUnvirtualizedFn(props) {
4375
4457
  });
4376
4458
  const style = __spreadValues({}, domProps == null ? void 0 : domProps.style);
4377
4459
  if (totalWidth != null) {
4378
- style.width = totalWidth;
4460
+ style.width = availableWidth;
4379
4461
  }
4380
4462
  useEffect13(() => {
4381
- if (!brain || !scrollable) {
4463
+ const scroller = brain || scrollListener;
4464
+ if (!scroller || !scrollable) {
4382
4465
  return;
4383
4466
  }
4384
4467
  const onScroll = (scrollPosition) => {
4385
4468
  UPDATE_SCROLL(domRef.current, scrollPosition);
4386
4469
  };
4387
- const removeOnScroll = brain.onScroll(onScroll);
4470
+ const removeOnScroll = scroller.onScroll(onScroll);
4388
4471
  return removeOnScroll;
4389
- }, [brain]);
4472
+ }, [brain, scrollListener]);
4390
4473
  return /* @__PURE__ */ createElement18("div", __spreadProps(__spreadValues({}, domProps), {
4391
- ref: domRef,
4392
- className: join(ICSS.flexFlow.row, ICSS.display.flex, TableHeaderClassName2, `${TableHeaderClassName2}--unvirtualized`, domProps.className),
4474
+ className: join(TableHeaderClassName2, `${TableHeaderClassName2}--unvirtualized`, domProps.className, ...(classNameModifiers || []).filter(Boolean).map((modifier) => `${TableHeaderClassName2}--${modifier}`)),
4393
4475
  style
4394
- }), children);
4476
+ }), /* @__PURE__ */ createElement18("div", {
4477
+ style: { width: totalWidth },
4478
+ className: join(ICSS.flexFlow.row, ICSS.display.flex),
4479
+ ref: domRef
4480
+ }, children));
4395
4481
  }
4396
4482
  var InfiniteTableHeaderUnvirtualized = memo7(InfiniteTableHeaderUnvirtualizedFn);
4397
4483
 
@@ -4404,11 +4490,21 @@ function TableHeaderWrapper(props) {
4404
4490
  computedPinnedStartColumns,
4405
4491
  computedPinnedEndColumns,
4406
4492
  computedPinnedStartColumnsWidth,
4493
+ computedPinnedStartWidth,
4494
+ computedPinnedEndWidth,
4407
4495
  computedPinnedEndColumnsWidth,
4408
- computedUnpinnedColumnsWidth
4496
+ computedUnpinnedColumnsWidth,
4497
+ computedPinnedStartOverflow,
4498
+ computedPinnedEndOverflow
4409
4499
  } = tableContextValue.computed;
4410
4500
  const {
4411
- componentState: { virtualizeHeader, headerHeight, columnGroupsMaxDepth }
4501
+ componentState: {
4502
+ virtualizeHeader,
4503
+ headerHeight,
4504
+ columnGroupsMaxDepth,
4505
+ pinnedStartScrollListener,
4506
+ pinnedEndScrollListener
4507
+ }
4412
4508
  } = tableContextValue;
4413
4509
  const hasPinnedStart = computedPinnedStartColumns.length > 0;
4414
4510
  const hasPinnedEnd = computedPinnedEndColumns.length > 0;
@@ -4419,15 +4515,17 @@ function TableHeaderWrapper(props) {
4419
4515
  brain,
4420
4516
  style: {
4421
4517
  position: "absolute",
4422
- left: computedPinnedStartColumnsWidth,
4518
+ left: computedPinnedStartWidth,
4423
4519
  width: computedUnpinnedColumnsWidth,
4424
4520
  height: columnGroupsMaxDepth || headerHeight
4425
4521
  },
4522
+ availableWidth: computedUnpinnedColumnsWidth,
4426
4523
  totalWidth: computedUnpinnedColumnsWidth
4427
4524
  }) : /* @__PURE__ */ createElement19(InfiniteTableHeaderUnvirtualized, {
4428
4525
  brain,
4429
4526
  scrollable: true,
4430
4527
  columns: computedUnpinnedColumns,
4528
+ availableWidth: computedUnpinnedColumnsWidth,
4431
4529
  totalWidth: computedUnpinnedColumnsWidth
4432
4530
  });
4433
4531
  return /* @__PURE__ */ createElement19("div", {
@@ -4440,18 +4538,34 @@ function TableHeaderWrapper(props) {
4440
4538
  style: {
4441
4539
  left: 0,
4442
4540
  position: "absolute",
4443
- width: computedPinnedStartColumnsWidth
4541
+ width: computedPinnedStartWidth
4444
4542
  },
4543
+ availableWidth: computedPinnedStartWidth,
4544
+ totalWidth: computedPinnedStartColumnsWidth,
4445
4545
  columns: computedPinnedStartColumns,
4446
- totalWidth: computedPinnedStartColumnsWidth
4546
+ scrollable: computedPinnedStartOverflow,
4547
+ classNameModifiers: [
4548
+ "pinned",
4549
+ "pinned-start",
4550
+ computedPinnedStartOverflow ? "overflow" : ""
4551
+ ],
4552
+ scrollListener: computedPinnedStartOverflow ? pinnedStartScrollListener : void 0
4447
4553
  }) : null, header, hasPinnedEnd ? /* @__PURE__ */ createElement19(InfiniteTableHeaderUnvirtualized, {
4448
4554
  style: {
4449
4555
  right: scrollbars.vertical ? getScrollbarWidth() : 0,
4450
4556
  position: "absolute",
4451
- width: computedPinnedEndColumnsWidth
4557
+ width: computedPinnedEndWidth
4452
4558
  },
4453
4559
  columns: computedPinnedEndColumns,
4454
- totalWidth: computedPinnedEndColumnsWidth
4560
+ availableWidth: computedPinnedEndWidth,
4561
+ totalWidth: computedPinnedEndColumnsWidth,
4562
+ scrollable: computedPinnedEndOverflow,
4563
+ classNameModifiers: [
4564
+ "pinned",
4565
+ "pinned-end",
4566
+ computedPinnedEndOverflow ? "overflow" : ""
4567
+ ],
4568
+ scrollListener: computedPinnedEndOverflow ? pinnedEndScrollListener : void 0
4455
4569
  }) : null, scrollbars.vertical ? /* @__PURE__ */ createElement19(VerticalScrollbarPlaceholder, {
4456
4570
  style: {
4457
4571
  height: "100%",
@@ -4504,13 +4618,6 @@ var getScrollableClassName = (scrollable) => {
4504
4618
 
4505
4619
  // src/components/VirtualScrollContainer/index.tsx
4506
4620
  var rootClassName6 = "IT-VirtualScrollContainer";
4507
- var defaultClasName = [
4508
- ICSS.position.fixed,
4509
- ICSS.height["100%"],
4510
- ICSS.width["100%"],
4511
- ICSS.left[0],
4512
- ICSS.top[0]
4513
- ].join(" ");
4514
4621
  var VirtualScrollContainer = forwardRef2(function VirtualScrollContainer2(props, ref) {
4515
4622
  const {
4516
4623
  children,
@@ -4527,7 +4634,6 @@ var VirtualScrollContainer = forwardRef2(function VirtualScrollContainer2(props,
4527
4634
  className: [
4528
4635
  className,
4529
4636
  rootClassName6,
4530
- defaultClasName,
4531
4637
  getScrollableClassName(scrollable)
4532
4638
  ].join(" ")
4533
4639
  }, children);
@@ -4558,7 +4664,7 @@ function SpacePlaceholderFn(props) {
4558
4664
  var SpacePlaceholder = memo8(SpacePlaceholderFn);
4559
4665
 
4560
4666
  // src/components/InfiniteTable/hooks/useListRendering.tsx
4561
- import { useCallback as useCallback17, useEffect as useEffect19, useMemo as useMemo8, useRef as useRef14 } from "react";
4667
+ import { useCallback as useCallback17, useEffect as useEffect19, useMemo as useMemo9, useRef as useRef14 } from "react";
4562
4668
 
4563
4669
  // src/components/InfiniteTable/hooks/useUnpinnedRendering.tsx
4564
4670
  import {
@@ -4584,7 +4690,6 @@ var UPDATE_SCROLL2 = (node, scrollPosition) => {
4584
4690
  var CLASSES = join(ICSS.height["0"], ICSS.width["0"], ICSS.willChange.transform);
4585
4691
  var debug4 = dbg("VirtuaList");
4586
4692
  var rootClassName7 = "IList";
4587
- var defaultClasses = [ICSS.position.relative, ICSS.transform.translate3D000];
4588
4693
  var VirtualList = (props) => {
4589
4694
  const _a = props, {
4590
4695
  scrollable,
@@ -4648,7 +4753,7 @@ var VirtualList = (props) => {
4648
4753
  const width = mainAxis === "horizontal" ? totalSize : itemCrossAxisSize != null ? itemCrossAxisSize : 0;
4649
4754
  const height = mainAxis === "vertical" ? totalSize : itemCrossAxisSize != null ? itemCrossAxisSize : 0;
4650
4755
  const domProps = __spreadProps(__spreadValues({}, restDOMProps), {
4651
- className: join(props.className, rootClassName7, `${rootClassName7}--${mainAxis}`, ...defaultClasses)
4756
+ className: join(props.className, rootClassName7, `${rootClassName7}--${mainAxis}`, ICSS.transform.translate3D000)
4652
4757
  });
4653
4758
  if (false) {
4654
4759
  domProps["data-cmp-name"] = `VirtualList`;
@@ -4658,7 +4763,8 @@ var VirtualList = (props) => {
4658
4763
  onContainerScroll
4659
4764
  }, /* @__PURE__ */ createElement22("div", {
4660
4765
  ref: domRef,
4661
- className: CLASSES
4766
+ className: CLASSES,
4767
+ "data-name": "scroll-transform-target"
4662
4768
  }, /* @__PURE__ */ createElement22(RawList, {
4663
4769
  brain: virtualBrain,
4664
4770
  renderItem,
@@ -4945,8 +5051,8 @@ function useUnpinnedRendering(params) {
4945
5051
  verticalVirtualBrain,
4946
5052
  horizontalVirtualBrain,
4947
5053
  computedUnpinnedColumnsWidth,
4948
- computedPinnedStartColumnsWidth,
4949
- computedPinnedEndColumnsWidth,
5054
+ computedPinnedStartWidth,
5055
+ computedPinnedEndWidth,
4950
5056
  computedUnpinnedColumns,
4951
5057
  getState
4952
5058
  } = params;
@@ -5001,8 +5107,8 @@ function useUnpinnedRendering(params) {
5001
5107
  height: bodySize.height,
5002
5108
  top: 0,
5003
5109
  position: "absolute",
5004
- left: computedPinnedStartColumnsWidth,
5005
- right: computedPinnedEndColumnsWidth
5110
+ left: computedPinnedStartWidth,
5111
+ right: computedPinnedEndWidth
5006
5112
  },
5007
5113
  count: getData().length,
5008
5114
  rowHeight,
@@ -5080,7 +5186,8 @@ var useOnContainerScroll = ({
5080
5186
 
5081
5187
  // src/components/InfiniteTable/hooks/usePinnedRendering.tsx
5082
5188
  import {
5083
- createElement as createElement29
5189
+ createElement as createElement29,
5190
+ useMemo as useMemo8
5084
5191
  } from "react";
5085
5192
  import { useCallback as useCallback15 } from "react";
5086
5193
 
@@ -5105,7 +5212,7 @@ function useOnMount(domRef, props) {
5105
5212
 
5106
5213
  // src/components/VirtualList/RowListWithExternalScrolling.tsx
5107
5214
  var rootClassName10 = "IList";
5108
- var defaultClasses2 = [
5215
+ var defaultClasses = [
5109
5216
  ICSS.willChange.transform,
5110
5217
  ICSS.position.relative,
5111
5218
  ICSS.transform.translate3D000
@@ -5139,8 +5246,6 @@ var RowListWithExternalScrolling = (props) => {
5139
5246
  const { renderStartIndex, renderEndIndex } = brain.getRenderRange();
5140
5247
  node.dataset.renderStartIndex = renderStartIndex;
5141
5248
  node.dataset.renderEndIndex = renderEndIndex;
5142
- node.dataset.scrollLeft = scrollPosition.scrollLeft;
5143
- node.dataset.scrollTop = scrollPosition.scrollTop;
5144
5249
  }
5145
5250
  if (updateScroll) {
5146
5251
  updateScroll(node, scrollPosition);
@@ -5157,7 +5262,7 @@ var RowListWithExternalScrolling = (props) => {
5157
5262
  const domProps = {
5158
5263
  ref: domRef,
5159
5264
  style,
5160
- className: join(className, rootClassName10, `${rootClassName10}--vertical`, ...defaultClasses2)
5265
+ className: join(className, rootClassName10, `${rootClassName10}--vertical`, ...defaultClasses)
5161
5266
  };
5162
5267
  if (false) {
5163
5268
  domProps["data-cmp-name"] = "RowListWithExternalScrolling";
@@ -5170,9 +5275,74 @@ var RowListWithExternalScrolling = (props) => {
5170
5275
  };
5171
5276
 
5172
5277
  // src/components/InfiniteTable/hooks/usePinnedRendering.tsx
5173
- var UPDATE_SCROLL3 = (node, scrollPosition) => {
5174
- node.style.transform = `translate3d(0px, ${-scrollPosition.scrollTop}px, 0px)`;
5278
+ var UPDATE_SCROLL3 = (node, brainScrollPosition, horizontalPinnedScrollPosition) => {
5279
+ node.style.transform = `translate3d(${horizontalPinnedScrollPosition ? -horizontalPinnedScrollPosition.scrollLeft : 0}px, ${-brainScrollPosition.scrollTop}px, 0px)`;
5175
5280
  };
5281
+ var PinnedRowsContainerClassName = `ITablePinnedRows`;
5282
+ function PinnedRowsContainer(props) {
5283
+ const {
5284
+ maxWidth,
5285
+ pinning,
5286
+ rowWidth,
5287
+ height,
5288
+ pinnedScrollListener,
5289
+ hasOverflow,
5290
+ brain,
5291
+ renderRow
5292
+ } = props;
5293
+ const style = useMemo8(() => {
5294
+ const result = pinning === "end" ? {
5295
+ width: rowWidth,
5296
+ height,
5297
+ right: 0
5298
+ } : {};
5299
+ if (!hasOverflow && pinning === "end") {
5300
+ result.position = "absolute";
5301
+ }
5302
+ if (hasOverflow) {
5303
+ result.height = getScrollbarWidth();
5304
+ result.width = getScrollbarWidth();
5305
+ }
5306
+ return result;
5307
+ }, [height, rowWidth, pinning, hasOverflow]);
5308
+ const updateScroll = useCallback15((node, scrollPosition) => {
5309
+ UPDATE_SCROLL3(node, scrollPosition, hasOverflow ? pinnedScrollListener.getScrollPosition() : void 0);
5310
+ }, [hasOverflow, pinnedScrollListener]);
5311
+ const rowListProps = {
5312
+ style,
5313
+ brain,
5314
+ renderRow,
5315
+ updateScroll,
5316
+ className: join(`${PinnedRowsContainerClassName}`, `${PinnedRowsContainerClassName}--pinned-${pinning}`, `${PinnedRowsContainerClassName}--overflow`)
5317
+ };
5318
+ if (hasOverflow) {
5319
+ return /* @__PURE__ */ createElement29(VirtualScrollContainer, {
5320
+ scrollable: {
5321
+ horizontal: true,
5322
+ vertical: false
5323
+ },
5324
+ style: {
5325
+ width: maxWidth,
5326
+ height,
5327
+ position: "absolute",
5328
+ [pinning === "start" ? "left" : "right"]: 0,
5329
+ [pinning === "start" ? "right" : "left"]: "unset"
5330
+ },
5331
+ onContainerScroll: pinnedScrollListener == null ? void 0 : pinnedScrollListener.setScrollPosition,
5332
+ className: join(`${PinnedRowsContainerClassName}Container`, `${PinnedRowsContainerClassName}Container--pinned-${pinning}`)
5333
+ }, /* @__PURE__ */ createElement29(RowListWithExternalScrolling, __spreadProps(__spreadValues({}, rowListProps), {
5334
+ onMount: (node) => {
5335
+ pinnedScrollListener == null ? void 0 : pinnedScrollListener.onScroll((scrollPosition) => {
5336
+ updateScroll(node, brain.getScrollPosition(), scrollPosition);
5337
+ });
5338
+ }
5339
+ })), /* @__PURE__ */ createElement29(SpacePlaceholder, {
5340
+ width: rowWidth,
5341
+ height: 1
5342
+ }));
5343
+ }
5344
+ return /* @__PURE__ */ createElement29(RowListWithExternalScrolling, __spreadValues({}, rowListProps));
5345
+ }
5176
5346
  function useRenderPinnedRow(params) {
5177
5347
  const { getData, getState, columnsWidth, columns } = params;
5178
5348
  const renderPinnedRow = useCallback15((rowInfo) => {
@@ -5192,7 +5362,7 @@ function useRenderPinnedRow(params) {
5192
5362
  }, [columnsWidth, columns]);
5193
5363
  return renderPinnedRow;
5194
5364
  }
5195
- function usePinnedEndRendering(params) {
5365
+ function usePinnedRenderingForSide(side, params) {
5196
5366
  const {
5197
5367
  getState,
5198
5368
  getData,
@@ -5200,7 +5370,15 @@ function usePinnedEndRendering(params) {
5200
5370
  bodySize,
5201
5371
  computedPinnedEndColumns,
5202
5372
  computedPinnedEndColumnsWidth,
5373
+ computedPinnedStartColumns,
5374
+ computedPinnedStartColumnsWidth,
5203
5375
  verticalVirtualBrain,
5376
+ computedPinnedEndWidth,
5377
+ computedPinnedEndOverflow,
5378
+ computedPinnedStartWidth,
5379
+ computedPinnedStartOverflow,
5380
+ pinnedStartScrollListener,
5381
+ pinnedEndScrollListener,
5204
5382
  repaintId,
5205
5383
  toggleGroupRow,
5206
5384
  scrollbars: {
@@ -5208,31 +5386,54 @@ function usePinnedEndRendering(params) {
5208
5386
  horizontal: hasHorizontalScrollbar
5209
5387
  }
5210
5388
  } = params;
5211
- const renderRowPinnedEnd = useRenderPinnedRow({
5389
+ const count = getData().length;
5390
+ const rowWidth = side === "start" ? computedPinnedStartColumnsWidth : computedPinnedEndColumnsWidth;
5391
+ const columns = side === "start" ? computedPinnedStartColumns : computedPinnedEndColumns;
5392
+ const columnsWidth = side === "start" ? computedPinnedStartColumnsWidth : computedPinnedEndColumnsWidth;
5393
+ const maxWidth = side === "start" ? computedPinnedStartWidth : computedPinnedEndWidth;
5394
+ const hasOverflow = side === "start" ? computedPinnedStartOverflow : computedPinnedEndOverflow;
5395
+ const pinnedScrollListener = side === "start" ? pinnedStartScrollListener : pinnedEndScrollListener;
5396
+ const renderRowPinned = useRenderPinnedRow({
5212
5397
  getData,
5213
5398
  getState,
5214
5399
  toggleGroupRow,
5215
- columns: computedPinnedEndColumns,
5216
- columnsWidth: computedPinnedEndColumnsWidth
5400
+ columns,
5401
+ columnsWidth
5217
5402
  });
5218
- const pinnedEndList = computedPinnedEndColumns.length && rowHeight !== 0 ? /* @__PURE__ */ createElement29(RowListWithExternalScrolling, {
5219
- repaintId: `${repaintId}-pin-end-${rowHeight}`,
5403
+ const pinnedList = columns.length && rowHeight !== 0 ? /* @__PURE__ */ createElement29(PinnedRowsContainer, {
5404
+ pinning: side,
5405
+ pinnedScrollListener,
5406
+ hasOverflow,
5407
+ rowHeight,
5408
+ rowWidth,
5409
+ maxWidth,
5410
+ height: bodySize.height,
5411
+ count,
5412
+ repaintId: `${repaintId}-pin-${side}-${rowHeight}`,
5220
5413
  brain: verticalVirtualBrain,
5221
- renderRow: renderRowPinnedEnd,
5222
- style: {
5223
- position: "absolute",
5224
- height: bodySize.height,
5225
- width: computedPinnedEndColumnsWidth,
5226
- right: 0
5227
- },
5228
- updateScroll: UPDATE_SCROLL3
5414
+ renderRow: renderRowPinned
5229
5415
  }) : null;
5230
- const pinnedEndScrollbarPlaceholder = pinnedEndList && hasHorizontalScrollbar ? /* @__PURE__ */ createElement29(HorizontalScrollbarPlaceholder, {
5231
- style: {
5232
- width: computedPinnedEndColumnsWidth,
5416
+ const pinnedScrollbarPlaceholder = pinnedList && hasHorizontalScrollbar && !hasOverflow ? /* @__PURE__ */ createElement29(HorizontalScrollbarPlaceholder, {
5417
+ style: side === "end" ? {
5418
+ width: columnsWidth,
5233
5419
  right: hasVerticalScrollbar ? getScrollbarWidth() : 0
5420
+ } : {
5421
+ width: columnsWidth,
5422
+ left: 0
5234
5423
  }
5235
5424
  }) : null;
5425
+ return {
5426
+ renderRowPinned,
5427
+ pinnedList,
5428
+ pinnedScrollbarPlaceholder
5429
+ };
5430
+ }
5431
+ function usePinnedEndRendering(params) {
5432
+ const {
5433
+ renderRowPinned: renderRowPinnedEnd,
5434
+ pinnedList: pinnedEndList,
5435
+ pinnedScrollbarPlaceholder: pinnedEndScrollbarPlaceholder
5436
+ } = usePinnedRenderingForSide("end", params);
5236
5437
  return {
5237
5438
  renderRowPinnedEnd,
5238
5439
  pinnedEndList,
@@ -5241,40 +5442,16 @@ function usePinnedEndRendering(params) {
5241
5442
  }
5242
5443
  function usePinnedStartRendering(params) {
5243
5444
  const {
5244
- getData,
5245
- getState,
5246
- rowHeight,
5247
- computedPinnedStartColumns,
5248
- computedPinnedStartColumnsWidth,
5249
- verticalVirtualBrain,
5250
- toggleGroupRow,
5251
- repaintId,
5252
- scrollbars: { horizontal: hasHorizontalScrollbar }
5253
- } = params;
5254
- const renderRowPinnedStart = useRenderPinnedRow({
5255
- getData,
5256
- getState,
5257
- toggleGroupRow,
5258
- columns: computedPinnedStartColumns,
5259
- columnsWidth: computedPinnedStartColumnsWidth
5260
- });
5261
- const pinnedStartList = computedPinnedStartColumns.length && rowHeight !== 0 ? /* @__PURE__ */ createElement29(RowListWithExternalScrolling, {
5262
- repaintId: `${repaintId}-pin-start-${rowHeight}`,
5263
- brain: verticalVirtualBrain,
5264
- renderRow: renderRowPinnedStart,
5265
- updateScroll: UPDATE_SCROLL3
5266
- }) : null;
5267
- const pinnedStartScrollbarPlaceholder = pinnedStartList && hasHorizontalScrollbar ? /* @__PURE__ */ createElement29(HorizontalScrollbarPlaceholder, {
5268
- style: {
5269
- width: computedPinnedStartColumnsWidth,
5270
- left: 0
5271
- }
5272
- }) : null;
5273
- return {
5445
+ renderRowPinned: renderRowPinnedStart,
5446
+ pinnedList: pinnedStartList,
5447
+ pinnedScrollbarPlaceholder: pinnedStartScrollbarPlaceholder
5448
+ } = usePinnedRenderingForSide("start", params);
5449
+ const result = {
5274
5450
  renderRowPinnedStart,
5275
5451
  pinnedStartList,
5276
5452
  pinnedStartScrollbarPlaceholder
5277
5453
  };
5454
+ return result;
5278
5455
  }
5279
5456
 
5280
5457
  // src/components/InfiniteTable/hooks/useYourBrain.ts
@@ -5282,7 +5459,7 @@ import { useEffect as useEffect18 } from "react";
5282
5459
 
5283
5460
  // src/components/VirtualBrain/index.ts
5284
5461
  var import_binary_search2 = __toModule(require_binary_search());
5285
- var initialScrollPosition = {
5462
+ var initialScrollPosition2 = {
5286
5463
  scrollLeft: 0,
5287
5464
  scrollTop: 0
5288
5465
  };
@@ -5291,7 +5468,7 @@ var SORT_ASC = (a, b) => a - b;
5291
5468
  var VirtualBrain = class extends Logger {
5292
5469
  constructor(options) {
5293
5470
  super(`VirtualBrain:${options.mainAxis}`);
5294
- this.scrollPosition = initialScrollPosition;
5471
+ this.scrollPosition = initialScrollPosition2;
5295
5472
  this.scrollPositionOnMainAxis = 0;
5296
5473
  this.totalSize = 0;
5297
5474
  this.onScrollFns = [];
@@ -5645,8 +5822,8 @@ function useYourBrain(param) {
5645
5822
  const {
5646
5823
  dataArray,
5647
5824
  computedUnpinnedColumns,
5648
- computedPinnedStartColumnsWidth,
5649
- computedPinnedEndColumnsWidth,
5825
+ computedPinnedStartWidth,
5826
+ computedPinnedEndWidth,
5650
5827
  rowHeight,
5651
5828
  bodySize
5652
5829
  } = param;
@@ -5679,13 +5856,9 @@ function useYourBrain(param) {
5679
5856
  useEffect18(() => {
5680
5857
  horizontalVirtualBrain.setAvailableSize({
5681
5858
  height: 0,
5682
- width: Math.max(bodySize.width - computedPinnedStartColumnsWidth - computedPinnedEndColumnsWidth, 0)
5859
+ width: Math.max(bodySize.width - computedPinnedStartWidth - computedPinnedEndWidth, 0)
5683
5860
  });
5684
- }, [
5685
- bodySize.width,
5686
- computedPinnedStartColumnsWidth,
5687
- computedPinnedEndColumnsWidth
5688
- ]);
5861
+ }, [bodySize.width, computedPinnedStartWidth, computedPinnedEndWidth]);
5689
5862
  return { horizontalVirtualBrain, verticalVirtualBrain };
5690
5863
  }
5691
5864
 
@@ -5722,13 +5895,23 @@ function useListRendering(param) {
5722
5895
  computedPinnedEndColumns,
5723
5896
  computedPinnedStartColumnsWidth,
5724
5897
  computedPinnedEndColumnsWidth,
5898
+ computedPinnedStartWidth,
5899
+ computedPinnedEndWidth,
5725
5900
  computedUnpinnedColumns,
5726
- computedUnpinnedColumnsWidth
5901
+ computedUnpinnedColumnsWidth,
5902
+ computedPinnedStartOverflow,
5903
+ computedPinnedEndOverflow
5727
5904
  } = computed;
5728
- const { componentState: dataSourceState } = useDataSourceContextValue();
5905
+ const { componentState: dataSourceState, getState: getDataSourceState } = useDataSourceContextValue();
5729
5906
  const { dataArray } = dataSourceState;
5730
5907
  const getData = useLatest(dataArray);
5731
- const { rowHeight } = componentState;
5908
+ const {
5909
+ rowHeightComputed: rowHeight,
5910
+ pinnedStartMaxWidth,
5911
+ pinnedEndMaxWidth,
5912
+ pinnedStartScrollListener,
5913
+ pinnedEndScrollListener
5914
+ } = componentState;
5732
5915
  const prevDataSourceTimestamp = usePrevious(dataSourceState.updatedAt);
5733
5916
  const repaintIdRef = useRef14(0);
5734
5917
  if (!shallowEqualObjects(prevComputed, computed) || prevDataSourceTimestamp !== dataSourceState.updatedAt) {
@@ -5736,9 +5919,9 @@ function useListRendering(param) {
5736
5919
  }
5737
5920
  const repaintId = repaintIdRef.current;
5738
5921
  const { horizontalVirtualBrain, verticalVirtualBrain } = useYourBrain({
5922
+ computedPinnedStartWidth: computed.computedPinnedStartWidth,
5923
+ computedPinnedEndWidth: computed.computedPinnedEndWidth,
5739
5924
  computedUnpinnedColumns: computed.computedUnpinnedColumns,
5740
- computedPinnedStartColumnsWidth: computed.computedPinnedStartColumnsWidth,
5741
- computedPinnedEndColumnsWidth: computed.computedPinnedEndColumnsWidth,
5742
5925
  rowHeight,
5743
5926
  dataArray,
5744
5927
  bodySize
@@ -5746,7 +5929,7 @@ function useListRendering(param) {
5746
5929
  const hasHorizontalScrollbar = computedUnpinnedColumnsWidth > bodySize.width - computedPinnedStartColumnsWidth - computedPinnedEndColumnsWidth;
5747
5930
  const reservedContentHeight = verticalVirtualBrain.getTotalSize() + (hasHorizontalScrollbar ? getScrollbarWidth() : 0);
5748
5931
  const hasVerticalScrollbar = bodySize.height < reservedContentHeight;
5749
- const scrollbars = useMemo8(() => ({
5932
+ const scrollbars = useMemo9(() => ({
5750
5933
  vertical: hasVerticalScrollbar,
5751
5934
  horizontal: hasHorizontalScrollbar
5752
5935
  }), [hasVerticalScrollbar, hasHorizontalScrollbar]);
@@ -5763,7 +5946,9 @@ function useListRendering(param) {
5763
5946
  setColumnVisibility: (columnVisibility) => {
5764
5947
  componentActions.columnVisibility = columnVisibility;
5765
5948
  },
5766
- setColumnAggregations: (columnAggregations) => componentActions.columnAggregations = columnAggregations
5949
+ setColumnAggregations: (columnAggregations) => componentActions.columnAggregations = columnAggregations,
5950
+ getState,
5951
+ getDataSourceState
5767
5952
  };
5768
5953
  onReady(imperativeApi);
5769
5954
  }
@@ -5773,7 +5958,7 @@ function useListRendering(param) {
5773
5958
  horizontalVirtualBrain,
5774
5959
  domRef
5775
5960
  });
5776
- const { getState: getDataSourceState, componentActions: dataSourceActions } = useDataSourceContextValue();
5961
+ const { componentActions: dataSourceActions } = useDataSourceContextValue();
5777
5962
  const toggleGroupRow = useCallback17((groupKeys) => {
5778
5963
  const newState = new GroupRowsState(getDataSourceState().groupRowsState);
5779
5964
  newState.toggleGroupRow(groupKeys);
@@ -5784,14 +5969,22 @@ function useListRendering(param) {
5784
5969
  scrollbars,
5785
5970
  computedPinnedStartColumns,
5786
5971
  computedPinnedEndColumns,
5972
+ computedPinnedStartWidth,
5973
+ computedPinnedEndWidth,
5974
+ computedPinnedStartOverflow,
5975
+ computedPinnedEndOverflow,
5787
5976
  computedPinnedStartColumnsWidth,
5788
5977
  computedPinnedEndColumnsWidth,
5789
5978
  getData,
5790
5979
  getState,
5791
5980
  toggleGroupRow,
5981
+ pinnedStartMaxWidth,
5982
+ pinnedEndMaxWidth,
5792
5983
  repaintId,
5793
5984
  rowHeight,
5794
- verticalVirtualBrain
5985
+ verticalVirtualBrain,
5986
+ pinnedStartScrollListener,
5987
+ pinnedEndScrollListener
5795
5988
  };
5796
5989
  const centerRenderingParams = __spreadProps(__spreadValues({}, pinnedRenderingParams), {
5797
5990
  columnShifts,
@@ -5908,7 +6101,7 @@ var InfiniteTableLicenseFooter = forwardRef3(function InfiniteTableLicenseFooter
5908
6101
  });
5909
6102
 
5910
6103
  // src/components/InfiniteTable/hooks/useLicense/useLicense.ts
5911
- import { useMemo as useMemo9 } from "react";
6104
+ import { useMemo as useMemo10 } from "react";
5912
6105
 
5913
6106
  // src/components/InfiniteTable/hooks/useLicense/crc32.ts
5914
6107
  var DEFAULT_ReversedPolynomial = 3988292384;
@@ -6054,10 +6247,10 @@ var decode = (licenseKey) => {
6054
6247
 
6055
6248
  // src/components/InfiniteTable/hooks/useLicense/useLicense.ts
6056
6249
  var useLicense = (licenseKey) => {
6057
- const valid = useMemo9(() => {
6250
+ const valid = useMemo10(() => {
6058
6251
  return isValidLicense(licenseKey, {
6059
6252
  publishedAt: 1624970570587,
6060
- version: "0.0.1-canary.9"
6253
+ version: "0.0.2-canary.2"
6061
6254
  });
6062
6255
  }, [licenseKey]);
6063
6256
  return valid;
@@ -6147,7 +6340,6 @@ var InfiniteTableComponent = memo12(function InfiniteTableComponent2() {
6147
6340
  headerHeightCSSVar
6148
6341
  } = componentState;
6149
6342
  const { columnShifts, bodySize } = componentState;
6150
- const className = join(InfiniteTableClassName, columnShifts ? `${InfiniteTableClassName}--shifting` : "", domProps == null ? void 0 : domProps.className);
6151
6343
  const {
6152
6344
  pinnedStartList,
6153
6345
  pinnedEndList,
@@ -6167,6 +6359,7 @@ var InfiniteTableComponent = memo12(function InfiniteTableComponent2() {
6167
6359
  computed
6168
6360
  });
6169
6361
  const licenseValid = useLicense(licenseKey);
6362
+ 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);
6170
6363
  return /* @__PURE__ */ createElement32("div", __spreadProps(__spreadValues({
6171
6364
  ref: domRef
6172
6365
  }, domProps), {
@@ -6202,7 +6395,10 @@ function InfiniteTableContextProvider() {
6202
6395
  const computed = useComputed();
6203
6396
  const getComputed = useLatest(computed);
6204
6397
  const getState = useLatest(componentState);
6205
- globalThis.getState = getState;
6398
+ if (false) {
6399
+ globalThis.getState = getState;
6400
+ globalThis.getComputed = getComputed;
6401
+ }
6206
6402
  const contextValue = {
6207
6403
  componentActions,
6208
6404
  componentState,
@@ -6251,6 +6447,9 @@ export {
6251
6447
  InfiniteTableClassName,
6252
6448
  InfiniteTableComponent,
6253
6449
  flatten,
6450
+ getComponentStateRoot,
6254
6451
  group,
6452
+ interceptMap,
6453
+ useComponentState,
6255
6454
  useDataSource
6256
6455
  };