import { useState, useId } from 'react' import { ChevronDown, ChevronUp } from 'lucide-react' /** * Kuratierte Emoji-Gruppen für Sport, Körper, Ernährung usw. * Kann bei Bedarf erweitert werden (z. B. prop `extraGroups`). */ export const EMOJI_ICON_GROUPS = [ { label: 'Training & Sport', emojis: [ '🏃', '🚴', '🏊', '🧘', '🏋️', '⛷️', '🤸', '🥊', '🎾', '⚽', '🏀', '🤺', '🚶', '🧗', '⛰️', '🏄', '🤿', '🥋', '🤼', '⛹️', '🤾', '🏌️', '🎿', '🧗♂️' ] }, { label: 'Körper & Gesundheit', emojis: [ '💪', '❤️', '🫀', '🦵', '🧠', '👁️', '⚖️', '📏', '🩺', '💊', '🌡️', '🫁' ] }, { label: 'Ernährung', emojis: [ '🍎', '🥩', '🥗', '🍽️', '💧', '☕', '🥤', '🥛', '🍌', '🥑', '🍞', '🐟' ] }, { label: 'Schlaf & Erholung', emojis: ['😴', '🌙', '🛌', '💤', '🧖', '☀️', '🌿'] }, { label: 'Allgemein', emojis: [ '🎯', '📊', '🔥', '⭐', '✨', '🎵', '📌', '🧭', '📝', '✅', '💡', '🪄' ] } ] /** * Wiederverwendbare Emoji-/Icon-Auswahl: Vorschau, Freitext (inkl. System-Emoji-Picker), * optional ausklappbare Vorschläge. * * @param {string} value – aktueller Icon-String (meist ein Emoji) * @param {(next: string) => void} onChange * @param {string} [placeholder] * @param {number} [maxLength=10] * @param {boolean} [disabled] * @param {string} [id] – optionale ID für das Textfeld (Label for=) * @param {boolean} [defaultExpanded=false] – Vorschlags-Bereich initial offen */ export default function EmojiIconPicker({ value, onChange, placeholder = '📝', maxLength = 10, disabled = false, id: idProp, defaultExpanded = false }) { const uid = useId() const inputId = idProp || `emoji-icon-${uid}` const [open, setOpen] = useState(defaultExpanded) const handleInput = (e) => { onChange(e.target.value.slice(0, maxLength)) } const pick = (em) => { onChange(em.slice(0, maxLength)) } return (
Du kannst auch direkt in das Feld tippen oder das Betriebssystem-Emoji-Menü nutzen (z. B. Win + . unter Windows).