'use client' import type { ChangeEvent, FC } from 'react' import React, { useState } from 'react' import data from '@emoji-mart/data' import type { EmojiMartData } from '@emoji-mart/data' import { init } from 'emoji-mart' import { MagnifyingGlassIcon, } from '@heroicons/react/24/outline' import cn from '@/utils/classnames' import Divider from '@/app/components/base/divider' import { searchEmoji } from '@/utils/emoji' declare global { namespace JSX { // eslint-disable-next-line @typescript-eslint/consistent-type-definitions interface IntrinsicElements { 'em-emoji': React.DetailedHTMLProps< React.HTMLAttributes, HTMLElement > } } } init({ data }) const backgroundColors = [ '#FFEAD5', '#E4FBCC', '#D3F8DF', '#E0F2FE', '#E0EAFF', '#EFF1F5', '#FBE8FF', '#FCE7F6', '#FEF7C3', '#E6F4D7', '#D5F5F6', '#D1E9FF', '#D1E0FF', '#D5D9EB', '#ECE9FE', '#FFE4E8', ] type IEmojiPickerInnerProps = { emoji?: string background?: string onSelect?: (emoji: string, background: string) => void className?: string } const EmojiPickerInner: FC = ({ onSelect, className, }) => { const { categories } = data as EmojiMartData const [selectedEmoji, setSelectedEmoji] = useState('') const [selectedBackground, setSelectedBackground] = useState(backgroundColors[0]) const [searchedEmojis, setSearchedEmojis] = useState([]) const [isSearching, setIsSearching] = useState(false) React.useEffect(() => { if (selectedEmoji && selectedBackground) onSelect?.(selectedEmoji, selectedBackground) }, [onSelect, selectedEmoji, selectedBackground]) return
) => { if (e.target.value === '') { setIsSearching(false) } else { setIsSearching(true) const emojis = await searchEmoji(e.target.value) setSearchedEmojis(emojis) } }} />
{isSearching && <>

Search

{searchedEmojis.map((emoji: string, index: number) => { return
{ setSelectedEmoji(emoji) }} >
})}
} {categories.map((category, index: number) => { return

{category.id}

{category.emojis.map((emoji, index: number) => { return
{ setSelectedEmoji(emoji) }} >
})}
})}
{/* Color Select */}

Choose Style

{backgroundColors.map((color) => { return
{ setSelectedBackground(color) }} >
{selectedEmoji !== '' && }
})}
} export default EmojiPickerInner