import React, { useState } from 'react'; import { Button } from '@/components/ui/button'; import { Popover, PopoverContent, PopoverTrigger, } from '@/components/ui/popover'; interface EmojiPickerProps { value?: string; onChange: (emoji: string) => void; disabled?: boolean; } // 扩展的emoji分类 const EMOJI_CATEGORIES = { common: [ '⚙️', '📚', '🔗', '📁', '💡', '🎯', '✨', '🚀', '📝', '🔧', '⚡', '🔥', '💎', '🎨', '🎭', ], objects: [ '📦', '📂', '📋', '📌', '🔖', '💼', '🗂️', '📮', '🗃️', '📊', '📈', '📉', '🗄️', '📇', '🗳️', ], symbols: [ '🔴', '🟠', '🟡', '🟢', '🔵', '🟣', '⚪', '⚫', '🟤', '🔺', '🔻', '🔶', '🔷', '🔸', '🔹', ], nature: [ '🌟', '⭐', '🌈', '💧', '🌍', '🌙', '☀️', '🌱', '🌲', '🌳', '🌴', '🌵', '🌾', '🍀', '🌻', ], faces: [ '😀', '😊', '🤔', '😎', '🤖', '👾', '💬', '💭', '❤️', '⚠️', '✅', '❌', '🎉', '🎊', '🎈', ], tech: [ '💻', '📱', '⌨️', '🖥️', '🖱️', '💾', '💿', '📀', '🔌', '🔋', '📡', '🛰️', '🖨️', '🖲️', '💽', ], science: [ '🔬', '🔭', '⚗️', '🧪', '🧬', '🧫', '🩺', '💊', '💉', '🌡️', '🧲', '⚛️', '🧬', '🦠', '🧫', ], business: [ '💼', '📊', '📈', '💰', '💵', '💴', '💶', '💷', '💳', '💸', '📉', '💹', '🏦', '🏢', '🏭', ], }; const CATEGORY_LABELS: { [key: string]: string } = { common: '常用', objects: '物品', symbols: '符号', nature: '自然', faces: '表情', tech: '科技', science: '科学', business: '商业', }; // 每个分类的代表性 emoji(用于分页按钮) const CATEGORY_ICONS: { [key: string]: string } = { common: '⭐', objects: '📦', symbols: '🔴', nature: '🌟', faces: '😀', tech: '💻', science: '🔬', business: '💼', }; export default function EmojiPicker({ value, onChange, disabled, }: EmojiPickerProps) { const [open, setOpen] = useState(false); const [activeCategory, setActiveCategory] = useState('common'); const handleEmojiSelect = (emoji: string) => { onChange(emoji); setOpen(false); }; const currentEmojis = EMOJI_CATEGORIES[activeCategory as keyof typeof EMOJI_CATEGORIES]; return (
{/* 分类标题 */}

{CATEGORY_LABELS[activeCategory]}

{/* Emoji 网格 */}
{currentEmojis.map((emoji, index) => ( ))}
{/* 分类切换按钮 */}
{Object.keys(EMOJI_CATEGORIES).map((category) => ( ))}
); }