@hitachivantara/uikit-react-lab
Version:
Contributed React components to UI Kit by the community.
32 lines (31 loc) • 1.11 kB
JavaScript
import { HvFlowSidebarGroupItem } from "./SidebarGroupItem.js";
import { useRef } from "react";
import { useUniqueId } from "@hitachivantara/uikit-react-core";
import { jsx } from "react/jsx-runtime";
import { useDraggable } from "@dnd-kit/core";
import { useForkRef } from "@mui/material/utils";
//#region src/Flow/Sidebar/SidebarGroup/SidebarGroupItem/DraggableSidebarGroupItem.tsx
var HvFlowDraggableSidebarGroupItem = ({ id: idProp, label, nodeType, data, ...others }) => {
const itemRef = useRef(null);
const { attributes, listeners, setNodeRef, isDragging, transform } = useDraggable({
id: useUniqueId(idProp),
data: { hvFlow: {
type: nodeType,
label,
x: itemRef.current?.getBoundingClientRect().x,
y: itemRef.current?.getBoundingClientRect().y,
data
} }
});
return /* @__PURE__ */ jsx(HvFlowSidebarGroupItem, {
ref: useForkRef(itemRef, setNodeRef),
style: transform ? { transform: `translate3d(${transform.x}px, ${transform.y}px, 0)` } : void 0,
label,
isDragging,
...listeners,
...attributes,
...others
});
};
//#endregion
export { HvFlowDraggableSidebarGroupItem };