@mitcsutt/kiln-dnd
Version:
Kiln drag and drop: sortable lists, boards, drop zones and grid layouts with one keyboard model and one announcer, rendered through kiln-ui
30 lines (29 loc) • 1.36 kB
TypeScript
import { type HTMLAttributes } from 'react';
import type { DndItem } from '../../core/controller.js';
export interface DropZoneProps extends Omit<HTMLAttributes<HTMLDivElement>, 'id' | 'onDrop'> {
/** Unique within the `Dnd` scope. */
id: string;
/** The zone's name, as announcements say it ("Archive"). */
label: string;
/** Which items it takes. Default: every item in the scope. */
accept?: (item: DndItem) => boolean;
/** Anything you want back in `onDragEnd`'s target. */
data?: unknown;
/** Stops it taking drops. */
disabled?: boolean;
/** Called when an item is dropped here, with the item's `id`, `label` and `data`. */
onDrop?: (item: DndItem) => void;
}
/**
* A place to drop `Draggable` items.
*
* @remarks
* A `DropZone` is a framed area. While an item it accepts is being dragged, its frame
* darkens; when the item would land in it, it fills with the accent's soft tint. Its
* `label` is what a keyboard user hears as the arrow keys bring an item over it ("Invoice
* 1042 is over Archive"), so name it after the destination.
*
* `onDrop` gets the dropped item. Put the zone's own content (a heading, the items it
* already holds) inside it.
*/
export declare const DropZone: import("react").ForwardRefExoticComponent<DropZoneProps & import("react").RefAttributes<HTMLDivElement>>;