/** * The tab a key moves to in a tablist with automatic activation: Left and * Right wrap, Home and End jump. null for any other key. */ export function nextIndex(key: string, index: number, count: number): number | null { if (count <= 0) return null switch (key) { case 'ArrowRight': return (index + 1) % count case 'ArrowLeft': return (index - 1 + count) % count case 'Home': return 0 case 'End': return count - 1 default: return null } }