@infinite-table/infinite-react 8.0.0 → 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,11 +68,16 @@ 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,
73
+ DRAG_ITEM_ATTRIBUTE: () => DRAG_ITEM_ATTRIBUTE,
72
74
  DataClient: () => DataClient,
73
75
  DataSource: () => DataSource,
74
76
  DataSourceActionType: () => DataSourceActionType,
75
77
  DeepMap: () => DeepMap,
78
+ DragDropProvider: () => DragDropProvider,
79
+ DragInteractionTarget: () => DragInteractionTarget,
80
+ DragList: () => DragList,
76
81
  FixedSizeSet: () => FixedSizeSet,
77
82
  FlashingColumnCell: () => FlashingColumnCell,
78
83
  GroupRowsState: () => GroupRowsState,
@@ -92,9 +97,11 @@ __export(index_exports, {
92
97
  WeakFixedSizeSet: () => WeakFixedSizeSet,
93
98
  alignNode: () => alignNode,
94
99
  components: () => components,
100
+ createDefaultProxy: () => createDefaultProxy,
95
101
  createFlashingColumnCellComponent: () => createFlashingColumnCellComponent,
96
102
  debounce: () => debounce,
97
103
  debug: () => debug,
104
+ defaultDragProxyMove: () => defaultDragProxyMove,
98
105
  defaultFilterTypes: () => defaultFilterTypes2,
99
106
  eventMatchesKeyboardShortcut: () => eventMatchesKeyboardShortcut,
100
107
  filterDataArray: () => filterDataArray,
@@ -112,6 +119,8 @@ __export(index_exports, {
112
119
  useDataSourceInternal: () => useDataSourceInternal,
113
120
  useDataSourceSelector: () => useDataSourceSelector,
114
121
  useDataSourceState: () => useDataSourceState,
122
+ useDragDropProvider: () => useDragDropProvider,
123
+ useDragListContext: () => useDragListContext,
115
124
  useEffectWhen: () => useEffectWhen,
116
125
  useEffectWhenSameDeps: () => useEffectWhenSameDeps,
117
126
  useEffectWithChanges: () => useEffectWithChanges,
@@ -2117,7 +2126,7 @@ function InfiniteTableFooter(props) {
2117
2126
  // src/components/InfiniteTable/components/InfiniteTableHeader/InfiniteTableHeaderCell.tsx
2118
2127
  var React51 = __toESM(require("react"));
2119
2128
  var import_react36 = require("react");
2120
- var import_react_dom = require("react-dom");
2129
+ var import_react_dom2 = require("react-dom");
2121
2130
 
2122
2131
  // src/utils/keyMirror.ts
2123
2132
  function keyMirror(obj) {
@@ -3920,6 +3929,7 @@ function useCellClassName(column, baseClasses, variants, extraFlags) {
3920
3929
 
3921
3930
  // src/components/InfiniteTable/hooks/useColumnPointerEvents.ts
3922
3931
  var import_react15 = require("react");
3932
+ var import_react_dom = require("react-dom");
3923
3933
 
3924
3934
  // src/utils/selectParent.ts
3925
3935
  function selectParent(el, selector2) {
@@ -5428,7 +5438,7 @@ var handleOutsideOperation = (operation, interactionTarget) => {
5428
5438
  if (inside) {
5429
5439
  return { left: 0, top: 0 };
5430
5440
  }
5431
- if (index > dragIndex) {
5441
+ if (index > dragIndex && !interactionTarget.getData().preserveDragSpace) {
5432
5442
  return orientation === "horizontal" ? { left: -dragItem.rect.width, top: 0 } : { left: 0, top: -dragItem.rect.height };
5433
5443
  }
5434
5444
  return { left: 0, top: 0 };
@@ -5457,12 +5467,24 @@ var _DragManager = class _DragManager {
5457
5467
  activeDragSource,
5458
5468
  startPoint
5459
5469
  });
5470
+ _DragManager.currentDragOperation = dragOperation;
5460
5471
  dragOperation.on("start", _DragManager.onDragStart);
5461
5472
  dragOperation.on("move", _DragManager.onDragMove);
5462
5473
  dragOperation.on("drop", _DragManager.onDragDrop);
5463
5474
  dragOperation.start();
5464
5475
  return dragOperation;
5465
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
+ }
5466
5488
  static emit(event, ...params) {
5467
5489
  _DragManager.emitter.emit(event, ...params);
5468
5490
  }
@@ -5613,11 +5635,13 @@ var _DragManager = class _DragManager {
5613
5635
  dragIndex: event?.dragIndex ?? -1,
5614
5636
  dropIndex: event?.dropIndex ?? -1
5615
5637
  });
5638
+ _DragManager.currentDragOperation = null;
5616
5639
  _DragManager.unregisterAll();
5617
5640
  }
5618
5641
  };
5619
5642
  // public static dragInteractionTargets: DragInteractionTarget[] = [];
5620
5643
  _DragManager.dragInteractionTargetsMap = /* @__PURE__ */ new Map();
5644
+ _DragManager.currentDragOperation = null;
5621
5645
  _DragManager.emitter = new EventEmitter();
5622
5646
  var DragManager = _DragManager;
5623
5647
  var ActiveDragSource = class _ActiveDragSource {
@@ -5936,13 +5960,6 @@ var useColumnPointerEvents = ({
5936
5960
  }
5937
5961
  const currentComputedColumnOrder = getComputed().computedColumnOrder;
5938
5962
  if (JSON.stringify(columnOrder, currentComputedColumnOrder)) {
5939
- computedVisibleColumns.forEach((col) => {
5940
- setInfiniteColumnOffsetWhileReordering(
5941
- col.computedVisibleIndex,
5942
- "",
5943
- rootRef.current
5944
- );
5945
- });
5946
5963
  actions.columnOrder = adjustColumnOrderForAllColumns({
5947
5964
  newColumnOrder: columnOrder,
5948
5965
  visibleColumnOrder: getComputed().computedVisibleColumns.map(
@@ -6003,27 +6020,48 @@ var useColumnPointerEvents = ({
6003
6020
  requestAnimationFrame(() => {
6004
6021
  const { multiSortBehavior } = getState();
6005
6022
  const target2 = domRef.current;
6006
- rootRef.current?.classList.remove(InfiniteClsShiftingColumns);
6023
+ const rootNode = rootRef.current;
6024
+ rootNode?.classList.remove(InfiniteClsShiftingColumns);
6007
6025
  dragger.stop();
6008
6026
  brain.update({
6009
6027
  ...initialAvailableSize
6010
6028
  });
6011
6029
  discardAlwaysRenderedColumn?.();
6012
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
+ });
6013
6055
  computedVisibleColumns.forEach((col) => {
6014
6056
  clearInfiniteColumnReorderDuration(
6015
6057
  col.computedVisibleIndex,
6016
- rootRef.current
6017
- );
6018
- setInfiniteColumnVisibility(
6019
- col.computedVisibleIndex,
6020
- "",
6021
- rootRef.current
6058
+ rootNode
6022
6059
  );
6060
+ setInfiniteColumnVisibility(col.computedVisibleIndex, "", rootNode);
6023
6061
  setInfiniteColumnOffsetWhileReordering(
6024
6062
  col.computedVisibleIndex,
6025
6063
  "",
6026
- rootRef.current
6064
+ rootNode
6027
6065
  );
6028
6066
  });
6029
6067
  setInfiniteColumnZIndex(
@@ -6032,30 +6070,8 @@ var useColumnPointerEvents = ({
6032
6070
  pinnedStartColsCount: computedPinnedStartColumns.length,
6033
6071
  visibleColsCount: computedVisibleColumns.length
6034
6072
  }),
6035
- rootRef.current
6073
+ rootNode
6036
6074
  );
6037
- target2.style.cursor = initialCursor;
6038
- target2.releasePointerCapture(pointerId);
6039
- target2.removeEventListener("pointermove", onPointerMove);
6040
- target2.removeEventListener("pointerup", onPointerUp);
6041
- setProxyPosition(null);
6042
- const dragColumnSortable = api.getColumnApi(dragColumn.id)?.isSortable() ?? false;
6043
- if (!didDragAtLeastOnce && dragColumnSortable) {
6044
- api.toggleSortingForColumn(dragColumn.id, {
6045
- multiSortBehavior: multiSortBehavior === "replace" && (e2.ctrlKey || e2.metaKey) ? "append" : multiSortBehavior
6046
- });
6047
- }
6048
- if (reorderDragResult) {
6049
- persistColumnOrder(reorderDragResult);
6050
- } else if (didDragAtLeastOnce) {
6051
- if (allowColumnHideOnDrag) {
6052
- api.setVisibilityForColumn(dragColumn.id, false);
6053
- }
6054
- }
6055
- actions.columnReorderDragColumnId = false;
6056
- if (horizontalLayoutPageIndex != null) {
6057
- actions.columnReorderInPageIndex = null;
6058
- }
6059
6075
  });
6060
6076
  };
6061
6077
  target.addEventListener("pointermove", onPointerMove);
@@ -8247,6 +8263,20 @@ var DragInteractionTarget = class extends EventEmitter {
8247
8263
  }
8248
8264
  return result;
8249
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
+ }
8250
8280
  move(params) {
8251
8281
  this.emit("move", params);
8252
8282
  }
@@ -8302,6 +8332,217 @@ var DragInteractionTarget = class extends EventEmitter {
8302
8332
  }
8303
8333
  };
8304
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
+
8305
8546
  // src/components/InfiniteTable/components/draggable/DragList.tsx
8306
8547
  var DragListContext = React33.createContext({
8307
8548
  dragItemId: null,
@@ -8343,15 +8584,34 @@ function getDraggableItems(domRef) {
8343
8584
  }
8344
8585
  function getInteractionTargetData(params) {
8345
8586
  const { domRef, orientation, dragListId } = params;
8346
- 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
+ });
8347
8606
  const options = {
8348
- draggableItems: getDraggableItems(domRef),
8607
+ draggableItems,
8349
8608
  orientation,
8350
8609
  listId: dragListId,
8351
8610
  listRectangle,
8352
8611
  acceptDropsFrom: params.acceptDropsFrom,
8353
8612
  shouldAcceptDrop: params.shouldAcceptDrop,
8354
- initial: params.initial
8613
+ initial: params.initial,
8614
+ preserveDragSpace: params.preserveDragSpace
8355
8615
  };
8356
8616
  return options;
8357
8617
  }
@@ -8409,8 +8669,49 @@ function useInteractionTarget(domRef, props) {
8409
8669
  getInteractionTarget
8410
8670
  };
8411
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
+ }
8412
8706
  var DragList = (props) => {
8413
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
+ }, []);
8414
8715
  const { dropTargetListId, dragSourceListId } = useDragDropProvider();
8415
8716
  const { updateDragOperationSourceAndTarget, dragItemId, status } = useDragDropProvider();
8416
8717
  const getOnDrop = useLatest(props.onDrop);
@@ -8451,18 +8752,29 @@ var DragList = (props) => {
8451
8752
  );
8452
8753
  const removeOnDragMove = interactionTarget.on(
8453
8754
  "move",
8454
- ({ offsetsForItems, items, status: status2 }) => {
8755
+ ({ offsetsForItems, items, status: status2, dragItem }) => {
8455
8756
  if (status2 === "rejected") {
8456
8757
  return;
8457
8758
  }
8458
8759
  const dragItems = getDragItems();
8459
8760
  const updatePosition = getUpdatePosition();
8761
+ const proxyState = proxyStateRef.current;
8460
8762
  items.forEach((item, index) => {
8461
- const offset = offsetsForItems[index];
8763
+ let offset = offsetsForItems[index];
8462
8764
  const node = dragItems[index];
8463
8765
  if (!node) {
8464
8766
  return;
8465
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
+ }
8466
8778
  updatePosition({
8467
8779
  id: item.id,
8468
8780
  node,
@@ -8500,6 +8812,12 @@ var DragList = (props) => {
8500
8812
  offset: null
8501
8813
  });
8502
8814
  });
8815
+ cleanupProxy(proxyStateRef);
8816
+ setDragProxyRenderState((prev) => {
8817
+ if (!prev) return prev;
8818
+ requestAnimationFrame(() => setDragProxyRenderState(null));
8819
+ return { ...prev, dragItemId: null };
8820
+ });
8503
8821
  const accepted = status2 === "accepted";
8504
8822
  if (dragListId === dropTargetListId2 && dragSourceListId2 !== dragListId) {
8505
8823
  if (onAcceptDrop && accepted) {
@@ -8529,10 +8847,58 @@ var DragList = (props) => {
8529
8847
  });
8530
8848
  }
8531
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
+ }
8532
8883
  return () => {
8533
8884
  removeOnDragStart();
8534
8885
  removeOnDragMove();
8535
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
+ }
8536
8902
  };
8537
8903
  }
8538
8904
  return void 0;
@@ -8577,19 +8943,63 @@ var DragList = (props) => {
8577
8943
  orientation: props.orientation,
8578
8944
  dragListId: props.dragListId,
8579
8945
  acceptDropsFrom: props.acceptDropsFrom,
8580
- initial: true
8946
+ initial: true,
8947
+ preserveDragSpace: props.preserveDragSpace
8581
8948
  });
8582
8949
  const draggableItems = interactionTarget2.getData().draggableItems;
8583
8950
  const dragIndex = draggableItems.findIndex(
8584
8951
  (item) => item.id === dragItemId2
8585
8952
  );
8586
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
+ );
8587
8957
  setInteractionTarget(interactionTarget2);
8588
8958
  const initialCoords = {
8589
8959
  left: e.clientX,
8590
8960
  top: e.clientY
8591
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;
8592
9001
  const onPointerMove = (e2) => {
9002
+ lastPointer = { left: e2.clientX, top: e2.clientY };
8593
9003
  if (!dragOperation) {
8594
9004
  dragOperation = DragManager.startDrag(
8595
9005
  {
@@ -8599,15 +9009,84 @@ var DragList = (props) => {
8599
9009
  },
8600
9010
  initialCoords
8601
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
+ }
8602
9057
  }
8603
- 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({
8604
9071
  left: e2.clientX,
8605
9072
  top: e2.clientY
8606
9073
  });
9074
+ fireDragMove();
8607
9075
  };
8608
9076
  const onPointerUp = () => {
9077
+ autoScroller.stop();
9078
+ scrollContainer?.removeEventListener("scroll", onContainerScroll);
8609
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
+ }
8610
9088
  if (!dragOperation) {
9089
+ cleanupProxy(proxyStateRef);
8611
9090
  setInteractionTarget(null);
8612
9091
  return;
8613
9092
  }
@@ -8621,7 +9100,11 @@ var DragList = (props) => {
8621
9100
  props.orientation,
8622
9101
  props.dragListId,
8623
9102
  props.acceptDropsFrom,
8624
- props.removeOnDropOutside
9103
+ props.removeOnDropOutside,
9104
+ props.dragStrategy,
9105
+ props.renderDragProxy,
9106
+ props.onDragProxySetup,
9107
+ props.onDragProxyMove
8625
9108
  ]
8626
9109
  );
8627
9110
  const dragging = !!dragItemId;
@@ -8656,7 +9139,10 @@ var DragList = (props) => {
8656
9139
  [DRAG_LIST_ATTRIBUTE]: props.dragListId
8657
9140
  };
8658
9141
  const children = typeof props.children === "function" ? props.children(domProps, contextValue) : props.children;
8659
- 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);
8660
9146
  };
8661
9147
  var DRAG_LIST_ATTRIBUTE = "data-drag-list-id";
8662
9148
  var DRAG_ITEM_ATTRIBUTE = "data-drag-item-id";
@@ -13360,6 +13846,7 @@ function InfiniteTableInternalHeaderFn(props) {
13360
13846
  {
13361
13847
  orientation: "horizontal",
13362
13848
  dragListId: "header",
13849
+ dragStrategy: "inline",
13363
13850
  onDrop: emptyFn3,
13364
13851
  updatePosition: emptyFn3
13365
13852
  },
@@ -13979,7 +14466,7 @@ function InfiniteTableHeaderCellFn(props) {
13979
14466
  ),
13980
14467
  currentHeader
13981
14468
  );
13982
- draggingProxy = (0, import_react_dom.createPortal)(draggingProxy, portalDOMRef.current);
14469
+ draggingProxy = (0, import_react_dom2.createPortal)(draggingProxy, portalDOMRef.current);
13983
14470
  }
13984
14471
  return /* @__PURE__ */ React51.createElement(ContextProvider, { value: renderParam }, /* @__PURE__ */ React51.createElement(
13985
14472
  InfiniteTableCell,
@@ -26432,7 +26919,7 @@ var useLicense = (licenseKey = "") => {
26432
26919
  }
26433
26920
  let valid2 = isValidLicense(licenseKey, {
26434
26921
  publishedAt: 1624970570587,
26435
- version: "8.0.0"
26922
+ version: "8.0.2"
26436
26923
  });
26437
26924
  if (!licenseKey && !valid2 && isInsidePlayground) {
26438
26925
  return true;
@@ -27297,7 +27784,7 @@ var import_react59 = require("react");
27297
27784
  // src/components/hooks/useOverlay/index.tsx
27298
27785
  var React57 = __toESM(require("react"));
27299
27786
  var import_react55 = require("react");
27300
- var import_react_dom2 = require("react-dom");
27787
+ var import_react_dom3 = require("react-dom");
27301
27788
 
27302
27789
  // src/utils/pageGeometry/alignment/index.ts
27303
27790
  function isHTMLElement(v) {
@@ -27549,7 +28036,7 @@ function useOverlayPortal(content, portalContainer) {
27549
28036
  }
27550
28037
  getContainer();
27551
28038
  }, [portalContainer]);
27552
- return portalContainer ? container ? (0, import_react_dom2.createPortal)(content, container) : (
28039
+ return portalContainer ? container ? (0, import_react_dom3.createPortal)(content, container) : (
27553
28040
  // we're probably still fetching the container
27554
28041
  /* @__PURE__ */ React57.createElement(React57.Fragment, null)
27555
28042
  ) : portalContainer === null || portalContainer === false ? content : /* @__PURE__ */ React57.createElement(DefaultOverlayPortal, null, content);
@@ -30519,6 +31006,7 @@ function GroupingToolbar(props) {
30519
31006
  dragListId: GROUPING_TOOLBAR_DRAG_LIST_ID,
30520
31007
  acceptDropsFrom: ["header", GROUPING_TOOLBAR_DRAG_LIST_ID],
30521
31008
  onDrop,
31009
+ dragStrategy: "inline",
30522
31010
  onAcceptDrop,
30523
31011
  shouldAcceptDrop
30524
31012
  },
@@ -32264,7 +32752,7 @@ var FlashingColumnCell = createFlashingColumnCellComponent();
32264
32752
  // src/components/HeadlessTable/MatrixDebugger.tsx
32265
32753
  var React82 = __toESM(require("react"));
32266
32754
  var import_react77 = require("react");
32267
- var import_react_dom3 = require("react-dom");
32755
+ var import_react_dom4 = require("react-dom");
32268
32756
  function INTERNAL_MatrixDebugger(props) {
32269
32757
  const [getState, setGetState] = React82.useState(null);
32270
32758
  (0, import_react77.useEffect)(() => {
@@ -32304,7 +32792,7 @@ function MatrixDebuggerUI() {
32304
32792
  const columnsIndexes = cellManager.getColumnsWithCells();
32305
32793
  const domRef = (0, import_react77.useRef)(null);
32306
32794
  const displayTimeoutRef = (0, import_react77.useRef)(null);
32307
- 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)(
32308
32796
  /* @__PURE__ */ React82.createElement(
32309
32797
  "div",
32310
32798
  {
@@ -32396,11 +32884,16 @@ var components = {
32396
32884
  };
32397
32885
  // Annotate the CommonJS export names for ESM import in node:
32398
32886
  0 && (module.exports = {
32887
+ AutoScroller,
32399
32888
  CellSelectionState,
32889
+ DRAG_ITEM_ATTRIBUTE,
32400
32890
  DataClient,
32401
32891
  DataSource,
32402
32892
  DataSourceActionType,
32403
32893
  DeepMap,
32894
+ DragDropProvider,
32895
+ DragInteractionTarget,
32896
+ DragList,
32404
32897
  FixedSizeSet,
32405
32898
  FlashingColumnCell,
32406
32899
  GroupRowsState,
@@ -32420,9 +32913,11 @@ var components = {
32420
32913
  WeakFixedSizeSet,
32421
32914
  alignNode,
32422
32915
  components,
32916
+ createDefaultProxy,
32423
32917
  createFlashingColumnCellComponent,
32424
32918
  debounce,
32425
32919
  debug,
32920
+ defaultDragProxyMove,
32426
32921
  defaultFilterTypes,
32427
32922
  eventMatchesKeyboardShortcut,
32428
32923
  filterDataArray,
@@ -32440,6 +32935,8 @@ var components = {
32440
32935
  useDataSourceInternal,
32441
32936
  useDataSourceSelector,
32442
32937
  useDataSourceState,
32938
+ useDragDropProvider,
32939
+ useDragListContext,
32443
32940
  useEffectWhen,
32444
32941
  useEffectWhenSameDeps,
32445
32942
  useEffectWithChanges,