@veracity/vui 2.26.0-beta.4 → 2.26.0-beta.5
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/dist/cjs/chat/chat.types.d.ts +2 -0
- package/dist/cjs/chat/chat.types.d.ts.map +1 -1
- package/dist/cjs/chat/chatInput.d.ts.map +1 -1
- package/dist/cjs/chat/chatInput.js +11 -11
- package/dist/cjs/chat/chatInput.js.map +1 -1
- package/dist/esm/chat/chat.types.d.ts +2 -0
- package/dist/esm/chat/chat.types.d.ts.map +1 -1
- package/dist/esm/chat/chatInput.d.ts.map +1 -1
- package/dist/esm/chat/chatInput.js +11 -11
- package/dist/esm/chat/chatInput.js.map +1 -1
- package/dist/tsconfig.legacy.tsbuildinfo +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/chat/chat.types.ts +2 -0
- package/src/chat/chatInput.tsx +14 -11
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@veracity/vui",
|
|
3
|
-
"version": "2.26.0-beta.
|
|
3
|
+
"version": "2.26.0-beta.5",
|
|
4
4
|
"description": "Veracity UI is a React component library crafted for use within Veracity applications and pages. Based on Styled Components and @xstyled.",
|
|
5
5
|
"module": "./dist/esm/index.js",
|
|
6
6
|
"main": "./dist/cjs/index.js",
|
package/src/chat/chat.types.ts
CHANGED
|
@@ -36,6 +36,8 @@ export type ChatInputProps = Omit<BoxProps, 'size' | 'variant'> & {
|
|
|
36
36
|
placeholder?: string
|
|
37
37
|
status?: ChatInputStatus
|
|
38
38
|
helpText?: string
|
|
39
|
+
/** @default 120 */
|
|
40
|
+
maxTextareaHeight?: number
|
|
39
41
|
/** @default 'Generating message' */
|
|
40
42
|
processingMessage?: string
|
|
41
43
|
onNewTopicClick?: () => void
|
package/src/chat/chatInput.tsx
CHANGED
|
@@ -16,7 +16,7 @@ const CustomTextarea = styled.textareaBox`
|
|
|
16
16
|
outline: none;
|
|
17
17
|
padding: 0 8px;
|
|
18
18
|
resize: none;
|
|
19
|
-
transition-duration: 0;
|
|
19
|
+
transition-duration: 0.3s;
|
|
20
20
|
width: 100%;
|
|
21
21
|
min-height: 1.5em;
|
|
22
22
|
overflow-y: hidden;
|
|
@@ -41,6 +41,7 @@ export const ChatInput = vui<'input', ChatInputProps>((props, ref) => {
|
|
|
41
41
|
helpText,
|
|
42
42
|
placeholder = 'Type your message',
|
|
43
43
|
status = ChatInputStatus.Default,
|
|
44
|
+
maxTextareaHeight = 120,
|
|
44
45
|
processingMessage = 'Generating message',
|
|
45
46
|
value: valueProp,
|
|
46
47
|
onNewTopicClick,
|
|
@@ -74,30 +75,32 @@ export const ChatInput = vui<'input', ChatInputProps>((props, ref) => {
|
|
|
74
75
|
textarea.placeholder = ''
|
|
75
76
|
|
|
76
77
|
// Dynamically adjust the height of the textarea
|
|
77
|
-
textarea.style.height = 'auto' // Set the height based on scrollHeight
|
|
78
|
-
textarea.style.maxHeight = 'auto' // Reset the height
|
|
79
|
-
textarea.style.height = `${textarea.scrollHeight}px` // Set the height based on scrollHeight
|
|
80
|
-
textarea.style.maxHeight = `${textarea.scrollHeight}px` // Set the height based on scrollHeight
|
|
81
|
-
textarea.style.lineHeight = '2.2' // Set the height based on scrollHeight
|
|
82
78
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
79
|
+
if (textarea.scrollHeight <= maxTextareaHeight) {
|
|
80
|
+
textarea.style.height = 'auto'
|
|
81
|
+
textarea.style.maxHeight = 'auto'
|
|
82
|
+
textarea.style.height = `${textarea.scrollHeight}px`
|
|
83
|
+
textarea.style.maxHeight = `${textarea.scrollHeight}px`
|
|
84
|
+
textarea.style.lineHeight = '2.2'
|
|
86
85
|
}
|
|
86
|
+
|
|
87
|
+
if (status === ChatInputStatus.Default) setValue(textarea.value)
|
|
87
88
|
}
|
|
88
89
|
|
|
89
90
|
const isDisabled = status === ChatInputStatus.Disabled
|
|
90
91
|
|
|
91
92
|
return (
|
|
92
93
|
<Box className={cs('vui-chat-input')} justifyContent="space-between" ref={ref} {...styles?.input} {...rest}>
|
|
93
|
-
{!!onNewTopicClick &&
|
|
94
|
+
{!!onNewTopicClick && status === ChatInputStatus.Default && (
|
|
95
|
+
<Button animation="fadeUp" icon="falPlus" mr={1} onClick={() => onNewTopicClick?.()} />
|
|
96
|
+
)}
|
|
94
97
|
{status === ChatInputStatus.Processing ? (
|
|
95
98
|
<Box borderColor={inputColors.border} borderWidth={1} center justifyContent="flex-start" py={0.5} w="100%">
|
|
96
99
|
<Icon mx={1} name="fadSpinnerThird" pathFill={['blue.40', 'blue.60']} size="lg" variant="spinning" />
|
|
97
100
|
<Box>{processingMessage}</Box>
|
|
98
101
|
</Box>
|
|
99
102
|
) : (
|
|
100
|
-
<Box column w="100%">
|
|
103
|
+
<Box animation="fadeUp" border="0" column outline="none" w="100%">
|
|
101
104
|
<Box
|
|
102
105
|
borderColor={inputColors.border}
|
|
103
106
|
borderWidth={1}
|