5fd29bb0d6
Co-authored-by: Anton SHEPILOV <ashepilov@linagora.com> Co-authored-by: montaghanmy <monta.ghanmy@gmail.com>
22 lines
481 B
TypeScript
22 lines
481 B
TypeScript
import React, { MouseEventHandler } from 'react';
|
|
import {useDraggable} from '@dnd-kit/core';
|
|
|
|
type DraggableProps={
|
|
children: React.ReactNode
|
|
id: number
|
|
}
|
|
|
|
export function Draggable(props:DraggableProps) {
|
|
const {attributes, listeners, setNodeRef, transform} = useDraggable({
|
|
id: `draggable-${props.id+1}`,
|
|
data: {
|
|
child: props.children
|
|
},
|
|
});
|
|
|
|
return (
|
|
<div ref={setNodeRef} {...listeners} {...attributes}>
|
|
{props.children}
|
|
</div>
|
|
);
|
|
} |