@elicecontents/content-ui 1.0.7 → 1.0.8
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/cjs/components/Modal/Modal.js +1 -4
- package/cjs/components/chat/Chat.d.ts +12 -3
- package/cjs/components/chat/Chat.js +92 -35
- package/cjs/components/recorder/Recorder.d.ts +3 -1
- package/cjs/components/recorder/Recorder.js +6 -4
- package/es/components/Modal/Modal.js +2 -5
- package/es/components/chat/Chat.d.ts +12 -3
- package/es/components/chat/Chat.js +92 -35
- package/es/components/recorder/Recorder.d.ts +3 -1
- package/es/components/recorder/Recorder.js +6 -4
- package/package.json +1 -1
|
@@ -11,6 +11,8 @@ export interface EliceChatProps {
|
|
|
11
11
|
onChange: (text: string) => void;
|
|
12
12
|
onSend: (text: string) => void;
|
|
13
13
|
onRecord?: () => void;
|
|
14
|
+
setAudioFile?: (file: File | null) => void;
|
|
15
|
+
onTransform?: () => void;
|
|
14
16
|
height?: string;
|
|
15
17
|
onTranscribingChange?: (value: boolean) => void;
|
|
16
18
|
isLoadingMessage?: boolean;
|
|
@@ -18,8 +20,8 @@ export interface EliceChatProps {
|
|
|
18
20
|
CustomAssistantAvatar?: React.ReactNode;
|
|
19
21
|
}
|
|
20
22
|
declare const EliceChat: {
|
|
21
|
-
({ placeholder, messages, content, onReset, onSend, onChange, onRecord, onTranscribingChange, isLoadingMessage, CustomAssistantAvatar, isDisabled, height, }: EliceChatProps): import("react/jsx-runtime").JSX.Element;
|
|
22
|
-
MessageList({ messages, isLoadingMessage, scrollRef, height, CustomAssistantAvatar, }: {
|
|
23
|
+
({ placeholder, messages, content, onReset, onSend, onChange, onRecord, onTranscribingChange, setAudioFile, onTransform, isLoadingMessage, CustomAssistantAvatar, isDisabled, height, }: EliceChatProps): import("react/jsx-runtime").JSX.Element;
|
|
24
|
+
MessageList({ messages, isLoadingMessage, scrollRef, height, isRecord, setIsRecord, CustomAssistantAvatar, }: {
|
|
23
25
|
messages: {
|
|
24
26
|
role: "system" | "user" | "assistant";
|
|
25
27
|
content: string;
|
|
@@ -27,9 +29,11 @@ declare const EliceChat: {
|
|
|
27
29
|
isLoadingMessage?: boolean | undefined;
|
|
28
30
|
scrollRef: React.RefObject<HTMLDivElement>;
|
|
29
31
|
height?: string | undefined;
|
|
32
|
+
isRecord: boolean;
|
|
33
|
+
setIsRecord?: (() => void) | undefined;
|
|
30
34
|
CustomAssistantAvatar: React.ReactNode;
|
|
31
35
|
}): import("react/jsx-runtime").JSX.Element;
|
|
32
|
-
InputArea({ placeHolder, value, isDisabled, onChange, onSend, onReset, onRecord, onTranscribingChange, }: {
|
|
36
|
+
InputArea({ placeHolder, value, isDisabled, onChange, onSend, onReset, onRecord, onTranscribingChange, setAudioFile, onTransform, setIsRecord, isRecord, }: {
|
|
33
37
|
placeHolder: string;
|
|
34
38
|
value: string;
|
|
35
39
|
isDisabled: boolean;
|
|
@@ -37,7 +41,12 @@ declare const EliceChat: {
|
|
|
37
41
|
onSend: () => void;
|
|
38
42
|
onReset: () => void;
|
|
39
43
|
onRecord?: (() => void) | undefined;
|
|
44
|
+
isRecord: boolean;
|
|
45
|
+
setIsRecord?: (() => void) | undefined;
|
|
46
|
+
onTransform?: (() => void) | undefined;
|
|
47
|
+
setAudioFile?: ((file: File | null) => void) | undefined;
|
|
40
48
|
onTranscribingChange?: ((value: boolean) => void) | undefined;
|
|
41
49
|
}): import("react/jsx-runtime").JSX.Element;
|
|
42
50
|
};
|
|
51
|
+
export type AudioStep = "ready" | "waiting" | "recording";
|
|
43
52
|
export default EliceChat;
|
|
@@ -15,14 +15,16 @@ var IconButton = require('../icon-button/IconButton.js');
|
|
|
15
15
|
var AssistantAvatar = require('./AssistantAvatar.js');
|
|
16
16
|
var UserAvatar = require('./UserAvatar.js');
|
|
17
17
|
var TypingIndicator = require('./TypingIndicator.js');
|
|
18
|
+
var Recorder = require('../recorder/Recorder.js');
|
|
18
19
|
|
|
19
20
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
20
21
|
|
|
21
22
|
var _styled__default = /*#__PURE__*/_interopDefaultCompat(_styled);
|
|
22
23
|
|
|
24
|
+
function _EMOTION_STRINGIFIED_CSS_ERROR__() { return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."; }
|
|
23
25
|
var StyledChatContainer = /*#__PURE__*/_styled__default.default(material.Stack, {
|
|
24
|
-
target: "
|
|
25
|
-
})("height:fit-content;max-height:100%;height:", function (_ref) {
|
|
26
|
+
target: "e1i7zt4"
|
|
27
|
+
})("position:relative;height:fit-content;max-height:100%;height:", function (_ref) {
|
|
26
28
|
var height = _ref.height;
|
|
27
29
|
return height;
|
|
28
30
|
}, ";min-width:30rem;max-width:100%;border:2px solid ", function (_ref2) {
|
|
@@ -30,7 +32,7 @@ var StyledChatContainer = /*#__PURE__*/_styled__default.default(material.Stack,
|
|
|
30
32
|
return theme.palette.grey[300];
|
|
31
33
|
}, ";border-radius:1.5rem;padding:1.5rem;gap:1.75rem;");
|
|
32
34
|
var StyledScrollBarStack = /*#__PURE__*/_styled__default.default(material.Stack, {
|
|
33
|
-
target: "
|
|
35
|
+
target: "e1i7zt3"
|
|
34
36
|
})("flex:1;overflow-y:auto;border-radius:1.125rem;padding-right:1rem;::-webkit-scrollbar{width:0.25rem;}::-webkit-scrollbar-track{background:", function (_ref3) {
|
|
35
37
|
var theme = _ref3.theme;
|
|
36
38
|
return theme.palette.grey[200];
|
|
@@ -42,7 +44,7 @@ var StyledScrollBarStack = /*#__PURE__*/_styled__default.default(material.Stack,
|
|
|
42
44
|
return theme.palette.secondary.main;
|
|
43
45
|
}, ";}");
|
|
44
46
|
var StyledInput = /*#__PURE__*/_styled__default.default(material.Input, {
|
|
45
|
-
target: "
|
|
47
|
+
target: "e1i7zt2"
|
|
46
48
|
})("width:100%;height:100%;border:none!important;background-color:transparent;font-size:1.375rem;font-weight:700;outline:none;resize:none;color:", function (_ref6) {
|
|
47
49
|
var theme = _ref6.theme;
|
|
48
50
|
return theme.palette.secondary.main;
|
|
@@ -60,7 +62,7 @@ var StyledInput = /*#__PURE__*/_styled__default.default(material.Input, {
|
|
|
60
62
|
return theme.palette.secondary.main;
|
|
61
63
|
}, ";}");
|
|
62
64
|
var StyledMessage = /*#__PURE__*/_styled__default.default(material.Typography, {
|
|
63
|
-
target: "
|
|
65
|
+
target: "e1i7zt1"
|
|
64
66
|
})("color:", function (_ref11) {
|
|
65
67
|
var isAssistant = _ref11.isAssistant,
|
|
66
68
|
theme = _ref11.theme;
|
|
@@ -73,6 +75,16 @@ var StyledMessage = /*#__PURE__*/_styled__default.default(material.Typography, {
|
|
|
73
75
|
theme = _ref13.theme;
|
|
74
76
|
return isAssistant ? theme.palette.grey[50] : theme.palette.primary.light;
|
|
75
77
|
}, ";border-radius:1rem;white-space:pre-wrap;padding:0.75rem;margin-bottom:16px;");
|
|
78
|
+
var RecordingOverlay = /*#__PURE__*/_styled__default.default("div", {
|
|
79
|
+
target: "e1i7zt0"
|
|
80
|
+
})("production" === "production" ? {
|
|
81
|
+
name: "1805g3a",
|
|
82
|
+
styles: "position:absolute;top:0;left:24px;width:calc(100% - 48px);height:calc(100% - 24px);background-color:rgba(0, 0, 0, 0.4);z-index:999;backdrop-filter:blur(1px);border-radius:0 0 1.125rem 1.125rem"
|
|
83
|
+
} : {
|
|
84
|
+
name: "1805g3a",
|
|
85
|
+
styles: "position:absolute;top:0;left:24px;width:calc(100% - 48px);height:calc(100% - 24px);background-color:rgba(0, 0, 0, 0.4);z-index:999;backdrop-filter:blur(1px);border-radius:0 0 1.125rem 1.125rem",
|
|
86
|
+
toString: _EMOTION_STRINGIFIED_CSS_ERROR__
|
|
87
|
+
});
|
|
76
88
|
var _EliceChat = function EliceChat(_ref14) {
|
|
77
89
|
var _ref14$placeholder = _ref14.placeholder,
|
|
78
90
|
placeholder = _ref14$placeholder === void 0 ? "AI와 대화를 시작해 보세요" : _ref14$placeholder,
|
|
@@ -85,6 +97,8 @@ var _EliceChat = function EliceChat(_ref14) {
|
|
|
85
97
|
_onChange = _ref14.onChange,
|
|
86
98
|
onRecord = _ref14.onRecord,
|
|
87
99
|
onTranscribingChange = _ref14.onTranscribingChange,
|
|
100
|
+
setAudioFile = _ref14.setAudioFile,
|
|
101
|
+
onTransform = _ref14.onTransform,
|
|
88
102
|
isLoadingMessage = _ref14.isLoadingMessage,
|
|
89
103
|
CustomAssistantAvatar = _ref14.CustomAssistantAvatar,
|
|
90
104
|
_ref14$isDisabled = _ref14.isDisabled,
|
|
@@ -97,6 +111,16 @@ var _EliceChat = function EliceChat(_ref14) {
|
|
|
97
111
|
inputValue = _useState2[0],
|
|
98
112
|
setInputValue = _useState2[1];
|
|
99
113
|
var scrollRef = React.useRef(null);
|
|
114
|
+
var _useState3 = React.useState(false),
|
|
115
|
+
_useState4 = _rollupPluginBabelHelpers.slicedToArray(_useState3, 2),
|
|
116
|
+
isRecord = _useState4[0],
|
|
117
|
+
setIsRecord = _useState4[1];
|
|
118
|
+
var onClickRecordButton = function onClickRecordButton() {
|
|
119
|
+
setIsRecord(true);
|
|
120
|
+
};
|
|
121
|
+
var onClickRecordOverlay = function onClickRecordOverlay() {
|
|
122
|
+
setIsRecord(false);
|
|
123
|
+
};
|
|
100
124
|
React.useEffect(function () {
|
|
101
125
|
if (scrollRef.current) {
|
|
102
126
|
scrollRef.current.scrollIntoView({
|
|
@@ -104,6 +128,10 @@ var _EliceChat = function EliceChat(_ref14) {
|
|
|
104
128
|
});
|
|
105
129
|
}
|
|
106
130
|
}, [messages, isLoadingMessage]);
|
|
131
|
+
var onClickRecordSubmit = function onClickRecordSubmit() {
|
|
132
|
+
setIsRecord(false);
|
|
133
|
+
onTransform === null || onTransform === void 0 ? void 0 : onTransform();
|
|
134
|
+
};
|
|
107
135
|
var handleSend = function handleSend() {
|
|
108
136
|
if (inputValue.trim()) {
|
|
109
137
|
onSend(inputValue);
|
|
@@ -117,6 +145,8 @@ var _EliceChat = function EliceChat(_ref14) {
|
|
|
117
145
|
messages: messages,
|
|
118
146
|
isLoadingMessage: isLoadingMessage,
|
|
119
147
|
scrollRef: scrollRef,
|
|
148
|
+
setIsRecord: onClickRecordOverlay,
|
|
149
|
+
isRecord: isRecord,
|
|
120
150
|
CustomAssistantAvatar: CustomAssistantAvatar
|
|
121
151
|
}), jsxRuntime.jsx(_EliceChat.InputArea, {
|
|
122
152
|
placeHolder: placeholder,
|
|
@@ -125,6 +155,10 @@ var _EliceChat = function EliceChat(_ref14) {
|
|
|
125
155
|
setInputValue(e.target.value);
|
|
126
156
|
_onChange(e.target.value);
|
|
127
157
|
},
|
|
158
|
+
setIsRecord: onClickRecordButton,
|
|
159
|
+
isRecord: isRecord,
|
|
160
|
+
setAudioFile: setAudioFile,
|
|
161
|
+
onTransform: onClickRecordSubmit,
|
|
128
162
|
onSend: handleSend,
|
|
129
163
|
onReset: onReset,
|
|
130
164
|
onRecord: onRecord,
|
|
@@ -140,12 +174,16 @@ _EliceChat.MessageList = function (_ref15) {
|
|
|
140
174
|
scrollRef = _ref15.scrollRef,
|
|
141
175
|
_ref15$height = _ref15.height,
|
|
142
176
|
height = _ref15$height === void 0 ? "100%" : _ref15$height,
|
|
177
|
+
isRecord = _ref15.isRecord,
|
|
178
|
+
setIsRecord = _ref15.setIsRecord,
|
|
143
179
|
CustomAssistantAvatar = _ref15.CustomAssistantAvatar;
|
|
144
180
|
var theme = material.useTheme();
|
|
145
|
-
return jsxRuntime.
|
|
181
|
+
return jsxRuntime.jsxs(StyledScrollBarStack, {
|
|
146
182
|
theme: theme,
|
|
147
183
|
height: height,
|
|
148
|
-
children:
|
|
184
|
+
children: [isRecord && jsxRuntime.jsx(RecordingOverlay, {
|
|
185
|
+
onClick: setIsRecord
|
|
186
|
+
}), messages.length === 0 ? jsxRuntime.jsx(material.Typography, {
|
|
149
187
|
color: theme.palette.text.disabled,
|
|
150
188
|
fontSize: "2rem",
|
|
151
189
|
fontWeight: 700,
|
|
@@ -170,7 +208,7 @@ _EliceChat.MessageList = function (_ref15) {
|
|
|
170
208
|
}), isLoadingMessage && jsxRuntime.jsx(TypingIndicator.default, {}), jsxRuntime.jsx("div", {
|
|
171
209
|
ref: scrollRef
|
|
172
210
|
})]
|
|
173
|
-
})
|
|
211
|
+
})]
|
|
174
212
|
});
|
|
175
213
|
};
|
|
176
214
|
_EliceChat.InputArea = function (_ref16) {
|
|
@@ -181,40 +219,59 @@ _EliceChat.InputArea = function (_ref16) {
|
|
|
181
219
|
onSend = _ref16.onSend,
|
|
182
220
|
onReset = _ref16.onReset,
|
|
183
221
|
onRecord = _ref16.onRecord,
|
|
184
|
-
onTranscribingChange = _ref16.onTranscribingChange
|
|
222
|
+
onTranscribingChange = _ref16.onTranscribingChange,
|
|
223
|
+
setAudioFile = _ref16.setAudioFile,
|
|
224
|
+
onTransform = _ref16.onTransform,
|
|
225
|
+
setIsRecord = _ref16.setIsRecord,
|
|
226
|
+
isRecord = _ref16.isRecord;
|
|
227
|
+
var _a;
|
|
185
228
|
var theme = material.useTheme();
|
|
186
|
-
return jsxRuntime.
|
|
229
|
+
return jsxRuntime.jsx(material.Stack, {
|
|
187
230
|
direction: "row",
|
|
188
231
|
minHeight: "3.875rem",
|
|
189
232
|
bgcolor: theme.palette.grey[50],
|
|
190
233
|
borderRadius: "1.125rem",
|
|
234
|
+
width: isRecord ? "100%" : "auto",
|
|
235
|
+
justifyContent: isRecord ? "center" : "none",
|
|
236
|
+
alignItems: isRecord ? "center" : "none",
|
|
191
237
|
p: "0.5rem 1rem",
|
|
192
238
|
gap: "0.625rem",
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
239
|
+
zIndex: "1000",
|
|
240
|
+
children: isRecord ? jsxRuntime.jsx(Recorder.default
|
|
241
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
242
|
+
, {
|
|
243
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
244
|
+
onAudioReady: (_a = setAudioFile !== null && setAudioFile !== void 0 ? setAudioFile : setAudioFile) !== null && _a !== void 0 ? _a : function () {},
|
|
245
|
+
onTransform: onTransform,
|
|
246
|
+
type: "submit"
|
|
247
|
+
}) : jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
248
|
+
children: [jsxRuntime.jsx(material.Stack, {
|
|
249
|
+
flexGrow: 1,
|
|
250
|
+
maxHeight: "14.625rem",
|
|
251
|
+
children: jsxRuntime.jsx(StyledInput, {
|
|
252
|
+
disabled: isDisabled,
|
|
253
|
+
value: value,
|
|
254
|
+
onChange: onChange,
|
|
255
|
+
placeholder: placeHolder,
|
|
256
|
+
theme: theme,
|
|
257
|
+
multiline: true
|
|
258
|
+
})
|
|
259
|
+
}), onRecord && jsxRuntime.jsx(IconButton.default, {
|
|
260
|
+
onClick: function onClick() {
|
|
261
|
+
setIsRecord === null || setIsRecord === void 0 ? void 0 : setIsRecord();
|
|
262
|
+
onRecord();
|
|
263
|
+
onTranscribingChange === null || onTranscribingChange === void 0 ? void 0 : onTranscribingChange(true);
|
|
264
|
+
},
|
|
265
|
+
children: jsxRuntime.jsx(Micro.default, {})
|
|
266
|
+
}), jsxRuntime.jsx(IconButton.default, {
|
|
267
|
+
onClick: onReset,
|
|
268
|
+
children: jsxRuntime.jsx(Reset.default, {})
|
|
269
|
+
}), jsxRuntime.jsx(IconButton.default, {
|
|
270
|
+
onClick: onSend,
|
|
271
|
+
disabled: !value.trim(),
|
|
272
|
+
children: jsxRuntime.jsx(Send.default, {})
|
|
273
|
+
})]
|
|
274
|
+
})
|
|
218
275
|
});
|
|
219
276
|
};
|
|
220
277
|
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
type RecorderType = "submit" | "change";
|
|
1
2
|
export interface EliceRecorderProps {
|
|
2
3
|
onAudioReady: (file: File) => void;
|
|
3
4
|
onTransform?: () => void;
|
|
5
|
+
type?: RecorderType;
|
|
4
6
|
}
|
|
5
|
-
declare const EliceRecorder: ({ onAudioReady, onTransform }: EliceRecorderProps) => import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
declare const EliceRecorder: ({ onAudioReady, onTransform, type }: EliceRecorderProps) => import("react/jsx-runtime").JSX.Element;
|
|
6
8
|
export default EliceRecorder;
|
|
@@ -19,7 +19,9 @@ var _styled__default = /*#__PURE__*/_interopDefaultCompat(_styled);
|
|
|
19
19
|
function _EMOTION_STRINGIFIED_CSS_ERROR__() { return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."; }
|
|
20
20
|
var EliceRecorder = function EliceRecorder(_ref) {
|
|
21
21
|
var onAudioReady = _ref.onAudioReady,
|
|
22
|
-
onTransform = _ref.onTransform
|
|
22
|
+
onTransform = _ref.onTransform,
|
|
23
|
+
_ref$type = _ref.type,
|
|
24
|
+
type = _ref$type === void 0 ? "change" : _ref$type;
|
|
23
25
|
var theme = material.useTheme();
|
|
24
26
|
var _useState = React.useState("ready"),
|
|
25
27
|
_useState2 = _rollupPluginBabelHelpers.slicedToArray(_useState, 2),
|
|
@@ -117,16 +119,16 @@ var EliceRecorder = function EliceRecorder(_ref) {
|
|
|
117
119
|
direction: "row",
|
|
118
120
|
children: [jsxRuntime.jsxs(StyledRecorderButton, {
|
|
119
121
|
step: recordingStep,
|
|
120
|
-
onClick: recordingStep === "ready" ? startRecording : stopRecording,
|
|
122
|
+
onClick: recordingStep === "ready" || recordingStep === "waiting" ? startRecording : stopRecording,
|
|
121
123
|
children: [recordingStep === "ready" || recordingStep === "waiting" ? jsxRuntime.jsx(ReadyRecord.default, {}) : jsxRuntime.jsx(Recording.default, {}), jsxRuntime.jsx(material.Typography, {
|
|
122
124
|
variant: "buttoninput",
|
|
123
125
|
children: recordingStep === "ready" ? "녹음 시작" : recordingStep === "recording" ? "녹음 중지" : "다시 녹음"
|
|
124
126
|
})]
|
|
125
127
|
}), jsxRuntime.jsx(Button.default, {
|
|
126
128
|
disabled: recordingStep !== "waiting",
|
|
127
|
-
variant: recordingStep === "waiting" ? "outlined" : "contained",
|
|
129
|
+
variant: recordingStep === "waiting" ? type === "change" ? "outlined" : "contained" : "contained",
|
|
128
130
|
onClick: onTransform,
|
|
129
|
-
children: "
|
|
131
|
+
children: type === "change" ? "변환" : "제출"
|
|
130
132
|
})]
|
|
131
133
|
})]
|
|
132
134
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
2
|
import HighlightOffIcon from '@mui/icons-material/HighlightOff';
|
|
3
|
-
import { Modal, Box, Stack
|
|
3
|
+
import { Modal, Box, Stack } from '@mui/material';
|
|
4
4
|
|
|
5
5
|
var EliceModal = function EliceModal(props) {
|
|
6
6
|
var open = props.open,
|
|
@@ -39,10 +39,7 @@ var EliceModal = function EliceModal(props) {
|
|
|
39
39
|
},
|
|
40
40
|
color: "secondary"
|
|
41
41
|
})
|
|
42
|
-
}),
|
|
43
|
-
variant: 'body1',
|
|
44
|
-
children: children
|
|
45
|
-
})]
|
|
42
|
+
}), children]
|
|
46
43
|
})
|
|
47
44
|
});
|
|
48
45
|
};
|
|
@@ -11,6 +11,8 @@ export interface EliceChatProps {
|
|
|
11
11
|
onChange: (text: string) => void;
|
|
12
12
|
onSend: (text: string) => void;
|
|
13
13
|
onRecord?: () => void;
|
|
14
|
+
setAudioFile?: (file: File | null) => void;
|
|
15
|
+
onTransform?: () => void;
|
|
14
16
|
height?: string;
|
|
15
17
|
onTranscribingChange?: (value: boolean) => void;
|
|
16
18
|
isLoadingMessage?: boolean;
|
|
@@ -18,8 +20,8 @@ export interface EliceChatProps {
|
|
|
18
20
|
CustomAssistantAvatar?: React.ReactNode;
|
|
19
21
|
}
|
|
20
22
|
declare const EliceChat: {
|
|
21
|
-
({ placeholder, messages, content, onReset, onSend, onChange, onRecord, onTranscribingChange, isLoadingMessage, CustomAssistantAvatar, isDisabled, height, }: EliceChatProps): import("react/jsx-runtime").JSX.Element;
|
|
22
|
-
MessageList({ messages, isLoadingMessage, scrollRef, height, CustomAssistantAvatar, }: {
|
|
23
|
+
({ placeholder, messages, content, onReset, onSend, onChange, onRecord, onTranscribingChange, setAudioFile, onTransform, isLoadingMessage, CustomAssistantAvatar, isDisabled, height, }: EliceChatProps): import("react/jsx-runtime").JSX.Element;
|
|
24
|
+
MessageList({ messages, isLoadingMessage, scrollRef, height, isRecord, setIsRecord, CustomAssistantAvatar, }: {
|
|
23
25
|
messages: {
|
|
24
26
|
role: "system" | "user" | "assistant";
|
|
25
27
|
content: string;
|
|
@@ -27,9 +29,11 @@ declare const EliceChat: {
|
|
|
27
29
|
isLoadingMessage?: boolean | undefined;
|
|
28
30
|
scrollRef: React.RefObject<HTMLDivElement>;
|
|
29
31
|
height?: string | undefined;
|
|
32
|
+
isRecord: boolean;
|
|
33
|
+
setIsRecord?: (() => void) | undefined;
|
|
30
34
|
CustomAssistantAvatar: React.ReactNode;
|
|
31
35
|
}): import("react/jsx-runtime").JSX.Element;
|
|
32
|
-
InputArea({ placeHolder, value, isDisabled, onChange, onSend, onReset, onRecord, onTranscribingChange, }: {
|
|
36
|
+
InputArea({ placeHolder, value, isDisabled, onChange, onSend, onReset, onRecord, onTranscribingChange, setAudioFile, onTransform, setIsRecord, isRecord, }: {
|
|
33
37
|
placeHolder: string;
|
|
34
38
|
value: string;
|
|
35
39
|
isDisabled: boolean;
|
|
@@ -37,7 +41,12 @@ declare const EliceChat: {
|
|
|
37
41
|
onSend: () => void;
|
|
38
42
|
onReset: () => void;
|
|
39
43
|
onRecord?: (() => void) | undefined;
|
|
44
|
+
isRecord: boolean;
|
|
45
|
+
setIsRecord?: (() => void) | undefined;
|
|
46
|
+
onTransform?: (() => void) | undefined;
|
|
47
|
+
setAudioFile?: ((file: File | null) => void) | undefined;
|
|
40
48
|
onTranscribingChange?: ((value: boolean) => void) | undefined;
|
|
41
49
|
}): import("react/jsx-runtime").JSX.Element;
|
|
42
50
|
};
|
|
51
|
+
export type AudioStep = "ready" | "waiting" | "recording";
|
|
43
52
|
export default EliceChat;
|
|
@@ -6,14 +6,16 @@ import { useTheme, Stack, Typography, Input } from '@mui/material';
|
|
|
6
6
|
import AssistantAvatar from './AssistantAvatar.js';
|
|
7
7
|
import UserAvatar from './UserAvatar.js';
|
|
8
8
|
import TypingIndicator from './TypingIndicator.js';
|
|
9
|
+
import EliceRecorder from '../recorder/Recorder.js';
|
|
9
10
|
import EliceIconButton from '../icon-button/IconButton.js';
|
|
10
11
|
import Micro from '../../icons/Micro.js';
|
|
11
12
|
import Reset from '../../icons/Reset.js';
|
|
12
13
|
import Send from '../../icons/Send.js';
|
|
13
14
|
|
|
15
|
+
function _EMOTION_STRINGIFIED_CSS_ERROR__() { return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."; }
|
|
14
16
|
var StyledChatContainer = /*#__PURE__*/_styled(Stack, {
|
|
15
|
-
target: "
|
|
16
|
-
})("height:fit-content;max-height:100%;height:", function (_ref) {
|
|
17
|
+
target: "e1i7zt4"
|
|
18
|
+
})("position:relative;height:fit-content;max-height:100%;height:", function (_ref) {
|
|
17
19
|
var height = _ref.height;
|
|
18
20
|
return height;
|
|
19
21
|
}, ";min-width:30rem;max-width:100%;border:2px solid ", function (_ref2) {
|
|
@@ -21,7 +23,7 @@ var StyledChatContainer = /*#__PURE__*/_styled(Stack, {
|
|
|
21
23
|
return theme.palette.grey[300];
|
|
22
24
|
}, ";border-radius:1.5rem;padding:1.5rem;gap:1.75rem;");
|
|
23
25
|
var StyledScrollBarStack = /*#__PURE__*/_styled(Stack, {
|
|
24
|
-
target: "
|
|
26
|
+
target: "e1i7zt3"
|
|
25
27
|
})("flex:1;overflow-y:auto;border-radius:1.125rem;padding-right:1rem;::-webkit-scrollbar{width:0.25rem;}::-webkit-scrollbar-track{background:", function (_ref3) {
|
|
26
28
|
var theme = _ref3.theme;
|
|
27
29
|
return theme.palette.grey[200];
|
|
@@ -33,7 +35,7 @@ var StyledScrollBarStack = /*#__PURE__*/_styled(Stack, {
|
|
|
33
35
|
return theme.palette.secondary.main;
|
|
34
36
|
}, ";}");
|
|
35
37
|
var StyledInput = /*#__PURE__*/_styled(Input, {
|
|
36
|
-
target: "
|
|
38
|
+
target: "e1i7zt2"
|
|
37
39
|
})("width:100%;height:100%;border:none!important;background-color:transparent;font-size:1.375rem;font-weight:700;outline:none;resize:none;color:", function (_ref6) {
|
|
38
40
|
var theme = _ref6.theme;
|
|
39
41
|
return theme.palette.secondary.main;
|
|
@@ -51,7 +53,7 @@ var StyledInput = /*#__PURE__*/_styled(Input, {
|
|
|
51
53
|
return theme.palette.secondary.main;
|
|
52
54
|
}, ";}");
|
|
53
55
|
var StyledMessage = /*#__PURE__*/_styled(Typography, {
|
|
54
|
-
target: "
|
|
56
|
+
target: "e1i7zt1"
|
|
55
57
|
})("color:", function (_ref11) {
|
|
56
58
|
var isAssistant = _ref11.isAssistant,
|
|
57
59
|
theme = _ref11.theme;
|
|
@@ -64,6 +66,16 @@ var StyledMessage = /*#__PURE__*/_styled(Typography, {
|
|
|
64
66
|
theme = _ref13.theme;
|
|
65
67
|
return isAssistant ? theme.palette.grey[50] : theme.palette.primary.light;
|
|
66
68
|
}, ";border-radius:1rem;white-space:pre-wrap;padding:0.75rem;margin-bottom:16px;");
|
|
69
|
+
var RecordingOverlay = /*#__PURE__*/_styled("div", {
|
|
70
|
+
target: "e1i7zt0"
|
|
71
|
+
})("production" === "production" ? {
|
|
72
|
+
name: "1805g3a",
|
|
73
|
+
styles: "position:absolute;top:0;left:24px;width:calc(100% - 48px);height:calc(100% - 24px);background-color:rgba(0, 0, 0, 0.4);z-index:999;backdrop-filter:blur(1px);border-radius:0 0 1.125rem 1.125rem"
|
|
74
|
+
} : {
|
|
75
|
+
name: "1805g3a",
|
|
76
|
+
styles: "position:absolute;top:0;left:24px;width:calc(100% - 48px);height:calc(100% - 24px);background-color:rgba(0, 0, 0, 0.4);z-index:999;backdrop-filter:blur(1px);border-radius:0 0 1.125rem 1.125rem",
|
|
77
|
+
toString: _EMOTION_STRINGIFIED_CSS_ERROR__
|
|
78
|
+
});
|
|
67
79
|
var _EliceChat = function EliceChat(_ref14) {
|
|
68
80
|
var _ref14$placeholder = _ref14.placeholder,
|
|
69
81
|
placeholder = _ref14$placeholder === void 0 ? "AI와 대화를 시작해 보세요" : _ref14$placeholder,
|
|
@@ -76,6 +88,8 @@ var _EliceChat = function EliceChat(_ref14) {
|
|
|
76
88
|
_onChange = _ref14.onChange,
|
|
77
89
|
onRecord = _ref14.onRecord,
|
|
78
90
|
onTranscribingChange = _ref14.onTranscribingChange,
|
|
91
|
+
setAudioFile = _ref14.setAudioFile,
|
|
92
|
+
onTransform = _ref14.onTransform,
|
|
79
93
|
isLoadingMessage = _ref14.isLoadingMessage,
|
|
80
94
|
CustomAssistantAvatar = _ref14.CustomAssistantAvatar,
|
|
81
95
|
_ref14$isDisabled = _ref14.isDisabled,
|
|
@@ -88,6 +102,16 @@ var _EliceChat = function EliceChat(_ref14) {
|
|
|
88
102
|
inputValue = _useState2[0],
|
|
89
103
|
setInputValue = _useState2[1];
|
|
90
104
|
var scrollRef = useRef(null);
|
|
105
|
+
var _useState3 = useState(false),
|
|
106
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
107
|
+
isRecord = _useState4[0],
|
|
108
|
+
setIsRecord = _useState4[1];
|
|
109
|
+
var onClickRecordButton = function onClickRecordButton() {
|
|
110
|
+
setIsRecord(true);
|
|
111
|
+
};
|
|
112
|
+
var onClickRecordOverlay = function onClickRecordOverlay() {
|
|
113
|
+
setIsRecord(false);
|
|
114
|
+
};
|
|
91
115
|
useEffect(function () {
|
|
92
116
|
if (scrollRef.current) {
|
|
93
117
|
scrollRef.current.scrollIntoView({
|
|
@@ -95,6 +119,10 @@ var _EliceChat = function EliceChat(_ref14) {
|
|
|
95
119
|
});
|
|
96
120
|
}
|
|
97
121
|
}, [messages, isLoadingMessage]);
|
|
122
|
+
var onClickRecordSubmit = function onClickRecordSubmit() {
|
|
123
|
+
setIsRecord(false);
|
|
124
|
+
onTransform === null || onTransform === void 0 ? void 0 : onTransform();
|
|
125
|
+
};
|
|
98
126
|
var handleSend = function handleSend() {
|
|
99
127
|
if (inputValue.trim()) {
|
|
100
128
|
onSend(inputValue);
|
|
@@ -108,6 +136,8 @@ var _EliceChat = function EliceChat(_ref14) {
|
|
|
108
136
|
messages: messages,
|
|
109
137
|
isLoadingMessage: isLoadingMessage,
|
|
110
138
|
scrollRef: scrollRef,
|
|
139
|
+
setIsRecord: onClickRecordOverlay,
|
|
140
|
+
isRecord: isRecord,
|
|
111
141
|
CustomAssistantAvatar: CustomAssistantAvatar
|
|
112
142
|
}), jsx(_EliceChat.InputArea, {
|
|
113
143
|
placeHolder: placeholder,
|
|
@@ -116,6 +146,10 @@ var _EliceChat = function EliceChat(_ref14) {
|
|
|
116
146
|
setInputValue(e.target.value);
|
|
117
147
|
_onChange(e.target.value);
|
|
118
148
|
},
|
|
149
|
+
setIsRecord: onClickRecordButton,
|
|
150
|
+
isRecord: isRecord,
|
|
151
|
+
setAudioFile: setAudioFile,
|
|
152
|
+
onTransform: onClickRecordSubmit,
|
|
119
153
|
onSend: handleSend,
|
|
120
154
|
onReset: onReset,
|
|
121
155
|
onRecord: onRecord,
|
|
@@ -131,12 +165,16 @@ _EliceChat.MessageList = function (_ref15) {
|
|
|
131
165
|
scrollRef = _ref15.scrollRef,
|
|
132
166
|
_ref15$height = _ref15.height,
|
|
133
167
|
height = _ref15$height === void 0 ? "100%" : _ref15$height,
|
|
168
|
+
isRecord = _ref15.isRecord,
|
|
169
|
+
setIsRecord = _ref15.setIsRecord,
|
|
134
170
|
CustomAssistantAvatar = _ref15.CustomAssistantAvatar;
|
|
135
171
|
var theme = useTheme();
|
|
136
|
-
return
|
|
172
|
+
return jsxs(StyledScrollBarStack, {
|
|
137
173
|
theme: theme,
|
|
138
174
|
height: height,
|
|
139
|
-
children:
|
|
175
|
+
children: [isRecord && jsx(RecordingOverlay, {
|
|
176
|
+
onClick: setIsRecord
|
|
177
|
+
}), messages.length === 0 ? jsx(Typography, {
|
|
140
178
|
color: theme.palette.text.disabled,
|
|
141
179
|
fontSize: "2rem",
|
|
142
180
|
fontWeight: 700,
|
|
@@ -161,7 +199,7 @@ _EliceChat.MessageList = function (_ref15) {
|
|
|
161
199
|
}), isLoadingMessage && jsx(TypingIndicator, {}), jsx("div", {
|
|
162
200
|
ref: scrollRef
|
|
163
201
|
})]
|
|
164
|
-
})
|
|
202
|
+
})]
|
|
165
203
|
});
|
|
166
204
|
};
|
|
167
205
|
_EliceChat.InputArea = function (_ref16) {
|
|
@@ -172,40 +210,59 @@ _EliceChat.InputArea = function (_ref16) {
|
|
|
172
210
|
onSend = _ref16.onSend,
|
|
173
211
|
onReset = _ref16.onReset,
|
|
174
212
|
onRecord = _ref16.onRecord,
|
|
175
|
-
onTranscribingChange = _ref16.onTranscribingChange
|
|
213
|
+
onTranscribingChange = _ref16.onTranscribingChange,
|
|
214
|
+
setAudioFile = _ref16.setAudioFile,
|
|
215
|
+
onTransform = _ref16.onTransform,
|
|
216
|
+
setIsRecord = _ref16.setIsRecord,
|
|
217
|
+
isRecord = _ref16.isRecord;
|
|
218
|
+
var _a;
|
|
176
219
|
var theme = useTheme();
|
|
177
|
-
return
|
|
220
|
+
return jsx(Stack, {
|
|
178
221
|
direction: "row",
|
|
179
222
|
minHeight: "3.875rem",
|
|
180
223
|
bgcolor: theme.palette.grey[50],
|
|
181
224
|
borderRadius: "1.125rem",
|
|
225
|
+
width: isRecord ? "100%" : "auto",
|
|
226
|
+
justifyContent: isRecord ? "center" : "none",
|
|
227
|
+
alignItems: isRecord ? "center" : "none",
|
|
182
228
|
p: "0.5rem 1rem",
|
|
183
229
|
gap: "0.625rem",
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
230
|
+
zIndex: "1000",
|
|
231
|
+
children: isRecord ? jsx(EliceRecorder
|
|
232
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
233
|
+
, {
|
|
234
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
235
|
+
onAudioReady: (_a = setAudioFile !== null && setAudioFile !== void 0 ? setAudioFile : setAudioFile) !== null && _a !== void 0 ? _a : function () {},
|
|
236
|
+
onTransform: onTransform,
|
|
237
|
+
type: "submit"
|
|
238
|
+
}) : jsxs(Fragment, {
|
|
239
|
+
children: [jsx(Stack, {
|
|
240
|
+
flexGrow: 1,
|
|
241
|
+
maxHeight: "14.625rem",
|
|
242
|
+
children: jsx(StyledInput, {
|
|
243
|
+
disabled: isDisabled,
|
|
244
|
+
value: value,
|
|
245
|
+
onChange: onChange,
|
|
246
|
+
placeholder: placeHolder,
|
|
247
|
+
theme: theme,
|
|
248
|
+
multiline: true
|
|
249
|
+
})
|
|
250
|
+
}), onRecord && jsx(EliceIconButton, {
|
|
251
|
+
onClick: function onClick() {
|
|
252
|
+
setIsRecord === null || setIsRecord === void 0 ? void 0 : setIsRecord();
|
|
253
|
+
onRecord();
|
|
254
|
+
onTranscribingChange === null || onTranscribingChange === void 0 ? void 0 : onTranscribingChange(true);
|
|
255
|
+
},
|
|
256
|
+
children: jsx(Micro, {})
|
|
257
|
+
}), jsx(EliceIconButton, {
|
|
258
|
+
onClick: onReset,
|
|
259
|
+
children: jsx(Reset, {})
|
|
260
|
+
}), jsx(EliceIconButton, {
|
|
261
|
+
onClick: onSend,
|
|
262
|
+
disabled: !value.trim(),
|
|
263
|
+
children: jsx(Send, {})
|
|
264
|
+
})]
|
|
265
|
+
})
|
|
209
266
|
});
|
|
210
267
|
};
|
|
211
268
|
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
type RecorderType = "submit" | "change";
|
|
1
2
|
export interface EliceRecorderProps {
|
|
2
3
|
onAudioReady: (file: File) => void;
|
|
3
4
|
onTransform?: () => void;
|
|
5
|
+
type?: RecorderType;
|
|
4
6
|
}
|
|
5
|
-
declare const EliceRecorder: ({ onAudioReady, onTransform }: EliceRecorderProps) => import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
declare const EliceRecorder: ({ onAudioReady, onTransform, type }: EliceRecorderProps) => import("react/jsx-runtime").JSX.Element;
|
|
6
8
|
export default EliceRecorder;
|
|
@@ -10,7 +10,9 @@ import EliceButton from '../button/Button.js';
|
|
|
10
10
|
function _EMOTION_STRINGIFIED_CSS_ERROR__() { return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."; }
|
|
11
11
|
var EliceRecorder = function EliceRecorder(_ref) {
|
|
12
12
|
var onAudioReady = _ref.onAudioReady,
|
|
13
|
-
onTransform = _ref.onTransform
|
|
13
|
+
onTransform = _ref.onTransform,
|
|
14
|
+
_ref$type = _ref.type,
|
|
15
|
+
type = _ref$type === void 0 ? "change" : _ref$type;
|
|
14
16
|
var theme = useTheme();
|
|
15
17
|
var _useState = useState("ready"),
|
|
16
18
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -108,16 +110,16 @@ var EliceRecorder = function EliceRecorder(_ref) {
|
|
|
108
110
|
direction: "row",
|
|
109
111
|
children: [jsxs(StyledRecorderButton, {
|
|
110
112
|
step: recordingStep,
|
|
111
|
-
onClick: recordingStep === "ready" ? startRecording : stopRecording,
|
|
113
|
+
onClick: recordingStep === "ready" || recordingStep === "waiting" ? startRecording : stopRecording,
|
|
112
114
|
children: [recordingStep === "ready" || recordingStep === "waiting" ? jsx(ReadyRecord, {}) : jsx(Recording, {}), jsx(Typography, {
|
|
113
115
|
variant: "buttoninput",
|
|
114
116
|
children: recordingStep === "ready" ? "녹음 시작" : recordingStep === "recording" ? "녹음 중지" : "다시 녹음"
|
|
115
117
|
})]
|
|
116
118
|
}), jsx(EliceButton, {
|
|
117
119
|
disabled: recordingStep !== "waiting",
|
|
118
|
-
variant: recordingStep === "waiting" ? "outlined" : "contained",
|
|
120
|
+
variant: recordingStep === "waiting" ? type === "change" ? "outlined" : "contained" : "contained",
|
|
119
121
|
onClick: onTransform,
|
|
120
|
-
children: "
|
|
122
|
+
children: type === "change" ? "변환" : "제출"
|
|
121
123
|
})]
|
|
122
124
|
})]
|
|
123
125
|
});
|