@botonic/react
Version:
Build Chatbots using React
18 lines • 1.03 kB
JavaScript
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { useContext, useEffect, useState } from 'react';
import { BotonicContainerId } from '../constants';
import { WebchatContext } from '../context';
import { useWebchatDimensions } from '../hooks';
import { WebchatMessageList } from '../message-list';
import { WebchatReplies } from '../replies';
import { StyledChatArea } from './styles';
export const ChatArea = () => {
const { webchatState: { replies }, chatAreaRef, } = useContext(WebchatContext);
const { calculateResizedPxChatAreaHeight } = useWebchatDimensions();
const [chatAreaHeight, setChatAreaHeight] = useState(0);
useEffect(() => {
setChatAreaHeight(calculateResizedPxChatAreaHeight());
}, []);
return (_jsxs(StyledChatArea, Object.assign({ id: BotonicContainerId.ChatArea, ref: chatAreaRef, height: chatAreaHeight }, { children: [_jsx(WebchatMessageList, {}), replies && replies.length > 0 && _jsx(WebchatReplies, {})] })));
};
//# sourceMappingURL=index.js.map