Hi Ganesh,
There you go, thanks!
import { createElement, useEffect, useState } from "react";
import "./ui/DragableInputContainer.css";
export function DragableInputContainer({ content }) {
const handleDragOver = event => {
event.preventDefault();
event.dataTransfer.dropEffect = "move";
};
const handleDragStart = (event, item) => {
event.dataTransfer.effectAllowed = "move";
event.dataTransfer.setData("draggedId", event.target.id);
};
const handleDrop = (event, item) => {
event.preventDefault();
const draggedId = event.dataTransfer.getData("draggedId");
const source = document.getElementById(draggedId);
item.value = source.value;
};
useEffect(() => {
const container = document.querySelector(".dragable-input-container-widget");
const elements = container.querySelectorAll(".mx-textbox input");
Array.from(elements).forEach(element => {
element.draggable = true;
element.ondragstart = event => handleDragStart(event, element);
element.ondragover = handleDragOver;
element.ondrop = event => handleDrop(event, element);
});
}, []);
return <div className="dragable-input-container-widget">{content}</div>;
}