@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.js
CHANGED
|
@@ -156,6 +156,7 @@ __export(src_exports, {
|
|
|
156
156
|
colorForStringValues: () => colorForStringValues,
|
|
157
157
|
colorFromString: () => colorFromString,
|
|
158
158
|
colorSwatchSizeMap: () => colorSwatchSizeMap,
|
|
159
|
+
createDragItemKey: () => createDragItemKey,
|
|
159
160
|
createSectionedMenu: () => createSectionedMenu,
|
|
160
161
|
createSharedDrag: () => createSharedDrag,
|
|
161
162
|
cssVarNames: () => cssVarNames,
|
|
@@ -186,6 +187,7 @@ __export(src_exports, {
|
|
|
186
187
|
mergeConflictingClassNames: () => mergeConflictingClassNames,
|
|
187
188
|
moveTreeItem: () => moveTreeItem,
|
|
188
189
|
normalizeListTargetIndex: () => normalizeListTargetIndex,
|
|
190
|
+
parseDragItemKey: () => parseDragItemKey,
|
|
189
191
|
popoverStyle: () => popoverStyle,
|
|
190
192
|
portalScopeDataSetName: () => portalScopeDataSetName,
|
|
191
193
|
portalScopePropName: () => portalScopePropName,
|
|
@@ -4647,7 +4649,7 @@ var import_react51 = require("react");
|
|
|
4647
4649
|
var import_react_dom2 = require("react-dom");
|
|
4648
4650
|
function SharedDragProvider({
|
|
4649
4651
|
children,
|
|
4650
|
-
|
|
4652
|
+
sharedDragProps = {
|
|
4651
4653
|
dragRegistrationContext: DragRegistrationContext,
|
|
4652
4654
|
activeDragContext: ActiveDragContext
|
|
4653
4655
|
}
|
|
@@ -4660,22 +4662,13 @@ function SharedDragProvider({
|
|
|
4660
4662
|
})
|
|
4661
4663
|
);
|
|
4662
4664
|
const mounted = useMounted();
|
|
4663
|
-
const [
|
|
4664
|
-
|
|
4665
|
+
const [dragState, setDragState] = React45.useState({
|
|
4666
|
+
source: null,
|
|
4667
|
+
target: null,
|
|
4668
|
+
indicator: null
|
|
4669
|
+
});
|
|
4665
4670
|
const { registerList, unregisterList, registeredLists } = useDragRegistrationManager();
|
|
4666
4671
|
const activatorEventRef = React45.useRef(null);
|
|
4667
|
-
const acceptsListDrop = React45.useCallback(
|
|
4668
|
-
(sourceListId, targetListId) => {
|
|
4669
|
-
const sourceList = registeredLists.get(sourceListId);
|
|
4670
|
-
const targetList = registeredLists.get(targetListId);
|
|
4671
|
-
if (!sourceList || !targetList) return false;
|
|
4672
|
-
return targetList.acceptsFromList({
|
|
4673
|
-
sourceListId,
|
|
4674
|
-
targetListId
|
|
4675
|
-
});
|
|
4676
|
-
},
|
|
4677
|
-
[registeredLists]
|
|
4678
|
-
);
|
|
4679
4672
|
const handleDragStart = React45.useCallback(
|
|
4680
4673
|
(event) => {
|
|
4681
4674
|
activatorEventRef.current = event.activatorEvent;
|
|
@@ -4683,132 +4676,115 @@ function SharedDragProvider({
|
|
|
4683
4676
|
const itemIndex = list.keys.findIndex((key) => key === event.active.id);
|
|
4684
4677
|
if (itemIndex >= 0) {
|
|
4685
4678
|
const dragItem = {
|
|
4686
|
-
|
|
4679
|
+
itemId: event.active.id,
|
|
4687
4680
|
listId,
|
|
4688
4681
|
index: itemIndex
|
|
4689
4682
|
};
|
|
4690
|
-
|
|
4683
|
+
setDragState({
|
|
4684
|
+
source: dragItem,
|
|
4685
|
+
target: null,
|
|
4686
|
+
indicator: null
|
|
4687
|
+
});
|
|
4691
4688
|
break;
|
|
4692
4689
|
}
|
|
4693
4690
|
}
|
|
4694
4691
|
},
|
|
4695
4692
|
[registeredLists]
|
|
4696
4693
|
);
|
|
4697
|
-
const handleDragMove = React45.useCallback(
|
|
4698
|
-
|
|
4699
|
-
|
|
4694
|
+
const handleDragMove = React45.useCallback(
|
|
4695
|
+
(event) => {
|
|
4696
|
+
const { active, over } = event;
|
|
4697
|
+
if (!activatorEventRef.current || !dragState.source) return;
|
|
4698
|
+
const dropTarget = findDropTarget({
|
|
4699
|
+
activationPoint: {
|
|
4700
|
+
x: activatorEventRef.current.clientX,
|
|
4701
|
+
y: activatorEventRef.current.clientY
|
|
4702
|
+
},
|
|
4703
|
+
delta: { x: event.delta.x, y: event.delta.y },
|
|
4704
|
+
over,
|
|
4705
|
+
active,
|
|
4706
|
+
source: dragState.source,
|
|
4707
|
+
registeredLists
|
|
4708
|
+
});
|
|
4709
|
+
setDragState({
|
|
4710
|
+
source: dragState.source,
|
|
4711
|
+
target: dropTarget?.target ?? null,
|
|
4712
|
+
indicator: dropTarget?.indicator ?? null
|
|
4713
|
+
});
|
|
4714
|
+
},
|
|
4715
|
+
[registeredLists, dragState.source]
|
|
4716
|
+
);
|
|
4700
4717
|
const handleDragEnd = React45.useCallback(
|
|
4701
4718
|
(event) => {
|
|
4702
4719
|
const { active, over } = event;
|
|
4703
|
-
|
|
4704
|
-
|
|
4705
|
-
|
|
4706
|
-
|
|
4707
|
-
|
|
4720
|
+
if (!activatorEventRef.current || !dragState.source) return;
|
|
4721
|
+
const dropTarget = findDropTarget({
|
|
4722
|
+
activationPoint: {
|
|
4723
|
+
x: activatorEventRef.current.clientX,
|
|
4724
|
+
y: activatorEventRef.current.clientY
|
|
4725
|
+
},
|
|
4726
|
+
delta: { x: event.delta.x, y: event.delta.y },
|
|
4727
|
+
over,
|
|
4728
|
+
active,
|
|
4729
|
+
source: dragState.source,
|
|
4730
|
+
registeredLists
|
|
4731
|
+
});
|
|
4732
|
+
setDragState({
|
|
4733
|
+
source: null,
|
|
4734
|
+
target: null,
|
|
4735
|
+
indicator: null
|
|
4736
|
+
});
|
|
4708
4737
|
activatorEventRef.current = null;
|
|
4709
|
-
if (!
|
|
4710
|
-
|
|
4711
|
-
|
|
4712
|
-
|
|
4713
|
-
|
|
4714
|
-
|
|
4715
|
-
|
|
4716
|
-
|
|
4717
|
-
|
|
4718
|
-
|
|
4719
|
-
|
|
4720
|
-
}
|
|
4721
|
-
if (over.id === listId) {
|
|
4722
|
-
targetListId = listId;
|
|
4723
|
-
targetIndex = list.keys.length;
|
|
4724
|
-
break;
|
|
4725
|
-
}
|
|
4726
|
-
}
|
|
4727
|
-
if (!targetListId || !acceptsListDrop(activeItem.listId, targetListId)) {
|
|
4728
|
-
setActiveItem(null);
|
|
4729
|
-
activatorEventRef.current = null;
|
|
4730
|
-
return;
|
|
4731
|
-
}
|
|
4732
|
-
const targetList = registeredLists.get(targetListId);
|
|
4733
|
-
const sourceList = registeredLists.get(activeItem.listId);
|
|
4734
|
-
if (!targetList || !sourceList) {
|
|
4735
|
-
return;
|
|
4736
|
-
}
|
|
4737
|
-
if (targetIndex < targetList.keys.length && activatorEventPoint) {
|
|
4738
|
-
const eventX = activatorEventPoint.x;
|
|
4739
|
-
const eventY = activatorEventPoint.y;
|
|
4740
|
-
const currentX = eventX + delta.x;
|
|
4741
|
-
const currentY = eventY + delta.y;
|
|
4742
|
-
const absolutePosition = { x: currentX, y: currentY };
|
|
4743
|
-
const indicator = targetList.getDropIndicator({
|
|
4744
|
-
absolutePosition,
|
|
4745
|
-
active,
|
|
4746
|
-
over,
|
|
4747
|
-
sourceListId: activeItem.listId,
|
|
4748
|
-
targetListId
|
|
4749
|
-
});
|
|
4750
|
-
if (!indicator) return;
|
|
4751
|
-
sourceList.onMoveItem(
|
|
4752
|
-
activeItem.index,
|
|
4753
|
-
targetIndex,
|
|
4754
|
-
indicator,
|
|
4755
|
-
activeItem.listId,
|
|
4756
|
-
targetListId
|
|
4757
|
-
);
|
|
4758
|
-
} else if (targetIndex >= targetList.keys.length) {
|
|
4759
|
-
const canDrop = targetList.acceptsDrop(
|
|
4760
|
-
activeItem.index,
|
|
4761
|
-
Math.max(0, targetList.keys.length - 1),
|
|
4762
|
-
// Use last valid index or 0 for empty lists
|
|
4763
|
-
"below",
|
|
4764
|
-
activeItem.listId,
|
|
4765
|
-
targetListId
|
|
4766
|
-
);
|
|
4767
|
-
if (canDrop) {
|
|
4768
|
-
sourceList.onMoveItem(
|
|
4769
|
-
activeItem.index,
|
|
4770
|
-
targetIndex,
|
|
4771
|
-
"below",
|
|
4772
|
-
activeItem.listId,
|
|
4773
|
-
targetListId
|
|
4774
|
-
);
|
|
4775
|
-
}
|
|
4776
|
-
}
|
|
4738
|
+
if (!dropTarget) return;
|
|
4739
|
+
const sourceList = registeredLists.get(dropTarget.source.listId);
|
|
4740
|
+
const targetList = registeredLists.get(dropTarget.target.listId);
|
|
4741
|
+
if (!sourceList || !targetList) return;
|
|
4742
|
+
sourceList.onMoveItem(
|
|
4743
|
+
dropTarget.source.index,
|
|
4744
|
+
dropTarget.target.index,
|
|
4745
|
+
dropTarget.indicator,
|
|
4746
|
+
dropTarget.source.listId,
|
|
4747
|
+
dropTarget.target.listId
|
|
4748
|
+
);
|
|
4777
4749
|
},
|
|
4778
|
-
[
|
|
4750
|
+
[registeredLists, dragState.source]
|
|
4779
4751
|
);
|
|
4780
4752
|
const contextValue = React45.useMemo(
|
|
4781
4753
|
() => ({
|
|
4782
|
-
activeItem,
|
|
4783
|
-
delta,
|
|
4784
4754
|
registerList,
|
|
4785
4755
|
unregisterList
|
|
4786
4756
|
}),
|
|
4787
|
-
[
|
|
4757
|
+
[registerList, unregisterList]
|
|
4788
4758
|
);
|
|
4789
|
-
const activeList =
|
|
4759
|
+
const activeList = dragState.source ? registeredLists.get(dragState.source.listId) : null;
|
|
4790
4760
|
const activeDragContextValue = React45.useMemo(
|
|
4791
|
-
() =>
|
|
4792
|
-
[
|
|
4761
|
+
() => dragState,
|
|
4762
|
+
[dragState]
|
|
4793
4763
|
);
|
|
4794
4764
|
const collisionDetection = (0, import_react51.useMemo)(() => {
|
|
4795
4765
|
return getItemFirstCollisionDetection(Array.from(registeredLists.keys()));
|
|
4796
4766
|
}, [registeredLists]);
|
|
4797
|
-
return /* @__PURE__ */ React45.createElement(AnyDragContext.Provider, { value: true }, /* @__PURE__ */ React45.createElement(
|
|
4798
|
-
|
|
4767
|
+
return /* @__PURE__ */ React45.createElement(AnyDragContext.Provider, { value: true }, /* @__PURE__ */ React45.createElement(sharedDragProps.dragRegistrationContext.Provider, { value: contextValue }, /* @__PURE__ */ React45.createElement(
|
|
4768
|
+
sharedDragProps.activeDragContext.Provider,
|
|
4799
4769
|
{
|
|
4800
|
-
|
|
4801
|
-
collisionDetection,
|
|
4802
|
-
onDragStart: handleDragStart,
|
|
4803
|
-
onDragMove: handleDragMove,
|
|
4804
|
-
onDragEnd: handleDragEnd
|
|
4770
|
+
value: activeDragContextValue
|
|
4805
4771
|
},
|
|
4806
|
-
|
|
4807
|
-
|
|
4808
|
-
|
|
4809
|
-
|
|
4772
|
+
/* @__PURE__ */ React45.createElement(
|
|
4773
|
+
import_core.DndContext,
|
|
4774
|
+
{
|
|
4775
|
+
sensors,
|
|
4776
|
+
collisionDetection,
|
|
4777
|
+
onDragStart: handleDragStart,
|
|
4778
|
+
onDragMove: handleDragMove,
|
|
4779
|
+
onDragEnd: handleDragEnd
|
|
4780
|
+
},
|
|
4781
|
+
children,
|
|
4782
|
+
mounted && activeList?.renderOverlay && dragState.source && (0, import_react_dom2.createPortal)(
|
|
4783
|
+
/* @__PURE__ */ React45.createElement(import_core.DragOverlay, { dropAnimation: null }, activeList.renderOverlay(dragState.source.itemId)),
|
|
4784
|
+
document.body
|
|
4785
|
+
)
|
|
4810
4786
|
)
|
|
4811
|
-
)))
|
|
4787
|
+
)));
|
|
4812
4788
|
}
|
|
4813
4789
|
function useMounted() {
|
|
4814
4790
|
const [mounted, setMounted] = React45.useState(false);
|
|
@@ -4843,6 +4819,83 @@ var getItemFirstCollisionDetection = (registeredListIds) => (parameters) => {
|
|
|
4843
4819
|
}
|
|
4844
4820
|
return pointerCollisions.length > 0 ? pointerCollisions : (0, import_core.closestCenter)(parameters);
|
|
4845
4821
|
};
|
|
4822
|
+
function findDropTarget({
|
|
4823
|
+
activationPoint,
|
|
4824
|
+
delta,
|
|
4825
|
+
over,
|
|
4826
|
+
active,
|
|
4827
|
+
source,
|
|
4828
|
+
registeredLists
|
|
4829
|
+
}) {
|
|
4830
|
+
if (!over || active.id === over.id) return;
|
|
4831
|
+
let targetListId = null;
|
|
4832
|
+
let targetIndex = -1;
|
|
4833
|
+
for (const [listId, list] of registeredLists) {
|
|
4834
|
+
const itemIndex = list.keys.findIndex((key) => key === over.id);
|
|
4835
|
+
if (itemIndex >= 0) {
|
|
4836
|
+
targetListId = listId;
|
|
4837
|
+
targetIndex = itemIndex;
|
|
4838
|
+
break;
|
|
4839
|
+
}
|
|
4840
|
+
if (over.id === listId) {
|
|
4841
|
+
targetListId = listId;
|
|
4842
|
+
targetIndex = list.keys.length;
|
|
4843
|
+
break;
|
|
4844
|
+
}
|
|
4845
|
+
}
|
|
4846
|
+
const targetList = targetListId !== null ? registeredLists.get(targetListId) : null;
|
|
4847
|
+
const sourceList = registeredLists.get(source.listId);
|
|
4848
|
+
if (!targetList || !sourceList || !targetList.acceptsFromList({
|
|
4849
|
+
sourceListId: sourceList.id,
|
|
4850
|
+
targetListId: targetList.id
|
|
4851
|
+
})) {
|
|
4852
|
+
return;
|
|
4853
|
+
}
|
|
4854
|
+
if (over.id === targetList.id) {
|
|
4855
|
+
const canDrop = targetList.acceptsDrop(
|
|
4856
|
+
source.index,
|
|
4857
|
+
Math.max(0, targetList.keys.length - 1),
|
|
4858
|
+
// Use last valid index or 0 for empty lists
|
|
4859
|
+
"below",
|
|
4860
|
+
sourceList.id,
|
|
4861
|
+
targetList.id
|
|
4862
|
+
);
|
|
4863
|
+
if (canDrop) {
|
|
4864
|
+
return {
|
|
4865
|
+
source,
|
|
4866
|
+
target: {
|
|
4867
|
+
itemId: over.id,
|
|
4868
|
+
listId: targetList.id,
|
|
4869
|
+
index: targetIndex
|
|
4870
|
+
},
|
|
4871
|
+
indicator: "below"
|
|
4872
|
+
};
|
|
4873
|
+
}
|
|
4874
|
+
}
|
|
4875
|
+
const eventX = activationPoint.x;
|
|
4876
|
+
const eventY = activationPoint.y;
|
|
4877
|
+
const currentX = eventX + delta.x;
|
|
4878
|
+
const currentY = eventY + delta.y;
|
|
4879
|
+
const absolutePosition = { x: currentX, y: currentY };
|
|
4880
|
+
const indicator = targetList.getDropIndicator({
|
|
4881
|
+
absolutePosition,
|
|
4882
|
+
active,
|
|
4883
|
+
over,
|
|
4884
|
+
sourceListId: sourceList.id,
|
|
4885
|
+
targetListId: targetList.id
|
|
4886
|
+
});
|
|
4887
|
+
if (indicator) {
|
|
4888
|
+
return {
|
|
4889
|
+
source,
|
|
4890
|
+
target: {
|
|
4891
|
+
itemId: over.id,
|
|
4892
|
+
listId: targetList.id,
|
|
4893
|
+
index: targetIndex
|
|
4894
|
+
},
|
|
4895
|
+
indicator
|
|
4896
|
+
};
|
|
4897
|
+
}
|
|
4898
|
+
}
|
|
4846
4899
|
|
|
4847
4900
|
// src/components/sorting/sorting.ts
|
|
4848
4901
|
var React46 = __toESM(require("react"));
|
|
@@ -4897,6 +4950,9 @@ function validateDropIndicator({
|
|
|
4897
4950
|
elementSize,
|
|
4898
4951
|
offsetStart
|
|
4899
4952
|
);
|
|
4953
|
+
if (!isContained(elementStart, elementSize, offsetStart) && sourceListId === targetListId) {
|
|
4954
|
+
return void 0;
|
|
4955
|
+
}
|
|
4900
4956
|
const acceptedHalf = acceptsDrop2(
|
|
4901
4957
|
activeIndex,
|
|
4902
4958
|
overIndex,
|
|
@@ -4912,84 +4968,79 @@ function validateDropIndicator({
|
|
|
4912
4968
|
function isContainedInMiddleThird(elementStart, elementSize, offsetStart) {
|
|
4913
4969
|
return offsetStart >= elementStart + elementSize / 3 && offsetStart <= elementStart + elementSize * 2 / 3;
|
|
4914
4970
|
}
|
|
4971
|
+
function isContained(elementStart, elementSize, offsetStart) {
|
|
4972
|
+
return offsetStart >= elementStart && offsetStart <= elementStart + elementSize;
|
|
4973
|
+
}
|
|
4915
4974
|
function getContainingHalf(elementStart, elementSize, offsetStart) {
|
|
4916
4975
|
if (offsetStart < elementStart + elementSize / 2) return "above";
|
|
4917
4976
|
return "below";
|
|
4918
4977
|
}
|
|
4978
|
+
function createDragItemKey(listId, itemId) {
|
|
4979
|
+
return `${listId}-~-${itemId}`;
|
|
4980
|
+
}
|
|
4981
|
+
function parseDragItemKey(key) {
|
|
4982
|
+
const [listId, itemId] = key.split("-~-");
|
|
4983
|
+
return { listId, itemId };
|
|
4984
|
+
}
|
|
4919
4985
|
|
|
4920
4986
|
// src/components/sorting/Sortable.tsx
|
|
4921
4987
|
var SortableItemContext2 = React47.createContext({
|
|
4922
|
-
keys: [],
|
|
4923
4988
|
acceptsDrop: defaultAcceptsDrop,
|
|
4924
|
-
axis: "y",
|
|
4925
4989
|
listId: "",
|
|
4926
4990
|
getDropTargetParentIndex: void 0,
|
|
4927
4991
|
activeDragContext: ActiveDragContext
|
|
4928
4992
|
});
|
|
4929
4993
|
function useSortableDropIndicator({
|
|
4930
|
-
id,
|
|
4931
4994
|
index,
|
|
4932
|
-
|
|
4933
|
-
overIndex,
|
|
4934
|
-
activeIndex,
|
|
4935
|
-
keys,
|
|
4936
|
-
acceptsDrop: acceptsDrop2,
|
|
4937
|
-
axis,
|
|
4995
|
+
itemId,
|
|
4938
4996
|
listId,
|
|
4997
|
+
acceptsDrop: acceptsDrop2,
|
|
4939
4998
|
getDropTargetParentIndex
|
|
4940
4999
|
}) {
|
|
4941
|
-
const { active, over, activatorEvent } = (0, import_core2.useDndContext)();
|
|
4942
5000
|
const { activeDragContext } = React47.useContext(SortableItemContext2);
|
|
4943
|
-
const
|
|
4944
|
-
|
|
4945
|
-
(
|
|
4946
|
-
|
|
4947
|
-
|
|
4948
|
-
|
|
4949
|
-
|
|
4950
|
-
|
|
4951
|
-
|
|
4952
|
-
|
|
4953
|
-
|
|
4954
|
-
|
|
4955
|
-
const
|
|
4956
|
-
|
|
4957
|
-
|
|
4958
|
-
|
|
4959
|
-
|
|
4960
|
-
|
|
4961
|
-
|
|
4962
|
-
|
|
4963
|
-
|
|
4964
|
-
|
|
4965
|
-
elementSize: axis === "x" ? over.rect.width : over.rect.height,
|
|
4966
|
-
sourceListId: listId,
|
|
4967
|
-
targetListId: listId
|
|
4968
|
-
}) : void 0;
|
|
4969
|
-
const showDragInsideIndicatorOnParent = !overIdAcceptsDrop && isValidParent && parentIndex === index;
|
|
4970
|
-
return relativeDropPosition ?? (showDragInsideIndicatorOnParent ? "inside" : void 0);
|
|
5001
|
+
const activeDrag = useActiveDrag(activeDragContext);
|
|
5002
|
+
const { source, target } = activeDrag;
|
|
5003
|
+
if (!source || !target) return;
|
|
5004
|
+
const indicator = target.listId === listId && target.itemId === itemId ? activeDrag.indicator : void 0;
|
|
5005
|
+
const targetParentIndex = target.index === -1 ? void 0 : getDropTargetParentIndex?.(target.index);
|
|
5006
|
+
const isValidParent = targetParentIndex === void 0 || targetParentIndex === -1 ? false : acceptsDrop2(
|
|
5007
|
+
source.index,
|
|
5008
|
+
targetParentIndex,
|
|
5009
|
+
"inside",
|
|
5010
|
+
source.listId,
|
|
5011
|
+
target.listId
|
|
5012
|
+
);
|
|
5013
|
+
const overIdAcceptsDrop = target.index === -1 ? void 0 : acceptsDrop2(
|
|
5014
|
+
source.index,
|
|
5015
|
+
target.index,
|
|
5016
|
+
"inside",
|
|
5017
|
+
source.listId,
|
|
5018
|
+
target.listId
|
|
5019
|
+
);
|
|
5020
|
+
const thisItemIsTargetParent = targetParentIndex === index;
|
|
5021
|
+
const showDragInsideIndicatorOnParent = !overIdAcceptsDrop && isValidParent && thisItemIsTargetParent;
|
|
5022
|
+
return indicator ?? (showDragInsideIndicatorOnParent ? "inside" : void 0);
|
|
4971
5023
|
}
|
|
4972
5024
|
function SortableItem({
|
|
4973
5025
|
id,
|
|
4974
5026
|
disabled,
|
|
4975
5027
|
children
|
|
4976
5028
|
}) {
|
|
4977
|
-
const {
|
|
4978
|
-
const
|
|
5029
|
+
const { acceptsDrop: acceptsDrop2, listId, getDropTargetParentIndex } = React47.useContext(SortableItemContext2);
|
|
5030
|
+
const dragItemKey = createDragItemKey(listId, id);
|
|
5031
|
+
const { attributes, listeners, setNodeRef, isDragging, index } = (0, import_sortable.useSortable)({
|
|
5032
|
+
id: dragItemKey,
|
|
5033
|
+
disabled
|
|
5034
|
+
});
|
|
4979
5035
|
const ref = React47.useCallback(
|
|
4980
5036
|
(node) => setNodeRef(node),
|
|
4981
5037
|
[setNodeRef]
|
|
4982
5038
|
);
|
|
4983
5039
|
const relativeDropPosition = useSortableDropIndicator({
|
|
4984
|
-
id,
|
|
4985
5040
|
index,
|
|
4986
|
-
|
|
4987
|
-
overIndex,
|
|
4988
|
-
keys,
|
|
4989
|
-
acceptsDrop: acceptsDrop2,
|
|
4990
|
-
axis,
|
|
5041
|
+
itemId: dragItemKey,
|
|
4991
5042
|
listId,
|
|
4992
|
-
|
|
5043
|
+
acceptsDrop: acceptsDrop2,
|
|
4993
5044
|
getDropTargetParentIndex
|
|
4994
5045
|
});
|
|
4995
5046
|
return children({
|
|
@@ -5004,7 +5055,7 @@ function SortableItem({
|
|
|
5004
5055
|
}
|
|
5005
5056
|
function SortableRoot_({
|
|
5006
5057
|
id: idProp,
|
|
5007
|
-
keys,
|
|
5058
|
+
keys: keysProp,
|
|
5008
5059
|
onMoveItem,
|
|
5009
5060
|
renderOverlay,
|
|
5010
5061
|
acceptsFromList,
|
|
@@ -5012,13 +5063,16 @@ function SortableRoot_({
|
|
|
5012
5063
|
axis = "y",
|
|
5013
5064
|
children,
|
|
5014
5065
|
getDropTargetParentIndex,
|
|
5015
|
-
|
|
5066
|
+
sharedDragProps,
|
|
5016
5067
|
containerRef
|
|
5017
5068
|
}) {
|
|
5018
5069
|
const defaultId = React47.useId();
|
|
5019
5070
|
const id = idProp ?? defaultId;
|
|
5071
|
+
const keys = React47.useMemo(() => {
|
|
5072
|
+
return keysProp.map((key) => createDragItemKey(id, key));
|
|
5073
|
+
}, [keysProp, id]);
|
|
5020
5074
|
const { registerList, unregisterList } = useDragRegistration(
|
|
5021
|
-
|
|
5075
|
+
sharedDragProps?.dragRegistrationContext ?? DragRegistrationContext
|
|
5022
5076
|
);
|
|
5023
5077
|
const { setNodeRef: setDroppableRef } = (0, import_core2.useDroppable)({
|
|
5024
5078
|
id,
|
|
@@ -5039,7 +5093,7 @@ function SortableRoot_({
|
|
|
5039
5093
|
const index = keys.findIndex((key) => key === id2);
|
|
5040
5094
|
return renderOverlay?.(index) ?? null;
|
|
5041
5095
|
},
|
|
5042
|
-
acceptsFromList: acceptsFromList ?? ((
|
|
5096
|
+
acceptsFromList: acceptsFromList ?? (() => true),
|
|
5043
5097
|
acceptsDrop: acceptsDrop2,
|
|
5044
5098
|
getDropIndicator: (parameters) => {
|
|
5045
5099
|
const { absolutePosition, active, over, sourceListId, targetListId } = parameters;
|
|
@@ -5079,19 +5133,11 @@ function SortableRoot_({
|
|
|
5079
5133
|
() => ({
|
|
5080
5134
|
keys,
|
|
5081
5135
|
acceptsDrop: acceptsDrop2,
|
|
5082
|
-
axis,
|
|
5083
5136
|
listId: id,
|
|
5084
5137
|
getDropTargetParentIndex,
|
|
5085
|
-
activeDragContext:
|
|
5138
|
+
activeDragContext: sharedDragProps?.activeDragContext ?? ActiveDragContext
|
|
5086
5139
|
}),
|
|
5087
|
-
[
|
|
5088
|
-
keys,
|
|
5089
|
-
acceptsDrop2,
|
|
5090
|
-
axis,
|
|
5091
|
-
id,
|
|
5092
|
-
getDropTargetParentIndex,
|
|
5093
|
-
sharedDragProviderContexts
|
|
5094
|
-
]
|
|
5140
|
+
[keys, acceptsDrop2, id, getDropTargetParentIndex, sharedDragProps]
|
|
5095
5141
|
);
|
|
5096
5142
|
React47.useEffect(() => {
|
|
5097
5143
|
if (containerRef) {
|
|
@@ -5615,7 +5661,9 @@ var ListViewRootInner = forwardRefGeneric(function ListViewRootInner2({
|
|
|
5615
5661
|
onDragLeave,
|
|
5616
5662
|
onDrop,
|
|
5617
5663
|
renderEmptyState,
|
|
5618
|
-
getDropTargetParentIndex
|
|
5664
|
+
getDropTargetParentIndex,
|
|
5665
|
+
sharedDragProps,
|
|
5666
|
+
sortableId
|
|
5619
5667
|
}, forwardedRef) {
|
|
5620
5668
|
const handleClick = (0, import_react52.useCallback)(
|
|
5621
5669
|
(event) => {
|
|
@@ -5739,11 +5787,13 @@ var ListViewRootInner = forwardRefGeneric(function ListViewRootInner2({
|
|
|
5739
5787
|
const withSortable = (children) => sortable ? /* @__PURE__ */ import_react52.default.createElement(
|
|
5740
5788
|
Sortable.Root,
|
|
5741
5789
|
{
|
|
5790
|
+
id: sortableId,
|
|
5742
5791
|
onMoveItem,
|
|
5743
5792
|
keys: ids,
|
|
5744
5793
|
renderOverlay,
|
|
5745
5794
|
acceptsDrop: acceptsDrop2,
|
|
5746
|
-
getDropTargetParentIndex
|
|
5795
|
+
getDropTargetParentIndex,
|
|
5796
|
+
sharedDragProps
|
|
5747
5797
|
},
|
|
5748
5798
|
children
|
|
5749
5799
|
) : children;
|
|
@@ -5936,7 +5986,9 @@ var List = memoGeneric(
|
|
|
5936
5986
|
getDropTargetParentIndex,
|
|
5937
5987
|
getPlaceholder,
|
|
5938
5988
|
onClickItem,
|
|
5939
|
-
dragIndicatorStyle
|
|
5989
|
+
dragIndicatorStyle,
|
|
5990
|
+
sortableId,
|
|
5991
|
+
sharedDragProps
|
|
5940
5992
|
} = props;
|
|
5941
5993
|
const [internalHoveredId, setHoveredId] = (0, import_react54.useState)();
|
|
5942
5994
|
const [internalRenamingId, setRenamingId] = (0, import_react54.useState)();
|
|
@@ -5997,6 +6049,8 @@ var List = memoGeneric(
|
|
|
5997
6049
|
onMoveItem,
|
|
5998
6050
|
renderEmptyState,
|
|
5999
6051
|
getDropTargetParentIndex,
|
|
6052
|
+
sharedDragProps,
|
|
6053
|
+
sortableId,
|
|
6000
6054
|
...dropTargetProps,
|
|
6001
6055
|
renderItem: (item, _, { isDragOverlay }) => {
|
|
6002
6056
|
const id = getId(item);
|
|
@@ -11853,24 +11907,15 @@ function createSharedDrag() {
|
|
|
11853
11907
|
const activeDragContext = React82.createContext(
|
|
11854
11908
|
null
|
|
11855
11909
|
);
|
|
11856
|
-
const
|
|
11857
|
-
SharedDragProvider,
|
|
11858
|
-
{
|
|
11859
|
-
contexts: {
|
|
11860
|
-
dragRegistrationContext,
|
|
11861
|
-
activeDragContext
|
|
11862
|
-
}
|
|
11863
|
-
},
|
|
11864
|
-
children
|
|
11865
|
-
);
|
|
11866
|
-
const dragProps = {
|
|
11910
|
+
const sharedDragProps = {
|
|
11867
11911
|
dragRegistrationContext,
|
|
11868
11912
|
activeDragContext
|
|
11869
11913
|
};
|
|
11914
|
+
const Provider3 = ({ children }) => /* @__PURE__ */ React82.createElement(SharedDragProvider, { sharedDragProps }, children);
|
|
11870
11915
|
return {
|
|
11871
11916
|
Provider: Provider3,
|
|
11872
|
-
Sortable: (props) => /* @__PURE__ */ React82.createElement(Sortable, {
|
|
11873
|
-
props:
|
|
11917
|
+
Sortable: (props) => /* @__PURE__ */ React82.createElement(Sortable, { sharedDragProps, ...props }),
|
|
11918
|
+
props: sharedDragProps
|
|
11874
11919
|
};
|
|
11875
11920
|
}
|
|
11876
11921
|
|
|
@@ -13140,6 +13185,7 @@ function Toolbar({
|
|
|
13140
13185
|
colorForStringValues,
|
|
13141
13186
|
colorFromString,
|
|
13142
13187
|
colorSwatchSizeMap,
|
|
13188
|
+
createDragItemKey,
|
|
13143
13189
|
createSectionedMenu,
|
|
13144
13190
|
createSharedDrag,
|
|
13145
13191
|
cssVarNames,
|
|
@@ -13170,6 +13216,7 @@ function Toolbar({
|
|
|
13170
13216
|
mergeConflictingClassNames,
|
|
13171
13217
|
moveTreeItem,
|
|
13172
13218
|
normalizeListTargetIndex,
|
|
13219
|
+
parseDragItemKey,
|
|
13173
13220
|
popoverStyle,
|
|
13174
13221
|
portalScopeDataSetName,
|
|
13175
13222
|
portalScopePropName,
|