/** * EmojiPicker - Emoji selection component for Agent onboarding * * Displays categorized emoji presets for users to choose from. */ import { useState } from 'react'; import { motion, AnimatePresence } from 'framer-motion'; import { cn } from '../../lib/utils'; import { EMOJI_PRESETS, ALL_EMOJIS } from '../../lib/personality-presets'; type EmojiCategory = 'all' | 'animals' | 'objects' | 'expressions'; export interface EmojiPickerProps { value?: string; onChange: (emoji: string) => void; className?: string; } const categoryLabels: Record = { all: '全部', animals: '动物', objects: '物体', expressions: '表情', }; export function EmojiPicker({ value, onChange, className }: EmojiPickerProps) { const [activeCategory, setActiveCategory] = useState('all'); const getEmojisForCategory = (category: EmojiCategory): string[] => { if (category === 'all') { return ALL_EMOJIS; } return EMOJI_PRESETS[category] || []; }; const emojis = getEmojisForCategory(activeCategory); return (
{/* Category Tabs */}
{(Object.keys(categoryLabels) as EmojiCategory[]).map((category) => ( ))}
{/* Emoji Grid */} {emojis.map((emoji) => ( onChange(emoji)} className={cn( 'w-9 h-9 flex items-center justify-center text-xl rounded-lg transition-all', 'hover:bg-gray-100 dark:hover:bg-gray-700', 'focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-1', value === emoji && 'bg-primary/10 ring-2 ring-primary' )} > {emoji} ))} {/* Selected Preview */} {value && ( {value} 已选择 )}
); }