import { type CSSProperties, type KeyboardEvent, type Ref, useEffect, } from "react"; import { EmojiPicker, type Locale as EmojiLocale, useSkinTone, } from "frimousse"; import { t } from "@lingui/core/macro"; import { Trans } from "@lingui/react/macro"; import { useLingui } from "@lingui/react"; import { readSkinTone, SKIN_TONE_KEY } from "./skinTone.ts"; /** Remembers the skin tone picked in the selector for the next picker. */ function SkinTonePersist() { const [skinTone] = useSkinTone(); useEffect(() => { try { localStorage.setItem(SKIN_TONE_KEY, skinTone); } catch { // Private mode: the tone lasts as long as the picker. } }, [skinTone]); return null; } interface EmojiPickerPopupProps { floatRef: Ref; searchRef: Ref; viewportRef: Ref; style: CSSProperties; /** Inline, the query is typed in the textarea and the search only shows it; * browsing, the search field takes it. */ inline: boolean; query: string; onQueryChange: (query: string) => void; onSelect: (emoji: string) => void; onClose: () => void; onKeyDownCapture: (e: KeyboardEvent) => void; } /** The floating emoji picker the editor opens from its button or a `:query`. */ export function EmojiPickerPopup( { floatRef, searchRef, viewportRef, style, inline, query, onQueryChange, onSelect, onClose, onKeyDownCapture, }: EmojiPickerPopupProps, ) { const { i18n } = useLingui(); return (
onSelect(e.emoji)} locale={i18n.locale as EmojiLocale} emojibaseUrl={import.meta.env.VITE_EMOJIBASE_URL} skinTone={readSkinTone()} >
onQueryChange(e.target.value)} placeholder={t`Search emoji…`} aria-label={t`Search emoji`} readOnly={inline} tabIndex={inline ? -1 : undefined} />
Loading… No emoji found.
); }