@infinite-table/infinite-react 8.0.1 → 8.0.3

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,
@@ -8333,8 +8568,15 @@ var defaultUpdatePosition = (options) => {
8333
8568
  var getDraggableItemId = (node) => {
8334
8569
  return `${node.getAttribute(DRAG_ITEM_ATTRIBUTE)}`;
8335
8570
  };
8336
- function getDraggableItems(domRef) {
8571
+ function getDraggableItemNodes(domRef, dragListId) {
8337
8572
  const dragItems = domRef.current?.querySelectorAll(DRAG_ITEM_SELECTOR) ?? [];
8573
+ const result = Array.from(dragItems).filter(
8574
+ (item) => item.getAttribute(DRAG_ITEM_LIST_ATTRIBUTE) === `${dragListId}`
8575
+ );
8576
+ return result;
8577
+ }
8578
+ function getDraggableItems(domRef, dragListId) {
8579
+ const dragItems = getDraggableItemNodes(domRef, dragListId);
8338
8580
  if (!dragItems || dragItems.length === 0) {
8339
8581
  }
8340
8582
  const draggableItems = Array.from(dragItems).map((item) => {
@@ -8349,15 +8591,34 @@ function getDraggableItems(domRef) {
8349
8591
  }
8350
8592
  function getInteractionTargetData(params) {
8351
8593
  const { domRef, orientation, dragListId } = params;
8352
- const listRectangle = Rectangle.from(domRef.current.getBoundingClientRect());
8594
+ const draggableItems = getDraggableItems(domRef, dragListId);
8595
+ const domRect = domRef.current.getBoundingClientRect();
8596
+ let top2 = domRect.top;
8597
+ let left2 = domRect.left;
8598
+ let bottom = domRect.bottom;
8599
+ let right = domRect.right;
8600
+ for (const item of draggableItems) {
8601
+ const r = item.rect;
8602
+ if (r.top < top2) top2 = r.top;
8603
+ if (r.left < left2) left2 = r.left;
8604
+ if (r.bottom > bottom) bottom = r.bottom;
8605
+ if (r.right > right) right = r.right;
8606
+ }
8607
+ const listRectangle = Rectangle.from({
8608
+ top: top2,
8609
+ left: left2,
8610
+ width: right - left2,
8611
+ height: bottom - top2
8612
+ });
8353
8613
  const options = {
8354
- draggableItems: getDraggableItems(domRef),
8614
+ draggableItems,
8355
8615
  orientation,
8356
8616
  listId: dragListId,
8357
8617
  listRectangle,
8358
8618
  acceptDropsFrom: params.acceptDropsFrom,
8359
8619
  shouldAcceptDrop: params.shouldAcceptDrop,
8360
- initial: params.initial
8620
+ initial: params.initial,
8621
+ preserveDragSpace: params.preserveDragSpace
8361
8622
  };
8362
8623
  return options;
8363
8624
  }
@@ -8415,8 +8676,49 @@ function useInteractionTarget(domRef, props) {
8415
8676
  getInteractionTarget
8416
8677
  };
8417
8678
  }
8679
+ function createDefaultProxy(dragItemNode, initialRect) {
8680
+ const proxy = dragItemNode.cloneNode(true);
8681
+ proxy.removeAttribute(DRAG_ITEM_ATTRIBUTE);
8682
+ proxy.style.position = "fixed";
8683
+ proxy.style.top = `${initialRect.top}px`;
8684
+ proxy.style.left = `${initialRect.left}px`;
8685
+ proxy.style.width = `${initialRect.width}px`;
8686
+ proxy.style.height = `${initialRect.height}px`;
8687
+ proxy.style.zIndex = "999999";
8688
+ proxy.style.pointerEvents = "none";
8689
+ proxy.style.margin = "0";
8690
+ proxy.style.boxSizing = "border-box";
8691
+ proxy.style.transform = "none";
8692
+ document.body.appendChild(proxy);
8693
+ return proxy;
8694
+ }
8695
+ function defaultDragProxyMove({
8696
+ proxyElement,
8697
+ dx,
8698
+ dy
8699
+ }) {
8700
+ proxyElement.style.transform = `translate3d(${dx}px, ${dy}px, 0)`;
8701
+ }
8702
+ function cleanupProxy(proxyStateRef) {
8703
+ const state = proxyStateRef.current;
8704
+ if (!state) return;
8705
+ if (state.cleanup) {
8706
+ state.cleanup({ proxyElement: state.proxyElement });
8707
+ } else {
8708
+ state.proxyElement.remove();
8709
+ }
8710
+ state.originalNode.style.visibility = "";
8711
+ proxyStateRef.current = null;
8712
+ }
8418
8713
  var DragList = (props) => {
8419
8714
  const domRef = React33.useRef(null);
8715
+ const proxyStateRef = React33.useRef(null);
8716
+ const [dragProxyRenderState, setDragProxyRenderState] = (0, import_react23.useState)(null);
8717
+ const sourceScrollOffsetRef = React33.useRef({ top: 0, left: 0 });
8718
+ const proxyPortalNodeRef = React33.useRef(null);
8719
+ const proxyRefCallback = React33.useCallback((node) => {
8720
+ proxyPortalNodeRef.current = node;
8721
+ }, []);
8420
8722
  const { dropTargetListId, dragSourceListId } = useDragDropProvider();
8421
8723
  const { updateDragOperationSourceAndTarget, dragItemId, status } = useDragDropProvider();
8422
8724
  const getOnDrop = useLatest(props.onDrop);
@@ -8457,18 +8759,29 @@ var DragList = (props) => {
8457
8759
  );
8458
8760
  const removeOnDragMove = interactionTarget.on(
8459
8761
  "move",
8460
- ({ offsetsForItems, items, status: status2 }) => {
8762
+ ({ offsetsForItems, items, status: status2, dragItem }) => {
8461
8763
  if (status2 === "rejected") {
8462
8764
  return;
8463
8765
  }
8464
8766
  const dragItems = getDragItems();
8465
8767
  const updatePosition = getUpdatePosition();
8768
+ const proxyState = proxyStateRef.current;
8466
8769
  items.forEach((item, index) => {
8467
- const offset = offsetsForItems[index];
8770
+ let offset = offsetsForItems[index];
8468
8771
  const node = dragItems[index];
8469
8772
  if (!node) {
8470
8773
  return;
8471
8774
  }
8775
+ if (proxyState && item.id === proxyState.dragItemId) {
8776
+ return;
8777
+ }
8778
+ if (!proxyState && item.id === dragItem.id) {
8779
+ const scrollOffset = sourceScrollOffsetRef.current;
8780
+ offset = {
8781
+ left: offset.left + scrollOffset.left,
8782
+ top: offset.top + scrollOffset.top
8783
+ };
8784
+ }
8472
8785
  updatePosition({
8473
8786
  id: item.id,
8474
8787
  node,
@@ -8506,6 +8819,12 @@ var DragList = (props) => {
8506
8819
  offset: null
8507
8820
  });
8508
8821
  });
8822
+ cleanupProxy(proxyStateRef);
8823
+ setDragProxyRenderState((prev) => {
8824
+ if (!prev) return prev;
8825
+ requestAnimationFrame(() => setDragProxyRenderState(null));
8826
+ return { ...prev, dragItemId: null };
8827
+ });
8509
8828
  const accepted = status2 === "accepted";
8510
8829
  if (dragListId === dropTargetListId2 && dragSourceListId2 !== dragListId) {
8511
8830
  if (onAcceptDrop && accepted) {
@@ -8535,10 +8854,58 @@ var DragList = (props) => {
8535
8854
  });
8536
8855
  }
8537
8856
  });
8857
+ let targetAutoScroller = null;
8858
+ let targetScrollContainer = null;
8859
+ let targetScrollHandler = null;
8860
+ let targetPointermoveHandler = null;
8861
+ if (!interactionTarget.getData().initial && domRef.current) {
8862
+ targetAutoScroller = new AutoScroller({
8863
+ orientation: props.orientation,
8864
+ onScroll: () => {
8865
+ }
8866
+ });
8867
+ targetAutoScroller.start(domRef.current);
8868
+ targetScrollContainer = targetAutoScroller.getScrollContainer();
8869
+ if (targetScrollContainer) {
8870
+ let lastScroll = props.orientation === "vertical" ? targetScrollContainer.scrollTop : targetScrollContainer.scrollLeft;
8871
+ targetScrollHandler = () => {
8872
+ const current = props.orientation === "vertical" ? targetScrollContainer.scrollTop : targetScrollContainer.scrollLeft;
8873
+ const delta = current - lastScroll;
8874
+ lastScroll = current;
8875
+ if (delta !== 0) {
8876
+ interactionTarget.adjustForScroll(delta);
8877
+ DragManager.retriggerMove();
8878
+ }
8879
+ };
8880
+ targetScrollContainer.addEventListener("scroll", targetScrollHandler);
8881
+ }
8882
+ targetPointermoveHandler = (e) => {
8883
+ targetAutoScroller.updatePointer({
8884
+ left: e.clientX,
8885
+ top: e.clientY
8886
+ });
8887
+ };
8888
+ getGlobal().addEventListener("pointermove", targetPointermoveHandler);
8889
+ }
8538
8890
  return () => {
8539
8891
  removeOnDragStart();
8540
8892
  removeOnDragMove();
8541
8893
  removeOnDragDrop();
8894
+ if (targetAutoScroller) {
8895
+ targetAutoScroller.stop();
8896
+ }
8897
+ if (targetScrollContainer && targetScrollHandler) {
8898
+ targetScrollContainer.removeEventListener(
8899
+ "scroll",
8900
+ targetScrollHandler
8901
+ );
8902
+ }
8903
+ if (targetPointermoveHandler) {
8904
+ getGlobal().removeEventListener(
8905
+ "pointermove",
8906
+ targetPointermoveHandler
8907
+ );
8908
+ }
8542
8909
  };
8543
8910
  }
8544
8911
  return void 0;
@@ -8547,13 +8914,11 @@ var DragList = (props) => {
8547
8914
  const getDragItems = (0, import_react23.useCallback)(() => {
8548
8915
  let dragItems = dragItemsRef.current;
8549
8916
  if (!dragItems || dragItems.length === 0) {
8550
- dragItems = Array.from(
8551
- domRef.current?.querySelectorAll(DRAG_ITEM_SELECTOR) ?? []
8552
- );
8917
+ dragItems = getDraggableItemNodes(domRef, props.dragListId);
8553
8918
  dragItemsRef.current = dragItems;
8554
8919
  }
8555
8920
  return dragItems;
8556
- }, []);
8921
+ }, [props.dragListId]);
8557
8922
  const onDragItemPointerDown = (0, import_react23.useCallback)(
8558
8923
  (e) => {
8559
8924
  const target = e.currentTarget;
@@ -8574,28 +8939,70 @@ var DragList = (props) => {
8574
8939
  }
8575
8940
  dragItemId2 = `${dragItemId2}`;
8576
8941
  let dragOperation = null;
8577
- const dragItems = Array.from(
8578
- domRef.current?.querySelectorAll(DRAG_ITEM_SELECTOR) ?? []
8579
- );
8942
+ const dragItems = getDraggableItemNodes(domRef, props.dragListId);
8580
8943
  dragItemsRef.current = dragItems;
8581
8944
  const interactionTarget2 = createInteractionTarget({
8582
8945
  domRef,
8583
8946
  orientation: props.orientation,
8584
8947
  dragListId: props.dragListId,
8585
8948
  acceptDropsFrom: props.acceptDropsFrom,
8586
- initial: true
8949
+ initial: true,
8950
+ preserveDragSpace: props.preserveDragSpace
8587
8951
  });
8588
8952
  const draggableItems = interactionTarget2.getData().draggableItems;
8589
8953
  const dragIndex = draggableItems.findIndex(
8590
8954
  (item) => item.id === dragItemId2
8591
8955
  );
8592
8956
  const dragItem = draggableItems[dragIndex];
8957
+ const dragItemNode = dragItems[dragIndex].getAttribute(DRAG_ITEM_ATTRIBUTE) === `${dragItemId2}` ? dragItems[dragIndex] : dragItems.find(
8958
+ (node) => node.getAttribute(DRAG_ITEM_ATTRIBUTE) === `${dragItemId2}`
8959
+ );
8593
8960
  setInteractionTarget(interactionTarget2);
8594
8961
  const initialCoords = {
8595
8962
  left: e.clientX,
8596
8963
  top: e.clientY
8597
8964
  };
8965
+ let lastPointer = { left: e.clientX, top: e.clientY };
8966
+ sourceScrollOffsetRef.current = { top: 0, left: 0 };
8967
+ const autoScroller = new AutoScroller({
8968
+ orientation: props.orientation,
8969
+ onScroll: () => {
8970
+ }
8971
+ });
8972
+ if (domRef.current) {
8973
+ autoScroller.start(domRef.current);
8974
+ }
8975
+ const scrollContainer = autoScroller.getScrollContainer();
8976
+ let lastSourceScroll = scrollContainer ? props.orientation === "vertical" ? scrollContainer.scrollTop : scrollContainer.scrollLeft : 0;
8977
+ function fireDragMove() {
8978
+ if (!dragOperation) return;
8979
+ dragOperation.move({
8980
+ left: lastPointer.left,
8981
+ top: lastPointer.top
8982
+ });
8983
+ }
8984
+ const onContainerScroll = () => {
8985
+ if (!scrollContainer) return;
8986
+ const current = props.orientation === "vertical" ? scrollContainer.scrollTop : scrollContainer.scrollLeft;
8987
+ const delta = current - lastSourceScroll;
8988
+ lastSourceScroll = current;
8989
+ if (delta !== 0) {
8990
+ interactionTarget2.adjustForScroll(delta);
8991
+ if (props.orientation === "vertical") {
8992
+ sourceScrollOffsetRef.current.top += delta;
8993
+ } else {
8994
+ sourceScrollOffsetRef.current.left += delta;
8995
+ }
8996
+ }
8997
+ fireDragMove();
8998
+ };
8999
+ scrollContainer?.addEventListener("scroll", onContainerScroll);
9000
+ const dragStrategy = props.dragStrategy ?? "proxy";
9001
+ const useProxy = dragStrategy === "proxy" && !props.renderDragProxy;
9002
+ const useRenderProxy = dragStrategy === "proxy" && !!props.renderDragProxy;
9003
+ const proxyMove = props.onDragProxyMove ?? defaultDragProxyMove;
8598
9004
  const onPointerMove = (e2) => {
9005
+ lastPointer = { left: e2.clientX, top: e2.clientY };
8599
9006
  if (!dragOperation) {
8600
9007
  dragOperation = DragManager.startDrag(
8601
9008
  {
@@ -8605,15 +9012,84 @@ var DragList = (props) => {
8605
9012
  },
8606
9013
  initialCoords
8607
9014
  );
9015
+ if (dragItemNode && useProxy) {
9016
+ const rect = dragItemNode.getBoundingClientRect();
9017
+ let cachedProxy = null;
9018
+ const setupParams = {
9019
+ dragItemNode,
9020
+ dragItemId: `${dragItemId2}`,
9021
+ initialRect: rect,
9022
+ initialCoords,
9023
+ get proxyElement() {
9024
+ if (!cachedProxy) {
9025
+ cachedProxy = createDefaultProxy(dragItemNode, rect);
9026
+ }
9027
+ return cachedProxy;
9028
+ }
9029
+ };
9030
+ const setupResult = props.onDragProxySetup?.(setupParams);
9031
+ const proxyElement = setupResult?.proxyElement ?? setupParams.proxyElement;
9032
+ dragItemNode.style.visibility = "hidden";
9033
+ proxyStateRef.current = {
9034
+ proxyElement,
9035
+ originalNode: dragItemNode,
9036
+ dragItemId: `${dragItemId2}`,
9037
+ initialRect: rect,
9038
+ cleanup: setupResult?.cleanup
9039
+ };
9040
+ }
9041
+ if (dragItemNode && useRenderProxy) {
9042
+ const rect = dragItemNode.getBoundingClientRect();
9043
+ dragItemNode.style.visibility = "hidden";
9044
+ proxyStateRef.current = {
9045
+ proxyElement: dragItemNode,
9046
+ originalNode: dragItemNode,
9047
+ dragItemId: `${dragItemId2}`,
9048
+ initialRect: rect,
9049
+ // Portal handles its own DOM; only restore visibility.
9050
+ cleanup: () => {
9051
+ }
9052
+ };
9053
+ setDragProxyRenderState({
9054
+ dragItemId: `${dragItemId2}`,
9055
+ initialRect: rect,
9056
+ dx: 0,
9057
+ dy: 0
9058
+ });
9059
+ }
8608
9060
  }
8609
- dragOperation.move({
9061
+ const dx = e2.clientX - initialCoords.left;
9062
+ const dy = e2.clientY - initialCoords.top;
9063
+ if (useRenderProxy) {
9064
+ setDragProxyRenderState(
9065
+ (prev) => prev ? { ...prev, dx, dy } : prev
9066
+ );
9067
+ } else {
9068
+ const proxyState = proxyStateRef.current;
9069
+ if (proxyState) {
9070
+ proxyMove({ proxyElement: proxyState.proxyElement, dx, dy });
9071
+ }
9072
+ }
9073
+ autoScroller.updatePointer({
8610
9074
  left: e2.clientX,
8611
9075
  top: e2.clientY
8612
9076
  });
9077
+ fireDragMove();
8613
9078
  };
8614
9079
  const onPointerUp = () => {
9080
+ autoScroller.stop();
9081
+ scrollContainer?.removeEventListener("scroll", onContainerScroll);
8615
9082
  getGlobal().removeEventListener("pointermove", onPointerMove);
9083
+ if (useRenderProxy) {
9084
+ setDragProxyRenderState(
9085
+ (prev) => prev ? { ...prev, dragItemId: null } : prev
9086
+ );
9087
+ requestAnimationFrame(() => {
9088
+ setDragProxyRenderState(null);
9089
+ });
9090
+ }
8616
9091
  if (!dragOperation) {
9092
+ cleanupProxy(proxyStateRef);
8617
9093
  setInteractionTarget(null);
8618
9094
  return;
8619
9095
  }
@@ -8627,7 +9103,11 @@ var DragList = (props) => {
8627
9103
  props.orientation,
8628
9104
  props.dragListId,
8629
9105
  props.acceptDropsFrom,
8630
- props.removeOnDropOutside
9106
+ props.removeOnDropOutside,
9107
+ props.dragStrategy,
9108
+ props.renderDragProxy,
9109
+ props.onDragProxySetup,
9110
+ props.onDragProxyMove
8631
9111
  ]
8632
9112
  );
8633
9113
  const dragging = !!dragItemId;
@@ -8662,10 +9142,14 @@ var DragList = (props) => {
8662
9142
  [DRAG_LIST_ATTRIBUTE]: props.dragListId
8663
9143
  };
8664
9144
  const children = typeof props.children === "function" ? props.children(domProps, contextValue) : props.children;
8665
- return /* @__PURE__ */ React33.createElement(DragListContext.Provider, { value: contextValue }, children);
9145
+ return /* @__PURE__ */ React33.createElement(DragListContext.Provider, { value: contextValue }, children, dragProxyRenderState && props.renderDragProxy ? props.renderDragProxy({
9146
+ ...dragProxyRenderState,
9147
+ ref: proxyRefCallback
9148
+ }) : null);
8666
9149
  };
8667
9150
  var DRAG_LIST_ATTRIBUTE = "data-drag-list-id";
8668
9151
  var DRAG_ITEM_ATTRIBUTE = "data-drag-item-id";
9152
+ var DRAG_ITEM_LIST_ATTRIBUTE = "data-drag-item-list-id";
8669
9153
  var DRAG_ITEM_SELECTOR = `[${DRAG_ITEM_ATTRIBUTE}]`;
8670
9154
  var DragItemContext = React33.createContext({
8671
9155
  dragItemId: "",
@@ -8684,21 +9168,30 @@ var DraggableItem = (props) => {
8684
9168
  dragSourceListId,
8685
9169
  dropTargetListId
8686
9170
  } = useDragListContext();
8687
- const active = dragSourceListId === dragListId && dragItemId === `${props.id}`;
9171
+ const dragItemListId = props.dragListId ?? dragListId;
9172
+ const active = dragSourceListId === dragItemListId && dragItemId === `${props.id}`;
8688
9173
  const contextValue = React33.useMemo(
8689
9174
  () => ({
8690
9175
  dragItemId: props.id,
8691
9176
  active,
8692
- dragListId,
9177
+ dragListId: dragItemListId,
8693
9178
  draggingInProgress,
8694
9179
  dragSourceListId,
8695
9180
  dropTargetListId
8696
9181
  }),
8697
- [props.id, active, draggingInProgress, dragSourceListId, dropTargetListId]
9182
+ [
9183
+ props.id,
9184
+ active,
9185
+ dragItemListId,
9186
+ draggingInProgress,
9187
+ dragSourceListId,
9188
+ dropTargetListId
9189
+ ]
8698
9190
  );
8699
9191
  const domProps = {
8700
9192
  // @ts-ignore
8701
- "data-drag-item-id": `${props.id}`,
9193
+ [DRAG_ITEM_ATTRIBUTE]: `${props.id}`,
9194
+ [DRAG_ITEM_LIST_ATTRIBUTE]: dragItemListId,
8702
9195
  onPointerDown: onDragItemPointerDown,
8703
9196
  className: join(
8704
9197
  "DraggableItem",
@@ -13366,6 +13859,7 @@ function InfiniteTableInternalHeaderFn(props) {
13366
13859
  {
13367
13860
  orientation: "horizontal",
13368
13861
  dragListId: "header",
13862
+ dragStrategy: "inline",
13369
13863
  onDrop: emptyFn3,
13370
13864
  updatePosition: emptyFn3
13371
13865
  },
@@ -13617,7 +14111,8 @@ var InfiniteHeaderCellDataAttributes = keyMirror({
13617
14111
  "data-column-id": "",
13618
14112
  "data-sort": "",
13619
14113
  "data-sort-index": "",
13620
- [DRAG_ITEM_ATTRIBUTE]: ""
14114
+ [DRAG_ITEM_ATTRIBUTE]: "",
14115
+ [DRAG_ITEM_LIST_ATTRIBUTE]: ""
13621
14116
  });
13622
14117
  function InfiniteTableHeaderCellFn(props) {
13623
14118
  const column = props.column;
@@ -13932,6 +14427,7 @@ function InfiniteTableHeaderCellFn(props) {
13932
14427
  "data-field": `${column.field || ""}`,
13933
14428
  "data-column-id": column.id,
13934
14429
  [DRAG_ITEM_ATTRIBUTE]: column.id,
14430
+ [DRAG_ITEM_LIST_ATTRIBUTE]: "header",
13935
14431
  "data-header-align": align2,
13936
14432
  "data-name": "HeaderCell",
13937
14433
  "data-sort": column.computedSortedAsc ? "asc" : column.computedSortedDesc ? "desc" : "none",
@@ -13985,7 +14481,7 @@ function InfiniteTableHeaderCellFn(props) {
13985
14481
  ),
13986
14482
  currentHeader
13987
14483
  );
13988
- draggingProxy = (0, import_react_dom.createPortal)(draggingProxy, portalDOMRef.current);
14484
+ draggingProxy = (0, import_react_dom2.createPortal)(draggingProxy, portalDOMRef.current);
13989
14485
  }
13990
14486
  return /* @__PURE__ */ React51.createElement(ContextProvider, { value: renderParam }, /* @__PURE__ */ React51.createElement(
13991
14487
  InfiniteTableCell,
@@ -26438,7 +26934,7 @@ var useLicense = (licenseKey = "") => {
26438
26934
  }
26439
26935
  let valid2 = isValidLicense(licenseKey, {
26440
26936
  publishedAt: 1624970570587,
26441
- version: "8.0.1"
26937
+ version: "8.0.3"
26442
26938
  });
26443
26939
  if (!licenseKey && !valid2 && isInsidePlayground) {
26444
26940
  return true;
@@ -27303,7 +27799,7 @@ var import_react59 = require("react");
27303
27799
  // src/components/hooks/useOverlay/index.tsx
27304
27800
  var React57 = __toESM(require("react"));
27305
27801
  var import_react55 = require("react");
27306
- var import_react_dom2 = require("react-dom");
27802
+ var import_react_dom3 = require("react-dom");
27307
27803
 
27308
27804
  // src/utils/pageGeometry/alignment/index.ts
27309
27805
  function isHTMLElement(v) {
@@ -27555,7 +28051,7 @@ function useOverlayPortal(content, portalContainer) {
27555
28051
  }
27556
28052
  getContainer();
27557
28053
  }, [portalContainer]);
27558
- return portalContainer ? container ? (0, import_react_dom2.createPortal)(content, container) : (
28054
+ return portalContainer ? container ? (0, import_react_dom3.createPortal)(content, container) : (
27559
28055
  // we're probably still fetching the container
27560
28056
  /* @__PURE__ */ React57.createElement(React57.Fragment, null)
27561
28057
  ) : portalContainer === null || portalContainer === false ? content : /* @__PURE__ */ React57.createElement(DefaultOverlayPortal, null, content);
@@ -30525,6 +31021,7 @@ function GroupingToolbar(props) {
30525
31021
  dragListId: GROUPING_TOOLBAR_DRAG_LIST_ID,
30526
31022
  acceptDropsFrom: ["header", GROUPING_TOOLBAR_DRAG_LIST_ID],
30527
31023
  onDrop,
31024
+ dragStrategy: "inline",
30528
31025
  onAcceptDrop,
30529
31026
  shouldAcceptDrop
30530
31027
  },
@@ -32270,7 +32767,7 @@ var FlashingColumnCell = createFlashingColumnCellComponent();
32270
32767
  // src/components/HeadlessTable/MatrixDebugger.tsx
32271
32768
  var React82 = __toESM(require("react"));
32272
32769
  var import_react77 = require("react");
32273
- var import_react_dom3 = require("react-dom");
32770
+ var import_react_dom4 = require("react-dom");
32274
32771
  function INTERNAL_MatrixDebugger(props) {
32275
32772
  const [getState, setGetState] = React82.useState(null);
32276
32773
  (0, import_react77.useEffect)(() => {
@@ -32310,7 +32807,7 @@ function MatrixDebuggerUI() {
32310
32807
  const columnsIndexes = cellManager.getColumnsWithCells();
32311
32808
  const domRef = (0, import_react77.useRef)(null);
32312
32809
  const displayTimeoutRef = (0, import_react77.useRef)(null);
32313
- return /* @__PURE__ */ React82.createElement("div", { style: { overflow: "auto" } }, (0, import_react_dom3.createPortal)(
32810
+ return /* @__PURE__ */ React82.createElement("div", { style: { overflow: "auto" } }, (0, import_react_dom4.createPortal)(
32314
32811
  /* @__PURE__ */ React82.createElement(
32315
32812
  "div",
32316
32813
  {
@@ -32402,6 +32899,7 @@ var components = {
32402
32899
  };
32403
32900
  // Annotate the CommonJS export names for ESM import in node:
32404
32901
  0 && (module.exports = {
32902
+ AutoScroller,
32405
32903
  CellSelectionState,
32406
32904
  DRAG_ITEM_ATTRIBUTE,
32407
32905
  DataClient,
@@ -32430,9 +32928,11 @@ var components = {
32430
32928
  WeakFixedSizeSet,
32431
32929
  alignNode,
32432
32930
  components,
32931
+ createDefaultProxy,
32433
32932
  createFlashingColumnCellComponent,
32434
32933
  debounce,
32435
32934
  debug,
32935
+ defaultDragProxyMove,
32436
32936
  defaultFilterTypes,
32437
32937
  eventMatchesKeyboardShortcut,
32438
32938
  filterDataArray,