@ray-js/t-agent-ui-ray 0.1.1 → 0.2.0-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/dist/ChatContainer/index.js +0 -10
- package/dist/MessageInput/MessageInputAIStream/AsrInput.d.ts +15 -0
- package/dist/MessageInput/MessageInputAIStream/AsrInput.js +109 -0
- package/dist/MessageInput/MessageInputAIStream/index.d.ts +10 -0
- package/dist/MessageInput/MessageInputAIStream/index.js +359 -0
- package/dist/MessageInput/{AsrInput.d.ts → MessageInputAssistant/AsrInput.d.ts} +1 -1
- package/dist/MessageInput/{AsrInput.js → MessageInputAssistant/AsrInput.js} +2 -2
- package/dist/MessageInput/MessageInputAssistant/index.d.ts +11 -0
- package/dist/MessageInput/MessageInputAssistant/index.js +322 -0
- package/dist/MessageInput/icons/keyboard.svg +1 -0
- package/dist/MessageInput/index.d.ts +0 -1
- package/dist/MessageInput/index.js +3 -320
- package/dist/MessageInput/index.less +78 -3
- package/dist/MessageList/index.d.ts +5 -0
- package/dist/MessageList/index.js +4 -2
- package/dist/MessageRender/index.d.ts +6 -1
- package/dist/MessageRender/index.js +19 -2
- package/dist/MessageRender/index.less +48 -1
- package/dist/PrivateImage/index.js +1 -1
- package/dist/cards/map.js +3 -2
- package/dist/contexts.d.ts +1 -2
- package/dist/contexts.js +1 -0
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.js +2 -1
- package/dist/hooks/useAttachmentInput.d.ts +3 -1
- package/dist/hooks/useAttachmentInput.js +75 -34
- package/dist/hooks/useLongPress.d.ts +1 -1
- package/dist/hooks/useLongPress.js +38 -36
- package/dist/hooks/useMultSelect.d.ts +7 -0
- package/dist/hooks/useMultSelect.js +12 -0
- package/dist/i18n/strings.d.ts +8 -0
- package/dist/i18n/strings.js +11 -0
- package/dist/renderOption.js +5 -0
- package/dist/tiles/BubbleTile/index.js +9 -10
- package/dist/tiles/CardTile/index.js +6 -7
- package/dist/tiles/ExecuteCardTile/index.d.ts +8 -1
- package/dist/tiles/ExecuteCardTile/index.js +11 -1
- package/dist/tiles/FileTile/index.d.ts +8 -0
- package/dist/tiles/FileTile/index.js +57 -0
- package/dist/tiles/FileTile/index.less +44 -0
- package/dist/tiles/ImageTile/index.js +1 -0
- package/dist/tiles/OperateCardTile/Expand.d.ts +7 -1
- package/dist/tiles/OperateCardTile/Expand.js +11 -1
- package/dist/tiles/OperateCardTile/index.d.ts +4 -1
- package/dist/tiles/OperateCardTile/index.js +2 -0
- package/dist/tiles/WorkflowTile/RollBack/index.js +11 -12
- package/dist/tiles/WorkflowTile/index.d.ts +4 -1
- package/dist/tiles/map.js +3 -1
- package/dist/types.d.ts +2 -0
- package/dist/utils/file.d.ts +24 -0
- package/dist/utils/file.js +190 -0
- package/package.json +2 -2
|
@@ -1,322 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import "core-js/modules/esnext.iterator.filter.js";
|
|
4
|
-
import "core-js/modules/esnext.iterator.map.js";
|
|
5
|
-
import "core-js/modules/web.dom-collections.iterator.js";
|
|
6
|
-
import './index.less';
|
|
7
|
-
import { Button, View } from '@ray-js/components';
|
|
8
|
-
import React, { useRef, useState } from 'react';
|
|
9
|
-
import { Image, Input, ScrollView } from '@ray-js/ray';
|
|
10
|
-
import { Asr, AbortController } from '@ray-js/t-agent-plugin-assistant';
|
|
11
|
-
import cx from 'clsx';
|
|
12
|
-
import PrivateImage from '../PrivateImage';
|
|
13
|
-
import imageSvg from './icons/image.svg';
|
|
14
|
-
import videoSvg from './icons/video.svg';
|
|
15
|
-
import loadingSvg from './icons/loading.svg';
|
|
16
|
-
import closeCircleSvg from './icons/close-circle.svg';
|
|
17
|
-
import { useAttachmentInput, useChatAgent, useEmitEvent, useIsUnmounted, useOnEvent, useRenderOptions, useTranslate } from '../hooks';
|
|
18
|
-
import AsrInput from './AsrInput';
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import MessageInputAIStream from './MessageInputAIStream';
|
|
19
3
|
export default function MessageInput(props) {
|
|
20
|
-
|
|
21
|
-
const t = useTranslate();
|
|
22
|
-
const [text, setText] = useState('');
|
|
23
|
-
const [asrText, setAsrText] = useState('');
|
|
24
|
-
const attachmentInput = useAttachmentInput();
|
|
25
|
-
const {
|
|
26
|
-
uploading,
|
|
27
|
-
uploaded,
|
|
28
|
-
setUploaded,
|
|
29
|
-
upload
|
|
30
|
-
} = attachmentInput;
|
|
31
|
-
const acRef = useRef(null);
|
|
32
|
-
const [responding, setResponding] = useState(false);
|
|
33
|
-
const [mode, setMode] = useState('text');
|
|
34
|
-
const agent = useChatAgent();
|
|
35
|
-
const emitEvent = useEmitEvent();
|
|
36
|
-
const isUnmounted = useIsUnmounted();
|
|
37
|
-
useOnEvent('networkChange', _ref => {
|
|
38
|
-
let {
|
|
39
|
-
online
|
|
40
|
-
} = _ref;
|
|
41
|
-
if (!online && responding) {
|
|
42
|
-
setResponding(false);
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
const hasMore = !!agent.plugins.assistant.options.multiModal;
|
|
46
|
-
const isMore = !text.trim().length && hasMore;
|
|
47
|
-
const send = async inputBlocks => {
|
|
48
|
-
if (!(inputBlocks !== null && inputBlocks !== void 0 && inputBlocks.length) || attachmentInput.uploading || responding) {
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
setUploaded([]);
|
|
52
|
-
setText('');
|
|
53
|
-
setResponding(true);
|
|
54
|
-
const ac = new AbortController();
|
|
55
|
-
acRef.current = ac;
|
|
56
|
-
ac.signal.addEventListener('abort', () => {
|
|
57
|
-
if (acRef.current === ac) {
|
|
58
|
-
acRef.current = null;
|
|
59
|
-
}
|
|
60
|
-
setResponding(false);
|
|
61
|
-
});
|
|
62
|
-
try {
|
|
63
|
-
await agent.pushInputBlocks(inputBlocks, ac.signal);
|
|
64
|
-
} finally {
|
|
65
|
-
if (!isUnmounted()) {
|
|
66
|
-
setResponding(false);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
useOnEvent('sendMessage', async _ref2 => {
|
|
71
|
-
let {
|
|
72
|
-
blocks
|
|
73
|
-
} = _ref2;
|
|
74
|
-
if (uploading || responding) {
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
setText('');
|
|
78
|
-
setMoreOpen(false);
|
|
79
|
-
setUploaded([]);
|
|
80
|
-
setResponding(true);
|
|
81
|
-
const ac = new AbortController();
|
|
82
|
-
acRef.current = ac;
|
|
83
|
-
ac.signal.addEventListener('abort', () => {
|
|
84
|
-
if (acRef.current === ac) {
|
|
85
|
-
acRef.current = null;
|
|
86
|
-
}
|
|
87
|
-
setResponding(false);
|
|
88
|
-
});
|
|
89
|
-
try {
|
|
90
|
-
await agent.pushInputBlocks(blocks, ac.signal);
|
|
91
|
-
} finally {
|
|
92
|
-
if (!isUnmounted()) {
|
|
93
|
-
setResponding(false);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
|
-
useOnEvent('setInputBlocks', async _ref3 => {
|
|
98
|
-
let {
|
|
99
|
-
blocks
|
|
100
|
-
} = _ref3;
|
|
101
|
-
if (uploading || responding) {
|
|
102
|
-
return;
|
|
103
|
-
}
|
|
104
|
-
if (mode !== 'text') {
|
|
105
|
-
setMode('text');
|
|
106
|
-
}
|
|
107
|
-
attachmentInput.loadBlocks(blocks);
|
|
108
|
-
let t = '';
|
|
109
|
-
for (const block of blocks) {
|
|
110
|
-
if (block.type === 'text') {
|
|
111
|
-
t = block.text;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
if (t) {
|
|
115
|
-
setText(t);
|
|
116
|
-
}
|
|
117
|
-
setMoreOpen(false);
|
|
118
|
-
});
|
|
119
|
-
const openMoreClick = () => {
|
|
120
|
-
setMoreOpen(!moreOpen);
|
|
121
|
-
if (!moreOpen) {
|
|
122
|
-
emitEvent('scrollToBottom', {
|
|
123
|
-
animation: true
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
};
|
|
127
|
-
const {
|
|
128
|
-
getStaticResourceBizType
|
|
129
|
-
} = useRenderOptions();
|
|
130
|
-
let container;
|
|
131
|
-
if (mode === 'text') {
|
|
132
|
-
container = /*#__PURE__*/React.createElement(View, {
|
|
133
|
-
className: "t-agent-message-input-text-bar"
|
|
134
|
-
}, /*#__PURE__*/React.createElement(View, {
|
|
135
|
-
className: "t-agent-message-input-text-group"
|
|
136
|
-
}, /*#__PURE__*/React.createElement(Input, {
|
|
137
|
-
confirmType: "send",
|
|
138
|
-
value: text,
|
|
139
|
-
onInput: event => setText(event.detail.value),
|
|
140
|
-
placeholder: props.placeholder,
|
|
141
|
-
"data-testid": "t-agent-message-input-text-inner",
|
|
142
|
-
className: "t-agent-message-input-text-inner",
|
|
143
|
-
onConfirm: () => {
|
|
144
|
-
if (text.trim().length) {
|
|
145
|
-
send([...attachmentInput.blocks, {
|
|
146
|
-
type: 'text',
|
|
147
|
-
text
|
|
148
|
-
}]);
|
|
149
|
-
}
|
|
150
|
-
},
|
|
151
|
-
maxLength: 200,
|
|
152
|
-
placeholderStyle: "color: var(--app-B1-N4)",
|
|
153
|
-
onFocus: () => {
|
|
154
|
-
setMoreOpen(false);
|
|
155
|
-
emitEvent('scrollToBottom', {
|
|
156
|
-
animation: true
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
}), /*#__PURE__*/React.createElement(Button, {
|
|
160
|
-
"data-testid": "t-agent-message-input-button-asr",
|
|
161
|
-
onClick: async () => {
|
|
162
|
-
const auth = await Asr.authorize();
|
|
163
|
-
if (!auth) {
|
|
164
|
-
ty.showToast({
|
|
165
|
-
icon: 'none',
|
|
166
|
-
title: t('t-agent.input.voice.require-permission')
|
|
167
|
-
});
|
|
168
|
-
return;
|
|
169
|
-
}
|
|
170
|
-
setText('');
|
|
171
|
-
setMode('voice');
|
|
172
|
-
},
|
|
173
|
-
className: "t-agent-message-input-button t-agent-message-input-button-voice"
|
|
174
|
-
})), /*#__PURE__*/React.createElement(Button, {
|
|
175
|
-
disabled: !isMore && uploading,
|
|
176
|
-
className: cx('t-agent-message-input-button', {
|
|
177
|
-
't-agent-message-input-button-more': isMore,
|
|
178
|
-
't-agent-message-input-button-more-open': moreOpen && isMore,
|
|
179
|
-
't-agent-message-input-button-send': !isMore && !responding,
|
|
180
|
-
't-agent-message-input-button-stop': responding
|
|
181
|
-
}),
|
|
182
|
-
"data-testid": "t-agent-message-input-button-main",
|
|
183
|
-
onClick: async () => {
|
|
184
|
-
if (responding) {
|
|
185
|
-
if (acRef.current) {
|
|
186
|
-
acRef.current.abort('User abort');
|
|
187
|
-
}
|
|
188
|
-
} else if (isMore) {
|
|
189
|
-
openMoreClick();
|
|
190
|
-
} else if (text.trim().length) {
|
|
191
|
-
await send([...attachmentInput.blocks, {
|
|
192
|
-
type: 'text',
|
|
193
|
-
text
|
|
194
|
-
}]);
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
}));
|
|
198
|
-
} else {
|
|
199
|
-
container = /*#__PURE__*/React.createElement(AsrInput, {
|
|
200
|
-
text: asrText,
|
|
201
|
-
setText: setAsrText,
|
|
202
|
-
onBack: () => {
|
|
203
|
-
setText('');
|
|
204
|
-
setMode('text');
|
|
205
|
-
},
|
|
206
|
-
onAbort: () => {
|
|
207
|
-
if (acRef.current) {
|
|
208
|
-
acRef.current.abort('User abort');
|
|
209
|
-
}
|
|
210
|
-
},
|
|
211
|
-
moreOpen: moreOpen,
|
|
212
|
-
closeMore: () => setMoreOpen(false),
|
|
213
|
-
onMoreClick: openMoreClick,
|
|
214
|
-
responding: responding,
|
|
215
|
-
sendDisabled: uploading,
|
|
216
|
-
onSend: async () => {
|
|
217
|
-
if (asrText) {
|
|
218
|
-
await send([...attachmentInput.blocks, {
|
|
219
|
-
type: 'text',
|
|
220
|
-
text: asrText
|
|
221
|
-
}]);
|
|
222
|
-
}
|
|
223
|
-
},
|
|
224
|
-
hasMore: hasMore,
|
|
225
|
-
onError: error => {
|
|
226
|
-
ty.showToast({
|
|
227
|
-
icon: 'error',
|
|
228
|
-
title: error.message
|
|
229
|
-
});
|
|
230
|
-
}
|
|
231
|
-
});
|
|
232
|
-
}
|
|
233
|
-
return /*#__PURE__*/React.createElement(View, {
|
|
234
|
-
className: "".concat(props.className || '', " t-agent-message-input"),
|
|
235
|
-
style: props.style
|
|
236
|
-
}, /*#__PURE__*/React.createElement(View, {
|
|
237
|
-
className: "t-agent-message-input-container"
|
|
238
|
-
}, props.renderTop, !!uploaded.length && /*#__PURE__*/React.createElement(ScrollView, {
|
|
239
|
-
scrollX: true,
|
|
240
|
-
scrollY: false,
|
|
241
|
-
enableFlex: true,
|
|
242
|
-
className: "t-agent-message-input-uploaded-files",
|
|
243
|
-
refresherTriggered: false
|
|
244
|
-
}, uploaded.map(file => {
|
|
245
|
-
let content;
|
|
246
|
-
switch (file.type) {
|
|
247
|
-
case 'image':
|
|
248
|
-
content = /*#__PURE__*/React.createElement(PrivateImage, {
|
|
249
|
-
className: "t-agent-message-input-uploaded-file-image",
|
|
250
|
-
mode: "aspectFill",
|
|
251
|
-
bizType: getStaticResourceBizType(file.url, 'image:view'),
|
|
252
|
-
src: file.url
|
|
253
|
-
});
|
|
254
|
-
break;
|
|
255
|
-
case 'video':
|
|
256
|
-
content = /*#__PURE__*/React.createElement(PrivateImage, {
|
|
257
|
-
bizType: getStaticResourceBizType(file.thumbUrl, 'videoThumb:view'),
|
|
258
|
-
className: "t-agent-message-input-uploaded-file-image",
|
|
259
|
-
mode: "aspectFill",
|
|
260
|
-
src: file.thumbUrl
|
|
261
|
-
});
|
|
262
|
-
break;
|
|
263
|
-
case 'loading':
|
|
264
|
-
content = /*#__PURE__*/React.createElement(View, {
|
|
265
|
-
className: "t-agent-message-input-uploaded-file-loading",
|
|
266
|
-
key: file.id
|
|
267
|
-
}, /*#__PURE__*/React.createElement(Image, {
|
|
268
|
-
src: loadingSvg,
|
|
269
|
-
className: "t-agent-message-input-uploaded-file-loading-icon"
|
|
270
|
-
}));
|
|
271
|
-
break;
|
|
272
|
-
default:
|
|
273
|
-
content = null;
|
|
274
|
-
}
|
|
275
|
-
return /*#__PURE__*/React.createElement(View, {
|
|
276
|
-
key: file.id,
|
|
277
|
-
className: "t-agent-message-input-uploaded-file"
|
|
278
|
-
}, /*#__PURE__*/React.createElement(Image, {
|
|
279
|
-
onClick: () => {
|
|
280
|
-
setUploaded(prev => prev.filter(f => f.id !== file.id));
|
|
281
|
-
},
|
|
282
|
-
className: "t-agent-message-input-uploaded-file-delete",
|
|
283
|
-
src: closeCircleSvg
|
|
284
|
-
}), content);
|
|
285
|
-
})), container), /*#__PURE__*/React.createElement(View, {
|
|
286
|
-
className: "t-agent-message-input-panel ".concat(moreOpen ? '' : 't-agent-message-input-panel-close')
|
|
287
|
-
}, /*#__PURE__*/React.createElement(View, {
|
|
288
|
-
className: "t-agent-message-input-panel-content"
|
|
289
|
-
}, /*#__PURE__*/React.createElement(Button, {
|
|
290
|
-
className: "t-agent-message-input-panel-button",
|
|
291
|
-
onClick: async () => {
|
|
292
|
-
try {
|
|
293
|
-
await upload('image', 1);
|
|
294
|
-
} catch (e) {
|
|
295
|
-
ty.showToast({
|
|
296
|
-
icon: 'error',
|
|
297
|
-
title: t('t-agent.input.upload.failed')
|
|
298
|
-
});
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
}, /*#__PURE__*/React.createElement(View, {
|
|
302
|
-
className: "t-agent-message-input-panel-button-icon"
|
|
303
|
-
}, /*#__PURE__*/React.createElement(Image, {
|
|
304
|
-
src: imageSvg
|
|
305
|
-
}))), /*#__PURE__*/React.createElement(Button, {
|
|
306
|
-
className: "t-agent-message-input-panel-button",
|
|
307
|
-
onClick: async () => {
|
|
308
|
-
try {
|
|
309
|
-
await upload('video', 1);
|
|
310
|
-
} catch (e) {
|
|
311
|
-
ty.showToast({
|
|
312
|
-
icon: 'error',
|
|
313
|
-
title: t('t-agent.input.upload.failed')
|
|
314
|
-
});
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
}, /*#__PURE__*/React.createElement(View, {
|
|
318
|
-
className: "t-agent-message-input-panel-button-icon"
|
|
319
|
-
}, /*#__PURE__*/React.createElement(Image, {
|
|
320
|
-
src: videoSvg
|
|
321
|
-
}))))));
|
|
4
|
+
return /*#__PURE__*/React.createElement(MessageInputAIStream, props);
|
|
322
5
|
}
|
|
@@ -146,8 +146,16 @@
|
|
|
146
146
|
right: 10rpx;
|
|
147
147
|
}
|
|
148
148
|
|
|
149
|
+
.t-agent-message-input-button-keyboard {
|
|
150
|
+
background: transparent url('icons/keyboard.svg') no-repeat center;
|
|
151
|
+
position: absolute;
|
|
152
|
+
top: 50%;
|
|
153
|
+
transform: translateY(-50%);
|
|
154
|
+
right: 10rpx;
|
|
155
|
+
}
|
|
156
|
+
|
|
149
157
|
.t-agent-message-input-button-stop {
|
|
150
|
-
background: rgba(0,0,0,0) url('icons/stop.svg') no-repeat center;
|
|
158
|
+
background: rgba(0, 0, 0, 0) url('icons/stop.svg') no-repeat center;
|
|
151
159
|
border: 2rpx solid var(--t-agent-input-border-color);
|
|
152
160
|
}
|
|
153
161
|
|
|
@@ -155,7 +163,7 @@
|
|
|
155
163
|
overflow: hidden;
|
|
156
164
|
height: 168rpx;
|
|
157
165
|
box-sizing: border-box;
|
|
158
|
-
transition: height .2s ease-in-out;
|
|
166
|
+
transition: height 0.2s ease-in-out;
|
|
159
167
|
}
|
|
160
168
|
|
|
161
169
|
.t-agent-message-input-panel-close {
|
|
@@ -251,7 +259,7 @@
|
|
|
251
259
|
left: 0;
|
|
252
260
|
right: 0;
|
|
253
261
|
height: 100vh;
|
|
254
|
-
background: linear-gradient(to top, var(--app-B3), rgba(0, 0, 0, 0));
|
|
262
|
+
background: linear-gradient(to top, var(--app-B3), rgba(0, 0, 0, 0)); //z-index: 100;
|
|
255
263
|
}
|
|
256
264
|
|
|
257
265
|
.t-agent-message-input-voice-bubble {
|
|
@@ -305,3 +313,70 @@
|
|
|
305
313
|
border: none;
|
|
306
314
|
min-height: 56rpx;
|
|
307
315
|
}
|
|
316
|
+
|
|
317
|
+
@transition-duration: 0.3s;
|
|
318
|
+
|
|
319
|
+
.t-agent-message-input-ptt {
|
|
320
|
+
background: transparent;
|
|
321
|
+
padding: 0;
|
|
322
|
+
border: none;
|
|
323
|
+
height: 56rpx;
|
|
324
|
+
display: flex;
|
|
325
|
+
justify-content: center;
|
|
326
|
+
align-items: center;
|
|
327
|
+
transition: height @transition-duration ease-in-out; // 定义高度变化的过渡效果
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
.t-agent-message-input-ptt-handle {
|
|
331
|
+
height: 224rpx;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
.t-agent-message-input-ptt-text {
|
|
335
|
+
font-size: 32rpx;
|
|
336
|
+
line-height: 56rpx;
|
|
337
|
+
color: var(--app-M1-B1);
|
|
338
|
+
text-align: center;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
.t-agent-message-input-oninput-text-top {
|
|
342
|
+
font-size: 32rpx;
|
|
343
|
+
line-height: 56rpx;
|
|
344
|
+
color: var(--app-M1-B1);
|
|
345
|
+
text-align: center;
|
|
346
|
+
}
|
|
347
|
+
.t-agent-message-input-oninput-text-center {
|
|
348
|
+
font-size: 20rpx;
|
|
349
|
+
color: var(--app-M1-B1);
|
|
350
|
+
text-align: center;
|
|
351
|
+
margin-top: 32rpx;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
.t-agent-message-input-waveform-container {
|
|
355
|
+
display: flex;
|
|
356
|
+
align-items: center;
|
|
357
|
+
justify-content: center;
|
|
358
|
+
gap: 2px;
|
|
359
|
+
height: 40px;
|
|
360
|
+
padding: 8px 0;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
.t-agent-message-input-waveform-bar {
|
|
364
|
+
width: 2px;
|
|
365
|
+
min-height: 2px;
|
|
366
|
+
background-color: #4a90e2;
|
|
367
|
+
border-radius: 1px;
|
|
368
|
+
transition: height 0.3s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.3s ease;
|
|
369
|
+
animation: colorPulse 2s infinite;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
@keyframes colorPulse {
|
|
373
|
+
0% {
|
|
374
|
+
background-color: #4a90e2;
|
|
375
|
+
}
|
|
376
|
+
50% {
|
|
377
|
+
background-color: #7cb3ff;
|
|
378
|
+
}
|
|
379
|
+
100% {
|
|
380
|
+
background-color: #4a90e2;
|
|
381
|
+
}
|
|
382
|
+
}
|
|
@@ -10,6 +10,11 @@ interface Props {
|
|
|
10
10
|
assistant?: 'start' | 'end' | string;
|
|
11
11
|
[key: string]: 'start' | 'end' | string;
|
|
12
12
|
};
|
|
13
|
+
multSelect?: {
|
|
14
|
+
show: boolean;
|
|
15
|
+
select: string[];
|
|
16
|
+
onSelect: (msgs: string[]) => void;
|
|
17
|
+
};
|
|
13
18
|
historyLimit?: {
|
|
14
19
|
/** 历史消息数量限制 */
|
|
15
20
|
count: number;
|
|
@@ -8,7 +8,7 @@ import { View } from '@ray-js/components';
|
|
|
8
8
|
import React, { useMemo, useRef, useState } from 'react';
|
|
9
9
|
import { ScrollView } from '@ray-js/ray';
|
|
10
10
|
import { generateId } from '@ray-js/t-agent';
|
|
11
|
-
import { isVersionMatch } from '@ray-js/t-agent-plugin-
|
|
11
|
+
import { isVersionMatch } from '@ray-js/t-agent-plugin-aistream';
|
|
12
12
|
import MessageRender from '../MessageRender';
|
|
13
13
|
import { useAgentMessage, useOnEvent } from '../hooks';
|
|
14
14
|
import { useDebouncedFn } from '../hooks/useDebouncedFn';
|
|
@@ -20,7 +20,8 @@ export default function MessageList(props) {
|
|
|
20
20
|
style,
|
|
21
21
|
wrapperClassName,
|
|
22
22
|
wrapperStyle,
|
|
23
|
-
historyLimit
|
|
23
|
+
historyLimit,
|
|
24
|
+
multSelect
|
|
24
25
|
} = props;
|
|
25
26
|
const {
|
|
26
27
|
messages
|
|
@@ -103,6 +104,7 @@ export default function MessageList(props) {
|
|
|
103
104
|
side = msg.role === 'user' ? 'end' : 'start';
|
|
104
105
|
}
|
|
105
106
|
return /*#__PURE__*/React.createElement(MessageRender, {
|
|
107
|
+
multSelect: multSelect,
|
|
106
108
|
key: msg.id,
|
|
107
109
|
message: msg,
|
|
108
110
|
isLatestMessage: index === 0,
|
|
@@ -5,6 +5,11 @@ interface Props {
|
|
|
5
5
|
message: ChatMessageObject;
|
|
6
6
|
isLatestMessage: boolean;
|
|
7
7
|
side: 'start' | 'end' | string;
|
|
8
|
+
multSelect?: {
|
|
9
|
+
show: boolean;
|
|
10
|
+
select: string[];
|
|
11
|
+
onSelect: (msgs: string[]) => void;
|
|
12
|
+
};
|
|
8
13
|
}
|
|
9
|
-
export default function MessageRender({ message, isLatestMessage, side }: Props): React.JSX.Element;
|
|
14
|
+
export default function MessageRender({ message, isLatestMessage, side, multSelect }: Props): React.JSX.Element;
|
|
10
15
|
export {};
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import "core-js/modules/esnext.iterator.constructor.js";
|
|
2
|
+
import "core-js/modules/esnext.iterator.filter.js";
|
|
2
3
|
import "core-js/modules/esnext.iterator.map.js";
|
|
4
|
+
import "core-js/modules/web.dom-collections.iterator.js";
|
|
3
5
|
import './index.less';
|
|
4
6
|
import { View } from '@ray-js/components';
|
|
5
7
|
import React from 'react';
|
|
@@ -8,12 +10,18 @@ export default function MessageRender(_ref) {
|
|
|
8
10
|
let {
|
|
9
11
|
message,
|
|
10
12
|
isLatestMessage,
|
|
11
|
-
side
|
|
13
|
+
side,
|
|
14
|
+
multSelect
|
|
12
15
|
} = _ref;
|
|
13
16
|
const {
|
|
14
17
|
id,
|
|
15
18
|
tiles
|
|
16
19
|
} = message;
|
|
20
|
+
const {
|
|
21
|
+
select = [],
|
|
22
|
+
onSelect = () => {},
|
|
23
|
+
show: showMultSelect = false
|
|
24
|
+
} = multSelect || {};
|
|
17
25
|
if (tiles.length === 0) {
|
|
18
26
|
return /*#__PURE__*/React.createElement(View, {
|
|
19
27
|
key: id,
|
|
@@ -22,6 +30,15 @@ export default function MessageRender(_ref) {
|
|
|
22
30
|
}
|
|
23
31
|
return /*#__PURE__*/React.createElement(View, {
|
|
24
32
|
key: id,
|
|
33
|
+
className: "t-agent-message-list-row-container "
|
|
34
|
+
}, showMultSelect && /*#__PURE__*/React.createElement(View, {
|
|
35
|
+
className: "t-agent-message-list-row-check"
|
|
36
|
+
}, /*#__PURE__*/React.createElement(View, {
|
|
37
|
+
className: "checkbox-container ".concat(select.includes(id) ? 'selected' : ''),
|
|
38
|
+
onClick: () => select.includes(id) ? onSelect([...select.filter(v => v !== id)]) : onSelect([...select, id])
|
|
39
|
+
}, /*#__PURE__*/React.createElement(View, {
|
|
40
|
+
className: "checkbox-check"
|
|
41
|
+
}))), /*#__PURE__*/React.createElement(View, {
|
|
25
42
|
className: "t-agent-message-list-row t-agent-message-list-row-".concat(side)
|
|
26
43
|
}, tiles.map(tile => {
|
|
27
44
|
return /*#__PURE__*/React.createElement(TileRender, {
|
|
@@ -31,5 +48,5 @@ export default function MessageRender(_ref) {
|
|
|
31
48
|
key: tile.id,
|
|
32
49
|
isLatestMessage: isLatestMessage
|
|
33
50
|
});
|
|
34
|
-
}));
|
|
51
|
+
})));
|
|
35
52
|
}
|
|
@@ -1,8 +1,19 @@
|
|
|
1
|
+
.t-agent-message-list-row-container {
|
|
2
|
+
display: flex;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.t-agent-message-list-row-check {
|
|
6
|
+
display: flex;
|
|
7
|
+
align-items: flex-end;
|
|
8
|
+
margin-bottom: calc(var(--t-agent-y-gap) + 24rpx);
|
|
9
|
+
margin-right: 28rpx;
|
|
10
|
+
}
|
|
11
|
+
|
|
1
12
|
.t-agent-message-list-row {
|
|
2
13
|
margin-bottom: var(--t-agent-y-gap);
|
|
3
14
|
display: flex;
|
|
4
15
|
flex-direction: column;
|
|
5
|
-
flex:
|
|
16
|
+
flex: 1 0 auto;
|
|
6
17
|
}
|
|
7
18
|
|
|
8
19
|
.t-agent-message-list-row-start {
|
|
@@ -12,3 +23,39 @@
|
|
|
12
23
|
.t-agent-message-list-row-end {
|
|
13
24
|
align-items: flex-end;
|
|
14
25
|
}
|
|
26
|
+
|
|
27
|
+
@checkbox-size: 40rpx;
|
|
28
|
+
@border-color: rgba(0, 0, 0, 0.3);
|
|
29
|
+
@active-color: #3678E3;
|
|
30
|
+
|
|
31
|
+
.checkbox-container {
|
|
32
|
+
position: relative;
|
|
33
|
+
width: @checkbox-size;
|
|
34
|
+
height: @checkbox-size;
|
|
35
|
+
border: 2rpx solid @border-color;
|
|
36
|
+
border-radius: 50%;
|
|
37
|
+
background: transparent;
|
|
38
|
+
cursor: pointer;
|
|
39
|
+
transition: all 0.2s ease-in-out;
|
|
40
|
+
|
|
41
|
+
&.selected {
|
|
42
|
+
background: @active-color;
|
|
43
|
+
border-color: transparent;
|
|
44
|
+
|
|
45
|
+
.checkbox-check {
|
|
46
|
+
opacity: 1;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.checkbox-check {
|
|
52
|
+
position: absolute;
|
|
53
|
+
top: 50%;
|
|
54
|
+
left: 50%;
|
|
55
|
+
transform: translate(-50%, -50%);
|
|
56
|
+
width: 24rpx;
|
|
57
|
+
height: 18rpx;
|
|
58
|
+
background-image: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMiIgaGVpZ2h0PSI5IiB2aWV3Qm94PSIwIDAgMTIgOSI+PHBhdGggZmlsbD0ibm9uZSIgc3Ryb2tlPSIjRkZGIiBzdHJva2Utd2lkdGg9IjIiIGQ9Ik0xIDRsMy43NSA0TDEwLjMgMSIvPjwvc3ZnPg==");
|
|
59
|
+
opacity: 0;
|
|
60
|
+
transition: opacity 0.2s ease-in-out;
|
|
61
|
+
}
|
|
@@ -4,7 +4,7 @@ const _excluded = ["src", "bizType"];
|
|
|
4
4
|
import "core-js/modules/web.dom-collections.iterator.js";
|
|
5
5
|
import React, { useMemo, useRef, useState } from 'react';
|
|
6
6
|
import { Image, View } from '@ray-js/ray';
|
|
7
|
-
import { getUrlByCloudKey, isLinkExpired, parseCloudKey, isFullLink } from '
|
|
7
|
+
import { getUrlByCloudKey, isLinkExpired, parseCloudKey, isFullLink } from '../utils/file';
|
|
8
8
|
import logger from '../logger';
|
|
9
9
|
const PrivateImage = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
10
10
|
const {
|
package/dist/cards/map.js
CHANGED
package/dist/contexts.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { ChatAgent, ChatMessageObject, UIPlugin } from '@ray-js/t-agent';
|
|
3
|
-
import { AssistantPlugin } from '@ray-js/t-agent-plugin-assistant';
|
|
4
3
|
import { RenderOptions, TileProps } from './types';
|
|
5
4
|
import { ChatSession } from '@ray-js/t-agent';
|
|
6
5
|
export declare const MessageContext: import("react").Context<{
|
|
@@ -9,7 +8,7 @@ export declare const MessageContext: import("react").Context<{
|
|
|
9
8
|
}>;
|
|
10
9
|
export declare const RenderContext: import("react").Context<RenderOptions>;
|
|
11
10
|
export type UIChatSession = Pick<ChatSession, 'get' | 'getData' | 'set' | 'sessionId'>;
|
|
12
|
-
export type UIChatAgent = Pick<ChatAgent<UIPlugin
|
|
11
|
+
export type UIChatAgent = Pick<ChatAgent<UIPlugin>, 'pushInputBlocks' | 'plugins' | 'emitTileEvent' | 'removeMessage'> & {
|
|
13
12
|
session: UIChatSession;
|
|
14
13
|
};
|
|
15
14
|
export declare const ChatAgentContext: import("react").Context<UIChatAgent>;
|
package/dist/contexts.js
CHANGED
|
@@ -7,6 +7,7 @@ export const RenderContext = /*#__PURE__*/createContext({
|
|
|
7
7
|
renderTileAs: () => null,
|
|
8
8
|
renderCustomBlockAs: () => null,
|
|
9
9
|
renderCardAs: () => null,
|
|
10
|
+
renderLongPressAs: () => null,
|
|
10
11
|
customBlockTypes: [],
|
|
11
12
|
customCardMap: {},
|
|
12
13
|
getStaticResourceBizType: () => '',
|
package/dist/hooks/index.d.ts
CHANGED
package/dist/hooks/index.js
CHANGED
|
@@ -6,7 +6,9 @@ export interface UploadFile {
|
|
|
6
6
|
url?: string;
|
|
7
7
|
thumbUrl?: string;
|
|
8
8
|
}
|
|
9
|
-
export declare function useAttachmentInput(
|
|
9
|
+
export declare function useAttachmentInput({ local }?: {
|
|
10
|
+
local: boolean;
|
|
11
|
+
}): {
|
|
10
12
|
blocks: InputBlock[];
|
|
11
13
|
uploaded: UploadFile[];
|
|
12
14
|
setUploaded: import("react").Dispatch<import("react").SetStateAction<UploadFile[]>>;
|