A SortableList component to display a list of items that can be reordered with drag and drop or keyboard navigation.

Parameters:
NameTypeDescription
propsobject

Component props.

Properties
NameTypeDescription
borderstring

The border type.

customAttributesobject

Custom attributes for the component.

customClassesstring | Array | object

Custom classes for the component.

depthnumber

The current depth of this list.

itemsArray

The items for this list.

maxNestingnumber

The max number of levels of nesting to allow.

newItemPropsobject

The props to use for new items.

NewItemTemplatestring | function | element

The template to use for new items.

showAddboolean

Whether to show the add button.

showArrowsboolean

Whether to show the navigation arrows.

showDragHandleboolean

Whether to show the drag handle.

showDropZoneboolean

Whether to show the drop zone.

formFieldId
spacingstring | number | Array | object

The spacing for the component, as a string, number, array, or object.

enableExternalDragboolean

Whether to enable drag and drop from external sources.

showDropIndicatorsboolean

Whether to show visual drop indicators during external drag operations.

externalDragConfigobject

Configuration for external drag behavior including selectors and data attributes.

Since
  • 3.3.6
Returns:

The Sortable List component.

Type: 
JSX.Element

Methods

(inner) addExternalItem(e)

Add an item to the list from an external source.

Parameters:
NameTypeDescription
eEvent

The triggering event with item data in detail property.

Since
  • 1.0.0
Returns:

void

(inner) addItem()

Add an item to the list.

Since
  • 1.0.0
Returns:

void

(inner) calculateDropIndex(mouseY) → {number}

Calculate the insertion index based on mouse position relative to existing items.

Parameters:
NameTypeDescription
mouseYnumber

The Y position of the mouse relative to the document.

Since
  • 1.0.0
Returns:

The calculated insertion index.

Type: 
number

(inner) clearAllTargetStates()

Clear data attributes from all target elements to prevent conflicts between multiple lists.

Since
  • 1.0.0
Returns:

void

(inner) clearExternalDragState()

Clear the visual state when no longer receiving external drag.

Since
  • 1.0.0
Returns:

void

(inner) deleteItem(deleteId)

Delete an item from the list.

Parameters:
NameTypeDescription
deleteIdstring

ID of the item to be deleted.

Since
  • 1.0.0
Returns:

void

(inner) isMouseOverThisList(clientX, clientY) → {boolean}

Check if the mouse coordinates are over this specific list container.

Parameters:
NameTypeDescription
clientXnumber

The X coordinate of the mouse.

clientYnumber

The Y coordinate of the mouse.

Since
  • 1.0.0
Returns:

Whether the mouse is over this list.

Type: 
boolean

(inner) isValidDragSource(target) → {boolean}

Check if the target element is a valid drag source based on configuration.

Parameters:
NameTypeDescription
targetElement

The target element to check.

Since
  • 1.0.0
Returns:

Whether the element is a valid drag source.

Type: 
boolean

(inner) moveItem(originIndex, newIndex)

Moves an item within a list by a given set of positions.

Parameters:
NameTypeDescription
originIndexnumber

The original index of the item.

newIndexnumber

The new index of the item.

Since
  • 1.0.0
Returns:

void

(inner) renderDropIndicator(index, position) → {JSX.Element}

Render a visual indicator showing where an external item will be dropped.

Parameters:
NameTypeDescription
indexnumber

The index where the indicator should appear.

positionstring

Additional identifier for unique keys (e.g., 'start', 'end', 'empty').

Since
  • 1.0.0
Returns:

The drop indicator component.

Type: 
JSX.Element

(inner) renderEmptyState() → {JSX.Element}

Render the emptyh state UI.

Since
  • 1.0.0
Returns:

A JSX element.

Type: 
JSX.Element

(inner) renderItemsWithIndicators() → {Array}

Render all items with drop indicators interspersed between them.

Since
  • 1.0.0
Returns:

Array of JSX elements including items and indicators.

Type: 
Array

(inner) renderListItem(listItem, index) → {JSX.Element|null}

Render a list item with all necessary props.

Parameters:
NameTypeDescription
listItemobject

The list item to render.

indexnumber

The index to render at.

Since
  • 1.0.0
Returns:

The rendered list item component.

Type: 
JSX.Element | null

(inner) renderSortableList(origDepth, children) → {JSX.Element|null}

Render a nested SortableList component.

Parameters:
NameTypeDescription
origDepthnumber

The original depth of the item.

childrenArray | boolean

The children of the item.

Since
  • 1.0.0
Returns:

The nested SortableList component or null.

Type: 
JSX.Element | null

(inner) updateExternalDragState(insertIndex)

Update the visual state and data attributes when receiving external drag.

Parameters:
NameTypeDescription
insertIndexnumber

The calculated insertion index.

Since
  • 1.0.0
Returns:

void