import * as React from 'react'; import { cn } from '@/lib/utils'; export interface TabBarItem { id: T; label: React.ReactNode; } interface TabBarProps { tabs: TabBarItem[]; activeTab: T; onTabChange: (id: T) => void; tablistId: string; ariaLabel: string; className?: string; } export function TabBar({ tabs, activeTab, onTabChange, tablistId, ariaLabel, className, }: TabBarProps) { return (
{ if (e.key !== 'ArrowRight' && e.key !== 'ArrowLeft') return; e.preventDefault(); const idx = tabs.findIndex((t) => t.id === activeTab); const delta = e.key === 'ArrowRight' ? 1 : -1; const next = tabs[(idx + delta + tabs.length) % tabs.length]; onTabChange(next.id); document.getElementById(`${tablistId}-tab-${next.id}`)?.focus(); }} > {tabs.map((tab) => ( ))}
); }