A SortableList component to display a list of items that can be reordered with drag and drop or keyboard navigation.
| Name | Type | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
props | object | Component props. Properties
|
- Since
- 3.3.6
The Sortable List component.
- Type:
- JSX.
Element
Methods
(inner) addExternalItem(e)
Add an item to the list from an external source.
| Name | Type | Description |
|---|---|---|
e | Event | The triggering event with item data in detail property. |
- Since
- 1.0.0
void
(inner) addItem()
Add an item to the list.
- Since
- 1.0.0
void
(inner) calculateDropIndex(mouseY) → {number}
Calculate the insertion index based on mouse position relative to existing items.
| Name | Type | Description |
|---|---|---|
mouseY | number | The Y position of the mouse relative to the document. |
- Since
- 1.0.0
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
void
(inner) clearExternalDragState()
Clear the visual state when no longer receiving external drag.
- Since
- 1.0.0
void
(inner) deleteItem(deleteId)
Delete an item from the list.
| Name | Type | Description |
|---|---|---|
deleteId | string | ID of the item to be deleted. |
- Since
- 1.0.0
void
(inner) isMouseOverThisList(clientX, clientY) → {boolean}
Check if the mouse coordinates are over this specific list container.
| Name | Type | Description |
|---|---|---|
clientX | number | The X coordinate of the mouse. |
clientY | number | The Y coordinate of the mouse. |
- Since
- 1.0.0
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.
| Name | Type | Description |
|---|---|---|
target | Element | The target element to check. |
- Since
- 1.0.0
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.
| Name | Type | Description |
|---|---|---|
originIndex | number | The original index of the item. |
newIndex | number | The new index of the item. |
- Since
- 1.0.0
void
(inner) renderDropIndicator(index, position) → {JSX.Element}
Render a visual indicator showing where an external item will be dropped.
| Name | Type | Description |
|---|---|---|
index | number | The index where the indicator should appear. |
position | string | Additional identifier for unique keys (e.g., 'start', 'end', 'empty'). |
- Since
- 1.0.0
The drop indicator component.
- Type:
- JSX.
Element
(inner) renderEmptyState() → {JSX.Element}
Render the emptyh state UI.
- Since
- 1.0.0
A JSX element.
- Type:
- JSX.
Element
(inner) renderItemsWithIndicators() → {Array}
Render all items with drop indicators interspersed between them.
- Since
- 1.0.0
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.
| Name | Type | Description |
|---|---|---|
listItem | object | The list item to render. |
index | number | The index to render at. |
- Since
- 1.0.0
The rendered list item component.
- Type:
- JSX.
Element |null
(inner) renderSortableList(origDepth, children) → {JSX.Element|null}
Render a nested SortableList component.
| Name | Type | Description |
|---|---|---|
origDepth | number | The original depth of the item. |
children | Array | | The children of the item. |
- Since
- 1.0.0
The nested SortableList component or null.
- Type:
- JSX.
Element |null
(inner) updateExternalDragState(insertIndex)
Update the visual state and data attributes when receiving external drag.
| Name | Type | Description |
|---|---|---|
insertIndex | number | The calculated insertion index. |
- Since
- 1.0.0
void