@plteam/chat-ui
Version:
CUI Kit is a free and open-source library for creating AI assistant chat interfaces, built with React, Material UI, and TypeScript
12 lines (11 loc) • 779 B
JavaScript
import { ChatViewConstants } from '../ChatViewConstants';
export const useConversationBlockHeightCallback = (contentRef, getConversationBlockHeightMin) => {
const textFieldHeight = document.getElementById(ChatViewConstants.TEXT_FIELD_ROW_ID)?.clientHeight || 0;
const paddingsSum = ChatViewConstants.MESSAGE_ROW_PADDING_TOP + ChatViewConstants.MESSAGE_ROW_PADDING_BOTTOM;
return () => {
const boxHeight = contentRef?.current?.clientHeight || document.getElementById(ChatViewConstants.DIALOGUE_ROOT_ID)?.clientHeight || 0;
const calculatedHeight = Math.max(0, boxHeight - textFieldHeight - paddingsSum);
const usersHeight = getConversationBlockHeightMin?.(calculatedHeight);
return usersHeight ?? calculatedHeight;
};
};