"use client"; import { forwardRef, memo, useCallback } from "react"; import { SelectOptionView } from "./SelectOption.view"; import type { SelectOptionProps } from "./SelectOption.types"; const SelectOptionContainer = forwardRef( ( { children, selected = false, disabled = false, className = "", onClick, size = "medium", ...props }, ref, ) => { const getTextSize = (): string => { switch (size) { case "small": return "text-[10px] leading-[14px]"; case "medium": return "text-[14px] leading-[20px]"; case "large": return "text-[16px] leading-[24px]"; default: return "text-[14px] leading-[20px]"; } }; const itemClasses = ` flex items-center justify-between px-[8px] py-[4px] text-[var(--color-content-default-brand-primary)] ${getTextSize()} cursor-pointer transition-colors duration-150 ${ selected ? "bg-[var(--color-surface-default-secondary)] rounded-[var(--measures-radius-small)]" : "" } ${ disabled ? "opacity-50 cursor-not-allowed" : "hover:!bg-[var(--color-surface-default-secondary)] hover:!rounded-[var(--measures-radius-small)]" } ${className} ` .trim() .replace(/\s+/g, " "); const handleClick = useCallback( (e: React.MouseEvent) => { if (!disabled && onClick) { onClick(e); } }, [disabled, onClick], ); const handleKeyDown = useCallback( (e: React.KeyboardEvent) => { if (e.key === "Enter" || e.key === " ") { e.preventDefault(); if (!disabled && onClick) { onClick(e); } } }, [disabled, onClick], ); return ( {children} ); }, ); SelectOptionContainer.displayName = "SelectOption"; export default memo(SelectOptionContainer);