View as Markdown

API reference: @salmonui/dropdowns/listbox

moveItemsfunction

import { moveItems } from '@salmonui/dropdowns/listbox';
function moveItems<T>(source: readonly T[], target: readonly T[], values: Iterable<ListboxKey>, index?: number, getItemValue?: (item: T) => ListboxKey): [
    nextSource: T[],
    nextTarget: T[]
];

Moves the items whose values are in values from source to target, inserted at index of target (default: the end), in source order. Returns [nextSource, nextTarget]. When source === target the items move within the list: index is the insertion index in the current list (as a drop position), and both results are the same new array.