import React, { useEffect, useState, useRef } from "react"; // headless ui import { Tab, Transition, Popover } from "@headlessui/react"; // react colors import { TwitterPicker } from "react-color"; // types import { Props } from "./types"; // emojis import emojis from "./emojis.json"; import icons from "./icons.json"; // helpers import { getRecentEmojis, saveRecentEmoji } from "./helpers"; import { getRandomEmoji } from "helpers/common.helper"; // hooks import useOutsideClickDetector from "hooks/use-outside-click-detector"; const tabOptions = [ { key: "emoji", title: "Emoji", }, { key: "icon", title: "Icon", }, ]; const EmojiIconPicker: React.FC = ({ label, value, onChange, onIconColorChange, onIconsClick, }) => { const ref = useRef(null); const [isOpen, setIsOpen] = useState(false); const [openColorPicker, setOpenColorPicker] = useState(false); const [activeColor, setActiveColor] = useState("#858e96"); const [recentEmojis, setRecentEmojis] = useState([]); useEffect(() => { setRecentEmojis(getRecentEmojis()); }, []); useOutsideClickDetector(ref, () => { setIsOpen(false); }); useEffect(() => { if (!value || value?.length === 0) onChange(getRandomEmoji()); }, [value, onChange]); return ( setIsOpen((prev) => !prev)} > {label}
{tabOptions.map((tab) => ( {({ selected }) => ( )} ))} {recentEmojis.length > 0 && (

Recent

{recentEmojis.map((emoji) => ( ))}
)}
{emojis.map((emoji) => ( ))}
{[ "#FF6B00", "#8CC1FF", "#FCBE1D", "#18904F", "#ADF672", "#05C3FF", "#000000", ].map((curCol) => ( setActiveColor(curCol)} /> ))}
{ setActiveColor(color.hex); if (onIconColorChange) onIconColorChange(color.hex); }} triangle="hide" width="205px" />

{icons.material_rounded.map((icon) => ( ))}
); }; export default EmojiIconPicker;