/** * Reactive composables for the bQuery Drag & Drop module. * * `useDraggable`, `useDroppable`, and `useSortable` wrap their imperative * counterparts and expose signals for the values most often consumed * reactively (position, isDragging, isOver, active dragged element, ordered * items). When called inside an active reactive scope, the composables * register a cleanup callback so the underlying handle is destroyed * automatically when the scope is disposed. * * `draggablePosition` and `sortableOrder` adapt raw imperative handles into * signals for cases where the composables cannot be used (e.g. when the * handle's lifetime is managed externally). * * @module bquery/dnd */ import type { ReadonlySignal } from '../reactive/index'; import type { DragPosition, DraggableHandle, DraggableOptions, DroppableOptions, SortableHandle, SortableOptions, UseDraggableReturn, UseDroppableReturn, UseSortableReturn } from './types'; /** * Reactive composable returning signals for the position and drag-active * state of a {@link draggable} target. * * The underlying handle is destroyed automatically when the surrounding * reactive scope is disposed (via `onScopeDispose`). Outside a scope, call * `handle.destroy()` manually. * * @example * ```ts * import { effectScope } from '@bquery/bquery/reactive'; * import { useDraggable } from '@bquery/bquery/dnd'; * * const scope = effectScope(); * scope.run(() => { * const { position, isDragging } = useDraggable(boxEl, { bounds: 'parent' }); * // position.value, isDragging.value * }); * scope.stop(); // releases the draggable * ``` */ export declare const useDraggable: (el: HTMLElement, options?: DraggableOptions) => UseDraggableReturn; /** * Reactive composable returning signals for the hover state of a * {@link droppable} zone. * * @example * ```ts * const { isOver, activeDragged } = useDroppable(zoneEl, { accept: '.task' }); * effect(() => { * if (isOver.value) console.log('hovering with', activeDragged.value); * }); * ``` */ export declare const useDroppable: (el: HTMLElement, options?: DroppableOptions) => UseDroppableReturn; /** * Reactive composable returning signals for the current item order and * drag-active state of a {@link sortable} container. * * The order signal updates whenever a sort completes (`onSortEnd`) and on * initial setup. It reflects the DOM order returned by * `handle.getItems()` at the time of each event. * * @example * ```ts * const { order, isDragging } = useSortable(listEl, { items: 'li' }); * effect(() => console.log(order.value.map((el) => el.textContent))); * ``` */ export declare const useSortable: (container: HTMLElement, options?: SortableOptions) => UseSortableReturn; /** * Wraps an existing {@link DraggableHandle} so its current position is * observable as a signal. Polls `handle.getPosition()` at the cadence of * native pointer events on the captured element by reading it once per * tick of a passive `pointermove` listener. * * @remarks * Prefer {@link useDraggable} for new code — this adapter exists for cases * where the draggable handle is created externally and you only need a * reactive position view. When called outside a reactive scope, the adapter's * listeners are still removed when `handle.destroy()` is called. */ export declare const draggablePosition: (el: HTMLElement, handle: DraggableHandle) => ReadonlySignal; /** * Wraps an existing {@link SortableHandle} so its current item order is * observable as a signal. The signal value is refreshed by listening for * `pointerup` events on the container, which is when sorts conclude. * * @remarks * Prefer {@link useSortable} for new code — this adapter exists for cases * where the sortable handle is created externally and you only need a * reactive order view. When called outside a reactive scope, the adapter's * listener is still removed when `handle.destroy()` is called. */ export declare const sortableOrder: (container: HTMLElement, handle: SortableHandle) => ReadonlySignal; //# sourceMappingURL=reactive.d.ts.map