, currentValue: string) => {
const currentIndex = enabledItems.findIndex((item) => item.value === currentValue);
let nextIndex: number | null = null;
if (e.key === 'ArrowRight' || e.key === 'ArrowDown') {
nextIndex = (currentIndex + 1) % enabledItems.length;
} else if (e.key === 'ArrowLeft' || e.key === 'ArrowUp') {
nextIndex = (currentIndex - 1 + enabledItems.length) % enabledItems.length;
} else if (e.key === 'Home') {
nextIndex = 0;
} else if (e.key === 'End') {
nextIndex = enabledItems.length - 1;
}
if (nextIndex !== null) {
e.preventDefault();
const nextValue = enabledItems[nextIndex].value;
tabRefs.current.get(nextValue)?.focus();
handleTabClick(nextValue);
}
};
const sizeClasses = {
sm: 'px-3 py-1.5 text-xs',
md: 'px-4 py-2 text-sm',
};
const isDefault = variant === 'default';
const isUnderline = variant === 'underline';
return (
{/* Sliding indicator */}
{items.map((item) => {
const isActive = activeValue === item.value;
return (
);
})}
);
};
AppTab.displayName = 'AppTab';
export default AppTab;