/** * * The useDraggable hook registers an element as draggable. * * @module useDraggable * @group headless * */ import type { HeadlessInstance } from '@primereact/types/core'; import type { DndInstance, DragData, KeyboardSensorOptions, PointerSensorOptions, UniqueId } from '@primereact/types/primitive/dnd'; /** * Defines valid properties in useDraggable. */ export interface UseDraggableProps { /** * The DndInstance to register with. */ dnd?: DndInstance; /** * Unique identifier for this draggable. */ id?: UniqueId; /** * Whether the draggable is disabled. * @default false */ disabled?: boolean; /** * Scope for filtering drop targets. */ scope?: string; /** * Data attached to this draggable. */ data?: DragData; /** * Which sensor types to attach. * @default 'both' */ sensor?: 'pointer' | 'keyboard' | 'both'; /** * Pointer sensor configuration. */ pointerOptions?: PointerSensorOptions; /** * Keyboard sensor configuration. */ keyboardOptions?: KeyboardSensorOptions; } /** * Defines valid state in useDraggable. */ export interface UseDraggableState { /** * Whether this item is currently being dragged. */ isDragging: boolean; } /** * Data attribute props for the draggable element. */ export interface UseDraggableRootProps { 'data-scope': string; 'data-part': string; 'data-dragging'?: string; 'data-disabled'?: string; tabIndex: number; role: string; 'aria-roledescription': string; 'aria-describedby'?: string; } /** * Defines the methods and properties exposed by useDraggable. */ export interface UseDraggableExposes { /** * The reactive draggable state. */ state: UseDraggableState; /** * Pre-built data attribute and a11y props for the draggable element. */ rootProps: UseDraggableRootProps; } /** * Instance of useDraggable headless. */ export type UseDraggableInstance = HeadlessInstance;