ObjectStackObjectStack

Dnd

Dnd protocol schemas

Drag Handle Schema

Defines how a drag interaction is initiated on an element.

Source: packages/spec/src/ui/dnd.zod.ts

TypeScript Usage

import { DndConfig, DragConstraint, DragHandle, DragItem, DropEffect, DropZone } from '@objectstack/spec/ui';
import type { DndConfig, DragConstraint, DragHandle, DragItem, DropEffect, DropZone } from '@objectstack/spec/ui';

// Validate data
const result = DndConfig.parse(data);

DndConfig

Drag and drop interaction configuration

Properties

PropertyTypeRequiredDescription
enabledbooleanEnable drag and drop
dragItemObjectoptionalConfiguration for draggable item
dropZoneObjectoptionalConfiguration for drop target
sortablebooleanEnable sortable list behavior
autoScrollbooleanAuto-scroll during drag near edges
touchDelaynumberDelay in ms before drag starts on touch devices

DragConstraint

Drag movement constraints

Properties

PropertyTypeRequiredDescription
axisEnum<'x' | 'y' | 'both'>Constrain drag axis
boundsEnum<'parent' | 'viewport' | 'none'>Constrain within bounds
gridany[]optionalSnap to grid [x, y] in pixels

DragHandle

Drag initiation method

Allowed Values

  • element
  • handle
  • grip_icon

DragItem

Draggable item configuration

Properties

PropertyTypeRequiredDescription
typestringDrag item type identifier for matching with drop zones
labelstring | ObjectoptionalAccessible label describing the draggable item
handleEnum<'element' | 'handle' | 'grip_icon'>How to initiate drag
constraintObjectoptionalDrag movement constraints
previewEnum<'element' | 'custom' | 'none'>Drag preview type
disabledbooleanDisable dragging
ariaLabelstring | ObjectoptionalAccessible label for screen readers (WAI-ARIA aria-label)
ariaDescribedBystringoptionalID of element providing additional description (WAI-ARIA aria-describedby)
rolestringoptionalWAI-ARIA role attribute (e.g., "dialog", "navigation", "alert")

DropEffect

Drop operation effect

Allowed Values

  • move
  • copy
  • link
  • none

DropZone

Drop zone configuration

Properties

PropertyTypeRequiredDescription
labelstring | ObjectoptionalAccessible label for the drop zone
acceptstring[]Accepted drag item types
maxItemsnumberoptionalMaximum items allowed in drop zone
highlightOnDragOverbooleanHighlight drop zone when dragging over
dropEffectEnum<'move' | 'copy' | 'link' | 'none'>Visual effect on drop
ariaLabelstring | ObjectoptionalAccessible label for screen readers (WAI-ARIA aria-label)
ariaDescribedBystringoptionalID of element providing additional description (WAI-ARIA aria-describedby)
rolestringoptionalWAI-ARIA role attribute (e.g., "dialog", "navigation", "alert")

On this page