UNPKG

@botonic/react

Version:

Build Chatbots using React

24 lines 1.52 kB
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime"; import { useContext } from 'react'; import LogoEmoji from '../../assets/emojiButton.svg'; import { ROLES } from '../../constants'; import { WebchatContext } from '../../webchat/context'; import { Icon } from '../components/common'; import { ConditionalAnimation } from '../components/conditional-animation'; export const EmojiPicker = ({ onClick }) => { var _a, _b; const { webchatState } = useContext(WebchatContext); const CustomEmojiPicker = (_b = (_a = webchatState.theme.userInput) === null || _a === void 0 ? void 0 : _a.emojiPicker) === null || _b === void 0 ? void 0 : _b.custom; const isEmojiPickerEnabled = () => { var _a, _b, _c; const hasCustomEmojiPicker = !!CustomEmojiPicker; return ((_c = (_b = (_a = webchatState.theme.userInput) === null || _a === void 0 ? void 0 : _a.emojiPicker) === null || _b === void 0 ? void 0 : _b.enable) !== null && _c !== void 0 ? _c : hasCustomEmojiPicker); }; const emojiPickerEnabled = isEmojiPickerEnabled(); const handleClick = (event) => { onClick(); event.stopPropagation(); }; return (_jsx(_Fragment, { children: emojiPickerEnabled ? (_jsx(ConditionalAnimation, { children: _jsx("div", Object.assign({ role: ROLES.EMOJI_PICKER_ICON, onClick: handleClick }, { children: CustomEmojiPicker ? (_jsx(CustomEmojiPicker, {})) : (_jsx(Icon, { src: LogoEmoji })) })) })) : null })); }; //# sourceMappingURL=emoji-picker.js.map