@metreeca/tile
    Preparing search index...

    Headless sortable lists.

    Holds a fixed set of labelled lists and the items each holds, offering the moves a reader performs on them: an item is picked up, carried to any position in any list, and finally either dropped, leaving it where it stands while the new order waits to be settled, or cancelled, restoring the order it was picked up from. No item is picked up while a dropped one is waiting, so moves are settled one at a time. Items are identified by keys unique across all lists, so an item keeps its identity wherever it is carried.

    The lists stand for the gesture under way, not for the order an application keeps: once settled, a move restores the order it started from, and the order the application adopts arrives as new lists created from it.

    A move yields new lists and leaves these as they stand, so lists read earlier keep their items and their order. One that changes nothing yields these lists themselves, which a rendering layer takes as nothing to redraw.

    interface Sortable {
        lists: Readonly<Record<string, readonly string[]>>;
        held: Optional<string>;
        pending: Optional<string>;
        settled: Optional<string>;
        focus: Optional<string>;
        active: Optional<string>;
        activate(item: string): this;
        pick(item: string, focus?: boolean): this;
        move(list: string, index: number): this;
        drop(): this;
        settle(): this;
        cancel(): this;
    }
    Index
    lists: Readonly<Record<string, readonly string[]>>

    The keys of the items in each list, in display order, keyed by the list label, in display order.

    held: Optional<string>

    The key of the item being moved, or undefined if none is picked up.

    pending: Optional<string>

    The key of the item dropped and waiting for its new order to be settled, or undefined if none is waiting.

    settled: Optional<string>

    The key of the item whose wait ended last, or undefined if none ended since an item was last picked up.

    focus: Optional<string>

    The key of the item owing the focus, or undefined if none does: the item last picked up from the keyboard takes the focus back whenever it is drawn afresh, in the list it is carried into or the one it is sent back to, until another item is picked up.

    active: Optional<string>

    The key of the item the keyboard last stood on, or undefined if none: the one item of the lists reached with Tab, the others being reached from it with the arrow keys.

    • Marks the item the keyboard stands on.

      Parameters

      • item: string

        The key of the item reached

      Returns this

      Lists with item active

    • Picks up an item.

      Parameters

      • item: string

        The key of the item to move

      • Optionalfocus: boolean

        Whether the item is picked up from the keyboard, so that it owes the focus

      Returns this

      Lists holding item, owing the focus to it if picked up from the keyboard and to no item otherwise, with no item settled, or these lists if item is unknown, an item is already held, or a dropped one is waiting

    • Carries the held item to a new position.

      Parameters

      • list: string

        The label of the list to carry the held item into

      • index: number

        The position the held item is to take in list, counted once the held item is taken out of its current place; clamped to the positions available in list

      Returns this

      Lists with the held item at index in list, or these lists if no item is held, list is unknown or the held item already stands there

    • Drops the held item where it stands, leaving it waiting for the new order to be settled.

      Returns this

      Lists holding no item, keeping the current order, with the item dropped waiting, or these lists if no item is held

    • Ends the wait for the dropped item.

      Returns this

      Lists with no item waiting and the item dropped settled, in the order they had when the item was picked up, or these lists if no item is waiting

    • Sends the held item back to where it was picked up from.

      Returns this

      Lists holding no item, in the order they had when the item was picked up, or these lists if no item is held