@noya-app/noya-designsystem 0.1.56 → 0.1.57
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/.turbo/turbo-build.log +10 -10
- package/CHANGELOG.md +6 -0
- package/dist/index.d.mts +48 -42
- package/dist/index.d.ts +48 -42
- package/dist/index.js +236 -189
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +235 -190
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/components/Collection.tsx +3 -0
- package/src/components/List.tsx +4 -0
- package/src/components/ListView.tsx +7 -0
- package/src/components/sorting/DragRegistration.tsx +3 -6
- package/src/components/sorting/SharedDragProvider.tsx +200 -131
- package/src/components/sorting/Sortable.tsx +57 -104
- package/src/components/sorting/createSharedDrag.tsx +10 -15
- package/src/components/sorting/sorting.ts +41 -6
package/dist/index.mjs
CHANGED
|
@@ -4455,7 +4455,7 @@ function mergeEventHandlers(...handlerMaps) {
|
|
|
4455
4455
|
}
|
|
4456
4456
|
|
|
4457
4457
|
// src/components/sorting/Sortable.tsx
|
|
4458
|
-
import {
|
|
4458
|
+
import { useDroppable } from "@dnd-kit/core";
|
|
4459
4459
|
import {
|
|
4460
4460
|
horizontalListSortingStrategy,
|
|
4461
4461
|
SortableContext,
|
|
@@ -4515,7 +4515,7 @@ import { useMemo as useMemo19 } from "react";
|
|
|
4515
4515
|
import { createPortal as createPortal2 } from "react-dom";
|
|
4516
4516
|
function SharedDragProvider({
|
|
4517
4517
|
children,
|
|
4518
|
-
|
|
4518
|
+
sharedDragProps = {
|
|
4519
4519
|
dragRegistrationContext: DragRegistrationContext,
|
|
4520
4520
|
activeDragContext: ActiveDragContext
|
|
4521
4521
|
}
|
|
@@ -4528,22 +4528,13 @@ function SharedDragProvider({
|
|
|
4528
4528
|
})
|
|
4529
4529
|
);
|
|
4530
4530
|
const mounted = useMounted();
|
|
4531
|
-
const [
|
|
4532
|
-
|
|
4531
|
+
const [dragState, setDragState] = React45.useState({
|
|
4532
|
+
source: null,
|
|
4533
|
+
target: null,
|
|
4534
|
+
indicator: null
|
|
4535
|
+
});
|
|
4533
4536
|
const { registerList, unregisterList, registeredLists } = useDragRegistrationManager();
|
|
4534
4537
|
const activatorEventRef = React45.useRef(null);
|
|
4535
|
-
const acceptsListDrop = React45.useCallback(
|
|
4536
|
-
(sourceListId, targetListId) => {
|
|
4537
|
-
const sourceList = registeredLists.get(sourceListId);
|
|
4538
|
-
const targetList = registeredLists.get(targetListId);
|
|
4539
|
-
if (!sourceList || !targetList) return false;
|
|
4540
|
-
return targetList.acceptsFromList({
|
|
4541
|
-
sourceListId,
|
|
4542
|
-
targetListId
|
|
4543
|
-
});
|
|
4544
|
-
},
|
|
4545
|
-
[registeredLists]
|
|
4546
|
-
);
|
|
4547
4538
|
const handleDragStart = React45.useCallback(
|
|
4548
4539
|
(event) => {
|
|
4549
4540
|
activatorEventRef.current = event.activatorEvent;
|
|
@@ -4551,132 +4542,115 @@ function SharedDragProvider({
|
|
|
4551
4542
|
const itemIndex = list.keys.findIndex((key) => key === event.active.id);
|
|
4552
4543
|
if (itemIndex >= 0) {
|
|
4553
4544
|
const dragItem = {
|
|
4554
|
-
|
|
4545
|
+
itemId: event.active.id,
|
|
4555
4546
|
listId,
|
|
4556
4547
|
index: itemIndex
|
|
4557
4548
|
};
|
|
4558
|
-
|
|
4549
|
+
setDragState({
|
|
4550
|
+
source: dragItem,
|
|
4551
|
+
target: null,
|
|
4552
|
+
indicator: null
|
|
4553
|
+
});
|
|
4559
4554
|
break;
|
|
4560
4555
|
}
|
|
4561
4556
|
}
|
|
4562
4557
|
},
|
|
4563
4558
|
[registeredLists]
|
|
4564
4559
|
);
|
|
4565
|
-
const handleDragMove = React45.useCallback(
|
|
4566
|
-
|
|
4567
|
-
|
|
4560
|
+
const handleDragMove = React45.useCallback(
|
|
4561
|
+
(event) => {
|
|
4562
|
+
const { active, over } = event;
|
|
4563
|
+
if (!activatorEventRef.current || !dragState.source) return;
|
|
4564
|
+
const dropTarget = findDropTarget({
|
|
4565
|
+
activationPoint: {
|
|
4566
|
+
x: activatorEventRef.current.clientX,
|
|
4567
|
+
y: activatorEventRef.current.clientY
|
|
4568
|
+
},
|
|
4569
|
+
delta: { x: event.delta.x, y: event.delta.y },
|
|
4570
|
+
over,
|
|
4571
|
+
active,
|
|
4572
|
+
source: dragState.source,
|
|
4573
|
+
registeredLists
|
|
4574
|
+
});
|
|
4575
|
+
setDragState({
|
|
4576
|
+
source: dragState.source,
|
|
4577
|
+
target: dropTarget?.target ?? null,
|
|
4578
|
+
indicator: dropTarget?.indicator ?? null
|
|
4579
|
+
});
|
|
4580
|
+
},
|
|
4581
|
+
[registeredLists, dragState.source]
|
|
4582
|
+
);
|
|
4568
4583
|
const handleDragEnd = React45.useCallback(
|
|
4569
4584
|
(event) => {
|
|
4570
4585
|
const { active, over } = event;
|
|
4571
|
-
|
|
4572
|
-
|
|
4573
|
-
|
|
4574
|
-
|
|
4575
|
-
|
|
4586
|
+
if (!activatorEventRef.current || !dragState.source) return;
|
|
4587
|
+
const dropTarget = findDropTarget({
|
|
4588
|
+
activationPoint: {
|
|
4589
|
+
x: activatorEventRef.current.clientX,
|
|
4590
|
+
y: activatorEventRef.current.clientY
|
|
4591
|
+
},
|
|
4592
|
+
delta: { x: event.delta.x, y: event.delta.y },
|
|
4593
|
+
over,
|
|
4594
|
+
active,
|
|
4595
|
+
source: dragState.source,
|
|
4596
|
+
registeredLists
|
|
4597
|
+
});
|
|
4598
|
+
setDragState({
|
|
4599
|
+
source: null,
|
|
4600
|
+
target: null,
|
|
4601
|
+
indicator: null
|
|
4602
|
+
});
|
|
4576
4603
|
activatorEventRef.current = null;
|
|
4577
|
-
if (!
|
|
4578
|
-
|
|
4579
|
-
|
|
4580
|
-
|
|
4581
|
-
|
|
4582
|
-
|
|
4583
|
-
|
|
4584
|
-
|
|
4585
|
-
|
|
4586
|
-
|
|
4587
|
-
|
|
4588
|
-
}
|
|
4589
|
-
if (over.id === listId) {
|
|
4590
|
-
targetListId = listId;
|
|
4591
|
-
targetIndex = list.keys.length;
|
|
4592
|
-
break;
|
|
4593
|
-
}
|
|
4594
|
-
}
|
|
4595
|
-
if (!targetListId || !acceptsListDrop(activeItem.listId, targetListId)) {
|
|
4596
|
-
setActiveItem(null);
|
|
4597
|
-
activatorEventRef.current = null;
|
|
4598
|
-
return;
|
|
4599
|
-
}
|
|
4600
|
-
const targetList = registeredLists.get(targetListId);
|
|
4601
|
-
const sourceList = registeredLists.get(activeItem.listId);
|
|
4602
|
-
if (!targetList || !sourceList) {
|
|
4603
|
-
return;
|
|
4604
|
-
}
|
|
4605
|
-
if (targetIndex < targetList.keys.length && activatorEventPoint) {
|
|
4606
|
-
const eventX = activatorEventPoint.x;
|
|
4607
|
-
const eventY = activatorEventPoint.y;
|
|
4608
|
-
const currentX = eventX + delta.x;
|
|
4609
|
-
const currentY = eventY + delta.y;
|
|
4610
|
-
const absolutePosition = { x: currentX, y: currentY };
|
|
4611
|
-
const indicator = targetList.getDropIndicator({
|
|
4612
|
-
absolutePosition,
|
|
4613
|
-
active,
|
|
4614
|
-
over,
|
|
4615
|
-
sourceListId: activeItem.listId,
|
|
4616
|
-
targetListId
|
|
4617
|
-
});
|
|
4618
|
-
if (!indicator) return;
|
|
4619
|
-
sourceList.onMoveItem(
|
|
4620
|
-
activeItem.index,
|
|
4621
|
-
targetIndex,
|
|
4622
|
-
indicator,
|
|
4623
|
-
activeItem.listId,
|
|
4624
|
-
targetListId
|
|
4625
|
-
);
|
|
4626
|
-
} else if (targetIndex >= targetList.keys.length) {
|
|
4627
|
-
const canDrop = targetList.acceptsDrop(
|
|
4628
|
-
activeItem.index,
|
|
4629
|
-
Math.max(0, targetList.keys.length - 1),
|
|
4630
|
-
// Use last valid index or 0 for empty lists
|
|
4631
|
-
"below",
|
|
4632
|
-
activeItem.listId,
|
|
4633
|
-
targetListId
|
|
4634
|
-
);
|
|
4635
|
-
if (canDrop) {
|
|
4636
|
-
sourceList.onMoveItem(
|
|
4637
|
-
activeItem.index,
|
|
4638
|
-
targetIndex,
|
|
4639
|
-
"below",
|
|
4640
|
-
activeItem.listId,
|
|
4641
|
-
targetListId
|
|
4642
|
-
);
|
|
4643
|
-
}
|
|
4644
|
-
}
|
|
4604
|
+
if (!dropTarget) return;
|
|
4605
|
+
const sourceList = registeredLists.get(dropTarget.source.listId);
|
|
4606
|
+
const targetList = registeredLists.get(dropTarget.target.listId);
|
|
4607
|
+
if (!sourceList || !targetList) return;
|
|
4608
|
+
sourceList.onMoveItem(
|
|
4609
|
+
dropTarget.source.index,
|
|
4610
|
+
dropTarget.target.index,
|
|
4611
|
+
dropTarget.indicator,
|
|
4612
|
+
dropTarget.source.listId,
|
|
4613
|
+
dropTarget.target.listId
|
|
4614
|
+
);
|
|
4645
4615
|
},
|
|
4646
|
-
[
|
|
4616
|
+
[registeredLists, dragState.source]
|
|
4647
4617
|
);
|
|
4648
4618
|
const contextValue = React45.useMemo(
|
|
4649
4619
|
() => ({
|
|
4650
|
-
activeItem,
|
|
4651
|
-
delta,
|
|
4652
4620
|
registerList,
|
|
4653
4621
|
unregisterList
|
|
4654
4622
|
}),
|
|
4655
|
-
[
|
|
4623
|
+
[registerList, unregisterList]
|
|
4656
4624
|
);
|
|
4657
|
-
const activeList =
|
|
4625
|
+
const activeList = dragState.source ? registeredLists.get(dragState.source.listId) : null;
|
|
4658
4626
|
const activeDragContextValue = React45.useMemo(
|
|
4659
|
-
() =>
|
|
4660
|
-
[
|
|
4627
|
+
() => dragState,
|
|
4628
|
+
[dragState]
|
|
4661
4629
|
);
|
|
4662
4630
|
const collisionDetection = useMemo19(() => {
|
|
4663
4631
|
return getItemFirstCollisionDetection(Array.from(registeredLists.keys()));
|
|
4664
4632
|
}, [registeredLists]);
|
|
4665
|
-
return /* @__PURE__ */ React45.createElement(AnyDragContext.Provider, { value: true }, /* @__PURE__ */ React45.createElement(
|
|
4666
|
-
|
|
4633
|
+
return /* @__PURE__ */ React45.createElement(AnyDragContext.Provider, { value: true }, /* @__PURE__ */ React45.createElement(sharedDragProps.dragRegistrationContext.Provider, { value: contextValue }, /* @__PURE__ */ React45.createElement(
|
|
4634
|
+
sharedDragProps.activeDragContext.Provider,
|
|
4667
4635
|
{
|
|
4668
|
-
|
|
4669
|
-
collisionDetection,
|
|
4670
|
-
onDragStart: handleDragStart,
|
|
4671
|
-
onDragMove: handleDragMove,
|
|
4672
|
-
onDragEnd: handleDragEnd
|
|
4636
|
+
value: activeDragContextValue
|
|
4673
4637
|
},
|
|
4674
|
-
|
|
4675
|
-
|
|
4676
|
-
|
|
4677
|
-
|
|
4638
|
+
/* @__PURE__ */ React45.createElement(
|
|
4639
|
+
DndContext,
|
|
4640
|
+
{
|
|
4641
|
+
sensors,
|
|
4642
|
+
collisionDetection,
|
|
4643
|
+
onDragStart: handleDragStart,
|
|
4644
|
+
onDragMove: handleDragMove,
|
|
4645
|
+
onDragEnd: handleDragEnd
|
|
4646
|
+
},
|
|
4647
|
+
children,
|
|
4648
|
+
mounted && activeList?.renderOverlay && dragState.source && createPortal2(
|
|
4649
|
+
/* @__PURE__ */ React45.createElement(DragOverlay, { dropAnimation: null }, activeList.renderOverlay(dragState.source.itemId)),
|
|
4650
|
+
document.body
|
|
4651
|
+
)
|
|
4678
4652
|
)
|
|
4679
|
-
)))
|
|
4653
|
+
)));
|
|
4680
4654
|
}
|
|
4681
4655
|
function useMounted() {
|
|
4682
4656
|
const [mounted, setMounted] = React45.useState(false);
|
|
@@ -4711,6 +4685,83 @@ var getItemFirstCollisionDetection = (registeredListIds) => (parameters) => {
|
|
|
4711
4685
|
}
|
|
4712
4686
|
return pointerCollisions.length > 0 ? pointerCollisions : closestCenter(parameters);
|
|
4713
4687
|
};
|
|
4688
|
+
function findDropTarget({
|
|
4689
|
+
activationPoint,
|
|
4690
|
+
delta,
|
|
4691
|
+
over,
|
|
4692
|
+
active,
|
|
4693
|
+
source,
|
|
4694
|
+
registeredLists
|
|
4695
|
+
}) {
|
|
4696
|
+
if (!over || active.id === over.id) return;
|
|
4697
|
+
let targetListId = null;
|
|
4698
|
+
let targetIndex = -1;
|
|
4699
|
+
for (const [listId, list] of registeredLists) {
|
|
4700
|
+
const itemIndex = list.keys.findIndex((key) => key === over.id);
|
|
4701
|
+
if (itemIndex >= 0) {
|
|
4702
|
+
targetListId = listId;
|
|
4703
|
+
targetIndex = itemIndex;
|
|
4704
|
+
break;
|
|
4705
|
+
}
|
|
4706
|
+
if (over.id === listId) {
|
|
4707
|
+
targetListId = listId;
|
|
4708
|
+
targetIndex = list.keys.length;
|
|
4709
|
+
break;
|
|
4710
|
+
}
|
|
4711
|
+
}
|
|
4712
|
+
const targetList = targetListId !== null ? registeredLists.get(targetListId) : null;
|
|
4713
|
+
const sourceList = registeredLists.get(source.listId);
|
|
4714
|
+
if (!targetList || !sourceList || !targetList.acceptsFromList({
|
|
4715
|
+
sourceListId: sourceList.id,
|
|
4716
|
+
targetListId: targetList.id
|
|
4717
|
+
})) {
|
|
4718
|
+
return;
|
|
4719
|
+
}
|
|
4720
|
+
if (over.id === targetList.id) {
|
|
4721
|
+
const canDrop = targetList.acceptsDrop(
|
|
4722
|
+
source.index,
|
|
4723
|
+
Math.max(0, targetList.keys.length - 1),
|
|
4724
|
+
// Use last valid index or 0 for empty lists
|
|
4725
|
+
"below",
|
|
4726
|
+
sourceList.id,
|
|
4727
|
+
targetList.id
|
|
4728
|
+
);
|
|
4729
|
+
if (canDrop) {
|
|
4730
|
+
return {
|
|
4731
|
+
source,
|
|
4732
|
+
target: {
|
|
4733
|
+
itemId: over.id,
|
|
4734
|
+
listId: targetList.id,
|
|
4735
|
+
index: targetIndex
|
|
4736
|
+
},
|
|
4737
|
+
indicator: "below"
|
|
4738
|
+
};
|
|
4739
|
+
}
|
|
4740
|
+
}
|
|
4741
|
+
const eventX = activationPoint.x;
|
|
4742
|
+
const eventY = activationPoint.y;
|
|
4743
|
+
const currentX = eventX + delta.x;
|
|
4744
|
+
const currentY = eventY + delta.y;
|
|
4745
|
+
const absolutePosition = { x: currentX, y: currentY };
|
|
4746
|
+
const indicator = targetList.getDropIndicator({
|
|
4747
|
+
absolutePosition,
|
|
4748
|
+
active,
|
|
4749
|
+
over,
|
|
4750
|
+
sourceListId: sourceList.id,
|
|
4751
|
+
targetListId: targetList.id
|
|
4752
|
+
});
|
|
4753
|
+
if (indicator) {
|
|
4754
|
+
return {
|
|
4755
|
+
source,
|
|
4756
|
+
target: {
|
|
4757
|
+
itemId: over.id,
|
|
4758
|
+
listId: targetList.id,
|
|
4759
|
+
index: targetIndex
|
|
4760
|
+
},
|
|
4761
|
+
indicator
|
|
4762
|
+
};
|
|
4763
|
+
}
|
|
4764
|
+
}
|
|
4714
4765
|
|
|
4715
4766
|
// src/components/sorting/sorting.ts
|
|
4716
4767
|
import * as React46 from "react";
|
|
@@ -4765,6 +4816,9 @@ function validateDropIndicator({
|
|
|
4765
4816
|
elementSize,
|
|
4766
4817
|
offsetStart
|
|
4767
4818
|
);
|
|
4819
|
+
if (!isContained(elementStart, elementSize, offsetStart) && sourceListId === targetListId) {
|
|
4820
|
+
return void 0;
|
|
4821
|
+
}
|
|
4768
4822
|
const acceptedHalf = acceptsDrop2(
|
|
4769
4823
|
activeIndex,
|
|
4770
4824
|
overIndex,
|
|
@@ -4780,84 +4834,79 @@ function validateDropIndicator({
|
|
|
4780
4834
|
function isContainedInMiddleThird(elementStart, elementSize, offsetStart) {
|
|
4781
4835
|
return offsetStart >= elementStart + elementSize / 3 && offsetStart <= elementStart + elementSize * 2 / 3;
|
|
4782
4836
|
}
|
|
4837
|
+
function isContained(elementStart, elementSize, offsetStart) {
|
|
4838
|
+
return offsetStart >= elementStart && offsetStart <= elementStart + elementSize;
|
|
4839
|
+
}
|
|
4783
4840
|
function getContainingHalf(elementStart, elementSize, offsetStart) {
|
|
4784
4841
|
if (offsetStart < elementStart + elementSize / 2) return "above";
|
|
4785
4842
|
return "below";
|
|
4786
4843
|
}
|
|
4844
|
+
function createDragItemKey(listId, itemId) {
|
|
4845
|
+
return `${listId}-~-${itemId}`;
|
|
4846
|
+
}
|
|
4847
|
+
function parseDragItemKey(key) {
|
|
4848
|
+
const [listId, itemId] = key.split("-~-");
|
|
4849
|
+
return { listId, itemId };
|
|
4850
|
+
}
|
|
4787
4851
|
|
|
4788
4852
|
// src/components/sorting/Sortable.tsx
|
|
4789
4853
|
var SortableItemContext2 = React47.createContext({
|
|
4790
|
-
keys: [],
|
|
4791
4854
|
acceptsDrop: defaultAcceptsDrop,
|
|
4792
|
-
axis: "y",
|
|
4793
4855
|
listId: "",
|
|
4794
4856
|
getDropTargetParentIndex: void 0,
|
|
4795
4857
|
activeDragContext: ActiveDragContext
|
|
4796
4858
|
});
|
|
4797
4859
|
function useSortableDropIndicator({
|
|
4798
|
-
id,
|
|
4799
4860
|
index,
|
|
4800
|
-
|
|
4801
|
-
overIndex,
|
|
4802
|
-
activeIndex,
|
|
4803
|
-
keys,
|
|
4804
|
-
acceptsDrop: acceptsDrop2,
|
|
4805
|
-
axis,
|
|
4861
|
+
itemId,
|
|
4806
4862
|
listId,
|
|
4863
|
+
acceptsDrop: acceptsDrop2,
|
|
4807
4864
|
getDropTargetParentIndex
|
|
4808
4865
|
}) {
|
|
4809
|
-
const { active, over, activatorEvent } = useDndContext();
|
|
4810
4866
|
const { activeDragContext } = React47.useContext(SortableItemContext2);
|
|
4811
|
-
const
|
|
4812
|
-
|
|
4813
|
-
(
|
|
4814
|
-
|
|
4815
|
-
|
|
4816
|
-
|
|
4817
|
-
|
|
4818
|
-
|
|
4819
|
-
|
|
4820
|
-
|
|
4821
|
-
|
|
4822
|
-
|
|
4823
|
-
const
|
|
4824
|
-
|
|
4825
|
-
|
|
4826
|
-
|
|
4827
|
-
|
|
4828
|
-
|
|
4829
|
-
|
|
4830
|
-
|
|
4831
|
-
|
|
4832
|
-
|
|
4833
|
-
elementSize: axis === "x" ? over.rect.width : over.rect.height,
|
|
4834
|
-
sourceListId: listId,
|
|
4835
|
-
targetListId: listId
|
|
4836
|
-
}) : void 0;
|
|
4837
|
-
const showDragInsideIndicatorOnParent = !overIdAcceptsDrop && isValidParent && parentIndex === index;
|
|
4838
|
-
return relativeDropPosition ?? (showDragInsideIndicatorOnParent ? "inside" : void 0);
|
|
4867
|
+
const activeDrag = useActiveDrag(activeDragContext);
|
|
4868
|
+
const { source, target } = activeDrag;
|
|
4869
|
+
if (!source || !target) return;
|
|
4870
|
+
const indicator = target.listId === listId && target.itemId === itemId ? activeDrag.indicator : void 0;
|
|
4871
|
+
const targetParentIndex = target.index === -1 ? void 0 : getDropTargetParentIndex?.(target.index);
|
|
4872
|
+
const isValidParent = targetParentIndex === void 0 || targetParentIndex === -1 ? false : acceptsDrop2(
|
|
4873
|
+
source.index,
|
|
4874
|
+
targetParentIndex,
|
|
4875
|
+
"inside",
|
|
4876
|
+
source.listId,
|
|
4877
|
+
target.listId
|
|
4878
|
+
);
|
|
4879
|
+
const overIdAcceptsDrop = target.index === -1 ? void 0 : acceptsDrop2(
|
|
4880
|
+
source.index,
|
|
4881
|
+
target.index,
|
|
4882
|
+
"inside",
|
|
4883
|
+
source.listId,
|
|
4884
|
+
target.listId
|
|
4885
|
+
);
|
|
4886
|
+
const thisItemIsTargetParent = targetParentIndex === index;
|
|
4887
|
+
const showDragInsideIndicatorOnParent = !overIdAcceptsDrop && isValidParent && thisItemIsTargetParent;
|
|
4888
|
+
return indicator ?? (showDragInsideIndicatorOnParent ? "inside" : void 0);
|
|
4839
4889
|
}
|
|
4840
4890
|
function SortableItem({
|
|
4841
4891
|
id,
|
|
4842
4892
|
disabled,
|
|
4843
4893
|
children
|
|
4844
4894
|
}) {
|
|
4845
|
-
const {
|
|
4846
|
-
const
|
|
4895
|
+
const { acceptsDrop: acceptsDrop2, listId, getDropTargetParentIndex } = React47.useContext(SortableItemContext2);
|
|
4896
|
+
const dragItemKey = createDragItemKey(listId, id);
|
|
4897
|
+
const { attributes, listeners, setNodeRef, isDragging, index } = useSortable({
|
|
4898
|
+
id: dragItemKey,
|
|
4899
|
+
disabled
|
|
4900
|
+
});
|
|
4847
4901
|
const ref = React47.useCallback(
|
|
4848
4902
|
(node) => setNodeRef(node),
|
|
4849
4903
|
[setNodeRef]
|
|
4850
4904
|
);
|
|
4851
4905
|
const relativeDropPosition = useSortableDropIndicator({
|
|
4852
|
-
id,
|
|
4853
4906
|
index,
|
|
4854
|
-
|
|
4855
|
-
overIndex,
|
|
4856
|
-
keys,
|
|
4857
|
-
acceptsDrop: acceptsDrop2,
|
|
4858
|
-
axis,
|
|
4907
|
+
itemId: dragItemKey,
|
|
4859
4908
|
listId,
|
|
4860
|
-
|
|
4909
|
+
acceptsDrop: acceptsDrop2,
|
|
4861
4910
|
getDropTargetParentIndex
|
|
4862
4911
|
});
|
|
4863
4912
|
return children({
|
|
@@ -4872,7 +4921,7 @@ function SortableItem({
|
|
|
4872
4921
|
}
|
|
4873
4922
|
function SortableRoot_({
|
|
4874
4923
|
id: idProp,
|
|
4875
|
-
keys,
|
|
4924
|
+
keys: keysProp,
|
|
4876
4925
|
onMoveItem,
|
|
4877
4926
|
renderOverlay,
|
|
4878
4927
|
acceptsFromList,
|
|
@@ -4880,13 +4929,16 @@ function SortableRoot_({
|
|
|
4880
4929
|
axis = "y",
|
|
4881
4930
|
children,
|
|
4882
4931
|
getDropTargetParentIndex,
|
|
4883
|
-
|
|
4932
|
+
sharedDragProps,
|
|
4884
4933
|
containerRef
|
|
4885
4934
|
}) {
|
|
4886
4935
|
const defaultId = React47.useId();
|
|
4887
4936
|
const id = idProp ?? defaultId;
|
|
4937
|
+
const keys = React47.useMemo(() => {
|
|
4938
|
+
return keysProp.map((key) => createDragItemKey(id, key));
|
|
4939
|
+
}, [keysProp, id]);
|
|
4888
4940
|
const { registerList, unregisterList } = useDragRegistration(
|
|
4889
|
-
|
|
4941
|
+
sharedDragProps?.dragRegistrationContext ?? DragRegistrationContext
|
|
4890
4942
|
);
|
|
4891
4943
|
const { setNodeRef: setDroppableRef } = useDroppable({
|
|
4892
4944
|
id,
|
|
@@ -4907,7 +4959,7 @@ function SortableRoot_({
|
|
|
4907
4959
|
const index = keys.findIndex((key) => key === id2);
|
|
4908
4960
|
return renderOverlay?.(index) ?? null;
|
|
4909
4961
|
},
|
|
4910
|
-
acceptsFromList: acceptsFromList ?? ((
|
|
4962
|
+
acceptsFromList: acceptsFromList ?? (() => true),
|
|
4911
4963
|
acceptsDrop: acceptsDrop2,
|
|
4912
4964
|
getDropIndicator: (parameters) => {
|
|
4913
4965
|
const { absolutePosition, active, over, sourceListId, targetListId } = parameters;
|
|
@@ -4947,19 +4999,11 @@ function SortableRoot_({
|
|
|
4947
4999
|
() => ({
|
|
4948
5000
|
keys,
|
|
4949
5001
|
acceptsDrop: acceptsDrop2,
|
|
4950
|
-
axis,
|
|
4951
5002
|
listId: id,
|
|
4952
5003
|
getDropTargetParentIndex,
|
|
4953
|
-
activeDragContext:
|
|
5004
|
+
activeDragContext: sharedDragProps?.activeDragContext ?? ActiveDragContext
|
|
4954
5005
|
}),
|
|
4955
|
-
[
|
|
4956
|
-
keys,
|
|
4957
|
-
acceptsDrop2,
|
|
4958
|
-
axis,
|
|
4959
|
-
id,
|
|
4960
|
-
getDropTargetParentIndex,
|
|
4961
|
-
sharedDragProviderContexts
|
|
4962
|
-
]
|
|
5006
|
+
[keys, acceptsDrop2, id, getDropTargetParentIndex, sharedDragProps]
|
|
4963
5007
|
);
|
|
4964
5008
|
React47.useEffect(() => {
|
|
4965
5009
|
if (containerRef) {
|
|
@@ -5483,7 +5527,9 @@ var ListViewRootInner = forwardRefGeneric(function ListViewRootInner2({
|
|
|
5483
5527
|
onDragLeave,
|
|
5484
5528
|
onDrop,
|
|
5485
5529
|
renderEmptyState,
|
|
5486
|
-
getDropTargetParentIndex
|
|
5530
|
+
getDropTargetParentIndex,
|
|
5531
|
+
sharedDragProps,
|
|
5532
|
+
sortableId
|
|
5487
5533
|
}, forwardedRef) {
|
|
5488
5534
|
const handleClick = useCallback23(
|
|
5489
5535
|
(event) => {
|
|
@@ -5607,11 +5653,13 @@ var ListViewRootInner = forwardRefGeneric(function ListViewRootInner2({
|
|
|
5607
5653
|
const withSortable = (children) => sortable ? /* @__PURE__ */ React48.createElement(
|
|
5608
5654
|
Sortable.Root,
|
|
5609
5655
|
{
|
|
5656
|
+
id: sortableId,
|
|
5610
5657
|
onMoveItem,
|
|
5611
5658
|
keys: ids,
|
|
5612
5659
|
renderOverlay,
|
|
5613
5660
|
acceptsDrop: acceptsDrop2,
|
|
5614
|
-
getDropTargetParentIndex
|
|
5661
|
+
getDropTargetParentIndex,
|
|
5662
|
+
sharedDragProps
|
|
5615
5663
|
},
|
|
5616
5664
|
children
|
|
5617
5665
|
) : children;
|
|
@@ -5804,7 +5852,9 @@ var List = memoGeneric(
|
|
|
5804
5852
|
getDropTargetParentIndex,
|
|
5805
5853
|
getPlaceholder,
|
|
5806
5854
|
onClickItem,
|
|
5807
|
-
dragIndicatorStyle
|
|
5855
|
+
dragIndicatorStyle,
|
|
5856
|
+
sortableId,
|
|
5857
|
+
sharedDragProps
|
|
5808
5858
|
} = props;
|
|
5809
5859
|
const [internalHoveredId, setHoveredId] = useState23();
|
|
5810
5860
|
const [internalRenamingId, setRenamingId] = useState23();
|
|
@@ -5865,6 +5915,8 @@ var List = memoGeneric(
|
|
|
5865
5915
|
onMoveItem,
|
|
5866
5916
|
renderEmptyState,
|
|
5867
5917
|
getDropTargetParentIndex,
|
|
5918
|
+
sharedDragProps,
|
|
5919
|
+
sortableId,
|
|
5868
5920
|
...dropTargetProps,
|
|
5869
5921
|
renderItem: (item, _, { isDragOverlay }) => {
|
|
5870
5922
|
const id = getId(item);
|
|
@@ -11767,24 +11819,15 @@ function createSharedDrag() {
|
|
|
11767
11819
|
const activeDragContext = React82.createContext(
|
|
11768
11820
|
null
|
|
11769
11821
|
);
|
|
11770
|
-
const
|
|
11771
|
-
SharedDragProvider,
|
|
11772
|
-
{
|
|
11773
|
-
contexts: {
|
|
11774
|
-
dragRegistrationContext,
|
|
11775
|
-
activeDragContext
|
|
11776
|
-
}
|
|
11777
|
-
},
|
|
11778
|
-
children
|
|
11779
|
-
);
|
|
11780
|
-
const dragProps = {
|
|
11822
|
+
const sharedDragProps = {
|
|
11781
11823
|
dragRegistrationContext,
|
|
11782
11824
|
activeDragContext
|
|
11783
11825
|
};
|
|
11826
|
+
const Provider3 = ({ children }) => /* @__PURE__ */ React82.createElement(SharedDragProvider, { sharedDragProps }, children);
|
|
11784
11827
|
return {
|
|
11785
11828
|
Provider: Provider3,
|
|
11786
|
-
Sortable: (props) => /* @__PURE__ */ React82.createElement(Sortable, {
|
|
11787
|
-
props:
|
|
11829
|
+
Sortable: (props) => /* @__PURE__ */ React82.createElement(Sortable, { sharedDragProps, ...props }),
|
|
11830
|
+
props: sharedDragProps
|
|
11788
11831
|
};
|
|
11789
11832
|
}
|
|
11790
11833
|
|
|
@@ -13067,6 +13110,7 @@ export {
|
|
|
13067
13110
|
colorForStringValues,
|
|
13068
13111
|
colorFromString,
|
|
13069
13112
|
colorSwatchSizeMap,
|
|
13113
|
+
createDragItemKey,
|
|
13070
13114
|
createSectionedMenu,
|
|
13071
13115
|
createSharedDrag,
|
|
13072
13116
|
cssVarNames,
|
|
@@ -13097,6 +13141,7 @@ export {
|
|
|
13097
13141
|
mergeConflictingClassNames,
|
|
13098
13142
|
moveTreeItem,
|
|
13099
13143
|
normalizeListTargetIndex,
|
|
13144
|
+
parseDragItemKey,
|
|
13100
13145
|
popoverStyle,
|
|
13101
13146
|
portalScopeDataSetName,
|
|
13102
13147
|
portalScopePropName,
|