@botonic/react
Version:
Build Chatbots using React
20 lines • 1.41 kB
JavaScript
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
import { useContext } from 'react';
import SendButtonIcon from '../../assets/send-button.svg';
import { ROLES } from '../../constants';
import { WebchatContext } from '../../webchat/context';
import { Icon } from '../components/common';
import { ConditionalAnimation } from '../components/conditional-animation';
export const SendButton = ({ onClick }) => {
var _a, _b;
const { webchatState } = useContext(WebchatContext);
const CustomSendButton = (_b = (_a = webchatState.theme.userInput) === null || _a === void 0 ? void 0 : _a.sendButton) === null || _b === void 0 ? void 0 : _b.custom;
const isSendButtonEnabled = () => {
var _a, _b, _c;
const hasCustomSendButton = !!CustomSendButton;
return ((_c = (_b = (_a = webchatState.theme.userInput) === null || _a === void 0 ? void 0 : _a.sendButton) === null || _b === void 0 ? void 0 : _b.enable) !== null && _c !== void 0 ? _c : hasCustomSendButton);
};
const sendButtonEnabled = isSendButtonEnabled();
return (_jsx(_Fragment, { children: sendButtonEnabled ? (_jsx(ConditionalAnimation, { children: _jsx("div", Object.assign({ onClick: onClick, role: ROLES.SEND_BUTTON_ICON }, { children: CustomSendButton ? (_jsx(CustomSendButton, {})) : (_jsx(Icon, { src: SendButtonIcon })) })) })) : null }));
};
//# sourceMappingURL=send-button.js.map