UNPKG

@botonic/react

Version:

Build Chatbots using React

29 lines 1.9 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.EmojiPicker = void 0; const tslib_1 = require("tslib"); const jsx_runtime_1 = require("react/jsx-runtime"); const react_1 = require("react"); const emojiButton_svg_1 = tslib_1.__importDefault(require("../../assets/emojiButton.svg")); const constants_1 = require("../../constants"); const context_1 = require("../../webchat/context"); const common_1 = require("../components/common"); const conditional_animation_1 = require("../components/conditional-animation"); const EmojiPicker = ({ onClick }) => { var _a, _b; const { webchatState } = (0, react_1.useContext)(context_1.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 ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: emojiPickerEnabled ? ((0, jsx_runtime_1.jsx)(conditional_animation_1.ConditionalAnimation, { children: (0, jsx_runtime_1.jsx)("div", Object.assign({ role: constants_1.ROLES.EMOJI_PICKER_ICON, onClick: handleClick }, { children: CustomEmojiPicker ? ((0, jsx_runtime_1.jsx)(CustomEmojiPicker, {})) : ((0, jsx_runtime_1.jsx)(common_1.Icon, { src: emojiButton_svg_1.default })) })) })) : null })); }; exports.EmojiPicker = EmojiPicker; //# sourceMappingURL=emoji-picker.js.map