@@ -7,10 +7,10 @@ import {
7
7
Autocomplete ,
8
8
AutocompleteInputChangeReason ,
9
9
Box ,
10
- InputAdornment ,
11
10
SxProps ,
12
11
TextField ,
13
- Theme
12
+ Theme ,
13
+ Toolbar
14
14
} from '@mui/material' ;
15
15
import clsx from 'clsx' ;
16
16
import React , { useEffect , useRef , useState } from 'react' ;
@@ -26,6 +26,8 @@ import { IChatCommandRegistry } from '../../registers';
26
26
import { IAttachment } from '../../types' ;
27
27
28
28
const INPUT_BOX_CLASS = 'jp-chat-input-container' ;
29
+ const INPUT_TEXTFIELD_CLASS = 'jp-chat-input-textfield' ;
30
+ const INPUT_COMPONENT_CLASS = 'jp-chat-input-component' ;
29
31
const INPUT_TOOLBAR_CLASS = 'jp-chat-input-toolbar' ;
30
32
31
33
export function ChatInput ( props : ChatInput . IProps ) : JSX . Element {
@@ -185,28 +187,29 @@ export function ChatInput(props: ChatInput.IProps): JSX.Element {
185
187
< Autocomplete
186
188
{ ...chatCommands . autocompleteProps }
187
189
// ensure the autocomplete popup always renders on top
188
- componentsProps = { {
190
+ slotProps = { {
189
191
popper : {
190
192
placement : 'top'
191
193
} ,
192
194
paper : {
193
195
sx : {
194
196
border : '1px solid lightgray'
195
197
}
196
- }
197
- } }
198
- ListboxProps = { {
199
- sx : {
200
- '& .MuiAutocomplete-option' : {
201
- padding : 2
198
+ } ,
199
+ listbox : {
200
+ sx : {
201
+ '& .MuiAutocomplete-option' : {
202
+ padding : 2
203
+ }
202
204
}
203
205
}
204
206
} }
205
207
renderInput = { params => (
206
208
< TextField
207
209
{ ...params }
208
210
fullWidth
209
- variant = "outlined"
211
+ variant = "filled"
212
+ className = { INPUT_TEXTFIELD_CLASS }
210
213
multiline
211
214
onKeyDown = { handleKeyDown }
212
215
placeholder = "Start chatting"
@@ -215,23 +218,13 @@ export function ChatInput(props: ChatInput.IProps): JSX.Element {
215
218
onSelect = { ( ) =>
216
219
( model . cursorIndex = inputRef . current ?. selectionStart ?? null )
217
220
}
218
- InputProps = { {
219
- ...params . InputProps ,
220
- endAdornment : (
221
- < InputAdornment position = "end" className = { INPUT_TOOLBAR_CLASS } >
222
- { toolbarElements . map ( item => (
223
- < item . element
224
- model = { model }
225
- chatCommandRegistry = { props . chatCommandRegistry }
226
- />
227
- ) ) }
228
- </ InputAdornment >
229
- )
230
- } }
231
- FormHelperTextProps = { {
232
- sx : { marginLeft : 'auto' , marginRight : 0 }
221
+ slotProps = { {
222
+ input : {
223
+ ...params . InputProps ,
224
+ className : INPUT_COMPONENT_CLASS
225
+ }
233
226
} }
234
- helperText = { input . length > 2 ? helperText : ' ' }
227
+ label = { input . length > 2 ? helperText : ' ' }
235
228
/>
236
229
) }
237
230
inputValue = { input }
@@ -248,6 +241,14 @@ export function ChatInput(props: ChatInput.IProps): JSX.Element {
248
241
}
249
242
} }
250
243
/>
244
+ < Toolbar className = { INPUT_TOOLBAR_CLASS } >
245
+ { toolbarElements . map ( item => (
246
+ < item . element
247
+ model = { model }
248
+ chatCommandRegistry = { props . chatCommandRegistry }
249
+ />
250
+ ) ) }
251
+ </ Toolbar >
251
252
</ Box >
252
253
) ;
253
254
}
0 commit comments