import { useState, useEffect } from "react"; import { IconDefinition } from "@fortawesome/fontawesome-svg-core"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { twMerge } from "tailwind-merge"; import { Tooltip } from "../Tooltip"; // Adjust the path if necessary interface Option { value: string; icon: IconDefinition; text?: string; tooltip?: string; } interface ButtonIconSelectProps { options: Option[]; onOptionChange?: (value: string) => void; selectedOption?: string; } export function ButtonIconSelect({ options, onOptionChange, selectedOption, }: ButtonIconSelectProps) { const [internalSelectedOption, setInternalSelectedOption] = useState( selectedOption || options[0].value, ); useEffect(() => { setInternalSelectedOption(selectedOption || options[0].value); }, [selectedOption, options]); const handleOptionChange = (value: string) => { setInternalSelectedOption(value); if (onOptionChange) { onOptionChange(value); } }; return (
{options.map(({ value, icon, text, tooltip }) => tooltip ? ( ) : ( ), )}
); }