import React, { useState, useRef, useEffect } from 'react'; import Icon from './Icon'; interface IconPickerProps { options: { label: string, value: string }[]; onClick; value: string; menuPosition?: string; className?: string; } export default function IconPicker(props:IconPickerProps) { const [isActive, setIsActive] = useState(false) const clickOutsideRef = useRef(null); const currentOption = props.options.find(option => option.value === props.value) const handleClickOutside = (e) => { if (!clickOutsideRef.current.contains(e.target)) { setIsActive(false); } }; const handleClick = (newValue) => { props.onClick(newValue) setIsActive(false) } const togglePicker = () => { setIsActive(!isActive) } useEffect(() => { document.addEventListener('mousedown', handleClickOutside); return () => document.removeEventListener('mousedown', handleClickOutside); }); const options = props.options.map((option) => { return ( <>