@infinite-table/infinite-react 8.0.1 → 8.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.dev.js CHANGED
@@ -68,6 +68,7 @@ var require_binary_search = __commonJS({
68
68
  // src/index.tsx
69
69
  var index_exports = {};
70
70
  __export(index_exports, {
71
+ AutoScroller: () => AutoScroller,
71
72
  CellSelectionState: () => CellSelectionState,
72
73
  DRAG_ITEM_ATTRIBUTE: () => DRAG_ITEM_ATTRIBUTE,
73
74
  DataClient: () => DataClient,
@@ -96,9 +97,11 @@ __export(index_exports, {
96
97
  WeakFixedSizeSet: () => WeakFixedSizeSet,
97
98
  alignNode: () => alignNode,
98
99
  components: () => components,
100
+ createDefaultProxy: () => createDefaultProxy,
99
101
  createFlashingColumnCellComponent: () => createFlashingColumnCellComponent,
100
102
  debounce: () => debounce,
101
103
  debug: () => debug,
104
+ defaultDragProxyMove: () => defaultDragProxyMove,
102
105
  defaultFilterTypes: () => defaultFilterTypes2,
103
106
  eventMatchesKeyboardShortcut: () => eventMatchesKeyboardShortcut,
104
107
  filterDataArray: () => filterDataArray,
@@ -2123,7 +2126,7 @@ function InfiniteTableFooter(props) {
2123
2126
  // src/components/InfiniteTable/components/InfiniteTableHeader/InfiniteTableHeaderCell.tsx
2124
2127
  var React51 = __toESM(require("react"));
2125
2128
  var import_react36 = require("react");
2126
- var import_react_dom = require("react-dom");
2129
+ var import_react_dom2 = require("react-dom");
2127
2130
 
2128
2131
  // src/utils/keyMirror.ts
2129
2132
  function keyMirror(obj) {
@@ -3926,6 +3929,7 @@ function useCellClassName(column, baseClasses, variants, extraFlags) {
3926
3929
 
3927
3930
  // src/components/InfiniteTable/hooks/useColumnPointerEvents.ts
3928
3931
  var import_react15 = require("react");
3932
+ var import_react_dom = require("react-dom");
3929
3933
 
3930
3934
  // src/utils/selectParent.ts
3931
3935
  function selectParent(el, selector2) {
@@ -5434,7 +5438,7 @@ var handleOutsideOperation = (operation, interactionTarget) => {
5434
5438
  if (inside) {
5435
5439
  return { left: 0, top: 0 };
5436
5440
  }
5437
- if (index > dragIndex) {
5441
+ if (index > dragIndex && !interactionTarget.getData().preserveDragSpace) {
5438
5442
  return orientation === "horizontal" ? { left: -dragItem.rect.width, top: 0 } : { left: 0, top: -dragItem.rect.height };
5439
5443
  }
5440
5444
  return { left: 0, top: 0 };
@@ -5463,12 +5467,24 @@ var _DragManager = class _DragManager {
5463
5467
  activeDragSource,
5464
5468
  startPoint
5465
5469
  });
5470
+ _DragManager.currentDragOperation = dragOperation;
5466
5471
  dragOperation.on("start", _DragManager.onDragStart);
5467
5472
  dragOperation.on("move", _DragManager.onDragMove);
5468
5473
  dragOperation.on("drop", _DragManager.onDragDrop);
5469
5474
  dragOperation.start();
5470
5475
  return dragOperation;
5471
5476
  }
5477
+ /**
5478
+ * Re-evaluates the current drag position against all interaction targets.
5479
+ * Used when a target list scrolls and its breakpoints change, requiring
5480
+ * the drop index to be recalculated without a new pointer move.
5481
+ */
5482
+ static retriggerMove() {
5483
+ const op = _DragManager.currentDragOperation;
5484
+ if (op && op.phase === "move") {
5485
+ _DragManager.onDragMove(op);
5486
+ }
5487
+ }
5472
5488
  static emit(event, ...params) {
5473
5489
  _DragManager.emitter.emit(event, ...params);
5474
5490
  }
@@ -5619,11 +5635,13 @@ var _DragManager = class _DragManager {
5619
5635
  dragIndex: event?.dragIndex ?? -1,
5620
5636
  dropIndex: event?.dropIndex ?? -1
5621
5637
  });
5638
+ _DragManager.currentDragOperation = null;
5622
5639
  _DragManager.unregisterAll();
5623
5640
  }
5624
5641
  };
5625
5642
  // public static dragInteractionTargets: DragInteractionTarget[] = [];
5626
5643
  _DragManager.dragInteractionTargetsMap = /* @__PURE__ */ new Map();
5644
+ _DragManager.currentDragOperation = null;
5627
5645
  _DragManager.emitter = new EventEmitter();
5628
5646
  var DragManager = _DragManager;
5629
5647
  var ActiveDragSource = class _ActiveDragSource {
@@ -5942,13 +5960,6 @@ var useColumnPointerEvents = ({
5942
5960
  }
5943
5961
  const currentComputedColumnOrder = getComputed().computedColumnOrder;
5944
5962
  if (JSON.stringify(columnOrder, currentComputedColumnOrder)) {
5945
- computedVisibleColumns.forEach((col) => {
5946
- setInfiniteColumnOffsetWhileReordering(
5947
- col.computedVisibleIndex,
5948
- "",
5949
- rootRef.current
5950
- );
5951
- });
5952
5963
  actions.columnOrder = adjustColumnOrderForAllColumns({
5953
5964
  newColumnOrder: columnOrder,
5954
5965
  visibleColumnOrder: getComputed().computedVisibleColumns.map(
@@ -6009,27 +6020,48 @@ var useColumnPointerEvents = ({
6009
6020
  requestAnimationFrame(() => {
6010
6021
  const { multiSortBehavior } = getState();
6011
6022
  const target2 = domRef.current;
6012
- rootRef.current?.classList.remove(InfiniteClsShiftingColumns);
6023
+ const rootNode = rootRef.current;
6024
+ rootNode?.classList.remove(InfiniteClsShiftingColumns);
6013
6025
  dragger.stop();
6014
6026
  brain.update({
6015
6027
  ...initialAvailableSize
6016
6028
  });
6017
6029
  discardAlwaysRenderedColumn?.();
6018
6030
  restoreRenderRange?.();
6031
+ target2.style.cursor = initialCursor;
6032
+ target2.releasePointerCapture(pointerId);
6033
+ target2.removeEventListener("pointermove", onPointerMove);
6034
+ target2.removeEventListener("pointerup", onPointerUp);
6035
+ setProxyPosition(null);
6036
+ const dragColumnSortable = api.getColumnApi(dragColumn.id)?.isSortable() ?? false;
6037
+ if (!didDragAtLeastOnce && dragColumnSortable) {
6038
+ api.toggleSortingForColumn(dragColumn.id, {
6039
+ multiSortBehavior: multiSortBehavior === "replace" && (e2.ctrlKey || e2.metaKey) ? "append" : multiSortBehavior
6040
+ });
6041
+ }
6042
+ (0, import_react_dom.flushSync)(() => {
6043
+ if (reorderDragResult) {
6044
+ persistColumnOrder(reorderDragResult);
6045
+ } else if (didDragAtLeastOnce) {
6046
+ if (allowColumnHideOnDrag) {
6047
+ api.setVisibilityForColumn(dragColumn.id, false);
6048
+ }
6049
+ }
6050
+ actions.columnReorderDragColumnId = false;
6051
+ if (horizontalLayoutPageIndex != null) {
6052
+ actions.columnReorderInPageIndex = null;
6053
+ }
6054
+ });
6019
6055
  computedVisibleColumns.forEach((col) => {
6020
6056
  clearInfiniteColumnReorderDuration(
6021
6057
  col.computedVisibleIndex,
6022
- rootRef.current
6023
- );
6024
- setInfiniteColumnVisibility(
6025
- col.computedVisibleIndex,
6026
- "",
6027
- rootRef.current
6058
+ rootNode
6028
6059
  );
6060
+ setInfiniteColumnVisibility(col.computedVisibleIndex, "", rootNode);
6029
6061
  setInfiniteColumnOffsetWhileReordering(
6030
6062
  col.computedVisibleIndex,
6031
6063
  "",
6032
- rootRef.current
6064
+ rootNode
6033
6065
  );
6034
6066
  });
6035
6067
  setInfiniteColumnZIndex(
@@ -6038,30 +6070,8 @@ var useColumnPointerEvents = ({
6038
6070
  pinnedStartColsCount: computedPinnedStartColumns.length,
6039
6071
  visibleColsCount: computedVisibleColumns.length
6040
6072
  }),
6041
- rootRef.current
6073
+ rootNode
6042
6074
  );
6043
- target2.style.cursor = initialCursor;
6044
- target2.releasePointerCapture(pointerId);
6045
- target2.removeEventListener("pointermove", onPointerMove);
6046
- target2.removeEventListener("pointerup", onPointerUp);
6047
- setProxyPosition(null);
6048
- const dragColumnSortable = api.getColumnApi(dragColumn.id)?.isSortable() ?? false;
6049
- if (!didDragAtLeastOnce && dragColumnSortable) {
6050
- api.toggleSortingForColumn(dragColumn.id, {
6051
- multiSortBehavior: multiSortBehavior === "replace" && (e2.ctrlKey || e2.metaKey) ? "append" : multiSortBehavior
6052
- });
6053
- }
6054
- if (reorderDragResult) {
6055
- persistColumnOrder(reorderDragResult);
6056
- } else if (didDragAtLeastOnce) {
6057
- if (allowColumnHideOnDrag) {
6058
- api.setVisibilityForColumn(dragColumn.id, false);
6059
- }
6060
- }
6061
- actions.columnReorderDragColumnId = false;
6062
- if (horizontalLayoutPageIndex != null) {
6063
- actions.columnReorderInPageIndex = null;
6064
- }
6065
6075
  });
6066
6076
  };
6067
6077
  target.addEventListener("pointermove", onPointerMove);
@@ -8253,6 +8263,20 @@ var DragInteractionTarget = class extends EventEmitter {
8253
8263
  }
8254
8264
  return result;
8255
8265
  }
8266
+ /**
8267
+ * Adjusts breakpoints and listRectangle to compensate for container scroll.
8268
+ * When the container scrolls by `scrollDelta`, items shift in the viewport
8269
+ * but the pointer (in the source-adjusted coordinate space) doesn't change.
8270
+ * Shifting breakpoints keeps the drop index calculation correct.
8271
+ */
8272
+ adjustForScroll(scrollDelta) {
8273
+ this.breakpoints = this.breakpoints.map((bp) => bp - scrollDelta);
8274
+ if (this.data.orientation === "vertical") {
8275
+ this.data.listRectangle.shift({ top: -scrollDelta, left: 0 });
8276
+ } else {
8277
+ this.data.listRectangle.shift({ top: 0, left: -scrollDelta });
8278
+ }
8279
+ }
8256
8280
  move(params) {
8257
8281
  this.emit("move", params);
8258
8282
  }
@@ -8308,6 +8332,217 @@ var DragInteractionTarget = class extends EventEmitter {
8308
8332
  }
8309
8333
  };
8310
8334
 
8335
+ // src/components/InfiniteTable/components/draggable/AutoScroller.ts
8336
+ var defaultAutoScrollerConfig = {
8337
+ startFromPercentage: 0.25,
8338
+ maxScrollAtPercentage: 0.05,
8339
+ maxPixelScroll: 28,
8340
+ ease: (pct) => pct ** 2,
8341
+ durationDampening: {
8342
+ stopDampeningAt: 1200,
8343
+ accelerateAt: 360
8344
+ }
8345
+ };
8346
+ function isScrollable(element, orientation) {
8347
+ const style2 = getComputedStyle(element);
8348
+ const overflowProp = orientation === "vertical" ? style2.overflowY : style2.overflowX;
8349
+ if (overflowProp !== "auto" && overflowProp !== "scroll") {
8350
+ return false;
8351
+ }
8352
+ return orientation === "vertical" ? element.scrollHeight > element.clientHeight : element.scrollWidth > element.clientWidth;
8353
+ }
8354
+ function findScrollableAncestor(element, orientation) {
8355
+ let current = element;
8356
+ while (current) {
8357
+ if (current === document.documentElement || current === document.body) {
8358
+ break;
8359
+ }
8360
+ if (isScrollable(current, orientation)) {
8361
+ return current;
8362
+ }
8363
+ current = current.parentElement;
8364
+ }
8365
+ return null;
8366
+ }
8367
+ function getThresholds(containerSize, config) {
8368
+ return {
8369
+ startScrollingFrom: containerSize * config.startFromPercentage,
8370
+ maxScrollValueAt: containerSize * config.maxScrollAtPercentage
8371
+ };
8372
+ }
8373
+ var MIN_SCROLL = 1;
8374
+ function getValueFromDistance(distanceToEdge, thresholds, config) {
8375
+ if (distanceToEdge > thresholds.startScrollingFrom) {
8376
+ return 0;
8377
+ }
8378
+ if (distanceToEdge <= thresholds.maxScrollValueAt) {
8379
+ return config.maxPixelScroll;
8380
+ }
8381
+ if (distanceToEdge === thresholds.startScrollingFrom) {
8382
+ return MIN_SCROLL;
8383
+ }
8384
+ const percentFromMax = (distanceToEdge - thresholds.maxScrollValueAt) / (thresholds.startScrollingFrom - thresholds.maxScrollValueAt);
8385
+ const percentFromStart = 1 - percentFromMax;
8386
+ return Math.ceil(config.maxPixelScroll * config.ease(percentFromStart));
8387
+ }
8388
+ function dampenByTime(proposedScroll, dragStartTime, config) {
8389
+ const { accelerateAt, stopDampeningAt } = config.durationDampening;
8390
+ const runTime = Date.now() - dragStartTime;
8391
+ if (runTime >= stopDampeningAt) {
8392
+ return proposedScroll;
8393
+ }
8394
+ if (runTime < accelerateAt) {
8395
+ return MIN_SCROLL;
8396
+ }
8397
+ const pct = (runTime - accelerateAt) / (stopDampeningAt - accelerateAt);
8398
+ return Math.ceil(proposedScroll * config.ease(pct));
8399
+ }
8400
+ function getScrollForAxis(point, containerStart, containerEnd, containerSize, config, dragStartTime, shouldUseDampening) {
8401
+ if (point < containerStart || point > containerEnd) {
8402
+ return 0;
8403
+ }
8404
+ const thresholds = getThresholds(containerSize, config);
8405
+ const distToStart = point - containerStart;
8406
+ const distToEnd = containerEnd - point;
8407
+ const closerToEnd = distToEnd < distToStart;
8408
+ let value;
8409
+ if (closerToEnd) {
8410
+ value = getValueFromDistance(distToEnd, thresholds, config);
8411
+ } else {
8412
+ value = -getValueFromDistance(distToStart, thresholds, config);
8413
+ }
8414
+ if (value === 0) {
8415
+ return 0;
8416
+ }
8417
+ if (shouldUseDampening) {
8418
+ const sign = value > 0 ? 1 : -1;
8419
+ return sign * dampenByTime(Math.abs(value), dragStartTime, config);
8420
+ }
8421
+ return value;
8422
+ }
8423
+ var AutoScroller = class {
8424
+ constructor(options) {
8425
+ this.scrollContainer = null;
8426
+ this.rafId = null;
8427
+ this.lastPointer = { left: 0, top: 0 };
8428
+ this.dragStartTime = 0;
8429
+ this.shouldUseDampening = false;
8430
+ this.active = false;
8431
+ // captured at drag start before transforms inflate scrollHeight
8432
+ this.maxScrollTop = 0;
8433
+ this.maxScrollLeft = 0;
8434
+ this.orientation = options.orientation;
8435
+ this.onScroll = options.onScroll;
8436
+ this.config = { ...defaultAutoScrollerConfig, ...options.config };
8437
+ }
8438
+ start(listElement) {
8439
+ this.scrollContainer = findScrollableAncestor(
8440
+ listElement,
8441
+ this.orientation
8442
+ );
8443
+ if (this.scrollContainer) {
8444
+ this.maxScrollTop = this.scrollContainer.scrollHeight - this.scrollContainer.clientHeight;
8445
+ this.maxScrollLeft = this.scrollContainer.scrollWidth - this.scrollContainer.clientWidth;
8446
+ }
8447
+ this.dragStartTime = Date.now();
8448
+ this.shouldUseDampening = true;
8449
+ this.active = true;
8450
+ }
8451
+ getScrollContainer() {
8452
+ return this.scrollContainer;
8453
+ }
8454
+ updatePointer(point) {
8455
+ this.lastPointer = point;
8456
+ if (!this.rafId && this.active) {
8457
+ this.scheduleScroll();
8458
+ }
8459
+ }
8460
+ scheduleScroll() {
8461
+ this.rafId = requestAnimationFrame(() => {
8462
+ this.rafId = null;
8463
+ if (!this.active || !this.scrollContainer) {
8464
+ return;
8465
+ }
8466
+ const delta = this.computeScroll();
8467
+ if (delta.top === 0 && delta.left === 0) {
8468
+ return;
8469
+ }
8470
+ const scrollBefore = {
8471
+ top: this.scrollContainer.scrollTop,
8472
+ left: this.scrollContainer.scrollLeft
8473
+ };
8474
+ const clampedTop = Math.max(
8475
+ 0,
8476
+ Math.min(this.maxScrollTop, scrollBefore.top + delta.top)
8477
+ );
8478
+ const clampedLeft = Math.max(
8479
+ 0,
8480
+ Math.min(this.maxScrollLeft, scrollBefore.left + delta.left)
8481
+ );
8482
+ this.scrollContainer.scrollTop = clampedTop;
8483
+ this.scrollContainer.scrollLeft = clampedLeft;
8484
+ const actualDelta = {
8485
+ top: this.scrollContainer.scrollTop - scrollBefore.top,
8486
+ left: this.scrollContainer.scrollLeft - scrollBefore.left
8487
+ };
8488
+ const didScroll = actualDelta.top !== 0 || actualDelta.left !== 0;
8489
+ if (didScroll) {
8490
+ this.onScroll(actualDelta);
8491
+ }
8492
+ if (this.active && didScroll) {
8493
+ this.scheduleScroll();
8494
+ }
8495
+ });
8496
+ }
8497
+ computeScroll() {
8498
+ if (!this.scrollContainer) {
8499
+ return { top: 0, left: 0 };
8500
+ }
8501
+ const rect = this.scrollContainer.getBoundingClientRect();
8502
+ if (this.orientation === "vertical") {
8503
+ if (this.lastPointer.left < rect.left || this.lastPointer.left > rect.right) {
8504
+ return { top: 0, left: 0 };
8505
+ }
8506
+ } else {
8507
+ if (this.lastPointer.top < rect.top || this.lastPointer.top > rect.bottom) {
8508
+ return { top: 0, left: 0 };
8509
+ }
8510
+ }
8511
+ let scrollTop2 = 0;
8512
+ let scrollLeft2 = 0;
8513
+ if (this.orientation === "vertical") {
8514
+ scrollTop2 = getScrollForAxis(
8515
+ this.lastPointer.top,
8516
+ rect.top,
8517
+ rect.bottom,
8518
+ rect.height,
8519
+ this.config,
8520
+ this.dragStartTime,
8521
+ this.shouldUseDampening
8522
+ );
8523
+ } else {
8524
+ scrollLeft2 = getScrollForAxis(
8525
+ this.lastPointer.left,
8526
+ rect.left,
8527
+ rect.right,
8528
+ rect.width,
8529
+ this.config,
8530
+ this.dragStartTime,
8531
+ this.shouldUseDampening
8532
+ );
8533
+ }
8534
+ return { top: scrollTop2, left: scrollLeft2 };
8535
+ }
8536
+ stop() {
8537
+ this.active = false;
8538
+ if (this.rafId != null) {
8539
+ cancelAnimationFrame(this.rafId);
8540
+ this.rafId = null;
8541
+ }
8542
+ this.scrollContainer = null;
8543
+ }
8544
+ };
8545
+
8311
8546
  // src/components/InfiniteTable/components/draggable/DragList.tsx
8312
8547
  var DragListContext = React33.createContext({
8313
8548
  dragItemId: null,
@@ -8349,15 +8584,34 @@ function getDraggableItems(domRef) {
8349
8584
  }
8350
8585
  function getInteractionTargetData(params) {
8351
8586
  const { domRef, orientation, dragListId } = params;
8352
- const listRectangle = Rectangle.from(domRef.current.getBoundingClientRect());
8587
+ const draggableItems = getDraggableItems(domRef);
8588
+ const domRect = domRef.current.getBoundingClientRect();
8589
+ let top2 = domRect.top;
8590
+ let left2 = domRect.left;
8591
+ let bottom = domRect.bottom;
8592
+ let right = domRect.right;
8593
+ for (const item of draggableItems) {
8594
+ const r = item.rect;
8595
+ if (r.top < top2) top2 = r.top;
8596
+ if (r.left < left2) left2 = r.left;
8597
+ if (r.bottom > bottom) bottom = r.bottom;
8598
+ if (r.right > right) right = r.right;
8599
+ }
8600
+ const listRectangle = Rectangle.from({
8601
+ top: top2,
8602
+ left: left2,
8603
+ width: right - left2,
8604
+ height: bottom - top2
8605
+ });
8353
8606
  const options = {
8354
- draggableItems: getDraggableItems(domRef),
8607
+ draggableItems,
8355
8608
  orientation,
8356
8609
  listId: dragListId,
8357
8610
  listRectangle,
8358
8611
  acceptDropsFrom: params.acceptDropsFrom,
8359
8612
  shouldAcceptDrop: params.shouldAcceptDrop,
8360
- initial: params.initial
8613
+ initial: params.initial,
8614
+ preserveDragSpace: params.preserveDragSpace
8361
8615
  };
8362
8616
  return options;
8363
8617
  }
@@ -8415,8 +8669,49 @@ function useInteractionTarget(domRef, props) {
8415
8669
  getInteractionTarget
8416
8670
  };
8417
8671
  }
8672
+ function createDefaultProxy(dragItemNode, initialRect) {
8673
+ const proxy = dragItemNode.cloneNode(true);
8674
+ proxy.removeAttribute(DRAG_ITEM_ATTRIBUTE);
8675
+ proxy.style.position = "fixed";
8676
+ proxy.style.top = `${initialRect.top}px`;
8677
+ proxy.style.left = `${initialRect.left}px`;
8678
+ proxy.style.width = `${initialRect.width}px`;
8679
+ proxy.style.height = `${initialRect.height}px`;
8680
+ proxy.style.zIndex = "999999";
8681
+ proxy.style.pointerEvents = "none";
8682
+ proxy.style.margin = "0";
8683
+ proxy.style.boxSizing = "border-box";
8684
+ proxy.style.transform = "none";
8685
+ document.body.appendChild(proxy);
8686
+ return proxy;
8687
+ }
8688
+ function defaultDragProxyMove({
8689
+ proxyElement,
8690
+ dx,
8691
+ dy
8692
+ }) {
8693
+ proxyElement.style.transform = `translate3d(${dx}px, ${dy}px, 0)`;
8694
+ }
8695
+ function cleanupProxy(proxyStateRef) {
8696
+ const state = proxyStateRef.current;
8697
+ if (!state) return;
8698
+ if (state.cleanup) {
8699
+ state.cleanup({ proxyElement: state.proxyElement });
8700
+ } else {
8701
+ state.proxyElement.remove();
8702
+ }
8703
+ state.originalNode.style.visibility = "";
8704
+ proxyStateRef.current = null;
8705
+ }
8418
8706
  var DragList = (props) => {
8419
8707
  const domRef = React33.useRef(null);
8708
+ const proxyStateRef = React33.useRef(null);
8709
+ const [dragProxyRenderState, setDragProxyRenderState] = (0, import_react23.useState)(null);
8710
+ const sourceScrollOffsetRef = React33.useRef({ top: 0, left: 0 });
8711
+ const proxyPortalNodeRef = React33.useRef(null);
8712
+ const proxyRefCallback = React33.useCallback((node) => {
8713
+ proxyPortalNodeRef.current = node;
8714
+ }, []);
8420
8715
  const { dropTargetListId, dragSourceListId } = useDragDropProvider();
8421
8716
  const { updateDragOperationSourceAndTarget, dragItemId, status } = useDragDropProvider();
8422
8717
  const getOnDrop = useLatest(props.onDrop);
@@ -8457,18 +8752,29 @@ var DragList = (props) => {
8457
8752
  );
8458
8753
  const removeOnDragMove = interactionTarget.on(
8459
8754
  "move",
8460
- ({ offsetsForItems, items, status: status2 }) => {
8755
+ ({ offsetsForItems, items, status: status2, dragItem }) => {
8461
8756
  if (status2 === "rejected") {
8462
8757
  return;
8463
8758
  }
8464
8759
  const dragItems = getDragItems();
8465
8760
  const updatePosition = getUpdatePosition();
8761
+ const proxyState = proxyStateRef.current;
8466
8762
  items.forEach((item, index) => {
8467
- const offset = offsetsForItems[index];
8763
+ let offset = offsetsForItems[index];
8468
8764
  const node = dragItems[index];
8469
8765
  if (!node) {
8470
8766
  return;
8471
8767
  }
8768
+ if (proxyState && item.id === proxyState.dragItemId) {
8769
+ return;
8770
+ }
8771
+ if (!proxyState && item.id === dragItem.id) {
8772
+ const scrollOffset = sourceScrollOffsetRef.current;
8773
+ offset = {
8774
+ left: offset.left + scrollOffset.left,
8775
+ top: offset.top + scrollOffset.top
8776
+ };
8777
+ }
8472
8778
  updatePosition({
8473
8779
  id: item.id,
8474
8780
  node,
@@ -8506,6 +8812,12 @@ var DragList = (props) => {
8506
8812
  offset: null
8507
8813
  });
8508
8814
  });
8815
+ cleanupProxy(proxyStateRef);
8816
+ setDragProxyRenderState((prev) => {
8817
+ if (!prev) return prev;
8818
+ requestAnimationFrame(() => setDragProxyRenderState(null));
8819
+ return { ...prev, dragItemId: null };
8820
+ });
8509
8821
  const accepted = status2 === "accepted";
8510
8822
  if (dragListId === dropTargetListId2 && dragSourceListId2 !== dragListId) {
8511
8823
  if (onAcceptDrop && accepted) {
@@ -8535,10 +8847,58 @@ var DragList = (props) => {
8535
8847
  });
8536
8848
  }
8537
8849
  });
8850
+ let targetAutoScroller = null;
8851
+ let targetScrollContainer = null;
8852
+ let targetScrollHandler = null;
8853
+ let targetPointermoveHandler = null;
8854
+ if (!interactionTarget.getData().initial && domRef.current) {
8855
+ targetAutoScroller = new AutoScroller({
8856
+ orientation: props.orientation,
8857
+ onScroll: () => {
8858
+ }
8859
+ });
8860
+ targetAutoScroller.start(domRef.current);
8861
+ targetScrollContainer = targetAutoScroller.getScrollContainer();
8862
+ if (targetScrollContainer) {
8863
+ let lastScroll = props.orientation === "vertical" ? targetScrollContainer.scrollTop : targetScrollContainer.scrollLeft;
8864
+ targetScrollHandler = () => {
8865
+ const current = props.orientation === "vertical" ? targetScrollContainer.scrollTop : targetScrollContainer.scrollLeft;
8866
+ const delta = current - lastScroll;
8867
+ lastScroll = current;
8868
+ if (delta !== 0) {
8869
+ interactionTarget.adjustForScroll(delta);
8870
+ DragManager.retriggerMove();
8871
+ }
8872
+ };
8873
+ targetScrollContainer.addEventListener("scroll", targetScrollHandler);
8874
+ }
8875
+ targetPointermoveHandler = (e) => {
8876
+ targetAutoScroller.updatePointer({
8877
+ left: e.clientX,
8878
+ top: e.clientY
8879
+ });
8880
+ };
8881
+ getGlobal().addEventListener("pointermove", targetPointermoveHandler);
8882
+ }
8538
8883
  return () => {
8539
8884
  removeOnDragStart();
8540
8885
  removeOnDragMove();
8541
8886
  removeOnDragDrop();
8887
+ if (targetAutoScroller) {
8888
+ targetAutoScroller.stop();
8889
+ }
8890
+ if (targetScrollContainer && targetScrollHandler) {
8891
+ targetScrollContainer.removeEventListener(
8892
+ "scroll",
8893
+ targetScrollHandler
8894
+ );
8895
+ }
8896
+ if (targetPointermoveHandler) {
8897
+ getGlobal().removeEventListener(
8898
+ "pointermove",
8899
+ targetPointermoveHandler
8900
+ );
8901
+ }
8542
8902
  };
8543
8903
  }
8544
8904
  return void 0;
@@ -8583,19 +8943,63 @@ var DragList = (props) => {
8583
8943
  orientation: props.orientation,
8584
8944
  dragListId: props.dragListId,
8585
8945
  acceptDropsFrom: props.acceptDropsFrom,
8586
- initial: true
8946
+ initial: true,
8947
+ preserveDragSpace: props.preserveDragSpace
8587
8948
  });
8588
8949
  const draggableItems = interactionTarget2.getData().draggableItems;
8589
8950
  const dragIndex = draggableItems.findIndex(
8590
8951
  (item) => item.id === dragItemId2
8591
8952
  );
8592
8953
  const dragItem = draggableItems[dragIndex];
8954
+ const dragItemNode = dragItems[dragIndex].getAttribute(DRAG_ITEM_ATTRIBUTE) === `${dragItemId2}` ? dragItems[dragIndex] : dragItems.find(
8955
+ (node) => node.getAttribute(DRAG_ITEM_ATTRIBUTE) === `${dragItemId2}`
8956
+ );
8593
8957
  setInteractionTarget(interactionTarget2);
8594
8958
  const initialCoords = {
8595
8959
  left: e.clientX,
8596
8960
  top: e.clientY
8597
8961
  };
8962
+ let lastPointer = { left: e.clientX, top: e.clientY };
8963
+ sourceScrollOffsetRef.current = { top: 0, left: 0 };
8964
+ const autoScroller = new AutoScroller({
8965
+ orientation: props.orientation,
8966
+ onScroll: () => {
8967
+ }
8968
+ });
8969
+ if (domRef.current) {
8970
+ autoScroller.start(domRef.current);
8971
+ }
8972
+ const scrollContainer = autoScroller.getScrollContainer();
8973
+ let lastSourceScroll = scrollContainer ? props.orientation === "vertical" ? scrollContainer.scrollTop : scrollContainer.scrollLeft : 0;
8974
+ function fireDragMove() {
8975
+ if (!dragOperation) return;
8976
+ dragOperation.move({
8977
+ left: lastPointer.left,
8978
+ top: lastPointer.top
8979
+ });
8980
+ }
8981
+ const onContainerScroll = () => {
8982
+ if (!scrollContainer) return;
8983
+ const current = props.orientation === "vertical" ? scrollContainer.scrollTop : scrollContainer.scrollLeft;
8984
+ const delta = current - lastSourceScroll;
8985
+ lastSourceScroll = current;
8986
+ if (delta !== 0) {
8987
+ interactionTarget2.adjustForScroll(delta);
8988
+ if (props.orientation === "vertical") {
8989
+ sourceScrollOffsetRef.current.top += delta;
8990
+ } else {
8991
+ sourceScrollOffsetRef.current.left += delta;
8992
+ }
8993
+ }
8994
+ fireDragMove();
8995
+ };
8996
+ scrollContainer?.addEventListener("scroll", onContainerScroll);
8997
+ const dragStrategy = props.dragStrategy ?? "proxy";
8998
+ const useProxy = dragStrategy === "proxy" && !props.renderDragProxy;
8999
+ const useRenderProxy = dragStrategy === "proxy" && !!props.renderDragProxy;
9000
+ const proxyMove = props.onDragProxyMove ?? defaultDragProxyMove;
8598
9001
  const onPointerMove = (e2) => {
9002
+ lastPointer = { left: e2.clientX, top: e2.clientY };
8599
9003
  if (!dragOperation) {
8600
9004
  dragOperation = DragManager.startDrag(
8601
9005
  {
@@ -8605,15 +9009,84 @@ var DragList = (props) => {
8605
9009
  },
8606
9010
  initialCoords
8607
9011
  );
9012
+ if (dragItemNode && useProxy) {
9013
+ const rect = dragItemNode.getBoundingClientRect();
9014
+ let cachedProxy = null;
9015
+ const setupParams = {
9016
+ dragItemNode,
9017
+ dragItemId: `${dragItemId2}`,
9018
+ initialRect: rect,
9019
+ initialCoords,
9020
+ get proxyElement() {
9021
+ if (!cachedProxy) {
9022
+ cachedProxy = createDefaultProxy(dragItemNode, rect);
9023
+ }
9024
+ return cachedProxy;
9025
+ }
9026
+ };
9027
+ const setupResult = props.onDragProxySetup?.(setupParams);
9028
+ const proxyElement = setupResult?.proxyElement ?? setupParams.proxyElement;
9029
+ dragItemNode.style.visibility = "hidden";
9030
+ proxyStateRef.current = {
9031
+ proxyElement,
9032
+ originalNode: dragItemNode,
9033
+ dragItemId: `${dragItemId2}`,
9034
+ initialRect: rect,
9035
+ cleanup: setupResult?.cleanup
9036
+ };
9037
+ }
9038
+ if (dragItemNode && useRenderProxy) {
9039
+ const rect = dragItemNode.getBoundingClientRect();
9040
+ dragItemNode.style.visibility = "hidden";
9041
+ proxyStateRef.current = {
9042
+ proxyElement: dragItemNode,
9043
+ originalNode: dragItemNode,
9044
+ dragItemId: `${dragItemId2}`,
9045
+ initialRect: rect,
9046
+ // Portal handles its own DOM; only restore visibility.
9047
+ cleanup: () => {
9048
+ }
9049
+ };
9050
+ setDragProxyRenderState({
9051
+ dragItemId: `${dragItemId2}`,
9052
+ initialRect: rect,
9053
+ dx: 0,
9054
+ dy: 0
9055
+ });
9056
+ }
8608
9057
  }
8609
- dragOperation.move({
9058
+ const dx = e2.clientX - initialCoords.left;
9059
+ const dy = e2.clientY - initialCoords.top;
9060
+ if (useRenderProxy) {
9061
+ setDragProxyRenderState(
9062
+ (prev) => prev ? { ...prev, dx, dy } : prev
9063
+ );
9064
+ } else {
9065
+ const proxyState = proxyStateRef.current;
9066
+ if (proxyState) {
9067
+ proxyMove({ proxyElement: proxyState.proxyElement, dx, dy });
9068
+ }
9069
+ }
9070
+ autoScroller.updatePointer({
8610
9071
  left: e2.clientX,
8611
9072
  top: e2.clientY
8612
9073
  });
9074
+ fireDragMove();
8613
9075
  };
8614
9076
  const onPointerUp = () => {
9077
+ autoScroller.stop();
9078
+ scrollContainer?.removeEventListener("scroll", onContainerScroll);
8615
9079
  getGlobal().removeEventListener("pointermove", onPointerMove);
9080
+ if (useRenderProxy) {
9081
+ setDragProxyRenderState(
9082
+ (prev) => prev ? { ...prev, dragItemId: null } : prev
9083
+ );
9084
+ requestAnimationFrame(() => {
9085
+ setDragProxyRenderState(null);
9086
+ });
9087
+ }
8616
9088
  if (!dragOperation) {
9089
+ cleanupProxy(proxyStateRef);
8617
9090
  setInteractionTarget(null);
8618
9091
  return;
8619
9092
  }
@@ -8627,7 +9100,11 @@ var DragList = (props) => {
8627
9100
  props.orientation,
8628
9101
  props.dragListId,
8629
9102
  props.acceptDropsFrom,
8630
- props.removeOnDropOutside
9103
+ props.removeOnDropOutside,
9104
+ props.dragStrategy,
9105
+ props.renderDragProxy,
9106
+ props.onDragProxySetup,
9107
+ props.onDragProxyMove
8631
9108
  ]
8632
9109
  );
8633
9110
  const dragging = !!dragItemId;
@@ -8662,7 +9139,10 @@ var DragList = (props) => {
8662
9139
  [DRAG_LIST_ATTRIBUTE]: props.dragListId
8663
9140
  };
8664
9141
  const children = typeof props.children === "function" ? props.children(domProps, contextValue) : props.children;
8665
- return /* @__PURE__ */ React33.createElement(DragListContext.Provider, { value: contextValue }, children);
9142
+ return /* @__PURE__ */ React33.createElement(DragListContext.Provider, { value: contextValue }, children, dragProxyRenderState && props.renderDragProxy ? props.renderDragProxy({
9143
+ ...dragProxyRenderState,
9144
+ ref: proxyRefCallback
9145
+ }) : null);
8666
9146
  };
8667
9147
  var DRAG_LIST_ATTRIBUTE = "data-drag-list-id";
8668
9148
  var DRAG_ITEM_ATTRIBUTE = "data-drag-item-id";
@@ -13366,6 +13846,7 @@ function InfiniteTableInternalHeaderFn(props) {
13366
13846
  {
13367
13847
  orientation: "horizontal",
13368
13848
  dragListId: "header",
13849
+ dragStrategy: "inline",
13369
13850
  onDrop: emptyFn3,
13370
13851
  updatePosition: emptyFn3
13371
13852
  },
@@ -13985,7 +14466,7 @@ function InfiniteTableHeaderCellFn(props) {
13985
14466
  ),
13986
14467
  currentHeader
13987
14468
  );
13988
- draggingProxy = (0, import_react_dom.createPortal)(draggingProxy, portalDOMRef.current);
14469
+ draggingProxy = (0, import_react_dom2.createPortal)(draggingProxy, portalDOMRef.current);
13989
14470
  }
13990
14471
  return /* @__PURE__ */ React51.createElement(ContextProvider, { value: renderParam }, /* @__PURE__ */ React51.createElement(
13991
14472
  InfiniteTableCell,
@@ -26438,7 +26919,7 @@ var useLicense = (licenseKey = "") => {
26438
26919
  }
26439
26920
  let valid2 = isValidLicense(licenseKey, {
26440
26921
  publishedAt: 1624970570587,
26441
- version: "8.0.1"
26922
+ version: "8.0.2"
26442
26923
  });
26443
26924
  if (!licenseKey && !valid2 && isInsidePlayground) {
26444
26925
  return true;
@@ -27303,7 +27784,7 @@ var import_react59 = require("react");
27303
27784
  // src/components/hooks/useOverlay/index.tsx
27304
27785
  var React57 = __toESM(require("react"));
27305
27786
  var import_react55 = require("react");
27306
- var import_react_dom2 = require("react-dom");
27787
+ var import_react_dom3 = require("react-dom");
27307
27788
 
27308
27789
  // src/utils/pageGeometry/alignment/index.ts
27309
27790
  function isHTMLElement(v) {
@@ -27555,7 +28036,7 @@ function useOverlayPortal(content, portalContainer) {
27555
28036
  }
27556
28037
  getContainer();
27557
28038
  }, [portalContainer]);
27558
- return portalContainer ? container ? (0, import_react_dom2.createPortal)(content, container) : (
28039
+ return portalContainer ? container ? (0, import_react_dom3.createPortal)(content, container) : (
27559
28040
  // we're probably still fetching the container
27560
28041
  /* @__PURE__ */ React57.createElement(React57.Fragment, null)
27561
28042
  ) : portalContainer === null || portalContainer === false ? content : /* @__PURE__ */ React57.createElement(DefaultOverlayPortal, null, content);
@@ -30525,6 +31006,7 @@ function GroupingToolbar(props) {
30525
31006
  dragListId: GROUPING_TOOLBAR_DRAG_LIST_ID,
30526
31007
  acceptDropsFrom: ["header", GROUPING_TOOLBAR_DRAG_LIST_ID],
30527
31008
  onDrop,
31009
+ dragStrategy: "inline",
30528
31010
  onAcceptDrop,
30529
31011
  shouldAcceptDrop
30530
31012
  },
@@ -32270,7 +32752,7 @@ var FlashingColumnCell = createFlashingColumnCellComponent();
32270
32752
  // src/components/HeadlessTable/MatrixDebugger.tsx
32271
32753
  var React82 = __toESM(require("react"));
32272
32754
  var import_react77 = require("react");
32273
- var import_react_dom3 = require("react-dom");
32755
+ var import_react_dom4 = require("react-dom");
32274
32756
  function INTERNAL_MatrixDebugger(props) {
32275
32757
  const [getState, setGetState] = React82.useState(null);
32276
32758
  (0, import_react77.useEffect)(() => {
@@ -32310,7 +32792,7 @@ function MatrixDebuggerUI() {
32310
32792
  const columnsIndexes = cellManager.getColumnsWithCells();
32311
32793
  const domRef = (0, import_react77.useRef)(null);
32312
32794
  const displayTimeoutRef = (0, import_react77.useRef)(null);
32313
- return /* @__PURE__ */ React82.createElement("div", { style: { overflow: "auto" } }, (0, import_react_dom3.createPortal)(
32795
+ return /* @__PURE__ */ React82.createElement("div", { style: { overflow: "auto" } }, (0, import_react_dom4.createPortal)(
32314
32796
  /* @__PURE__ */ React82.createElement(
32315
32797
  "div",
32316
32798
  {
@@ -32402,6 +32884,7 @@ var components = {
32402
32884
  };
32403
32885
  // Annotate the CommonJS export names for ESM import in node:
32404
32886
  0 && (module.exports = {
32887
+ AutoScroller,
32405
32888
  CellSelectionState,
32406
32889
  DRAG_ITEM_ATTRIBUTE,
32407
32890
  DataClient,
@@ -32430,9 +32913,11 @@ var components = {
32430
32913
  WeakFixedSizeSet,
32431
32914
  alignNode,
32432
32915
  components,
32916
+ createDefaultProxy,
32433
32917
  createFlashingColumnCellComponent,
32434
32918
  debounce,
32435
32919
  debug,
32920
+ defaultDragProxyMove,
32436
32921
  defaultFilterTypes,
32437
32922
  eventMatchesKeyboardShortcut,
32438
32923
  filterDataArray,