UNPKG

@memori.ai/memori-react

Version:

[![npm version](https://img.shields.io/github/package-json/v/memori-ai/memori-react)](https://www.npmjs.com/package/@memori.ai/memori-react) ![Tests](https://github.com/memori-ai/memori-react/workflows/CI/badge.svg?branch=main) ![TypeScript Support](https

23 lines 1.65 kB
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; import { useState } from 'react'; import cx from 'classnames'; import Button from '../ui/Button'; import Expand from '../icons/Expand'; import FullscreenExit from '../icons/FullscreenExit'; import { useTranslation } from 'react-i18next'; const ChatTextArea = ({ disabled = false, value, onChange, onPressEnter, onFocus, onBlur, }) => { const { t } = useTranslation(); const [expanded, setExpanded] = useState(false); return (_jsx("div", { "data-testid": "chat-textarea", className: cx('memori-chat-textarea', { 'memori-chat-textarea--expanded': expanded, 'memori-chat-textarea--disabled': disabled, }), children: _jsxs("div", { className: "memori-chat-textarea--inner", children: [_jsx("textarea", { className: "memori-chat-textarea--input", disabled: disabled, value: value, onChange: e => { onChange(e.target.value); }, onKeyDownCapture: e => { if (e.key === 'Enter' && !e.shiftKey && onPressEnter) { onPressEnter(e); } }, onFocus: onFocus, onBlur: onBlur, maxLength: 100000 }), _jsx("div", { className: "memori-chat-textarea--expand", children: _jsx(Button, { className: cx('memori-chat-textarea--expand-button'), onClick: () => setExpanded(!expanded), padded: false, ghost: true, title: expanded ? t('collapse') || 'Collapse' : t('expand') || 'Expand', icon: expanded ? _jsx(FullscreenExit, {}) : _jsx(Expand, {}) }) })] }) })); }; export default ChatTextArea; //# sourceMappingURL=ChatTextArea.js.map