Files
vue-chat-layer/app/lib/tabs.ts
Jakub Zych 5d581539b3 feat: port the chat store, realtime client and components
- realtime.ts: the page's one Centrifuge client, setRealtimeAuth, onUserEvent for user:{me} events the chat does not handle
- chatEvents, chatFormat, chatText, chatUnread, format, media, tabs ported; copy passed in localized
- useChat over useState: channels with join and leave, DMs, member list, unread and mention counts, read marks, typing, presence, polling fallback
- ChatPanel, ChatHeader, ChatMessage, ChatDmList, ChatMemberPicker, ChatMentionPopup, ChatAvatar, ChatIcon, ChatNotices
- EN and PL strings
2026-10-31 13:52:56 +01:00

20 lines
501 B
TypeScript

/**
* 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
}
}