Skip to main content
On this pageFunctions

Ui/DragAndDrop

Functions

droppable

functionsource
/**
 * Returns attributes the parent attaches to a droppable container element.
 *  Handler-free, so the bundle is built with `inertHtml` and spreads into
 *  any Message universe's attribute array.
 */
(
  containerId: string,
  label?: string
): readonly Array<Attribute<never>>

ghostStyle

functionsource

isDragging

functionsource

maybeDraggedItemId

functionsource

maybeDropTarget

functionsource

sortable

functionsource
/**
 * Returns attributes the parent attaches to a sortable item element.
 *  Typically combined with `draggable`. Handler-free, so the bundle is built
 *  with `inertHtml` and spreads into any Message universe's attribute
 *  array.
 */
(itemId: string): readonly Array<Attribute<never>>

Types

DraggableAttributesInput

typesource
/** Identifies the draggable item and its current location. */
type DraggableAttributesInput = Readonly<{
  containerId: string
  index: number
  itemId: string
}>

InitConfig

typesource
type InitConfig = Readonly<{
  activationThreshold: number
  id: string
  orientation: "Horizontal" | "Vertical"
}>

RenderInfo

typesource
/** Attribute builders supplied to the consumer's `toView` callback. */
type RenderInfo = Readonly<{
  draggable: (input: DraggableAttributesInput) => ReadonlyArray<ChildAttribute>
  droppable: (containerId: string, label?: string) => ReadonlyArray<ChildAttribute>
  sortable: (itemId: string) => ReadonlyArray<ChildAttribute>
}>

ViewInputs

typesource
/** Per-render inputs passed to the DragAndDrop connection's `embedView` method. */
type ViewInputs = Readonly<{
  toView: (render: RenderInfo) => Html
}>

Constants

DragState

constsource
/** Schema for the current pointer or keyboard drag phase. */
const DragState: TaggedUnion<{
  Dragging: {
    current: Struct<{
      clientX: Number
      clientY: Number
    }>
    itemId: String
    maybeDropTarget: Option<Struct<{
      containerId: String
      index: Number
    }>>
    origin: Struct<{
      screenX: Number
      screenY: Number
    }>
    sourceContainerId: String
    sourceIndex: Number
  }
  Idle: {}
  KeyboardDragging: {
    itemId: String
    sourceContainerId: String
    sourceIndex: Number
    targetContainerId: String
    targetIndex: Number
  }
  Pending: {
    containerId: String
    index: Number
    itemId: String
    origin: Struct<{
      screenX: Number
      screenY: Number
    }>
  }
}>