import React from "react"; import { CaretDownCircleFillIcon, CaretUpCircleFillIcon, DragVerticalIcon, } from "@navikt/aksel-icons"; import { useDragAndDropContext } from "../root/DragAndDrop.context"; import { DragAndDropElement } from "../types"; export interface DragAndDropDragHandlerProps { item: DragAndDropElement; itemRef?: React.RefObject; } /** * DragAndDropDragHandler * * A button component that serves as a drag handle for drag and drop operations. * Can be used to initiate dragging of elements in a data table or list. */ export const DragAndDropDragHandler = React.forwardRef< HTMLDivElement, DragAndDropDragHandlerProps >(({ item, itemRef }, forwardedRef) => { const context = useDragAndDropContext(); const active = context?.dragHandlerActive && item && context?.dragHandlerActive?.id === item.id; return (
{active && ( )} {active && ( )}
); });