FragiolaDnD
Documentation
API (@fragiola/dnd-react)

SortableGroup

The optional wrapper that marks a sortable group's container, so an item can be sorted into the group while it is empty or to the container's end.

SortableGroup marks the one element it wraps as the container of a sortable group. It renders no element of its own. A list never needs it to sort within itself; it is needed only to sort into a group while it is empty, or to the end of a container taller than its items.

column.tsx
import { Sortable, SortableGroup } from "@fragiola/dnd-react/sortable";

<SortableGroup group="done" accepts={["todo", "doing"]}>
    <ul aria-label="Done" className="column data-dnd-sorting:outline-dashed">
        {done.map((id, index) => (
            <Sortable key={id} id={id} index={index} group="done" accepts={["todo", "doing"]}>
                <li>{id}</li>
            </Sortable>
        ))}
    </ul>
</SortableGroup>;

Props

proptypedefault
groupstringrequiredthe group whose container it is
scopestringthe default scopeits group's scope
spaceDragSpaceits document'san explicit space from createDragSpace
dataunknownwhat the drop middleware sees as the target's data (ctx.target.data)
disabledbooleanfalsethe group is never sorted into, nor within; its items may still leave it
acceptsstring[] | (source: SortSource) => booleanthe other groups whose items it takes, with its items' own accepts
strategySortStrategyits items', else verticalListhow the group places and shifts items
className, style, render, ref, childrenas on Draggable, with the group's state

Any other prop is forwarded to the element.

Where an item lands

In an empty group, the item lands at the container's inline-start top corner. Use padding on the container to place it. An item coming from another group over the container, but over none of its items, goes to the end. Once the item is in the group, a place between items does not change it.

State

{ sorting: boolean; disabled: boolean }, given to className, style and render. sorting is true while a sort its group takes part in runs: the source's group, or one that accepts it.

Attributes

attributewhen
data-dnd-part="sortable-group"always
data-dnd-idalways: the group
data-dnd-sortinga sort it takes part in runs
data-dnd-disabled, aria-disabled="true"disabled
Kanban
Gallery

useSortableGroup

useSortableGroup(options) takes the same options and returns { state, props }: spread props (the registering ref and the attributes) onto the container's element.

column.tsx
const { state, props } = useSortableGroup({ group: "done", accepts: COLUMNS });
return <ul {...props} className={state.sorting ? "column open" : "column"} />;

In the core

registerSortableGroup(element, options) takes the same options and returns a registration (update, unregister, getState, subscribe).