SearchCtrlK

  • ↑↓navigate
  • ↵open
  • escclose

Can’t find it? Contact us

dropZone

Drag-and-drop file acceptance for a DropZone.

tsx
import { dropZone } from "@sdxc/ui/app";

Usage

Adds drag-and-drop file acceptance to a DropZone, driving session through native dragenter/dragover/dragleave/drop events and mirroring its target onto the host as DROP_TARGET_ATTRIBUTE.

Signature

typescript
dropZone(session: DragSession<unknown>): MixinDescriptor<HTMLElement>

Parameters

ParameterTypeDefaultRequiredDescription
sessionDragSession<unknown>—YesDragSession instance the mixin drives; share the same instance with a DropIndicator or another mixin that needs to observe the same drag.

Examples

tsx
let session = new DragSession();
<div id="uploads" mix={dropZone(session)}>
  <input type="file" multiple />
</div>

The events, constants and types its module publishes, each imported from @sdxc/ui/app too.

Event

DropFilesEvent

Dispatched on a DropZone's host by dropZone once a drop carries at least one file, carrying those files directly so a consumer can start uploading from the event detail.

typescript
new DropFilesEvent(files: readonly File[])
PropertyTypeDefaultRequiredDescription
filesreadonly readonly File[]—YesFiles carried by the drop that triggered this event.
Constant

DROP_TARGET_ATTRIBUTE

data-* attribute dropZone toggles on its host while a file drag from outside the page hovers over it, so a DropZone's styling can render the drag-over highlight from this attribute alone.

typescript
const DROP_TARGET_ATTRIBUTE = "data-drop-target"
@sdxc/ui

Can’t find it? Contact us