@infinite-table/infinite-react 10.1.5 → 10.2.0
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/README.md +4 -2
- package/index.d.ts +158 -135
- package/index.dev.js +677 -524
- package/index.dev.mjs +687 -534
- package/index.js +8 -8
- package/index.mjs +8 -8
- package/package.json +2 -2
- package/theme/balsam.css +209 -19
- package/theme/minimalist.css +205 -33
- package/theme/ocean.css +205 -29
- package/theme/shadcn.css +102 -7
package/index.dev.js
CHANGED
|
@@ -1598,6 +1598,7 @@ var DevToolsTracks = {
|
|
|
1598
1598
|
};
|
|
1599
1599
|
|
|
1600
1600
|
// src/utils/devTools/index.ts
|
|
1601
|
+
var MEASURE_NAME_PREFIX = "\u200B";
|
|
1601
1602
|
var DevToolsMarker = class _DevToolsMarker {
|
|
1602
1603
|
constructor(debugId) {
|
|
1603
1604
|
this.debugId = debugId;
|
|
@@ -1635,7 +1636,8 @@ var DevToolsMarker = class _DevToolsMarker {
|
|
|
1635
1636
|
const tooltip = markerDetails.tooltip || this.markerDetails.tooltip;
|
|
1636
1637
|
const label = markerDetails.label || this.markerDetails.label || "Unknown";
|
|
1637
1638
|
const track = markerDetails.track || this.markerDetails.track || "Unknown";
|
|
1638
|
-
|
|
1639
|
+
const measureName = MEASURE_NAME_PREFIX + label;
|
|
1640
|
+
performance.measure(measureName, {
|
|
1639
1641
|
start,
|
|
1640
1642
|
end,
|
|
1641
1643
|
detail: {
|
|
@@ -1649,6 +1651,7 @@ var DevToolsMarker = class _DevToolsMarker {
|
|
|
1649
1651
|
}
|
|
1650
1652
|
}
|
|
1651
1653
|
});
|
|
1654
|
+
performance.clearMeasures(measureName);
|
|
1652
1655
|
return this;
|
|
1653
1656
|
};
|
|
1654
1657
|
this.debugId = debugId;
|
|
@@ -5329,6 +5332,7 @@ function reorderColumnsOnDrag(params) {
|
|
|
5329
5332
|
setProxyPosition,
|
|
5330
5333
|
setDragColumnOutside,
|
|
5331
5334
|
getCurrentDragSourceAndTarget,
|
|
5335
|
+
groupingToolbarDragListId,
|
|
5332
5336
|
api: imperativeApi,
|
|
5333
5337
|
horizontalLayoutPageIndex,
|
|
5334
5338
|
pageWidth
|
|
@@ -5621,7 +5625,7 @@ function reorderColumnsOnDrag(params) {
|
|
|
5621
5625
|
},
|
|
5622
5626
|
onMove(mousePosition) {
|
|
5623
5627
|
const currentColHeaderRect = updatePositionAndDiff(mousePosition);
|
|
5624
|
-
if (getCurrentDragSourceAndTarget().dropTargetListId ===
|
|
5628
|
+
if (getCurrentDragSourceAndTarget().dropTargetListId === groupingToolbarDragListId || allowColumnHideOnDrag && !acceptDropToReorderRect.containsPoint(
|
|
5625
5629
|
currentColHeaderRect.getCenter()
|
|
5626
5630
|
)) {
|
|
5627
5631
|
if (allowColumnHideOnDrag) {
|
|
@@ -5958,17 +5962,18 @@ var _DragManager = class _DragManager {
|
|
|
5958
5962
|
return _DragManager.emitter.on(event, callback);
|
|
5959
5963
|
}
|
|
5960
5964
|
static registerDragInteractionTarget(dragInteractionTarget) {
|
|
5961
|
-
|
|
5965
|
+
const { listId } = dragInteractionTarget;
|
|
5966
|
+
const current = _DragManager.dragInteractionTargetsMap.get(listId);
|
|
5967
|
+
if (current && current !== dragInteractionTarget) {
|
|
5962
5968
|
console.warn(
|
|
5963
|
-
`DragInteractionTarget with listId ${
|
|
5969
|
+
`DragInteractionTarget with listId ${listId} already registered`
|
|
5964
5970
|
);
|
|
5965
5971
|
return;
|
|
5966
5972
|
}
|
|
5967
|
-
|
|
5968
|
-
|
|
5969
|
-
dragInteractionTarget
|
|
5970
|
-
|
|
5971
|
-
_DragManager.emit("register", dragInteractionTarget);
|
|
5973
|
+
if (!current) {
|
|
5974
|
+
_DragManager.dragInteractionTargetsMap.set(listId, dragInteractionTarget);
|
|
5975
|
+
_DragManager.emit("register", dragInteractionTarget);
|
|
5976
|
+
}
|
|
5972
5977
|
return () => {
|
|
5973
5978
|
_DragManager.unregisterDragInteractionTarget(dragInteractionTarget);
|
|
5974
5979
|
};
|
|
@@ -5982,13 +5987,11 @@ var _DragManager = class _DragManager {
|
|
|
5982
5987
|
if (!dragInteractionTarget) {
|
|
5983
5988
|
return;
|
|
5984
5989
|
}
|
|
5985
|
-
|
|
5986
|
-
|
|
5987
|
-
`DragInteractionTarget with listId ${dragInteractionTarget.listId} not found`
|
|
5988
|
-
);
|
|
5990
|
+
const { listId } = dragInteractionTarget;
|
|
5991
|
+
if (_DragManager.dragInteractionTargetsMap.get(listId) !== dragInteractionTarget) {
|
|
5989
5992
|
return;
|
|
5990
5993
|
}
|
|
5991
|
-
_DragManager.dragInteractionTargetsMap.delete(
|
|
5994
|
+
_DragManager.dragInteractionTargetsMap.delete(listId);
|
|
5992
5995
|
dragInteractionTarget.unregister();
|
|
5993
5996
|
_DragManager.emit("unregister", dragInteractionTarget);
|
|
5994
5997
|
}
|
|
@@ -6085,6 +6088,14 @@ var _DragManager = class _DragManager {
|
|
|
6085
6088
|
let insideTargetEvent = null;
|
|
6086
6089
|
const events = [];
|
|
6087
6090
|
_DragManager.withDragMove(dragOperation, (interactionTarget, { event: event2 }) => {
|
|
6091
|
+
if (dragOperation.cancelled) {
|
|
6092
|
+
event2 = {
|
|
6093
|
+
...event2,
|
|
6094
|
+
dropTargetListId: null,
|
|
6095
|
+
dropIndex: -1,
|
|
6096
|
+
outside: false
|
|
6097
|
+
};
|
|
6098
|
+
}
|
|
6088
6099
|
interactionTarget.drop(event2);
|
|
6089
6100
|
events.push(event2);
|
|
6090
6101
|
if (!event2.outside) {
|
|
@@ -6150,6 +6161,11 @@ var DragOperation = class extends EventEmitter {
|
|
|
6150
6161
|
constructor(options) {
|
|
6151
6162
|
super(options.listeners);
|
|
6152
6163
|
this.phase = "start";
|
|
6164
|
+
/**
|
|
6165
|
+
* Whether the drag was cancelled - the browser took the pointer away -
|
|
6166
|
+
* rather than dropped.
|
|
6167
|
+
*/
|
|
6168
|
+
this.cancelled = false;
|
|
6153
6169
|
this.currentOffset = {
|
|
6154
6170
|
top: 0,
|
|
6155
6171
|
left: 0
|
|
@@ -6178,6 +6194,13 @@ var DragOperation = class extends EventEmitter {
|
|
|
6178
6194
|
this.phase = "drop";
|
|
6179
6195
|
this.emit("drop", this);
|
|
6180
6196
|
}
|
|
6197
|
+
/**
|
|
6198
|
+
* Ends the drag without a drop.
|
|
6199
|
+
*/
|
|
6200
|
+
cancel() {
|
|
6201
|
+
this.cancelled = true;
|
|
6202
|
+
this.drop();
|
|
6203
|
+
}
|
|
6181
6204
|
move(point) {
|
|
6182
6205
|
if (this.phase !== "start" && this.phase !== "move") {
|
|
6183
6206
|
return;
|
|
@@ -6216,6 +6239,11 @@ var DragDropProviderContext = React20.createContext({
|
|
|
6216
6239
|
var useDragDropProvider = () => {
|
|
6217
6240
|
return React20.useContext(DragDropProviderContext);
|
|
6218
6241
|
};
|
|
6242
|
+
var DragDropProviderIdContext = React20.createContext("");
|
|
6243
|
+
var useDragListId = (name) => {
|
|
6244
|
+
const providerId = React20.useContext(DragDropProviderIdContext);
|
|
6245
|
+
return providerId ? `${name}-${providerId}` : name;
|
|
6246
|
+
};
|
|
6219
6247
|
var DragDropProvider = (props) => {
|
|
6220
6248
|
const [state, setState] = React20.useState({
|
|
6221
6249
|
dragSourceListId: null,
|
|
@@ -6223,6 +6251,7 @@ var DragDropProvider = (props) => {
|
|
|
6223
6251
|
dragItemId: "",
|
|
6224
6252
|
status: "accepted"
|
|
6225
6253
|
});
|
|
6254
|
+
const providerId = React20.useId();
|
|
6226
6255
|
const stateRef = React20.useRef(state);
|
|
6227
6256
|
stateRef.current = state;
|
|
6228
6257
|
const getCurrentDragSourceAndTarget = React20.useCallback(() => {
|
|
@@ -6280,9 +6309,13 @@ var DragDropProvider = (props) => {
|
|
|
6280
6309
|
removeDragDrop();
|
|
6281
6310
|
};
|
|
6282
6311
|
}, [DragManager, setState]);
|
|
6283
|
-
return /* @__PURE__ */ React20.createElement(DragDropProviderContext.Provider, { value: contextValue }, typeof props.children === "function" ? props.children(contextValue) : props.children);
|
|
6312
|
+
return /* @__PURE__ */ React20.createElement(DragDropProviderIdContext.Provider, { value: providerId }, /* @__PURE__ */ React20.createElement(DragDropProviderContext.Provider, { value: contextValue }, typeof props.children === "function" ? props.children(contextValue) : props.children));
|
|
6284
6313
|
};
|
|
6285
6314
|
|
|
6315
|
+
// src/components/InfiniteTable/components/draggable/dragListNames.ts
|
|
6316
|
+
var HEADER_DRAG_LIST_NAME = "header";
|
|
6317
|
+
var GROUPING_TOOLBAR_DRAG_LIST_NAME = "grouping-toolbar";
|
|
6318
|
+
|
|
6286
6319
|
// src/components/InfiniteTable/components/InfiniteTableBody/bodyClassName.ts
|
|
6287
6320
|
var InfiniteTableBodyClassName = `${rootClassName}Body`;
|
|
6288
6321
|
var getBodyNode = (root) => {
|
|
@@ -6329,6 +6362,9 @@ var useColumnPointerEvents = ({
|
|
|
6329
6362
|
const [proxyPosition, setProxyPosition] = (0, import_react16.useState)(null);
|
|
6330
6363
|
const [dragColumnOutside, setDragColumnOutside] = (0, import_react16.useState)(false);
|
|
6331
6364
|
const { getCurrentDragSourceAndTarget } = useDragDropProvider();
|
|
6365
|
+
const groupingToolbarDragListId = useDragListId(
|
|
6366
|
+
GROUPING_TOOLBAR_DRAG_LIST_NAME
|
|
6367
|
+
);
|
|
6332
6368
|
const { getComputed, getState, api, computedDraggable, rootRef, actions } = useInfiniteTableSelector((ctx) => {
|
|
6333
6369
|
return {
|
|
6334
6370
|
actions: ctx.actions,
|
|
@@ -6405,6 +6441,7 @@ var useColumnPointerEvents = ({
|
|
|
6405
6441
|
dragColumnHeaderTargetRect: targetRect,
|
|
6406
6442
|
dragColumnId: columnId,
|
|
6407
6443
|
getCurrentDragSourceAndTarget,
|
|
6444
|
+
groupingToolbarDragListId,
|
|
6408
6445
|
api,
|
|
6409
6446
|
infiniteDOMNode: rootRef.current,
|
|
6410
6447
|
setProxyPosition,
|
|
@@ -6545,7 +6582,7 @@ var useColumnPointerEvents = ({
|
|
|
6545
6582
|
target.addEventListener("pointerup", onPointerUp);
|
|
6546
6583
|
target.setPointerCapture(e.pointerId);
|
|
6547
6584
|
},
|
|
6548
|
-
[columnId, horizontalLayoutPageIndex]
|
|
6585
|
+
[columnId, horizontalLayoutPageIndex, groupingToolbarDragListId]
|
|
6549
6586
|
);
|
|
6550
6587
|
return {
|
|
6551
6588
|
onPointerDown: computedDraggable ? onPointerDown : defaultPointerDown,
|
|
@@ -12482,7 +12519,7 @@ function dampenByTime(proposedScroll, dragStartTime, config) {
|
|
|
12482
12519
|
return MIN_SCROLL;
|
|
12483
12520
|
}
|
|
12484
12521
|
const pct = (runTime - accelerateAt) / (stopDampeningAt - accelerateAt);
|
|
12485
|
-
return Math.ceil(proposedScroll * config.ease(pct));
|
|
12522
|
+
return Math.max(MIN_SCROLL, Math.ceil(proposedScroll * config.ease(pct)));
|
|
12486
12523
|
}
|
|
12487
12524
|
function getScrollForAxis(point, containerStart, containerEnd, containerSize, config, dragStartTime, shouldUseDampening) {
|
|
12488
12525
|
if (point < containerStart || point > containerEnd) {
|
|
@@ -12630,20 +12667,12 @@ var AutoScroller = class {
|
|
|
12630
12667
|
}
|
|
12631
12668
|
};
|
|
12632
12669
|
|
|
12633
|
-
// src/components/InfiniteTable/components/draggable/
|
|
12634
|
-
var
|
|
12635
|
-
|
|
12636
|
-
|
|
12637
|
-
|
|
12638
|
-
|
|
12639
|
-
dragListId: "",
|
|
12640
|
-
status: "accepted",
|
|
12641
|
-
dragSourceListId: null,
|
|
12642
|
-
dropTargetListId: null
|
|
12643
|
-
});
|
|
12644
|
-
var useDragListContext = () => {
|
|
12645
|
-
return React31.useContext(DragListContext);
|
|
12646
|
-
};
|
|
12670
|
+
// src/components/InfiniteTable/components/draggable/dragListController.ts
|
|
12671
|
+
var DRAG_LIST_ATTRIBUTE = "data-drag-list-id";
|
|
12672
|
+
var DRAG_ITEM_ATTRIBUTE = "data-drag-item-id";
|
|
12673
|
+
var DRAG_ITEM_LIST_ATTRIBUTE = "data-drag-item-list-id";
|
|
12674
|
+
var DRAG_ITEM_SELECTOR = `[${DRAG_ITEM_ATTRIBUTE}]`;
|
|
12675
|
+
var RETURN_NULL = () => null;
|
|
12647
12676
|
var defaultUpdatePosition = (options) => {
|
|
12648
12677
|
const { node, offset } = options;
|
|
12649
12678
|
if (!offset) {
|
|
@@ -12664,8 +12693,6 @@ function getDraggableItemNodes(domRef, dragListId) {
|
|
|
12664
12693
|
}
|
|
12665
12694
|
function getDraggableItems(domRef, dragListId) {
|
|
12666
12695
|
const dragItems = getDraggableItemNodes(domRef, dragListId);
|
|
12667
|
-
if (!dragItems || dragItems.length === 0) {
|
|
12668
|
-
}
|
|
12669
12696
|
const draggableItems = Array.from(dragItems).map((item) => {
|
|
12670
12697
|
const id = getDraggableItemId(item);
|
|
12671
12698
|
const rect = item.getBoundingClientRect();
|
|
@@ -12713,55 +12740,54 @@ function createInteractionTarget(params) {
|
|
|
12713
12740
|
const target = new DragInteractionTarget(getInteractionTargetData(params));
|
|
12714
12741
|
return target;
|
|
12715
12742
|
}
|
|
12716
|
-
function
|
|
12717
|
-
const
|
|
12718
|
-
|
|
12719
|
-
const setInteractionTarget = (0, import_react24.useCallback)(
|
|
12720
|
-
(interactionTarget2) => {
|
|
12721
|
-
if (interactionTarget2) {
|
|
12722
|
-
DragManager.registerDragInteractionTarget(interactionTarget2);
|
|
12723
|
-
} else {
|
|
12724
|
-
const currentInteractionTarget = getInteractionTarget();
|
|
12725
|
-
if (currentInteractionTarget) {
|
|
12726
|
-
DragManager.unregisterDragInteractionTarget(currentInteractionTarget);
|
|
12727
|
-
}
|
|
12728
|
-
}
|
|
12729
|
-
doSetInteractionTarget(interactionTarget2);
|
|
12730
|
-
},
|
|
12731
|
-
[]
|
|
12743
|
+
function findDragListElement(domRef, dragListId) {
|
|
12744
|
+
const dragList = document.querySelector(
|
|
12745
|
+
`[${DRAG_LIST_ATTRIBUTE}="${dragListId}"]`
|
|
12732
12746
|
);
|
|
12733
|
-
|
|
12734
|
-
|
|
12735
|
-
|
|
12736
|
-
|
|
12737
|
-
|
|
12738
|
-
|
|
12739
|
-
|
|
12740
|
-
|
|
12741
|
-
|
|
12742
|
-
|
|
12743
|
-
|
|
12744
|
-
|
|
12745
|
-
|
|
12746
|
-
|
|
12747
|
-
|
|
12748
|
-
|
|
12749
|
-
|
|
12750
|
-
|
|
12751
|
-
|
|
12752
|
-
|
|
12753
|
-
|
|
12754
|
-
|
|
12755
|
-
|
|
12756
|
-
|
|
12757
|
-
|
|
12758
|
-
}
|
|
12759
|
-
|
|
12760
|
-
|
|
12761
|
-
|
|
12762
|
-
|
|
12763
|
-
|
|
12764
|
-
|
|
12747
|
+
if (dragList) {
|
|
12748
|
+
domRef.current = dragList;
|
|
12749
|
+
} else {
|
|
12750
|
+
console.warn(
|
|
12751
|
+
`DragList with id "${dragListId}" not found. You're probably not spreading the domProps to the parent element. Make sure you also include the "className" prop.`
|
|
12752
|
+
);
|
|
12753
|
+
}
|
|
12754
|
+
}
|
|
12755
|
+
function replaceRegisteredInteractionTarget(registeredTargetRef, interactionTarget) {
|
|
12756
|
+
const registeredTarget = registeredTargetRef.current;
|
|
12757
|
+
if (registeredTarget && registeredTarget !== interactionTarget) {
|
|
12758
|
+
DragManager.unregisterDragInteractionTarget(registeredTarget);
|
|
12759
|
+
}
|
|
12760
|
+
registeredTargetRef.current = interactionTarget;
|
|
12761
|
+
if (interactionTarget) {
|
|
12762
|
+
DragManager.registerDragInteractionTarget(interactionTarget);
|
|
12763
|
+
}
|
|
12764
|
+
}
|
|
12765
|
+
function acceptDragsFromOtherLists(options) {
|
|
12766
|
+
const { getProps, domRef, setInteractionTarget } = options;
|
|
12767
|
+
return DragManager.on("register", (interactionTarget) => {
|
|
12768
|
+
const { dragListId, acceptDropsFrom, orientation, shouldAcceptDrop } = getProps();
|
|
12769
|
+
const interactionTargetData = interactionTarget.getData();
|
|
12770
|
+
if (!interactionTargetData.initial) {
|
|
12771
|
+
return;
|
|
12772
|
+
}
|
|
12773
|
+
if (interactionTargetData.listId === dragListId) {
|
|
12774
|
+
return;
|
|
12775
|
+
}
|
|
12776
|
+
if (acceptDropsFrom?.includes(interactionTargetData.listId)) {
|
|
12777
|
+
const newInteractionTarget = createInteractionTarget({
|
|
12778
|
+
domRef,
|
|
12779
|
+
orientation,
|
|
12780
|
+
dragListId,
|
|
12781
|
+
initial: false,
|
|
12782
|
+
acceptDropsFrom,
|
|
12783
|
+
shouldAcceptDrop
|
|
12784
|
+
});
|
|
12785
|
+
interactionTarget.once("unregister", () => {
|
|
12786
|
+
setInteractionTarget(null);
|
|
12787
|
+
});
|
|
12788
|
+
setInteractionTarget(newInteractionTarget);
|
|
12789
|
+
}
|
|
12790
|
+
});
|
|
12765
12791
|
}
|
|
12766
12792
|
function createDefaultProxy(dragItemNode, initialRect) {
|
|
12767
12793
|
const proxy = dragItemNode.cloneNode(true);
|
|
@@ -12797,6 +12823,444 @@ function cleanupProxy(proxyStateRef) {
|
|
|
12797
12823
|
state.originalNode.style.visibility = "";
|
|
12798
12824
|
proxyStateRef.current = null;
|
|
12799
12825
|
}
|
|
12826
|
+
function getDragItemNodes(dragItemsRef, domRef, dragListId) {
|
|
12827
|
+
let dragItems = dragItemsRef.current;
|
|
12828
|
+
if (!dragItems || dragItems.length === 0) {
|
|
12829
|
+
dragItems = getDraggableItemNodes(domRef, dragListId);
|
|
12830
|
+
dragItemsRef.current = dragItems;
|
|
12831
|
+
}
|
|
12832
|
+
return dragItems;
|
|
12833
|
+
}
|
|
12834
|
+
function bindInteractionTarget(interactionTarget, options) {
|
|
12835
|
+
const {
|
|
12836
|
+
dragListId,
|
|
12837
|
+
orientation,
|
|
12838
|
+
domRef,
|
|
12839
|
+
proxyStateRef,
|
|
12840
|
+
sourceScrollOffsetRef,
|
|
12841
|
+
dragItemsRef,
|
|
12842
|
+
getDragItems,
|
|
12843
|
+
getOnDrop,
|
|
12844
|
+
getOnAcceptDrop,
|
|
12845
|
+
getOnRemove,
|
|
12846
|
+
getUpdatePosition,
|
|
12847
|
+
updateDragOperationSourceAndTarget,
|
|
12848
|
+
updateDragProxyRenderState
|
|
12849
|
+
} = options;
|
|
12850
|
+
const removeOnDragStart = interactionTarget.on(
|
|
12851
|
+
"start",
|
|
12852
|
+
({ dragItem, dragSourceListId, dropTargetListId }) => {
|
|
12853
|
+
updateDragOperationSourceAndTarget({
|
|
12854
|
+
dragSourceListId,
|
|
12855
|
+
dropTargetListId,
|
|
12856
|
+
dragItemId: dragItem.id,
|
|
12857
|
+
status: "accepted"
|
|
12858
|
+
});
|
|
12859
|
+
}
|
|
12860
|
+
);
|
|
12861
|
+
const removeOnDragMove = interactionTarget.on(
|
|
12862
|
+
"move",
|
|
12863
|
+
({ offsetsForItems, items, status, dragItem }) => {
|
|
12864
|
+
if (status === "rejected") {
|
|
12865
|
+
return;
|
|
12866
|
+
}
|
|
12867
|
+
const dragItems = getDragItems();
|
|
12868
|
+
const updatePosition = getUpdatePosition();
|
|
12869
|
+
const proxyState = proxyStateRef.current;
|
|
12870
|
+
items.forEach((item, index) => {
|
|
12871
|
+
let offset = offsetsForItems[index];
|
|
12872
|
+
const node = dragItems[index];
|
|
12873
|
+
if (!node) {
|
|
12874
|
+
return;
|
|
12875
|
+
}
|
|
12876
|
+
if (proxyState && item.id === proxyState.dragItemId) {
|
|
12877
|
+
return;
|
|
12878
|
+
}
|
|
12879
|
+
if (!proxyState && item.id === dragItem.id) {
|
|
12880
|
+
const scrollOffset = sourceScrollOffsetRef.current;
|
|
12881
|
+
offset = {
|
|
12882
|
+
left: offset.left + scrollOffset.left,
|
|
12883
|
+
top: offset.top + scrollOffset.top
|
|
12884
|
+
};
|
|
12885
|
+
}
|
|
12886
|
+
updatePosition({
|
|
12887
|
+
id: item.id,
|
|
12888
|
+
node,
|
|
12889
|
+
offset
|
|
12890
|
+
});
|
|
12891
|
+
});
|
|
12892
|
+
}
|
|
12893
|
+
);
|
|
12894
|
+
const removeOnDragDrop = interactionTarget.on("drop", (params) => {
|
|
12895
|
+
const {
|
|
12896
|
+
sortedIndexes,
|
|
12897
|
+
dragIndex,
|
|
12898
|
+
dropIndex,
|
|
12899
|
+
dragItem,
|
|
12900
|
+
items,
|
|
12901
|
+
dragSourceListId,
|
|
12902
|
+
dropTargetListId,
|
|
12903
|
+
outside,
|
|
12904
|
+
status
|
|
12905
|
+
} = params;
|
|
12906
|
+
const dragItems = getDragItems();
|
|
12907
|
+
dragItemsRef.current = [];
|
|
12908
|
+
const onAcceptDrop = getOnAcceptDrop();
|
|
12909
|
+
const onRemove = getOnRemove();
|
|
12910
|
+
const onDrop = getOnDrop();
|
|
12911
|
+
const updatePosition = getUpdatePosition();
|
|
12912
|
+
items.forEach((item, index) => {
|
|
12913
|
+
const node = dragItems[index];
|
|
12914
|
+
if (!node) {
|
|
12915
|
+
return;
|
|
12916
|
+
}
|
|
12917
|
+
updatePosition({
|
|
12918
|
+
id: item.id,
|
|
12919
|
+
node,
|
|
12920
|
+
offset: null
|
|
12921
|
+
});
|
|
12922
|
+
});
|
|
12923
|
+
cleanupProxy(proxyStateRef);
|
|
12924
|
+
updateDragProxyRenderState((prev) => {
|
|
12925
|
+
if (!prev) return prev;
|
|
12926
|
+
requestAnimationFrame(() => updateDragProxyRenderState(RETURN_NULL));
|
|
12927
|
+
return { ...prev, dragItemId: null };
|
|
12928
|
+
});
|
|
12929
|
+
const accepted = status === "accepted";
|
|
12930
|
+
if (dragListId === dropTargetListId && dragSourceListId !== dragListId) {
|
|
12931
|
+
if (onAcceptDrop && accepted) {
|
|
12932
|
+
onAcceptDrop({
|
|
12933
|
+
dragItemId: dragItem.id,
|
|
12934
|
+
dragSourceListId,
|
|
12935
|
+
dropTargetListId,
|
|
12936
|
+
dragIndex,
|
|
12937
|
+
dropIndex,
|
|
12938
|
+
dropItemId: items[dropIndex]?.id
|
|
12939
|
+
});
|
|
12940
|
+
}
|
|
12941
|
+
}
|
|
12942
|
+
let callbackFn = null;
|
|
12943
|
+
if (dropIndex === -1 && dragSourceListId === dragListId && dropTargetListId === dragListId && outside) {
|
|
12944
|
+
callbackFn = onRemove;
|
|
12945
|
+
}
|
|
12946
|
+
if (dropIndex !== -1 && dropTargetListId === dragListId && dragSourceListId === dragListId) {
|
|
12947
|
+
callbackFn = onDrop;
|
|
12948
|
+
}
|
|
12949
|
+
if (callbackFn) {
|
|
12950
|
+
callbackFn?.(sortedIndexes, {
|
|
12951
|
+
dragIndex,
|
|
12952
|
+
dropIndex,
|
|
12953
|
+
dragItemId: items[dragIndex].id,
|
|
12954
|
+
dropItemId: items[dropIndex]?.id
|
|
12955
|
+
});
|
|
12956
|
+
}
|
|
12957
|
+
});
|
|
12958
|
+
let targetAutoScroller = null;
|
|
12959
|
+
let targetScrollContainer = null;
|
|
12960
|
+
let targetScrollHandler = null;
|
|
12961
|
+
let targetPointermoveHandler = null;
|
|
12962
|
+
if (!interactionTarget.getData().initial && domRef.current) {
|
|
12963
|
+
targetAutoScroller = new AutoScroller({
|
|
12964
|
+
orientation,
|
|
12965
|
+
onScroll: () => {
|
|
12966
|
+
}
|
|
12967
|
+
});
|
|
12968
|
+
targetAutoScroller.start(domRef.current);
|
|
12969
|
+
targetScrollContainer = targetAutoScroller.getScrollContainer();
|
|
12970
|
+
if (targetScrollContainer) {
|
|
12971
|
+
let lastScroll = orientation === "vertical" ? targetScrollContainer.scrollTop : targetScrollContainer.scrollLeft;
|
|
12972
|
+
targetScrollHandler = () => {
|
|
12973
|
+
const current = orientation === "vertical" ? targetScrollContainer.scrollTop : targetScrollContainer.scrollLeft;
|
|
12974
|
+
const delta = current - lastScroll;
|
|
12975
|
+
lastScroll = current;
|
|
12976
|
+
if (delta !== 0) {
|
|
12977
|
+
interactionTarget.adjustForScroll(delta);
|
|
12978
|
+
DragManager.retriggerMove();
|
|
12979
|
+
}
|
|
12980
|
+
};
|
|
12981
|
+
targetScrollContainer.addEventListener("scroll", targetScrollHandler);
|
|
12982
|
+
}
|
|
12983
|
+
targetPointermoveHandler = (e) => {
|
|
12984
|
+
targetAutoScroller.updatePointer({
|
|
12985
|
+
left: e.clientX,
|
|
12986
|
+
top: e.clientY
|
|
12987
|
+
});
|
|
12988
|
+
};
|
|
12989
|
+
getGlobal().addEventListener("pointermove", targetPointermoveHandler);
|
|
12990
|
+
}
|
|
12991
|
+
return () => {
|
|
12992
|
+
removeOnDragStart();
|
|
12993
|
+
removeOnDragMove();
|
|
12994
|
+
removeOnDragDrop();
|
|
12995
|
+
if (targetAutoScroller) {
|
|
12996
|
+
targetAutoScroller.stop();
|
|
12997
|
+
}
|
|
12998
|
+
if (targetScrollContainer && targetScrollHandler) {
|
|
12999
|
+
targetScrollContainer.removeEventListener("scroll", targetScrollHandler);
|
|
13000
|
+
}
|
|
13001
|
+
if (targetPointermoveHandler) {
|
|
13002
|
+
getGlobal().removeEventListener("pointermove", targetPointermoveHandler);
|
|
13003
|
+
}
|
|
13004
|
+
};
|
|
13005
|
+
}
|
|
13006
|
+
function startDragOnPointerDown(e, props, options) {
|
|
13007
|
+
const {
|
|
13008
|
+
dragListId,
|
|
13009
|
+
orientation,
|
|
13010
|
+
acceptDropsFrom,
|
|
13011
|
+
preserveDragSpace,
|
|
13012
|
+
onDragProxySetup
|
|
13013
|
+
} = props;
|
|
13014
|
+
const {
|
|
13015
|
+
domRef,
|
|
13016
|
+
proxyStateRef,
|
|
13017
|
+
sourceScrollOffsetRef,
|
|
13018
|
+
dragItemsRef,
|
|
13019
|
+
setInteractionTarget,
|
|
13020
|
+
updateDragProxyRenderState
|
|
13021
|
+
} = options;
|
|
13022
|
+
const dragStrategy = props.dragStrategy ?? "proxy";
|
|
13023
|
+
const useProxy = dragStrategy === "proxy" && !props.renderDragProxy;
|
|
13024
|
+
const useRenderProxy = dragStrategy === "proxy" && !!props.renderDragProxy;
|
|
13025
|
+
const proxyMove = props.onDragProxyMove ?? defaultDragProxyMove;
|
|
13026
|
+
const target = e.currentTarget;
|
|
13027
|
+
let dragItemId = target.getAttribute(DRAG_ITEM_ATTRIBUTE);
|
|
13028
|
+
if (dragItemId == null) {
|
|
13029
|
+
const parentDragItem = selectParent(target, DRAG_ITEM_SELECTOR);
|
|
13030
|
+
if (parentDragItem) {
|
|
13031
|
+
dragItemId = parentDragItem.getAttribute(DRAG_ITEM_ATTRIBUTE);
|
|
13032
|
+
}
|
|
13033
|
+
}
|
|
13034
|
+
if (dragItemId == null) {
|
|
13035
|
+
console.warn(
|
|
13036
|
+
`Could not find drag item id for element`,
|
|
13037
|
+
target,
|
|
13038
|
+
`Make sure you have a parent element with a ${DRAG_ITEM_ATTRIBUTE} attribute`
|
|
13039
|
+
);
|
|
13040
|
+
return;
|
|
13041
|
+
}
|
|
13042
|
+
dragItemId = `${dragItemId}`;
|
|
13043
|
+
let dragOperation = null;
|
|
13044
|
+
const dragItems = getDraggableItemNodes(domRef, dragListId);
|
|
13045
|
+
dragItemsRef.current = dragItems;
|
|
13046
|
+
const interactionTarget = createInteractionTarget({
|
|
13047
|
+
domRef,
|
|
13048
|
+
orientation,
|
|
13049
|
+
dragListId,
|
|
13050
|
+
acceptDropsFrom,
|
|
13051
|
+
initial: true,
|
|
13052
|
+
preserveDragSpace
|
|
13053
|
+
});
|
|
13054
|
+
const draggableItems = interactionTarget.getData().draggableItems;
|
|
13055
|
+
const dragIndex = draggableItems.findIndex((item) => item.id === dragItemId);
|
|
13056
|
+
if (dragIndex === -1) {
|
|
13057
|
+
return;
|
|
13058
|
+
}
|
|
13059
|
+
const dragItem = draggableItems[dragIndex];
|
|
13060
|
+
const dragItemNode = dragItems[dragIndex]?.getAttribute(DRAG_ITEM_ATTRIBUTE) === `${dragItemId}` ? dragItems[dragIndex] : dragItems.find(
|
|
13061
|
+
(node) => node.getAttribute(DRAG_ITEM_ATTRIBUTE) === `${dragItemId}`
|
|
13062
|
+
);
|
|
13063
|
+
setInteractionTarget(interactionTarget);
|
|
13064
|
+
const initialCoords = {
|
|
13065
|
+
left: e.clientX,
|
|
13066
|
+
top: e.clientY
|
|
13067
|
+
};
|
|
13068
|
+
let lastPointer = { left: e.clientX, top: e.clientY };
|
|
13069
|
+
sourceScrollOffsetRef.current = { top: 0, left: 0 };
|
|
13070
|
+
const autoScroller = new AutoScroller({
|
|
13071
|
+
orientation,
|
|
13072
|
+
onScroll: () => {
|
|
13073
|
+
}
|
|
13074
|
+
});
|
|
13075
|
+
if (domRef.current) {
|
|
13076
|
+
autoScroller.start(domRef.current);
|
|
13077
|
+
}
|
|
13078
|
+
const scrollContainer = autoScroller.getScrollContainer();
|
|
13079
|
+
let lastSourceScroll = scrollContainer ? orientation === "vertical" ? scrollContainer.scrollTop : scrollContainer.scrollLeft : 0;
|
|
13080
|
+
function fireDragMove() {
|
|
13081
|
+
if (!dragOperation) return;
|
|
13082
|
+
dragOperation.move({
|
|
13083
|
+
left: lastPointer.left,
|
|
13084
|
+
top: lastPointer.top
|
|
13085
|
+
});
|
|
13086
|
+
}
|
|
13087
|
+
const onContainerScroll = () => {
|
|
13088
|
+
if (!scrollContainer) return;
|
|
13089
|
+
const current = orientation === "vertical" ? scrollContainer.scrollTop : scrollContainer.scrollLeft;
|
|
13090
|
+
const delta = current - lastSourceScroll;
|
|
13091
|
+
lastSourceScroll = current;
|
|
13092
|
+
if (delta !== 0) {
|
|
13093
|
+
interactionTarget.adjustForScroll(delta);
|
|
13094
|
+
if (orientation === "vertical") {
|
|
13095
|
+
sourceScrollOffsetRef.current.top += delta;
|
|
13096
|
+
} else {
|
|
13097
|
+
sourceScrollOffsetRef.current.left += delta;
|
|
13098
|
+
}
|
|
13099
|
+
}
|
|
13100
|
+
fireDragMove();
|
|
13101
|
+
};
|
|
13102
|
+
scrollContainer?.addEventListener("scroll", onContainerScroll);
|
|
13103
|
+
const onPointerMove = (e2) => {
|
|
13104
|
+
lastPointer = { left: e2.clientX, top: e2.clientY };
|
|
13105
|
+
if (!dragOperation) {
|
|
13106
|
+
dragOperation = DragManager.startDrag(
|
|
13107
|
+
{
|
|
13108
|
+
listId: dragListId,
|
|
13109
|
+
dragItem,
|
|
13110
|
+
dragIndex
|
|
13111
|
+
},
|
|
13112
|
+
initialCoords
|
|
13113
|
+
);
|
|
13114
|
+
if (dragItemNode && useProxy) {
|
|
13115
|
+
const rect = dragItemNode.getBoundingClientRect();
|
|
13116
|
+
let cachedProxy = null;
|
|
13117
|
+
const setupParams = {
|
|
13118
|
+
dragItemNode,
|
|
13119
|
+
dragItemId: `${dragItemId}`,
|
|
13120
|
+
initialRect: rect,
|
|
13121
|
+
initialCoords,
|
|
13122
|
+
get proxyElement() {
|
|
13123
|
+
if (!cachedProxy) {
|
|
13124
|
+
cachedProxy = createDefaultProxy(dragItemNode, rect);
|
|
13125
|
+
}
|
|
13126
|
+
return cachedProxy;
|
|
13127
|
+
}
|
|
13128
|
+
};
|
|
13129
|
+
const setupResult = onDragProxySetup?.(setupParams);
|
|
13130
|
+
const proxyElement = setupResult?.proxyElement ?? setupParams.proxyElement;
|
|
13131
|
+
dragItemNode.style.visibility = "hidden";
|
|
13132
|
+
proxyStateRef.current = {
|
|
13133
|
+
proxyElement,
|
|
13134
|
+
originalNode: dragItemNode,
|
|
13135
|
+
dragItemId: `${dragItemId}`,
|
|
13136
|
+
initialRect: rect,
|
|
13137
|
+
cleanup: setupResult?.cleanup
|
|
13138
|
+
};
|
|
13139
|
+
}
|
|
13140
|
+
if (dragItemNode && useRenderProxy) {
|
|
13141
|
+
const rect = dragItemNode.getBoundingClientRect();
|
|
13142
|
+
dragItemNode.style.visibility = "hidden";
|
|
13143
|
+
proxyStateRef.current = {
|
|
13144
|
+
proxyElement: dragItemNode,
|
|
13145
|
+
originalNode: dragItemNode,
|
|
13146
|
+
dragItemId: `${dragItemId}`,
|
|
13147
|
+
initialRect: rect,
|
|
13148
|
+
// Portal handles its own DOM; only restore visibility.
|
|
13149
|
+
cleanup: () => {
|
|
13150
|
+
}
|
|
13151
|
+
};
|
|
13152
|
+
const initialRenderState = {
|
|
13153
|
+
dragItemId: `${dragItemId}`,
|
|
13154
|
+
initialRect: rect,
|
|
13155
|
+
dx: 0,
|
|
13156
|
+
dy: 0
|
|
13157
|
+
};
|
|
13158
|
+
updateDragProxyRenderState(() => initialRenderState);
|
|
13159
|
+
}
|
|
13160
|
+
}
|
|
13161
|
+
const dx = e2.clientX - initialCoords.left;
|
|
13162
|
+
const dy = e2.clientY - initialCoords.top;
|
|
13163
|
+
if (useRenderProxy) {
|
|
13164
|
+
updateDragProxyRenderState((prev) => prev ? { ...prev, dx, dy } : prev);
|
|
13165
|
+
} else {
|
|
13166
|
+
const proxyState = proxyStateRef.current;
|
|
13167
|
+
if (proxyState) {
|
|
13168
|
+
proxyMove({ proxyElement: proxyState.proxyElement, dx, dy });
|
|
13169
|
+
}
|
|
13170
|
+
}
|
|
13171
|
+
autoScroller.updatePointer({
|
|
13172
|
+
left: e2.clientX,
|
|
13173
|
+
top: e2.clientY
|
|
13174
|
+
});
|
|
13175
|
+
fireDragMove();
|
|
13176
|
+
};
|
|
13177
|
+
const preventNativeDrag = (e2) => {
|
|
13178
|
+
e2.preventDefault();
|
|
13179
|
+
};
|
|
13180
|
+
const endDrag = (cancelled) => {
|
|
13181
|
+
autoScroller.stop();
|
|
13182
|
+
scrollContainer?.removeEventListener("scroll", onContainerScroll);
|
|
13183
|
+
win.removeEventListener("pointermove", onPointerMove);
|
|
13184
|
+
win.removeEventListener("pointerup", onPointerUp);
|
|
13185
|
+
win.removeEventListener("pointercancel", onPointerCancel);
|
|
13186
|
+
win.removeEventListener("dragstart", preventNativeDrag, true);
|
|
13187
|
+
if (useRenderProxy) {
|
|
13188
|
+
updateDragProxyRenderState(
|
|
13189
|
+
(prev) => prev ? { ...prev, dragItemId: null } : prev
|
|
13190
|
+
);
|
|
13191
|
+
requestAnimationFrame(() => {
|
|
13192
|
+
updateDragProxyRenderState(RETURN_NULL);
|
|
13193
|
+
});
|
|
13194
|
+
}
|
|
13195
|
+
if (!dragOperation) {
|
|
13196
|
+
cleanupProxy(proxyStateRef);
|
|
13197
|
+
setInteractionTarget(null);
|
|
13198
|
+
return;
|
|
13199
|
+
}
|
|
13200
|
+
if (cancelled) {
|
|
13201
|
+
dragOperation.cancel();
|
|
13202
|
+
} else {
|
|
13203
|
+
dragOperation.drop();
|
|
13204
|
+
}
|
|
13205
|
+
dragOperation = null;
|
|
13206
|
+
};
|
|
13207
|
+
const onPointerUp = () => endDrag(false);
|
|
13208
|
+
const onPointerCancel = () => endDrag(true);
|
|
13209
|
+
const win = getGlobal();
|
|
13210
|
+
win.addEventListener("pointermove", onPointerMove);
|
|
13211
|
+
win.addEventListener("pointerup", onPointerUp);
|
|
13212
|
+
win.addEventListener("pointercancel", onPointerCancel);
|
|
13213
|
+
win.addEventListener("dragstart", preventNativeDrag, true);
|
|
13214
|
+
}
|
|
13215
|
+
|
|
13216
|
+
// src/components/InfiniteTable/components/draggable/DragList.tsx
|
|
13217
|
+
var DragListContext = React31.createContext({
|
|
13218
|
+
dragItemId: null,
|
|
13219
|
+
onDragItemPointerDown: () => {
|
|
13220
|
+
},
|
|
13221
|
+
draggingInProgress: false,
|
|
13222
|
+
dragListId: "",
|
|
13223
|
+
status: "accepted",
|
|
13224
|
+
dragSourceListId: null,
|
|
13225
|
+
dropTargetListId: null
|
|
13226
|
+
});
|
|
13227
|
+
var useDragListContext = () => {
|
|
13228
|
+
return React31.useContext(DragListContext);
|
|
13229
|
+
};
|
|
13230
|
+
function useInteractionTarget(domRef, props) {
|
|
13231
|
+
const getProps = useLatest(props);
|
|
13232
|
+
const [interactionTarget, doSetInteractionTarget] = React31.useState(null);
|
|
13233
|
+
const registeredTargetRef = React31.useRef(null);
|
|
13234
|
+
const setInteractionTarget = (0, import_react24.useCallback)(
|
|
13235
|
+
(interactionTarget2) => {
|
|
13236
|
+
replaceRegisteredInteractionTarget(
|
|
13237
|
+
registeredTargetRef,
|
|
13238
|
+
interactionTarget2
|
|
13239
|
+
);
|
|
13240
|
+
doSetInteractionTarget(interactionTarget2);
|
|
13241
|
+
},
|
|
13242
|
+
[]
|
|
13243
|
+
);
|
|
13244
|
+
const getInteractionTarget = useLatest(interactionTarget);
|
|
13245
|
+
(0, import_react24.useEffect)(() => {
|
|
13246
|
+
return () => {
|
|
13247
|
+
DragManager.unregisterDragInteractionTarget(registeredTargetRef.current);
|
|
13248
|
+
registeredTargetRef.current = null;
|
|
13249
|
+
};
|
|
13250
|
+
}, []);
|
|
13251
|
+
(0, import_react24.useEffect)(() => {
|
|
13252
|
+
return acceptDragsFromOtherLists({
|
|
13253
|
+
getProps,
|
|
13254
|
+
domRef,
|
|
13255
|
+
setInteractionTarget
|
|
13256
|
+
});
|
|
13257
|
+
}, [getProps]);
|
|
13258
|
+
return {
|
|
13259
|
+
interactionTarget,
|
|
13260
|
+
setInteractionTarget,
|
|
13261
|
+
getInteractionTarget
|
|
13262
|
+
};
|
|
13263
|
+
}
|
|
12800
13264
|
var DragList = (props) => {
|
|
12801
13265
|
const domRef = React31.useRef(null);
|
|
12802
13266
|
const proxyStateRef = React31.useRef(null);
|
|
@@ -12819,375 +13283,42 @@ var DragList = (props) => {
|
|
|
12819
13283
|
props
|
|
12820
13284
|
);
|
|
12821
13285
|
(0, import_react24.useEffect)(() => {
|
|
12822
|
-
|
|
12823
|
-
`[${DRAG_LIST_ATTRIBUTE}="${props.dragListId}"]`
|
|
12824
|
-
);
|
|
12825
|
-
if (dragList) {
|
|
12826
|
-
domRef.current = dragList;
|
|
12827
|
-
} else {
|
|
12828
|
-
console.warn(
|
|
12829
|
-
`DragList with id "${props.dragListId}" not found. You're probably not spreading the domProps to the parent element. Make sure you also include the "className" prop.`
|
|
12830
|
-
);
|
|
12831
|
-
}
|
|
13286
|
+
findDragListElement(domRef, props.dragListId);
|
|
12832
13287
|
}, [props.dragListId]);
|
|
12833
13288
|
(0, import_react24.useEffect)(() => {
|
|
12834
13289
|
if (interactionTarget) {
|
|
12835
|
-
|
|
12836
|
-
|
|
12837
|
-
|
|
12838
|
-
|
|
12839
|
-
|
|
12840
|
-
|
|
12841
|
-
|
|
12842
|
-
|
|
12843
|
-
|
|
12844
|
-
|
|
12845
|
-
|
|
12846
|
-
|
|
12847
|
-
|
|
12848
|
-
|
|
12849
|
-
({ offsetsForItems, items, status: status2, dragItem }) => {
|
|
12850
|
-
if (status2 === "rejected") {
|
|
12851
|
-
return;
|
|
12852
|
-
}
|
|
12853
|
-
const dragItems = getDragItems();
|
|
12854
|
-
const updatePosition = getUpdatePosition();
|
|
12855
|
-
const proxyState = proxyStateRef.current;
|
|
12856
|
-
items.forEach((item, index) => {
|
|
12857
|
-
let offset = offsetsForItems[index];
|
|
12858
|
-
const node = dragItems[index];
|
|
12859
|
-
if (!node) {
|
|
12860
|
-
return;
|
|
12861
|
-
}
|
|
12862
|
-
if (proxyState && item.id === proxyState.dragItemId) {
|
|
12863
|
-
return;
|
|
12864
|
-
}
|
|
12865
|
-
if (!proxyState && item.id === dragItem.id) {
|
|
12866
|
-
const scrollOffset = sourceScrollOffsetRef.current;
|
|
12867
|
-
offset = {
|
|
12868
|
-
left: offset.left + scrollOffset.left,
|
|
12869
|
-
top: offset.top + scrollOffset.top
|
|
12870
|
-
};
|
|
12871
|
-
}
|
|
12872
|
-
updatePosition({
|
|
12873
|
-
id: item.id,
|
|
12874
|
-
node,
|
|
12875
|
-
offset
|
|
12876
|
-
});
|
|
12877
|
-
});
|
|
12878
|
-
}
|
|
12879
|
-
);
|
|
12880
|
-
const removeOnDragDrop = interactionTarget.on("drop", (params) => {
|
|
12881
|
-
const {
|
|
12882
|
-
sortedIndexes,
|
|
12883
|
-
dragIndex,
|
|
12884
|
-
dropIndex,
|
|
12885
|
-
dragItem,
|
|
12886
|
-
items,
|
|
12887
|
-
dragSourceListId: dragSourceListId2,
|
|
12888
|
-
dropTargetListId: dropTargetListId2,
|
|
12889
|
-
outside,
|
|
12890
|
-
status: status2
|
|
12891
|
-
} = params;
|
|
12892
|
-
const dragItems = getDragItems();
|
|
12893
|
-
dragItemsRef.current = [];
|
|
12894
|
-
const onAcceptDrop = getOnAcceptDrop();
|
|
12895
|
-
const onRemove = getOnRemove();
|
|
12896
|
-
const onDrop = getOnDrop();
|
|
12897
|
-
const updatePosition = getUpdatePosition();
|
|
12898
|
-
items.forEach((item, index) => {
|
|
12899
|
-
const node = dragItems[index];
|
|
12900
|
-
if (!node) {
|
|
12901
|
-
return;
|
|
12902
|
-
}
|
|
12903
|
-
updatePosition({
|
|
12904
|
-
id: item.id,
|
|
12905
|
-
node,
|
|
12906
|
-
offset: null
|
|
12907
|
-
});
|
|
12908
|
-
});
|
|
12909
|
-
cleanupProxy(proxyStateRef);
|
|
12910
|
-
setDragProxyRenderState((prev) => {
|
|
12911
|
-
if (!prev) return prev;
|
|
12912
|
-
requestAnimationFrame(() => setDragProxyRenderState(null));
|
|
12913
|
-
return { ...prev, dragItemId: null };
|
|
12914
|
-
});
|
|
12915
|
-
const accepted = status2 === "accepted";
|
|
12916
|
-
if (dragListId === dropTargetListId2 && dragSourceListId2 !== dragListId) {
|
|
12917
|
-
if (onAcceptDrop && accepted) {
|
|
12918
|
-
onAcceptDrop({
|
|
12919
|
-
dragItemId: dragItem.id,
|
|
12920
|
-
dragSourceListId: dragSourceListId2,
|
|
12921
|
-
dropTargetListId: dropTargetListId2,
|
|
12922
|
-
dragIndex,
|
|
12923
|
-
dropIndex,
|
|
12924
|
-
dropItemId: items[dropIndex]?.id
|
|
12925
|
-
});
|
|
12926
|
-
}
|
|
12927
|
-
}
|
|
12928
|
-
let callbackFn = null;
|
|
12929
|
-
if (dropIndex === -1 && dragSourceListId2 === dragListId && dropTargetListId2 === dragListId && outside) {
|
|
12930
|
-
callbackFn = onRemove;
|
|
12931
|
-
}
|
|
12932
|
-
if (dropIndex !== -1 && dropTargetListId2 === dragListId && dragSourceListId2 === dragListId) {
|
|
12933
|
-
callbackFn = onDrop;
|
|
12934
|
-
}
|
|
12935
|
-
if (callbackFn) {
|
|
12936
|
-
callbackFn?.(sortedIndexes, {
|
|
12937
|
-
dragIndex,
|
|
12938
|
-
dropIndex,
|
|
12939
|
-
dragItemId: items[dragIndex].id,
|
|
12940
|
-
dropItemId: items[dropIndex]?.id
|
|
12941
|
-
});
|
|
12942
|
-
}
|
|
13290
|
+
return bindInteractionTarget(interactionTarget, {
|
|
13291
|
+
dragListId: props.dragListId,
|
|
13292
|
+
orientation: props.orientation,
|
|
13293
|
+
domRef,
|
|
13294
|
+
proxyStateRef,
|
|
13295
|
+
sourceScrollOffsetRef,
|
|
13296
|
+
dragItemsRef,
|
|
13297
|
+
getDragItems,
|
|
13298
|
+
getOnDrop,
|
|
13299
|
+
getOnAcceptDrop,
|
|
13300
|
+
getOnRemove,
|
|
13301
|
+
getUpdatePosition,
|
|
13302
|
+
updateDragOperationSourceAndTarget,
|
|
13303
|
+
updateDragProxyRenderState: setDragProxyRenderState
|
|
12943
13304
|
});
|
|
12944
|
-
let targetAutoScroller = null;
|
|
12945
|
-
let targetScrollContainer = null;
|
|
12946
|
-
let targetScrollHandler = null;
|
|
12947
|
-
let targetPointermoveHandler = null;
|
|
12948
|
-
if (!interactionTarget.getData().initial && domRef.current) {
|
|
12949
|
-
targetAutoScroller = new AutoScroller({
|
|
12950
|
-
orientation: props.orientation,
|
|
12951
|
-
onScroll: () => {
|
|
12952
|
-
}
|
|
12953
|
-
});
|
|
12954
|
-
targetAutoScroller.start(domRef.current);
|
|
12955
|
-
targetScrollContainer = targetAutoScroller.getScrollContainer();
|
|
12956
|
-
if (targetScrollContainer) {
|
|
12957
|
-
let lastScroll = props.orientation === "vertical" ? targetScrollContainer.scrollTop : targetScrollContainer.scrollLeft;
|
|
12958
|
-
targetScrollHandler = () => {
|
|
12959
|
-
const current = props.orientation === "vertical" ? targetScrollContainer.scrollTop : targetScrollContainer.scrollLeft;
|
|
12960
|
-
const delta = current - lastScroll;
|
|
12961
|
-
lastScroll = current;
|
|
12962
|
-
if (delta !== 0) {
|
|
12963
|
-
interactionTarget.adjustForScroll(delta);
|
|
12964
|
-
DragManager.retriggerMove();
|
|
12965
|
-
}
|
|
12966
|
-
};
|
|
12967
|
-
targetScrollContainer.addEventListener("scroll", targetScrollHandler);
|
|
12968
|
-
}
|
|
12969
|
-
targetPointermoveHandler = (e) => {
|
|
12970
|
-
targetAutoScroller.updatePointer({
|
|
12971
|
-
left: e.clientX,
|
|
12972
|
-
top: e.clientY
|
|
12973
|
-
});
|
|
12974
|
-
};
|
|
12975
|
-
getGlobal().addEventListener("pointermove", targetPointermoveHandler);
|
|
12976
|
-
}
|
|
12977
|
-
return () => {
|
|
12978
|
-
removeOnDragStart();
|
|
12979
|
-
removeOnDragMove();
|
|
12980
|
-
removeOnDragDrop();
|
|
12981
|
-
if (targetAutoScroller) {
|
|
12982
|
-
targetAutoScroller.stop();
|
|
12983
|
-
}
|
|
12984
|
-
if (targetScrollContainer && targetScrollHandler) {
|
|
12985
|
-
targetScrollContainer.removeEventListener(
|
|
12986
|
-
"scroll",
|
|
12987
|
-
targetScrollHandler
|
|
12988
|
-
);
|
|
12989
|
-
}
|
|
12990
|
-
if (targetPointermoveHandler) {
|
|
12991
|
-
getGlobal().removeEventListener(
|
|
12992
|
-
"pointermove",
|
|
12993
|
-
targetPointermoveHandler
|
|
12994
|
-
);
|
|
12995
|
-
}
|
|
12996
|
-
};
|
|
12997
13305
|
}
|
|
12998
13306
|
return void 0;
|
|
12999
13307
|
}, [interactionTarget, props.dragListId]);
|
|
13000
13308
|
const dragItemsRef = React31.useRef([]);
|
|
13001
13309
|
const getDragItems = (0, import_react24.useCallback)(() => {
|
|
13002
|
-
|
|
13003
|
-
if (!dragItems || dragItems.length === 0) {
|
|
13004
|
-
dragItems = getDraggableItemNodes(domRef, props.dragListId);
|
|
13005
|
-
dragItemsRef.current = dragItems;
|
|
13006
|
-
}
|
|
13007
|
-
return dragItems;
|
|
13310
|
+
return getDragItemNodes(dragItemsRef, domRef, props.dragListId);
|
|
13008
13311
|
}, [props.dragListId]);
|
|
13009
13312
|
const onDragItemPointerDown = (0, import_react24.useCallback)(
|
|
13010
13313
|
(e) => {
|
|
13011
|
-
|
|
13012
|
-
let dragItemId2 = target.getAttribute(DRAG_ITEM_ATTRIBUTE);
|
|
13013
|
-
if (dragItemId2 == null) {
|
|
13014
|
-
const parentDragItem = selectParent(target, DRAG_ITEM_SELECTOR);
|
|
13015
|
-
if (parentDragItem) {
|
|
13016
|
-
dragItemId2 = parentDragItem.getAttribute(DRAG_ITEM_ATTRIBUTE);
|
|
13017
|
-
}
|
|
13018
|
-
}
|
|
13019
|
-
if (dragItemId2 == null) {
|
|
13020
|
-
console.warn(
|
|
13021
|
-
`Could not find drag item id for element`,
|
|
13022
|
-
target,
|
|
13023
|
-
`Make sure you have a parent element with a ${DRAG_ITEM_ATTRIBUTE} attribute`
|
|
13024
|
-
);
|
|
13025
|
-
return;
|
|
13026
|
-
}
|
|
13027
|
-
dragItemId2 = `${dragItemId2}`;
|
|
13028
|
-
let dragOperation = null;
|
|
13029
|
-
const dragItems = getDraggableItemNodes(domRef, props.dragListId);
|
|
13030
|
-
dragItemsRef.current = dragItems;
|
|
13031
|
-
const interactionTarget2 = createInteractionTarget({
|
|
13314
|
+
startDragOnPointerDown(e, props, {
|
|
13032
13315
|
domRef,
|
|
13033
|
-
|
|
13034
|
-
|
|
13035
|
-
|
|
13036
|
-
|
|
13037
|
-
|
|
13316
|
+
proxyStateRef,
|
|
13317
|
+
sourceScrollOffsetRef,
|
|
13318
|
+
dragItemsRef,
|
|
13319
|
+
setInteractionTarget,
|
|
13320
|
+
updateDragProxyRenderState: setDragProxyRenderState
|
|
13038
13321
|
});
|
|
13039
|
-
const draggableItems = interactionTarget2.getData().draggableItems;
|
|
13040
|
-
const dragIndex = draggableItems.findIndex(
|
|
13041
|
-
(item) => item.id === dragItemId2
|
|
13042
|
-
);
|
|
13043
|
-
if (dragIndex === -1) {
|
|
13044
|
-
return;
|
|
13045
|
-
}
|
|
13046
|
-
const dragItem = draggableItems[dragIndex];
|
|
13047
|
-
const dragItemNode = dragItems[dragIndex]?.getAttribute(DRAG_ITEM_ATTRIBUTE) === `${dragItemId2}` ? dragItems[dragIndex] : dragItems.find(
|
|
13048
|
-
(node) => node.getAttribute(DRAG_ITEM_ATTRIBUTE) === `${dragItemId2}`
|
|
13049
|
-
);
|
|
13050
|
-
setInteractionTarget(interactionTarget2);
|
|
13051
|
-
const initialCoords = {
|
|
13052
|
-
left: e.clientX,
|
|
13053
|
-
top: e.clientY
|
|
13054
|
-
};
|
|
13055
|
-
let lastPointer = { left: e.clientX, top: e.clientY };
|
|
13056
|
-
sourceScrollOffsetRef.current = { top: 0, left: 0 };
|
|
13057
|
-
const autoScroller = new AutoScroller({
|
|
13058
|
-
orientation: props.orientation,
|
|
13059
|
-
onScroll: () => {
|
|
13060
|
-
}
|
|
13061
|
-
});
|
|
13062
|
-
if (domRef.current) {
|
|
13063
|
-
autoScroller.start(domRef.current);
|
|
13064
|
-
}
|
|
13065
|
-
const scrollContainer = autoScroller.getScrollContainer();
|
|
13066
|
-
let lastSourceScroll = scrollContainer ? props.orientation === "vertical" ? scrollContainer.scrollTop : scrollContainer.scrollLeft : 0;
|
|
13067
|
-
function fireDragMove() {
|
|
13068
|
-
if (!dragOperation) return;
|
|
13069
|
-
dragOperation.move({
|
|
13070
|
-
left: lastPointer.left,
|
|
13071
|
-
top: lastPointer.top
|
|
13072
|
-
});
|
|
13073
|
-
}
|
|
13074
|
-
const onContainerScroll = () => {
|
|
13075
|
-
if (!scrollContainer) return;
|
|
13076
|
-
const current = props.orientation === "vertical" ? scrollContainer.scrollTop : scrollContainer.scrollLeft;
|
|
13077
|
-
const delta = current - lastSourceScroll;
|
|
13078
|
-
lastSourceScroll = current;
|
|
13079
|
-
if (delta !== 0) {
|
|
13080
|
-
interactionTarget2.adjustForScroll(delta);
|
|
13081
|
-
if (props.orientation === "vertical") {
|
|
13082
|
-
sourceScrollOffsetRef.current.top += delta;
|
|
13083
|
-
} else {
|
|
13084
|
-
sourceScrollOffsetRef.current.left += delta;
|
|
13085
|
-
}
|
|
13086
|
-
}
|
|
13087
|
-
fireDragMove();
|
|
13088
|
-
};
|
|
13089
|
-
scrollContainer?.addEventListener("scroll", onContainerScroll);
|
|
13090
|
-
const dragStrategy = props.dragStrategy ?? "proxy";
|
|
13091
|
-
const useProxy = dragStrategy === "proxy" && !props.renderDragProxy;
|
|
13092
|
-
const useRenderProxy = dragStrategy === "proxy" && !!props.renderDragProxy;
|
|
13093
|
-
const proxyMove = props.onDragProxyMove ?? defaultDragProxyMove;
|
|
13094
|
-
const onPointerMove = (e2) => {
|
|
13095
|
-
lastPointer = { left: e2.clientX, top: e2.clientY };
|
|
13096
|
-
if (!dragOperation) {
|
|
13097
|
-
dragOperation = DragManager.startDrag(
|
|
13098
|
-
{
|
|
13099
|
-
listId: props.dragListId,
|
|
13100
|
-
dragItem,
|
|
13101
|
-
dragIndex
|
|
13102
|
-
},
|
|
13103
|
-
initialCoords
|
|
13104
|
-
);
|
|
13105
|
-
if (dragItemNode && useProxy) {
|
|
13106
|
-
const rect = dragItemNode.getBoundingClientRect();
|
|
13107
|
-
let cachedProxy = null;
|
|
13108
|
-
const setupParams = {
|
|
13109
|
-
dragItemNode,
|
|
13110
|
-
dragItemId: `${dragItemId2}`,
|
|
13111
|
-
initialRect: rect,
|
|
13112
|
-
initialCoords,
|
|
13113
|
-
get proxyElement() {
|
|
13114
|
-
if (!cachedProxy) {
|
|
13115
|
-
cachedProxy = createDefaultProxy(dragItemNode, rect);
|
|
13116
|
-
}
|
|
13117
|
-
return cachedProxy;
|
|
13118
|
-
}
|
|
13119
|
-
};
|
|
13120
|
-
const setupResult = props.onDragProxySetup?.(setupParams);
|
|
13121
|
-
const proxyElement = setupResult?.proxyElement ?? setupParams.proxyElement;
|
|
13122
|
-
dragItemNode.style.visibility = "hidden";
|
|
13123
|
-
proxyStateRef.current = {
|
|
13124
|
-
proxyElement,
|
|
13125
|
-
originalNode: dragItemNode,
|
|
13126
|
-
dragItemId: `${dragItemId2}`,
|
|
13127
|
-
initialRect: rect,
|
|
13128
|
-
cleanup: setupResult?.cleanup
|
|
13129
|
-
};
|
|
13130
|
-
}
|
|
13131
|
-
if (dragItemNode && useRenderProxy) {
|
|
13132
|
-
const rect = dragItemNode.getBoundingClientRect();
|
|
13133
|
-
dragItemNode.style.visibility = "hidden";
|
|
13134
|
-
proxyStateRef.current = {
|
|
13135
|
-
proxyElement: dragItemNode,
|
|
13136
|
-
originalNode: dragItemNode,
|
|
13137
|
-
dragItemId: `${dragItemId2}`,
|
|
13138
|
-
initialRect: rect,
|
|
13139
|
-
// Portal handles its own DOM; only restore visibility.
|
|
13140
|
-
cleanup: () => {
|
|
13141
|
-
}
|
|
13142
|
-
};
|
|
13143
|
-
setDragProxyRenderState({
|
|
13144
|
-
dragItemId: `${dragItemId2}`,
|
|
13145
|
-
initialRect: rect,
|
|
13146
|
-
dx: 0,
|
|
13147
|
-
dy: 0
|
|
13148
|
-
});
|
|
13149
|
-
}
|
|
13150
|
-
}
|
|
13151
|
-
const dx = e2.clientX - initialCoords.left;
|
|
13152
|
-
const dy = e2.clientY - initialCoords.top;
|
|
13153
|
-
if (useRenderProxy) {
|
|
13154
|
-
setDragProxyRenderState(
|
|
13155
|
-
(prev) => prev ? { ...prev, dx, dy } : prev
|
|
13156
|
-
);
|
|
13157
|
-
} else {
|
|
13158
|
-
const proxyState = proxyStateRef.current;
|
|
13159
|
-
if (proxyState) {
|
|
13160
|
-
proxyMove({ proxyElement: proxyState.proxyElement, dx, dy });
|
|
13161
|
-
}
|
|
13162
|
-
}
|
|
13163
|
-
autoScroller.updatePointer({
|
|
13164
|
-
left: e2.clientX,
|
|
13165
|
-
top: e2.clientY
|
|
13166
|
-
});
|
|
13167
|
-
fireDragMove();
|
|
13168
|
-
};
|
|
13169
|
-
const onPointerUp = () => {
|
|
13170
|
-
autoScroller.stop();
|
|
13171
|
-
scrollContainer?.removeEventListener("scroll", onContainerScroll);
|
|
13172
|
-
getGlobal().removeEventListener("pointermove", onPointerMove);
|
|
13173
|
-
if (useRenderProxy) {
|
|
13174
|
-
setDragProxyRenderState(
|
|
13175
|
-
(prev) => prev ? { ...prev, dragItemId: null } : prev
|
|
13176
|
-
);
|
|
13177
|
-
requestAnimationFrame(() => {
|
|
13178
|
-
setDragProxyRenderState(null);
|
|
13179
|
-
});
|
|
13180
|
-
}
|
|
13181
|
-
if (!dragOperation) {
|
|
13182
|
-
cleanupProxy(proxyStateRef);
|
|
13183
|
-
setInteractionTarget(null);
|
|
13184
|
-
return;
|
|
13185
|
-
}
|
|
13186
|
-
dragOperation.drop();
|
|
13187
|
-
dragOperation = null;
|
|
13188
|
-
};
|
|
13189
|
-
getGlobal().addEventListener("pointermove", onPointerMove);
|
|
13190
|
-
getGlobal().addEventListener("pointerup", onPointerUp, { once: true });
|
|
13191
13322
|
},
|
|
13192
13323
|
[
|
|
13193
13324
|
props.orientation,
|
|
@@ -13237,10 +13368,6 @@ var DragList = (props) => {
|
|
|
13237
13368
|
ref: proxyRefCallback
|
|
13238
13369
|
}) : null);
|
|
13239
13370
|
};
|
|
13240
|
-
var DRAG_LIST_ATTRIBUTE = "data-drag-list-id";
|
|
13241
|
-
var DRAG_ITEM_ATTRIBUTE = "data-drag-item-id";
|
|
13242
|
-
var DRAG_ITEM_LIST_ATTRIBUTE = "data-drag-item-list-id";
|
|
13243
|
-
var DRAG_ITEM_SELECTOR = `[${DRAG_ITEM_ATTRIBUTE}]`;
|
|
13244
13371
|
var DragItemContext = React31.createContext({
|
|
13245
13372
|
dragItemId: "",
|
|
13246
13373
|
dragListId: "",
|
|
@@ -14648,13 +14775,13 @@ var MatrixBrain = class extends Logger {
|
|
|
14648
14775
|
* transforms that follow the scroll position should use.
|
|
14649
14776
|
*/
|
|
14650
14777
|
getDOMScrollPosition(scrollPosition = this.getScrollPosition()) {
|
|
14651
|
-
const
|
|
14652
|
-
if (!
|
|
14778
|
+
const origin = this.getScrollOrigin();
|
|
14779
|
+
if (!origin.scrollTop && !origin.scrollLeft) {
|
|
14653
14780
|
return scrollPosition;
|
|
14654
14781
|
}
|
|
14655
14782
|
return {
|
|
14656
|
-
scrollTop: scrollPosition.scrollTop -
|
|
14657
|
-
scrollLeft: scrollPosition.scrollLeft -
|
|
14783
|
+
scrollTop: scrollPosition.scrollTop - origin.scrollTop,
|
|
14784
|
+
scrollLeft: scrollPosition.scrollLeft - origin.scrollLeft
|
|
14658
14785
|
};
|
|
14659
14786
|
}
|
|
14660
14787
|
// a method (not an arrow property) so subclasses can call it via super
|
|
@@ -14688,8 +14815,8 @@ var MatrixBrain = class extends Logger {
|
|
|
14688
14815
|
if (this.destroyed) {
|
|
14689
14816
|
return;
|
|
14690
14817
|
}
|
|
14691
|
-
const
|
|
14692
|
-
this.onScrollOriginChangeFns.forEach((fn) => fn(
|
|
14818
|
+
const origin = this.getScrollOrigin();
|
|
14819
|
+
this.onScrollOriginChangeFns.forEach((fn) => fn(origin));
|
|
14693
14820
|
}
|
|
14694
14821
|
doUpdateRenderCount(which = ALL_DIRECTIONS) {
|
|
14695
14822
|
if (!this.availableWidth || !this.availableHeight) {
|
|
@@ -18238,11 +18365,12 @@ function InfiniteTableInternalHeaderFn(props) {
|
|
|
18238
18365
|
dataSourceStatePartialForHeaderCell
|
|
18239
18366
|
]
|
|
18240
18367
|
);
|
|
18368
|
+
const headerDragListId = useDragListId(HEADER_DRAG_LIST_NAME);
|
|
18241
18369
|
return /* @__PURE__ */ React46.createElement(
|
|
18242
18370
|
DragList,
|
|
18243
18371
|
{
|
|
18244
18372
|
orientation: "horizontal",
|
|
18245
|
-
dragListId:
|
|
18373
|
+
dragListId: headerDragListId,
|
|
18246
18374
|
dragStrategy: "inline",
|
|
18247
18375
|
onDrop: emptyFn3,
|
|
18248
18376
|
updatePosition: emptyFn3
|
|
@@ -18512,7 +18640,7 @@ function InfiniteTableHeaderCellFn(props) {
|
|
|
18512
18640
|
filterDelay
|
|
18513
18641
|
} = props;
|
|
18514
18642
|
const { allRowsSelected, someRowsSelected, selectionMode } = dataSourceStatePartialForHeaderCell;
|
|
18515
|
-
const { onDragItemPointerDown } = useDragListContext();
|
|
18643
|
+
const { onDragItemPointerDown, dragListId } = useDragListContext();
|
|
18516
18644
|
const {
|
|
18517
18645
|
api,
|
|
18518
18646
|
getComputed,
|
|
@@ -18811,7 +18939,7 @@ function InfiniteTableHeaderCellFn(props) {
|
|
|
18811
18939
|
"data-field": `${column.field || ""}`,
|
|
18812
18940
|
"data-column-id": column.id,
|
|
18813
18941
|
[DRAG_ITEM_ATTRIBUTE]: column.id,
|
|
18814
|
-
[DRAG_ITEM_LIST_ATTRIBUTE]:
|
|
18942
|
+
[DRAG_ITEM_LIST_ATTRIBUTE]: dragListId,
|
|
18815
18943
|
"data-header-align": align2,
|
|
18816
18944
|
"data-name": "HeaderCell",
|
|
18817
18945
|
"data-sort": column.computedSortedAsc ? "asc" : column.computedSortedDesc ? "desc" : "none",
|
|
@@ -18942,25 +19070,40 @@ function decamelize(str, options) {
|
|
|
18942
19070
|
).toLowerCase();
|
|
18943
19071
|
}
|
|
18944
19072
|
|
|
18945
|
-
// src/components/InfiniteTable/components/InfiniteTableLicenseFooter/
|
|
18946
|
-
var
|
|
19073
|
+
// src/components/InfiniteTable/components/InfiniteTableLicenseFooter/licenseFooterShared.ts
|
|
19074
|
+
var LICENSE_FOOTER_LINK = "https://infinite-table.com";
|
|
19075
|
+
var LICENSE_FOOTER_INVALID_MESSAGE = "Invalid Infinite Table license. See console for details.";
|
|
19076
|
+
var baseFooterStyle = {
|
|
18947
19077
|
padding: ThemeVars.spacing[2],
|
|
18948
19078
|
textAlign: "end",
|
|
18949
19079
|
opacity: "1",
|
|
18950
19080
|
visibility: "visible",
|
|
18951
19081
|
display: "block",
|
|
18952
|
-
fontSize: "0.85rem"
|
|
19082
|
+
fontSize: "0.85rem"
|
|
19083
|
+
};
|
|
19084
|
+
var missingFooterStyle = {
|
|
19085
|
+
...baseFooterStyle,
|
|
18953
19086
|
background: "white",
|
|
18954
19087
|
color: "black"
|
|
18955
19088
|
};
|
|
18956
|
-
var
|
|
18957
|
-
|
|
19089
|
+
var invalidFooterStyle = {
|
|
19090
|
+
...baseFooterStyle,
|
|
19091
|
+
// pale red, with dark red text
|
|
19092
|
+
background: "#fee2e2",
|
|
19093
|
+
color: "#991b1b"
|
|
19094
|
+
};
|
|
19095
|
+
var baseAnchorStyle = {
|
|
19096
|
+
opacity: "1",
|
|
18958
19097
|
visibility: "visible",
|
|
18959
19098
|
display: "inline-block",
|
|
18960
19099
|
pointerEvents: "all",
|
|
18961
|
-
color: "black",
|
|
18962
19100
|
textDecoration: "underline"
|
|
18963
19101
|
};
|
|
19102
|
+
var missingAnchorStyle = { ...baseAnchorStyle, color: "black" };
|
|
19103
|
+
var invalidAnchorStyle = { ...baseAnchorStyle, color: "#991b1b" };
|
|
19104
|
+
function getLicenseFooterStyles(invalid) {
|
|
19105
|
+
return invalid ? { footer: invalidFooterStyle, anchor: invalidAnchorStyle } : { footer: missingFooterStyle, anchor: missingAnchorStyle };
|
|
19106
|
+
}
|
|
18964
19107
|
var enforceStyle = (node, style2) => {
|
|
18965
19108
|
if (!node) {
|
|
18966
19109
|
return;
|
|
@@ -18973,8 +19116,26 @@ var enforceStyle = (node, style2) => {
|
|
|
18973
19116
|
);
|
|
18974
19117
|
}
|
|
18975
19118
|
};
|
|
19119
|
+
function enforceLicenseFooterStyle(getNode, invalid) {
|
|
19120
|
+
const styles = getLicenseFooterStyles(invalid);
|
|
19121
|
+
const forceStyle = () => {
|
|
19122
|
+
setTimeout(() => {
|
|
19123
|
+
const node = getNode();
|
|
19124
|
+
enforceStyle(node, styles.footer);
|
|
19125
|
+
enforceStyle(node?.querySelector("a") ?? null, styles.anchor);
|
|
19126
|
+
});
|
|
19127
|
+
};
|
|
19128
|
+
forceStyle();
|
|
19129
|
+
const intervalId = setInterval(forceStyle, 1e3);
|
|
19130
|
+
return () => {
|
|
19131
|
+
clearInterval(intervalId);
|
|
19132
|
+
};
|
|
19133
|
+
}
|
|
19134
|
+
|
|
19135
|
+
// src/components/InfiniteTable/components/InfiniteTableLicenseFooter/index.tsx
|
|
18976
19136
|
var InfiniteTableLicenseFooter = React50.forwardRef(
|
|
18977
19137
|
function InfiniteTableLicenseFooter2(props, ref) {
|
|
19138
|
+
const { invalid = false, ...domProps } = props;
|
|
18978
19139
|
const { rootClassName: rootClassName12 } = useInternalProps();
|
|
18979
19140
|
const domRef = React50.useRef(null);
|
|
18980
19141
|
const domCallback = React50.useCallback((node) => {
|
|
@@ -18989,42 +19150,33 @@ var InfiniteTableLicenseFooter = React50.forwardRef(
|
|
|
18989
19150
|
}
|
|
18990
19151
|
}, []);
|
|
18991
19152
|
(0, import_react38.useEffect)(() => {
|
|
18992
|
-
|
|
18993
|
-
|
|
18994
|
-
|
|
18995
|
-
enforceStyle(
|
|
18996
|
-
domRef.current?.firstElementChild,
|
|
18997
|
-
anchorStyle
|
|
18998
|
-
);
|
|
18999
|
-
});
|
|
19000
|
-
};
|
|
19001
|
-
forceStyle();
|
|
19002
|
-
const intervalId = setInterval(forceStyle, 1e3);
|
|
19003
|
-
return () => {
|
|
19004
|
-
clearInterval(intervalId);
|
|
19005
|
-
};
|
|
19006
|
-
}, []);
|
|
19153
|
+
return enforceLicenseFooterStyle(() => domRef.current, invalid);
|
|
19154
|
+
}, [invalid]);
|
|
19155
|
+
const styles = getLicenseFooterStyles(invalid);
|
|
19007
19156
|
return /* @__PURE__ */ React50.createElement(
|
|
19008
19157
|
"div",
|
|
19009
19158
|
{
|
|
19010
19159
|
ref: domCallback,
|
|
19011
|
-
...
|
|
19160
|
+
...domProps,
|
|
19012
19161
|
className: join(
|
|
19013
19162
|
`${rootClassName12}-Footer`,
|
|
19163
|
+
invalid ? `${rootClassName12}-Footer--invalid` : null,
|
|
19014
19164
|
FooterCls,
|
|
19015
|
-
|
|
19165
|
+
domProps.className
|
|
19016
19166
|
),
|
|
19017
|
-
style:
|
|
19167
|
+
style: styles.footer
|
|
19018
19168
|
},
|
|
19169
|
+
invalid ? `${LICENSE_FOOTER_INVALID_MESSAGE} ` : null,
|
|
19019
19170
|
"Powered by",
|
|
19020
19171
|
" ",
|
|
19021
19172
|
/* @__PURE__ */ React50.createElement(
|
|
19022
19173
|
"a",
|
|
19023
19174
|
{
|
|
19024
|
-
href:
|
|
19175
|
+
href: LICENSE_FOOTER_LINK,
|
|
19025
19176
|
rel: "noopener noreferrer",
|
|
19026
19177
|
role: "link",
|
|
19027
|
-
target: "_blank"
|
|
19178
|
+
target: "_blank",
|
|
19179
|
+
style: styles.anchor
|
|
19028
19180
|
},
|
|
19029
19181
|
"Infinite Table"
|
|
19030
19182
|
)
|
|
@@ -25989,6 +26141,7 @@ function concludeReducer(params) {
|
|
|
25989
26141
|
} else {
|
|
25990
26142
|
state.groupDeepMap = void 0;
|
|
25991
26143
|
state.pivotColumns = void 0;
|
|
26144
|
+
state.pivotColumnGroups = void 0;
|
|
25992
26145
|
state.groupRowsIndexesInDataArray = void 0;
|
|
25993
26146
|
const arrayDifferentAfterSortStep = previousState.postSortDataArray != state.postSortDataArray;
|
|
25994
26147
|
if (arrayDifferentAfterSortStep || groupsDepsChanged || selectionDepsChanged || rowDisabledStateDepsChanged || rowInfoReducersChanged) {
|
|
@@ -27645,7 +27798,9 @@ var forwardProps4 = (_setupState) => {
|
|
|
27645
27798
|
pivotGrandTotalColumnPosition: 1,
|
|
27646
27799
|
// groupRenderStrategy: (groupRenderStrategy) =>
|
|
27647
27800
|
// groupRenderStrategy ?? 'multi-column',
|
|
27648
|
-
|
|
27801
|
+
// keep undefined - it means "use InfiniteTable.licenseKey", while an
|
|
27802
|
+
// empty string means "no license key"
|
|
27803
|
+
licenseKey: (licenseKey) => licenseKey,
|
|
27649
27804
|
keyboardSelection: (keyboardSelection) => keyboardSelection ?? true,
|
|
27650
27805
|
multiRowSelectionWith: (multiRowSelectionWith) => multiRowSelectionWith ?? "checkbox",
|
|
27651
27806
|
activeRowIndex: 1,
|
|
@@ -27748,8 +27903,10 @@ function getMappedCallbacks2() {
|
|
|
27748
27903
|
var mapPropsToState = (params) => {
|
|
27749
27904
|
const { props, state, oldState, parentState } = params;
|
|
27750
27905
|
const computedColumnGroups = state.pivotColumnGroups || state.columnGroups;
|
|
27751
|
-
const columnGroupsDepthsMap = state.columnGroups && state.columnGroups != oldState?.columnGroups || state.columnGroups && state.columnGroupVisibility != oldState?.columnGroupVisibility ||
|
|
27752
|
-
|
|
27906
|
+
const columnGroupsDepthsMap = state.columnGroups && state.columnGroups != oldState?.columnGroups || state.columnGroups && state.columnGroupVisibility != oldState?.columnGroupVisibility || // also when the pivot column groups go away, as the header has to go back
|
|
27907
|
+
// to the depth of `columnGroups` (or to a single row, when there are none)
|
|
27908
|
+
state.pivotColumnGroups != oldState?.pivotColumnGroups ? computeColumnGroupsDepths(
|
|
27909
|
+
computedColumnGroups ?? EMPTY_OBJECT,
|
|
27753
27910
|
state.columnGroupVisibility
|
|
27754
27911
|
) : state.columnGroupsDepthsMap;
|
|
27755
27912
|
const groupBy = parentState?.groupBy;
|
|
@@ -29253,7 +29410,7 @@ var logLicenseError = (lines, fn = console.error.bind(console)) => {
|
|
|
29253
29410
|
});
|
|
29254
29411
|
fn("*".repeat(max));
|
|
29255
29412
|
};
|
|
29256
|
-
var
|
|
29413
|
+
var checkLicense = (licenseKey = "", packageInfo, fn) => {
|
|
29257
29414
|
let details;
|
|
29258
29415
|
try {
|
|
29259
29416
|
details = decode(licenseKey);
|
|
@@ -29266,7 +29423,7 @@ var isValidLicense = (licenseKey = "", packageInfo, fn) => {
|
|
|
29266
29423
|
],
|
|
29267
29424
|
fn
|
|
29268
29425
|
);
|
|
29269
|
-
return
|
|
29426
|
+
return "invalid";
|
|
29270
29427
|
}
|
|
29271
29428
|
const currentVersionReleaseDate = new Date(packageInfo.publishedAt);
|
|
29272
29429
|
const licenseEndDate = new Date(details.end);
|
|
@@ -29282,14 +29439,16 @@ Your Infinite Table license has expired on ${licenseEndDate.toDateString()}.
|
|
|
29282
29439
|
],
|
|
29283
29440
|
fn
|
|
29284
29441
|
);
|
|
29285
|
-
return
|
|
29442
|
+
return "expired";
|
|
29286
29443
|
}
|
|
29287
|
-
return
|
|
29444
|
+
return "valid";
|
|
29288
29445
|
};
|
|
29289
29446
|
var decode = (licenseKey) => {
|
|
29290
29447
|
let crc = "";
|
|
29291
29448
|
let fields = licenseKey.split("|").map((part) => {
|
|
29292
|
-
|
|
29449
|
+
const separatorIndex = part.indexOf("=");
|
|
29450
|
+
const name = separatorIndex === -1 ? part : part.slice(0, separatorIndex);
|
|
29451
|
+
const value = separatorIndex === -1 ? "" : part.slice(separatorIndex + 1);
|
|
29293
29452
|
if (name === "C") {
|
|
29294
29453
|
crc = value;
|
|
29295
29454
|
}
|
|
@@ -29326,40 +29485,29 @@ var decode = (licenseKey) => {
|
|
|
29326
29485
|
return fieldsToLicenseDetails(fields);
|
|
29327
29486
|
};
|
|
29328
29487
|
|
|
29488
|
+
// src/components/InfiniteTable/hooks/useLicense/getLicenseStatus.ts
|
|
29489
|
+
function getLicenseStatus(licenseKey = "", options) {
|
|
29490
|
+
if (options.isDetail) {
|
|
29491
|
+
return "valid";
|
|
29492
|
+
}
|
|
29493
|
+
const result = checkLicense(licenseKey, {
|
|
29494
|
+
publishedAt: 1794927344373,
|
|
29495
|
+
version: "10.2.0"
|
|
29496
|
+
});
|
|
29497
|
+
if (result === "invalid" && !licenseKey) {
|
|
29498
|
+
return "missing";
|
|
29499
|
+
}
|
|
29500
|
+
return result;
|
|
29501
|
+
}
|
|
29502
|
+
|
|
29329
29503
|
// src/components/InfiniteTable/hooks/useLicense/useLicense.ts
|
|
29330
|
-
var SANDPACK_REGEX = /(https):\/\/\d+\-\d+\-\d+\-(sandpack\.codesandbox\.io)/g;
|
|
29331
|
-
var SANDBOX_REGEX = /(https):\/\/\S+(\.csb\.app)/g;
|
|
29332
|
-
var origin = typeof window !== "undefined" ? window.location.origin : "";
|
|
29333
|
-
var isInsideSandpack = () => {
|
|
29334
|
-
const [_fullUrl, protocol, sandpackUrl] = Array.from(
|
|
29335
|
-
SANDPACK_REGEX.exec(origin) || []
|
|
29336
|
-
);
|
|
29337
|
-
return protocol === "https" && sandpackUrl === "sandpack.codesandbox.io";
|
|
29338
|
-
};
|
|
29339
|
-
var isInsideSandbox = () => {
|
|
29340
|
-
const [_fullUrl, protocol, sandboxUrl] = Array.from(
|
|
29341
|
-
SANDBOX_REGEX.exec(origin) || []
|
|
29342
|
-
);
|
|
29343
|
-
return protocol === "https" && sandboxUrl === ".csb.app";
|
|
29344
|
-
};
|
|
29345
|
-
var isInsidePlayground = isInsideSandbox() || isInsideSandpack();
|
|
29346
29504
|
var useLicense = (licenseKey = "") => {
|
|
29347
29505
|
const masterRowInfo = useMasterRowInfo();
|
|
29348
29506
|
const isDetail = !!masterRowInfo;
|
|
29349
|
-
|
|
29350
|
-
|
|
29351
|
-
|
|
29352
|
-
|
|
29353
|
-
let valid2 = isValidLicense(licenseKey, {
|
|
29354
|
-
publishedAt: 1624970570587,
|
|
29355
|
-
version: "10.1.5"
|
|
29356
|
-
});
|
|
29357
|
-
if (!licenseKey && !valid2 && isInsidePlayground) {
|
|
29358
|
-
return true;
|
|
29359
|
-
}
|
|
29360
|
-
return valid2;
|
|
29361
|
-
}, [licenseKey, isDetail]);
|
|
29362
|
-
return valid;
|
|
29507
|
+
return (0, import_react51.useMemo)(
|
|
29508
|
+
() => getLicenseStatus(licenseKey, { isDetail }),
|
|
29509
|
+
[licenseKey, isDetail]
|
|
29510
|
+
);
|
|
29363
29511
|
};
|
|
29364
29512
|
|
|
29365
29513
|
// src/components/InfiniteTable/hooks/useScrollToActiveCell.ts
|
|
@@ -33297,8 +33445,8 @@ var getFastClickHandler = (callback, prevHandler) => {
|
|
|
33297
33445
|
};
|
|
33298
33446
|
function GroupingToolbarItem(props) {
|
|
33299
33447
|
const { column, onClear, components: components2, field, id, toggleSorting } = props;
|
|
33300
|
-
const { dragSourceListId, dragItemId } = useDragListContext();
|
|
33301
|
-
const draggingInProgress = dragSourceListId ===
|
|
33448
|
+
const { dragSourceListId, dragItemId, dragListId } = useDragListContext();
|
|
33449
|
+
const draggingInProgress = dragSourceListId === dragListId;
|
|
33302
33450
|
const context = useInfiniteTableStableContext();
|
|
33303
33451
|
const columnHeader = (column ? getColumnLabel(column.id, context, "grouping-toolbar") : field) ?? id;
|
|
33304
33452
|
const sortIcon = column ? /* @__PURE__ */ React73.createElement(
|
|
@@ -33310,7 +33458,7 @@ function GroupingToolbarItem(props) {
|
|
|
33310
33458
|
}
|
|
33311
33459
|
) : null;
|
|
33312
33460
|
const header = /* @__PURE__ */ React73.createElement(React73.Fragment, null, columnHeader, sortIcon);
|
|
33313
|
-
const active = dragItemId === id && dragSourceListId ===
|
|
33461
|
+
const active = dragItemId === id && dragSourceListId === dragListId;
|
|
33314
33462
|
const className = join(
|
|
33315
33463
|
GroupingToolbarItemRecipe({
|
|
33316
33464
|
draggingInProgress,
|
|
@@ -33340,7 +33488,6 @@ function GroupingToolbarItem(props) {
|
|
|
33340
33488
|
}
|
|
33341
33489
|
);
|
|
33342
33490
|
}
|
|
33343
|
-
var GROUPING_TOOLBAR_DRAG_LIST_ID = "grouping-toolbar";
|
|
33344
33491
|
function GroupingToolbar(props) {
|
|
33345
33492
|
const { groupBy } = useDataSourceSelector((ctx) => {
|
|
33346
33493
|
return {
|
|
@@ -33358,8 +33505,14 @@ function GroupingToolbar(props) {
|
|
|
33358
33505
|
);
|
|
33359
33506
|
const { dropTargetListId, dragSourceListId } = useDragDropProvider();
|
|
33360
33507
|
const { fieldsToColumn, computedColumnsMap } = getComputed();
|
|
33361
|
-
const
|
|
33362
|
-
const
|
|
33508
|
+
const dragListId = useDragListId(GROUPING_TOOLBAR_DRAG_LIST_NAME);
|
|
33509
|
+
const headerDragListId = useDragListId(HEADER_DRAG_LIST_NAME);
|
|
33510
|
+
const acceptDropsFrom = (0, import_react69.useMemo)(
|
|
33511
|
+
() => [headerDragListId, dragListId],
|
|
33512
|
+
[headerDragListId, dragListId]
|
|
33513
|
+
);
|
|
33514
|
+
const active = dropTargetListId === dragListId;
|
|
33515
|
+
const draggingInProgress = dragSourceListId === dragListId;
|
|
33363
33516
|
const PlaceholderComponent = props.components?.Placeholder ?? PlaceholderDefault;
|
|
33364
33517
|
const HostComponent = props.components?.Host ?? HostDefault;
|
|
33365
33518
|
const children = !groupBy.length ? /* @__PURE__ */ React73.createElement(
|
|
@@ -33432,8 +33585,8 @@ function GroupingToolbar(props) {
|
|
|
33432
33585
|
DragList,
|
|
33433
33586
|
{
|
|
33434
33587
|
orientation,
|
|
33435
|
-
dragListId
|
|
33436
|
-
acceptDropsFrom
|
|
33588
|
+
dragListId,
|
|
33589
|
+
acceptDropsFrom,
|
|
33437
33590
|
onDrop,
|
|
33438
33591
|
dragStrategy: "inline",
|
|
33439
33592
|
onAcceptDrop,
|
|
@@ -34374,7 +34527,7 @@ var InfiniteTableComponent = React79.memo(
|
|
|
34374
34527
|
activeCellIndex
|
|
34375
34528
|
} = componentState;
|
|
34376
34529
|
let { licenseKey } = componentState;
|
|
34377
|
-
if (
|
|
34530
|
+
if (licenseKey === void 0 && InfiniteTable.licenseKey) {
|
|
34378
34531
|
licenseKey = InfiniteTable.licenseKey;
|
|
34379
34532
|
}
|
|
34380
34533
|
useScrollToActiveRow(activeRowIndex, dataArrayLength, api);
|
|
@@ -34393,7 +34546,7 @@ var InfiniteTableComponent = React79.memo(
|
|
|
34393
34546
|
);
|
|
34394
34547
|
return brain.onVerticalRenderRangeChange(onChange);
|
|
34395
34548
|
}, [brain, scrollStopDelay]);
|
|
34396
|
-
const
|
|
34549
|
+
const licenseStatus = useLicense(licenseKey);
|
|
34397
34550
|
const {
|
|
34398
34551
|
// remove autoFocus and tabIndex from the domProps
|
|
34399
34552
|
// that will be spread on the root DOM element
|
|
@@ -34494,7 +34647,7 @@ var InfiniteTableComponent = React79.memo(
|
|
|
34494
34647
|
onChange: onColumnHeaderHeightCSSVarChange
|
|
34495
34648
|
}
|
|
34496
34649
|
) : null,
|
|
34497
|
-
|
|
34650
|
+
licenseStatus === "valid" ? null : /* @__PURE__ */ React79.createElement(InfiniteTableLicenseFooter, { invalid: licenseStatus === "invalid" }),
|
|
34498
34651
|
/* @__PURE__ */ React79.createElement(FocusDetect, null)
|
|
34499
34652
|
);
|
|
34500
34653
|
}
|