import { Popover, TextField } from '@mui/material'; import React, { useMemo, useState } from 'react'; import { HexColorPicker } from 'react-colorful'; import { hexColorPattern } from '@/config/colors'; import ColorAvatar from './ColorAvatar'; type Props = { label: string; color: string; className?: string; onChange: (color: string) => void; }; const ColorPicker: React.FC = ({ label, color, onChange, className }) => { const isValid = useMemo(() => hexColorPattern.test(color), [color]); const [anchorEl, setAnchorEl] = useState(null); const isOpen = Boolean(anchorEl); const handleOpen = (event: React.MouseEvent) => { setAnchorEl(event.currentTarget); }; const handleClose = () => { setAnchorEl(null); }; const handleChange = (event: React.ChangeEvent) => { if (hexColorPattern.test(event.target.value)) { onChange(event.target.value); } }; return ( <> ), }} /> ); }; export default ColorPicker;