export function moveArrayItem(items: T[], fromIndex: number, toIndex: number) { if ( fromIndex < 0 || toIndex < 0 || fromIndex >= items.length || toIndex >= items.length || fromIndex === toIndex ) { return items; } const nextItems = [...items]; const [movedItem] = nextItems.splice(fromIndex, 1); nextItems.splice(toIndex, 0, movedItem); return nextItems; }