@stack-spot/ai-chat-widget 1.30.1-beta.1 → 1.30.2-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/dist/app-metadata.json +2 -2
- package/dist/components/AdaptiveTextArea.d.ts +2 -2
- package/dist/components/AdaptiveTextArea.d.ts.map +1 -1
- package/dist/components/AdaptiveTextArea.js +8 -13
- package/dist/components/AdaptiveTextArea.js.map +1 -1
- package/dist/views/MessageInput/index.d.ts.map +1 -1
- package/dist/views/MessageInput/index.js +4 -3
- package/dist/views/MessageInput/index.js.map +1 -1
- package/package.json +1 -1
- package/src/app-metadata.json +2 -2
- package/src/components/AdaptiveTextArea.tsx +10 -18
- package/src/views/MessageInput/index.tsx +4 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [1.30.2-beta.1](https://github.com/stack-spot/portal-ai-chat-widget/compare/ai-chat-widget-beta@v1.30.1-beta.1...ai-chat-widget-beta@v1.30.2-beta.1) (2025-07-07)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* calc max height ([#200](https://github.com/stack-spot/portal-ai-chat-widget/issues/200)) ([01d69c0](https://github.com/stack-spot/portal-ai-chat-widget/commit/01d69c04848db47e55b368b1e27a27b4ad24e8a3))
|
|
9
|
+
|
|
3
10
|
## [1.30.1-beta.1](https://github.com/stack-spot/portal-ai-chat-widget/compare/ai-chat-widget-beta@v1.30.0-beta.1...ai-chat-widget-beta@v1.30.1-beta.1) (2025-07-04)
|
|
4
11
|
|
|
5
12
|
|
package/dist/app-metadata.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stack-spot/ai-chat-widget",
|
|
3
|
-
"version": "1.30.
|
|
4
|
-
"date": "
|
|
3
|
+
"version": "1.30.2-beta.1",
|
|
4
|
+
"date": "Mon Jul 07 2025 19:23:52 GMT+0000 (Coordinated Universal Time)",
|
|
5
5
|
"dependencies": [
|
|
6
6
|
{
|
|
7
7
|
"name": "@stack-spot/app-metadata",
|
|
@@ -10,9 +10,9 @@ interface Props extends PropsOf<typeof Textarea> {
|
|
|
10
10
|
*/
|
|
11
11
|
onResetSize?: () => void;
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
13
|
+
* The maximum height this textarea can get to.
|
|
14
14
|
*/
|
|
15
|
-
|
|
15
|
+
maxHeight?: () => number;
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
18
18
|
* The adaptive textarea grows in height whenever needed until the maximum height is reached.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AdaptiveTextArea.d.ts","sourceRoot":"","sources":["../../src/components/AdaptiveTextArea.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AAEvC,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"AdaptiveTextArea.d.ts","sourceRoot":"","sources":["../../src/components/AdaptiveTextArea.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AAEvC,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AAElC,UAAU,KAAM,SAAQ,OAAO,CAAC,OAAO,QAAQ,CAAC;IAC9C;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,IAAI,CAAC;IAC5B;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,IAAI,CAAC;IACzB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,MAAM,CAAC;CAC1B;AAED;;GAEG;AACH,eAAO,MAAM,gBAAgB,oHAmC3B,CAAA"}
|
|
@@ -1,22 +1,16 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
/* eslint-disable react/display-name */
|
|
3
3
|
import { Textarea } from '@citric/core';
|
|
4
|
-
import { forwardRef, useEffect,
|
|
5
|
-
import { MIN_INPUT_HEIGHT } from '../views/MessageInput/styled.js';
|
|
4
|
+
import { forwardRef, useEffect, useRef } from 'react';
|
|
6
5
|
/**
|
|
7
6
|
* The adaptive textarea grows in height whenever needed until the maximum height is reached.
|
|
8
7
|
*/
|
|
9
|
-
export const AdaptiveTextArea = forwardRef(({ value, onIncreaseSize, onResetSize, style,
|
|
8
|
+
export const AdaptiveTextArea = forwardRef(({ value, onIncreaseSize, onResetSize, style, maxHeight, ...props }, externalRef) => {
|
|
10
9
|
const localRef = useRef(null);
|
|
11
10
|
const ref = externalRef ?? localRef;
|
|
12
|
-
/**
|
|
13
|
-
* Calculates the maximum height for the textarea.
|
|
14
|
-
* Uses 30% of container height if available, otherwise falls back to MIN_INPUT_HEIGHT.
|
|
15
|
-
*/
|
|
16
|
-
const maxHeight = useMemo(() => chatWindowRef?.current?.offsetHeight ? chatWindowRef?.current?.offsetHeight * 0.3 : MIN_INPUT_HEIGHT, [chatWindowRef?.current?.offsetHeight]);
|
|
17
11
|
const handleIncreaseSize = (newHeight) => {
|
|
18
12
|
onIncreaseSize?.();
|
|
19
|
-
if (maxHeight && newHeight > maxHeight && ref.current) {
|
|
13
|
+
if (maxHeight && newHeight > maxHeight?.() && ref.current) {
|
|
20
14
|
ref.current.style.overflowY = 'auto';
|
|
21
15
|
}
|
|
22
16
|
};
|
|
@@ -25,21 +19,22 @@ export const AdaptiveTextArea = forwardRef(({ value, onIncreaseSize, onResetSize
|
|
|
25
19
|
return;
|
|
26
20
|
const height = ref.current.clientHeight;
|
|
27
21
|
const scroll = ref.current.scrollHeight;
|
|
28
|
-
|
|
22
|
+
const computedMaxHeight = maxHeight?.() ?? 0;
|
|
23
|
+
if (!maxHeight || height < computedMaxHeight) {
|
|
29
24
|
ref.current.style.overflowY = 'hidden';
|
|
30
25
|
if (height < scroll) {
|
|
31
26
|
ref.current.style.height = `${scroll}px`;
|
|
32
27
|
handleIncreaseSize(scroll);
|
|
33
28
|
}
|
|
34
29
|
}
|
|
35
|
-
else if (
|
|
30
|
+
else if (computedMaxHeight) {
|
|
36
31
|
ref.current.style.overflowY = 'auto';
|
|
37
32
|
}
|
|
38
33
|
if (!value) {
|
|
39
34
|
ref.current.style.height = '';
|
|
40
35
|
onResetSize?.();
|
|
41
36
|
}
|
|
42
|
-
}, [value
|
|
43
|
-
return _jsx(Textarea, { ...props, ref: ref, value: value, style: { ...style, maxHeight } });
|
|
37
|
+
}, [value]);
|
|
38
|
+
return _jsx(Textarea, { ...props, ref: ref, value: value, style: { ...style, maxHeight: maxHeight?.() } });
|
|
44
39
|
});
|
|
45
40
|
//# sourceMappingURL=AdaptiveTextArea.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AdaptiveTextArea.js","sourceRoot":"","sources":["../../src/components/AdaptiveTextArea.tsx"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AACvC,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,
|
|
1
|
+
{"version":3,"file":"AdaptiveTextArea.js","sourceRoot":"","sources":["../../src/components/AdaptiveTextArea.tsx"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AACvC,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAA;AAkBrD;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,UAAU,CAA6B,CACrE,EAAE,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAClE,WAAW,EACX,EAAE;IACF,MAAM,QAAQ,GAAG,MAAM,CAAsB,IAAI,CAAC,CAAA;IAClD,MAAM,GAAG,GAAG,WAAmD,IAAI,QAAQ,CAAA;IAE3E,MAAM,kBAAkB,GAA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,GAAG,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,EAAE,EAAE,GAAI,CAAA;AACvG,CAAC,CAAC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/views/MessageInput/index.tsx"],"names":[],"mappings":"AAsBA;;;;GAIG;AACH,eAAO,MAAM,YAAY,sBAAuB;IAAE,aAAa,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAA;CAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/views/MessageInput/index.tsx"],"names":[],"mappings":"AAsBA;;;;GAIG;AACH,eAAO,MAAM,YAAY,sBAAuB;IAAE,aAAa,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAA;CAAE,4CA0H/F,CAAA"}
|
|
@@ -4,7 +4,7 @@ import { interpolate } from '@stack-spot/portal-translate';
|
|
|
4
4
|
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
5
5
|
import { AdaptiveTextArea } from '../../components/AdaptiveTextArea.js';
|
|
6
6
|
import { ProgressBar } from '../../components/ProgressBar.js';
|
|
7
|
-
import { useCurrentChat, useCurrentChatState } from '../../context/hooks.js';
|
|
7
|
+
import { useCurrentChat, useCurrentChatState, useWidgetState } from '../../context/hooks.js';
|
|
8
8
|
import { quickCommandRegex } from '../../regex.js';
|
|
9
9
|
import { ChatEntry } from '../../state/ChatEntry.js';
|
|
10
10
|
import { checkIsTrial } from '../../utils/check-is-trial.js';
|
|
@@ -17,7 +17,7 @@ import { useUserEntryHistoryShortcut } from './chat-entry-history.js';
|
|
|
17
17
|
import { ContextBar } from './ContextBar.js';
|
|
18
18
|
import { useMessageInputDictionary } from './dictionary.js';
|
|
19
19
|
import { QuickCommandSelector } from './QuickCommandSelector.js';
|
|
20
|
-
import { MessageInputBox } from './styled.js';
|
|
20
|
+
import { MessageInputBox, MIN_INPUT_HEIGHT } from './styled.js';
|
|
21
21
|
import { UploadBar } from './UploadBar.js';
|
|
22
22
|
import { UploadDragNDrop, useUploadDragDrop } from './UploadDragNDrop.js';
|
|
23
23
|
/**
|
|
@@ -33,6 +33,7 @@ export const MessageInput = ({ chatWindowRef }) => {
|
|
|
33
33
|
const chat = useCurrentChat();
|
|
34
34
|
const isLoading = useCurrentChatState('isLoading') ?? false;
|
|
35
35
|
const value = useCurrentChatState('nextMessage') ?? '';
|
|
36
|
+
const isMinimized = useWidgetState('isMinimized');
|
|
36
37
|
const textAreaRef = useRef(null);
|
|
37
38
|
const agentLabel = useCurrentChatState('agent')?.label;
|
|
38
39
|
const { handleKeyDown, handleKeyUp } = useUserEntryHistoryShortcut();
|
|
@@ -103,7 +104,7 @@ export const MessageInput = ({ chatWindowRef }) => {
|
|
|
103
104
|
if (!isLoading)
|
|
104
105
|
textAreaRef.current?.focus();
|
|
105
106
|
}, [isLoading]);
|
|
106
|
-
return (_jsxs(UploadProvider, { value: chat.uploadManager, children: [_jsxs(MessageInputBox, { "aria-busy": isLoading, className: "message-input", "$inputFocused": focused, children: [_jsxs("div", { className: "wrapper-action", children: [_jsx(QuickCommandSelector, { inputRef: textAreaRef, isTrial: isTrial }), _jsx(AgentSelector, { inputRef: textAreaRef, isTrial: isTrial }), _jsxs("div", { className: listToClass(['action-box', focused && 'focused', isLoading && 'disabled']), children: [_jsx(ButtonAgent, {}), _jsx(AdaptiveTextArea, {
|
|
107
|
+
return (_jsxs(UploadProvider, { value: chat.uploadManager, children: [_jsxs(MessageInputBox, { "aria-busy": isLoading, className: "message-input", "$inputFocused": focused, children: [_jsxs("div", { className: "wrapper-action", children: [_jsx(QuickCommandSelector, { inputRef: textAreaRef, isTrial: isTrial }), _jsx(AgentSelector, { inputRef: textAreaRef, isTrial: isTrial }), _jsxs("div", { className: listToClass(['action-box', focused && 'focused', isLoading && 'disabled']), children: [_jsx(ButtonAgent, {}), _jsx(AdaptiveTextArea, { maxHeight: () => isMinimized ? MIN_INPUT_HEIGHT : chatWindowRef?.current?.querySelector('.chat-content')?.clientHeight ?? 0, ref: textAreaRef, placeholder: agentLabel
|
|
107
108
|
? interpolate(t.placeholder, agentLabel)
|
|
108
109
|
: t.typing, onChange: e => chat.set('nextMessage', e.target.value), value: value, onFocus: () => setFocused(true), onBlur: () => setFocused(false), onKeyDown: onKeyDown, onKeyUp: handleKeyUp, onIncreaseSize: () => setExpanded(false), onResetSize: () => !expansionLocked.current && setExpanded(true) })] })] }), _jsx(ProgressBar, { visible: true, animate: isLoading, backgroundColor: isLoading || !focused ? theme.color.light[500] : theme.color.primary[500] }), _jsx(ContextBar, {}), chat.get('features').upload && _jsx(UploadBar, {}), _jsx(ButtonBar, { onSend: onSend, isLoading: isLoading })] }), _jsx(UploadDragNDrop, { isDragging: isDragging, onDrop: handleDrop, onDragLeave: handleDragLeave })] }));
|
|
109
110
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/views/MessageInput/index.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAA;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAA;AAC1D,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAA;AACpE,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAA;AAC1D,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/views/MessageInput/index.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAA;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAA;AAC1D,OAAO,EAAE,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C,eAAe,EAAE,SAAS,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,GAAI,EAChG,KAAC,UAAU,KAAG,EACb,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,MAAM,IAAI,KAAC,SAAS,KAAG,EAC7C,KAAC,SAAS,IAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,GAAI,IACnC,EAClB,KAAC,eAAe,IAAC,UAAU,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,eAAe,GAAI,IAC9E,CAClB,CAAA;AACH,CAAC,CAAA"}
|
package/package.json
CHANGED
package/src/app-metadata.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stack-spot/ai-chat-widget",
|
|
3
|
-
"version": "1.30.
|
|
4
|
-
"date": "
|
|
3
|
+
"version": "1.30.2-beta.1",
|
|
4
|
+
"date": "Mon Jul 07 2025 19:23:52 GMT+0000 (Coordinated Universal Time)",
|
|
5
5
|
"dependencies": [
|
|
6
6
|
{
|
|
7
7
|
"name": "@stack-spot/app-metadata",
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
/* eslint-disable react/display-name */
|
|
2
2
|
import { Textarea } from '@citric/core'
|
|
3
|
-
import { forwardRef, useEffect,
|
|
3
|
+
import { forwardRef, useEffect, useRef } from 'react'
|
|
4
4
|
import { PropsOf } from '../types'
|
|
5
|
-
import { MIN_INPUT_HEIGHT } from '../views/MessageInput/styled'
|
|
6
5
|
|
|
7
6
|
interface Props extends PropsOf<typeof Textarea> {
|
|
8
7
|
/**
|
|
@@ -14,32 +13,24 @@ interface Props extends PropsOf<typeof Textarea> {
|
|
|
14
13
|
*/
|
|
15
14
|
onResetSize?: () => void,
|
|
16
15
|
/**
|
|
17
|
-
*
|
|
16
|
+
* The maximum height this textarea can get to.
|
|
18
17
|
*/
|
|
19
|
-
|
|
18
|
+
maxHeight?: () => number,
|
|
20
19
|
}
|
|
21
20
|
|
|
22
21
|
/**
|
|
23
22
|
* The adaptive textarea grows in height whenever needed until the maximum height is reached.
|
|
24
23
|
*/
|
|
25
24
|
export const AdaptiveTextArea = forwardRef<HTMLTextAreaElement, Props>((
|
|
26
|
-
{ value, onIncreaseSize, onResetSize, style,
|
|
25
|
+
{ value, onIncreaseSize, onResetSize, style, maxHeight, ...props },
|
|
27
26
|
externalRef,
|
|
28
27
|
) => {
|
|
29
28
|
const localRef = useRef<HTMLTextAreaElement>(null)
|
|
30
29
|
const ref = externalRef as React.RefObject<HTMLTextAreaElement> ?? localRef
|
|
31
|
-
/**
|
|
32
|
-
* Calculates the maximum height for the textarea.
|
|
33
|
-
* Uses 30% of container height if available, otherwise falls back to MIN_INPUT_HEIGHT.
|
|
34
|
-
*/
|
|
35
|
-
const maxHeight = useMemo(
|
|
36
|
-
() => chatWindowRef?.current?.offsetHeight ? chatWindowRef?.current?.offsetHeight * 0.3 : MIN_INPUT_HEIGHT,
|
|
37
|
-
[chatWindowRef?.current?.offsetHeight],
|
|
38
|
-
)
|
|
39
30
|
|
|
40
31
|
const handleIncreaseSize = (newHeight: number) => {
|
|
41
32
|
onIncreaseSize?.()
|
|
42
|
-
if (maxHeight && newHeight > maxHeight && ref.current) {
|
|
33
|
+
if (maxHeight && newHeight > maxHeight?.() && ref.current) {
|
|
43
34
|
ref.current.style.overflowY = 'auto'
|
|
44
35
|
}
|
|
45
36
|
}
|
|
@@ -48,20 +39,21 @@ export const AdaptiveTextArea = forwardRef<HTMLTextAreaElement, Props>((
|
|
|
48
39
|
if (!ref.current) return
|
|
49
40
|
const height = ref.current.clientHeight
|
|
50
41
|
const scroll = ref.current.scrollHeight
|
|
51
|
-
|
|
42
|
+
const computedMaxHeight = maxHeight?.() ?? 0
|
|
43
|
+
if (!maxHeight || height < computedMaxHeight) {
|
|
52
44
|
ref.current.style.overflowY = 'hidden'
|
|
53
45
|
if (height < scroll) {
|
|
54
46
|
ref.current.style.height = `${scroll}px`
|
|
55
47
|
handleIncreaseSize(scroll)
|
|
56
48
|
}
|
|
57
|
-
} else if (
|
|
49
|
+
} else if (computedMaxHeight) {
|
|
58
50
|
ref.current.style.overflowY = 'auto'
|
|
59
51
|
}
|
|
60
52
|
if (!value) {
|
|
61
53
|
ref.current.style.height = ''
|
|
62
54
|
onResetSize?.()
|
|
63
55
|
}
|
|
64
|
-
}, [value
|
|
56
|
+
}, [value])
|
|
65
57
|
|
|
66
|
-
return <Textarea {...props} ref={ref} value={value} style={{ ...style, maxHeight }} />
|
|
58
|
+
return <Textarea {...props} ref={ref} value={value} style={{ ...style, maxHeight: maxHeight?.() }} />
|
|
67
59
|
})
|
|
@@ -3,7 +3,7 @@ import { interpolate } from '@stack-spot/portal-translate'
|
|
|
3
3
|
import { useCallback, useEffect, useRef, useState } from 'react'
|
|
4
4
|
import { AdaptiveTextArea } from '../../components/AdaptiveTextArea'
|
|
5
5
|
import { ProgressBar } from '../../components/ProgressBar'
|
|
6
|
-
import { useCurrentChat, useCurrentChatState } from '../../context/hooks'
|
|
6
|
+
import { useCurrentChat, useCurrentChatState, useWidgetState } from '../../context/hooks'
|
|
7
7
|
import { quickCommandRegex } from '../../regex'
|
|
8
8
|
import { ChatEntry } from '../../state/ChatEntry'
|
|
9
9
|
import { checkIsTrial } from '../../utils/check-is-trial'
|
|
@@ -16,7 +16,7 @@ import { useUserEntryHistoryShortcut } from './chat-entry-history'
|
|
|
16
16
|
import { ContextBar } from './ContextBar'
|
|
17
17
|
import { useMessageInputDictionary } from './dictionary'
|
|
18
18
|
import { QuickCommandSelector } from './QuickCommandSelector'
|
|
19
|
-
import { MessageInputBox } from './styled'
|
|
19
|
+
import { MessageInputBox, MIN_INPUT_HEIGHT } from './styled'
|
|
20
20
|
import { UploadBar } from './UploadBar'
|
|
21
21
|
import { UploadDragNDrop, useUploadDragDrop } from './UploadDragNDrop'
|
|
22
22
|
|
|
@@ -33,6 +33,7 @@ export const MessageInput = ({ chatWindowRef }: { chatWindowRef?: React.RefObjec
|
|
|
33
33
|
const chat = useCurrentChat()
|
|
34
34
|
const isLoading = useCurrentChatState('isLoading') ?? false
|
|
35
35
|
const value = useCurrentChatState('nextMessage') ?? ''
|
|
36
|
+
const isMinimized = useWidgetState('isMinimized')
|
|
36
37
|
const textAreaRef = useRef<HTMLTextAreaElement>(null)
|
|
37
38
|
const agentLabel = useCurrentChatState('agent')?.label
|
|
38
39
|
const { handleKeyDown, handleKeyUp } = useUserEntryHistoryShortcut()
|
|
@@ -119,7 +120,7 @@ export const MessageInput = ({ chatWindowRef }: { chatWindowRef?: React.RefObjec
|
|
|
119
120
|
<div className={listToClass(['action-box', focused && 'focused', isLoading && 'disabled'])}>
|
|
120
121
|
<ButtonAgent />
|
|
121
122
|
<AdaptiveTextArea
|
|
122
|
-
|
|
123
|
+
maxHeight={() => isMinimized? MIN_INPUT_HEIGHT : chatWindowRef?.current?.querySelector('.chat-content')?.clientHeight ?? 0}
|
|
123
124
|
ref={textAreaRef}
|
|
124
125
|
placeholder={
|
|
125
126
|
agentLabel
|