2025-06-20 13:02:18 +00:00
|
|
|
import { Box, ButtonBase, Typography, useTheme, Modal } from "@mui/material";
|
|
|
|
import { useState } from "react";
|
|
|
|
import { EmojiPicker } from "./EmojiPicker";
|
2025-06-22 14:30:13 +00:00
|
|
|
import { useTranslation } from "react-i18next";
|
2025-06-20 13:02:18 +00:00
|
|
|
|
|
|
|
interface Props {
|
|
|
|
emoji: string;
|
|
|
|
onEmojiSelect?: (emoji: string) => void;
|
|
|
|
}
|
|
|
|
|
|
|
|
export const OwnEmojiPicker = ({ emoji = "", onEmojiSelect }: Props) => {
|
|
|
|
const theme = useTheme();
|
2025-06-22 14:30:13 +00:00
|
|
|
const { t } = useTranslation();
|
2025-06-20 13:02:18 +00:00
|
|
|
const [isPickerOpen, setIsPickerOpen] = useState(false);
|
|
|
|
|
|
|
|
const handleEmojiSelect = (emojiData: any) => {
|
|
|
|
onEmojiSelect?.(emojiData.native);
|
|
|
|
setIsPickerOpen(false);
|
|
|
|
};
|
|
|
|
|
|
|
|
const handleClick = (e: React.MouseEvent) => {
|
|
|
|
e.stopPropagation();
|
|
|
|
setIsPickerOpen(true);
|
|
|
|
};
|
|
|
|
|
|
|
|
const handleClose = (e: React.MouseEvent) => {
|
|
|
|
e.stopPropagation();
|
|
|
|
setIsPickerOpen(false);
|
|
|
|
};
|
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<ButtonBase
|
|
|
|
onClick={handleClick}
|
|
|
|
sx={{
|
|
|
|
width: "100%",
|
|
|
|
height: "100%",
|
|
|
|
display: "flex",
|
|
|
|
alignItems: "center",
|
|
|
|
justifyContent: "center",
|
|
|
|
"&:hover": {
|
|
|
|
bgcolor: theme.palette.grey[100],
|
|
|
|
},
|
|
|
|
}}
|
|
|
|
>
|
2025-06-22 14:30:13 +00:00
|
|
|
<Typography fontSize={emoji ? "100px" : "18px"}>{emoji || t("select emoji")}</Typography>
|
2025-06-20 13:02:18 +00:00
|
|
|
</ButtonBase>
|
|
|
|
|
|
|
|
<Modal
|
|
|
|
open={isPickerOpen}
|
|
|
|
onClose={handleClose}
|
|
|
|
sx={{
|
|
|
|
display: "flex",
|
|
|
|
alignItems: "center",
|
|
|
|
justifyContent: "center",
|
|
|
|
}}
|
|
|
|
keepMounted
|
|
|
|
>
|
|
|
|
<Box
|
|
|
|
onClick={(e) => e.stopPropagation()}
|
|
|
|
sx={{
|
|
|
|
bgcolor: "background.paper",
|
|
|
|
borderRadius: 2,
|
|
|
|
p: 2,
|
|
|
|
boxShadow: 24,
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<EmojiPicker onEmojiSelect={handleEmojiSelect} />
|
|
|
|
</Box>
|
|
|
|
</Modal>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
};
|