@nethru/kit 1.1.5 → 1.1.6
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.
|
@@ -24,12 +24,7 @@ function AiChat({
|
|
|
24
24
|
messages: messages,
|
|
25
25
|
isLoading: isLoading,
|
|
26
26
|
chatContainerRef: chatContainerRef
|
|
27
|
-
}), /*#__PURE__*/_jsx(ChatInput, {
|
|
28
|
-
inputValue: inputValue,
|
|
29
|
-
setInputValue: setInputValue,
|
|
30
|
-
onSend: sendMessage,
|
|
31
|
-
isLoading: isLoading
|
|
32
|
-
})]
|
|
27
|
+
}), /*#__PURE__*/_jsx(ChatInput, {})]
|
|
33
28
|
});
|
|
34
29
|
}
|
|
35
30
|
export default AiChat;
|
|
@@ -1,25 +1,33 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useRef, useEffect, useState } from 'react';
|
|
2
2
|
import { Box, FormControl, IconButton, Stack, TextField } from '@mui/material';
|
|
3
3
|
import { Send as SendIcon } from '@mui/icons-material';
|
|
4
|
+
import { useChatContext } from "./contexts/ChatContext";
|
|
4
5
|
import ModelSelect from "./ModelSelect";
|
|
5
6
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
6
|
-
const ChatInput = ({
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
const ChatInput = () => {
|
|
8
|
+
const inputRef = useRef(null);
|
|
9
|
+
const [selectOpen, setSelectOpen] = useState(false);
|
|
10
|
+
const {
|
|
11
|
+
inputValue,
|
|
12
|
+
setInputValue,
|
|
13
|
+
isLoading,
|
|
14
|
+
sendMessage
|
|
15
|
+
} = useChatContext();
|
|
12
16
|
const handleKeyPress = e => {
|
|
13
17
|
if (e.key === 'Enter' && !e.shiftKey) {
|
|
14
18
|
e.preventDefault();
|
|
15
|
-
|
|
19
|
+
sendMessage();
|
|
16
20
|
}
|
|
17
21
|
};
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
if (!isLoading && !selectOpen && inputRef.current) inputRef.current.focus();
|
|
24
|
+
}, [isLoading, selectOpen]);
|
|
18
25
|
return /*#__PURE__*/_jsx(Box, {
|
|
19
26
|
sx: styles.container,
|
|
20
27
|
children: /*#__PURE__*/_jsxs(Stack, {
|
|
21
28
|
sx: styles.textArea,
|
|
22
29
|
children: [/*#__PURE__*/_jsx(TextField, {
|
|
30
|
+
inputRef: inputRef,
|
|
23
31
|
fullWidth: true,
|
|
24
32
|
multiline: true,
|
|
25
33
|
placeholder: "\uBA54\uC2DC\uC9C0\uB97C \uC785\uB825\uD558\uC138\uC694...",
|
|
@@ -41,9 +49,13 @@ const ChatInput = ({
|
|
|
41
49
|
alignItems: "center",
|
|
42
50
|
children: [/*#__PURE__*/_jsx(FormControl, {
|
|
43
51
|
variant: "standard",
|
|
44
|
-
children: /*#__PURE__*/_jsx(ModelSelect, {
|
|
52
|
+
children: /*#__PURE__*/_jsx(ModelSelect, {
|
|
53
|
+
open: selectOpen,
|
|
54
|
+
onOpen: () => setSelectOpen(true),
|
|
55
|
+
onClose: () => setSelectOpen(false)
|
|
56
|
+
})
|
|
45
57
|
}), /*#__PURE__*/_jsx(IconButton, {
|
|
46
|
-
onClick:
|
|
58
|
+
onClick: sendMessage,
|
|
47
59
|
disabled: isLoading || !inputValue.trim(),
|
|
48
60
|
sx: styles.iconButton,
|
|
49
61
|
children: /*#__PURE__*/_jsx(SendIcon, {
|
|
@@ -2,7 +2,9 @@ import React from "react";
|
|
|
2
2
|
import { Box, Divider, MenuItem, Select } from "@mui/material";
|
|
3
3
|
import { useChatContext } from "./contexts/ChatContext";
|
|
4
4
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
5
|
-
export default function ModelSelect(
|
|
5
|
+
export default function ModelSelect({
|
|
6
|
+
...props
|
|
7
|
+
}) {
|
|
6
8
|
const {
|
|
7
9
|
model,
|
|
8
10
|
setModel,
|
|
@@ -25,6 +27,7 @@ export default function ModelSelect() {
|
|
|
25
27
|
disableUnderline: true,
|
|
26
28
|
sx: styles.select,
|
|
27
29
|
renderValue: value => findModel(providers, value)?.name,
|
|
30
|
+
...props,
|
|
28
31
|
children: makeOptions(providers)
|
|
29
32
|
})
|
|
30
33
|
});
|