@botonic/react
Version:
Build Chatbots using React
30 lines • 1.65 kB
JavaScript
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import React, { useContext } from 'react';
import styled from 'styled-components';
import { Button } from '../../components/button/index';
import { ROLES, WEBCHAT } from '../../constants';
import { WebchatContext } from '../context';
import { useComponentVisible } from '../hooks';
const ButtonsContainer = styled.div `
position: absolute;
z-index: 2;
width: 100%;
bottom: 0;
text-align: center;
`;
export const OpenedPersistentMenu = ({ onClick, options, borderRadius }) => {
const { ref, isComponentVisible } = useComponentVisible(true, onClick);
const { getThemeProperty } = useContext(WebchatContext);
const CustomPersistentMenu = getThemeProperty(WEBCHAT.CUSTOM_PROPERTIES.customPersistentMenu);
let closeLabel = 'Cancel';
try {
closeLabel = options.filter(opt => opt.closeLabel !== undefined)[0]
.closeLabel;
}
catch (e) { }
return (_jsx("div", Object.assign({ ref: ref, role: ROLES.PERSISTENT_MENU }, { children: isComponentVisible && CustomPersistentMenu ? (_jsx(CustomPersistentMenu, { onClick: onClick, options: options })) : (_jsxs(ButtonsContainer, { children: [Object.values(options).map((e, i) => {
return (e.label && (_jsx(Button, Object.assign({ onClick: onClick, url: e.url, target: e.target, webview: e.webview, payload: e.payload }, { children: e.label }), i)));
}), _jsx(Button, Object.assign({ onClick: onClick, bottomRadius: borderRadius }, { children: closeLabel }))] })) })));
};
export default OpenedPersistentMenu;
//# sourceMappingURL=opened-persistent-menu.js.map