@king-design/vue 3.8.0-beta.0 → 3.8.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/__tests__/__snapshots__/Vue Next Demos.md +74 -74
- package/components/bubble/bubble.d.ts +1 -0
- package/components/bubble/bubble.vdt.js +6 -2
- package/components/bubble/index.spec.js +58 -5
- package/components/bubble/styles.js +1 -1
- package/components/bubble/useBubbleDisplay.d.ts +1 -0
- package/components/bubble/useBubbleDisplay.js +8 -0
- package/components/bubbleList/bubbleList.vdt.js +3 -1
- package/components/bubbleList/index.spec.js +301 -237
- package/components/bubbleList/styles.js +2 -2
- package/components/bubbleList/useBubbleList.js +7 -0
- package/components/fileCard/fileCard.vdt.js +4 -4
- package/components/fileCard/index.spec.js +179 -107
- package/components/fileCard/list.d.ts +2 -1
- package/components/fileCard/list.vdt.js +7 -5
- package/components/fileCard/styles.js +10 -8
- package/components/fileCard/useFileCard.d.ts +1 -1
- package/components/fileCard/useFileCard.js +6 -35
- package/components/media/index.spec.js +774 -585
- package/components/media/media.vdt.js +17 -6
- package/components/media/mediaAssets.d.ts +2 -0
- package/components/media/mediaAssets.js +4 -0
- package/components/media/styles.js +5 -3
- package/components/media/useMedia.d.ts +6 -2
- package/components/media/useMedia.js +28 -6
- package/components/sender/index.spec.js +1039 -435
- package/components/sender/sender.d.ts +27 -4
- package/components/sender/sender.js +16 -5
- package/components/sender/sender.vdt.js +121 -49
- package/components/sender/styles.js +18 -9
- package/components/sender/useAutoResize.js +6 -6
- package/components/sender/useSenderDrag.js +12 -3
- package/components/sender/useSenderInput.d.ts +3 -0
- package/components/sender/useSenderInput.js +20 -3
- package/components/sender/useSenderPaste.js +1 -1
- package/components/sender/useSenderUpload.js +38 -29
- package/components/xmarkdown/index.spec.js +370 -239
- package/components/xmarkdown/markdown/streaming.js +41 -8
- package/components/xmarkdown/styles.js +2 -2
- package/components/xmarkdown/useXMarkdownDisplay.d.ts +1 -0
- package/components/xmarkdown/useXMarkdownDisplay.js +9 -1
- package/components/xmarkdown/xmarkdown.d.ts +1 -0
- package/components/xmarkdown/xmarkdown.vdt.js +6 -2
- package/dist/i18n/en-US.js +1 -0
- package/dist/i18n/en-US.js.map +1 -1
- package/dist/i18n/en-US.min.js +1 -1
- package/dist/index.js +400 -193
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +2 -2
- package/i18n/en-US.d.ts +1 -0
- package/i18n/en-US.js +1 -0
- package/index.d.ts +2 -2
- package/index.js +2 -2
- package/package.json +1 -1
|
@@ -20,6 +20,9 @@ export function useSenderInput(textareaRef) {
|
|
|
20
20
|
function isDisabled() {
|
|
21
21
|
return !!instance.get('disabled');
|
|
22
22
|
}
|
|
23
|
+
function isInputDisabled() {
|
|
24
|
+
return isDisabled() || !!instance.get('inputDisabled');
|
|
25
|
+
}
|
|
23
26
|
function isGenerating() {
|
|
24
27
|
return !!instance.get('generating');
|
|
25
28
|
}
|
|
@@ -28,13 +31,22 @@ export function useSenderInput(textareaRef) {
|
|
|
28
31
|
}
|
|
29
32
|
/** 发送按钮的最终禁用态:业务强制 disabled 优先,其余按内容自动判定 */
|
|
30
33
|
function isSendButtonDisabled() {
|
|
31
|
-
if (isDisabled() || isLoading()) return true;
|
|
34
|
+
if (isDisabled() || isLoading() || instance.get('sendDisabled') || instance.get('inputDisabled')) return true;
|
|
35
|
+
if (isGenerating()) return false;
|
|
36
|
+
return isSendButtonAutoDisabled();
|
|
37
|
+
}
|
|
38
|
+
/** 生成中的停止按钮禁用态,独立于发送禁用态。 */
|
|
39
|
+
function isStopButtonDisabled() {
|
|
40
|
+
return isDisabled() || !!instance.get('stopDisabled');
|
|
41
|
+
}
|
|
42
|
+
function isSendDisabled() {
|
|
43
|
+
if (isDisabled() || isLoading() || instance.get('sendDisabled') || instance.get('inputDisabled')) return true;
|
|
32
44
|
if (isGenerating()) return false;
|
|
33
45
|
return isSendButtonAutoDisabled();
|
|
34
46
|
}
|
|
35
47
|
// 发送消息
|
|
36
48
|
function send() {
|
|
37
|
-
if (isGenerating() ||
|
|
49
|
+
if (isGenerating() || isSendDisabled()) return;
|
|
38
50
|
var value = getValueText();
|
|
39
51
|
var attachments = getCurrentAttachments();
|
|
40
52
|
instance.trigger('messageSend', {
|
|
@@ -50,10 +62,11 @@ export function useSenderInput(textareaRef) {
|
|
|
50
62
|
}
|
|
51
63
|
}
|
|
52
64
|
function stopGenerate() {
|
|
65
|
+
if (!isGenerating() || isStopButtonDisabled()) return;
|
|
53
66
|
instance.trigger('stopGenerate');
|
|
54
67
|
}
|
|
55
68
|
function handleKeydown(e) {
|
|
56
|
-
if (e.key !== 'Enter' || !instance.get('submitOnEnter') ||
|
|
69
|
+
if (e.key !== 'Enter' || !instance.get('submitOnEnter') || isInputDisabled() || instance.get('readonly')) return;
|
|
57
70
|
// Shift / 中文 IME 期间不触发提交
|
|
58
71
|
if (e.shiftKey || e.isComposing || e.keyCode === 229) return;
|
|
59
72
|
e.preventDefault();
|
|
@@ -62,6 +75,7 @@ export function useSenderInput(textareaRef) {
|
|
|
62
75
|
send();
|
|
63
76
|
}
|
|
64
77
|
function handleInput(e) {
|
|
78
|
+
if (isInputDisabled() || instance.get('readonly')) return;
|
|
65
79
|
var next = e.target.value;
|
|
66
80
|
instance.set('value', next);
|
|
67
81
|
}
|
|
@@ -83,9 +97,12 @@ export function useSenderInput(textareaRef) {
|
|
|
83
97
|
return {
|
|
84
98
|
isFocus: isFocus,
|
|
85
99
|
isDisabled: isDisabled,
|
|
100
|
+
isInputDisabled: isInputDisabled,
|
|
86
101
|
isGenerating: isGenerating,
|
|
87
102
|
isLoading: isLoading,
|
|
88
103
|
isSendButtonDisabled: isSendButtonDisabled,
|
|
104
|
+
isStopButtonDisabled: isStopButtonDisabled,
|
|
105
|
+
isSendDisabled: isSendDisabled,
|
|
89
106
|
send: send,
|
|
90
107
|
stopGenerate: stopGenerate,
|
|
91
108
|
handleKeydown: handleKeydown,
|
|
@@ -24,7 +24,7 @@ function getClipboardFiles(e) {
|
|
|
24
24
|
export function useSenderPaste(addFiles) {
|
|
25
25
|
var instance = useInstance();
|
|
26
26
|
function handlePaste(e) {
|
|
27
|
-
if (!instance.get('pasteFile') || instance.get('disabled') || instance.get('readonly')) return;
|
|
27
|
+
if (!instance.get('pasteFile') || instance.get('disabled') || instance.get('inputDisabled') || instance.get('readonly')) return;
|
|
28
28
|
var files = getClipboardFiles(e);
|
|
29
29
|
if (!files.length) return;
|
|
30
30
|
e.preventDefault();
|
|
@@ -23,8 +23,6 @@ import { _$ } from '../../i18n';
|
|
|
23
23
|
import { isFunction } from 'intact-shared';
|
|
24
24
|
// 用一个递增 id 给本地附件分配 key,与 Upload 组件保持一致策略。
|
|
25
25
|
var uid = 0;
|
|
26
|
-
// 视觉模型默认 accept;普通文本模式不限制。
|
|
27
|
-
var IMAGE_ACCEPT = 'image/*';
|
|
28
26
|
// 内置的「文件选择 + XHR 上传」逻辑。
|
|
29
27
|
// 不直接复用 Upload 内部 hook,因为它强依赖 useInstance() as Upload 的状态形状;
|
|
30
28
|
// 这里直接复用更底层的 request() 和上传约束规则,避免在 Sender 里渲染额外的 Upload 节点。
|
|
@@ -37,7 +35,6 @@ export function useSenderUpload(fileInputRef) {
|
|
|
37
35
|
var _getUploadProps = getUploadProps(),
|
|
38
36
|
accept = _getUploadProps.accept;
|
|
39
37
|
if (accept) return accept;
|
|
40
|
-
if (instance.get('type') === 'image') return IMAGE_ACCEPT;
|
|
41
38
|
return undefined;
|
|
42
39
|
}
|
|
43
40
|
function isMultiple() {
|
|
@@ -50,6 +47,9 @@ export function useSenderUpload(fileInputRef) {
|
|
|
50
47
|
function getAttachments() {
|
|
51
48
|
return instance.get('attachments') || [];
|
|
52
49
|
}
|
|
50
|
+
function isInputDisabled() {
|
|
51
|
+
return !!instance.get('disabled') || !!instance.get('inputDisabled');
|
|
52
|
+
}
|
|
53
53
|
function setAttachments(next) {
|
|
54
54
|
// 触发 change:attachments,配合 Vue v-model:attachments / React onChangeAttachments
|
|
55
55
|
instance.set('attachments', next);
|
|
@@ -187,13 +187,19 @@ export function useSenderUpload(fileInputRef) {
|
|
|
187
187
|
return _regeneratorRuntime.wrap(function _callee2$(_context5) {
|
|
188
188
|
while (1) switch (_context5.prev = _context5.next) {
|
|
189
189
|
case 0:
|
|
190
|
+
if (!isInputDisabled()) {
|
|
191
|
+
_context5.next = 2;
|
|
192
|
+
break;
|
|
193
|
+
}
|
|
194
|
+
return _context5.abrupt("return");
|
|
195
|
+
case 2:
|
|
190
196
|
props = getUploadProps();
|
|
191
197
|
accept = getAcceptAttr();
|
|
192
198
|
limit = props.limit, maxSize = props.maxSize, _props$autoUpload = props.autoUpload, autoUpload = _props$autoUpload === void 0 ? true : _props$autoUpload, beforeUpload = props.beforeUpload;
|
|
193
199
|
current = getAttachments();
|
|
194
200
|
incoming = _Array$from(fileList);
|
|
195
201
|
if (!(limit && current.length + incoming.length > limit)) {
|
|
196
|
-
_context5.next =
|
|
202
|
+
_context5.next = 11;
|
|
197
203
|
break;
|
|
198
204
|
}
|
|
199
205
|
err = new Error(_$('超出文件数量最大限制:{limit}', {
|
|
@@ -201,18 +207,18 @@ export function useSenderUpload(fileInputRef) {
|
|
|
201
207
|
}));
|
|
202
208
|
instance.trigger('uploadError', err, undefined);
|
|
203
209
|
return _context5.abrupt("return");
|
|
204
|
-
case
|
|
210
|
+
case 11:
|
|
205
211
|
next = _sliceInstanceProperty(current).call(current, 0); // 暂存待上传项,先一次性入列再异步发起请求,避免 UI 抖动
|
|
206
212
|
queued = [];
|
|
207
213
|
_iterator = _createForOfIteratorHelperLoose(incoming);
|
|
208
|
-
case
|
|
214
|
+
case 14:
|
|
209
215
|
if ((_step = _iterator()).done) {
|
|
210
|
-
_context5.next =
|
|
216
|
+
_context5.next = 29;
|
|
211
217
|
break;
|
|
212
218
|
}
|
|
213
219
|
file = _step.value;
|
|
214
220
|
if (!(maxSize && file.size > maxSize * 1024)) {
|
|
215
|
-
_context5.next =
|
|
221
|
+
_context5.next = 20;
|
|
216
222
|
break;
|
|
217
223
|
}
|
|
218
224
|
_err = new Error(_$('"{name}" 超出文件最大限制:{maxSize}kb', {
|
|
@@ -220,48 +226,48 @@ export function useSenderUpload(fileInputRef) {
|
|
|
220
226
|
maxSize: maxSize
|
|
221
227
|
}));
|
|
222
228
|
instance.trigger('uploadError', _err, undefined);
|
|
223
|
-
return _context5.abrupt("continue",
|
|
224
|
-
case
|
|
229
|
+
return _context5.abrupt("continue", 27);
|
|
230
|
+
case 20:
|
|
225
231
|
if (isAcceptValid(file, accept)) {
|
|
226
|
-
_context5.next =
|
|
232
|
+
_context5.next = 24;
|
|
227
233
|
break;
|
|
228
234
|
}
|
|
229
235
|
_err2 = new Error(_$('"{name}" 文件类型不合法', {
|
|
230
236
|
name: file.name
|
|
231
237
|
}));
|
|
232
238
|
instance.trigger('uploadError', _err2, undefined);
|
|
233
|
-
return _context5.abrupt("continue",
|
|
234
|
-
case
|
|
239
|
+
return _context5.abrupt("continue", 27);
|
|
240
|
+
case 24:
|
|
235
241
|
_item = makeAttachment(file);
|
|
236
242
|
queued.push(_item);
|
|
237
243
|
next.push(_item);
|
|
238
|
-
case 25:
|
|
239
|
-
_context5.next = 12;
|
|
240
|
-
break;
|
|
241
244
|
case 27:
|
|
245
|
+
_context5.next = 14;
|
|
246
|
+
break;
|
|
247
|
+
case 29:
|
|
242
248
|
setAttachments(next);
|
|
243
249
|
_i = 0, _queued = queued;
|
|
244
|
-
case
|
|
250
|
+
case 31:
|
|
245
251
|
if (!(_i < _queued.length)) {
|
|
246
|
-
_context5.next =
|
|
252
|
+
_context5.next = 44;
|
|
247
253
|
break;
|
|
248
254
|
}
|
|
249
255
|
item = _queued[_i];
|
|
250
256
|
if (!beforeUpload) {
|
|
251
|
-
_context5.next =
|
|
257
|
+
_context5.next = 40;
|
|
252
258
|
break;
|
|
253
259
|
}
|
|
254
|
-
_context5.next =
|
|
260
|
+
_context5.next = 36;
|
|
255
261
|
return beforeUpload(item, getAttachments());
|
|
256
|
-
case
|
|
262
|
+
case 36:
|
|
257
263
|
ok = _context5.sent;
|
|
258
264
|
if (ok) {
|
|
259
|
-
_context5.next =
|
|
265
|
+
_context5.next = 40;
|
|
260
266
|
break;
|
|
261
267
|
}
|
|
262
268
|
removeAttachment(item, false);
|
|
263
|
-
return _context5.abrupt("continue",
|
|
264
|
-
case
|
|
269
|
+
return _context5.abrupt("continue", 41);
|
|
270
|
+
case 40:
|
|
265
271
|
if (autoUpload) {
|
|
266
272
|
performUpload(item);
|
|
267
273
|
} else {
|
|
@@ -269,11 +275,11 @@ export function useSenderUpload(fileInputRef) {
|
|
|
269
275
|
status: 'default'
|
|
270
276
|
});
|
|
271
277
|
}
|
|
272
|
-
case
|
|
278
|
+
case 41:
|
|
273
279
|
_i++;
|
|
274
|
-
_context5.next =
|
|
280
|
+
_context5.next = 31;
|
|
275
281
|
break;
|
|
276
|
-
case
|
|
282
|
+
case 44:
|
|
277
283
|
case "end":
|
|
278
284
|
return _context5.stop();
|
|
279
285
|
}
|
|
@@ -372,7 +378,7 @@ export function useSenderUpload(fileInputRef) {
|
|
|
372
378
|
}
|
|
373
379
|
function onInputChange(e) {
|
|
374
380
|
var input = e.target;
|
|
375
|
-
if (input.files && input.files.length) {
|
|
381
|
+
if (!isInputDisabled() && input.files && input.files.length) {
|
|
376
382
|
addFiles(input.files);
|
|
377
383
|
}
|
|
378
384
|
input.value = '';
|
|
@@ -380,7 +386,10 @@ export function useSenderUpload(fileInputRef) {
|
|
|
380
386
|
/** 触发左下角 + 号按钮的文件选择 */
|
|
381
387
|
function pickFiles() {
|
|
382
388
|
var _fileInputRef$value;
|
|
383
|
-
if (
|
|
389
|
+
if (isInputDisabled()) return;
|
|
390
|
+
var _getUploadProps4 = getUploadProps(),
|
|
391
|
+
limit = _getUploadProps4.limit;
|
|
392
|
+
if (limit !== undefined && limit !== null && getAttachments().length >= Number(limit)) return;
|
|
384
393
|
(_fileInputRef$value = fileInputRef.value) == null || _fileInputRef$value.click();
|
|
385
394
|
}
|
|
386
395
|
return {
|