import React, { CSSProperties, ReactNode } from "react";
import { useDraggable } from "@dnd-kit/core";

type Props = {
    id: number | string;
    children: ReactNode;
    style?: CSSProperties;
    disabled?: boolean;
};

const DragHandle = ({ id, children, style, disabled }: Props) => {
    const { attributes, listeners, setNodeRef } = useDraggable({
        id,
        disabled,
    });

    return (
        <div
            {...attributes}
            {...listeners}
            style={{
                width: "100wv",
                cursor: disabled ? "default" : "grab",
                touchAction: "auto",
                ...style,
            }}
            className={disabled ? "" : "swiper-no-swiping"}
            ref={setNodeRef}>
            {children}
        </div>
    );
};

export default DragHandle;
